diff --git a/source/enet/Doxyfile b/source/enet/Doxyfile deleted file mode 100755 index 9636a041..00000000 --- a/source/enet/Doxyfile +++ /dev/null @@ -1,993 +0,0 @@ -# Doxyfile 1.2.18 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = enet - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = docs - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these class will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = NO - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower case letters. If set to YES upper case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are adviced to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = YES - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consist of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = . include/enet docs - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl - -FILE_PATTERNS = *.c *.h *.dox - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = Tests - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output dir. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non empty doxygen will try to run -# the html help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the Html help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, -# or Internet explorer 4.0+). Note that for large projects the tree generation -# can take a very long time. In such cases it is better to disable this feature. -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_XML = NO - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = FORCE_DOXYGEN - -# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tagfiles. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superceded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yield more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermedate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO - -# The CGI_NAME tag should be the name of the CGI script that -# starts the search engine (doxysearch) with the correct parameters. -# A script with this name will be generated by doxygen. - -CGI_NAME = search.cgi - -# The CGI_URL tag should be the absolute URL to the directory where the -# cgi binaries are located. See the documentation of your http daemon for -# details. - -CGI_URL = - -# The DOC_URL tag should be the absolute URL to the directory where the -# documentation is located. If left blank the absolute path to the -# documentation, with file:// prepended to it, will be used. - -DOC_URL = - -# The DOC_ABSPATH tag should be the absolute path to the directory where the -# documentation is located. If left blank the directory on the local machine -# will be used. - -DOC_ABSPATH = - -# The BIN_ABSPATH tag must point to the directory where the doxysearch binary -# is installed. - -BIN_ABSPATH = /usr/local/bin/ - -# The EXT_DOC_PATHS tag can be used to specify one or more paths to -# documentation generated for other projects. This allows doxysearch to search -# the documentation for these projects as well. - -EXT_DOC_PATHS = diff --git a/source/enet/LICENSE b/source/enet/LICENSE deleted file mode 100755 index e9b9895e..00000000 --- a/source/enet/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2002 Lee Salzman - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/source/enet/Makefile b/source/enet/Makefile deleted file mode 100644 index 26055321..00000000 --- a/source/enet/Makefile +++ /dev/null @@ -1,656 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# Makefile. Generated from Makefile.in by configure. - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - - -srcdir = . -top_srcdir = . - -pkgdatadir = $(datadir)/libenet.a -pkglibdir = $(libdir)/libenet.a -pkgincludedir = $(includedir)/libenet.a -top_builddir = . -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = /usr/bin/install -c -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/configure config.guess \ - config.sub depcomp install-sh missing mkinstalldirs -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno configure.status.lineno -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(libdir)" -libLIBRARIES_INSTALL = $(INSTALL_DATA) -LIBRARIES = $(lib_LIBRARIES) -AR = ar -ARFLAGS = cru -libenet_a_AR = $(AR) $(ARFLAGS) -libenet_a_LIBADD = -am_libenet_a_OBJECTS = host.$(OBJEXT) list.$(OBJEXT) \ - callbacks.$(OBJEXT) packet.$(OBJEXT) peer.$(OBJEXT) \ - protocol.$(OBJEXT) unix.$(OBJEXT) win32.$(OBJEXT) -libenet_a_OBJECTS = $(am_libenet_a_OBJECTS) -DEFAULT_INCLUDES = -I. -I$(srcdir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libenet_a_SOURCES) -DIST_SOURCES = $(libenet_a_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = aclocal-1.9 -AMDEP_FALSE = # -AMDEP_TRUE = -AMTAR = tar -AUTOCONF = autoconf -AUTOHEADER = autoheader -AUTOMAKE = automake-1.9 -AWK = gawk -CC = gcc -CCDEPMODE = depmode=gcc3 -CFLAGS = -g -O2 -CPP = gcc -E -CPPFLAGS = -CYGPATH_W = echo -DEFS = -DPACKAGE_NAME=\"libenet\" -DPACKAGE_TARNAME=\"libenet\" -DPACKAGE_VERSION=\"10-31-2006\" -DPACKAGE_STRING=\"libenet\ 10-31-2006\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libenet.a\" -DVERSION=\"10-31-2006\" -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_SOCKLEN_T=1 -DEPDIR = .deps -ECHO_C = -ECHO_N = -n -ECHO_T = -EGREP = /bin/grep -E -EXEEXT = -GREP = /bin/grep -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_PROGRAM = ${INSTALL} -INSTALL_SCRIPT = ${INSTALL} -INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s -LDFLAGS = -LIBOBJS = -LIBS = -LTLIBOBJS = -MAKEINFO = makeinfo -OBJEXT = o -PACKAGE = libenet.a -PACKAGE_BUGREPORT = -PACKAGE_NAME = libenet -PACKAGE_STRING = libenet 10-31-2006 -PACKAGE_TARNAME = libenet -PACKAGE_VERSION = 10-31-2006 -PATH_SEPARATOR = : -RANLIB = ranlib -SET_MAKE = -SHELL = /bin/sh -STRIP = -VERSION = 10-31-2006 -ac_ct_CC = gcc -am__fastdepCC_FALSE = # -am__fastdepCC_TRUE = -am__include = include -am__leading_dot = . -am__quote = -am__tar = ${AMTAR} chof - "$$tardir" -am__untar = ${AMTAR} xf - -bindir = ${exec_prefix}/bin -build_alias = -datadir = ${datarootdir} -datarootdir = ${prefix}/share -docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} -dvidir = ${docdir} -exec_prefix = ${prefix} -host_alias = -htmldir = ${docdir} -includedir = ${prefix}/include -infodir = ${datarootdir}/info -install_sh = /home/lee/ac/ac/source/enet/install-sh -libdir = ${exec_prefix}/lib -libexecdir = ${exec_prefix}/libexec -localedir = ${datarootdir}/locale -localstatedir = ${prefix}/var -mandir = ${datarootdir}/man -mkdir_p = mkdir -p -- -oldincludedir = /usr/include -pdfdir = ${docdir} -prefix = /usr/local -program_transform_name = s,x,x, -psdir = ${docdir} -sbindir = ${exec_prefix}/sbin -sharedstatedir = ${prefix}/com -sysconfdir = ${prefix}/etc -target_alias = -lib_LIBRARIES = libenet.a -libenet_a_SOURCES = host.c list.c callbacks.c packet.c peer.c protocol.c unix.c win32.c -INCLUDES = -Iinclude/ -SUBDIRS = include -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .o .obj -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ - cd $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -install-libLIBRARIES: $(lib_LIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f=$(am__strip_dir) \ - echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ - else :; fi; \ - done - @$(POST_INSTALL) - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - p=$(am__strip_dir) \ - echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \ - $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \ - else :; fi; \ - done - -uninstall-libLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - p=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - rm -f "$(DESTDIR)$(libdir)/$$p"; \ - done - -clean-libLIBRARIES: - -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) -libenet.a: $(libenet_a_OBJECTS) $(libenet_a_DEPENDENCIES) - -rm -f libenet.a - $(libenet_a_AR) libenet.a $(libenet_a_OBJECTS) $(libenet_a_LIBADD) - $(RANLIB) libenet.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -include ./$(DEPDIR)/callbacks.Po -include ./$(DEPDIR)/host.Po -include ./$(DEPDIR)/list.Po -include ./$(DEPDIR)/packet.Po -include ./$(DEPDIR)/peer.Po -include ./$(DEPDIR)/protocol.Po -include ./$(DEPDIR)/unix.Po -include ./$(DEPDIR)/win32.Po - -.c.o: - if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ - then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -# source='$<' object='$@' libtool=no \ -# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ -# $(COMPILE) -c $< - -.c.obj: - if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ - then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -# source='$<' object='$@' libtool=no \ -# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ -# $(COMPILE) -c `$(CYGPATH_W) '$<'` -uninstall-info-am: - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - mkdir $(distdir) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(mkdir_p) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(LIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(libdir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-exec-am: install-libLIBRARIES - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-info-am uninstall-libLIBRARIES - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ - check-am clean clean-generic clean-libLIBRARIES \ - clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ - dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-compile distclean-generic distclean-recursive \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-libLIBRARIES install-man \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am uninstall-info-am \ - uninstall-libLIBRARIES - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/Makefile.am b/source/enet/Makefile.am deleted file mode 100755 index 5b9caf30..00000000 --- a/source/enet/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -lib_LIBRARIES = libenet.a -libenet_a_SOURCES = host.c list.c callbacks.c packet.c peer.c protocol.c unix.c win32.c -INCLUDES = -Iinclude/ - -SUBDIRS = include diff --git a/source/enet/Makefile.in b/source/enet/Makefile.in deleted file mode 100755 index 0ba2d8f0..00000000 --- a/source/enet/Makefile.in +++ /dev/null @@ -1,656 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = . -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/configure config.guess \ - config.sub depcomp install-sh missing mkinstalldirs -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno configure.status.lineno -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(libdir)" -libLIBRARIES_INSTALL = $(INSTALL_DATA) -LIBRARIES = $(lib_LIBRARIES) -AR = ar -ARFLAGS = cru -libenet_a_AR = $(AR) $(ARFLAGS) -libenet_a_LIBADD = -am_libenet_a_OBJECTS = host.$(OBJEXT) list.$(OBJEXT) \ - callbacks.$(OBJEXT) packet.$(OBJEXT) peer.$(OBJEXT) \ - protocol.$(OBJEXT) unix.$(OBJEXT) win32.$(OBJEXT) -libenet_a_OBJECTS = $(am_libenet_a_OBJECTS) -DEFAULT_INCLUDES = -I. -I$(srcdir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libenet_a_SOURCES) -DIST_SOURCES = $(libenet_a_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -lib_LIBRARIES = libenet.a -libenet_a_SOURCES = host.c list.c callbacks.c packet.c peer.c protocol.c unix.c win32.c -INCLUDES = -Iinclude/ -SUBDIRS = include -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .o .obj -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ - cd $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -install-libLIBRARIES: $(lib_LIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f=$(am__strip_dir) \ - echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ - else :; fi; \ - done - @$(POST_INSTALL) - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - p=$(am__strip_dir) \ - echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \ - $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \ - else :; fi; \ - done - -uninstall-libLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LIBRARIES)'; for p in $$list; do \ - p=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - rm -f "$(DESTDIR)$(libdir)/$$p"; \ - done - -clean-libLIBRARIES: - -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) -libenet.a: $(libenet_a_OBJECTS) $(libenet_a_DEPENDENCIES) - -rm -f libenet.a - $(libenet_a_AR) libenet.a $(libenet_a_OBJECTS) $(libenet_a_LIBADD) - $(RANLIB) libenet.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callbacks.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/host.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/win32.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -uninstall-info-am: - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - mkdir $(distdir) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(mkdir_p) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(LIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(libdir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-exec-am: install-libLIBRARIES - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-info-am uninstall-libLIBRARIES - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ - check-am clean clean-generic clean-libLIBRARIES \ - clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ - dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-compile distclean-generic distclean-recursive \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-libLIBRARIES install-man \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am uninstall-info-am \ - uninstall-libLIBRARIES - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/README b/source/enet/README deleted file mode 100755 index 58fa33fe..00000000 --- a/source/enet/README +++ /dev/null @@ -1,16 +0,0 @@ -Please visit the ENet homepage at http://enet.bespin.org for installation -and usage instructions. - -If you obtained this package from CVS, the quick description on how to build -is: - -# Generate the build system. - -aclocal && automake -a -c --foreign && autoconf - -# Compile and install the library. - -./configure && make && make install - -See pyenet/readme.txt for further information on Ling Lo's Python wrapper for -ENet. diff --git a/source/enet/aclocal.m4 b/source/enet/aclocal.m4 deleted file mode 100755 index aef181a6..00000000 --- a/source/enet/aclocal.m4 +++ /dev/null @@ -1,850 +0,0 @@ -# generated automatically by aclocal 1.9.6 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION so it can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.9.6])]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 7 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE]) -AC_SUBST([$1_FALSE]) -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH]) -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 3 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 12 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.58])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AM_PROG_INSTALL_SH -AM_PROG_INSTALL_STRIP -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -]) -]) - - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $1 | $1:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"$am_aux_dir/install-sh"} -AC_SUBST(install_sh)]) - -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. -# -# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories -# created by `make install' are always world readable, even if the -# installer happens to have an overly restrictive umask (e.g. 077). -# This was a mistake. There are at least two reasons why we must not -# use `-m 0755': -# - it causes special bits like SGID to be ignored, -# - it may be too restrictive (some setups expect 775 directories). -# -# Do not use -m 0755 and let people choose whatever they expect by -# setting umask. -# -# We cannot accept any implementation of `mkdir' that recognizes `-p'. -# Some implementations (such as Solaris 8's) are not thread-safe: if a -# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' -# concurrently, both version can detect that a/ is missing, but only -# one can create it and the other will error out. Consequently we -# restrict ourselves to GNU make (using the --version option ensures -# this.) -AC_DEFUN([AM_PROG_MKDIR_P], -[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi -AC_SUBST([mkdir_p])]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# ------------------------------ -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir - -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - diff --git a/source/enet/api.txt b/source/enet/api.txt deleted file mode 100755 index ddde9b13..00000000 --- a/source/enet/api.txt +++ /dev/null @@ -1,290 +0,0 @@ -enet.h - The file that should be included to use the ENet API. - -enet_uint8 - unsigned 8 bit integer -enet_uint16 - unsigned 16 bit integer -enet_uint32 - unsigned 32 bit integer - -typedef struct -{ - enet_uint32 host; - enet_uint16 port; -} ENetAddress; - - Portable internet address structure. The host must be specified in network -byte-order, and the port must be in host byte-order. The constant ENET_HOST_ANY -may be used to specify the default server host. - -typedef struct -{ - enet_uint32 flags; - enet_uint8 * data; - size_t dataLength; -} ENetPacket; - - An ENet data packet that may be sent to or received from a peer. The shown fields -should only be read and never modified. The data field contains the allocated data -for the packet. The dataLength fields specifies the length of the allocated data. -The flags field is either 0 (specifying no flags), or a bitwise-or of any -combination of the following flags: - - ENET_PACKET_FLAG_RELIABLE - - - Specifies that the packet must be received by the target peer and that resend - attempts should be made should delivery of the packet fail. - -typedef struct -{ - ENetAddress address; - void * data; - size_t channelCount; - enet_uint32 incomingBandwidth; - enet_uint32 outgoingBandwidth; - enet_uint32 roundTripTime; - enet_uint32 packetLoss; -} ENetPeer; - - An ENet peer which data packets may be sent or received from. No fields should be -modified unless otherwise specified. The address field contains the internet address -of the peer. The data fields may be used to associate any desired data with the peer -and may be freely modified. The channelCount field tells the number of channels that -have been allocated for use to communnicate with the peer. The incomingBandwidth field -specifies the downstream bandwidth of the client in bytes per second. The -outgoingBandwidth field specifies the upstream bandwidth of the client in bytes per -second. The roundTripTime field tells the mean round trip time from the sending of -a reliable packet until the receipt of its acknowledgement in milliseconds. The -packetLoss field tells the mean packet loss of reliable packets as a ratio with -respect to the constant ENET_PEER_PACKET_LOSS_SCALE. - -typedef enum -{ - ENET_EVENT_TYPE_NONE, - ENET_EVENT_TYPE_CONNECT, - ENET_EVENT_TYPE_DISCONNECT, - ENET_EVENT_TYPE_RECEIVE -} ENetEventType; - -typedef struct _ENetEvent -{ - ENetEventType type; - ENetPeer * peer; - enet_uint8 channelID; - ENetPacket * packet; -} ENetEvent; - - An ENet event as returned by enet_host_service. The type field contains the type -of the event, which may be any one of the following: - - ENET_EVENT_TYPE_NONE - No event occurred within the specified time limit. - ENET_EVENT_TYPE_CONNECT - - - A connection request initiated by enet_host_connect has completed. The peer field - contains the peer which successfully connected. - - ENET_EVENT_TYPE_DISCONNECT - - - A peer has disconnected. This event is generated on successful completion of a - disconnect iniated by enet_peer_disconnect, if a peer has timed out, or if a - connection request initialized by enet_host_connect has timed out. The peer field - contains the peer which disconnected. - - ENET_EVENT_TYPE_RECEIVE - - - A packet has been received from a peer. The peer field specifies the peer which - send the packet. The channelID field specifies the channel number upon which the - packet was received. The packet field contains the packet that was destroyed; this - packet must be destroyed with enet_packet_destroy after use. - -typedef struct -{ - ENetAddress address; - enet_uint32 incomingBandwidth; - enet_uint32 outgoingBandwidth; - ENetPeer * peers; - size_t peerCount; -} ENetHost; - - An ENet host for communicating with peers. No fields should be modified. The address -field tells the internet address of the host. The incomingBandwidth field tells the downstream -bandwidth of the host. The outgoingBandwidth field specifies the upstream bandwidth of the host. -The peers field contains an array of the peers that have been allocated for this host. The -peerCount field specifies the number of peers that have been allocated for this host. - -unsigned ENET_HOST_TO_NET_8 (unsigned); -unsigned ENET_HOST_TO_NET_16 (unsigned); -unsigned ENET_HOST_TO_NET_32 (unsigned); - - Macros that convert from host byte-order to network byte-order (big -endian) for unsigned integers of 8 bits, 16 bits, and 32 bits repectively. - -unsigned ENET_NET_TO_HOST_8 (unsigned); -unsigned ENET_NET_TO_HOST_16 (unsigned); -unsigned ENET_NET_TO_HOST_32 (unsigned); - - Macros that convert from network byte-order (big endian) to host -byte-order for unsigned integers of 8 bits, 16 bits, and 32 bits repectively. - -enet_uint32 enet_time_get (void); - - Returns the wall-time in milliseconds. Its initial value is unspecified unless -otherwise set. - -void enet_time_set (enet_uint32); - - Sets the current wall-time in milliseconds. - -int enet_initialize (void); - - Initialize ENet for use. Must be called prior to using any functions in ENet. -Returns 0 on success and -1 on failure. - -void enet_deinitialize (void); - - Clean-up ENet after use. Should be called when a program that has initialized -and used ENet exits. - -int enet_address_set_host (ENetAddress * address, const char * hostName); - - Attempts to resolve the host named by the parameter hostName and sets the host -field in the address parameter if successful. Returns 0 on success and -1 on -failure. - -int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength); - - Attempts to do a reverse lookup of the host field in the address parameter. -If successful, the name of the host is placed in the string described by -hostName and nameLength. The host name is always null-delimited and will -not exceed nameLength in length. Returns 0 on success and -1 on failure. - -ENetPacket * enet_packet_create (const void * dataContents, size_t dataLength, enet_uint32 flags); - - Creates a packet that may be sent to a peer. The dataContents parameter -specifies the initial contents of the packet's data; the packet's data will -remain uninitialized if dataContents is NULL. The dataLength parameter specifies -the size of the data that is allocated for this packet. The flags parameter -specifies flags for this packet as described for the ENetPacket structure. -Returns the packet on success and NULL on failure. - -void enet_packet_destroy (ENetPacket * packet); - - Destroys the packet and deallocates its data. - -int enet_packet_resize (ENetPacket * packet, size_t dataLength); - - Attempts to resize the data in the packet to the length specified in the -dataLength parameter. Returns 0 on success and -1 on failure. - -ENetHost * enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth); - - Creates a host for communicating with peers. The address parameter specifies -the address at which other peers may connect to this host; if the address parameter -is NULL, then no peers may connect to the host. The peerCount parameter specifies -the numbers of peers that should be allocated for the host; this limits the maximum -number of peers that may connect to this host to peerCount. The incomingBandwidth -parameter specifies the downstream bandwidth of the host in bytes per second; if -the incomingBandwidth parameter is 0, ENet will assume the host has unlimited -downstream bandwidth. The outgoingBandwidth parameter specifies the upstream bandwidth -of the host in bytes per second; if the outgoingBandwidth parameter is 0, ENet will -assume the host has unlimited upstream bandwidth. ENet will strategically drop packets -on specific sides of a connection between hosts to ensure the host's bandwidth is not -overwhelmed; the bandwidth parameters also determine the window size of a connection -which limits the amount of reliable packets that may be in transit at any given time. -Returns the host on success and NULL on failure. - -void enet_host_destroy (ENetHost * host); - - Destroys the host and all resources associated with it. - -ENetPeer * enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelCount); - - Initiates a connection from the host specified in the host parameter to a foreign -host whose internet address is specified by the address parameter. The channelCount -parameter specifies the number of channels that should be allocated for communicating -with the foreign host. Returns a peer representing the foreign host on success and NULL -on failure. The peer returned will have not completed the connection until enet_host_service -notifies of an ENET_EVENT_TYPE_CONNECT event for the peer. - -int enet_host_service (ENetHost * host, ENetEvent * event, enet_uint32 timeout); - - Waits for events on the host specified by the host parameters and shuttles packets -between the host and its peers. The event parameter specifies an event structure -where event details will be placed if one occurs. The timeout field specifies an -amount of time in milliseconds that ENet should wait for events. Returns 1 if an -event occured within the specified time limit, 0 if no event occurred within the -time limit, and -1 on failure. This function must be called frequently for adequate -performance. - -void enet_host_flush (ENetHost * host); - - Sends out any queued packets on the host specified in the host parameters to -the designated peers. This function need only be used in circumstances where one -wishes to send queued packets earlier than in a call to enet_host_service. - -void enet_host_broadcast (ENetHost * host, enet_uint8 channelID, ENetPacket * packet); - - Queues a packet to be sent to all peers on the host specified in the host parameter -over the channel number identified by the channelID parameter. - -void enet_host_bandwidth_limit (ENetHost * host, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth); - - Adjusts the bandwidth limits of the host specified in the host parameter. The -incomingBandwidth and outgoingBandwidth parameters are as specified in a call to -enet_host_create. - -int enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet); - - Queues a packet to be sent to the peer specified by the peer parameter over the -channel number identified by the channelID parameter. Returns 0 on success and -1 -on failure. - -ENetPacket * enet_peer_receive (ENetPeer * peer, enet_uint8 channelID); - - Attempts to dequeue any incoming queued packets on the peer specified by the peer -parameter on the channel number identified by the channelID parameter. Returns a packet -if one is available and NULL if there are no available incoming queued packets. - -void enet_peer_ping (ENetPeer * peer); - - Sends a ping request to the peer specified by the peer parameter. Ping requests factor -into the mean round trip time as designated by the roundTripTime field in the ENetPeer -structure. ENet automatically pings all connected peer at an interval, however, this -function may be called to ensure more frequent ping requests. - -void enet_peer_reset (ENetPeer * peer); - - Forcefully disconnects the peer specified by the peer parameter. The foreign host -represented by the peer is not notified of the disconnection and so will timeout on its -connection to the local host. - -void enet_peer_disconnect (ENetPeer * peer); - - Request a disconnection from the peer specified by the peer parameter. An -ENET_EVENT_DISCONNECT event will be generated by enet_host_service once the -disconnection is complete. - -void enet_peer_throttle_configure (ENetPeer * peer, enet_uint32 interval, enet_uint32 acceleration, enet_uint32 deceleration); - - Configures throttle parameter for the peer specified by the peer parameter. -Unreliable packets are dropped by ENet in response to the varying conditions of -the internet connection to the peer. The throttle represents a probability that -an unreliable packet should not be dropped and thus sent by ENet to the peer. -The lowest mean round trip time from the sending of a reliable packet to the -receipt of its acknowledgement is measured over an amount of time specified -by the interval parameter in milliseconds; the constant ENET_PEER_PACKET_THROTTLE_INTERVAL -is the default value for this parameter. If a measured round trip time happens -to be signifigantly less than the mean round trip time measured over the interval, -then the throttle probability is increased to allow more traffic by an amount -specified in the acceleration parameter which is in ratio to the -ENET_PEER_PACKET_THROTTLE_SCALE constant. If a measured round trip time happens -to be signifigantly greater than the mean round trip time measured over the interval, -then the throttle probability is decreased to limit traffic by an amount specified -in the deceleration parameter which is in ratio to the ENET_PEER_PACKET_THROTTLE_SCALE -constant. When the throttle has a value of ENET_PEER_PACKET_THROTTLE_SCALE, no unreliable -packets are dropped by ENET, and so 100% of all unreliable packets will be sent. When the -throttle has a value of 0, all unreliable packets are dropped by ENet, and so 0% of all -unreliable packets will be sent. Intermediate values for the throttle represent intermediate -probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits -of the local and foreign host are taken into account to determine a sensible limit for -the throttle probability above which it should not raise even in the best of conditions. - - - diff --git a/source/enet/callbacks.c b/source/enet/callbacks.c deleted file mode 100644 index 7f960af3..00000000 --- a/source/enet/callbacks.c +++ /dev/null @@ -1,53 +0,0 @@ -/** - @file callbacks.c - @brief ENet callback functions -*/ -#define ENET_BUILDING_LIB 1 -#include "enet/enet.h" - -static ENetCallbacks callbacks = { malloc, free, rand }; - -int -enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits) -{ - if (version != ENET_VERSION) - return -1; - - if (inits -> malloc != NULL || inits -> free != NULL) - { - if (inits -> malloc == NULL || inits -> free == NULL) - return -1; - - callbacks.malloc = inits -> malloc; - callbacks.free = inits -> free; - } - - if (inits -> rand != NULL) - callbacks.rand = inits -> rand; - - return enet_initialize (); -} - -void * -enet_malloc (size_t size) -{ - void * memory = callbacks.malloc (size); - - if (memory == NULL) - abort (); - - return memory; -} - -void -enet_free (void * memory) -{ - callbacks.free (memory); -} - -int -enet_rand (void) -{ - return callbacks.rand (); -} - diff --git a/source/enet/config.guess b/source/enet/config.guess deleted file mode 100644 index 77c7cbab..00000000 --- a/source/enet/config.guess +++ /dev/null @@ -1,1441 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -timestamp='2004-08-13' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit 0 ;; - macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit 0 ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms && exit 0 ;; - I*) echo ia64-dec-vms && exit 0 ;; - V*) echo vax-dec-vms && exit 0 ;; - esac -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source/enet/config.log b/source/enet/config.log deleted file mode 100755 index a481f727..00000000 --- a/source/enet/config.log +++ /dev/null @@ -1,411 +0,0 @@ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by libenet configure 10-31-2006, which was -generated by GNU Autoconf 2.60a. Invocation command line was - - $ ./configure - -## --------- ## -## Platform. ## -## --------- ## - -hostname = fweep -uname -m = i686 -uname -r = 2.6.16-2-k7 -uname -s = Linux -uname -v = #1 Fri Aug 18 19:48:42 UTC 2006 - -/usr/bin/uname -p = unknown -/bin/uname -X = unknown - -/bin/arch = i686 -/usr/bin/arch -k = unknown -/usr/convex/getsysinfo = unknown -/usr/bin/hostinfo = unknown -/bin/machine = unknown -/usr/bin/oslevel = unknown -/bin/universe = unknown - -PATH: /usr/local/bin -PATH: /usr/bin -PATH: /bin -PATH: /usr/bin/X11 -PATH: /usr/games - - -## ----------- ## -## Core tests. ## -## ----------- ## - -configure:1716: checking for a BSD-compatible install -configure:1772: result: /usr/bin/install -c -configure:1783: checking whether build environment is sane -configure:1826: result: yes -configure:1850: WARNING: `missing' script is too old or missing -configure:1891: checking for gawk -configure:1907: found /usr/bin/gawk -configure:1918: result: gawk -configure:1929: checking whether make sets $(MAKE) -configure:1950: result: yes -configure:2183: checking for gcc -configure:2199: found /usr/bin/gcc -configure:2210: result: gcc -configure:2448: checking for C compiler version -configure:2455: gcc --version >&5 -gcc (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13) -Copyright (C) 2006 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -configure:2458: $? = 0 -configure:2465: gcc -v >&5 -Using built-in specs. -Target: i486-linux-gnu -Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu -Thread model: posix -gcc version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13) -configure:2468: $? = 0 -configure:2475: gcc -V >&5 -gcc: '-V' option must have argument -configure:2478: $? = 1 -configure:2501: checking for C compiler default output file name -configure:2528: gcc conftest.c >&5 -configure:2531: $? = 0 -configure:2569: result: a.out -configure:2586: checking whether the C compiler works -configure:2596: ./a.out -configure:2599: $? = 0 -configure:2616: result: yes -configure:2623: checking whether we are cross compiling -configure:2625: result: no -configure:2628: checking for suffix of executables -configure:2635: gcc -o conftest conftest.c >&5 -configure:2638: $? = 0 -configure:2662: result: -configure:2668: checking for suffix of object files -configure:2694: gcc -c conftest.c >&5 -configure:2697: $? = 0 -configure:2720: result: o -configure:2724: checking whether we are using the GNU C compiler -configure:2753: gcc -c conftest.c >&5 -configure:2759: $? = 0 -configure:2766: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:2769: $? = 0 -configure:2776: test -s conftest.o -configure:2779: $? = 0 -configure:2793: result: yes -configure:2798: checking whether gcc accepts -g -configure:2828: gcc -c -g conftest.c >&5 -configure:2834: $? = 0 -configure:2841: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:2844: $? = 0 -configure:2851: test -s conftest.o -configure:2854: $? = 0 -configure:2984: result: yes -configure:3001: checking for gcc option to accept ISO C89 -configure:3075: gcc -c -g -O2 conftest.c >&5 -configure:3081: $? = 0 -configure:3088: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3091: $? = 0 -configure:3098: test -s conftest.o -configure:3101: $? = 0 -configure:3121: result: none needed -configure:3150: checking for style of include used by make -configure:3178: result: GNU -configure:3206: checking dependency style of gcc -configure:3296: result: gcc3 -configure:3356: checking for ranlib -configure:3372: found /usr/bin/ranlib -configure:3383: result: ranlib -configure:3411: checking for gethostbyaddr_r -configure:3467: gcc -o conftest -g -O2 conftest.c >&5 -configure:3473: $? = 0 -configure:3480: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3483: $? = 0 -configure:3490: test -s conftest -configure:3493: $? = 0 -configure:3506: result: yes -configure:3515: checking for gethostbyname_r -configure:3571: gcc -o conftest -g -O2 conftest.c >&5 -configure:3577: $? = 0 -configure:3584: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3587: $? = 0 -configure:3594: test -s conftest -configure:3597: $? = 0 -configure:3610: result: yes -configure:3619: checking for poll -configure:3675: gcc -o conftest -g -O2 conftest.c >&5 -configure:3681: $? = 0 -configure:3688: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3691: $? = 0 -configure:3698: test -s conftest -configure:3701: $? = 0 -configure:3714: result: yes -configure:3723: checking for fcntl -configure:3779: gcc -o conftest -g -O2 conftest.c >&5 -configure:3785: $? = 0 -configure:3792: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3795: $? = 0 -configure:3802: test -s conftest -configure:3805: $? = 0 -configure:3818: result: yes -configure:3827: checking for inet_pton -configure:3883: gcc -o conftest -g -O2 conftest.c >&5 -configure:3889: $? = 0 -configure:3896: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:3899: $? = 0 -configure:3906: test -s conftest -configure:3909: $? = 0 -configure:3922: result: yes -configure:3931: checking for inet_ntop -configure:3987: gcc -o conftest -g -O2 conftest.c >&5 -configure:3993: $? = 0 -configure:4000: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:4003: $? = 0 -configure:4010: test -s conftest -configure:4013: $? = 0 -configure:4026: result: yes -configure:4036: checking for struct msghdr.msg_flags -configure:4065: gcc -c -g -O2 conftest.c >&5 -configure:4071: $? = 0 -configure:4078: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:4081: $? = 0 -configure:4088: test -s conftest.o -configure:4091: $? = 0 -configure:4163: result: yes -configure:4173: checking for socklen_t -configure:4206: gcc -c -g -O2 conftest.c >&5 -configure:4212: $? = 0 -configure:4219: test -z "$ac_c_werror_flag" || test ! -s conftest.err -configure:4222: $? = 0 -configure:4229: test -s conftest.o -configure:4232: $? = 0 -configure:4244: result: yes -configure:4259: checking how to run the C preprocessor -configure:4299: gcc -E conftest.c -configure:4305: $? = 0 -configure:4343: gcc -E conftest.c -conftest.c:18:28: error: ac_nonexistent.h: No such file or directory -configure:4349: $? = 1 -configure: failed program was: -| /* confdefs.h. */ -| #define PACKAGE_NAME "libenet" -| #define PACKAGE_TARNAME "libenet" -| #define PACKAGE_VERSION "10-31-2006" -| #define PACKAGE_STRING "libenet 10-31-2006" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE "libenet.a" -| #define VERSION "10-31-2006" -| #define HAS_GETHOSTBYADDR_R 1 -| #define HAS_GETHOSTBYNAME_R 1 -| #define HAS_POLL 1 -| #define HAS_FCNTL 1 -| #define HAS_INET_PTON 1 -| #define HAS_INET_NTOP 1 -| #define HAS_MSGHDR_FLAGS 1 -| #define HAS_SOCKLEN_T 1 -| /* end confdefs.h. */ -| #include -configure:4389: result: gcc -E -configure:4418: gcc -E conftest.c -configure:4424: $? = 0 -configure:4462: gcc -E conftest.c -conftest.c:18:28: error: ac_nonexistent.h: No such file or directory -configure:4468: $? = 1 -configure: failed program was: -| /* confdefs.h. */ -| #define PACKAGE_NAME "libenet" -| #define PACKAGE_TARNAME "libenet" -| #define PACKAGE_VERSION "10-31-2006" -| #define PACKAGE_STRING "libenet 10-31-2006" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE "libenet.a" -| #define VERSION "10-31-2006" -| #define HAS_GETHOSTBYADDR_R 1 -| #define HAS_GETHOSTBYNAME_R 1 -| #define HAS_POLL 1 -| #define HAS_FCNTL 1 -| #define HAS_INET_PTON 1 -| #define HAS_INET_NTOP 1 -| #define HAS_MSGHDR_FLAGS 1 -| #define HAS_SOCKLEN_T 1 -| /* end confdefs.h. */ -| #include -configure:4513: checking for grep that handles long lines and -e -configure:4587: result: /bin/grep -configure:4592: checking for egrep -configure:4670: result: /bin/grep -E -conftest.c:18:20: error: socket.h: No such file or directory -configure:4712: checking whether to use CRC32 -configure:4728: result: no -configure:4879: creating ./config.status - -## ---------------------- ## -## Running config.status. ## -## ---------------------- ## - -This file was extended by libenet config.status 10-31-2006, which was -generated by GNU Autoconf 2.60a. Invocation command line was - - CONFIG_FILES = - CONFIG_HEADERS = - CONFIG_LINKS = - CONFIG_COMMANDS = - $ ./config.status - -on fweep - -config.status:606: creating Makefile -config.status:606: creating include/Makefile -config.status:606: creating include/enet/Makefile -config.status:791: executing depfiles commands - -## ---------------- ## -## Cache variables. ## -## ---------------- ## - -ac_cv_c_compiler_gnu=yes -ac_cv_env_CC_set= -ac_cv_env_CC_value= -ac_cv_env_CFLAGS_set= -ac_cv_env_CFLAGS_value= -ac_cv_env_CPPFLAGS_set= -ac_cv_env_CPPFLAGS_value= -ac_cv_env_CPP_set= -ac_cv_env_CPP_value= -ac_cv_env_LDFLAGS_set= -ac_cv_env_LDFLAGS_value= -ac_cv_env_build_alias_set= -ac_cv_env_build_alias_value= -ac_cv_env_host_alias_set= -ac_cv_env_host_alias_value= -ac_cv_env_target_alias_set= -ac_cv_env_target_alias_value= -ac_cv_func_fcntl=yes -ac_cv_func_gethostbyaddr_r=yes -ac_cv_func_gethostbyname_r=yes -ac_cv_func_inet_ntop=yes -ac_cv_func_inet_pton=yes -ac_cv_func_poll=yes -ac_cv_member_struct_msghdr_msg_flags=yes -ac_cv_objext=o -ac_cv_path_EGREP='/bin/grep -E' -ac_cv_path_GREP=/bin/grep -ac_cv_path_install='/usr/bin/install -c' -ac_cv_prog_AWK=gawk -ac_cv_prog_CPP='gcc -E' -ac_cv_prog_ac_ct_CC=gcc -ac_cv_prog_ac_ct_RANLIB=ranlib -ac_cv_prog_cc_c89= -ac_cv_prog_cc_g=yes -ac_cv_prog_make_make_set=yes -ac_cv_type_socklen_t=yes -am_cv_CC_dependencies_compiler_type=gcc3 - -## ----------------- ## -## Output variables. ## -## ----------------- ## - -ACLOCAL='aclocal-1.9' -AMDEPBACKSLASH='\' -AMDEP_FALSE='#' -AMDEP_TRUE='' -AMTAR='tar' -AUTOCONF='autoconf' -AUTOHEADER='autoheader' -AUTOMAKE='automake-1.9' -AWK='gawk' -CC='gcc' -CCDEPMODE='depmode=gcc3' -CFLAGS='-g -O2' -CPP='gcc -E' -CPPFLAGS='' -CYGPATH_W='echo' -DEFS='-DPACKAGE_NAME=\"libenet\" -DPACKAGE_TARNAME=\"libenet\" -DPACKAGE_VERSION=\"10-31-2006\" -DPACKAGE_STRING=\"libenet\ 10-31-2006\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libenet.a\" -DVERSION=\"10-31-2006\" -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_SOCKLEN_T=1' -DEPDIR='.deps' -ECHO_C='' -ECHO_N='-n' -ECHO_T='' -EGREP='/bin/grep -E' -EXEEXT='' -GREP='/bin/grep' -INSTALL_DATA='${INSTALL} -m 644' -INSTALL_PROGRAM='${INSTALL}' -INSTALL_SCRIPT='${INSTALL}' -INSTALL_STRIP_PROGRAM='${SHELL} $(install_sh) -c -s' -LDFLAGS='' -LIBOBJS='' -LIBS='' -LTLIBOBJS='' -MAKEINFO='makeinfo' -OBJEXT='o' -PACKAGE='libenet.a' -PACKAGE_BUGREPORT='' -PACKAGE_NAME='libenet' -PACKAGE_STRING='libenet 10-31-2006' -PACKAGE_TARNAME='libenet' -PACKAGE_VERSION='10-31-2006' -PATH_SEPARATOR=':' -RANLIB='ranlib' -SET_MAKE='' -SHELL='/bin/sh' -STRIP='' -VERSION='10-31-2006' -ac_ct_CC='gcc' -am__fastdepCC_FALSE='#' -am__fastdepCC_TRUE='' -am__include='include' -am__leading_dot='.' -am__quote='' -am__tar='${AMTAR} chof - "$$tardir"' -am__untar='${AMTAR} xf -' -bindir='${exec_prefix}/bin' -build_alias='' -datadir='${datarootdir}' -datarootdir='${prefix}/share' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -dvidir='${docdir}' -exec_prefix='${prefix}' -host_alias='' -htmldir='${docdir}' -includedir='${prefix}/include' -infodir='${datarootdir}/info' -install_sh='/home/lee/ac/ac/source/enet/install-sh' -libdir='${exec_prefix}/lib' -libexecdir='${exec_prefix}/libexec' -localedir='${datarootdir}/locale' -localstatedir='${prefix}/var' -mandir='${datarootdir}/man' -mkdir_p='mkdir -p --' -oldincludedir='/usr/include' -pdfdir='${docdir}' -prefix='/usr/local' -program_transform_name='s,x,x,' -psdir='${docdir}' -sbindir='${exec_prefix}/sbin' -sharedstatedir='${prefix}/com' -sysconfdir='${prefix}/etc' -target_alias='' - -## ----------- ## -## confdefs.h. ## -## ----------- ## - -#define PACKAGE_NAME "libenet" -#define PACKAGE_TARNAME "libenet" -#define PACKAGE_VERSION "10-31-2006" -#define PACKAGE_STRING "libenet 10-31-2006" -#define PACKAGE_BUGREPORT "" -#define PACKAGE "libenet.a" -#define VERSION "10-31-2006" -#define HAS_GETHOSTBYADDR_R 1 -#define HAS_GETHOSTBYNAME_R 1 -#define HAS_POLL 1 -#define HAS_FCNTL 1 -#define HAS_INET_PTON 1 -#define HAS_INET_NTOP 1 -#define HAS_MSGHDR_FLAGS 1 -#define HAS_SOCKLEN_T 1 - -configure: exit 0 diff --git a/source/enet/config.status b/source/enet/config.status deleted file mode 100755 index 35aacf84..00000000 --- a/source/enet/config.status +++ /dev/null @@ -1,926 +0,0 @@ -#! /bin/sh -# Generated by configure. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=${CONFIG_SHELL-/bin/sh} -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" -else - as_executable_p=: -fi -rm -f conf$$.file - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 - -# Save the log message, to keep $[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by libenet $as_me 10-31-2006, which was -generated by GNU Autoconf 2.60a. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -# Files that config.status was made for. -config_files=" Makefile include/Makefile include/enet/Makefile" -config_commands=" depfiles" - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to ." - -ac_cs_version="\ -libenet config.status 10-31-2006 -configured by ./configure, generated by GNU Autoconf 2.60a, - with options \"\" - -Copyright (C) 2006 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='/home/lee/ac/ac/source/enet' -srcdir='.' -INSTALL='/usr/bin/install -c' -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -if $ac_cs_recheck; then - echo "running CONFIG_SHELL=/bin/sh /bin/sh ./configure " $ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=/bin/sh - export CONFIG_SHELL - exec /bin/sh "./configure" $ac_configure_extra_args --no-create --no-recursion -fi - -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - echo "$ac_log" -} >&5 - -# -# INIT-COMMANDS -# -AMDEP_TRUE="" ac_aux_dir="." - - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; - "include/enet/Makefile") CONFIG_FILES="$CONFIG_FILES include/enet/Makefile" ;; - - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -# -# Set up the sed scripts for CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "$CONFIG_FILES"; then - -cat >"$tmp/subs-1.sed" <<\CEOF -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end -s,@SHELL@,|#_!!_#|/bin/sh,g -s,@PATH_SEPARATOR@,|#_!!_#|:,g -s,@PACKAGE_NAME@,|#_!!_#|libenet,g -s,@PACKAGE_TARNAME@,|#_!!_#|libenet,g -s,@PACKAGE_VERSION@,|#_!!_#|10-31-2006,g -s,@PACKAGE_STRING@,|#_!!_#|libenet 10-31-2006,g -s,@PACKAGE_BUGREPORT@,|#_!!_#|,g -s,@exec_prefix@,|#_!!_#|${prefix},g -s,@prefix@,|#_!!_#|/usr/local,g -s,@program_transform_name@,|#_!!_#|s\,x\,x\,,g -s,@bindir@,|#_!!_#|${exec_prefix}/bin,g -s,@sbindir@,|#_!!_#|${exec_prefix}/sbin,g -s,@libexecdir@,|#_!!_#|${exec_prefix}/libexec,g -s,@datarootdir@,|#_!!_#|${prefix}/share,g -s,@datadir@,|#_!!_#|${datarootdir},g -s,@sysconfdir@,|#_!!_#|${prefix}/etc,g -s,@sharedstatedir@,|#_!!_#|${prefix}/com,g -s,@localstatedir@,|#_!!_#|${prefix}/var,g -s,@includedir@,|#_!!_#|${prefix}/include,g -s,@oldincludedir@,|#_!!_#|/usr/include,g -s,@docdir@,|#_!!_#|${datarootdir}/doc/${PACKAGE_TARNAME},g -s,@infodir@,|#_!!_#|${datarootdir}/info,g -s,@htmldir@,|#_!!_#|${docdir},g -s,@dvidir@,|#_!!_#|${docdir},g -s,@pdfdir@,|#_!!_#|${docdir},g -s,@psdir@,|#_!!_#|${docdir},g -s,@libdir@,|#_!!_#|${exec_prefix}/lib,g -s,@localedir@,|#_!!_#|${datarootdir}/locale,g -s,@mandir@,|#_!!_#|${datarootdir}/man,g -s,@DEFS@,|#_!!_#|-DPACKAGE_NAME=\\"libenet\\" -DPACKAGE_TARNAME=\\"libenet\\" -DPACKAGE_VERSION=\\"10-31-2006\\" -DPACKAGE_STRING=\\"libenet\\ 10-31-2006\\" -DPACKAGE_BUGREPORT=\\"\\" -DPACKAGE=\\"libenet.a\\" -DVERSION=\\"10-31-2006\\" -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_SOCKLEN_T=1,g -s,@ECHO_C@,|#_!!_#|,g -s,@ECHO_N@,|#_!!_#|-n,g -s,@ECHO_T@,|#_!!_#|,g -s,@LIBS@,|#_!!_#|,g -s,@build_alias@,|#_!!_#|,g -s,@host_alias@,|#_!!_#|,g -s,@target_alias@,|#_!!_#|,g -s,@INSTALL_PROGRAM@,|#_!!_#|${INSTALL},g -s,@INSTALL_SCRIPT@,|#_!!_#|${INSTALL},g -s,@INSTALL_DATA@,|#_!!_#|${INSTALL} -m 644,g -s,@CYGPATH_W@,|#_!!_#|echo,g -s,@PACKAGE@,|#_!!_#|libenet.a,g -s,@VERSION@,|#_!!_#|10-31-2006,g -s,@ACLOCAL@,|#_!!_#|aclocal-1.9,g -s,@AUTOCONF@,|#_!!_#|autoconf,g -s,@AUTOMAKE@,|#_!!_#|automake-1.9,g -s,@AUTOHEADER@,|#_!!_#|autoheader,g -s,@MAKEINFO@,|#_!!_#|makeinfo,g -s,@install_sh@,|#_!!_#|/home/lee/ac/ac/source/enet/install-sh,g -s,@STRIP@,|#_!!_#|,g -s,@INSTALL_STRIP_PROGRAM@,|#_!!_#|${SHELL} $(install_sh) -c -s,g -s,@mkdir_p@,|#_!!_#|mkdir -p --,g -s,@AWK@,|#_!!_#|gawk,g -s,@SET_MAKE@,|#_!!_#|,g -s,@am__leading_dot@,|#_!!_#|.,g -s,@AMTAR@,|#_!!_#|tar,g -s,@am__tar@,|#_!!_#|${AMTAR} chof - "$$tardir",g -s,@am__untar@,|#_!!_#|${AMTAR} xf -,g -s,@CC@,|#_!!_#|gcc,g -s,@CFLAGS@,|#_!!_#|-g -O2,g -s,@LDFLAGS@,|#_!!_#|,g -s,@CPPFLAGS@,|#_!!_#|,g -s,@ac_ct_CC@,|#_!!_#|gcc,g -s,@EXEEXT@,|#_!!_#|,g -s,@OBJEXT@,|#_!!_#|o,g -s,@DEPDIR@,|#_!!_#|.deps,g -s,@am__include@,|#_!!_#|include,g -s,@am__quote@,|#_!!_#|,g -s,@AMDEP_TRUE@,|#_!!_#|,g -s,@AMDEP_FALSE@,|#_!!_#|#,g -s,@AMDEPBACKSLASH@,|#_!!_#|\\,g -s,@CCDEPMODE@,|#_!!_#|depmode=gcc3,g -s,@am__fastdepCC_TRUE@,|#_!!_#|,g -s,@am__fastdepCC_FALSE@,|#_!!_#|#,g -s,@RANLIB@,|#_!!_#|ranlib,g -s,@CPP@,|#_!!_#|gcc -E,g -s,@GREP@,|#_!!_#|/bin/grep,g -s,@EGREP@,|#_!!_#|/bin/grep -E,g -s,@LIBOBJS@,|#_!!_#|,g -s,@LTLIBOBJS@,|#_!!_#|,g -:end -s/|#_!!_#|//g -CEOF -fi # test -n "$CONFIG_FILES" - - -for ac_tag in :F $CONFIG_FILES :C $CONFIG_COMMANDS -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - ac_file_inputs="$ac_file_inputs $ac_f" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - fi - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= - -case `sed -n '/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' $ac_file_inputs` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} - ac_datarootdir_hack=' - s&@datadir@&${datarootdir}&g - s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g - s&@infodir@&${datarootdir}/info&g - s&@localedir@&${datarootdir}/locale&g - s&@mandir@&${datarootdir}/man&g - s&\${datarootdir}&${prefix}/share&g' ;; -esac - sed "/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -} - -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac - ;; - - - :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 -echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir=$dirpart/$fdir - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done - ;; - - esac -done # for ac_tag - - -{ (exit 0); exit 0; } diff --git a/source/enet/config.sub b/source/enet/config.sub deleted file mode 100644 index ac6de986..00000000 --- a/source/enet/config.sub +++ /dev/null @@ -1,1552 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -timestamp='2004-06-24' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | msp430 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | msp430-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source/enet/configure b/source/enet/configure deleted file mode 100755 index 8064071a..00000000 --- a/source/enet/configure +++ /dev/null @@ -1,5921 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60a for libenet 10-31-2006. -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell autoconf@gnu.org about your system, - echo including any error possibly output before this - echo message -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" -else - as_executable_p=: -fi -rm -f conf$$.file - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Identity of this package. -PACKAGE_NAME='libenet' -PACKAGE_TARNAME='libenet' -PACKAGE_VERSION='10-31-2006' -PACKAGE_STRING='libenet 10-31-2006' -PACKAGE_BUGREPORT='' - -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -INSTALL_PROGRAM -INSTALL_SCRIPT -INSTALL_DATA -CYGPATH_W -PACKAGE -VERSION -ACLOCAL -AUTOCONF -AUTOMAKE -AUTOHEADER -MAKEINFO -install_sh -STRIP -INSTALL_STRIP_PROGRAM -mkdir_p -AWK -SET_MAKE -am__leading_dot -AMTAR -am__tar -am__untar -CC -CFLAGS -LDFLAGS -CPPFLAGS -ac_ct_CC -EXEEXT -OBJEXT -DEPDIR -am__include -am__quote -AMDEP_TRUE -AMDEP_FALSE -AMDEPBACKSLASH -CCDEPMODE -am__fastdepCC_TRUE -am__fastdepCC_FALSE -RANLIB -CPP -GREP -EGREP -LIBOBJS -LTLIBOBJS' -ac_subst_files='' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval enable_$ac_feature=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval with_$ac_package=\$ac_optarg ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval with_$ac_package=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute directory names. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures libenet 10-31-2006 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/libenet] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of libenet 10-31-2006:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - --enable-crc32 enable CRC32 packet verification - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -libenet configure 10-31-2006 -generated by GNU Autoconf 2.60a - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by libenet $as_me 10-31-2006, which was -generated by GNU Autoconf 2.60a. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args '$ac_arg'" - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" -elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" -else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" -fi -shift -for ac_site_file -do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - - - - - - - - - - - - - - - - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -am__api_version="1.9" -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done -IFS=$as_save_IFS - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } -fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. -# By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm -f conftest.sed - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 -echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } -set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - SET_MAKE= -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE=libenet.a - VERSION=10-31-2006 - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -install_sh=${install_sh-"$am_aux_dir/install-sh"} - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -# -# List of possible output files, starting from the most likely. -# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) -# only as a last resort. b.out is created by i960 compilers. -ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' -# -# The IRIX 6 linker writes into existing files which may not be -# executable, retaining their permissions. Remove them first so a -# subsequent execution test works. -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { (ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi - -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } -if test -z "$ac_file"; then - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } -{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6; } - -{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_c89=$ac_arg -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6; } ;; - xno) - { echo "$as_me:$LINENO: result: unsupported" >&5 -echo "${ECHO_T}unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; -esac - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi - - -{ echo "$as_me:$LINENO: result: $_am_result" >&5 -echo "${ECHO_T}$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - - -if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - - -depcc="$CC" am_compiler_list= - -{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - - -if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { echo "$as_me:$LINENO: result: $RANLIB" >&5 -echo "${ECHO_T}$RANLIB" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -echo "${ECHO_T}$ac_ct_RANLIB" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - - - -{ echo "$as_me:$LINENO: checking for gethostbyaddr_r" >&5 -echo $ECHO_N "checking for gethostbyaddr_r... $ECHO_C" >&6; } -if test "${ac_cv_func_gethostbyaddr_r+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define gethostbyaddr_r to an innocuous variant, in case declares gethostbyaddr_r. - For example, HP-UX 11i declares gettimeofday. */ -#define gethostbyaddr_r innocuous_gethostbyaddr_r - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char gethostbyaddr_r (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef gethostbyaddr_r - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyaddr_r (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_gethostbyaddr_r || defined __stub___gethostbyaddr_r -choke me -#endif - -int -main () -{ -return gethostbyaddr_r (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_gethostbyaddr_r=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_gethostbyaddr_r=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyaddr_r" >&5 -echo "${ECHO_T}$ac_cv_func_gethostbyaddr_r" >&6; } -if test $ac_cv_func_gethostbyaddr_r = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_GETHOSTBYADDR_R 1 -_ACEOF - -fi - -{ echo "$as_me:$LINENO: checking for gethostbyname_r" >&5 -echo $ECHO_N "checking for gethostbyname_r... $ECHO_C" >&6; } -if test "${ac_cv_func_gethostbyname_r+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define gethostbyname_r to an innocuous variant, in case declares gethostbyname_r. - For example, HP-UX 11i declares gettimeofday. */ -#define gethostbyname_r innocuous_gethostbyname_r - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char gethostbyname_r (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef gethostbyname_r - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyname_r (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_gethostbyname_r || defined __stub___gethostbyname_r -choke me -#endif - -int -main () -{ -return gethostbyname_r (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_gethostbyname_r=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_gethostbyname_r=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname_r" >&5 -echo "${ECHO_T}$ac_cv_func_gethostbyname_r" >&6; } -if test $ac_cv_func_gethostbyname_r = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_GETHOSTBYNAME_R 1 -_ACEOF - -fi - -{ echo "$as_me:$LINENO: checking for poll" >&5 -echo $ECHO_N "checking for poll... $ECHO_C" >&6; } -if test "${ac_cv_func_poll+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define poll to an innocuous variant, in case declares poll. - For example, HP-UX 11i declares gettimeofday. */ -#define poll innocuous_poll - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char poll (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef poll - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char poll (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_poll || defined __stub___poll -choke me -#endif - -int -main () -{ -return poll (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_poll=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_poll=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_poll" >&5 -echo "${ECHO_T}$ac_cv_func_poll" >&6; } -if test $ac_cv_func_poll = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_POLL 1 -_ACEOF - -fi - -{ echo "$as_me:$LINENO: checking for fcntl" >&5 -echo $ECHO_N "checking for fcntl... $ECHO_C" >&6; } -if test "${ac_cv_func_fcntl+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define fcntl to an innocuous variant, in case declares fcntl. - For example, HP-UX 11i declares gettimeofday. */ -#define fcntl innocuous_fcntl - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char fcntl (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef fcntl - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char fcntl (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_fcntl || defined __stub___fcntl -choke me -#endif - -int -main () -{ -return fcntl (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_fcntl=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_fcntl=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_fcntl" >&5 -echo "${ECHO_T}$ac_cv_func_fcntl" >&6; } -if test $ac_cv_func_fcntl = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_FCNTL 1 -_ACEOF - -fi - -{ echo "$as_me:$LINENO: checking for inet_pton" >&5 -echo $ECHO_N "checking for inet_pton... $ECHO_C" >&6; } -if test "${ac_cv_func_inet_pton+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define inet_pton to an innocuous variant, in case declares inet_pton. - For example, HP-UX 11i declares gettimeofday. */ -#define inet_pton innocuous_inet_pton - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char inet_pton (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef inet_pton - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char inet_pton (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_inet_pton || defined __stub___inet_pton -choke me -#endif - -int -main () -{ -return inet_pton (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_inet_pton=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_inet_pton=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_inet_pton" >&5 -echo "${ECHO_T}$ac_cv_func_inet_pton" >&6; } -if test $ac_cv_func_inet_pton = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_INET_PTON 1 -_ACEOF - -fi - -{ echo "$as_me:$LINENO: checking for inet_ntop" >&5 -echo $ECHO_N "checking for inet_ntop... $ECHO_C" >&6; } -if test "${ac_cv_func_inet_ntop+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define inet_ntop to an innocuous variant, in case declares inet_ntop. - For example, HP-UX 11i declares gettimeofday. */ -#define inet_ntop innocuous_inet_ntop - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char inet_ntop (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef inet_ntop - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char inet_ntop (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_inet_ntop || defined __stub___inet_ntop -choke me -#endif - -int -main () -{ -return inet_ntop (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_inet_ntop=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_inet_ntop=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_inet_ntop" >&5 -echo "${ECHO_T}$ac_cv_func_inet_ntop" >&6; } -if test $ac_cv_func_inet_ntop = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_INET_NTOP 1 -_ACEOF - -fi - - -{ echo "$as_me:$LINENO: checking for struct msghdr.msg_flags" >&5 -echo $ECHO_N "checking for struct msghdr.msg_flags... $ECHO_C" >&6; } -if test "${ac_cv_member_struct_msghdr_msg_flags+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -static struct msghdr ac_aggr; -if (ac_aggr.msg_flags) -return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_member_struct_msghdr_msg_flags=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -static struct msghdr ac_aggr; -if (sizeof ac_aggr.msg_flags) -return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_member_struct_msghdr_msg_flags=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_member_struct_msghdr_msg_flags=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_msghdr_msg_flags" >&5 -echo "${ECHO_T}$ac_cv_member_struct_msghdr_msg_flags" >&6; } -if test $ac_cv_member_struct_msghdr_msg_flags = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_MSGHDR_FLAGS 1 -_ACEOF - -fi - - -{ echo "$as_me:$LINENO: checking for socklen_t" >&5 -echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6; } -if test "${ac_cv_type_socklen_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - #include - - -typedef socklen_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_socklen_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_socklen_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 -echo "${ECHO_T}$ac_cv_type_socklen_t" >&6; } -if test $ac_cv_type_socklen_t = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAS_SOCKLEN_T 1 -_ACEOF - -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Extract the first word of "grep ggrep" to use in msg output -if test -z "$GREP"; then -set dummy grep ggrep; ac_prog_name=$2 -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_GREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_executable_p "$ac_path_GREP"; } || continue - # Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_GREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -GREP="$ac_cv_path_GREP" -if test -z "$GREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_GREP=$GREP -fi - - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -echo "${ECHO_T}$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - # Extract the first word of "egrep" to use in msg output -if test -z "$EGREP"; then -set dummy egrep; ac_prog_name=$2 -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_EGREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_executable_p "$ac_path_EGREP"; } || continue - # Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_EGREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -EGREP="$ac_cv_path_EGREP" -if test -z "$EGREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_EGREP=$EGREP -fi - - - fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then - cat >>confdefs.h <<\_ACEOF -#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN -_ACEOF - -fi -rm -f conftest* - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then - cat >>confdefs.h <<\_ACEOF -#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN -_ACEOF - -fi -rm -f conftest* - - -{ echo "$as_me:$LINENO: checking whether to use CRC32" >&5 -echo $ECHO_N "checking whether to use CRC32... $ECHO_C" >&6; } -# Check whether --enable-crc32 was given. -if test "${enable_crc32+set}" = set; then - enableval=$enable_crc32; if test "$enableval" = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - cat >>confdefs.h <<\_ACEOF -#define USE_CRC32 1 -_ACEOF - - else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - fi -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -ac_config_files="$ac_config_files Makefile include/Makefile include/enet/Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" -else - as_executable_p=: -fi -rm -f conf$$.file - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 - -# Save the log message, to keep $[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by libenet $as_me 10-31-2006, which was -generated by GNU Autoconf 2.60a. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# Files that config.status was made for. -config_files="$ac_config_files" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -libenet config.status 10-31-2006 -configured by $0, generated by GNU Autoconf 2.60a, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2006 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL - export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; - "include/enet/Makefile") CONFIG_FILES="$CONFIG_FILES include/enet/Makefile" ;; - - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -# -# Set up the sed scripts for CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "$CONFIG_FILES"; then - -_ACEOF - - - -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -SHELL!$SHELL$ac_delim -PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim -PACKAGE_NAME!$PACKAGE_NAME$ac_delim -PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim -PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim -PACKAGE_STRING!$PACKAGE_STRING$ac_delim -PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim -exec_prefix!$exec_prefix$ac_delim -prefix!$prefix$ac_delim -program_transform_name!$program_transform_name$ac_delim -bindir!$bindir$ac_delim -sbindir!$sbindir$ac_delim -libexecdir!$libexecdir$ac_delim -datarootdir!$datarootdir$ac_delim -datadir!$datadir$ac_delim -sysconfdir!$sysconfdir$ac_delim -sharedstatedir!$sharedstatedir$ac_delim -localstatedir!$localstatedir$ac_delim -includedir!$includedir$ac_delim -oldincludedir!$oldincludedir$ac_delim -docdir!$docdir$ac_delim -infodir!$infodir$ac_delim -htmldir!$htmldir$ac_delim -dvidir!$dvidir$ac_delim -pdfdir!$pdfdir$ac_delim -psdir!$psdir$ac_delim -libdir!$libdir$ac_delim -localedir!$localedir$ac_delim -mandir!$mandir$ac_delim -DEFS!$DEFS$ac_delim -ECHO_C!$ECHO_C$ac_delim -ECHO_N!$ECHO_N$ac_delim -ECHO_T!$ECHO_T$ac_delim -LIBS!$LIBS$ac_delim -build_alias!$build_alias$ac_delim -host_alias!$host_alias$ac_delim -target_alias!$target_alias$ac_delim -INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim -INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim -INSTALL_DATA!$INSTALL_DATA$ac_delim -CYGPATH_W!$CYGPATH_W$ac_delim -PACKAGE!$PACKAGE$ac_delim -VERSION!$VERSION$ac_delim -ACLOCAL!$ACLOCAL$ac_delim -AUTOCONF!$AUTOCONF$ac_delim -AUTOMAKE!$AUTOMAKE$ac_delim -AUTOHEADER!$AUTOHEADER$ac_delim -MAKEINFO!$MAKEINFO$ac_delim -install_sh!$install_sh$ac_delim -STRIP!$STRIP$ac_delim -INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim -mkdir_p!$mkdir_p$ac_delim -AWK!$AWK$ac_delim -SET_MAKE!$SET_MAKE$ac_delim -am__leading_dot!$am__leading_dot$ac_delim -AMTAR!$AMTAR$ac_delim -am__tar!$am__tar$ac_delim -am__untar!$am__untar$ac_delim -CC!$CC$ac_delim -CFLAGS!$CFLAGS$ac_delim -LDFLAGS!$LDFLAGS$ac_delim -CPPFLAGS!$CPPFLAGS$ac_delim -ac_ct_CC!$ac_ct_CC$ac_delim -EXEEXT!$EXEEXT$ac_delim -OBJEXT!$OBJEXT$ac_delim -DEPDIR!$DEPDIR$ac_delim -am__include!$am__include$ac_delim -am__quote!$am__quote$ac_delim -AMDEP_TRUE!$AMDEP_TRUE$ac_delim -AMDEP_FALSE!$AMDEP_FALSE$ac_delim -AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim -CCDEPMODE!$CCDEPMODE$ac_delim -am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim -am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim -RANLIB!$RANLIB$ac_delim -CPP!$CPP$ac_delim -GREP!$GREP$ac_delim -EGREP!$EGREP$ac_delim -LIBOBJS!$LIBOBJS$ac_delim -LTLIBOBJS!$LTLIBOBJS$ac_delim -_ACEOF - - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then - break - elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` -if test -n "$ac_eof"; then - ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` - ac_eof=`expr $ac_eof + 1` -fi - -cat >>$CONFIG_STATUS <<_ACEOF -cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end -_ACEOF -sed ' -s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g -s/^/s,@/; s/!/@,|#_!!_#|/ -:n -t n -s/'"$ac_delim"'$/,g/; t -s/$/\\/; p -N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n -' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF -:end -s/|#_!!_#|//g -CEOF$ac_eof -_ACEOF - - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF -fi # test -n "$CONFIG_FILES" - - -for ac_tag in :F $CONFIG_FILES :C $CONFIG_COMMANDS -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - ac_file_inputs="$ac_file_inputs $ac_f" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - fi - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= - -case `sed -n '/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' $ac_file_inputs` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac - ;; - - - :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 -echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir=$dirpart/$fdir - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done - ;; - - esac -done # for ac_tag - - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - - diff --git a/source/enet/configure.in b/source/enet/configure.in deleted file mode 100755 index 17580895..00000000 --- a/source/enet/configure.in +++ /dev/null @@ -1,36 +0,0 @@ -AC_INIT(libenet, 10-31-2006) -AM_INIT_AUTOMAKE(libenet.a, 10-31-2006) - -AC_PROG_CC -AC_PROG_RANLIB - -AC_CHECK_FUNC(gethostbyaddr_r, [AC_DEFINE(HAS_GETHOSTBYADDR_R)]) -AC_CHECK_FUNC(gethostbyname_r, [AC_DEFINE(HAS_GETHOSTBYNAME_R)]) -AC_CHECK_FUNC(poll, [AC_DEFINE(HAS_POLL)]) -AC_CHECK_FUNC(fcntl, [AC_DEFINE(HAS_FCNTL)]) -AC_CHECK_FUNC(inet_pton, [AC_DEFINE(HAS_INET_PTON)]) -AC_CHECK_FUNC(inet_ntop, [AC_DEFINE(HAS_INET_NTOP)]) - -AC_CHECK_MEMBER(struct msghdr.msg_flags, [AC_DEFINE(HAS_MSGHDR_FLAGS)], , [#include ]) - -AC_CHECK_TYPE(socklen_t, [AC_DEFINE(HAS_SOCKLEN_T)], , - #include - #include -) - -AC_EGREP_HEADER(MSG_MAXIOVLEN, /usr/include/sys/socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN])) -AC_EGREP_HEADER(MSG_MAXIOVLEN, socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN])) - -AC_MSG_CHECKING(whether to use CRC32) -AC_ARG_ENABLE(crc32, - [ --enable-crc32 enable CRC32 packet verification ], - [if test "$enableval" = yes; then - AC_MSG_RESULT(yes) - AC_DEFINE(USE_CRC32) - else - AC_MSG_RESULT(no) - fi], - [AC_MSG_RESULT(no)]) - -AC_OUTPUT([Makefile include/Makefile include/enet/Makefile]) - diff --git a/source/enet/depcomp b/source/enet/depcomp deleted file mode 100755 index 11e2d3bf..00000000 --- a/source/enet/depcomp +++ /dev/null @@ -1,522 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2004-05-31.23 - -# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit 0 - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit 0 - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - stat=$? - - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" - fi - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - outname="$stripped.o" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # Dependencies are output in .lo.d with libtool 1.4. - # With libtool 1.5 they are output both in $dir.libs/$base.o.d - # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the - # latter, because the former will be cleaned when $dir.libs is - # erased. - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir$base.o.d" - tmpdepfile3="$dir.libs/$base.d" - "$@" -Wc,-MD - else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - tmpdepfile3="$dir$base.d" - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - elif test -f "$tmpdepfile2"; then - tmpdepfile="$tmpdepfile2" - else - tmpdepfile="$tmpdepfile3" - fi - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/source/enet/design.txt b/source/enet/design.txt deleted file mode 100755 index 9a88dba9..00000000 --- a/source/enet/design.txt +++ /dev/null @@ -1,117 +0,0 @@ -* Why ENet? - - ENet evolved specifically as a UDP networking layer for the multiplayer -first person shooter Cube. Cube necessitated low latency communcation with -data sent out very frequently, so TCP was an unsuitable choice due to its -high latency and stream orientation. UDP, however, lacks many sometimes -necessary features from TCP such as reliability, sequencing, unrestricted -packet sizes, and connection management. So UDP by itself was not suitable -as a network protocol either. No suitable freely available networking -libraries existed at the time of ENet's creation to fill this niche. - - UDP and TCP could have been used together in Cube to benefit somewhat -from both of their features, however, the resulting combinations of protocols -still leaves much to be desired. TCP lacks multiple streams of communication -without resorting to opening many sockets and complicates delineation of -packets due to its buffering behavior. UDP lacks sequencing, connection -management, management of bandwidth resources, and imposes limitations on -the size of packets. A significant investment is required to integrate these -two protocols, and the end result is worse off in features and performance -than the uniform protocol presented by ENet. - - ENet thus attempts to address these issues and provide a single, uniform -protocol layered over UDP to the developer with the best features of UDP and -TCP as well as some useful features neither provide, with a much cleaner -integration than any resulting from a mixture of UDP and TCP. - -* Connection management - - ENet provides a simple connection interface over which to communicate -with a foreign host. The liveness of the connection is actively monitored -by pinging the foreign host at frequent intervals, and also monitors the -network conditions from the local host to the foreign host such as the -mean round trip time and packet loss in this fashion. - -* Sequencing - - Rather than a single byte stream that complicates the delineation -of packets, ENet presents connections as multiple, properly sequenced packet -streams that simplify the transfer of various types of data. - - ENet provides sequencing for all packets by assigning to each sent -packet a sequence number that is incremented as packets are sent. ENet -guarentees that no packet with a higher sequence number will be delivered -before a packet with a lower sequence number, thus ensuring packets are -delivered exactly in the order they are sent. - - For unreliable packets, ENet will simply discard the lower sequence -number packet if a packet with a higher sequence number has already been -delivered. This allows the packets to be dispatched immediately as they -arrive, and reduce latency of unreliable packets to an absolute minimum. -For reliable packets, if a higher sequence number packet arrives, but the -preceding packets in the sequence have not yet arrived, ENet will stall -delivery of the higher sequence number packets until its predecessors -have arrived. - -* Channels - - Since ENet will stall delivery of reliable packets to ensure proper -sequencing, and consequently any packets of higher sequence number whether -reliable or unreliable, in the event the reliable packet's predecessors -have not yet arrived, this can introduce latency into the delivery of other -packets which may not need to be as strictly ordered with respect to the -packet that stalled their delivery. - - To combat this latency and reduce the ordering restrictions on packets, -ENet provides multiple channels of communication over a given connection. -Each channel is independently sequenced, and so the delivery status of -a packet in one channel will not stall the delivery of other packets -in another channel. - -* Reliability - - ENet provides optional reliability of packet delivery by ensuring the -foreign host acknowledges receipt of all reliable packets. ENet will attempt -to resend the packet up to a reasonable amount of times, if no acknowledgement -of the packet's receipt happens within a specified timeout. Retry timeouts -are progressive and become more lenient with every failed attempt to allow -for temporary turbulence in network conditions. - -* Fragmentation and reassembly - - ENet will send and deliver packets regardless of size. Large packets are -fragmented into many smaller packets of suitable size, and reassembled on -the foreign host to recover the original packet for delivery. The process -is entirely transparent to the developer. - -* Aggregation - - ENet aggregates all protocol commands, including acknowledgements and -packet transfer, into larger protocol packets to ensure the proper utilization -of the connection and to limit the opportunities for packet loss that might -otherwise result in further delivery latency. - -* Adaptability - - ENet provides an in-flight data window for reliable packets to ensure -connections are not overwhelmed by volumes of packets. It also provides a -static bandwidth allocation mechanism to ensure the total volume of packets -sent and received to a host don't exceed the host's capabilities. Further, -ENet also provides a dynamic throttle that responds to deviations from normal -network connections to rectify various types of network congestion by further -limiting the volume of packets sent. - -* Portability - - ENet works on Windows and any other Unix or Unix-like platform providing -a BSD sockets interface. The library has a small and stable code base that -can easily be extended to support other platforms and integrates easily. - -* Freedom - - ENet demands no royalties and doesn't carry a viral license that would -restrict you in how you might use it in your programs. ENet is licensed under -a short-and-sweet MIT-style license, which gives you the freedom to do anything -you want with it (well, almost anything). - - diff --git a/source/enet/docs/FAQ.dox b/source/enet/docs/FAQ.dox deleted file mode 100755 index 484b818a..00000000 --- a/source/enet/docs/FAQ.dox +++ /dev/null @@ -1,24 +0,0 @@ -/** - @page FAQ Frequently Answered Questions - -@section Q1 Is ENet thread safe? - -ENet does not use any significant global variables, the vast majority -of state is encapsulated in the ENetHost structure. As such, as long -as the application guards access to this structure, then ENet should -operate fine in a multithreaded environment. - -@section Q2 Isn't ENet just re-inventing TCP?! What's the point? - -In a perfect world, that would be true. But as many have found, using -TCP either in lieu of or in conjunction with UDP can lead to all kinds -of nightmares. TCP is a good, solid protocol, however it simply isn't -up to the task of real-time games. Too much of TCP's implementation -dictates a policy that isn't practical for games. If you want to use -TCP, then do so -- this library is for people that either don't want -to use TCP or have tried and ended up being discouraged with the -performance. - -*/ - - diff --git a/source/enet/docs/design.dox b/source/enet/docs/design.dox deleted file mode 100755 index daed221c..00000000 --- a/source/enet/docs/design.dox +++ /dev/null @@ -1,126 +0,0 @@ -/** -@page Features Features and Architecture - -ENet evolved specifically as a UDP networking layer for the -multiplayer first person shooter Cube. Cube necessitated low latency -communcation with data sent out very frequently, so TCP was an -unsuitable choice due to its high latency and stream orientation. UDP, -however, lacks many sometimes necessary features from TCP such as -reliability, sequencing, unrestricted packet sizes, and connection -management. So UDP by itself was not suitable as a network protocol -either. No suitable freely available networking libraries existed at -the time of ENet's creation to fill this niche. - -UDP and TCP could have been used together in Cube to benefit somewhat -from both of their features, however, the resulting combinations of -protocols still leaves much to be desired. TCP lacks multiple streams -of communication without resorting to opening many sockets and -complicates delineation of packets due to its buffering behavior. UDP -lacks sequencing, connection management, management of bandwidth -resources, and imposes limitations on the size of packets. A -significant investment is required to integrate these two protocols, -and the end result is worse off in features and performance than the -uniform protocol presented by ENet. - -ENet thus attempts to address these issues and provide a single, -uniform protocol layered over UDP to the developer with the best -features of UDP and TCP as well as some useful features neither -provide, with a much cleaner integration than any resulting from a -mixture of UDP and TCP. - -@section CM Connection Management - -ENet provides a simple connection interface over which to communicate -with a foreign host. The liveness of the connection is actively -monitored by pinging the foreign host at frequent intervals, and also -monitors the network conditions from the local host to the foreign -host such as the mean round trip time and packet loss in this fashion. - -@section Sequencing Sequencing - -Rather than a single byte stream that complicates the delineation of -packets, ENet presents connections as multiple, properly sequenced -packet streams that simplify the transfer of various types of data. - -ENet provides sequencing for all packets by assigning to each sent -packet a sequence number that is incremented as packets are sent. ENet -guarentees that no packet with a higher sequence number will be -delivered before a packet with a lower sequence number, thus ensuring -packets are delivered exactly in the order they are sent. - -For unreliable packets, ENet will simply discard the lower sequence -number packet if a packet with a higher sequence number has already -been delivered. This allows the packets to be dispatched immediately -as they arrive, and reduce latency of unreliable packets to an -absolute minimum. For reliable packets, if a higher sequence number -packet arrives, but the preceding packets in the sequence have not yet -arrived, ENet will stall delivery of the higher sequence number -packets until its predecessors have arrived. - -@section Channels Channels - -Since ENet will stall delivery of reliable packets to ensure proper -sequencing, and consequently any packets of higher sequence number -whether reliable or unreliable, in the event the reliable packet's -predecessors have not yet arrived, this can introduce latency into the -delivery of other packets which may not need to be as strictly ordered -with respect to the packet that stalled their delivery. - -To combat this latency and reduce the ordering restrictions on -packets, ENet provides multiple channels of communication over a given -connection. Each channel is independently sequenced, and so the -delivery status of a packet in one channel will not stall the delivery -of other packets in another channel. - -@section Reliability Reliability - -ENet provides optional reliability of packet delivery by ensuring the -foreign host acknowledges receipt of all reliable packets. ENet will -attempt to resend the packet up to a reasonable amount of times, if no -acknowledgement of the packet's receipt happens within a specified -timeout. Retry timeouts are progressive and become more lenient with -every failed attempt to allow for temporary turbulence in network -conditions. - -@section FaR Fragmentation and Reassembly - -ENet will send and deliver packets regardless of size. Large packets -are fragmented into many smaller packets of suitable size, and -reassembled on the foreign host to recover the original packet for -delivery. The process is entirely transparent to the developer. - -@section Aggregation Aggregation - -ENet aggregates all protocol commands, including acknowledgements and -packet transfer, into larger protocol packets to ensure the proper -utilization of the connection and to limit the opportunities for -packet loss that might otherwise result in further delivery latency. - -@section Adaptability Adaptability - -ENet provides an in-flight data window for reliable packets to ensure -connections are not overwhelmed by volumes of packets. It also -provides a static bandwidth allocation mechanism to ensure the total -volume of packets sent and received to a host don't exceed the host's -capabilities. Further, ENet also provides a dynamic throttle that -responds to deviations from normal network connections to rectify -various types of network congestion by further limiting the volume of -packets sent. - -@section Portability Portability - -ENet works on Windows and any other Unix or Unix-like platform -providing a BSD sockets interface. The library has a small and stable -code base that can easily be extended to support other platforms and -integrates easily. ENet makes no assumptions about the underlying -platform's endianess or word size. - -@section Freedom Freedom - -ENet demands no royalties and doesn't carry a viral license that would -restrict you in how you might use it in your programs. ENet is -licensed under a short-and-sweet MIT-style license, which gives you -the freedom to do anything you want with it (well, almost anything). - -*/ - diff --git a/source/enet/docs/install.dox b/source/enet/docs/install.dox deleted file mode 100755 index 2f0ae1b9..00000000 --- a/source/enet/docs/install.dox +++ /dev/null @@ -1,37 +0,0 @@ -/** -@page Installation Installation - -ENet should be trivially simple to integrate with most applications. -First, make sure you download the latest source distribution here @ref -SourceDistro. - -@section Unix Unix-like Operating Systems - -[to be completed] - -@subsection SolarisBSD Solaris and BSD - -When building ENet under Solaris, you must specify the -lsocket and --lnsl parameters to your compiler to ensure that the sockets library -is linked in. - -@section Windows Microsoft Windows - -Using MSVC 6 under Windows simply drag all the ENet source files into -your main project or, better yet, create a new static library project -and make your executable dependent (Project|Dependencies) on ENet. -There is also an enet.dsp provided. - -You will have to link to the Winsock2 libraries, so make sure to add -ws2_32.lib to your library list (Project Settings | Link | -Object/library modules). - -@subsection DLL DLL - -If you wish to build ENet as a DLL you must first define ENET_DLL -within the project (Project Settings | C/C++ | Preprocessor | -Preprocessor definitions) or, more invasively, simply define ENET_DLL -at the top of enet.h. - -*/ - diff --git a/source/enet/docs/license.dox b/source/enet/docs/license.dox deleted file mode 100755 index a72c6ea9..00000000 --- a/source/enet/docs/license.dox +++ /dev/null @@ -1,26 +0,0 @@ -/** - @page License License - -Copyright (c) 2002 Lee Salzman - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - diff --git a/source/enet/docs/mainpage.dox b/source/enet/docs/mainpage.dox deleted file mode 100755 index 813b6576..00000000 --- a/source/enet/docs/mainpage.dox +++ /dev/null @@ -1,67 +0,0 @@ -/** @mainpage enet -
http://enet.bespin.org
-
- -ENet's purpose is to provide a relatively thin, simple and robust -network communication layer on top of UDP (User Datagram Protocol). -The primary feature it provides is optional reliable, in-order -delivery of packets. - -ENet is NOT intended to be a general purpose high level networking -library that handles authentication, lobbying, server discovery, -compression, encryption and other high level, often application level -or dependent tasks. - -@ref Features - -@ref SourceDistro - -@ref Installation - -@ref Tutorial - -@ref MailingList - -@ref FAQ - -@ref License - - */ - -/** -@page SourceDistro Source Distribution - -You can retrieve the source to ENet by downloading it in either .tar.gz form -or accessing the cvs distribution directly. - -The most recent stable release (1.0) can be downloaded here. - -To access ENet via anonymous CVS, you must use the CVSROOT -:pserver:anonymous\@bespin.org:/var/lib/cvs/enet with an empty -password. - -@code - $ cvs -z3 -d :pserver:anonymous@bespin.org:/var/lib/cvs/enet login -@endcode - Hit the return key when prompted for a password. -@code - $ cvs -z3 -d :pserver:anonymous@bespin.org:/var/lib/cvs/enet co -l . - $ cvs -z3 co enet -@endcode - -This will create a CVS directory in the current directory, and with -the second command will proceed to check the enet module out of CVS. -Any problems with CVS access or request for write access should be -sent via email to @ref MailingList. - -*/ - -/** -@page MailingList ENet Mailing List - -The -enet-discuss list is for discussion of ENet, including bug reports -or feature requests. - -*/ diff --git a/source/enet/docs/tutorial.dox b/source/enet/docs/tutorial.dox deleted file mode 100755 index 7829d6c0..00000000 --- a/source/enet/docs/tutorial.dox +++ /dev/null @@ -1,349 +0,0 @@ -/** -@page Tutorial Tutorial - -@ref Initialization - -@ref CreateServer - -@ref CreateClient - -@ref ManageHost - -@ref SendingPacket - -@ref Disconnecting - -@ref Connecting - -@section Initialization Initialization - -Before using ENet, you must call enet_initialize() to initialize the -library. Upon program exit, you should call enet_deinitialize() so -that the library may clean up any used resources. - -@code -int -main (int argc, char ** argv) -{ - if (enet_initialize () != 0) - { - fprintf (stderr, "An error occurred while initializing ENet.\n"); - return EXIT_FAILURE; - } - atexit (enet_deinitialize); - ... - ... - ... -} -@endcode - -@section CreateServer Creating an ENet server - -Servers in ENet are constructed with enet_host_create(). You must -specify an address on which to receive data and new connections, as -well as the maximum allowable numbers of connected peers. You may -optionally specify the incoming and outgoing bandwidth of the server -in bytes per second so that ENet may try to statically manage -bandwidth resources among connected peers in addition to its dynamic -throttling algorithm; specifying 0 for these two options will cause -ENet to rely entirely upon its dynamic throttling algorithm to manage -bandwidth. - -When done with a host, the host may be destroyed with -enet_host_destroy(). All connected peers to the host will be reset, -and the resources used by the host will be freed. - -@code - ENetAddress address; - ENetHost * server; - - /* Bind the server to the default localhost. */ - /* A specific host address can be specified by */ - /* enet_address_set_host (& address, "x.x.x.x"); */ - - address.host = ENET_HOST_ANY; - /* Bind the server to port 1234. */ - address.port = 1234; - - server = enet_host_create (& address /* the address to bind the server host to */, - 32 /* allow up to 32 clients and/or outgoing connections */, - 0 /* assume any amount of incoming bandwidth */, - 0 /* assume any amount of outgoing bandwidth */); - if (server == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet server host.\n"); - exit (EXIT_FAILURE); - } - ... - ... - ... - enet_host_destroy(server); -@endcode - -@section CreateClient Creating an ENet client - -Clients in ENet are similarly constructed with enet_host_create() when -no address is specified to bind the host to. Bandwidth may be -specified for the client host as in the above example. The peer count -controls the maximum number of connections to other server hosts that -may be simultaneously open. - -@code - ENetHost * client; - - client = enet_host_create (NULL /* create a client host */, - 1 /* only allow 1 outgoing connection */, - 57600 / 8 /* 56K modem with 56 Kbps downstream bandwidth */, - 14400 / 8 /* 56K modem with 14 Kbps upstream bandwidth */); - - if (client == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet client host.\n"); - exit (EXIT_FAILURE); - } - ... - ... - ... - enet_host_destroy(client); -@endcode - -@section ManageHost Managing an ENet host - -ENet uses a polled event model to notify the programmer of significant -events. ENet hosts are polled for events with enet_host_service(), -where an optional timeout value in milliseconds may be specified to -control how long ENet will poll; if a timeout of 0 is specified, -enet_host_service() will return immediately if there are no events to -dispatch. enet_host_service() will return 1 if an event was dispatched -within the specified timeout. - -Currently there are only four types of significant events in ENet: - -An event of type ENET_EVENT_TYPE_NONE is returned if no event occurred -within the specified time limit. enet_host_service() will return 0 -with this event. - -An event of type ENET_EVENT_TYPE_CONNECT is returned when either a new client -host has connected to the server host or when an attempt to establish a -connection with a foreign host has succeeded. Only the "peer" field of the -event structure is valid for this event and contains the newly connected peer. - -An event of type ENET_EVENT_TYPE_RECEIVE is returned when a packet is received -from a connected peer. The "peer" field contains the peer the packet was -received from, "channelID" is the channel on which the packet was sent, and -"packet" is the packet that was sent. The packet contained in the "packet" -field must be destroyed with enet_packet_destroy() when you are done -inspecting its contents. - -An event of type ENET_EVENT_TYPE_DISCONNECT is returned when a connected peer -has either explicitly disconnected or timed out. Only the "peer" field of the -event structure is valid for this event and contains the peer that -disconnected. Only the "data" field of the peer is still valid on a -disconnect event and must be explicitly reset. - -@code - ENetEvent event; - - /* Wait up to 1000 milliseconds for an event. */ - while (enet_host_service (client, & event, 1000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - printf ("A new client connected from %x:%u.\n", - event.peer -> address.host, - event.peer -> address.port); - - /* Store any relevant client information here. */ - event.peer -> data = "Client information"; - - break; - - case ENET_EVENT_TYPE_RECEIVE: - printf ("A packet of length %u containing %s was received from %s on channel %u.\n", - event.packet -> dataLength, - event.packet -> data, - event.peer -> data, - event.channelID); - - /* Clean up the packet now that we're done using it. */ - enet_packet_destroy (event.packet); - - break; - - case ENET_EVENT_TYPE_DISCONNECT: - printf ("%s disconected.\n", event.peer -> data); - - /* Reset the peer's client information. */ - - event.peer -> data = NULL; - } - } - ... - ... - ... -@endcode - -@section SendingPacket Sending a packet to an ENet peer - -Packets in ENet are created with enet_packet_create(), where the size -of the packet must be specified. Optionally, initial data may be -specified to copy into the packet. - -Certain flags may also be supplied to enet_packet_create() to control -various packet features: - -ENET_PACKET_FLAG_RELIABLE specifies that the packet must use reliable -delivery. A reliable packet is guarenteed to be delivered, and a -number of retry attempts will be made until an acknowledgement is -received from the foreign host the packet is sent to. If a certain -number of retry attempts is reached without any acknowledgement, ENet -will assume the peer has disconnected and forcefully reset the -connection. If this flag is not specified, the packet is assumed an -unreliable packet, and no retry attempts will be made nor -acknowledgements generated. - -A packet may be resized (extended or truncated) with -enet_packet_resize(). - -A packet is sent to a foreign host with -enet_peer_send(). enet_peer_send() accepts a channel id over which to -send the packet to a given peer. Once the packet is handed over to -ENet with enet_peer_send(), ENet will handle its deallocation and -enet_packet_destroy() should not be used upon it. - -One may also use enet_host_broadcast() to send a packet to all -connected peers on a given host over a specified channel id, as with -enet_peer_send(). - -Queued packets will be sent on a call to enet_host_service(). -Alternatively, enet_host_flush() will send out queued packets without -dispatching any events. - -@code - /* Create a reliable packet of size 7 containing "packet\0" */ - ENetPacket * packet = enet_packet_create ("packet", - strlen ("packet") + 1, - ENET_PACKET_FLAG_RELIABLE); - - /* Extend the packet so and append the string "foo", so it now */ - /* contains "packetfoo\0" */ - enet_packet_resize (packet, strlen ("packetfoo") + 1); - strcpy (& packet -> data [strlen ("packet")], "foo"); - - /* Send the packet to the peer over channel id 0. */ - /* One could also broadcast the packet by */ - /* enet_host_broadcast (host, 0, packet); */ - enet_peer_send (peer, 0, packet); - ... - ... - ... - /* One could just use enet_host_service() instead. */ - enet_host_flush (host); -@endcode - -@section Disconnecting Disconnecting an ENet peer - -Peers may be gently disconnected with enet_peer_disconnect(). A -disconnect request will be sent to the foreign host, and ENet will -wait for an acknowledgement from the foreign host before finally -disconnecting. An event of type ENET_EVENT_TYPE_DISCONNECT will be -generated once the disconnection succeeds. Normally timeouts apply to -the disconnect acknowledgement, and so if no acknowledgement is -received after a length of time the peer will be forcefully -disconnected. - -enet_peer_reset() will forcefully disconnect a peer. The foreign host -will get no notification of a disconnect and will time out on the -foreign host. No event is generated. - -@code - ENetEvent event; - - enet_peer_disconnect (peer, 0); - - /* Allow up to 3 seconds for the disconnect to succeed - * and drop any packets received packets. - */ - while (enet_host_service (client, & event, 3000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_RECEIVE: - enet_packet_destroy (event.packet); - break; - - case ENET_EVENT_TYPE_DISCONNECT: - puts ("Disconnection succeeded."); - return; - ... - ... - ... - } - } - - /* We've arrived here, so the disconnect attempt didn't */ - /* succeed yet. Force the connection down. */ - enet_peer_reset (peer); - ... - ... - ... -@endcode - -@section Connecting Connecting to an ENet host - -A connection to a foreign host is initiated with enet_host_connect(). -It accepts the address of a foreign host to connect to, and the number -of channels that should be allocated for communication. If N channels -are allocated for use, their channel ids will be numbered 0 through -N-1. A peer representing the connection attempt is returned, or NULL -if there were no available peers over which to initiate the -connection. When the connection attempt succeeds, an event of type -ENET_EVENT_TYPE_CONNECT will be generated. If the connection attempt -times out or otherwise fails, an event of type -ENET_EVENT_TYPE_DISCONNECT will be generated. - -@code - ENetAddress address; - ENetEvent event; - ENetPeer *peer; - - /* Connect to some.server.net:1234. */ - enet_address_set_host (& address, "some.server.net"); - address.port = 1234; - - /* Initiate the connection, allocating the two channels 0 and 1. */ - peer = enet_host_connect (client, & address, 2); - - if (peer == NULL) - { - fprintf (stderr, - "No available peers for initiating an ENet connection.\n"); - exit (EXIT_FAILURE); - } - - /* Wait up to 5 seconds for the connection attempt to succeed. */ - if (enet_host_service (client, & event, 5000) > 0 && - event.type == ENET_EVENT_TYPE_CONNECT) - { - puts ("Connection to some.server.net:1234 succeeded."); - ... - ... - ... - } - else - { - /* Either the 5 seconds are up or a disconnect event was */ - /* received. Reset the peer in the event the 5 seconds */ - /* had run out without any significant event. */ - enet_peer_reset (peer); - - puts ("Connection to some.server.net:1234 failed."); - } - ... - ... - ... -@endcode -*/ diff --git a/source/enet/enet.dsp b/source/enet/enet.dsp deleted file mode 100755 index d5b6df02..00000000 --- a/source/enet/enet.dsp +++ /dev/null @@ -1,164 +0,0 @@ -# Microsoft Developer Studio Project File - Name="enet" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=enet - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "enet.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "enet.mak" CFG="enet - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "enet - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "enet - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "enet - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /O2 /I "include/enet" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "enet - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "\temp\enet\Debug" -# PROP Intermediate_Dir "\temp\enet\Debug" -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "include/enet" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "enet - Win32 Release" -# Name "enet - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\host.c -# End Source File -# Begin Source File - -SOURCE=.\list.c -# End Source File -# Begin Source File - -SOURCE=.\callbacks.c -# End Source File -# Begin Source File - -SOURCE=.\packet.c -# End Source File -# Begin Source File - -SOURCE=.\peer.c -# End Source File -# Begin Source File - -SOURCE=.\protocol.c -# End Source File -# Begin Source File - -SOURCE=.\unix.c -# End Source File -# Begin Source File - -SOURCE=.\win32.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\include\enet\enet.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\list.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\callbacks.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\protocol.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\time.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\types.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\unix.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\utility.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\win32.h -# End Source File -# End Group -# End Target -# End Project diff --git a/source/enet/enet.txt b/source/enet/enet.txt deleted file mode 100644 index 31b3b97f..00000000 --- a/source/enet/enet.txt +++ /dev/null @@ -1,291 +0,0 @@ - - The file that should be included to use the ENet API. - -uint8 - unsigned 8 bit integer -uint16 - unsigned 16 bit integer -uint32 - unsigned 32 bit integer - -typedef struct -{ - uint32 host; - uint16 port; -} ENetAddress; - - Portable internet address structure. The host must be specified in network -byte-order, and the port must be in host byte-order. The constant ENET_HOST_ANY -may be used to specify the default server host. - -typedef struct -{ - uint32 flags; - uint8 * data; - size_t dataLength; -} ENetPacket; - - An ENet data packet that may be sent or received from a peer. The shown fields -should only be read and never modified. The data field contains the allocated data -for the packet. The dataLength fields specifies the length of the allocated data. -The flags field is either 0 (specifying no flags), or a bitwise-or of any -combination of the following flags: - - ENET_PACKET_FLAG_RELIABLE - - - Specifies that the packet must be received by the target peer and that resend - attempts should be made should delivery of the packet fail. - -typedef struct -{ - ENetAddress address; - void * data; - size_t channelCount; - uint32 incomingBandwidth; - uint32 outgoingBandwidth; - uint32 roundTripTime; - uint32 packetLoss; -} ENetPeer; - - An ENet peer which data packets may be sent or received from. No fields should be -modified unless otherwise specified. The address field contains the internet address -of the peer. The data fields may be used to associate any desired data with the peer -and may be freely modified. The channelCount field tells the number of channels that -have been allocated for use to communnicate with the peer. The incomingBandwidth field -specifies the downstream bandwidth of the client in bytes per second. The -outgoingBandwidth field specifies the upstream bandwidth of the client in bytes per -second. The roundTripTime field tells the mean round trip time from the sending of -a reliable packet until the receipt of its acknowledgement in milliseconds. The -packetLoss field tells the mean packet loss of reliable packets as a ratio with -respect to the constant ENET_PEER_PACKET_LOSS_SCALE. - -typedef enum -{ - ENET_EVENT_TYPE_NONE, - ENET_EVENT_TYPE_CONNECT, - ENET_EVENT_TYPE_DISCONNECT, - ENET_EVENT_TYPE_RECEIVE -} ENetEventType; - -typedef struct _ENetEvent -{ - ENetEventType type; - ENetPeer * peer; - uint8 channelID; - ENetPacket * packet; -} ENetEvent; - - An ENet event as returned by enet_host_service. The type field contains the type -of the event, which may be any one of the following: - - ENET_EVENT_TYPE_NONE - No event occurred within the specified time limit. - ENET_EVENT_TYPE_CONNECT - - - A connection request initiated by enet_host_connect has completed. The peer field - contains the peer which successfully connected. - - ENET_EVENT_TYPE_DISCONNECT - - - A peer has disconnected. This event is generated on successful completion of a - disconnect iniated by enet_peer_disconnect, if a peer has timed out, or if a - connection request initialized by enet_host_connect has timed out. The peer field - contains the peer which disconnected. - - ENET_EVENT_TYPE_RECEIVE - - - A packet has been received from a peer. The peer field specifies the peer which - send the packet. The channelID field specifies the channel number upon which the - packet was received. The packet field contains the packet that was destroyed; this - packet must be destroyed with enet_packet_destroy after use. - -typedef struct -{ - ENetAddress address; - uint32 incomingBandwidth; - uint32 outgoingBandwidth; - ENetPeer * peers; - size_t peerCount; -} ENetHost; - - An ENet host for communicating with peers. No fields should be modified. The address -field tells the internet address of the host. The incomingBandwidth field tells the downstream -bandwidth of the host. The outgoingBandwidth field specifies the upstream bandwidth of the host. -The peers field contains an array of the peers that have been allocated for this host. The -peerCount field specifies the number of peers that have been allocated for this host. - -address -unsigned ENET_HOST_TO_NET_8 (unsigned); -unsigned ENET_HOST_TO_NET_16 (unsigned); -unsigned ENET_HOST_TO_NET_32 (unsigned); - - Macros that convert from host byte-order to network byte-order (big -endian) for unsigned integers of 8 bits, 16 bits, and 32 bits repectively. - -unsigned ENET_NET_TO_HOST_8 (unsigned); -unsigned ENET_NET_TO_HOST_16 (unsigned); -unsigned ENET_NET_TO_HOST_32 (unsigned); - - Macros that convert from network byte-order (big endian) to host -byte-order for unsigned integers of 8 bits, 16 bits, and 32 bits repectively. - -uint32 enet_time_get (void); - - Returns the wall-time in milliseconds. Its initial value is unspecified unless -otherwise set. - -void enet_time_set (uint32); - - Sets the current wall-time in milliseconds. - -int enet_initialize (void); - - Initialize ENet for use. Must be called prior to using any functions in ENet. -Returns 0 on success and -1 on failure. - -void enet_deinitialize (void); - - Clean-up ENet after use. Should be called when a program that has initialized -and used ENet exits. - -int enet_address_set_host (ENetAddress * address, const char * hostName); - - Attempts to resolve the host named by the parameter hostName and sets the host -field in the address parameter if successful. Returns 0 on success and -1 on -failure. - -int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength); - - Attempts to do a reverse lookup of the host field in the address parameter. -If successful, the name of the host is placed in the string described by -hostName and nameLength. The host name is always null-delimited and will -not exceed nameLength in length. Returns 0 on success and -1 on failure. - -ENetPacket * enet_packet_create (const void * dataContents, size_t dataLength, uint32 flags); - - Creates a packet that may be sent to a peer. The dataContents parameter -specifies the initial contents of the packet's data; the packet's data will -remain uninitialized if dataContents is NULL. The dataLength parameter specifies -the size of the data that is allocated for this packet. The flags parameter -specifies flags for this packet as described for the ENetPacket structure. -Returns the packet on success and NULL on failure. - -void enet_packet_destroy (ENetPacket * packet); - - Destroys the packet and deallocates its data. - -int enet_packet_resize (ENetPacket * packet, size_t dataLength); - - Attempts to resize the data in the packet to the length specified in the -dataLength parameter. Returns 0 on success and -1 on failure. - -ENetHost * enet_host_create (const ENetAddress * address, size_t peerCount, uint32 incomingBandwidth, uint32 outgoingBandwidth); - - Creates a host for communicating with peers. The address parameter specifies -the address at which other peers may connect to this host; if the address parameter -is NULL, then no peers may connect to the host. The peerCount parameter specifies -the numbers of peers that should be allocated for the host; this limits the maximum -number of peers that may connect to this host to peerCount. The incomingBandwidth -parameter specifies the downstream bandwidth of the host in bytes per second; if -the incomingBandwidth parameter is 0, ENet will assume the host has unlimited -downstream bandwidth. The outgoingBandwidth parameter specifies the upstream bandwidth -of the host in bytes per second; if the outgoingBandwidth parameter is 0, ENet will -assume the host has unlimited upstream bandwidth. ENet will strategically drop packets -on specific sides of a connection between hosts to ensure the host's bandwidth is not -overwhelmed; the bandwidth parameters also determine the window size of a connection -which limits the amount of reliable packets that may be in transit at any given time. -Returns the host on success and NULL on failure. - -void enet_host_destroy (ENetHost * host); - - Destroys the host and all resources associated with it. - -ENetPeer * enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelCount); - - Initiates a connection from the host specified in the host parameter to a foreign -host whose internet address is specified by the address parameter. The channelCount -parameter specifies the number of channels that should be allocated for communicating -with the foreign host. Returns a peer representing the foreign host on success and NULL -on failure. The peer returned will have not completed the connection until enet_host_service -notifies of an ENET_EVENT_TYPE_CONNECT event for the peer. - -int enet_host_service (ENetHost * host, ENetEvent * event, uint32 timeout); - - Waits for events on the host specified by the host parameters and shuttles packets -between the host and its peers. The event parameter specifies an event structure -where event details will be placed if one occurs. The timeout field specifies an -amount of time in milliseconds that ENet should wait for events. Returns 1 if an -event occured within the specified time limit, 0 if no event occurred within the -time limit, and -1 on failure. This function must be called frequently for adequate -performance. - -void enet_host_flush (ENetHost * host); - - Sends out any queued packets on the host specified in the host parameters to -the designated peers. This function need only be used in circumstances where one -wishes to send queued packets earlier than in a call to enet_host_service. - -void enet_host_broadcast (ENetHost * host, uint8 channelID, ENetPacket * packet); - - Queues a packet to be sent to all peers on the host specified in the host parameter -over the channel number identified by the channelID parameter. - -void enet_host_bandwidth_limit (ENetHost * host, uint32 incomingBandwidth, uint32 outgoingBandwidth); - - Adjusts the bandwidth limits of the host specified in the host parameter. The -incomingBandwidth and outgoingBandwidth parameters are as specified in a call to -enet_host_create. - -int enet_peer_send (ENetPeer * peer, uint8 channelID, ENetPacket * packet); - - Queues a packet to be sent to the peer specified by the peer parameter over the -channel number identified by the channelID parameter. Returns 0 on success and -1 -on failure. - -ENetPacket * enet_peer_receive (ENetPeer * peer, uint8 channelID); - - Attempts to dequeue any incoming queued packets on the peer specified by the peer -parameter on the channel number identified by the channelID parameter. Returns a packet -if one is available and NULL if there are no available incoming queued packets. - -void enet_peer_ping (ENetPeer * peer); - - Sends a ping request to the peer specified by the peer parameter. Ping requests factor -into the mean round trip time as designated by the roundTripTime field in the ENetPeer -structure. ENet automatically pings all connected peer at an interval, however, this -function may be called to ensure more frequent ping requests. - -void enet_peer_reset (ENetPeer * peer); - - Forcefully disconnects the peer specified by the peer parameter. The foreign host -represented by the peer is not notified of the disconnection and so will timeout on its -connection to the local host. - -void enet_peer_disconnect (ENetPeer * peer); - - Request a disconnection from the peer specified by the peer parameter. An -ENET_EVENT_DISCONNECT event will be generated by enet_host_service once the -disconnection is complete. - -void enet_peer_throttle_configure (ENetPeer * peer, uint32 interval, uint32 acceleration, uint32 deceleration); - - Configures throttle parameter for the peer specified by the peer parameter. -Unreliable packets are dropped by ENet in response to the varying conditions of -the internet connection to the peer. The throttle represents a probability that -an unreliable packet should not be dropped and thus sent by ENet to the peer. -The lowest mean round trip time from the sending of a reliable packet to the -receipt of its acknowledgement is measured over an amount of time specified -by the interval parameter in milliseconds; the constant ENET_PEER_PACKET_THROTTLE_INTERVAL -is the default value for this parameter. If a measured round trip time happens -to be signifigantly less than the mean round trip time measured over the interval, -then the throttle probability is increased to allow more traffic by an amount -specified in the acceleration parameter which is in ratio to the -ENET_PEER_PACKET_THROTTLE_SCALE constant. If a measured round trip time happens -to be signifigantly greater than the mean round trip time measured over the interval, -then the throttle probability is decreased to limit traffic by an amount specified -in the deceleration parameter which is in ratio to the ENET_PEER_PACKET_THROTTLE_SCALE -constant. When the throttle has a value of ENET_PEER_PACKET_THROTTLE_SCALE, no unreliable -packets are dropped by ENET, and so 100% of all unreliable packets will be sent. When the -throttle has a value of 0, all unreliable packets are dropped by ENet, and so 0% of all -unreliable packets will be sent. Intermediate values for the throttle represent intermediate -probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits -of the local and foreign host are taken into account to determine a sensible limit for -the throttle probability above which it should not raise even in the best of conditions. - - - diff --git a/source/enet/host.c b/source/enet/host.c deleted file mode 100755 index 5633fb9e..00000000 --- a/source/enet/host.c +++ /dev/null @@ -1,391 +0,0 @@ -/** - @file host.c - @brief ENet host management functions -*/ -#define ENET_BUILDING_LIB 1 -#include -#include "enet/enet.h" - -/** @defgroup host ENet host functions - @{ -*/ - -/** Creates a host for communicating to peers. - - @param address the address at which other peers may connect to this host. If NULL, then no peers may connect to the host. - @param peerCount the maximum number of peers that should be allocated for the host. - @param incomingBandwidth downstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth. - @param outgoingBandwidth upstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth. - - @returns the host on success and NULL on failure - - @remarks ENet will strategically drop packets on specific sides of a connection between hosts - to ensure the host's bandwidth is not overwhelmed. The bandwidth parameters also determine - the window size of a connection which limits the amount of reliable packets that may be in transit - at any given time. -*/ -ENetHost * -enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth) -{ - ENetHost * host = (ENetHost *) enet_malloc (sizeof (ENetHost)); - ENetPeer * currentPeer; - - if (peerCount > ENET_PROTOCOL_MAXIMUM_PEER_ID) - return NULL; - - host -> peers = (ENetPeer *) enet_malloc (peerCount * sizeof (ENetPeer)); - memset (host -> peers, 0, peerCount * sizeof (ENetPeer)); - - host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM, address); - if (host -> socket == ENET_SOCKET_NULL) - { - enet_free (host -> peers); - enet_free (host); - - return NULL; - } - - if (address != NULL) - host -> address = * address; - - host -> incomingBandwidth = incomingBandwidth; - host -> outgoingBandwidth = outgoingBandwidth; - host -> bandwidthThrottleEpoch = 0; - host -> recalculateBandwidthLimits = 0; - host -> mtu = ENET_HOST_DEFAULT_MTU; - host -> peerCount = peerCount; - host -> lastServicedPeer = host -> peers; - host -> commandCount = 0; - host -> bufferCount = 0; - host -> receivedAddress.host = ENET_HOST_ANY; - host -> receivedAddress.port = 0; - host -> receivedDataLength = 0; - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - currentPeer -> host = host; - currentPeer -> incomingPeerID = currentPeer - host -> peers; - currentPeer -> data = NULL; - - enet_list_clear (& currentPeer -> acknowledgements); - enet_list_clear (& currentPeer -> sentReliableCommands); - enet_list_clear (& currentPeer -> sentUnreliableCommands); - enet_list_clear (& currentPeer -> outgoingReliableCommands); - enet_list_clear (& currentPeer -> outgoingUnreliableCommands); - - enet_peer_reset (currentPeer); - } - - return host; -} - -/** Destroys the host and all resources associated with it. - @param host pointer to the host to destroy -*/ -void -enet_host_destroy (ENetHost * host) -{ - ENetPeer * currentPeer; - - enet_socket_destroy (host -> socket); - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - enet_peer_reset (currentPeer); - } - - enet_free (host -> peers); - enet_free (host); -} - -/** Initiates a connection to a foreign host. - @param host host seeking the connection - @param address destination for the connection - @param channelCount number of channels to allocate - @returns a peer representing the foreign host on success, NULL on failure - @remarks The peer returned will have not completed the connection until enet_host_service() - notifies of an ENET_EVENT_TYPE_CONNECT event for the peer. -*/ -ENetPeer * -enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelCount) -{ - ENetPeer * currentPeer; - ENetChannel * channel; - ENetProtocol command; - - if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT) - channelCount = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT; - else - if (channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) - channelCount = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT; - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED) - break; - } - - if (currentPeer >= & host -> peers [host -> peerCount]) - return NULL; - - currentPeer -> state = ENET_PEER_STATE_CONNECTING; - currentPeer -> address = * address; - currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel)); - currentPeer -> channelCount = channelCount; - currentPeer -> sessionID = (enet_uint32) enet_rand (); - - if (host -> outgoingBandwidth == 0) - currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - else - currentPeer -> windowSize = (host -> outgoingBandwidth / - ENET_PEER_WINDOW_SIZE_SCALE) * - ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - - if (currentPeer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) - currentPeer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - else - if (currentPeer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) - currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - - for (channel = currentPeer -> channels; - channel < & currentPeer -> channels [channelCount]; - ++ channel) - { - channel -> outgoingReliableSequenceNumber = 0; - channel -> outgoingUnreliableSequenceNumber = 0; - channel -> incomingReliableSequenceNumber = 0; - channel -> incomingUnreliableSequenceNumber = 0; - - enet_list_clear (& channel -> incomingReliableCommands); - enet_list_clear (& channel -> incomingUnreliableCommands); - } - - command.header.command = ENET_PROTOCOL_COMMAND_CONNECT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.header.channelID = 0xFF; - command.connect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID); - command.connect.mtu = ENET_HOST_TO_NET_16 (currentPeer -> mtu); - command.connect.windowSize = ENET_HOST_TO_NET_32 (currentPeer -> windowSize); - command.connect.channelCount = ENET_HOST_TO_NET_32 (channelCount); - command.connect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth); - command.connect.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); - command.connect.packetThrottleInterval = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleInterval); - command.connect.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleAcceleration); - command.connect.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleDeceleration); - command.connect.sessionID = currentPeer -> sessionID; - - enet_peer_queue_outgoing_command (currentPeer, & command, NULL, 0, 0); - - return currentPeer; -} - -/** Queues a packet to be sent to all peers associated with the host. - @param host host on which to broadcast the packet - @param channelID channel on which to broadcast - @param packet packet to broadcast -*/ -void -enet_host_broadcast (ENetHost * host, enet_uint8 channelID, ENetPacket * packet) -{ - ENetPeer * currentPeer; - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) - continue; - - enet_peer_send (currentPeer, channelID, packet); - } - - if (packet -> referenceCount == 0) - enet_packet_destroy (packet); -} - -/** Adjusts the bandwidth limits of a host. - @param host host to adjust - @param incomingBandwidth new incoming bandwidth - @param outgoingBandwidth new outgoing bandwidth - @remarks the incoming and outgoing bandwidth parameters are identical in function to those - specified in enet_host_create(). -*/ -void -enet_host_bandwidth_limit (ENetHost * host, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth) -{ - host -> incomingBandwidth = incomingBandwidth; - host -> outgoingBandwidth = outgoingBandwidth; - host -> recalculateBandwidthLimits = 1; -} - -void -enet_host_bandwidth_throttle (ENetHost * host) -{ - enet_uint32 timeCurrent = enet_time_get (), - elapsedTime = timeCurrent - host -> bandwidthThrottleEpoch, - peersTotal = 0, - dataTotal = 0, - peersRemaining, - bandwidth, - throttle = 0, - bandwidthLimit = 0; - int needsAdjustment; - ENetPeer * peer; - ENetProtocol command; - - if (elapsedTime < ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL) - return; - - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) - continue; - - ++ peersTotal; - dataTotal += peer -> outgoingDataTotal; - } - - if (peersTotal == 0) - return; - - peersRemaining = peersTotal; - needsAdjustment = 1; - - if (host -> outgoingBandwidth == 0) - bandwidth = ~0; - else - bandwidth = (host -> outgoingBandwidth * elapsedTime) / 1000; - - while (peersRemaining > 0 && needsAdjustment != 0) - { - needsAdjustment = 0; - - if (dataTotal < bandwidth) - throttle = ENET_PEER_PACKET_THROTTLE_SCALE; - else - throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal; - - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - enet_uint32 peerBandwidth; - - if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || - peer -> incomingBandwidth == 0 || - peer -> outgoingBandwidthThrottleEpoch == timeCurrent) - continue; - - peerBandwidth = (peer -> incomingBandwidth * elapsedTime) / 1000; - if ((throttle * peer -> outgoingDataTotal) / ENET_PEER_PACKET_THROTTLE_SCALE <= peerBandwidth) - continue; - - peer -> packetThrottleLimit = (peerBandwidth * - ENET_PEER_PACKET_THROTTLE_SCALE) / peer -> outgoingDataTotal; - - if (peer -> packetThrottleLimit == 0) - peer -> packetThrottleLimit = 1; - - if (peer -> packetThrottle > peer -> packetThrottleLimit) - peer -> packetThrottle = peer -> packetThrottleLimit; - - peer -> outgoingBandwidthThrottleEpoch = timeCurrent; - - - needsAdjustment = 1; - -- peersRemaining; - bandwidth -= peerBandwidth; - dataTotal -= peerBandwidth; - } - } - - if (peersRemaining > 0) - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || - peer -> outgoingBandwidthThrottleEpoch == timeCurrent) - continue; - - peer -> packetThrottleLimit = throttle; - - if (peer -> packetThrottle > peer -> packetThrottleLimit) - peer -> packetThrottle = peer -> packetThrottleLimit; - } - - if (host -> recalculateBandwidthLimits) - { - host -> recalculateBandwidthLimits = 0; - - peersRemaining = peersTotal; - bandwidth = host -> incomingBandwidth; - needsAdjustment = 1; - - if (bandwidth == 0) - bandwidthLimit = 0; - else - while (peersRemaining > 0 && needsAdjustment != 0) - { - needsAdjustment = 0; - bandwidthLimit = bandwidth / peersRemaining; - - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || - peer -> incomingBandwidthThrottleEpoch == timeCurrent) - continue; - - if (peer -> outgoingBandwidth > 0 && - peer -> outgoingBandwidth >= bandwidthLimit) - continue; - - peer -> incomingBandwidthThrottleEpoch = timeCurrent; - - needsAdjustment = 1; - -- peersRemaining; - bandwidth -= peer -> outgoingBandwidth; - } - } - - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) - continue; - - command.header.command = ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.header.channelID = 0xFF; - command.bandwidthLimit.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); - - if (peer -> incomingBandwidthThrottleEpoch == timeCurrent) - command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (peer -> outgoingBandwidth); - else - command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (bandwidthLimit); - - enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); - } - } - - host -> bandwidthThrottleEpoch = timeCurrent; - - for (peer = host -> peers; - peer < & host -> peers [host -> peerCount]; - ++ peer) - { - peer -> incomingDataTotal = 0; - peer -> outgoingDataTotal = 0; - } -} - -/** @} */ diff --git a/source/enet/include/Makefile b/source/enet/include/Makefile deleted file mode 100644 index dcff6b11..00000000 --- a/source/enet/include/Makefile +++ /dev/null @@ -1,435 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# include/Makefile. Generated from Makefile.in by configure. - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -srcdir = . -top_srcdir = .. - -pkgdatadir = $(datadir)/libenet.a -pkglibdir = $(libdir)/libenet.a -pkgincludedir = $(includedir)/libenet.a -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = /usr/bin/install -c -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = include -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = aclocal-1.9 -AMDEP_FALSE = # -AMDEP_TRUE = -AMTAR = tar -AUTOCONF = autoconf -AUTOHEADER = autoheader -AUTOMAKE = automake-1.9 -AWK = gawk -CC = gcc -CCDEPMODE = depmode=gcc3 -CFLAGS = -g -O2 -CPP = gcc -E -CPPFLAGS = -CYGPATH_W = echo -DEFS = -DPACKAGE_NAME=\"libenet\" -DPACKAGE_TARNAME=\"libenet\" -DPACKAGE_VERSION=\"10-31-2006\" -DPACKAGE_STRING=\"libenet\ 10-31-2006\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libenet.a\" -DVERSION=\"10-31-2006\" -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_SOCKLEN_T=1 -DEPDIR = .deps -ECHO_C = -ECHO_N = -n -ECHO_T = -EGREP = /bin/grep -E -EXEEXT = -GREP = /bin/grep -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_PROGRAM = ${INSTALL} -INSTALL_SCRIPT = ${INSTALL} -INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s -LDFLAGS = -LIBOBJS = -LIBS = -LTLIBOBJS = -MAKEINFO = makeinfo -OBJEXT = o -PACKAGE = libenet.a -PACKAGE_BUGREPORT = -PACKAGE_NAME = libenet -PACKAGE_STRING = libenet 10-31-2006 -PACKAGE_TARNAME = libenet -PACKAGE_VERSION = 10-31-2006 -PATH_SEPARATOR = : -RANLIB = ranlib -SET_MAKE = -SHELL = /bin/sh -STRIP = -VERSION = 10-31-2006 -ac_ct_CC = gcc -am__fastdepCC_FALSE = # -am__fastdepCC_TRUE = -am__include = include -am__leading_dot = . -am__quote = -am__tar = ${AMTAR} chof - "$$tardir" -am__untar = ${AMTAR} xf - -bindir = ${exec_prefix}/bin -build_alias = -datadir = ${datarootdir} -datarootdir = ${prefix}/share -docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} -dvidir = ${docdir} -exec_prefix = ${prefix} -host_alias = -htmldir = ${docdir} -includedir = ${prefix}/include -infodir = ${datarootdir}/info -install_sh = /home/lee/ac/ac/source/enet/install-sh -libdir = ${exec_prefix}/lib -libexecdir = ${exec_prefix}/libexec -localedir = ${datarootdir}/locale -localstatedir = ${prefix}/var -mandir = ${datarootdir}/man -mkdir_p = mkdir -p -- -oldincludedir = /usr/include -pdfdir = ${docdir} -prefix = /usr/local -program_transform_name = s,x,x, -psdir = ${docdir} -sbindir = ${exec_prefix}/sbin -sharedstatedir = ${prefix}/com -sysconfdir = ${prefix}/etc -target_alias = -SUBDIRS = enet -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -uninstall-info-am: - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(mkdir_p) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-info-am - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ - clean clean-generic clean-recursive ctags ctags-recursive \ - distclean distclean-generic distclean-recursive distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-generic \ - mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/include/Makefile.am b/source/enet/include/Makefile.am deleted file mode 100755 index 182de41d..00000000 --- a/source/enet/include/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = enet diff --git a/source/enet/include/Makefile.in b/source/enet/include/Makefile.in deleted file mode 100755 index 3e260432..00000000 --- a/source/enet/include/Makefile.in +++ /dev/null @@ -1,435 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = include -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -SUBDIRS = enet -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -uninstall-info-am: - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(mkdir_p) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-info-am - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ - clean clean-generic clean-recursive ctags ctags-recursive \ - distclean distclean-generic distclean-recursive distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-generic \ - mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/include/enet/Makefile b/source/enet/include/enet/Makefile deleted file mode 100644 index ab8169b8..00000000 --- a/source/enet/include/enet/Makefile +++ /dev/null @@ -1,367 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# include/enet/Makefile. Generated from Makefile.in by configure. - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - - -srcdir = . -top_srcdir = ../.. - -pkgdatadir = $(datadir)/libenet.a -pkglibdir = $(libdir)/libenet.a -pkgincludedir = $(includedir)/libenet.a -top_builddir = ../.. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = /usr/bin/install -c -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = include/enet -DIST_COMMON = $(libenetinclude_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(libenetincludedir)" -libenetincludeHEADERS_INSTALL = $(INSTALL_HEADER) -HEADERS = $(libenetinclude_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = aclocal-1.9 -AMDEP_FALSE = # -AMDEP_TRUE = -AMTAR = tar -AUTOCONF = autoconf -AUTOHEADER = autoheader -AUTOMAKE = automake-1.9 -AWK = gawk -CC = gcc -CCDEPMODE = depmode=gcc3 -CFLAGS = -g -O2 -CPP = gcc -E -CPPFLAGS = -CYGPATH_W = echo -DEFS = -DPACKAGE_NAME=\"libenet\" -DPACKAGE_TARNAME=\"libenet\" -DPACKAGE_VERSION=\"10-31-2006\" -DPACKAGE_STRING=\"libenet\ 10-31-2006\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libenet.a\" -DVERSION=\"10-31-2006\" -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_SOCKLEN_T=1 -DEPDIR = .deps -ECHO_C = -ECHO_N = -n -ECHO_T = -EGREP = /bin/grep -E -EXEEXT = -GREP = /bin/grep -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_PROGRAM = ${INSTALL} -INSTALL_SCRIPT = ${INSTALL} -INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s -LDFLAGS = -LIBOBJS = -LIBS = -LTLIBOBJS = -MAKEINFO = makeinfo -OBJEXT = o -PACKAGE = libenet.a -PACKAGE_BUGREPORT = -PACKAGE_NAME = libenet -PACKAGE_STRING = libenet 10-31-2006 -PACKAGE_TARNAME = libenet -PACKAGE_VERSION = 10-31-2006 -PATH_SEPARATOR = : -RANLIB = ranlib -SET_MAKE = -SHELL = /bin/sh -STRIP = -VERSION = 10-31-2006 -ac_ct_CC = gcc -am__fastdepCC_FALSE = # -am__fastdepCC_TRUE = -am__include = include -am__leading_dot = . -am__quote = -am__tar = ${AMTAR} chof - "$$tardir" -am__untar = ${AMTAR} xf - -bindir = ${exec_prefix}/bin -build_alias = -datadir = ${datarootdir} -datarootdir = ${prefix}/share -docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} -dvidir = ${docdir} -exec_prefix = ${prefix} -host_alias = -htmldir = ${docdir} -includedir = ${prefix}/include -infodir = ${datarootdir}/info -install_sh = /home/lee/ac/ac/source/enet/install-sh -libdir = ${exec_prefix}/lib -libexecdir = ${exec_prefix}/libexec -localedir = ${datarootdir}/locale -localstatedir = ${prefix}/var -mandir = ${datarootdir}/man -mkdir_p = mkdir -p -- -oldincludedir = /usr/include -pdfdir = ${docdir} -prefix = /usr/local -program_transform_name = s,x,x, -psdir = ${docdir} -sbindir = ${exec_prefix}/sbin -sharedstatedir = ${prefix}/com -sysconfdir = ${prefix}/etc -target_alias = -libenetincludedir = $(includedir)/enet -libenetinclude_HEADERS = \ - types.h \ - list.h \ - utility.h \ - time.h \ - callbacks.h \ - unix.h \ - win32.h \ - protocol.h \ - enet.h - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/enet/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/enet/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -uninstall-info-am: -install-libenetincludeHEADERS: $(libenetinclude_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(libenetincludedir)" || $(mkdir_p) "$(DESTDIR)$(libenetincludedir)" - @list='$(libenetinclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(libenetincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libenetincludedir)/$$f'"; \ - $(libenetincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libenetincludedir)/$$f"; \ - done - -uninstall-libenetincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(libenetinclude_HEADERS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(libenetincludedir)/$$f'"; \ - rm -f "$(DESTDIR)$(libenetincludedir)/$$f"; \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libenetincludedir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-libenetincludeHEADERS - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-info-am uninstall-libenetincludeHEADERS - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - ctags distclean distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-libenetincludeHEADERS \ - install-man install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ - uninstall uninstall-am uninstall-info-am \ - uninstall-libenetincludeHEADERS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/include/enet/Makefile.am b/source/enet/include/enet/Makefile.am deleted file mode 100755 index acefcd1b..00000000 --- a/source/enet/include/enet/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -libenetincludedir = $(includedir)/enet -libenetinclude_HEADERS = \ - types.h \ - list.h \ - utility.h \ - time.h \ - callbacks.h \ - unix.h \ - win32.h \ - protocol.h \ - enet.h - diff --git a/source/enet/include/enet/Makefile.in b/source/enet/include/enet/Makefile.in deleted file mode 100755 index bbec556b..00000000 --- a/source/enet/include/enet/Makefile.in +++ /dev/null @@ -1,367 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = ../.. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = include/enet -DIST_COMMON = $(libenetinclude_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(libenetincludedir)" -libenetincludeHEADERS_INSTALL = $(INSTALL_HEADER) -HEADERS = $(libenetinclude_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -libenetincludedir = $(includedir)/enet -libenetinclude_HEADERS = \ - types.h \ - list.h \ - utility.h \ - time.h \ - callbacks.h \ - unix.h \ - win32.h \ - protocol.h \ - enet.h - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/enet/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/enet/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -uninstall-info-am: -install-libenetincludeHEADERS: $(libenetinclude_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(libenetincludedir)" || $(mkdir_p) "$(DESTDIR)$(libenetincludedir)" - @list='$(libenetinclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(libenetincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libenetincludedir)/$$f'"; \ - $(libenetincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libenetincludedir)/$$f"; \ - done - -uninstall-libenetincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(libenetinclude_HEADERS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(libenetincludedir)/$$f'"; \ - rm -f "$(DESTDIR)$(libenetincludedir)/$$f"; \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libenetincludedir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-libenetincludeHEADERS - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-info-am uninstall-libenetincludeHEADERS - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - ctags distclean distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-libenetincludeHEADERS \ - install-man install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ - uninstall uninstall-am uninstall-info-am \ - uninstall-libenetincludeHEADERS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source/enet/include/enet/callbacks.h b/source/enet/include/enet/callbacks.h deleted file mode 100644 index be29ae05..00000000 --- a/source/enet/include/enet/callbacks.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - @file callbacks.h - @brief ENet callbacks -*/ -#ifndef __ENET_CALLBACKS_H__ -#define __ENET_CALLBACKS_H__ - -#include - -typedef struct -{ - void * (ENET_CALLBACK * malloc) (size_t size); - void (ENET_CALLBACK * free) (void * memory); - int (ENET_CALLBACK * rand) (void); -} ENetCallbacks; - -/** @defgroup callbacks ENet internal callbacks - @{ - @ingroup private -*/ -extern void * enet_malloc (size_t); -extern void enet_free (void *); -extern int enet_rand (void); - -/** @} */ - -#endif /* __ENET_CALLBACKS_H__ */ - diff --git a/source/enet/include/enet/enet.h b/source/enet/include/enet/enet.h deleted file mode 100755 index 5187aef1..00000000 --- a/source/enet/include/enet/enet.h +++ /dev/null @@ -1,446 +0,0 @@ -/** - @file enet.h - @brief ENet public header file -*/ -#ifndef __ENET_ENET_H__ -#define __ENET_ENET_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#ifdef WIN32 -#include "enet/win32.h" -#else -#include "enet/unix.h" -#endif - -#include "enet/types.h" -#include "enet/protocol.h" -#include "enet/list.h" -#include "enet/callbacks.h" - -typedef enum -{ - ENET_VERSION = 1 -} ENetVersion; - -typedef enum -{ - ENET_SOCKET_TYPE_STREAM = 1, - ENET_SOCKET_TYPE_DATAGRAM = 2 -} ENetSocketType; - -typedef enum -{ - ENET_SOCKET_WAIT_NONE = 0, - ENET_SOCKET_WAIT_SEND = (1 << 0), - ENET_SOCKET_WAIT_RECEIVE = (1 << 1) -} ENetSocketWait; - -enum -{ - ENET_HOST_ANY = 0, /**< specifies the default server host */ - ENET_HOST_BROADCAST = 0xFFFFFFFF /**< specifies a subnet-wide broadcast */ -}; - -/** - * Portable internet address structure. - * - * The host must be specified in network byte-order, and the port must be in host - * byte-order. The constant ENET_HOST_ANY may be used to specify the default - * server host. The constant ENET_HOST_BROADCAST may be used to specify the - * broadcast address (255.255.255.255). This makes sense for enet_host_connect, - * but not for enet_host_create. Once a server responds to a broadcast, the - * address is updated from ENET_HOST_BROADCAST to the server's actual IP address. - */ -typedef struct _ENetAddress -{ - enet_uint32 host; - enet_uint16 port; -} ENetAddress; - -/** - * Packet flag bit constants. - * - * The host must be specified in network byte-order, and the port must be in - * host byte-order. The constant ENET_HOST_ANY may be used to specify the - * default server host. - - @sa ENetPacket -*/ -typedef enum -{ - /** packet must be received by the target peer and resend attempts should be - * made until the packet is delivered */ - ENET_PACKET_FLAG_RELIABLE = (1 << 0), - /** packet will not be sequenced with other packets - * not supported for reliable packets - */ - ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1), - /** packet will not allocate data, and user must supply it instead */ - ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2) -} ENetPacketFlag; - -struct _ENetPacket; -typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *); - -/** - * ENet packet structure. - * - * An ENet data packet that may be sent to or received from a peer. The shown - * fields should only be read and never modified. The data field contains the - * allocated data for the packet. The dataLength fields specifies the length - * of the allocated data. The flags field is either 0 (specifying no flags), - * or a bitwise-or of any combination of the following flags: - * - * ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer - * and resend attempts should be made until the packet is delivered - - @sa ENetPacketFlag - */ -typedef struct _ENetPacket -{ - size_t referenceCount; /**< internal use only */ - enet_uint32 flags; /**< bitwise or of ENetPacketFlag constants */ - enet_uint8 * data; /**< allocated data for packet */ - size_t dataLength; /**< length of data */ - ENetPacketFreeCallback freeCallback; /**< function to be called when the packet is no longer in use */ -} ENetPacket; - -typedef struct _ENetAcknowledgement -{ - ENetListNode acknowledgementList; - enet_uint32 sentTime; - ENetProtocol command; -} ENetAcknowledgement; - -typedef struct _ENetOutgoingCommand -{ - ENetListNode outgoingCommandList; - enet_uint16 reliableSequenceNumber; - enet_uint16 unreliableSequenceNumber; - enet_uint32 sentTime; - enet_uint32 roundTripTimeout; - enet_uint32 roundTripTimeoutLimit; - enet_uint32 fragmentOffset; - enet_uint16 fragmentLength; - ENetProtocol command; - ENetPacket * packet; -} ENetOutgoingCommand; - -typedef struct _ENetIncomingCommand -{ - ENetListNode incomingCommandList; - enet_uint16 reliableSequenceNumber; - enet_uint16 unreliableSequenceNumber; - ENetProtocol command; - enet_uint32 fragmentCount; - enet_uint32 fragmentsRemaining; - enet_uint32 * fragments; - ENetPacket * packet; -} ENetIncomingCommand; - -typedef enum -{ - ENET_PEER_STATE_DISCONNECTED = 0, - ENET_PEER_STATE_CONNECTING = 1, - ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2, - ENET_PEER_STATE_CONNECTION_PENDING = 3, - ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, - ENET_PEER_STATE_CONNECTED = 5, - ENET_PEER_STATE_DISCONNECT_LATER = 6, - ENET_PEER_STATE_DISCONNECTING = 7, - ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, - ENET_PEER_STATE_ZOMBIE = 9 -} ENetPeerState; - -#ifndef ENET_BUFFER_MAXIMUM -#define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS) -#endif - -enum -{ - ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024, - ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024, - ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000, - ENET_HOST_DEFAULT_MTU = 1400, - - ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500, - ENET_PEER_DEFAULT_PACKET_THROTTLE = 32, - ENET_PEER_PACKET_THROTTLE_SCALE = 32, - ENET_PEER_PACKET_THROTTLE_COUNTER = 7, - ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2, - ENET_PEER_PACKET_THROTTLE_DECELERATION = 2, - ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000, - ENET_PEER_PACKET_LOSS_SCALE = (1 << 16), - ENET_PEER_PACKET_LOSS_INTERVAL = 10000, - ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024, - ENET_PEER_TIMEOUT_LIMIT = 32, - ENET_PEER_TIMEOUT_MINIMUM = 5000, - ENET_PEER_TIMEOUT_MAXIMUM = 30000, - ENET_PEER_PING_INTERVAL = 500, - ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32 -}; - -typedef struct _ENetChannel -{ - enet_uint32 outgoingReliableSequenceNumber; - enet_uint32 outgoingUnreliableSequenceNumber; - enet_uint32 incomingReliableSequenceNumber; - enet_uint32 incomingUnreliableSequenceNumber; - ENetList incomingReliableCommands; - ENetList incomingUnreliableCommands; -} ENetChannel; - -/** - * An ENet peer which data packets may be sent or received from. - * - * No fields should be modified unless otherwise specified. - */ -typedef struct _ENetPeer -{ - struct _ENetHost * host; - enet_uint16 outgoingPeerID; - enet_uint16 incomingPeerID; - enet_uint32 sessionID; - ENetAddress address; /**< Internet address of the peer */ - void * data; /**< Application private data, may be freely modified */ - ENetPeerState state; - ENetChannel * channels; - size_t channelCount; /**< Number of channels allocated for communication with peer */ - enet_uint32 incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */ - enet_uint32 outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */ - enet_uint32 incomingBandwidthThrottleEpoch; - enet_uint32 outgoingBandwidthThrottleEpoch; - enet_uint32 incomingDataTotal; - enet_uint32 outgoingDataTotal; - enet_uint32 lastSendTime; - enet_uint32 lastReceiveTime; - enet_uint32 nextTimeout; - enet_uint32 earliestTimeout; - enet_uint32 packetLossEpoch; - enet_uint32 packetsSent; - enet_uint32 packetsLost; - enet_uint32 packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */ - enet_uint32 packetLossVariance; - enet_uint32 packetThrottle; - enet_uint32 packetThrottleLimit; - enet_uint32 packetThrottleCounter; - enet_uint32 packetThrottleEpoch; - enet_uint32 packetThrottleAcceleration; - enet_uint32 packetThrottleDeceleration; - enet_uint32 packetThrottleInterval; - enet_uint32 lastRoundTripTime; - enet_uint32 lowestRoundTripTime; - enet_uint32 lastRoundTripTimeVariance; - enet_uint32 highestRoundTripTimeVariance; - enet_uint32 roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */ - enet_uint32 roundTripTimeVariance; - enet_uint16 mtu; - enet_uint32 windowSize; - enet_uint32 reliableDataInTransit; - enet_uint16 outgoingReliableSequenceNumber; - ENetList acknowledgements; - ENetList sentReliableCommands; - ENetList sentUnreliableCommands; - ENetList outgoingReliableCommands; - ENetList outgoingUnreliableCommands; - enet_uint16 incomingUnsequencedGroup; - enet_uint16 outgoingUnsequencedGroup; - enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; - enet_uint32 disconnectData; -} ENetPeer; - -/** An ENet host for communicating with peers. - * - * No fields should be modified. - - @sa enet_host_create() - @sa enet_host_destroy() - @sa enet_host_connect() - @sa enet_host_service() - @sa enet_host_flush() - @sa enet_host_broadcast() - @sa enet_host_bandwidth_limit() - @sa enet_host_bandwidth_throttle() - */ -typedef struct _ENetHost -{ - ENetSocket socket; - ENetAddress address; /**< Internet address of the host */ - enet_uint32 incomingBandwidth; /**< downstream bandwidth of the host */ - enet_uint32 outgoingBandwidth; /**< upstream bandwidth of the host */ - enet_uint32 bandwidthThrottleEpoch; - enet_uint32 mtu; - int recalculateBandwidthLimits; - ENetPeer * peers; /**< array of peers allocated for this host */ - size_t peerCount; /**< number of peers allocated for this host */ - ENetPeer * lastServicedPeer; - int continueSending; - size_t packetSize; - enet_uint16 headerFlags; - ENetProtocol commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS]; - size_t commandCount; - ENetBuffer buffers [ENET_BUFFER_MAXIMUM]; - size_t bufferCount; - ENetAddress receivedAddress; - enet_uint8 receivedData [ENET_PROTOCOL_MAXIMUM_MTU]; - size_t receivedDataLength; -} ENetHost; - -/** - * An ENet event type, as specified in @ref ENetEvent. - */ -typedef enum -{ - /** no event occurred within the specified time limit */ - ENET_EVENT_TYPE_NONE = 0, - - /** a connection request initiated by enet_host_connect has completed. - * The peer field contains the peer which successfully connected. - */ - ENET_EVENT_TYPE_CONNECT = 1, - - /** a peer has disconnected. This event is generated on a successful - * completion of a disconnect initiated by enet_pper_disconnect, if - * a peer has timed out, or if a connection request intialized by - * enet_host_connect has timed out. The peer field contains the peer - * which disconnected. The data field contains user supplied data - * describing the disconnection, or 0, if none is available. - */ - ENET_EVENT_TYPE_DISCONNECT = 2, - - /** a packet has been received from a peer. The peer field specifies the - * peer which sent the packet. The channelID field specifies the channel - * number upon which the packet was received. The packet field contains - * the packet that was received; this packet must be destroyed with - * enet_packet_destroy after use. - */ - ENET_EVENT_TYPE_RECEIVE = 3 -} ENetEventType; - -/** - * An ENet event as returned by enet_host_service(). - - @sa enet_host_service - */ -typedef struct _ENetEvent -{ - ENetEventType type; /**< type of the event */ - ENetPeer * peer; /**< peer that generated a connect, disconnect or receive event */ - enet_uint8 channelID; /**< channel on the peer that generated the event, if appropriate */ - enet_uint32 data; /**< data associated with the event, if appropriate */ - ENetPacket * packet; /**< packet associated with the event, if appropriate */ -} ENetEvent; - -/** @defgroup global ENet global functions - @{ -*/ - -/** - Initializes ENet globally. Must be called prior to using any functions in - ENet. - @returns 0 on success, < 0 on failure -*/ -ENET_API int enet_initialize (void); - -ENET_API int enet_initialize_with_callbacks (ENetVersion, const ENetCallbacks *); - -/** - Shuts down ENet globally. Should be called when a program that has - initialized ENet exits. -*/ -ENET_API void enet_deinitialize (void); - -/** @} */ - -/** @defgroup private ENet private implementation functions */ - -/** - Returns the wall-time in milliseconds. Its initial value is unspecified - unless otherwise set. - */ -ENET_API enet_uint32 enet_time_get (void); -/** - Sets the current wall-time in milliseconds. - */ -ENET_API void enet_time_set (enet_uint32); - -/** @defgroup socket ENet socket functions - @{ -*/ -ENET_API ENetSocket enet_socket_create (ENetSocketType, const ENetAddress *); -ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *); -ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *); -ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t); -ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t); -ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32); -ENET_API void enet_socket_destroy (ENetSocket); - -/** @} */ - -/** @defgroup Address ENet address functions - @{ -*/ -/** Attempts to resolve the host named by the parameter hostName and sets - the host field in the address parameter if successful. - @param address destination to store resolved address - @param hostName host name to lookup - @retval 0 on success - @retval < 0 on failure - @returns the address of the given hostName in address on success -*/ -ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName); - -/** Attempts to do a reserve lookup of the host field in the address parameter. - @param address address used for reverse lookup - @param hostName destination for name, must not be NULL - @param nameLength maximum length of hostName. - @returns the null-terminated name of the host in hostName on success - @retval 0 on success - @retval < 0 on failure -*/ -ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength); - -/** @} */ - -ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32); -ENET_API void enet_packet_destroy (ENetPacket *); -ENET_API int enet_packet_resize (ENetPacket *, size_t); -extern enet_uint32 enet_crc32 (const ENetBuffer *, size_t); - -ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, enet_uint32, enet_uint32); -ENET_API void enet_host_destroy (ENetHost *); -ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t); -ENET_API int enet_host_service (ENetHost *, ENetEvent *, enet_uint32); -ENET_API void enet_host_flush (ENetHost *); -ENET_API void enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *); -ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32); -extern void enet_host_bandwidth_throttle (ENetHost *); - -ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *); -ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8); -ENET_API void enet_peer_ping (ENetPeer *); -ENET_API void enet_peer_reset (ENetPeer *); -ENET_API void enet_peer_disconnect (ENetPeer *, enet_uint32); -ENET_API void enet_peer_disconnect_now (ENetPeer *, enet_uint32); -ENET_API void enet_peer_disconnect_later (ENetPeer *, enet_uint32); -ENET_API void enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32); -extern int enet_peer_throttle (ENetPeer *, enet_uint32); -extern void enet_peer_reset_queues (ENetPeer *); -extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16); -extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32); -extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16); - -extern size_t enet_protocol_command_size (enet_uint8); - -#ifdef __cplusplus -} -#endif - -#endif /* __ENET_ENET_H__ */ - diff --git a/source/enet/include/enet/list.h b/source/enet/include/enet/list.h deleted file mode 100755 index 99bc4aee..00000000 --- a/source/enet/include/enet/list.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - @file list.h - @brief ENet list management -*/ -#ifndef __ENET_LIST_H__ -#define __ENET_LIST_H__ - -#include - -typedef struct _ENetListNode -{ - struct _ENetListNode * next; - struct _ENetListNode * previous; -} ENetListNode; - -typedef ENetListNode * ENetListIterator; - -typedef struct _ENetList -{ - ENetListNode sentinel; -} ENetList; - -extern void enet_list_clear (ENetList *); - -extern ENetListIterator enet_list_insert (ENetListIterator, void *); -extern void * enet_list_remove (ENetListIterator); - -extern size_t enet_list_size (ENetList *); - -#define enet_list_begin(list) ((list) -> sentinel.next) -#define enet_list_end(list) (& (list) -> sentinel) - -#define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) - -#define enet_list_next(iterator) ((iterator) -> next) -#define enet_list_previous(iterator) ((iterator) -> previous) - -#define enet_list_front(list) ((void *) (list) -> sentinel.next) -#define enet_list_back(list) ((void *) (list) -> sentinel.previous) - -#endif /* __ENET_LIST_H__ */ - diff --git a/source/enet/include/enet/memory.h b/source/enet/include/enet/memory.h deleted file mode 100755 index 13ed76eb..00000000 --- a/source/enet/include/enet/memory.h +++ /dev/null @@ -1,22 +0,0 @@ -/** - @file memory.h - @brief ENet memory management -*/ -#ifndef __ENET_MEMORY_H__ -#define __ENET_MEMORY_H__ - -#include - -/** @defgroup memory ENet internal memory management - @{ - @ingroup private -*/ -extern void * enet_malloc (size_t); -extern void * enet_realloc (void *, size_t); -extern void * enet_calloc (size_t, size_t); -extern void enet_free (void *); - -/** @} */ - -#endif /* __ENET_MEMORY_H__ */ - diff --git a/source/enet/include/enet/protocol.h b/source/enet/include/enet/protocol.h deleted file mode 100755 index 363857bc..00000000 --- a/source/enet/include/enet/protocol.h +++ /dev/null @@ -1,174 +0,0 @@ -/** - @file protocol.h - @brief ENet protocol -*/ -#ifndef __ENET_PROTOCOL_H__ -#define __ENET_PROTOCOL_H__ - -#include "enet/types.h" - -enum -{ - ENET_PROTOCOL_MINIMUM_MTU = 576, - ENET_PROTOCOL_MAXIMUM_MTU = 4096, - ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, - ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, - ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 32768, - ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, - ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, - ENET_PROTOCOL_MAXIMUM_PEER_ID = 0x7FFF -}; - -typedef enum -{ - ENET_PROTOCOL_COMMAND_NONE = 0, - ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, - ENET_PROTOCOL_COMMAND_CONNECT = 2, - ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, - ENET_PROTOCOL_COMMAND_DISCONNECT = 4, - ENET_PROTOCOL_COMMAND_PING = 5, - ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, - ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, - ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, - ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, - ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, - ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, - ENET_PROTOCOL_COMMAND_COUNT = 12, - - ENET_PROTOCOL_COMMAND_MASK = 0x0F -} ENetProtocolCommand; - -typedef enum -{ - ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), - ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), - - ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), - ENET_PROTOCOL_HEADER_FLAG_MASK = 0x8000 -} ENetProtocolFlag; - -typedef struct -{ - enet_uint32 checksum; - enet_uint16 peerID; - enet_uint16 sentTime; -} ENetProtocolHeader; - -typedef struct -{ - enet_uint8 command; - enet_uint8 channelID; - enet_uint16 reliableSequenceNumber; -} ENetProtocolCommandHeader; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 receivedReliableSequenceNumber; - enet_uint16 receivedSentTime; -} ENetProtocolAcknowledge; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 outgoingPeerID; - enet_uint16 mtu; - enet_uint32 windowSize; - enet_uint32 channelCount; - enet_uint32 incomingBandwidth; - enet_uint32 outgoingBandwidth; - enet_uint32 packetThrottleInterval; - enet_uint32 packetThrottleAcceleration; - enet_uint32 packetThrottleDeceleration; - enet_uint32 sessionID; -} ENetProtocolConnect; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 outgoingPeerID; - enet_uint16 mtu; - enet_uint32 windowSize; - enet_uint32 channelCount; - enet_uint32 incomingBandwidth; - enet_uint32 outgoingBandwidth; - enet_uint32 packetThrottleInterval; - enet_uint32 packetThrottleAcceleration; - enet_uint32 packetThrottleDeceleration; -} ENetProtocolVerifyConnect; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint32 incomingBandwidth; - enet_uint32 outgoingBandwidth; -} ENetProtocolBandwidthLimit; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint32 packetThrottleInterval; - enet_uint32 packetThrottleAcceleration; - enet_uint32 packetThrottleDeceleration; -} ENetProtocolThrottleConfigure; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint32 data; -} ENetProtocolDisconnect; - -typedef struct -{ - ENetProtocolCommandHeader header; -} ENetProtocolPing; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 dataLength; -} ENetProtocolSendReliable; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 unreliableSequenceNumber; - enet_uint16 dataLength; -} ENetProtocolSendUnreliable; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 unsequencedGroup; - enet_uint16 dataLength; -} ENetProtocolSendUnsequenced; - -typedef struct -{ - ENetProtocolCommandHeader header; - enet_uint16 startSequenceNumber; - enet_uint16 dataLength; - enet_uint32 fragmentCount; - enet_uint32 fragmentNumber; - enet_uint32 totalLength; - enet_uint32 fragmentOffset; -} ENetProtocolSendFragment; - -typedef union -{ - ENetProtocolCommandHeader header; - ENetProtocolAcknowledge acknowledge; - ENetProtocolConnect connect; - ENetProtocolVerifyConnect verifyConnect; - ENetProtocolDisconnect disconnect; - ENetProtocolPing ping; - ENetProtocolSendReliable sendReliable; - ENetProtocolSendUnreliable sendUnreliable; - ENetProtocolSendUnsequenced sendUnsequenced; - ENetProtocolSendFragment sendFragment; - ENetProtocolBandwidthLimit bandwidthLimit; - ENetProtocolThrottleConfigure throttleConfigure; -} ENetProtocol; - -#endif /* __ENET_PROTOCOL_H__ */ - diff --git a/source/enet/include/enet/time.h b/source/enet/include/enet/time.h deleted file mode 100755 index c82a5460..00000000 --- a/source/enet/include/enet/time.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - @file time.h - @brief ENet time constants and macros -*/ -#ifndef __ENET_TIME_H__ -#define __ENET_TIME_H__ - -#define ENET_TIME_OVERFLOW 86400000 - -#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) -#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) -#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) - -#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) - -#endif /* __ENET_TIME_H__ */ - diff --git a/source/enet/include/enet/types.h b/source/enet/include/enet/types.h deleted file mode 100755 index ab010a4b..00000000 --- a/source/enet/include/enet/types.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - @file types.h - @brief type definitions for ENet -*/ -#ifndef __ENET_TYPES_H__ -#define __ENET_TYPES_H__ - -typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ -typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ -typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ - -#endif /* __ENET_TYPES_H__ */ - diff --git a/source/enet/include/enet/unix.h b/source/enet/include/enet/unix.h deleted file mode 100755 index b20fecd4..00000000 --- a/source/enet/include/enet/unix.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - @file unix.h - @brief ENet Unix header -*/ -#ifndef __ENET_UNIX_H__ -#define __ENET_UNIX_H__ - -#include -#include -#include - -typedef int ENetSocket; - -enum -{ - ENET_SOCKET_NULL = -1 -}; - -#define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ -#define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ - -#define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ -#define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ - -typedef struct -{ - void * data; - size_t dataLength; -} ENetBuffer; - -#define ENET_CALLBACK - -#define ENET_API extern - -#endif /* __ENET_UNIX_H__ */ - diff --git a/source/enet/include/enet/utility.h b/source/enet/include/enet/utility.h deleted file mode 100755 index e48a476b..00000000 --- a/source/enet/include/enet/utility.h +++ /dev/null @@ -1,12 +0,0 @@ -/** - @file utility.h - @brief ENet utility header -*/ -#ifndef __ENET_UTILITY_H__ -#define __ENET_UTILITY_H__ - -#define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) -#define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) - -#endif /* __ENET_UTILITY_H__ */ - diff --git a/source/enet/include/enet/win32.h b/source/enet/include/enet/win32.h deleted file mode 100755 index 310ecd53..00000000 --- a/source/enet/include/enet/win32.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - @file win32.h - @brief ENet Win32 header -*/ -#ifndef __ENET_WIN32_H__ -#define __ENET_WIN32_H__ - -#ifdef ENET_BUILDING_LIB -#pragma warning (disable: 4996) // 'strncpy' was declared deprecated -#pragma warning (disable: 4267) // size_t to int conversion -#pragma warning (disable: 4244) // 64bit to 32bit int -#pragma warning (disable: 4018) // signed/unsigned mismatch -#endif - -#include -#include - -typedef SOCKET ENetSocket; - -enum -{ - ENET_SOCKET_NULL = INVALID_SOCKET -}; - -#define ENET_HOST_TO_NET_16(value) (htons (value)) -#define ENET_HOST_TO_NET_32(value) (htonl (value)) - -#define ENET_NET_TO_HOST_16(value) (ntohs (value)) -#define ENET_NET_TO_HOST_32(value) (ntohl (value)) - -typedef struct -{ - size_t dataLength; - void * data; -} ENetBuffer; - -#define ENET_CALLBACK __cdecl - -#if defined ENET_DLL -#if defined ENET_BUILDING_LIB -#define ENET_API __declspec( dllexport ) -#else -#define ENET_API __declspec( dllimport ) -#endif /* ENET_BUILDING_LIB */ -#else /* !ENET_DLL */ -#define ENET_API extern -#endif /* ENET_DLL */ - -#endif /* __ENET_WIN32_H__ */ - - diff --git a/source/enet/install-sh b/source/enet/install-sh deleted file mode 100755 index e9de2384..00000000 --- a/source/enet/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/source/enet/list.c b/source/enet/list.c deleted file mode 100755 index 1a4aa3ae..00000000 --- a/source/enet/list.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - @file list.c - @brief ENet linked list functions -*/ -#define ENET_BUILDING_LIB 1 -#include "enet/list.h" - -/** - @defgroup list ENet linked list utility functions - @ingroup private - @{ -*/ -void -enet_list_clear (ENetList * list) -{ - list -> sentinel.next = & list -> sentinel; - list -> sentinel.previous = & list -> sentinel; -} - -ENetListIterator -enet_list_insert (ENetListIterator position, void * data) -{ - ENetListIterator result = (ENetListIterator) data; - - result -> previous = position -> previous; - result -> next = position; - - result -> previous -> next = result; - position -> previous = result; - - return result; -} - -void * -enet_list_remove (ENetListIterator position) -{ - position -> previous -> next = position -> next; - position -> next -> previous = position -> previous; - - return position; -} - -size_t -enet_list_size (ENetList * list) -{ - size_t size = 0; - ENetListIterator position; - - for (position = enet_list_begin (list); - position != enet_list_end (list); - position = enet_list_next (position)) - ++ size; - - return size; -} - -/** @} */ diff --git a/source/enet/missing b/source/enet/missing deleted file mode 100755 index 7789652e..00000000 --- a/source/enet/missing +++ /dev/null @@ -1,190 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997 Free Software Foundation, Inc. -# Franc,ois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing - GNU libit 0.0" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`configure.in'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`configure.in'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`configure.in'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/source/enet/mkinstalldirs b/source/enet/mkinstalldirs deleted file mode 100755 index 68e20969..00000000 --- a/source/enet/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs,v 1.2 2006-08-31 21:52:06 adrian_henke Exp $ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/source/enet/packet.c b/source/enet/packet.c deleted file mode 100755 index db6f2d47..00000000 --- a/source/enet/packet.c +++ /dev/null @@ -1,140 +0,0 @@ -/** - @file packet.c - @brief ENet packet management functions -*/ -#include -#define ENET_BUILDING_LIB 1 -#include "enet/enet.h" - -/** @defgroup Packet ENet packet functions - @{ -*/ - -/** Creates a packet that may be sent to a peer. - @param dataContents initial contents of the packet's data; the packet's data will remain uninitialized if dataContents is NULL. - @param dataLength size of the data allocated for this packet - @param flags flags for this packet as described for the ENetPacket structure. - @returns the packet on success, NULL on failure -*/ -ENetPacket * -enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags) -{ - ENetPacket * packet = (ENetPacket *) enet_malloc (sizeof (ENetPacket)); - - if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) - packet -> data = (enet_uint8 *) data; - else - { - packet -> data = (enet_uint8 *) enet_malloc (dataLength); - if (packet -> data == NULL) - { - enet_free (packet); - return NULL; - }; - - if (data != NULL) - memcpy (packet -> data, data, dataLength); - }; - - packet -> referenceCount = 0; - packet -> flags = flags; - packet -> dataLength = dataLength; - packet -> freeCallback = NULL; - - return packet; -} - -/** Destroys the packet and deallocates its data. - @param packet packet to be destroyed -*/ -void -enet_packet_destroy (ENetPacket * packet) -{ - if (packet -> freeCallback != NULL) - (* packet -> freeCallback) (packet); - if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE)) - enet_free (packet -> data); - enet_free (packet); -} - -/** Attempts to resize the data in the packet to length specified in the - dataLength parameter - @param packet packet to resize - @param dataLength new size for the packet data - @returns 0 on success, < 0 on failure -*/ -int -enet_packet_resize (ENetPacket * packet, size_t dataLength) -{ - enet_uint8 * newData; - - if (dataLength <= packet -> dataLength || (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE)) - { - packet -> dataLength = dataLength; - - return 0; - } - - newData = (enet_uint8 *) enet_malloc (dataLength); - if (newData == NULL) - return -1; - - memcpy (newData, packet -> data, packet -> dataLength); - enet_free (packet -> data); - - packet -> data = newData; - packet -> dataLength = dataLength; - - return 0; -} - -static int initializedCRC32 = 0; -static enet_uint32 crcTable [256]; - -static void initialize_crc32 () -{ - int byte; - - for (byte = 0; byte < 256; ++ byte) - { - enet_uint32 crc = byte << 24; - int offset; - - for(offset = 0; offset < 8; ++ offset) - { - if (crc & 0x80000000) - crc = (crc << 1) ^ 0x04c11db7; - else - crc <<= 1; - } - - crcTable [byte] = crc; - } - - initializedCRC32 = 1; -} - -enet_uint32 -enet_crc32 (const ENetBuffer * buffers, size_t bufferCount) -{ - enet_uint32 crc = 0xFFFFFFFF; - - if (! initializedCRC32) initialize_crc32 (); - - while (bufferCount -- > 0) - { - const enet_uint8 * data = (const enet_uint8 *) buffers -> data, - * dataEnd = & data [buffers -> dataLength]; - - while (data < dataEnd) - { - crc = ((crc << 8) | * data ++) ^ crcTable [crc >> 24]; - } - - ++ buffers; - } - - return ENET_HOST_TO_NET_32 (~ crc); -} - -/** @} */ diff --git a/source/enet/peer.c b/source/enet/peer.c deleted file mode 100755 index c7a7267a..00000000 --- a/source/enet/peer.c +++ /dev/null @@ -1,669 +0,0 @@ -/** - @file peer.c - @brief ENet peer management functions -*/ -#include -#define ENET_BUILDING_LIB 1 -#include "enet/enet.h" - -/** @defgroup peer ENet peer functions - @{ -*/ - -/** Configures throttle parameter for a peer. - - Unreliable packets are dropped by ENet in response to the varying conditions - of the Internet connection to the peer. The throttle represents a probability - that an unreliable packet should not be dropped and thus sent by ENet to the peer. - The lowest mean round trip time from the sending of a reliable packet to the - receipt of its acknowledgement is measured over an amount of time specified by - the interval parameter in milliseconds. If a measured round trip time happens to - be significantly less than the mean round trip time measured over the interval, - then the throttle probability is increased to allow more traffic by an amount - specified in the acceleration parameter, which is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE - constant. If a measured round trip time happens to be significantly greater than - the mean round trip time measured over the interval, then the throttle probability - is decreased to limit traffic by an amount specified in the deceleration parameter, which - is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. When the throttle has - a value of ENET_PEER_PACKET_THROTTLE_SCALE, on unreliable packets are dropped by - ENet, and so 100% of all unreliable packets will be sent. When the throttle has a - value of 0, all unreliable packets are dropped by ENet, and so 0% of all unreliable - packets will be sent. Intermediate values for the throttle represent intermediate - probabilities between 0% and 100% of unreliable packets being sent. The bandwidth - limits of the local and foreign hosts are taken into account to determine a - sensible limit for the throttle probability above which it should not raise even in - the best of conditions. - - @param peer peer to configure - @param interval interval, in milliseconds, over which to measure lowest mean RTT; the default value is ENET_PEER_PACKET_THROTTLE_INTERVAL. - @param acceleration rate at which to increase the throttle probability as mean RTT declines - @param deceleration rate at which to decrease the throttle probability as mean RTT increases -*/ -void -enet_peer_throttle_configure (ENetPeer * peer, enet_uint32 interval, enet_uint32 acceleration, enet_uint32 deceleration) -{ - ENetProtocol command; - - peer -> packetThrottleInterval = interval; - peer -> packetThrottleAcceleration = acceleration; - peer -> packetThrottleDeceleration = deceleration; - - command.header.command = ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.header.channelID = 0xFF; - - command.throttleConfigure.packetThrottleInterval = ENET_HOST_TO_NET_32 (interval); - command.throttleConfigure.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (acceleration); - command.throttleConfigure.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (deceleration); - - enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); -} - -int -enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt) -{ - if (peer -> lastRoundTripTime <= peer -> lastRoundTripTimeVariance) - { - peer -> packetThrottle = peer -> packetThrottleLimit; - } - else - if (rtt < peer -> lastRoundTripTime) - { - peer -> packetThrottle += peer -> packetThrottleAcceleration; - - if (peer -> packetThrottle > peer -> packetThrottleLimit) - peer -> packetThrottle = peer -> packetThrottleLimit; - - return 1; - } - else - if (rtt > peer -> lastRoundTripTime + 2 * peer -> lastRoundTripTimeVariance) - { - if (peer -> packetThrottle > peer -> packetThrottleDeceleration) - peer -> packetThrottle -= peer -> packetThrottleDeceleration; - else - peer -> packetThrottle = 0; - - return -1; - } - - return 0; -} - -/** Queues a packet to be sent. - @param peer destination for the packet - @param channelID channel on which to send - @param packet packet to send - @retval 0 on success - @retval < 0 on failure -*/ -int -enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet) -{ - ENetChannel * channel = & peer -> channels [channelID]; - ENetProtocol command; - size_t fragmentLength; - - if (peer -> state != ENET_PEER_STATE_CONNECTED || - channelID >= peer -> channelCount) - return -1; - - fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment); - - if (packet -> dataLength > fragmentLength) - { - enet_uint16 startSequenceNumber = ENET_HOST_TO_NET_16 (channel -> outgoingReliableSequenceNumber + 1); - enet_uint32 fragmentCount = ENET_HOST_TO_NET_32 ((packet -> dataLength + fragmentLength - 1) / fragmentLength), - fragmentNumber, - fragmentOffset; - - packet -> flags = ENET_PACKET_FLAG_RELIABLE; - - for (fragmentNumber = 0, - fragmentOffset = 0; - fragmentOffset < packet -> dataLength; - ++ fragmentNumber, - fragmentOffset += fragmentLength) - { - if (packet -> dataLength - fragmentOffset < fragmentLength) - fragmentLength = packet -> dataLength - fragmentOffset; - - command.header.command = ENET_PROTOCOL_COMMAND_SEND_FRAGMENT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.header.channelID = channelID; - command.sendFragment.startSequenceNumber = startSequenceNumber; - command.sendFragment.dataLength = ENET_HOST_TO_NET_16 (fragmentLength); - command.sendFragment.fragmentCount = fragmentCount; - command.sendFragment.fragmentNumber = ENET_HOST_TO_NET_32 (fragmentNumber); - command.sendFragment.totalLength = ENET_HOST_TO_NET_32 (packet -> dataLength); - command.sendFragment.fragmentOffset = ENET_NET_TO_HOST_32 (fragmentOffset); - - enet_peer_queue_outgoing_command (peer, & command, packet, fragmentOffset, fragmentLength); - } - - return 0; - } - - command.header.channelID = channelID; - - if (packet -> flags & ENET_PACKET_FLAG_RELIABLE) - { - command.header.command = ENET_PROTOCOL_COMMAND_SEND_RELIABLE | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.sendReliable.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); - } - else - if (packet -> flags & ENET_PACKET_FLAG_UNSEQUENCED) - { - command.header.command = ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; - command.sendUnsequenced.unsequencedGroup = ENET_HOST_TO_NET_16 (peer -> outgoingUnsequencedGroup + 1); - command.sendUnsequenced.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); - } - else - { - command.header.command = ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE; - command.sendUnreliable.unreliableSequenceNumber = ENET_HOST_TO_NET_16 (channel -> outgoingUnreliableSequenceNumber + 1); - command.sendUnreliable.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); - } - - enet_peer_queue_outgoing_command (peer, & command, packet, 0, packet -> dataLength); - - return 0; -} - -/** Attempts to dequeue any incoming queued packet. - @param peer peer to dequeue packets from - @param channelID channel on which to receive - @returns a pointer to the packet, or NULL if there are no available incoming queued packets -*/ -ENetPacket * -enet_peer_receive (ENetPeer * peer, enet_uint8 channelID) -{ - ENetChannel * channel = & peer -> channels [channelID]; - ENetIncomingCommand * incomingCommand = NULL; - ENetPacket * packet; - - if (! enet_list_empty (& channel -> incomingUnreliableCommands)) - { - incomingCommand = (ENetIncomingCommand *) enet_list_front (& channel -> incomingUnreliableCommands); - - if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE) - { - if (incomingCommand -> reliableSequenceNumber != channel -> incomingReliableSequenceNumber) - incomingCommand = NULL; - else - channel -> incomingUnreliableSequenceNumber = incomingCommand -> unreliableSequenceNumber; - } - } - - if (incomingCommand == NULL && - ! enet_list_empty (& channel -> incomingReliableCommands)) - { - incomingCommand = (ENetIncomingCommand *) enet_list_front (& channel -> incomingReliableCommands); - - if (incomingCommand -> fragmentsRemaining > 0 || - incomingCommand -> reliableSequenceNumber != channel -> incomingReliableSequenceNumber + 1) - return NULL; - - channel -> incomingReliableSequenceNumber = incomingCommand -> reliableSequenceNumber; - - if (incomingCommand -> fragmentCount > 0) - channel -> incomingReliableSequenceNumber += incomingCommand -> fragmentCount - 1; - } - - if (incomingCommand == NULL) - return NULL; - - enet_list_remove (& incomingCommand -> incomingCommandList); - - packet = incomingCommand -> packet; - - -- packet -> referenceCount; - - if (incomingCommand -> fragments != NULL) - enet_free (incomingCommand -> fragments); - - enet_free (incomingCommand); - - return packet; -} - -static void -enet_peer_reset_outgoing_commands (ENetList * queue) -{ - ENetOutgoingCommand * outgoingCommand; - - while (! enet_list_empty (queue)) - { - outgoingCommand = (ENetOutgoingCommand *) enet_list_remove (enet_list_begin (queue)); - - if (outgoingCommand -> packet != NULL) - { - -- outgoingCommand -> packet -> referenceCount; - - if (outgoingCommand -> packet -> referenceCount == 0) - enet_packet_destroy (outgoingCommand -> packet); - } - - enet_free (outgoingCommand); - } -} - -static void -enet_peer_reset_incoming_commands (ENetList * queue) -{ - ENetIncomingCommand * incomingCommand; - - while (! enet_list_empty (queue)) - { - incomingCommand = (ENetIncomingCommand *) enet_list_remove (enet_list_begin (queue)); - - if (incomingCommand -> packet != NULL) - { - -- incomingCommand -> packet -> referenceCount; - - if (incomingCommand -> packet -> referenceCount == 0) - enet_packet_destroy (incomingCommand -> packet); - } - - if (incomingCommand -> fragments != NULL) - enet_free (incomingCommand -> fragments); - - enet_free (incomingCommand); - } -} - -void -enet_peer_reset_queues (ENetPeer * peer) -{ - ENetChannel * channel; - - while (! enet_list_empty (& peer -> acknowledgements)) - enet_free (enet_list_remove (enet_list_begin (& peer -> acknowledgements))); - - enet_peer_reset_outgoing_commands (& peer -> sentReliableCommands); - enet_peer_reset_outgoing_commands (& peer -> sentUnreliableCommands); - enet_peer_reset_outgoing_commands (& peer -> outgoingReliableCommands); - enet_peer_reset_outgoing_commands (& peer -> outgoingUnreliableCommands); - - if (peer -> channels != NULL && peer -> channelCount > 0) - { - for (channel = peer -> channels; - channel < & peer -> channels [peer -> channelCount]; - ++ channel) - { - enet_peer_reset_incoming_commands (& channel -> incomingReliableCommands); - enet_peer_reset_incoming_commands (& channel -> incomingUnreliableCommands); - } - - enet_free (peer -> channels); - } - - peer -> channels = NULL; - peer -> channelCount = 0; -} - -/** Forcefully disconnects a peer. - @param peer peer to forcefully disconnect - @remarks The foreign host represented by the peer is not notified of the disconnection and will timeout - on its connection to the local host. -*/ -void -enet_peer_reset (ENetPeer * peer) -{ - peer -> outgoingPeerID = ENET_PROTOCOL_MAXIMUM_PEER_ID; - peer -> sessionID = 0; - - peer -> state = ENET_PEER_STATE_DISCONNECTED; - - peer -> incomingBandwidth = 0; - peer -> outgoingBandwidth = 0; - peer -> incomingBandwidthThrottleEpoch = 0; - peer -> outgoingBandwidthThrottleEpoch = 0; - peer -> incomingDataTotal = 0; - peer -> outgoingDataTotal = 0; - peer -> lastSendTime = 0; - peer -> lastReceiveTime = 0; - peer -> nextTimeout = 0; - peer -> earliestTimeout = 0; - peer -> packetLossEpoch = 0; - peer -> packetsSent = 0; - peer -> packetsLost = 0; - peer -> packetLoss = 0; - peer -> packetLossVariance = 0; - peer -> packetThrottle = ENET_PEER_DEFAULT_PACKET_THROTTLE; - peer -> packetThrottleLimit = ENET_PEER_PACKET_THROTTLE_SCALE; - peer -> packetThrottleCounter = 0; - peer -> packetThrottleEpoch = 0; - peer -> packetThrottleAcceleration = ENET_PEER_PACKET_THROTTLE_ACCELERATION; - peer -> packetThrottleDeceleration = ENET_PEER_PACKET_THROTTLE_DECELERATION; - peer -> packetThrottleInterval = ENET_PEER_PACKET_THROTTLE_INTERVAL; - peer -> lastRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; - peer -> lowestRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; - peer -> lastRoundTripTimeVariance = 0; - peer -> highestRoundTripTimeVariance = 0; - peer -> roundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; - peer -> roundTripTimeVariance = 0; - peer -> mtu = peer -> host -> mtu; - peer -> reliableDataInTransit = 0; - peer -> outgoingReliableSequenceNumber = 0; - peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - peer -> incomingUnsequencedGroup = 0; - peer -> outgoingUnsequencedGroup = 0; - peer -> disconnectData = 0; - - memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow)); - - enet_peer_reset_queues (peer); -} - -/** Sends a ping request to a peer. - @param peer destination for the ping request - @remarks ping requests factor into the mean round trip time as designated by the - roundTripTime field in the ENetPeer structure. Enet automatically pings all connected - peers at regular intervals, however, this function may be called to ensure more - frequent ping requests. -*/ -void -enet_peer_ping (ENetPeer * peer) -{ - ENetProtocol command; - - if (peer -> state != ENET_PEER_STATE_CONNECTED) - return; - - command.header.command = ENET_PROTOCOL_COMMAND_PING | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - command.header.channelID = 0xFF; - - enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); -} - -/** Force an immediate disconnection from a peer. - @param peer peer to disconnect - @param data data describing the disconnection - @remarks No ENET_EVENT_DISCONNECT event will be generated. The foreign peer is not - guarenteed to receive the disconnect notification, and is reset immediately upon - return from this function. -*/ -void -enet_peer_disconnect_now (ENetPeer * peer, enet_uint32 data) -{ - ENetProtocol command; - - if (peer -> state == ENET_PEER_STATE_DISCONNECTED) - return; - - if (peer -> state != ENET_PEER_STATE_ZOMBIE && - peer -> state != ENET_PEER_STATE_DISCONNECTING) - { - enet_peer_reset_queues (peer); - - command.header.command = ENET_PROTOCOL_COMMAND_DISCONNECT | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; - command.header.channelID = 0xFF; - command.disconnect.data = ENET_HOST_TO_NET_32 (data); - - enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); - - enet_host_flush (peer -> host); - } - - enet_peer_reset (peer); -} - -/** Request a disconnection from a peer. - @param peer peer to request a disconnection - @param data data describing the disconnection - @remarks An ENET_EVENT_DISCONNECT event will be generated by enet_host_service() - once the disconnection is complete. -*/ -void -enet_peer_disconnect (ENetPeer * peer, enet_uint32 data) -{ - ENetProtocol command; - - if (peer -> state == ENET_PEER_STATE_DISCONNECTING || - peer -> state == ENET_PEER_STATE_DISCONNECTED || - peer -> state == ENET_PEER_STATE_ZOMBIE) - return; - - enet_peer_reset_queues (peer); - - command.header.command = ENET_PROTOCOL_COMMAND_DISCONNECT; - command.header.channelID = 0xFF; - command.disconnect.data = ENET_HOST_TO_NET_32 (data); - - if (peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) - command.header.command |= ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - else - command.header.command |= ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; - - enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); - - if (peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) - peer -> state = ENET_PEER_STATE_DISCONNECTING; - else - { - enet_host_flush (peer -> host); - enet_peer_reset (peer); - } -} - -/** Request a disconnection from a peer, but only after all queued outgoing packets are sent. - @param peer peer to request a disconnection - @param data data describing the disconnection - @remarks An ENET_EVENT_DISCONNECT event will be generated by enet_host_service() - once the disconnection is complete. -*/ -void -enet_peer_disconnect_later (ENetPeer * peer, enet_uint32 data) -{ - if ((peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) && - ! (enet_list_empty (& peer -> outgoingReliableCommands) && - enet_list_empty (& peer -> outgoingUnreliableCommands) && - enet_list_empty (& peer -> sentReliableCommands))) - { - peer -> state = ENET_PEER_STATE_DISCONNECT_LATER; - peer -> disconnectData = data; - } - else - enet_peer_disconnect (peer, data); -} - -ENetAcknowledgement * -enet_peer_queue_acknowledgement (ENetPeer * peer, const ENetProtocol * command, enet_uint16 sentTime) -{ - ENetAcknowledgement * acknowledgement; - - peer -> outgoingDataTotal += sizeof (ENetProtocolAcknowledge); - - acknowledgement = (ENetAcknowledgement *) enet_malloc (sizeof (ENetAcknowledgement)); - - acknowledgement -> sentTime = sentTime; - acknowledgement -> command = * command; - - enet_list_insert (enet_list_end (& peer -> acknowledgements), acknowledgement); - - return acknowledgement; -} - -ENetOutgoingCommand * -enet_peer_queue_outgoing_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 offset, enet_uint16 length) -{ - ENetChannel * channel = & peer -> channels [command -> header.channelID]; - ENetOutgoingCommand * outgoingCommand; - - peer -> outgoingDataTotal += enet_protocol_command_size (command -> header.command) + length; - - outgoingCommand = (ENetOutgoingCommand *) enet_malloc (sizeof (ENetOutgoingCommand)); - - if (command -> header.channelID == 0xFF) - { - ++ peer -> outgoingReliableSequenceNumber; - - outgoingCommand -> reliableSequenceNumber = peer -> outgoingReliableSequenceNumber; - outgoingCommand -> unreliableSequenceNumber = 0; - } - else - if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) - { - ++ channel -> outgoingReliableSequenceNumber; - - outgoingCommand -> reliableSequenceNumber = channel -> outgoingReliableSequenceNumber; - outgoingCommand -> unreliableSequenceNumber = 0; - } - else - if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED) - { - ++ peer -> outgoingUnsequencedGroup; - - outgoingCommand -> reliableSequenceNumber = 0; - outgoingCommand -> unreliableSequenceNumber = 0; - } - else - { - ++ channel -> outgoingUnreliableSequenceNumber; - - outgoingCommand -> reliableSequenceNumber = channel -> outgoingReliableSequenceNumber; - outgoingCommand -> unreliableSequenceNumber = channel -> outgoingUnreliableSequenceNumber; - } - - outgoingCommand -> sentTime = 0; - outgoingCommand -> roundTripTimeout = 0; - outgoingCommand -> roundTripTimeoutLimit = 0; - outgoingCommand -> fragmentOffset = offset; - outgoingCommand -> fragmentLength = length; - outgoingCommand -> packet = packet; - outgoingCommand -> command = * command; - outgoingCommand -> command.header.reliableSequenceNumber = ENET_HOST_TO_NET_16 (outgoingCommand -> reliableSequenceNumber); - - if (packet != NULL) - ++ packet -> referenceCount; - - if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) - enet_list_insert (enet_list_end (& peer -> outgoingReliableCommands), outgoingCommand); - else - enet_list_insert (enet_list_end (& peer -> outgoingUnreliableCommands), outgoingCommand); - - return outgoingCommand; -} - -ENetIncomingCommand * -enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount) -{ - ENetChannel * channel = & peer -> channels [command -> header.channelID]; - enet_uint32 unreliableSequenceNumber = 0, reliableSequenceNumber; - ENetIncomingCommand * incomingCommand; - ENetListIterator currentCommand; - - if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) - goto freePacket; - - if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED) - { - reliableSequenceNumber = command -> header.reliableSequenceNumber; - - if (channel -> incomingReliableSequenceNumber >= 0xF000 && reliableSequenceNumber < 0x1000) - reliableSequenceNumber += 0x10000; - - if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber || - (channel -> incomingReliableSequenceNumber < 0x1000 && (reliableSequenceNumber & 0xFFFF) >= 0xF000)) - goto freePacket; - } - - switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) - { - case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: - case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: - if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber) - goto freePacket; - - for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands)); - currentCommand != enet_list_end (& channel -> incomingReliableCommands); - currentCommand = enet_list_previous (currentCommand)) - { - incomingCommand = (ENetIncomingCommand *) currentCommand; - - if (reliableSequenceNumber >= 0x10000 && incomingCommand -> reliableSequenceNumber < 0xF000) - reliableSequenceNumber -= 0x10000; - - if (incomingCommand -> reliableSequenceNumber <= reliableSequenceNumber) - { - if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber) - break; - - goto freePacket; - } - } - break; - - case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE: - unreliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendUnreliable.unreliableSequenceNumber); - - if (channel -> incomingUnreliableSequenceNumber >= 0xF000 && unreliableSequenceNumber < 0x1000) - unreliableSequenceNumber += 0x10000; - - if (unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber || - (channel -> incomingUnreliableSequenceNumber < 0x1000 && (unreliableSequenceNumber & 0xFFFF) >= 0xF000)) - goto freePacket; - - for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands)); - currentCommand != enet_list_end (& channel -> incomingUnreliableCommands); - currentCommand = enet_list_previous (currentCommand)) - { - incomingCommand = (ENetIncomingCommand *) currentCommand; - - if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE) - continue; - - if (unreliableSequenceNumber >= 0x10000 && incomingCommand -> unreliableSequenceNumber < 0xF000) - unreliableSequenceNumber -= 0x10000; - - if (incomingCommand -> unreliableSequenceNumber <= unreliableSequenceNumber) - { - if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber) - break; - - goto freePacket; - } - } - break; - - case ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED: - currentCommand = enet_list_end (& channel -> incomingUnreliableCommands); - break; - - default: - goto freePacket; - } - - incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand)); - - incomingCommand -> reliableSequenceNumber = command -> header.reliableSequenceNumber; - incomingCommand -> unreliableSequenceNumber = unreliableSequenceNumber & 0xFFFF; - incomingCommand -> command = * command; - incomingCommand -> fragmentCount = fragmentCount; - incomingCommand -> fragmentsRemaining = fragmentCount; - incomingCommand -> packet = packet; - incomingCommand -> fragments = NULL; - - if (fragmentCount > 0) - { - incomingCommand -> fragments = (enet_uint32 *) enet_malloc ((fragmentCount + 31) / 32 * sizeof (enet_uint32)); - memset (incomingCommand -> fragments, 0, (fragmentCount + 31) / 32 * sizeof (enet_uint32)); - } - - if (packet != NULL) - ++ packet -> referenceCount; - - enet_list_insert (enet_list_next (currentCommand), incomingCommand); - - return incomingCommand; - -freePacket: - if (packet != NULL) - { - if (packet -> referenceCount == 0) - enet_packet_destroy (packet); - } - - return NULL; -} - -/** @} */ diff --git a/source/enet/protocol.c b/source/enet/protocol.c deleted file mode 100755 index 14b0d433..00000000 --- a/source/enet/protocol.c +++ /dev/null @@ -1,1474 +0,0 @@ -/** - @file protocol.c - @brief ENet protocol functions -*/ -#include -#include -#define ENET_BUILDING_LIB 1 -#include "enet/utility.h" -#include "enet/time.h" -#include "enet/enet.h" - -static enet_uint32 timeCurrent; - -static size_t commandSizes [ENET_PROTOCOL_COMMAND_COUNT] = -{ - 0, - sizeof (ENetProtocolAcknowledge), - sizeof (ENetProtocolConnect), - sizeof (ENetProtocolVerifyConnect), - sizeof (ENetProtocolDisconnect), - sizeof (ENetProtocolPing), - sizeof (ENetProtocolSendReliable), - sizeof (ENetProtocolSendUnreliable), - sizeof (ENetProtocolSendFragment), - sizeof (ENetProtocolSendUnsequenced), - sizeof (ENetProtocolBandwidthLimit), - sizeof (ENetProtocolThrottleConfigure), -}; - -size_t -enet_protocol_command_size (enet_uint8 commandNumber) -{ - return commandSizes [commandNumber & ENET_PROTOCOL_COMMAND_MASK]; -} - -static int -enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event) -{ - ENetPeer * currentPeer = host -> lastServicedPeer; - ENetChannel * channel; - - do - { - ++ currentPeer; - - if (currentPeer >= & host -> peers [host -> peerCount]) - currentPeer = host -> peers; - - switch (currentPeer -> state) - { - case ENET_PEER_STATE_CONNECTION_PENDING: - case ENET_PEER_STATE_CONNECTION_SUCCEEDED: - currentPeer -> state = ENET_PEER_STATE_CONNECTED; - - event -> type = ENET_EVENT_TYPE_CONNECT; - event -> peer = currentPeer; - - return 1; - - case ENET_PEER_STATE_ZOMBIE: - host -> recalculateBandwidthLimits = 1; - - event -> type = ENET_EVENT_TYPE_DISCONNECT; - event -> peer = currentPeer; - event -> data = currentPeer -> disconnectData; - - enet_peer_reset (currentPeer); - - host -> lastServicedPeer = currentPeer; - - return 1; - } - - if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) - continue; - - for (channel = currentPeer -> channels; - channel < & currentPeer -> channels [currentPeer -> channelCount]; - ++ channel) - { - if (enet_list_empty (& channel -> incomingReliableCommands) && - enet_list_empty (& channel -> incomingUnreliableCommands)) - continue; - - event -> packet = enet_peer_receive (currentPeer, channel - currentPeer -> channels); - if (event -> packet == NULL) - continue; - - event -> type = ENET_EVENT_TYPE_RECEIVE; - event -> peer = currentPeer; - event -> channelID = (enet_uint8) (channel - currentPeer -> channels); - - host -> lastServicedPeer = currentPeer; - - return 1; - } - } while (currentPeer != host -> lastServicedPeer); - - return 0; -} - -static void -enet_protocol_notify_connect (ENetHost * host, ENetPeer * peer, ENetEvent * event) -{ - host -> recalculateBandwidthLimits = 1; - - if (event == NULL) - peer -> state = (peer -> state == ENET_PEER_STATE_CONNECTING ? ENET_PEER_STATE_CONNECTION_SUCCEEDED : ENET_PEER_STATE_CONNECTION_PENDING); - else - { - peer -> state = ENET_PEER_STATE_CONNECTED; - - event -> type = ENET_EVENT_TYPE_CONNECT; - event -> peer = peer; - } -} - -static void -enet_protocol_notify_disconnect (ENetHost * host, ENetPeer * peer, ENetEvent * event) -{ - if (peer -> state >= ENET_PEER_STATE_CONNECTION_PENDING) - host -> recalculateBandwidthLimits = 1; - - if (peer -> state < ENET_PEER_STATE_CONNECTION_SUCCEEDED) - enet_peer_reset (peer); - else - if (event == NULL) - peer -> state = ENET_PEER_STATE_ZOMBIE; - else - { - event -> type = ENET_EVENT_TYPE_DISCONNECT; - event -> peer = peer; - event -> data = 0; - - enet_peer_reset (peer); - } -} - -static void -enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer) -{ - ENetOutgoingCommand * outgoingCommand; - - while (! enet_list_empty (& peer -> sentUnreliableCommands)) - { - outgoingCommand = (ENetOutgoingCommand *) enet_list_front (& peer -> sentUnreliableCommands); - - enet_list_remove (& outgoingCommand -> outgoingCommandList); - - if (outgoingCommand -> packet != NULL) - { - -- outgoingCommand -> packet -> referenceCount; - - if (outgoingCommand -> packet -> referenceCount == 0) - enet_packet_destroy (outgoingCommand -> packet); - } - - enet_free (outgoingCommand); - } -} - -static ENetProtocolCommand -enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliableSequenceNumber, enet_uint8 channelID) -{ - ENetOutgoingCommand * outgoingCommand; - ENetListIterator currentCommand; - ENetProtocolCommand commandNumber; - - for (currentCommand = enet_list_begin (& peer -> sentReliableCommands); - currentCommand != enet_list_end (& peer -> sentReliableCommands); - currentCommand = enet_list_next (currentCommand)) - { - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - - if (outgoingCommand -> reliableSequenceNumber == reliableSequenceNumber && - outgoingCommand -> command.header.channelID == channelID) - break; - } - - if (currentCommand == enet_list_end (& peer -> sentReliableCommands)) - return ENET_PROTOCOL_COMMAND_NONE; - - commandNumber = outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK; - - enet_list_remove (& outgoingCommand -> outgoingCommandList); - - if (outgoingCommand -> packet != NULL) - { - peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; - - -- outgoingCommand -> packet -> referenceCount; - - if (outgoingCommand -> packet -> referenceCount == 0) - enet_packet_destroy (outgoingCommand -> packet); - } - - enet_free (outgoingCommand); - - if (enet_list_empty (& peer -> sentReliableCommands)) - return commandNumber; - - outgoingCommand = (ENetOutgoingCommand *) enet_list_front (& peer -> sentReliableCommands); - - peer -> nextTimeout = outgoingCommand -> sentTime + outgoingCommand -> roundTripTimeout; - - return commandNumber; -} - -static ENetPeer * -enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENetProtocol * command) -{ - enet_uint16 mtu; - enet_uint32 windowSize; - ENetChannel * channel; - size_t channelCount; - ENetPeer * currentPeer; - ENetProtocol verifyCommand; - -#ifdef USE_CRC32 - { - enet_uint32 crc = header -> checksum; - ENetBuffer buffer; - - command -> header.reliableSequenceNumber = ENET_HOST_TO_NET_16 (command -> header.reliableSequenceNumber); - - header -> checksum = command -> connect.sessionID; - - buffer.data = host -> receivedData; - buffer.dataLength = host -> receivedDataLength; - - if (enet_crc32 (& buffer, 1) != crc) - return NULL; - - command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber); - } -#endif - - channelCount = ENET_NET_TO_HOST_32 (command -> connect.channelCount); - - if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT || - channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) - return NULL; - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - if (currentPeer -> state != ENET_PEER_STATE_DISCONNECTED && - currentPeer -> address.host == host -> receivedAddress.host && - currentPeer -> address.port == host -> receivedAddress.port && - currentPeer -> sessionID == command -> connect.sessionID) - return NULL; - } - - for (currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED) - break; - } - - if (currentPeer >= & host -> peers [host -> peerCount]) - return NULL; - - currentPeer -> state = ENET_PEER_STATE_ACKNOWLEDGING_CONNECT; - currentPeer -> sessionID = command -> connect.sessionID; - currentPeer -> address = host -> receivedAddress; - currentPeer -> outgoingPeerID = ENET_NET_TO_HOST_16 (command -> connect.outgoingPeerID); - currentPeer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> connect.incomingBandwidth); - currentPeer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> connect.outgoingBandwidth); - currentPeer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleInterval); - currentPeer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleAcceleration); - currentPeer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleDeceleration); - currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel)); - currentPeer -> channelCount = channelCount; - - for (channel = currentPeer -> channels; - channel < & currentPeer -> channels [channelCount]; - ++ channel) - { - channel -> outgoingReliableSequenceNumber = 0; - channel -> outgoingUnreliableSequenceNumber = 0; - channel -> incomingReliableSequenceNumber = 0; - channel -> incomingUnreliableSequenceNumber = 0; - - enet_list_clear (& channel -> incomingReliableCommands); - enet_list_clear (& channel -> incomingUnreliableCommands); - } - - mtu = ENET_NET_TO_HOST_16 (command -> connect.mtu); - - if (mtu < ENET_PROTOCOL_MINIMUM_MTU) - mtu = ENET_PROTOCOL_MINIMUM_MTU; - else - if (mtu > ENET_PROTOCOL_MAXIMUM_MTU) - mtu = ENET_PROTOCOL_MAXIMUM_MTU; - - currentPeer -> mtu = mtu; - - if (host -> outgoingBandwidth == 0 && - currentPeer -> incomingBandwidth == 0) - currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - else - currentPeer -> windowSize = (ENET_MIN (host -> outgoingBandwidth, currentPeer -> incomingBandwidth) / - ENET_PEER_WINDOW_SIZE_SCALE) * - ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - - if (currentPeer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) - currentPeer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - else - if (currentPeer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) - currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - - if (host -> incomingBandwidth == 0) - windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - else - windowSize = (host -> incomingBandwidth / ENET_PEER_WINDOW_SIZE_SCALE) * - ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - - if (windowSize > ENET_NET_TO_HOST_32 (command -> connect.windowSize)) - windowSize = ENET_NET_TO_HOST_32 (command -> connect.windowSize); - - if (windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) - windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - else - if (windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) - windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - - verifyCommand.header.command = ENET_PROTOCOL_COMMAND_VERIFY_CONNECT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; - verifyCommand.header.channelID = 0xFF; - verifyCommand.verifyConnect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID); - verifyCommand.verifyConnect.mtu = ENET_HOST_TO_NET_16 (currentPeer -> mtu); - verifyCommand.verifyConnect.windowSize = ENET_HOST_TO_NET_32 (windowSize); - verifyCommand.verifyConnect.channelCount = ENET_HOST_TO_NET_32 (channelCount); - verifyCommand.verifyConnect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth); - verifyCommand.verifyConnect.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); - verifyCommand.verifyConnect.packetThrottleInterval = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleInterval); - verifyCommand.verifyConnect.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleAcceleration); - verifyCommand.verifyConnect.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleDeceleration); - - enet_peer_queue_outgoing_command (currentPeer, & verifyCommand, NULL, 0, 0); - - return currentPeer; -} - -static int -enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) -{ - ENetPacket * packet; - size_t dataLength; - - if (command -> header.channelID >= peer -> channelCount || - (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) - return -1; - - dataLength = ENET_NET_TO_HOST_16 (command -> sendReliable.dataLength); - * currentData += dataLength; - if (* currentData > & host -> receivedData [host -> receivedDataLength]) - return -1; - - packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable), - dataLength, - ENET_PACKET_FLAG_RELIABLE); - if (packet == NULL) - return -1; - - enet_peer_queue_incoming_command (peer, command, packet, 0); - return 0; -} - -static int -enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) -{ - ENetPacket * packet; - enet_uint32 unsequencedGroup, index; - size_t dataLength; - - if (command -> header.channelID >= peer -> channelCount || - (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) - return -1; - - dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength); - * currentData += dataLength; - if (* currentData > & host -> receivedData [host -> receivedDataLength]) - return -1; - - unsequencedGroup = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.unsequencedGroup); - index = unsequencedGroup % ENET_PEER_UNSEQUENCED_WINDOW_SIZE; - - if (unsequencedGroup >= peer -> incomingUnsequencedGroup + ENET_PEER_UNSEQUENCED_WINDOW_SIZE || - peer -> incomingUnsequencedGroup >= 0xF000 && unsequencedGroup < 0x1000) - { - peer -> incomingUnsequencedGroup = unsequencedGroup - index; - - memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow)); - } - else - if (unsequencedGroup < peer -> incomingUnsequencedGroup || - peer -> unsequencedWindow [index / 32] & (1 << (index % 32))) - return 0; - - peer -> unsequencedWindow [index / 32] |= 1 << (index % 32); - - - packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced), - dataLength, - ENET_PACKET_FLAG_UNSEQUENCED); - if (packet == NULL) - return -1; - - enet_peer_queue_incoming_command (peer, command, packet, 0); - return 0; -} - -static int -enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) -{ - ENetPacket * packet; - size_t dataLength; - - if (command -> header.channelID >= peer -> channelCount || - (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) - return -1; - - dataLength = ENET_NET_TO_HOST_16 (command -> sendUnreliable.dataLength); - * currentData += dataLength; - if (* currentData > & host -> receivedData [host -> receivedDataLength]) - return -1; - - packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable), - dataLength, - 0); - if (packet == NULL) - return -1; - - enet_peer_queue_incoming_command (peer, command, packet, 0); - return 0; -} - -static int -enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) -{ - enet_uint32 fragmentNumber, - fragmentCount, - fragmentOffset, - fragmentLength, - startSequenceNumber, - totalLength; - ENetChannel * channel; - ENetListIterator currentCommand; - ENetIncomingCommand * startCommand; - - if (command -> header.channelID >= peer -> channelCount || - (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) - return -1; - - fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength); - * currentData += fragmentLength; - if (* currentData > & host -> receivedData [host -> receivedDataLength]) - return -1; - - channel = & peer -> channels [command -> header.channelID]; - startSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendFragment.startSequenceNumber); - if (channel -> incomingReliableSequenceNumber >= 0xF000 && startSequenceNumber < 0x1000) - startSequenceNumber += 0x10000; - - if (startSequenceNumber < channel -> incomingReliableSequenceNumber || - (channel -> incomingReliableSequenceNumber < 0x1000 && (startSequenceNumber & 0xFFFF) >= 0xF000)) - return 0; - - fragmentNumber = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentNumber); - fragmentCount = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentCount); - fragmentOffset = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentOffset); - totalLength = ENET_NET_TO_HOST_32 (command -> sendFragment.totalLength); - - if (fragmentOffset >= totalLength || - fragmentOffset + fragmentLength > totalLength || - fragmentNumber >= fragmentCount) - return -1; - - for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands)); - currentCommand != enet_list_end (& channel -> incomingReliableCommands); - currentCommand = enet_list_previous (currentCommand)) - { - startCommand = (ENetIncomingCommand *) currentCommand; - - if ((startCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_SEND_FRAGMENT && - startCommand -> command.sendFragment.startSequenceNumber == (startSequenceNumber & 0xFFFF)) - break; - } - - if (currentCommand == enet_list_end (& channel -> incomingReliableCommands)) - { - ENetProtocol hostCommand = * command; - ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_RELIABLE); - if (packet == NULL) - return -1; - - hostCommand.header.reliableSequenceNumber = startSequenceNumber; - hostCommand.sendFragment.startSequenceNumber = startSequenceNumber; - hostCommand.sendFragment.dataLength = fragmentLength; - hostCommand.sendFragment.fragmentNumber = fragmentNumber; - hostCommand.sendFragment.fragmentCount = fragmentCount; - hostCommand.sendFragment.fragmentOffset = fragmentOffset; - hostCommand.sendFragment.totalLength = totalLength; - - startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, packet, fragmentCount); - } - else - if (totalLength != startCommand -> packet -> dataLength || - fragmentCount != startCommand -> fragmentCount) - return -1; - - if ((startCommand -> fragments [fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) - { - -- startCommand -> fragmentsRemaining; - - startCommand -> fragments [fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); - - if (fragmentOffset + fragmentLength > startCommand -> packet -> dataLength) - fragmentLength = startCommand -> packet -> dataLength - fragmentOffset; - - memcpy (startCommand -> packet -> data + fragmentOffset, - (enet_uint8 *) command + sizeof (ENetProtocolSendFragment), - fragmentLength); - } - - return 0; -} - -static int -enet_protocol_handle_ping (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) -{ - return 0; -} - -static int -enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) -{ - peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.incomingBandwidth); - peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.outgoingBandwidth); - - if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0) - peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - else - peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) / - ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - - if (peer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) - peer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - else - if (peer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) - peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - - return 0; -} - -static int -enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) -{ - peer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleInterval); - peer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleAcceleration); - peer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleDeceleration); - - return 0; -} - -static int -enet_protocol_handle_disconnect (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) -{ - enet_peer_reset_queues (peer); - - if (peer -> state == ENET_PEER_STATE_CONNECTION_SUCCEEDED) - peer -> state = ENET_PEER_STATE_ZOMBIE; - else - if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) - { - if (peer -> state == ENET_PEER_STATE_CONNECTION_PENDING) host -> recalculateBandwidthLimits = 1; - - enet_peer_reset (peer); - } - else - if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) - peer -> state = ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT; - else - peer -> state = ENET_PEER_STATE_ZOMBIE; - - peer -> disconnectData = ENET_NET_TO_HOST_32 (command -> disconnect.data); - return 0; -} - -static int -enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command) -{ - enet_uint32 roundTripTime, - receivedSentTime, - receivedReliableSequenceNumber; - ENetProtocolCommand commandNumber; - - receivedSentTime = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedSentTime); - receivedSentTime |= timeCurrent & 0xFFFF0000; - if ((receivedSentTime & 0x8000) > (timeCurrent & 0x8000)) - receivedSentTime -= 0x10000; - - if (ENET_TIME_LESS (timeCurrent, receivedSentTime)) - return 0; - - peer -> lastReceiveTime = timeCurrent; - peer -> earliestTimeout = 0; - - roundTripTime = ENET_TIME_DIFFERENCE (timeCurrent, receivedSentTime); - - enet_peer_throttle (peer, roundTripTime); - - peer -> roundTripTimeVariance -= peer -> roundTripTimeVariance / 4; - - if (roundTripTime >= peer -> roundTripTime) - { - peer -> roundTripTime += (roundTripTime - peer -> roundTripTime) / 8; - peer -> roundTripTimeVariance += (roundTripTime - peer -> roundTripTime) / 4; - } - else - { - peer -> roundTripTime -= (peer -> roundTripTime - roundTripTime) / 8; - peer -> roundTripTimeVariance += (peer -> roundTripTime - roundTripTime) / 4; - } - - if (peer -> roundTripTime < peer -> lowestRoundTripTime) - peer -> lowestRoundTripTime = peer -> roundTripTime; - - if (peer -> roundTripTimeVariance > peer -> highestRoundTripTimeVariance) - peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance; - - if (peer -> packetThrottleEpoch == 0 || - ENET_TIME_DIFFERENCE(timeCurrent, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval) - { - peer -> lastRoundTripTime = peer -> lowestRoundTripTime; - peer -> lastRoundTripTimeVariance = peer -> highestRoundTripTimeVariance; - peer -> lowestRoundTripTime = peer -> roundTripTime; - peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance; - peer -> packetThrottleEpoch = timeCurrent; - } - - receivedReliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedReliableSequenceNumber); - - commandNumber = enet_protocol_remove_sent_reliable_command (peer, receivedReliableSequenceNumber, command -> header.channelID); - - switch (peer -> state) - { - case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT: - if (commandNumber != ENET_PROTOCOL_COMMAND_VERIFY_CONNECT) - return -1; - - enet_protocol_notify_connect (host, peer, event); - break; - - case ENET_PEER_STATE_DISCONNECTING: - if (commandNumber != ENET_PROTOCOL_COMMAND_DISCONNECT) - return -1; - - enet_protocol_notify_disconnect (host, peer, event); - break; - - case ENET_PEER_STATE_DISCONNECT_LATER: - if (enet_list_empty (& peer -> outgoingReliableCommands) && - enet_list_empty (& peer -> outgoingUnreliableCommands) && - enet_list_empty (& peer -> sentReliableCommands)) - enet_peer_disconnect (peer, peer -> disconnectData); - break; - } - - return 0; -} - -static int -enet_protocol_handle_verify_connect (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command) -{ - enet_uint16 mtu; - enet_uint32 windowSize; - - if (peer -> state != ENET_PEER_STATE_CONNECTING) - return -1; - - if (ENET_NET_TO_HOST_32 (command -> verifyConnect.channelCount) != peer -> channelCount || - ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleInterval) != peer -> packetThrottleInterval || - ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleAcceleration) != peer -> packetThrottleAcceleration || - ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleDeceleration) != peer -> packetThrottleDeceleration) - { - peer -> state = ENET_PEER_STATE_ZOMBIE; - - return -1; - } - - enet_protocol_remove_sent_reliable_command (peer, 1, 0xFF); - - peer -> outgoingPeerID = ENET_NET_TO_HOST_16 (command -> verifyConnect.outgoingPeerID); - - mtu = ENET_NET_TO_HOST_16 (command -> verifyConnect.mtu); - - if (mtu < ENET_PROTOCOL_MINIMUM_MTU) - mtu = ENET_PROTOCOL_MINIMUM_MTU; - else - if (mtu > ENET_PROTOCOL_MAXIMUM_MTU) - mtu = ENET_PROTOCOL_MAXIMUM_MTU; - - if (mtu < peer -> mtu) - peer -> mtu = mtu; - - windowSize = ENET_NET_TO_HOST_32 (command -> verifyConnect.windowSize); - - if (windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) - windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; - - if (windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) - windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; - - if (windowSize < peer -> windowSize) - peer -> windowSize = windowSize; - - peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> verifyConnect.incomingBandwidth); - peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> verifyConnect.outgoingBandwidth); - - enet_protocol_notify_connect (host, peer, event); - return 0; -} - -static int -enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) -{ - ENetProtocolHeader * header; - ENetProtocol * command; - ENetPeer * peer; - enet_uint8 * currentData; - size_t headerSize; - enet_uint16 peerID, flags; - - if (host -> receivedDataLength < sizeof (ENetProtocolHeader)) - return 0; - - header = (ENetProtocolHeader *) host -> receivedData; - - peerID = ENET_NET_TO_HOST_16 (header -> peerID); - flags = peerID & ENET_PROTOCOL_HEADER_FLAG_MASK; - peerID &= ~ ENET_PROTOCOL_HEADER_FLAG_MASK; - - if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) - peer = NULL; - else - if (peerID >= host -> peerCount) - return 0; - else - { - peer = & host -> peers [peerID]; - - if (peer -> state == ENET_PEER_STATE_DISCONNECTED || - peer -> state == ENET_PEER_STATE_ZOMBIE || - (host -> receivedAddress.host != peer -> address.host && - peer -> address.host != ENET_HOST_BROADCAST)) - return 0; - -#ifdef USE_CRC32 - { - enet_uint32 crc = header -> checksum; - ENetBuffer buffer; - - header -> checksum = peer -> sessionID; - - buffer.data = host -> receivedData; - buffer.dataLength = host -> receivedDataLength; - - if (enet_crc32 (& buffer, 1) != crc) - return 0; - } -#else - if (header -> checksum != peer -> sessionID) - return 0; -#endif - - peer -> address.host = host -> receivedAddress.host; - peer -> address.port = host -> receivedAddress.port; - peer -> incomingDataTotal += host -> receivedDataLength; - } - - headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof (ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *) 0) -> sentTime); - currentData = host -> receivedData + headerSize; - - while (currentData < & host -> receivedData [host -> receivedDataLength]) - { - enet_uint8 commandNumber; - size_t commandSize; - - command = (ENetProtocol *) currentData; - - if (currentData + sizeof (ENetProtocolCommandHeader) > & host -> receivedData [host -> receivedDataLength]) - break; - - commandNumber = command -> header.command & ENET_PROTOCOL_COMMAND_MASK; - if (commandNumber >= ENET_PROTOCOL_COMMAND_COUNT) - break; - - commandSize = commandSizes [commandNumber]; - if (commandSize == 0 || currentData + commandSize > & host -> receivedData [host -> receivedDataLength]) - break; - - currentData += commandSize; - - if (peer == NULL && commandNumber != ENET_PROTOCOL_COMMAND_CONNECT) - break; - - command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber); - - switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) - { - case ENET_PROTOCOL_COMMAND_ACKNOWLEDGE: - if (enet_protocol_handle_acknowledge (host, event, peer, command)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_CONNECT: - peer = enet_protocol_handle_connect (host, header, command); - if (peer == NULL) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_VERIFY_CONNECT: - if (enet_protocol_handle_verify_connect (host, event, peer, command)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_DISCONNECT: - if (enet_protocol_handle_disconnect (host, peer, command)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_PING: - if (enet_protocol_handle_ping (host, peer, command)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: - if (enet_protocol_handle_send_reliable (host, peer, command, & currentData)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE: - if (enet_protocol_handle_send_unreliable (host, peer, command, & currentData)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED: - if (enet_protocol_handle_send_unsequenced (host, peer, command, & currentData)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: - if (enet_protocol_handle_send_fragment (host, peer, command, & currentData)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT: - if (enet_protocol_handle_bandwidth_limit (host, peer, command)) - goto commandError; - break; - - case ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE: - if (enet_protocol_handle_throttle_configure (host, peer, command)) - goto commandError; - break; - - default: - goto commandError; - } - - if (peer != NULL && - (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) != 0) - { - enet_uint16 sentTime; - - if (! (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME)) - break; - - sentTime = ENET_NET_TO_HOST_16 (header -> sentTime); - - switch (peer -> state) - { - case ENET_PEER_STATE_DISCONNECTING: - case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT: - break; - - case ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT: - if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_DISCONNECT) - enet_peer_queue_acknowledgement (peer, command, sentTime); - break; - - default: - enet_peer_queue_acknowledgement (peer, command, sentTime); - break; - } - } - } - -commandError: - if (event != NULL && event -> type != ENET_EVENT_TYPE_NONE) - return 1; - - return 0; -} - -static int -enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event) -{ - for (;;) - { - int receivedLength; - ENetBuffer buffer; - - buffer.data = host -> receivedData; - buffer.dataLength = sizeof (host -> receivedData); - - receivedLength = enet_socket_receive (host -> socket, - & host -> receivedAddress, - & buffer, - 1); - - if (receivedLength < 0) - return -1; - - if (receivedLength == 0) - return 0; - - host -> receivedDataLength = receivedLength; - - switch (enet_protocol_handle_incoming_commands (host, event)) - { - case 1: - return 1; - - case -1: - return -1; - - default: - break; - } - } - - return -1; -} - -static void -enet_protocol_send_acknowledgements (ENetHost * host, ENetPeer * peer) -{ - ENetProtocol * command = & host -> commands [host -> commandCount]; - ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; - ENetAcknowledgement * acknowledgement; - ENetListIterator currentAcknowledgement; - - currentAcknowledgement = enet_list_begin (& peer -> acknowledgements); - - while (currentAcknowledgement != enet_list_end (& peer -> acknowledgements)) - { - if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || - buffer >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || - peer -> mtu - host -> packetSize < sizeof (ENetProtocolAcknowledge)) - { - host -> continueSending = 1; - - break; - } - - acknowledgement = (ENetAcknowledgement *) currentAcknowledgement; - - currentAcknowledgement = enet_list_next (currentAcknowledgement); - - buffer -> data = command; - buffer -> dataLength = sizeof (ENetProtocolAcknowledge); - - host -> packetSize += buffer -> dataLength; - - command -> header.command = ENET_PROTOCOL_COMMAND_ACKNOWLEDGE; - command -> header.channelID = acknowledgement -> command.header.channelID; - command -> acknowledge.receivedReliableSequenceNumber = ENET_HOST_TO_NET_16 (acknowledgement -> command.header.reliableSequenceNumber); - command -> acknowledge.receivedSentTime = ENET_HOST_TO_NET_16 (acknowledgement -> sentTime); - - if ((acknowledgement -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_DISCONNECT) - peer -> state = ENET_PEER_STATE_ZOMBIE; - - enet_list_remove (& acknowledgement -> acknowledgementList); - enet_free (acknowledgement); - - ++ command; - ++ buffer; - } - - host -> commandCount = command - host -> commands; - host -> bufferCount = buffer - host -> buffers; -} - -static void -enet_protocol_send_unreliable_outgoing_commands (ENetHost * host, ENetPeer * peer) -{ - ENetProtocol * command = & host -> commands [host -> commandCount]; - ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; - ENetOutgoingCommand * outgoingCommand; - ENetListIterator currentCommand; - - currentCommand = enet_list_begin (& peer -> outgoingUnreliableCommands); - - while (currentCommand != enet_list_end (& peer -> outgoingUnreliableCommands)) - { - size_t commandSize; - - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; - - if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || - buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || - peer -> mtu - host -> packetSize < commandSize || - (outgoingCommand -> packet != NULL && - peer -> mtu - host -> packetSize < commandSize + outgoingCommand -> packet -> dataLength)) - { - host -> continueSending = 1; - - break; - } - - currentCommand = enet_list_next (currentCommand); - - if (outgoingCommand -> packet != NULL) - { - peer -> packetThrottleCounter += ENET_PEER_PACKET_THROTTLE_COUNTER; - peer -> packetThrottleCounter %= ENET_PEER_PACKET_THROTTLE_SCALE; - - if (peer -> packetThrottleCounter > peer -> packetThrottle) - { - -- outgoingCommand -> packet -> referenceCount; - - if (outgoingCommand -> packet -> referenceCount == 0) - enet_packet_destroy (outgoingCommand -> packet); - - enet_list_remove (& outgoingCommand -> outgoingCommandList); - enet_free (outgoingCommand); - - continue; - } - } - - buffer -> data = command; - buffer -> dataLength = commandSize; - - host -> packetSize += buffer -> dataLength; - - * command = outgoingCommand -> command; - - enet_list_remove (& outgoingCommand -> outgoingCommandList); - - if (outgoingCommand -> packet != NULL) - { - ++ buffer; - - buffer -> data = outgoingCommand -> packet -> data; - buffer -> dataLength = outgoingCommand -> packet -> dataLength; - - host -> packetSize += buffer -> dataLength; - - enet_list_insert (enet_list_end (& peer -> sentUnreliableCommands), outgoingCommand); - } - else - enet_free (outgoingCommand); - - ++ command; - ++ buffer; - } - - host -> commandCount = command - host -> commands; - host -> bufferCount = buffer - host -> buffers; - - if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER && - enet_list_empty (& peer -> outgoingReliableCommands) && - enet_list_empty (& peer -> outgoingUnreliableCommands) && - enet_list_empty (& peer -> sentReliableCommands)) - enet_peer_disconnect (peer, peer -> disconnectData); -} - -static int -enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * event) -{ - ENetOutgoingCommand * outgoingCommand; - ENetListIterator currentCommand; - - currentCommand = enet_list_begin (& peer -> sentReliableCommands); - - while (currentCommand != enet_list_end (& peer -> sentReliableCommands)) - { - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - - currentCommand = enet_list_next (currentCommand); - - if (ENET_TIME_DIFFERENCE (timeCurrent, outgoingCommand -> sentTime) < outgoingCommand -> roundTripTimeout) - continue; - - if(peer -> earliestTimeout == 0 || - ENET_TIME_LESS(outgoingCommand -> sentTime, peer -> earliestTimeout)) - peer -> earliestTimeout = outgoingCommand -> sentTime; - - if (peer -> earliestTimeout != 0 && - (ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MAXIMUM || - (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit && - ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MINIMUM))) - { - enet_protocol_notify_disconnect (host, peer, event); - - return 1; - } - - if (outgoingCommand -> packet != NULL) - peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; - - ++ peer -> packetsLost; - - outgoingCommand -> roundTripTimeout *= 2; - - enet_list_insert (enet_list_begin (& peer -> outgoingReliableCommands), - enet_list_remove (& outgoingCommand -> outgoingCommandList)); - - if (currentCommand == enet_list_begin (& peer -> sentReliableCommands) && - ! enet_list_empty (& peer -> sentReliableCommands)) - { - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - - peer -> nextTimeout = outgoingCommand -> sentTime + outgoingCommand -> roundTripTimeout; - } - } - - return 0; -} - -static void -enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) -{ - ENetProtocol * command = & host -> commands [host -> commandCount]; - ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; - ENetOutgoingCommand * outgoingCommand; - ENetListIterator currentCommand; - - currentCommand = enet_list_begin (& peer -> outgoingReliableCommands); - - while (currentCommand != enet_list_end (& peer -> outgoingReliableCommands)) - { - size_t commandSize; - - outgoingCommand = (ENetOutgoingCommand *) currentCommand; - commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; - - if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || - buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || - peer -> mtu - host -> packetSize < commandSize) - { - host -> continueSending = 1; - - break; - } - - currentCommand = enet_list_next (currentCommand); - - if (outgoingCommand -> packet != NULL) - { - if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > peer -> windowSize) - break; - - if ((enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength)) - { - host -> continueSending = 1; - - break; - } - } - - if (outgoingCommand -> roundTripTimeout == 0) - { - outgoingCommand -> roundTripTimeout = peer -> roundTripTime + 4 * peer -> roundTripTimeVariance; - outgoingCommand -> roundTripTimeoutLimit = ENET_PEER_TIMEOUT_LIMIT * outgoingCommand -> roundTripTimeout; - } - - if (enet_list_empty (& peer -> sentReliableCommands)) - peer -> nextTimeout = timeCurrent + outgoingCommand -> roundTripTimeout; - - enet_list_insert (enet_list_end (& peer -> sentReliableCommands), - enet_list_remove (& outgoingCommand -> outgoingCommandList)); - - outgoingCommand -> sentTime = timeCurrent; - - buffer -> data = command; - buffer -> dataLength = commandSize; - - host -> packetSize += buffer -> dataLength; - host -> headerFlags |= ENET_PROTOCOL_HEADER_FLAG_SENT_TIME; - - * command = outgoingCommand -> command; - - if (outgoingCommand -> packet != NULL) - { - ++ buffer; - - buffer -> data = outgoingCommand -> packet -> data + outgoingCommand -> fragmentOffset; - buffer -> dataLength = outgoingCommand -> fragmentLength; - - host -> packetSize += outgoingCommand -> fragmentLength; - - peer -> reliableDataInTransit += outgoingCommand -> fragmentLength; - } - - ++ peer -> packetsSent; - - ++ command; - ++ buffer; - } - - host -> commandCount = command - host -> commands; - host -> bufferCount = buffer - host -> buffers; -} - -static int -enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int checkForTimeouts) -{ - ENetProtocolHeader header; - ENetPeer * currentPeer; - int sentLength; - - host -> continueSending = 1; - - while (host -> continueSending) - for (host -> continueSending = 0, - currentPeer = host -> peers; - currentPeer < & host -> peers [host -> peerCount]; - ++ currentPeer) - { - if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED || - currentPeer -> state == ENET_PEER_STATE_ZOMBIE) - continue; - - host -> headerFlags = 0; - host -> commandCount = 0; - host -> bufferCount = 1; - host -> packetSize = sizeof (ENetProtocolHeader); - - if (! enet_list_empty (& currentPeer -> acknowledgements)) - enet_protocol_send_acknowledgements (host, currentPeer); - - if (checkForTimeouts != 0 && - ! enet_list_empty (& currentPeer -> sentReliableCommands) && - ENET_TIME_GREATER_EQUAL (timeCurrent, currentPeer -> nextTimeout) && - enet_protocol_check_timeouts (host, currentPeer, event) == 1) - return 1; - - if (! enet_list_empty (& currentPeer -> outgoingReliableCommands)) - enet_protocol_send_reliable_outgoing_commands (host, currentPeer); - else - if (enet_list_empty (& currentPeer -> sentReliableCommands) && - ENET_TIME_DIFFERENCE (timeCurrent, currentPeer -> lastReceiveTime) >= ENET_PEER_PING_INTERVAL && - currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing)) - { - enet_peer_ping (currentPeer); - enet_protocol_send_reliable_outgoing_commands (host, currentPeer); - } - - if (! enet_list_empty (& currentPeer -> outgoingUnreliableCommands)) - enet_protocol_send_unreliable_outgoing_commands (host, currentPeer); - - if (host -> commandCount == 0) - continue; - - if (currentPeer -> packetLossEpoch == 0) - currentPeer -> packetLossEpoch = timeCurrent; - else - if (ENET_TIME_DIFFERENCE (timeCurrent, currentPeer -> packetLossEpoch) >= ENET_PEER_PACKET_LOSS_INTERVAL && - currentPeer -> packetsSent > 0) - { - enet_uint32 packetLoss = currentPeer -> packetsLost * ENET_PEER_PACKET_LOSS_SCALE / currentPeer -> packetsSent; - -#ifdef ENET_DEBUG -#ifdef WIN32 - printf ( -#else - fprintf (stderr, -#endif - "peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer -> incomingPeerID, currentPeer -> packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> roundTripTime, currentPeer -> roundTripTimeVariance, currentPeer -> packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size (& currentPeer -> outgoingReliableCommands), enet_list_size (& currentPeer -> outgoingUnreliableCommands), currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingReliableCommands) : 0, currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands) : 0); -#endif - - currentPeer -> packetLossVariance -= currentPeer -> packetLossVariance / 4; - - if (packetLoss >= currentPeer -> packetLoss) - { - currentPeer -> packetLoss += (packetLoss - currentPeer -> packetLoss) / 8; - currentPeer -> packetLossVariance += (packetLoss - currentPeer -> packetLoss) / 4; - } - else - { - currentPeer -> packetLoss -= (currentPeer -> packetLoss - packetLoss) / 8; - currentPeer -> packetLossVariance += (currentPeer -> packetLoss - packetLoss) / 4; - } - - currentPeer -> packetLossEpoch = timeCurrent; - currentPeer -> packetsSent = 0; - currentPeer -> packetsLost = 0; - } - - header.checksum = currentPeer -> sessionID; - header.peerID = ENET_HOST_TO_NET_16 (currentPeer -> outgoingPeerID | host -> headerFlags); - - host -> buffers -> data = & header; - if (host -> headerFlags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME) - { - header.sentTime = ENET_HOST_TO_NET_16 (timeCurrent & 0xFFFF); - - host -> buffers -> dataLength = sizeof (ENetProtocolHeader); - } - else - host -> buffers -> dataLength = (size_t) & ((ENetProtocolHeader *) 0) -> sentTime; - -#ifdef USE_CRC32 - header.checksum = enet_crc32 (host -> buffers, host -> bufferCount); -#endif - - currentPeer -> lastSendTime = timeCurrent; - - sentLength = enet_socket_send (host -> socket, & currentPeer -> address, host -> buffers, host -> bufferCount); - - enet_protocol_remove_sent_unreliable_commands (currentPeer); - - if (sentLength < 0) - return -1; - } - - return 0; -} - -/** Sends any queued packets on the host specified to its designated peers. - - @param host host to flush - @remarks this function need only be used in circumstances where one wishes to send queued packets earlier than in a call to enet_host_service(). - @ingroup host -*/ -void -enet_host_flush (ENetHost * host) -{ - timeCurrent = enet_time_get (); - - enet_protocol_send_outgoing_commands (host, NULL, 0); -} - -/** Waits for events on the host specified and shuttles packets between - the host and its peers. - - @param host host to service - @param event an event structure where event details will be placed if one occurs - if event == NULL then no events will be delivered - @param timeout number of milliseconds that ENet should wait for events - @retval > 0 if an event occurred within the specified time limit - @retval 0 if no event occurred - @retval < 0 on failure - @remarks enet_host_service should be called fairly regularly for adequate performance - @ingroup host -*/ -int -enet_host_service (ENetHost * host, ENetEvent * event, enet_uint32 timeout) -{ - enet_uint32 waitCondition; - - if (event != NULL) - { - event -> type = ENET_EVENT_TYPE_NONE; - event -> peer = NULL; - event -> packet = NULL; - - switch (enet_protocol_dispatch_incoming_commands (host, event)) - { - case 1: - return 1; - - case -1: - perror ("Error dispatching incoming packets"); - - return -1; - - default: - break; - } - } - - timeCurrent = enet_time_get (); - - timeout += timeCurrent; - - do - { - if (ENET_TIME_DIFFERENCE (timeCurrent, host -> bandwidthThrottleEpoch) >= ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL) - enet_host_bandwidth_throttle (host); - - switch (enet_protocol_send_outgoing_commands (host, event, 1)) - { - case 1: - return 1; - - case -1: - perror ("Error sending outgoing packets"); - - return -1; - - default: - break; - } - - switch (enet_protocol_receive_incoming_commands (host, event)) - { - case 1: - return 1; - - case -1: - perror ("Error receiving incoming packets"); - - return -1; - - default: - break; - } - - switch (enet_protocol_send_outgoing_commands (host, event, 1)) - { - case 1: - return 1; - - case -1: - perror ("Error sending outgoing packets"); - - return -1; - - default: - break; - } - - if (event != NULL) - { - switch (enet_protocol_dispatch_incoming_commands (host, event)) - { - case 1: - return 1; - - case -1: - perror ("Error dispatching incoming packets"); - - return -1; - - default: - break; - } - } - - timeCurrent = enet_time_get (); - - if (ENET_TIME_GREATER_EQUAL (timeCurrent, timeout)) - return 0; - - waitCondition = ENET_SOCKET_WAIT_RECEIVE; - - if (enet_socket_wait (host -> socket, & waitCondition, ENET_TIME_DIFFERENCE (timeout, timeCurrent)) != 0) - return -1; - - timeCurrent = enet_time_get (); - } while (waitCondition == ENET_SOCKET_WAIT_RECEIVE); - - return 0; -} - diff --git a/source/enet/tutorial.txt b/source/enet/tutorial.txt deleted file mode 100755 index f187e2d4..00000000 --- a/source/enet/tutorial.txt +++ /dev/null @@ -1,325 +0,0 @@ -* Using ENet - - Before using ENet, you must call enet_initialize() to initialize the -library. Upon program exit, you should call enet_deinitialize() so that -the library may clean up any used resources. - -i.e. - -int -main (int argc, char ** argv) -{ - if (enet_initialize () != 0) - { - fprintf (stderror, "An error occurred while initializing ENet.\n"); - return EXIT_FAILURE; - } - atexit (enet_deinitialize); - ... - ... - ... -} - -* Creating an ENet server - - Servers in ENet are constructed with enet_host_create(). You must specify -an address on which to receive data and new connections, as well as the maximum -allowable numbers of connected peers. You may optionally specify the incoming -and outgoing bandwidth of the server in bytes per second so that ENet may try -to statically manage bandwidth resources among connected peers in addition to -its dynamic throttling algorithm; specifying 0 for these two options will cause -ENet to rely entirely upon its dynamic throttling algorithm to manage -bandwidth. - - When done with a host, the host may be destroyed with enet_host_destroy(). -All connected peers to the host will be reset, and the resources used by -the host will be freed. - -i.e. - - ENetAddress address; - ENetHost * server; - - /* Bind the server to the default localhost. - * A specific host address can be specified by - * enet_address_set_host (& address, "x.x.x.x"); - */ - address.host = ENET_HOST_ANY; - /* Bind the server to port 1234. */ - address.port = 1234; - - server = enet_host_create (& address /* the address to bind the server host to */, - 32 /* allow up to 32 clients and/or outgoing connections */, - 0 /* assume any amount of incoming bandwidth */, - 0 /* assume any amount of outgoing bandwidth */); - if (server == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet server host.\n"); - exit (EXIT_FAILURE); - } - ... - ... - ... - enet_host_destroy(server); - -* Creating an ENet client - - Clients in ENet are similarly constructed with enet_host_create() when no -address is specified to bind the host to. Bandwidth may be specified for the -client host as in the above example. The peer count controls the maximum number -of connections to other server hosts that may be simultaneously open. - -i.e. - - ENetHost * client; - - clienet = enet_host_create (NULL /* create a client host */, - 1 /* only allow 1 outgoing connection */, - 57600 / 8 /* 56K modem with 56 Kbps downstream bandwidth */, - 14400 / 8 /* 56K modem with 14 Kbps upstream bandwidth */); - - if (client == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet client host.\n"); - exit (EXIT_FAILURE); - } - ... - ... - ... - enet_host_destroy(client); - -* Managing an ENet host - - ENet uses a polled event model to notify the programmer of significant -events. ENet hosts are polled for events with enet_host_service(), where an -optional timeout value in milliseconds may be specified to control how long -ENet will poll; if a timeout of 0 is specified, enet_host_service() will -return immediately if there are no events to dispatch. enet_host_service() -will return 1 if an event was dispatched within the specified timeout. - - Currently there are only four types of significant events in ENet: - -An event of type ENET_EVENT_TYPE_NONE is returned if no event occurred -within the specified time limit. enet_host_service() will return 0 -with this event. - -An event of type ENET_EVENT_TYPE_CONNECT is returned when either a new client -host has connected to the server host or when an attempt to establish a -connection with a foreign host has succeeded. Only the "peer" field of the -event structure is valid for this event and contains the newly connected peer. - -An event of type ENET_EVENT_TYPE_RECEIVE is returned when a packet is received -from a connected peer. The "peer" field contains the peer the packet was -received from, "channelID" is the channel on which the packet was sent, and -"packet" is the packet that was sent. The packet contained in the "packet" -field must be destroyed with enet_packet_destroy() when you are done -inspecting its contents. - -An event of type ENET_EVENT_TYPE_DISCONNECT is returned when a connected peer -has either explicitly disconnected or timed out. Only the "peer" field of the -event structure is valid for this event and contains the peer that -disconnected. Only the "data" field of the peer is still valid on a -disconnect event and must be explicitly reset. - -i.e. - - ENetEvent event; - - /* Wait up to 1000 milliseconds for an event. */ - while (enet_host_service (client, & event, 1000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - printf ("A new client connected from %x:%u.\n", - event.peer -> address.host, - event.peer -> address.port); - - /* Store any relevant client information here. */ - event.peer -> data = "Client information"; - - break; - - case ENET_EVENT_TYPE_RECEIVE: - printf ("A packet of length %u containing %s was received from %s on channel %u.\n", - event.packet -> dataLength, - event.packet -> data, - event.peer -> data, - event.channelID); - - /* Clean up the packet now that we're done using it. */ - enet_packet_destroy (event.packet); - - break; - - case ENET_EVENT_TYPE_DISCONNECT: - printf ("%s disconected.\n", event.peer -> data); - - /* Reset the peer's client information. */ - - event.peer -> data = NULL; - } - } - ... - ... - ... - -* Sending a packet to an ENet peer - - Packets in ENet are created with enet_packet_create(), where the size of -the packet must be specified. Optionally, initial data may be specified to -copy into the packet. - - Certain flags may also be supplied to enet_packet_create() to control -various packet features: - -ENET_PACKET_FLAG_RELIABLE specifies that the packet must use reliable delivery. -A reliable packet is guarenteed to be delivered, and a number of retry attempts -will be made until an acknowledgement is received from the foreign host the -packet is sent to. If a certain number of retry attempts is reached without -any acknowledgement, ENet will assume the peer has disconnected and forcefully -reset the connection. If this flag is not specified, the packet is assumed -an unreliable packet, and no retry attempts will be made nor acknowledgements -generated. - - A packet may be resized (extended or truncated) with enet_packet_resize(). - - A packet is sent to a foreign host with enet_peer_send(). enet_peer_send() -accepts a channel id over which to send the packet to a given peer. Once the -packet is handed over to ENet with enet_peer_send(), ENet will handle its -deallocation and enet_packet_destroy() should not be used upon it. - - One may also use enet_host_broadcast() to send a packet to all connected -peers on a given host over a specified channel id, as with enet_peer_send(). - - Queued packets will be sent on a call to enet_host_service(). -Alternatively, enet_host_flush() will send out queued packets without -dispatching any events. - -i.e. - - /* Create a reliable packet of size 7 containing "packet\0" */ - ENetPacket * packet = enet_packet_create ("packet", - strlen ("packet") + 1, - ENET_PACKET_FLAG_RELIABLE); - - /* Extend the packet so and append the string "foo", so it now - * contains "packetfoo\0" - * - enet_packet_resize (packet, strlen ("packetfoo") + 1); - strcpy (& packet -> data [strlen ("packet")], "foo"); - - /* Send the packet to the peer over channel id 3. - * One could also broadcast the packet by - * enet_host_broadcast (host, 3, packet); - */ - enet_peer_send (peer, 3, packet); - ... - ... - ... - /* One could just use enet_host_service() instead. */ - enet_host_flush (host); - -* Disconnecting an ENet peer - - Peers may be gently disconnected with enet_peer_disconnect(). A disconnect -request will be sent to the foreign host, and ENet will wait for an -acknowledgement from the foreign host before finally disconnecting. An -event of type ENET_EVENT_TYPE_DISCONNECT will be generated once the -disconnection succeeds. Normally timeouts apply to the disconnect -acknowledgement, and so if no acknowledgement is received after a length -of time the peer will be forcefully disconnected. - - enet_peer_reset() will forcefully disconnect a peer. The foreign host -will get no notification of a disconnect and will time out on the foreign -host. No event is generated. - -i.e. - ENetEvent event; - - enet_peer_disconnect (& client -> peers [0]); - - /* Allow up to 3 seconds for the disconnect to succeed - * and drop any packets received packets. - */ - while (enet_host_service (client, & event, 3000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_RECEIVE: - enet_packet_destroy (event.packet); - break; - - case ENET_EVENT_TYPE_DISCONNECT: - puts ("Disconnection succeeded."); - return; - ... - ... - ... - } - } - - /* We've arrived here, so the disconnect attempt didn't succeed yet. - * Force the connection down. - */ - enet_peer_reset (& client -> peers [0]); - ... - ... - ... - -* Connecting to an ENet host - - A connection to a foregin host is initiated with enet_host_connect(). -It accepts the address of a foreign host to connect to, and the number of -channels that should be allocated for communication. If N channels are -allocated for use, their channel ids will be numbered 0 through N-1. -A peer representing the connection attempt is returned, or NULL if there -were no available peers over which to initiate the connection. When the -connection attempt succeeds, an event of type ENET_EVENT_TYPE_CONNECT will -be generated. If the connection attempt times out or otherwise fails, an -event of type ENET_EVENT_TYPE_DISCONNECT will be generated. - -i.e. - ENetAddress address; - ENetEvent event; - ENetPeer *peer; - - /* Connect to some.server.net:1234. */ - enet_address_set_host (& address, "some.server.net"); - address.port = 1234; - - /* Initiate the connection, allocating the two channels 0 and 1. */ - peer = enet_host_connect (client, & address, 2); - - if (peer == NULL) - { - fprintf (stderr, - "No available peers for initiating an ENet connection.\n"); - exit (EXIT_FAILURE); - } - - /* Wait up to 5 seconds for the connection attempt to succeed. - if (enet_host_service (client, & event, 5000) > 0 && - event.type == ENET_EVENT_TYPE_CONNECT) - { - puts ("Connection to some.server.net:1234 succeeded."); - ... - ... - ... - } - else - { - /* Either the 5 seconds are up or a disconnect event was - * received. Reset the peer in the event the 5 seconds - * had run out without any significant event. - */ - enet_peer_reset (peer); - - puts ("Connection to some.server.net:1234 failed."); - } - ... - ... - ... - diff --git a/source/enet/unix.c b/source/enet/unix.c deleted file mode 100755 index 75385a83..00000000 --- a/source/enet/unix.c +++ /dev/null @@ -1,399 +0,0 @@ -/** - @file unix.c - @brief ENet Unix system specific functions -*/ -#ifndef WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ENET_BUILDING_LIB 1 -#include "enet/enet.h" - -#ifdef HAS_FCNTL -#include -#endif - -#ifdef __APPLE__ -#undef HAS_POLL -#endif - -#ifdef HAS_POLL -#include -#endif - -#ifndef HAS_SOCKLEN_T -typedef int socklen_t; -#endif - -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - -static enet_uint32 timeBase = 0; - -int -enet_initialize (void) -{ - return 0; -} - -void -enet_deinitialize (void) -{ -} - -enet_uint32 -enet_time_get (void) -{ - struct timeval timeVal; - - gettimeofday (& timeVal, NULL); - - return timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - timeBase; -} - -void -enet_time_set (enet_uint32 newTimeBase) -{ - struct timeval timeVal; - - gettimeofday (& timeVal, NULL); - - timeBase = timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - newTimeBase; -} - -int -enet_address_set_host (ENetAddress * address, const char * name) -{ - struct hostent * hostEntry = NULL; -#ifdef HAS_GETHOSTBYNAME_R - struct hostent hostData; - char buffer [2048]; - int errnum; - -#if defined(linux) || defined(FREEBSD) - gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum); -#else - hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum); -#endif -#else - hostEntry = gethostbyname (name); -#endif - - if (hostEntry == NULL || - hostEntry -> h_addrtype != AF_INET) - { -#ifdef HAS_INET_PTON - if (! inet_pton (AF_INET, name, & address -> host)) -#else - if (! inet_aton (name, (struct in_addr *) & address -> host)) -#endif - return -1; - return 0; - } - - address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; - - return 0; -} - -int -enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) -{ - struct in_addr in; - struct hostent * hostEntry = NULL; -#ifdef HAS_GETHOSTBYADDR_R - struct hostent hostData; - char buffer [2048]; - int errnum; - - in.s_addr = address -> host; - -#if defined(linux) || defined(FREEBSD) - gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum); -#else - hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum); -#endif -#else - in.s_addr = address -> host; - - hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); -#endif - - if (hostEntry == NULL) - { -#ifdef HAS_INET_NTOP - if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) -#else - char * addr = inet_ntoa (* (struct in_addr *) & address -> host); - if (addr != NULL) - strncpy (name, addr, nameLength); - else -#endif - return -1; - return 0; - } - - strncpy (name, hostEntry -> h_name, nameLength); - - return 0; -} - -ENetSocket -enet_socket_create (ENetSocketType type, const ENetAddress * address) -{ - ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); - int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE, - sendBufferSize = ENET_HOST_SEND_BUFFER_SIZE, - allowBroadcasting = 1; -#ifndef HAS_FCNTL - int nonBlocking = 1; -#endif - struct sockaddr_in sin; - - if (newSocket == ENET_SOCKET_NULL) - return ENET_SOCKET_NULL; - - if (type == ENET_SOCKET_TYPE_DATAGRAM) - { -#ifdef HAS_FCNTL - fcntl (newSocket, F_SETFL, O_NONBLOCK | fcntl (newSocket, F_GETFL)); -#else - ioctl (newSocket, FIONBIO, & nonBlocking); -#endif - - setsockopt (newSocket, SOL_SOCKET, SO_RCVBUF, (char *) & receiveBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_SNDBUF, (char *) & sendBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_BROADCAST, (char *) & allowBroadcasting, sizeof (int)); - } - - if (address == NULL) - return newSocket; - - memset (& sin, 0, sizeof (struct sockaddr_in)); - - sin.sin_family = AF_INET; - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - - if (bind (newSocket, - (struct sockaddr *) & sin, - sizeof (struct sockaddr_in)) == -1 || - (type == ENET_SOCKET_TYPE_STREAM && - listen (newSocket, SOMAXCONN) == -1)) - { - close (newSocket); - - return ENET_SOCKET_NULL; - } - - return newSocket; -} - -int -enet_socket_connect (ENetSocket socket, const ENetAddress * address) -{ - struct sockaddr_in sin; - - memset (& sin, 0, sizeof (struct sockaddr_in)); - - sin.sin_family = AF_INET; - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - - return connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); -} - -ENetSocket -enet_socket_accept (ENetSocket socket, ENetAddress * address) -{ - int result; - struct sockaddr_in sin; - socklen_t sinLength = sizeof (struct sockaddr_in); - - result = accept (socket, - address != NULL ? (struct sockaddr *) & sin : NULL, - address != NULL ? & sinLength : NULL); - - if (result == -1) - return ENET_SOCKET_NULL; - - if (address != NULL) - { - address -> host = (enet_uint32) sin.sin_addr.s_addr; - address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); - } - - return result; -} - -void -enet_socket_destroy (ENetSocket socket) -{ - close (socket); -} - -int -enet_socket_send (ENetSocket socket, - const ENetAddress * address, - const ENetBuffer * buffers, - size_t bufferCount) -{ - struct msghdr msgHdr; - struct sockaddr_in sin; - int sentLength; - - memset (& msgHdr, 0, sizeof (struct msghdr)); - - if (address != NULL) - { - sin.sin_family = AF_INET; - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - - msgHdr.msg_name = & sin; - msgHdr.msg_namelen = sizeof (struct sockaddr_in); - } - - msgHdr.msg_iov = (struct iovec *) buffers; - msgHdr.msg_iovlen = bufferCount; - - sentLength = sendmsg (socket, & msgHdr, MSG_NOSIGNAL); - - if (sentLength == -1) - { - if (errno == EWOULDBLOCK) - return 0; - - return -1; - } - - return sentLength; -} - -int -enet_socket_receive (ENetSocket socket, - ENetAddress * address, - ENetBuffer * buffers, - size_t bufferCount) -{ - struct msghdr msgHdr; - struct sockaddr_in sin; - int recvLength; - - memset (& msgHdr, 0, sizeof (struct msghdr)); - - if (address != NULL) - { - msgHdr.msg_name = & sin; - msgHdr.msg_namelen = sizeof (struct sockaddr_in); - } - - msgHdr.msg_iov = (struct iovec *) buffers; - msgHdr.msg_iovlen = bufferCount; - - recvLength = recvmsg (socket, & msgHdr, MSG_NOSIGNAL); - - if (recvLength == -1) - { - if (errno == EWOULDBLOCK) - return 0; - - return -1; - } - -#ifdef HAS_MSGHDR_FLAGS - if (msgHdr.msg_flags & MSG_TRUNC) - return -1; -#endif - - if (address != NULL) - { - address -> host = (enet_uint32) sin.sin_addr.s_addr; - address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); - } - - return recvLength; -} - -int -enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) -{ -#ifdef HAS_POLL - struct pollfd pollSocket; - int pollCount; - - pollSocket.fd = socket; - pollSocket.events = 0; - - if (* condition & ENET_SOCKET_WAIT_SEND) - pollSocket.events |= POLLOUT; - - if (* condition & ENET_SOCKET_WAIT_RECEIVE) - pollSocket.events |= POLLIN; - - pollCount = poll (& pollSocket, 1, timeout); - - if (pollCount < 0) - return -1; - - * condition = ENET_SOCKET_WAIT_NONE; - - if (pollCount == 0) - return 0; - - if (pollSocket.revents & POLLOUT) - * condition |= ENET_SOCKET_WAIT_SEND; - - if (pollSocket.revents & POLLIN) - * condition |= ENET_SOCKET_WAIT_RECEIVE; - - return 0; -#else - fd_set readSet, writeSet; - struct timeval timeVal; - int selectCount; - - timeVal.tv_sec = timeout / 1000; - timeVal.tv_usec = (timeout % 1000) * 1000; - - FD_ZERO (& readSet); - FD_ZERO (& writeSet); - - if (* condition & ENET_SOCKET_WAIT_SEND) - FD_SET (socket, & writeSet); - - if (* condition & ENET_SOCKET_WAIT_RECEIVE) - FD_SET (socket, & readSet); - - selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); - - if (selectCount < 0) - return -1; - - * condition = ENET_SOCKET_WAIT_NONE; - - if (selectCount == 0) - return 0; - - if (FD_ISSET (socket, & writeSet)) - * condition |= ENET_SOCKET_WAIT_SEND; - - if (FD_ISSET (socket, & readSet)) - * condition |= ENET_SOCKET_WAIT_RECEIVE; - - return 0; -#endif -} - -#endif - diff --git a/source/enet/win32.c b/source/enet/win32.c deleted file mode 100755 index 8fdd7468..00000000 --- a/source/enet/win32.c +++ /dev/null @@ -1,311 +0,0 @@ -/** - @file win32.c - @brief ENet Win32 system specific functions -*/ -#ifdef WIN32 - -#include -#define ENET_BUILDING_LIB 1 -#include "enet/enet.h" - -static enet_uint32 timeBase = 0; - -int -enet_initialize (void) -{ - WORD versionRequested = MAKEWORD (1, 1); - WSADATA wsaData; - - if (WSAStartup (versionRequested, & wsaData)) - return -1; - - if (LOBYTE (wsaData.wVersion) != 1|| - HIBYTE (wsaData.wVersion) != 1) - { - WSACleanup (); - - return -1; - } - - timeBeginPeriod (1); - - return 0; -} - -void -enet_deinitialize (void) -{ - timeEndPeriod (1); - - WSACleanup (); -} - -enet_uint32 -enet_time_get (void) -{ - return (enet_uint32) timeGetTime () - timeBase; -} - -void -enet_time_set (enet_uint32 newTimeBase) -{ - timeBase = (enet_uint32) timeGetTime () - newTimeBase; -} - -int -enet_address_set_host (ENetAddress * address, const char * name) -{ - struct hostent * hostEntry; - - hostEntry = gethostbyname (name); - if (hostEntry == NULL || - hostEntry -> h_addrtype != AF_INET) - { - unsigned long host = inet_addr (name); - if (host == INADDR_NONE) - return -1; - address -> host = host; - return 0; - } - - address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; - - return 0; -} - -int -enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) -{ - struct in_addr in; - struct hostent * hostEntry; - - in.s_addr = address -> host; - - hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); - if (hostEntry == NULL) - { - char * addr = inet_ntoa (* (struct in_addr *) & address -> host); - if (addr == NULL) - return -1; - strncpy (name, addr, nameLength); - return 0; - } - - strncpy (name, hostEntry -> h_name, nameLength); - - return 0; -} - -ENetSocket -enet_socket_create (ENetSocketType type, const ENetAddress * address) -{ - ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); - u_long nonBlocking = 1; - int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE, - sendBufferSize = ENET_HOST_SEND_BUFFER_SIZE, - allowBroadcasting = 1; - struct sockaddr_in sin; - - if (newSocket == ENET_SOCKET_NULL) - return ENET_SOCKET_NULL; - - if (type == ENET_SOCKET_TYPE_DATAGRAM) - { - ioctlsocket (newSocket, FIONBIO, & nonBlocking); - - setsockopt (newSocket, SOL_SOCKET, SO_RCVBUF, (char *) & receiveBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_SNDBUF, (char *) & sendBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_BROADCAST, (char *) & allowBroadcasting, sizeof (int)); - } - - memset (& sin, 0, sizeof (struct sockaddr_in)); - - sin.sin_family = AF_INET; - - if (address != NULL) - { - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - } - else - { - sin.sin_port = 0; - sin.sin_addr.s_addr = INADDR_ANY; - } - - if (bind (newSocket, - (struct sockaddr *) & sin, - sizeof (struct sockaddr_in)) == SOCKET_ERROR || - (type == ENET_SOCKET_TYPE_STREAM && - address != NULL && - listen (newSocket, SOMAXCONN) == SOCKET_ERROR)) - { - closesocket (newSocket); - - return ENET_SOCKET_NULL; - } - - return newSocket; -} - -int -enet_socket_connect (ENetSocket socket, const ENetAddress * address) -{ - struct sockaddr_in sin; - - memset (& sin, 0, sizeof (struct sockaddr_in)); - - sin.sin_family = AF_INET; - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - - return connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); -} - -ENetSocket -enet_socket_accept (ENetSocket socket, ENetAddress * address) -{ - SOCKET result; - struct sockaddr_in sin; - int sinLength = sizeof (struct sockaddr_in); - - result = accept (socket, - address != NULL ? (struct sockaddr *) & sin : NULL, - address != NULL ? & sinLength : NULL); - - if (result == INVALID_SOCKET) - return ENET_SOCKET_NULL; - - if (address != NULL) - { - address -> host = (enet_uint32) sin.sin_addr.s_addr; - address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); - } - - return result; -} - -void -enet_socket_destroy (ENetSocket socket) -{ - closesocket (socket); -} - -int -enet_socket_send (ENetSocket socket, - const ENetAddress * address, - const ENetBuffer * buffers, - size_t bufferCount) -{ - struct sockaddr_in sin; - DWORD sentLength; - - if (address != NULL) - { - sin.sin_family = AF_INET; - sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); - sin.sin_addr.s_addr = address -> host; - } - - if (WSASendTo (socket, - (LPWSABUF) buffers, - (DWORD) bufferCount, - & sentLength, - 0, - address != NULL ? (struct sockaddr *) & sin : 0, - address != NULL ? sizeof (struct sockaddr_in) : 0, - NULL, - NULL) == SOCKET_ERROR) - { - if (WSAGetLastError () == WSAEWOULDBLOCK) - return 0; - - return -1; - } - - return (int) sentLength; -} - -int -enet_socket_receive (ENetSocket socket, - ENetAddress * address, - ENetBuffer * buffers, - size_t bufferCount) -{ - INT sinLength = sizeof (struct sockaddr_in); - DWORD flags = 0, - recvLength; - struct sockaddr_in sin; - - if (WSARecvFrom (socket, - (LPWSABUF) buffers, - (DWORD) bufferCount, - & recvLength, - & flags, - address != NULL ? (struct sockaddr *) & sin : NULL, - address != NULL ? & sinLength : NULL, - NULL, - NULL) == SOCKET_ERROR) - { - switch (WSAGetLastError ()) - { - case WSAEWOULDBLOCK: - case WSAECONNRESET: - return 0; - } - - return -1; - } - - if (flags & MSG_PARTIAL) - return -1; - - if (address != NULL) - { - address -> host = (enet_uint32) sin.sin_addr.s_addr; - address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); - } - - return (int) recvLength; -} - -int -enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) -{ - fd_set readSet, writeSet; - struct timeval timeVal; - int selectCount; - - timeVal.tv_sec = timeout / 1000; - timeVal.tv_usec = (timeout % 1000) * 1000; - - FD_ZERO (& readSet); - FD_ZERO (& writeSet); - - if (* condition & ENET_SOCKET_WAIT_SEND) - FD_SET (socket, & writeSet); - - if (* condition & ENET_SOCKET_WAIT_RECEIVE) - FD_SET (socket, & readSet); - - selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); - - if (selectCount < 0) - return -1; - - * condition = ENET_SOCKET_WAIT_NONE; - - if (selectCount == 0) - return 0; - - if (FD_ISSET (socket, & writeSet)) - * condition |= ENET_SOCKET_WAIT_SEND; - - if (FD_ISSET (socket, & readSet)) - * condition |= ENET_SOCKET_WAIT_RECEIVE; - - return 0; -} - -#endif - diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp new file mode 100644 index 00000000..f80aad13 --- /dev/null +++ b/source/src/bot/ac_bot.cpp @@ -0,0 +1,319 @@ +// +// C++ Implementation: bot +// +// Description: Main bot code for Action Cube +// +// Main bot file +// +// Author: Rick +// +// +// + +#include "../cube.h" + +#ifdef AC_CUBE + +extern vector sents; +extern int triggertime; +extern itemstat itemstats[]; +extern void spawnstate(dynent *d); + +//AC Bot class begin + +void CACBot::Spawn() +{ + // Init all bot variabeles + m_pMyEnt->eyeheight = 4.25f; + m_pMyEnt->aboveeye = 0.7f; + m_pMyEnt->radius = 1.1f; + m_pMyEnt->primary = m_pMyEnt->nextprimary = 2 + rnd(4); + + spawnplayer(m_pMyEnt); + + m_pMyEnt->targetyaw = m_pMyEnt->yaw = m_pMyEnt->targetpitch = m_pMyEnt->pitch = 0.0f; + radd(this->m_pMyEnt); + m_pMyEnt->move = 0; + m_pMyEnt->enemy = NULL; + m_pMyEnt->maxspeed = 16.0f; + m_pMyEnt->health = 100; + m_pMyEnt->armour = 50; + m_pMyEnt->pitch = 0; + m_pMyEnt->roll = 0; + m_pMyEnt->state = CS_ALIVE; + m_pMyEnt->anger = 0; + m_pMyEnt->pBot = this; + m_pMyEnt->lastanimswitchtime = -1; +// loopi(NUMGUNS) m_pMyEnt->ammo[i] = m_pMyEnt->mag[i] = 0; + + /* UNDONE + m_pMyEnt->ammo[GUN_FIST] = 1; + if(m_noitems) + { + m_pMyEnt->gunselect = GUN_RIFLE; + m_pMyEnt->armour = 0; + if(m_noitemsrail) + { + m_pMyEnt->health = 1; + m_pMyEnt->ammo[GUN_RIFLE] = 100; + } + else + { + if(gamemode==12) // eihrul's secret "instafist" mode + { + m_pMyEnt->gunselect = GUN_FIST; + } + else + { + m_pMyEnt->health = 256; + if(m_tarena) + { + int gun1 = rnd(4)+1; + botbaseammo(m_pMyEnt->gunselect = gun1, m_pMyEnt); + for(;;) + { + int gun2 = rnd(4)+1; + if(gun1!=gun2) { botbaseammo(gun2, m_pMyEnt); break; }; + } + } + else if(m_arena) // insta arena + { + m_pMyEnt->ammo[GUN_RIFLE] = 100; + } + else // efficiency + { + loopi(4) botbaseammo(i+1, m_pMyEnt); + m_pMyEnt->gunselect = GUN_CG; + } + m_pMyEnt->ammo[GUN_CG] /= 2; + } + } + } + else + { + m_pMyEnt->ammo[GUN_SEMIPISTOL] = 5; + SelectGun(GUN_SG); + }*/ + + SelectGun(m_pMyEnt->primary); + + m_eCurrentBotState = STATE_NORMAL; + m_iShootDelay = m_iChangeWeaponDelay = 0; + m_iCheckEnvDelay = 0; + m_vPrevOrigin = g_vecZero; + m_iStuckCheckDelay = lastmillis + 250; + m_bStuck = false; + m_iStuckTime = 0; + m_iStrafeTime = m_iStrafeCheckDelay = 0; + m_iMoveDir = DIR_NONE; + + m_pPrevEnemy = NULL; + m_iCombatNavTime = 0; + m_iSPMoveTime = 0; + m_iEnemySearchDelay = 0; + m_bCombatJump = false; + m_iCombatJumpDelay = 0; + m_bShootAtFeet = (RandomLong(1, 100) <= m_pBotSkill->sShootAtFeetWithRLPercent); + m_iHuntDelay = 0; + m_vHuntLocation = m_vPrevHuntLocation = g_vecZero; + m_pHuntTarget = NULL; + m_fPrevHuntDist = 0.0f; + m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0; + + m_iLastJumpPad = 0; + m_pTargetEnt = NULL; + m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0; + m_iCheckEntsDelay = 0; + m_iCheckTriggersDelay = 0; + m_iLookForWaypointTime = 0; + + m_iAimDelay = 0; + m_fYawToTurn = m_fPitchToTurn = 0.0f; + + m_vGoal = m_vWaterGoal = g_vecZero; + + ResetWaypointVars(); +} + +void CACBot::BotPain(int damage, dynent *d, bool gib) +{ + if(m_pMyEnt->state!=CS_ALIVE || editmode || intermission) return; +//fixmebot + int ad = damage*30/100; + if(ad>m_pMyEnt->armour) ad = m_pMyEnt->armour; + m_pMyEnt->armour -= ad; + damage -= ad; + float droll = damage/0.5f; + m_pMyEnt->roll += m_pMyEnt->roll>0 ? droll : (m_pMyEnt->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage + if((m_pMyEnt->health -= damage)<=0) + { + if (player1 == d) + { + int frags; + if(isteam(player1->team, m_pMyEnt->team)) + { + frags = -1; + conoutf("you fragged a teammate (%s)", m_pMyEnt->name); + } + else + { + frags = 1; + conoutf("you fragged %s", m_pMyEnt->name); + } + addmsg(SV_FRAGS, "ri", player1->frags += frags); + addmsg(SV_BOTDIED, "ri3", BotManager.GetBotIndex(m_pMyEnt), -1, false); + if(gib) addgib(m_pMyEnt); + } + else if (d->monsterstate) + conoutf("%s got killed by %s", m_pMyEnt->name, d->name); + else + { + int KillerIndex = -1; + + if (d == m_pMyEnt) + { + conoutf("%s suicided", d->name); + KillerIndex = BotManager.GetBotIndex(d); + addmsg(SV_BOTFRAGS, "rii", KillerIndex, --d->frags); + } + else + { + if (d->bIsBot) + { + KillerIndex = BotManager.GetBotIndex(d); + addmsg(SV_BOTFRAGS, "rii", KillerIndex, ++d->frags); + } + else + loopv(players){ if (players[i] == d) { KillerIndex = i; break;} } + + if(isteam(m_pMyEnt->team, d->team)) + { + conoutf("%s fragged his teammate (%s)", d->name, + m_pMyEnt->name); + } + else + { + conoutf("%s fragged %s", d->name, m_pMyEnt->name); + } + } + addmsg(SV_BOTDIED, "ri3", BotManager.GetBotIndex(m_pMyEnt), KillerIndex, + d->bIsBot); + if(d->gunselect==GUN_KNIFE) addgib(m_pMyEnt); + } + + m_pMyEnt->lifesequence++; + m_pMyEnt->attacking = false; + m_pMyEnt->state = CS_DEAD; + m_pMyEnt->pitch = 0; + m_pMyEnt->roll = 60; + playsound(S_DIE1+rnd(2), &m_pMyEnt->o); + spawnstate(m_pMyEnt); + m_pMyEnt->lastaction = lastmillis; + } + else + { + playsound(S_PAIN6, &m_pMyEnt->o); + } +} + +void CACBot::CheckItemPickup() +{ + if(editmode) return; + loopv(ents) + { + entity &e = ents[i]; + if(e.type==NOTUSED) continue; + + if (!e.spawned) continue; + if ((i < sents.length()) && (!sents[i].spawned)) continue; + + if(OUTBORD(e.x, e.y)) continue; + vec v = { e.x, e.y, S(e.x, e.y)->floor+m_pMyEnt->eyeheight }; + vdist(dist, t, m_pMyEnt->o, v); + if(dist<2.5) + { + PickUp(i); + } + } +} + +void CACBot::PickUp(int n) +{ + int np = 1; + loopv(players) if(players[i]) np++; + loopv(bots) if(bots[i]) np++; + np = np<3 ? 4 : (np>4 ? 2 : 3); // spawn times are dependent on number of players + int ammo = np*2; + switch(ents[n].type) + { + case I_AMMO: AddItem(n, m_pMyEnt->ammo[m_pMyEnt->primary], ammo, m_pMyEnt->primary); break; + case I_CLIPS: AddItem(n, m_pMyEnt->ammo[GUN_PISTOL], ammo, GUN_PISTOL); break; + case I_GRENADE: AddItem(n, m_pMyEnt->ammo[GUN_GRENADE], ammo, 6); break; + case I_HEALTH: AddItem(n, m_pMyEnt->health, ammo, 7); break; + case I_ARMOUR: AddItem(n, m_pMyEnt->armour, ammo, 8); break; + +/* case I_HELMET: + // (100h/100g only absorbs 166 damage) + if(m_pMyEnt->armourtype==A_YELLOW && m_pMyEnt->armour>66) break; + AddItem(n, m_pMyEnt->armour, 20); + break; + + case I_ARMOUR: + AddItem(n, m_pMyEnt->armour, 20); + break; + + case OBJ_ITEM: + AddItem(n, m_pMyEnt->quadmillis, 60); + break;*/ + +/* case TRIGGER: + ents[n].spawned = false; + triggertime = lastmillis; + trigger(ents[n].attr1, ents[n].attr2, false); // needs to go over server for multiplayer + + // HACK: Reset ent goal if bot was looking for this ent + if (m_pTargetEnt == &ents[n]) + { + m_pTargetEnt = NULL; + m_vGoal = g_vecZero; + ResetWaypointVars(); + m_iCheckEntsDelay = lastmillis + RandomLong(5000, 10000); + } + + BotManager.PickNextTrigger(); + break;*/ + }; +}; + +void CACBot::AddItem(int i, int &v, int spawnsec, int t) +{ + if((i>=sents.length()) || (!sents[i].spawned)) + return; + +//fixmebot + if(v>=itemstats[t].max) // don't pick up if not needed + return; + + itemstat &is = itemstats[t]; + ents[i].spawned = false; + v += is.add; + if(v>is.max) v = is.max; + botplaysound(is.sound, m_pMyEnt); + sents[i].spawned = false; + sents[i].spawnsecs = spawnsec; + + addmsg(SV_BOTITEMPICKUP, "rii", i, m_classicsp ? 100000 : spawnsec); + + // HACK: Reset ent goal if bot was looking for for this ent + if (m_pTargetEnt == &ents[i]) + { + m_pTargetEnt = NULL; + m_vGoal = g_vecZero; + ResetWaypointVars(); + m_iCheckEntsDelay = lastmillis + RandomLong(5000, 10000); + }; +} + +// AC Bot class end + +#endif diff --git a/source/src/bot/ac_bot.h b/source/src/bot/ac_bot.h new file mode 100644 index 00000000..6abe9e77 --- /dev/null +++ b/source/src/bot/ac_bot.h @@ -0,0 +1,47 @@ +// +// C++ Implementation: bot +// +// Description: +// +// Header specific for AC_CUBE +// +// Author: Rick +// +// +// + +#ifndef AC_BOT_H +#define AC_BOT_H + +#ifdef AC_CUBE + +#define MAX_WEAPONS 7 + +class CACBot: public CBot +{ +public: + friend class CBotManager; + friend class CWaypointClass; + + virtual void CheckItemPickup(void); + virtual void PickUp(int n); + virtual void AddItem(int i, int &v, int spawnsec, int t); + + // AI Functions + virtual bool ChoosePreferredWeapon(void); + void Reload(int Gun); + virtual entity *SearchForEnts(bool bUseWPs, float flRange=9999.0f, + float flMaxHeight=JUMP_HEIGHT); + virtual bool HeadToTargetEnt(void); + virtual bool DoSPStuff(void); + + virtual void Spawn(void); + virtual void BotPain(int damage, dynent *d, bool gib=false); +}; + +inline void AddScreenText(char *t, ...) {}; // UNDONE +inline void AddDebugText(char *t, ...) {}; // UNDONE + +#endif + +#endif diff --git a/source/src/bot/ac_bot_ai.cpp b/source/src/bot/ac_bot_ai.cpp new file mode 100644 index 00000000..749ecda9 --- /dev/null +++ b/source/src/bot/ac_bot_ai.cpp @@ -0,0 +1,321 @@ +// +// C++ Implementation: ac_bot_ai +// +// Description: The AI part of the bot for ac is here(navigation, shooting etc) +// +// +// Author: +// + + + +#include "../cube.h" + +#ifdef AC_CUBE + +extern vector sents; +extern vector monsters; + +// UNDONE +weaponinfo_s WeaponInfoTable[MAX_WEAPONS] = +{ + // KNIFE + { TYPE_MELEE, 0.0f, 2.0f, 0.0f, 3.5f, 1 }, + // PISTOL + { TYPE_NORMAL, 0.0f, 20.0f, 0.0f, 50.0f, 6 }, + // SHOTGUN + { TYPE_SHOTGUN, 0.0f, 15.0f, 0.0f, 40.0f, 3 }, + // SUBGUN + { TYPE_AUTO, 0.0f, 25.0f, 0.0f, 60.0f, 10 }, + // SNIPER + { TYPE_SNIPER, 30.0f, 50.0f, 20.0f, 200.0f, 3 }, + // ASSAULT + { TYPE_AUTO, 40.0f, 80.0f, 0.0f, 150.0f, 6 }, + // GRENADE + { TYPE_GRENADE, 30.0f, 25.0f, 0.0f, 50.0f, 1 } +}; + +// Code of CACBot - Start + +bool CACBot::ChoosePreferredWeapon() +{ + short bestWeapon = m_pMyEnt->gunselect; + short bestWeaponScore = 0; + + short sWeaponScore; + float flDist = GetDistance(m_pMyEnt->enemy->o); + + if (m_iChangeWeaponDelay < lastmillis && m_pMyEnt->mag[m_pMyEnt->gunselect]) + { + if ((WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType != TYPE_MELEE) || (flDist <= WeaponInfoTable[GUN_KNIFE].flMaxFireDistance)) + return true; + }; + + // Choose a weapon + for(int i=0;imag[i] && !m_pMyEnt->ammo[i]) continue; + + sWeaponScore = 5; // Minimal score for a weapon + + // use the advantage of the melee weapon + if((flDist >= WeaponInfoTable[i].flMinDesiredDistance) && + (flDist <= WeaponInfoTable[i].flMaxDesiredDistance)) + { + if(WeaponInfoTable[i].eWeaponType == TYPE_MELEE) sWeaponScore += 5; + } + + if ((flDist > WeaponInfoTable[i].flMinFireDistance) && // inside the range, continue to evaluate + (flDist < WeaponInfoTable[i].flMaxFireDistance)) + { + if(m_pMyEnt->mag[i]) sWeaponScore += 5; + if(i > 1) sWeaponScore += 4; // prefer primary guns + } + + if(sWeaponScore > bestWeaponScore) + { + bestWeaponScore = sWeaponScore; + bestWeapon = i; + } + } + + { + m_iChangeWeaponDelay = lastmillis + 8000; //RandomLong(2000, 8000); + m_bShootAtFeet = false; + SelectGun(bestWeapon); + if(!m_pMyEnt->mag[bestWeapon]) + { + reload(m_pMyEnt); + m_iShootDelay = lastmillis + reloadtime(bestWeapon) + 10; + } + return true; + } +}; + +void CACBot::Reload(int Gun) +{ + printf("bot reload"); +}; + +entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight) +{ + /* Entities are scored on the following things: + - Visibility + - For ammo: Need(ie has this bot much of this type or not) + - distance + */ + + float flNearestDist = 9999, flDist; + entity *pNewTargetEnt = NULL; + waypoint_s *pWptNearBot = NULL, *pBestWpt = NULL; + short sScore, sHighestScore = 0; + + if ((WaypointClass.m_iWaypointCount >= 1) && bUseWPs) + pWptNearBot = GetNearestWaypoint(15.0f); + +#ifdef WP_FLOOD + if (!pWptNearBot && bUseWPs) + pWptNearBot = GetNearestFloodWP(5.0f); +#endif + + loopv(ents) + { + sScore = 0; + entity &e = ents[i]; + vec o = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + + if (!ents[i].spawned) continue; + if (OUTBORD(e.x, e.y)) continue; + + bool bInteresting = false; + short sAmmo = 0, sMaxAmmo = 0; + //fixmebot + switch(e.type) + { + case I_CLIPS: + sMaxAmmo = itemstats[GUN_PISTOL].max; + bInteresting = (m_pMyEnt->ammo[GUN_PISTOL]ammo[GUN_PISTOL]; + break; + case I_AMMO: + sMaxAmmo = itemstats[m_pMyEnt->primary].max; + bInteresting = (m_pMyEnt->ammo[m_pMyEnt->primary]ammo[m_pMyEnt->primary]; + break; + case I_GRENADE: + sMaxAmmo = itemstats[GUN_GRENADE].max; + bInteresting = (m_pMyEnt->ammo[GUN_GRENADE]ammo[GUN_GRENADE]; + break; + case I_HEALTH: + sMaxAmmo = itemstats[7].max; //FIXME + bInteresting = (m_pMyEnt->health < sMaxAmmo); + sAmmo = m_pMyEnt->health; + break; + case I_ARMOUR: + sMaxAmmo = itemstats[8].max; // FIXME + bInteresting = (m_pMyEnt->armour < sMaxAmmo); + sAmmo = m_pMyEnt->armour; + break; + }; + + if (!bInteresting) + continue; // Not an interesting item, skip + + // Score on ammo and need + if (sAmmo == -1) + { + // This entity doesn't have/need ammo + // Score on type instead + switch(e.type) + { // UNDONE + } + } + else + { + // Calculate current percentage of max ammo + float percent = ((float)sAmmo / (float)sMaxAmmo) * 100.0f; + if (percent > 100.0f) percent = 100.0f; + sScore += ((100 - short(percent))/2); + } + + flDist = GetDistance(o); + + if (flDist > flRange) continue; + + // Score on distance + float f = flDist; + if (f > 100.0f) f = 100.0f; + sScore += ((100 - short(f)) / 2); + + waypoint_s *pWptNearEnt = NULL; + // If this entity isn't visible check if there is a nearby waypoint + if (!IsReachable(o, flMaxHeight))//(!IsVisible(o)) + { + if (!pWptNearBot) continue; + +#ifdef WP_FLOOD + if (pWptNearBot->pNode->iFlags & W_FL_FLOOD) + pWptNearEnt = GetNearestFloodWP(o, 8.0f); + else +#endif + pWptNearEnt = GetNearestWaypoint(o, 15.0f); + + if (!pWptNearEnt) continue; + } + + // Score on visibility + if (pWptNearEnt == NULL) // Ent is visible + sScore += 30; + else + sScore += 15; + + if (sScore > sHighestScore) + { + // Found a valid wp near the bot and the ent,so...lets store it :) + if (pWptNearEnt) + pBestWpt = pWptNearEnt; + else + pBestWpt = NULL; // Best ent so far doesn't need any waypoints + + sHighestScore = sScore; + flNearestDist = flDist; + pNewTargetEnt = &ents[i]; + } + } + + if (pNewTargetEnt) + { + // Need waypoints to reach it? + if (pBestWpt) + { + ResetWaypointVars(); + SetCurrentWaypoint(pWptNearBot); + SetCurrentGoalWaypoint(pBestWpt); + } + + m_vGoal.x = pNewTargetEnt->x; + m_vGoal.y = pNewTargetEnt->y; + m_vGoal.z = S(pNewTargetEnt->x, pNewTargetEnt->y)->floor+player1->eyeheight; + } + + return pNewTargetEnt; +} + +bool CACBot::HeadToTargetEnt() +{ + if (m_pTargetEnt) + { + vec o = { m_pTargetEnt->x, m_pTargetEnt->y, + S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight }; + + if (m_pTargetEnt->spawned && (!UnderWater(m_pMyEnt->o) || + !UnderWater(o))) + { + bool bIsVisible = false; + if (m_pCurrentGoalWaypoint) + { + if ((GetDistance(o) <= 20.0f) && IsReachable(o, 1.0f)) + bIsVisible = true; + else if (HeadToGoal()) + { + //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); + //debugbeam(m_pMyEnt->o, + // m_pCurrentGoalWaypoint->pNode->v_origin); + AddDebugText("Using WPs for ents"); + return true; + } + } + else + bIsVisible = IsVisible(o); + + if (bIsVisible) + { + if (m_pCurrentWaypoint || m_pCurrentGoalWaypoint) + { + condebug("ent is now visible"); + ResetWaypointVars(); + } + + float flHeightDiff = o.z - m_pMyEnt->o.z; + bool bToHigh = false; + if (Get2DDistance(o) <= 2.0f) + { + if (flHeightDiff >= 1.5f) + { + if (flHeightDiff <= JUMP_HEIGHT) + { +#ifndef RELEASE_BUILD + char sz[64]; + sprintf(sz, "Ent z diff: %f", o.z-m_pMyEnt->o.z); + condebug(sz); +#endif + // Jump if close to ent and the ent is high + m_pMyEnt->jumpnext = true; + } + else + bToHigh = true; + } + } + + if (!bToHigh) + { + AimToVec(o); + return true; + } + } + } + } + + return false; +} + +bool CACBot::DoSPStuff() +{ + return false; +} + +// Code of CACBot - End + +#endif diff --git a/source/src/bot/bot.cpp b/source/src/bot/bot.cpp new file mode 100644 index 00000000..d5b819bc --- /dev/null +++ b/source/src/bot/bot.cpp @@ -0,0 +1,489 @@ +// +// C++ Implementation: bot +// +// Description: +// +// Contains code of the base bot class +// +// Author: Rick +// +// +// + +#include "../cube.h" + +dvector bots; + +extern vector sents; +extern int triggertime; +extern itemstat itemstats[]; +extern ENetHost *clienthost; + +const vec g_vecZero = {0,0,0}; + +//Bot class begin + +CBot::~CBot() +{ + // Delete all waypoints + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + while (m_WaypointList[i][j].Empty() == false) + delete m_WaypointList[i][j].Pop(); + } + } +} + +void CBot::Spawn() +{ + // Init all bot variabeles + m_pMyEnt->eyeheight = 4.5f; + m_pMyEnt->aboveeye = 0.7f; + m_pMyEnt->radius = 1.1f; + + spawnplayer(m_pMyEnt); + + m_pMyEnt->targetyaw = m_pMyEnt->yaw = m_pMyEnt->targetpitch = m_pMyEnt->pitch = 0.0f; + m_pMyEnt->move = 0; + m_pMyEnt->enemy = NULL; + m_pMyEnt->maxspeed = 22.0f; + m_pMyEnt->health = 100; + m_pMyEnt->armour = 0; + m_pMyEnt->pitch = 0; + m_pMyEnt->roll = 0; + m_pMyEnt->state = CS_ALIVE; + m_pMyEnt->anger = 0; + m_pMyEnt->pBot = this; + + m_eCurrentBotState = STATE_NORMAL; + m_iShootDelay = m_iChangeWeaponDelay = 0; + m_iCheckEnvDelay = 0; + m_vPrevOrigin = g_vecZero; + m_iStuckCheckDelay = lastmillis + 250; + m_bStuck = false; + m_iStuckTime = 0; + m_iStrafeTime = m_iStrafeCheckDelay = 0; + m_iMoveDir = DIR_NONE; + + m_pPrevEnemy = NULL; + m_iCombatNavTime = 0; + m_iSPMoveTime = 0; + m_iEnemySearchDelay = 0; + m_iSawEnemyTime = 0; + m_bCombatJump = false; + m_iCombatJumpDelay = 0; + m_bShootAtFeet = (RandomLong(1, 100) <= m_pBotSkill->sShootAtFeetWithRLPercent); + m_iHuntDelay = 0; + m_vHuntLocation = m_vPrevHuntLocation = g_vecZero; + m_pHuntTarget = NULL; + m_fPrevHuntDist = 0.0f; + m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0; + m_iLookAroundDelay = m_iLookAroundTime = m_iLookAroundUpdateTime = 0; + m_fLookAroundYaw = 0.0f; + m_bLookLeft = false; + + m_iLastJumpPad = 0; + m_pTargetEnt = NULL; + while(!m_UnreachableEnts.Empty()) delete m_UnreachableEnts.Pop(); + m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0; + m_iCheckEntsDelay = 0; + m_iCheckTriggersDelay = 0; + m_iLookForWaypointTime = 0; + + m_iAimDelay = 0; + m_fYawToTurn = m_fPitchToTurn = 0.0f; + + m_vGoal = m_vWaterGoal = g_vecZero; + + ResetWaypointVars(); +} + +void CBot::Think() +{ + if (intermission) + return; + + // Bot is dead? + if (m_pMyEnt->state == CS_DEAD) + { + if(lastmillis-m_pMyEnt->lastaction<1200) + { + m_pMyEnt->move = 0; + moveplayer(m_pMyEnt, 1, false); + } + else if (!m_arena && lastmillis-m_pMyEnt->lastaction>5000) + Spawn(); + + SendBotInfo(); + return; + } + + CheckItemPickup(); + + TLinkedList::node_s *p = m_UnreachableEnts.GetFirst(), *tmp; + while(p) + { + if ((lastmillis - p->Entry->time) > 3500) + { + tmp = p; + p = p->next; + delete tmp->Entry; + m_UnreachableEnts.DeleteNode(tmp); + continue; + } + p = p->next; + } + + if (!BotManager.IdleBots()) + { + MainAI(); + } + else + { + ResetMoveSpeed(); + } + + // Aim to ideal yaw and pitch + AimToIdeal(); + + // Store current location, to see if the bot is stuck + m_vPrevOrigin = m_pMyEnt->o; + + // Don't check for stuck if the bot doesn't want to move + if (!m_pMyEnt->move && !m_pMyEnt->strafe) + m_iStuckCheckDelay = max(m_iStuckCheckDelay, (lastmillis+100)); + + // Move the bot + moveplayer(m_pMyEnt, 1, false); + + // Update bot info on all clients + SendBotInfo(); +} + +void CBot::AimToVec(const vec &o) +{ + m_pMyEnt->targetpitch = atan2(o.z-m_pMyEnt->o.z, GetDistance(o))*180/PI; + m_pMyEnt->targetyaw = -(float)atan2(o.x - m_pMyEnt->o.x, o.y - + m_pMyEnt->o.y)/PI*180+180; +} + +void CBot::AimToIdeal() +{ + if (m_iAimDelay > lastmillis) + return; + + float MaxXSpeed = RandomFloat(m_pBotSkill->flMinAimXSpeed, + m_pBotSkill->flMaxAimXSpeed); + float MaxYSpeed = RandomFloat(m_pBotSkill->flMinAimYSpeed, + m_pBotSkill->flMaxAimYSpeed); + float XOffset = RandomFloat(m_pBotSkill->flMinAimXOffset, + m_pBotSkill->flMaxAimXOffset); + float YOffset = RandomFloat(m_pBotSkill->flMinAimYOffset, + m_pBotSkill->flMaxAimYOffset); + float RealXOffset, RealYOffset; + float AimXSpeed = MaxXSpeed, AimYSpeed = MaxYSpeed; + float XDiff = fabs(m_pMyEnt->targetpitch - m_pMyEnt->pitch); + float YDiff = fabs(m_pMyEnt->targetyaw - m_pMyEnt->yaw); + + // How higher the diff, how higher the offsets and aim speed + + if (XOffset) + { + if (RandomLong(0, 1)) + RealXOffset = XDiff * (XOffset / 100.0f); + else + RealXOffset = -(XDiff * (XOffset / 100.0f)); + } + else + RealXOffset = 0.0f; + + if (YOffset) + { + if (RandomLong(0, 1)) + RealYOffset = YDiff * (YOffset / 100.0f); + else + RealYOffset = -(YDiff * (YOffset / 100.0f)); + } + else + RealYOffset = 0.0f; + + + if (XDiff >= 1.0f) + AimXSpeed = (AimXSpeed * (XDiff / 80.0f)) + (AimXSpeed * 0.25f); + else + AimXSpeed *= 0.01f; + + if (YDiff >= 1.0f) + AimYSpeed = (AimYSpeed * (YDiff / 70.0f)) + (AimYSpeed * 0.25f); + else + AimYSpeed *= 0.015f; + + m_fPitchToTurn = fabs((m_pMyEnt->targetpitch + RealXOffset) - m_pMyEnt->pitch); + m_fYawToTurn = fabs((m_pMyEnt->targetyaw + RealYOffset) - m_pMyEnt->yaw); + + float flIdealPitch = ChangeAngle(AimXSpeed, m_pMyEnt->targetpitch + RealXOffset, m_pMyEnt->pitch); + float flIdealYaw = ChangeAngle(AimYSpeed, m_pMyEnt->targetyaw + RealYOffset, m_pMyEnt->yaw); + +// m_pMyEnt->pitch = WrapXAngle(m_pMyEnt->targetpitch); // Uncomment for instant aiming +// m_pMyEnt->yaw = WrapYZAngle(m_pMyEnt->targetyaw); + + m_pMyEnt->pitch = WrapXAngle(flIdealPitch); + m_pMyEnt->yaw = WrapYZAngle(flIdealYaw); +} + +// Function code by Botman +float CBot::ChangeAngle(float speed, float ideal, float current) +{ + float current_180; // current +/- 180 degrees + float diff; + + // find the difference in the current and ideal angle + diff = fabs(current - ideal); + + // speed that we can turn during this frame... + speed = speed * (float(BotManager.m_iFrameTime)/1000.0f); + + // check if difference is less than the max degrees per turn + if (diff < speed) + speed = diff; // just need to turn a little bit (less than max) + + // check if the bot is already facing the idealpitch direction... + if (diff <= 1.0f) + return ideal; + + if ((current >= 180) && (ideal >= 180)) + { + if (current > ideal) + current -= speed; + else + current += speed; + } + else if ((current >= 180) && (ideal < 180)) + { + current_180 = current - 180; + + if (current_180 > ideal) + current += speed; + else + current -= speed; + } + else if ((current < 180) && (ideal >= 180)) + { + current_180 = current + 180; + + if (current_180 > ideal) + current += speed; + else + current -= speed; + } + else // (current < 180) && (ideal < 180) + { + if (current > ideal) + current -= speed; + else + current += speed; + } + + + return current; +} + +void CBot::SendBotInfo() +{ + if(lastmillis-m_iLastBotUpdate<40) return; // don't update faster than 25fps + m_iLastBotUpdate = lastmillis; + + int x = (int)(m_pMyEnt->o.x*DMF); + int y = (int)(m_pMyEnt->o.y*DMF); + int z = (int)(m_pMyEnt->o.z*DMF); + int yaw = (int)(m_pMyEnt->yaw*DAF); + int pitch = (int)(m_pMyEnt->pitch*DAF); + int roll = (int)(m_pMyEnt->roll*DAF); + int velx = (int)(m_pMyEnt->vel.x*DVF); + int vely = (int)(m_pMyEnt->vel.y*DVF); + int velz = (int)(m_pMyEnt->vel.z*DVF); + // pack rest in 1 byte: strafe:2, move:2, onfloor:1, state:3 + int moveflags = (m_pMyEnt->strafe&3) | ((m_pMyEnt->move&3)<<2) | + (((int)m_pMyEnt->onfloor)<<4) | + ((editmode ? CS_EDITING : + m_pMyEnt->state)<<5); + + ENetPacket *packet = enet_packet_create(NULL, 100, 0); + ucharbuf p(packet->data, packet->dataLength); + + putint(p, SV_BOTUPDATE); + putint(p, BotManager.GetBotIndex(m_pMyEnt)); + putint(p, x); // quantize coordinates to 1/16th of a cube, between 1 and 3 bytes + putint(p, y); + putint(p, z); + putint(p, yaw); + putint(p, pitch); + putint(p, roll); + putint(p, velx); // quantize to 1/100, almost always 1 byte + putint(p, vely); + putint(p, velz); + // pack rest in 1 byte: strafe:2, move:2, onfloor:1, state:3 + putint(p, moveflags); + + enet_packet_resize(packet, p.length()); + incomingdemodata(0, p.buf, p.length(), true); + sendpackettoserv(0, packet); + + if(!m_bSendC2SInit) // tell other clients who I am + { + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, 0); + ucharbuf p(packet->data, packet->dataLength); + + packet->flags = ENET_PACKET_FLAG_RELIABLE; + m_bSendC2SInit = true; + putint(p, SV_ADDBOT); + putint(p, BotManager.GetBotIndex(m_pMyEnt)); + sendstring(m_pMyEnt->name, p); + sendstring(m_pMyEnt->team, p); + putint(p, m_pMyEnt->lifesequence); + + enet_packet_resize(packet, p.length()); + incomingdemodata(1, p.buf, p.length(), true); + sendpackettoserv(1, packet); + } +} + +float CBot::GetDistance(const vec &o) +{ + vdist(flDist, vecto, m_pMyEnt->o, o); + return flDist; +} + +float CBot::GetDistance(const vec &v1, const vec &v2) +{ + vdist(flDist, vecto, v1, v2); + return flDist; +} + +float CBot::GetDistance(entity *e) +{ + vec v = { e->x, e->y, e->z }; + vdist(flDist, vecto, m_pMyEnt->o, v); + return flDist; +} + +bool CBot::SelectGun(int Gun) +{ + if(m_pMyEnt->reloading) return false; + if (m_pMyEnt->gunselect != Gun) botplaysound(S_GUNCHANGE, m_pMyEnt); + m_pMyEnt->gunselect = Gun; + return true; +} + +bool CBot::IsVisible(entity *e, bool CheckPlayers) +{ + vec v = { e->x, e->y, e->z }; + return ::IsVisible(m_pMyEnt->o, v, (CheckPlayers) ? m_pMyEnt : NULL); +} + +bool CBot::IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist) +{ + static vec angles, end, forward, right, up; + static traceresult_s tr; + + end = o; + angles = GetViewAngles(); + angles.x = 0; + + if (Dir & UP) + angles.x = WrapXAngle(angles.x + 45.0f); + else if (Dir & DOWN) + angles.x = WrapXAngle(angles.x - 45.0f); + + if ((Dir & FORWARD) || (Dir & BACKWARD)) + { + if (Dir & BACKWARD) + angles.y = WrapYZAngle(angles.y + 180.0f); + + if (Dir & LEFT) + { + if (Dir & FORWARD) + angles.y = WrapYZAngle(angles.y - 45.0f); + else + angles.y = WrapYZAngle(angles.y + 45.0f); + } + else if (Dir & RIGHT) + { + if (Dir & FORWARD) + angles.y = WrapYZAngle(angles.y + 45.0f); + else + angles.y = WrapYZAngle(angles.y - 45.0f); + } + } + else if (Dir & LEFT) + angles.y = WrapYZAngle(angles.y - 90.0f); + else if (Dir & RIGHT) + angles.y = WrapYZAngle(angles.y + 90.0f); + else if (Dir & UP) + angles.x = WrapXAngle(angles.x + 90.0f); + else if (Dir & DOWN) + angles.x = WrapXAngle(angles.x - 90.0f); + + AnglesToVectors(angles, forward, right, up); + + vmul(forward, flDist); + vadd(end, forward); + + TraceLine(o, end, m_pMyEnt, CheckPlayers, &tr); + + if (pEndDist) + *pEndDist = GetDistance(o, tr.end); + + return !tr.collided; +} + +void CBot::SetMoveDir(int iMoveDir, bool add) +{ + if (iMoveDir & FORWARD) + m_pMyEnt->move = 1; + else if (m_iMoveDir & BACKWARD) + m_pMyEnt->move = -1; + else if (!add) + m_pMyEnt->move = 0; + + if (iMoveDir & LEFT) + m_pMyEnt->strafe = 1; + else if (m_iMoveDir & RIGHT) + m_pMyEnt->strafe = -1; + else if (!add) + m_pMyEnt->strafe = 0; + + if (iMoveDir & UP) + m_pMyEnt->jumpnext = true; +} + +// Used when switching to another task/state +void CBot::ResetCurrentTask() +{ + switch (m_eCurrentBotState) + { + case STATE_ENEMY: + m_pMyEnt->enemy = NULL; + m_pTargetEnt = NULL; + m_iCombatNavTime = m_iMoveDir = 0; + m_bCombatJump = false; + m_vGoal = g_vecZero; + break; + case STATE_ENT: + m_pTargetEnt = NULL; + m_vGoal = g_vecZero; + break; + case STATE_SP: + m_iSPMoveTime = m_iMoveDir = 0; + m_pTargetEnt = NULL; + m_vGoal = g_vecZero; + break; + case STATE_NORMAL: + m_iStrafeTime = m_iMoveDir = 0; + break; + } +} + +// Bot class end diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h new file mode 100644 index 00000000..feb0b1f3 --- /dev/null +++ b/source/src/bot/bot.h @@ -0,0 +1,431 @@ +// +// C++ Interface: bot +// +// Description: +// +// Main bot header +// +// +// Author: Rick +// +// +// + + +/* + + TODO list + + -bots that "cover" each other in team matches ? + -If a bot gets ammo it should ignore that kind of ammo for the next 10 seconds. ? + -bots should ignore players that are too far away ? + -bots should dodge/jump when shot at + -If the bot's only weapon is the fist it should make looking for ammo its priority - Done ? + -bots should rocket jump to get quads and the 150 armor if normal jumping doesn't + work (only if health is x so they don't suicide). + -Make all the "UNDONE's" done :) + -Finish waypoint navigation + -Make bot personalities + -More advanced enemy scoring + -Bots should less bump into walls + -(Better) Coop support + -Check for reachable instead of visible in GetNearestWaypoint + -Waypoint experience file + -Bots should avoid team mates + -Handle failed goals better(ie remember them) + -Test multiplayer + -Fix bots getting stuck in each other + -Optimize hunting code + -Check/Fix msg code +*/ + +#ifndef BOT_H +#define BOT_H + + +//#define RELEASE_BUILD // Set when you want to make a release build + + +// Set for which mod the code is + +//#define VANILLA_CUBE +#define AC_CUBE +//#define CUBE_X + +#include "bot_util.h" +#include "bot_waypoint.h" + +#ifdef __linux__ +#include +#else // Windows doesn't have syslog +#define openlog (void)0 +#define syslog (void)0 +#define closelog (void)0 +#endif + +extern bool dedserv; +extern itemstat itemstats[]; + +#ifdef RELEASE_BUILD +inline void condebug(const char *s, int a = 0, int b = 0, int c = 0) {}; +inline void debugnav(const char *s, int a = 0, int b = 0, int c = 0) {}; +inline void debugbeam(vec &s, vec &e) { }; +#else +inline void condebug(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ }; +inline void debugnav(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ }; +inline void debugbeam(vec &s, vec &e) { /*if (!dedserv) particle_trail(1, 500, s, e);*/ }; +#endif + +#define JUMP_HEIGHT 4.0f // NOT accurate + +#define FORWARD (1<<1) +#define BACKWARD (1<<2) +#define LEFT (1<<3) +#define RIGHT (1<<4) +#define UP (1<<5) +#define DOWN (1<<6) +#define DIR_NONE 0 + +//fixmebot +#define m_sp 1000 +#define m_classicsp 1000 + +enum EBotCommands // For voting of bot commands +{ + COMMAND_ADDBOT=0, + COMMAND_KICKBOT, + COMMAND_BOTSKILL +}; + +struct bot_skill_s +{ + float flMinReactionDelay; // Minimal reaction time + float flMaxReactionDelay; // Maximal reaction time + float flMinAimXSpeed; // Minimal X aim speed in degrees(base value) + float flMaxAimXSpeed; // Maximal X aim speed in degrees(base value) + float flMinAimYSpeed; // Minimal Y aim speed in degrees(base value) + float flMaxAimYSpeed; // Maximal Y aim speed in degrees(base value) + float flMinAimXOffset; // Minimal X aim offset in degrees(base value) + float flMaxAimXOffset; // Maximal X aim offset in degrees(base value) + float flMinAimYOffset; // Minimal Y aim offset in degrees(base value) + float flMaxAimYOffset; // Maximal Y aim offset in degrees(base value) + float flMinAttackDelay; // Minimal delay for when a bot can attack again + float flMaxAttackDelay; // Maximal delay for when a bot can attack again + float flMinEnemySearchDelay; // Minimal delay for when a bot can search for an + // enemy again + float flMaxEnemySearchDelay; // Maximal delay for when a bot can search for an + // enemy again + short sShootAtFeetWithRLPercent; // Percent that a bot shoot with a rocket + // launcher at the enemy feet. + int iMaxHearVolume; // Max volume that bot can hear + bool bCanPredict; // Can this bot predict his enemy position? + bool bCircleStrafe; // Can this bot circle strafe? + bool bCanSearchItemsInCombat; +}; + +enum EBotWeaponTypes +{ + TYPE_MELEE, // Fist, knife etc + TYPE_NORMAL, // Normal weapon, distance doesn't really matter(ie pistol) + TYPE_SHOTGUN, + TYPE_ROCKET, + TYPE_SNIPER, // Rifle, sniper etc + TYPE_GRENADE, + TYPE_AUTO // Chain gun, machine gun etc +}; + +struct weaponinfo_s +{ + EBotWeaponTypes eWeaponType; + float flMinDesiredDistance; + float flMaxDesiredDistance; + float flMinFireDistance; + float flMaxFireDistance; + short sMinDesiredAmmo; +}; + +enum ECurrentBotState +{ + STATE_ENEMY, // Bot has an enemy + STATE_HUNT, // Bot is hunting an enemy + STATE_ENT, // Bot is heading to an entity + STATE_SP, // Bot is doing sp specific stuff + STATE_NORMAL // Bot is doing normal navigation +}; + +struct unreachable_ent_s +{ + entity *ent; + int time; + + unreachable_ent_s(entity *e, int t) : ent(e), time(t) { }; +}; + +class CBot +{ +public: + dynent *m_pMyEnt; + int m_iLastBotUpdate; + + // Combat variabels + dynent *m_pPrevEnemy; + int m_iShootDelay; + int m_iChangeWeaponDelay; + int m_iCombatNavTime; + int m_iEnemySearchDelay; + int m_iSawEnemyTime; + bool m_bCombatJump; + float m_iCombatJumpDelay; + bool m_bShootAtFeet; + + // Hunting variabeles + int m_iHuntDelay; + vec m_vHuntLocation, m_vPrevHuntLocation; + dynent *m_pHuntTarget; + float m_fPrevHuntDist; + int m_iHuntPauseTime, m_iHuntPlayerUpdateTime, m_iHuntLastTurnLessTime; + int m_iLookAroundDelay, m_iLookAroundTime, m_iLookAroundUpdateTime; + float m_fLookAroundYaw; + bool m_bLookLeft; + + // Navigation variabeles + int m_iCheckEnvDelay; + int m_iLastJumpPad; + vec m_vPrevOrigin; + float m_iStuckCheckDelay; + bool m_bStuck; + int m_iStuckTime; + int m_iStrafeTime; + int m_iStrafeCheckDelay; + int m_iMoveDir; + int m_iSPMoveTime; + bool m_bCalculatingAStarPath; + TLinkedList m_AStarNodeList; + TPriorList m_AStarOpenList[2]; + TLinkedList m_AStarClosedList[2]; + vec m_vWaterGoal; // Place to go to when underwater + + // Waypoint variabeles + TLinkedList m_WaypointList[MAX_MAP_GRIDS][MAX_MAP_GRIDS]; + float m_iWaypointTime; + waypoint_s *m_pCurrentWaypoint; + waypoint_s *m_pCurrentGoalWaypoint; + vec m_vGoal; + waypoint_s *m_pPrevWaypoints[5]; + int m_iRandomWaypointTime; + float m_fPrevWaypointDistance; + int m_iLookForWaypointTime; + int m_iWaypointHeadLastTurnLessTime; // Last time the didn't had to turn much wile + // heading to a WP + int m_iWaypointHeadPauseTime; // Pause time to give the bot time to aim. + bool m_bGoToDebugGoal; + + // Misc stuff + ECurrentBotState m_eCurrentBotState; + entity *m_pTargetEnt; + TLinkedList m_UnreachableEnts; + int m_iCheckTeleporterDelay; + int m_iCheckJumppadsDelay; + int m_iCheckEntsDelay; + int m_iCheckTriggersDelay; + int m_iAimDelay; + float m_fYawToTurn, m_fPitchToTurn; + bot_skill_s *m_pBotSkill; // Pointer to current bot skill + short m_sSkillNr; // Skill number, 0 == best 4 == worst + + void AimToVec(const vec &o); + void AimToIdeal(void); + float ChangeAngle(float speed, float ideal, float current); + bool SelectGun(int Gun); + virtual void CheckItemPickup(void) = 0; + virtual void PickUp(int n) = 0; + virtual void AddItem(int i, int &v, int spawnsec, int t) = 0; + virtual void BotPain(int damage, dynent *d, bool gib=false) = 0; + void SendBotInfo(void); + float GetDistance(const vec &o); + float GetDistance(const vec &v1, const vec &v2); + float GetDistance(entity *e); + float Get2DDistance(const vec &v) { return ::Get2DDistance(m_pMyEnt->o, v); }; + vec GetViewAngles(void) { vec temp = { m_pMyEnt->pitch, m_pMyEnt->yaw, + m_pMyEnt->roll }; return temp; }; + void ResetMoveSpeed(void) { m_pMyEnt->move = m_pMyEnt->strafe = 0; }; + void SetMoveDir(int iMoveDir, bool add); + void ResetCurrentTask(); + + // AI Functions + bool FindEnemy(void); + void CheckReload(void); + void ShootEnemy(void); + bool CheckHunt(void); + bool HuntEnemy(void); + void DoCombatNav(void); + void MainAI(void); + bool CheckStuck(void); + bool CheckJump(void); + bool CheckStrafe(void); + void CheckFOV(void); + bool IsVisible(const vec &o, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, o, + (CheckPlayers) ? m_pMyEnt : + NULL); }; + bool IsVisible(dynent *d, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, d->o, + (CheckPlayers) ? + m_pMyEnt : NULL); }; + bool IsVisible(entity *e, bool CheckPlayers = false); + bool IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist = NULL); + bool IsVisible(int Dir, float flDist, bool CheckPlayers) + { return IsVisible(m_pMyEnt->o, Dir, flDist, CheckPlayers); }; + bool IsInFOV(const vec &o); + bool IsInFOV(dynent *d) { return IsInFOV(d->o); }; + int GetShootDelay(void); + virtual bool ChoosePreferredWeapon(void); + virtual entity *SearchForEnts(bool bUseWPs, float flRange=9999.0f, + float flMaxHeight=JUMP_HEIGHT) = NULL; + virtual bool HeadToTargetEnt(void) = 0; + bool CheckItems(void); + bool InUnreachableList(entity *e); + virtual bool DoSPStuff(void) = 0; + vec GetEnemyPos(dynent *d); + bool AStar(void); + float AStarCost(waypoint_s *pWP1, waypoint_s *pWP2); + void CleanAStarLists(bool bPathFailed); + bool IsReachable(vec to, float flMaxHeight=JUMP_HEIGHT); + bool WaterNav(void); + void HearSound(int n, vec *o); + + // Waypoint functions + bool HeadToWaypoint(void); + bool FindWaypoint(void); + void ResetWaypointVars(void); + void SetCurrentWaypoint(node_s *pWP); + void SetCurrentWaypoint(waypoint_s *pWP); + void SetCurrentGoalWaypoint(node_s *pNode); + void SetCurrentGoalWaypoint(waypoint_s *pWP); + bool CurrentWPIsValid(void); + bool ReachedGoalWP(void); + bool HeadToGoal(void); + waypoint_s *GetWPFromNode(node_s *pNode); + waypoint_s *GetNearestWaypoint(vec v_src, float flRange); + waypoint_s *GetNearestWaypoint(float flRange) { return GetNearestWaypoint(m_pMyEnt->o, flRange); }; + waypoint_s *GetNearestTriggerWaypoint(vec v_src, float flRange); +#ifdef WP_FLOOD + waypoint_s *GetNearestFloodWP(vec v_origin, float flRange); + waypoint_s *GetNearestFloodWP(float flRange) { return GetNearestFloodWP(m_pMyEnt->o, flRange); }; + waypoint_s *GetNearestTriggerFloodWP(vec v_origin, float flRange); +#endif + void SyncWaypoints(void); + + friend class CBotManager; + friend class CWaypointClass; + + bool m_bSendC2SInit; + + virtual ~CBot(void); + + virtual void Spawn(void); + virtual void Think(void); + void GoToDebugGoal(vec o); +}; + +class CStoredBot; + +extern dvector bots; + +class CBotManager +{ + char m_szBotNames[150][16]; // Max 150 bot names with a length of 16 characters + short m_sBotNameCount; + char m_szBotTeams[20][5]; // Max 100 bot teams co a length of 5 characters + short m_sBotTeamCount; + bool m_bInit; + bool m_bBotsShoot; + bool m_bIdleBots; + bot_skill_s m_BotSkills[5]; // 5 different bot skills, 0 = best 4 = worst + int m_iFrameTime; + int m_iPrevTime; + short m_sBotSkill; // Bad - Worse - Medium - Good - Best + short m_sMaxAStarBots; // Max bots that can use a* at the same time + short m_sUsingAStarBotsCount; // Number of bots that are using a* + short m_sCurrentTriggerNr; // Current waypoint trigger bots should use + TLinkedList m_StoredBots; // List of bots that should be re-added after map change + float m_fReAddBotDelay; + + void LoadBotNamesFile(void); + char *GetBotName(void); + void LoadBotTeamsFile(void); + char *GetBotTeam(void); + void CreateSkillData(void); + void InitSkillData(void); + void InitBotItems(void); + + friend class CBot; + friend class CCubeBot; + friend class CACBot; + friend class CWaypointClass; + +public: + dynent *m_pBotToView; + + // Construction + CBotManager(void) { m_bInit = true; m_fReAddBotDelay = -1.0f; }; + + // Destruction + ~CBotManager(void); + + void Init(void); + void Think(void); + void RenderBots(void); + void RenderBotScore(void) { loopv(bots) if(bots[i]) renderscore(bots[i]); } + void AddBotTeamScore(void) { loopv(bots) addteamscore(bots[i]); }; + void RespawnBots(void) { loopv(bots) if (bots[i] && bots[i]->pBot) bots[i]->pBot->Spawn(); }; + void EndMap(void); + void BeginMap(char *szMapName); + int GetBotIndex(dynent *m); + void LetBotsUpdateStats(void); + void LetBotsHear(int n, vec *loc); + void AddWaypoint(node_s *pNode); + void DelWaypoint(node_s *pNode); + bool BotsShoot(void) { return m_bBotsShoot; }; + bool IdleBots(void) { return m_bIdleBots; }; + void SetBotsShoot(bool bShoot) { m_bBotsShoot = bShoot; }; + void SetIdleBots(bool bIdle) { m_bIdleBots = bIdle; }; + void EnableBotView(dynent *bot) { m_pBotToView = bot; }; + void DisableBotView(void); + void ChangeBotSkill(short Skill, dynent *bot = NULL); + dynent *CreateBot(const char *team, const char *skill, const char *name); + void ViewBot(void); + void CalculateMaxAStarCount(void); + void PickNextTrigger(void); + + void MakeBotFileName(const char *szFileName, const char *szDir1, const char *szDir2, + char *szOutput); +}; + +#if defined VANILLA_CUBE +#include "cube_bot.h" +#elif defined AC_CUBE +#include "ac_bot.h" +#endif + +extern CBotManager BotManager; +extern const vec g_vecZero; + +#if defined AC_CUBE +extern CACWaypointClass WaypointClass; +#elif defined VANILLA_CUBE +extern CCubeWaypointClass WaypointClass; +#endif + +class CStoredBot // Used to store bots after mapchange, so that they can be readded +{ + char m_szName[32]; + char m_szTeam[32]; + short m_sSkillNr; + +public: + + CStoredBot(const char *name, const char *team, const short skill) : m_sSkillNr(skill) + { strcpy(m_szName, name); strcpy(m_szTeam, team); }; + void ReAddBot(void) { BotManager.CreateBot(m_szTeam, SkillNrToSkillName(m_sSkillNr), m_szName); }; +}; + +#endif diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp new file mode 100644 index 00000000..28ce2100 --- /dev/null +++ b/source/src/bot/bot_ai.cpp @@ -0,0 +1,2306 @@ +// +// C++ Implementation: bot_ai +// +// Description: The AI part comes here(navigation, shooting etc) +// +// +// Author: +// + + +// Code of CBot - Start + +#include "../cube.h" + +extern vector sents; +extern vector monsters; + +extern weaponinfo_s WeaponInfoTable[MAX_WEAPONS]; + +vec CBot::GetEnemyPos(dynent *d) +{ + // Aim offset idea by botman + vec o = d->o, offset; + float flDist = GetDistance(d->o), flScale; + + if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_ROCKET) + { + // Bot is using a rocket launcher, aim at enemy feet? + if (m_bShootAtFeet && !OUTBORD(d->o.x, d->o.y)) + { + // Only do this when enemy is fairly close to the ground + vec end = o; + end.z -= 900.0f; + traceresult_s tr; + TraceLine(o, end, NULL, false, &tr); + if ((o.z - tr.end.z) < 8.0f) + { + end = o; + end.z = tr.end.z; + if (IsVisible(end)) + { + // Target at ground + o.z = tr.end.z; + } + } + } + + if (m_pBotSkill->bCanPredict) + { + // How higher the skill, how further the bot predicts + vec org = o; + float flPredictTime = RandomFloat(1.25f, 1.7f) / (m_sSkillNr+1); + o = PredictPos(o, d->vel, flPredictTime); + } + } + else + { + if (m_pBotSkill->bCanPredict) + { + // How higher the skill, how 'more' the bot predicts + vec org = o; + float flPredictTime = RandomFloat(0.8f, 1.2f) / (m_sSkillNr+1); + o = PredictPos(o, d->vel, flPredictTime); + } + } + + if (flDist > 60.0f) + flScale = 1.0; + else if (flDist > 6.0f) + flScale = flDist / 60.0; + else + flScale = 0.1; + + switch (m_sSkillNr) + { + case 0: + // no offset + offset.x = 0; + offset.y = 0; + offset.z = 0; + break; + case 1: + // GOOD, offset a little for x, y, and z + offset.x = RandomFloat(-3, 3) * flScale; + offset.y = RandomFloat(-3, 3) * flScale; + offset.z = RandomFloat(-6, 6) * flScale; + break; + case 2: + // FAIR, offset somewhat for x, y, and z + offset.x = RandomFloat(-8, 8) * flScale; + offset.y = RandomFloat(-8, 8) * flScale; + offset.z = RandomFloat(-12, 12) * flScale; + break; + case 3: + // POOR, offset for x, y, and z + offset.x = RandomFloat(-15, 15) * flScale; + offset.y = RandomFloat(-15, 15) * flScale; + offset.z = RandomFloat(-25, 25) * flScale; + break; + case 4: + // BAD, offset lots for x, y, and z + offset.x = RandomFloat(-20, 20) * flScale; + offset.y = RandomFloat(-20, 20) * flScale; + offset.z = RandomFloat(-35, 35) * flScale; + break; + } + + vadd(o, offset); + return o; +} + +bool CBot::FindEnemy(void) +{ + // UNDONE: Enemies are now only scored on their distance + + if (m_pMyEnt->enemy) // Bot already has an enemy + { + // Check if the enemy is still in game + bool found = IsInGame(m_pMyEnt->enemy); + + // Check if the enemy is still ingame, still alive, not joined my team and is visible + if (found && !isteam(m_pMyEnt->team, m_pMyEnt->enemy->team)) + { + if ((m_pMyEnt->enemy->state == CS_ALIVE) && (IsVisible(m_pMyEnt->enemy))) + return true; + else + m_pPrevEnemy = m_pMyEnt->enemy; + } + else + m_pMyEnt->enemy = NULL; + } + + if (m_iEnemySearchDelay > lastmillis) return (m_pMyEnt->enemy!=NULL); + + m_pMyEnt->enemy = NULL; + + // Add enemy searchy delay + float MinDelay = m_pBotSkill->flMinEnemySearchDelay; + float MaxDelay = m_pBotSkill->flMaxEnemySearchDelay; + m_iEnemySearchDelay = lastmillis + int(RandomFloat(MinDelay, MaxDelay) * 1000.0f); + + dynent *pNewEnemy = NULL, *d = NULL; + float flDist, flNearestDist = 99999.9f; + short EnemyVal, BestEnemyVal = -100; + + // search for only for monsters when SP mode + /* no more sp as such -argh (sorry bout messy commenting) + if (m_sp) + { + loopv(monsters) + { + d = monsters[i]; // Handy shortcut + + if (d->state != CS_ALIVE) + continue; + + // Check if the enemy is visible + if(!IsInFOV(d) || !IsVisible(d)) + continue; + + flDist = GetDistance(d->o); + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (EnemyVal > BestEnemyVal) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + } + } + } */ + + //else + //{ + + // First loop through all players + loopv(players) + { + d = players[i]; // Handy shortcut + + if (!d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) + continue; + + // Check if the enemy is visible + if(!IsInFOV(d) || !IsVisible(d)) + continue; + + flDist = GetDistance(d->o); + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (EnemyVal > BestEnemyVal) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + } + } + + // Then loop through all bots + loopv(bots) + { + d = bots[i]; // Handy shortcut + + if (d == m_pMyEnt) + continue; + + if (!d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) + continue; + + // Check if the enemy is visible + if(!IsInFOV(d) || !IsVisible(d)) + continue; + + flDist = GetDistance(d->o); + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (EnemyVal > BestEnemyVal) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + } + } + + // Then examine the local player + if (player1 && !isteam(player1->team, m_pMyEnt->team) && + (player1->state == CS_ALIVE)) + { + // Check if the enemy is visible + if(IsInFOV(player1) && IsVisible(player1)) + { + flDist = GetDistance(player1->o); + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (EnemyVal > BestEnemyVal) + { + pNewEnemy = player1; + BestEnemyVal = EnemyVal; + } + } + } + //} + + if (pNewEnemy) + { + if (!m_pMyEnt->enemy) // Add shoot delay if new enemy is found + { + float flMinShootDelay = m_pBotSkill->flMinAttackDelay; + float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; + + m_iShootDelay = lastmillis + int(RandomFloat(flMinShootDelay, + flMaxShootDelay) * 1000.0f); + } + + if ((m_pMyEnt->enemy != pNewEnemy) && m_pMyEnt->enemy) + m_pPrevEnemy = m_pMyEnt->enemy; + + m_pMyEnt->enemy = pNewEnemy; + return true; + } + + return false; +} + +bool CBot::CheckHunt(void) +{ + if (!BotManager.BotsShoot()) return false; + + if (m_pHuntTarget) // Bot already has an enemy to hunt + { + // Check if the enemy is still in game + bool found = IsInGame(m_pHuntTarget); + + // Check if the enemy is still ingame, still alive, not joined my team and is visible + if (found && !isteam(m_pMyEnt->team, m_pHuntTarget->team)) + { + if ((m_pHuntTarget->state == CS_ALIVE) && IsReachable(m_vHuntLocation)) + return true; + } + else + m_pHuntTarget = NULL; + } + + if (m_iHuntDelay > lastmillis) return (m_pHuntTarget!=NULL); + + if (!vis(m_vHuntLocation, g_vecZero)) + m_vPrevHuntLocation = m_vHuntLocation; + + m_pHuntTarget = NULL; + m_vHuntLocation = g_vecZero; + + // Add enemy hunt search delay + m_iHuntDelay = lastmillis + 1500; + + dynent *pNewEnemy = NULL, *d = NULL; + float flDist, flNearestDist = 99999.9f, flNearestOldPosDistToEnemy = 99999.9f; + float flNearestOldPosDistToBot = 99999.9f; + short EnemyVal, BestEnemyVal = -100; + vec BestOldPos; + + // search for only for monsters when SP mode + //edit -argh + /*if (m_sp) + { + loopv(monsters) + { + d = monsters[i]; // Handy shortcut + + if (d->state != CS_ALIVE) + continue; + + flDist = GetDistance(d->o); + + if (flDist > 250.0f) continue; + + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (d == m_pPrevEnemy) + EnemyVal+=2; + + if (EnemyVal < BestEnemyVal) continue; + + vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; + flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; + + // Check previous locations of enemy + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(d->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = d->PrevLocations.prevloc[j]; + + flDist = GetDistance(d->o, v); + + if ((flDist < flNearestOldPosDistToBot) && IsReachable(v)) + { + flNearestOldPosDistToEnemy = flDist; + bestfromenemy = v; + } + } + + // Check previous locations of bot hisself + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(m_pMyEnt->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = m_pMyEnt->PrevLocations.prevloc[j]; + + flDist = GetDistance(v); + + if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && + IsReachable(v)) + { + flNearestOldPosDistToBot = flDist; + bestfrombot = v; + } + } + + if (!vis(bestfromenemy, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfromenemy; + } + else if (!vis(bestfrombot, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfrombot; + } + } + } */ + //else + //{ + // First loop through all players + loopv(players) + { + d = players[i]; // Handy shortcut + + if (!d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) + continue; + + flDist = GetDistance(d->o); + + if (flDist > 250.0f) continue; + + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (d == m_pPrevEnemy) + EnemyVal+=2; + + if (EnemyVal < BestEnemyVal) continue; + + vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; + flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; + + // Check previous locations of enemy + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(d->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = d->PrevLocations.prevloc[j]; + + flDist = GetDistance(d->o, v); + + if ((flDist < flNearestOldPosDistToEnemy) && IsReachable(v)) + { + flNearestOldPosDistToEnemy = flDist; + bestfromenemy = v; + } + } + + // Check previous locations of bot hisself + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(m_pMyEnt->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = m_pMyEnt->PrevLocations.prevloc[j]; + + flDist = GetDistance(v); + + if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && + IsReachable(v)) + { + flNearestOldPosDistToBot = flDist; + bestfrombot = v; + } + } + + if (!vis(bestfromenemy, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfromenemy; + } + else if (!vis(bestfrombot, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfrombot; + } + //} + + // Then loop through all bots + loopv(bots) + { + d = bots[i]; // Handy shortcut + + if (d == m_pMyEnt) + continue; + + if (!d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) + continue; + + flDist = GetDistance(d->o); + + if (flDist > 250.0f) continue; + + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (d == m_pPrevEnemy) + EnemyVal+=2; + + if (EnemyVal < BestEnemyVal) continue; + + vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; + flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; + + // Check previous locations of enemy + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(d->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = d->PrevLocations.prevloc[j]; + + flDist = GetDistance(d->o, v); + + if ((flDist < flNearestOldPosDistToEnemy) && IsReachable(v)) + { + flNearestOldPosDistToEnemy = flDist; + bestfromenemy = v; + } + } + + // Check previous locations of bot hisself + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(m_pMyEnt->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = m_pMyEnt->PrevLocations.prevloc[j]; + + flDist = GetDistance(v); + + if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && + IsReachable(v)) + { + flNearestOldPosDistToBot = flDist; + bestfrombot = v; + } + } + + if (!vis(bestfromenemy, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfromenemy; + } + else if (!vis(bestfrombot, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfrombot; + } + } + + // Then examine the local player + if (player1 && !isteam(player1->team, m_pMyEnt->team) && + (player1->state == CS_ALIVE) && ((flDist = GetDistance(player1->o)) <= 250.0f)) + { + d = player1; + EnemyVal = 1; + + if (flDist < flNearestDist) + { + EnemyVal+=2; + flNearestDist = flDist; + } + + if (d == m_pPrevEnemy) + EnemyVal+=2; + + if (EnemyVal >= BestEnemyVal) + { + BestEnemyVal = EnemyVal; + vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; + flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; + + // Check previous locations of enemy + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(d->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = d->PrevLocations.prevloc[j]; + + flDist = GetDistance(d->o, v); + + if ((flDist < flNearestOldPosDistToEnemy) && IsReachable(v)) + { + flNearestOldPosDistToEnemy = flDist; + bestfromenemy = v; + } + } + + // Check previous locations of bot hisself + for (int j=0;jPrevLocations.prevloc[j], m_vPrevHuntLocation)) continue; + if (vis(m_pMyEnt->PrevLocations.prevloc[j], g_vecZero)) continue; + + vec v = m_pMyEnt->PrevLocations.prevloc[j]; + + flDist = GetDistance(v); + + if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && + IsReachable(v)) + { + flNearestOldPosDistToBot = flDist; + bestfrombot = v; + } + } + + if (!vis(bestfromenemy, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfromenemy; + } + else if (!vis(bestfrombot, g_vecZero)) + { + pNewEnemy = d; + BestEnemyVal = EnemyVal; + BestOldPos = bestfrombot; + } + } + } + } + + if (pNewEnemy) + { + if (!m_pHuntTarget) // Add shoot delay if new enemy is found + { + float flMinShootDelay = m_pBotSkill->flMinAttackDelay; + float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; + + m_iShootDelay = lastmillis + int(RandomFloat(flMinShootDelay, + flMaxShootDelay) * 1000.0f); + } + + if (!vis(m_vHuntLocation, g_vecZero)) + m_vPrevHuntLocation = m_vHuntLocation; + + m_pHuntTarget = pNewEnemy; + m_vHuntLocation = BestOldPos; + m_fPrevHuntDist = 0.0f; + return true; + } + + return false; +} + +bool CBot::HuntEnemy(void) +{ + if (m_iCombatNavTime > lastmillis) + { + SetMoveDir(m_iMoveDir, false); + return true; + } + + m_iCombatNavTime = m_iMoveDir = 0; + + bool bDone = false, bNew = false; + float flDist = GetDistance(m_vHuntLocation); + + if (flDist <= 3.0f) + bDone = true; + + if ((m_fPrevHuntDist > 0.0) && (flDist > m_fPrevHuntDist)) + bDone = true; + + m_fPrevHuntDist = flDist; + + if ((m_iHuntPlayerUpdateTime < lastmillis) || bDone) + { + m_iHuntPlayerUpdateTime = lastmillis + 1250; + + short BestPosIndexFromEnemy = -1, BestPosIndexFromBot = -1, j; + float NearestDistToEnemy = 9999.9f, NearestDistToBot = 9999.9f; + + // Check previous locations of enemy + for (j=0;jPrevLocations.prevloc[j]; + + if (bDone && vis(m_vHuntLocation, OldPos)) + continue; + + if (vis(OldPos, g_vecZero)) + continue; + + if (GetDistance(OldPos) > 250.0f) + continue; + + flDist = GetDistance(m_pHuntTarget->o, OldPos); + + if ((flDist < NearestDistToEnemy) && (IsReachable(OldPos))) + { + NearestDistToEnemy = flDist; + BestPosIndexFromEnemy = j; + break; + } + } + + // Check previous locations of bot + for (j=0;jPrevLocations.prevloc[j]; + + if (bDone && vis(m_vHuntLocation, OldPos)) + continue; + + if (vis(OldPos, g_vecZero)) + continue; + + if (GetDistance(OldPos) > 25.0f) + continue; + + flDist = GetDistance(OldPos); + + if ((flDist < NearestDistToBot) && ::IsVisible(m_pHuntTarget->o, OldPos) && + (IsReachable(OldPos))) + { + NearestDistToBot = flDist; + BestPosIndexFromBot = j; + break; + } + } + + if (BestPosIndexFromEnemy > -1) + { + m_vPrevHuntLocation = m_vHuntLocation; + m_vHuntLocation = m_pHuntTarget->PrevLocations.prevloc[BestPosIndexFromEnemy]; + bNew = true; + m_fPrevHuntDist = 0.0f; + } + else if (BestPosIndexFromBot > -1) + { + m_vPrevHuntLocation = m_vHuntLocation; + m_vHuntLocation = m_pMyEnt->PrevLocations.prevloc[BestPosIndexFromBot]; + bNew = true; + m_fPrevHuntDist = 0.0f; + } + } + + if (!bNew) // Check if current location is still reachable + { + if (bDone || !IsReachable(m_vHuntLocation)) + { + m_pHuntTarget = NULL; + m_vPrevHuntLocation = m_vHuntLocation; + m_vHuntLocation = g_vecZero; + m_fPrevHuntDist = 0.0f; + m_iHuntDelay = lastmillis + 3500; + return false; + } + } + else + condebug("New hunt pos"); + + // Aim to position + //AimToVec(m_vHuntLocation); + + int iMoveDir = GetDirection(GetViewAngles(), m_pMyEnt->o, m_vHuntLocation); + + if (iMoveDir != DIR_NONE) + { + m_iMoveDir = iMoveDir; + m_iCombatNavTime = lastmillis + 125; + } + + bool aimtopos = true; + + if ((lastmillis - m_iSawEnemyTime) > 1500) + { + if (m_iLookAroundDelay < lastmillis) + { + if (m_iLookAroundTime > lastmillis) + { + if (m_iLookAroundUpdateTime < lastmillis) + { + float flAddAngle; + if (m_bLookLeft) flAddAngle = RandomFloat(-110, -80); + else flAddAngle = RandomFloat(80, 110); + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->targetyaw + flAddAngle); + m_iLookAroundUpdateTime = lastmillis + RandomLong(400, 800); + } + aimtopos = false; + } + else if (m_iLookAroundTime > 0) + { + m_iLookAroundTime = 0; + m_iLookAroundDelay = lastmillis + RandomLong(750, 1000); + } + else + m_iLookAroundTime = lastmillis + RandomLong(2200, 3200); + } + } + + if (aimtopos) + AimToVec(m_vHuntLocation); + + debugbeam(m_pMyEnt->o, m_vHuntLocation); + + if (m_fYawToTurn <= 25.0f) + m_iHuntLastTurnLessTime = lastmillis; + + // Bot had to turn much for a while? + if ((m_iHuntLastTurnLessTime > 0) && (m_iHuntLastTurnLessTime < (lastmillis - 1000))) + { + m_iHuntPauseTime = lastmillis + 200; + } + + if (m_iHuntPauseTime >= lastmillis) + { + m_pMyEnt->move = 0; + m_fPrevHuntDist = 0.0f; + } + else + { + // Check if bot has to jump over a wall... + if (CheckJump()) + m_pMyEnt->jumpnext = true; + else // Check if bot has to jump to reach this location + { + float flHeightDiff = m_vHuntLocation.z - m_pMyEnt->o.z; + bool bToHigh = false; + if (Get2DDistance(m_vHuntLocation) <= 2.0f) + { + if (flHeightDiff >= 1.5f) + { + if (flHeightDiff <= JUMP_HEIGHT) + { +#ifndef RELEASE_BUILD + char sz[64]; + sprintf(sz, "OldPos z diff: %f", m_vHuntLocation.z-m_pMyEnt->o.z); + condebug(sz); +#endif + // Jump if close to pos and the pos is high + m_pMyEnt->jumpnext = true; + } + else + bToHigh = true; + } + } + + if (bToHigh) + { + m_pHuntTarget = NULL; + m_vPrevHuntLocation = m_vHuntLocation; + m_vHuntLocation = g_vecZero; + m_fPrevHuntDist = 0.0f; + m_iHuntDelay = lastmillis + 3500; + return false; + } + } + } + + return true; +} + +void CBot::ShootEnemy() +{ + if(!m_pMyEnt->enemy) return; + + m_iSawEnemyTime = lastmillis; + + // Aim to enemy + vec enemypos = GetEnemyPos(m_pMyEnt->enemy); + AimToVec(enemypos); + + // Time to shoot? + if (m_iShootDelay < lastmillis) + //if ((lastmillis-m_pMyEnt->lastaction) >= m_pMyEnt->gunwait) + { + if (m_pMyEnt->mag[m_pMyEnt->gunselect]) + { + // If the bot is using a sniper only shoot if crosshair is near the enemy + if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_SNIPER) + { + float yawtoturn = fabs(WrapYZAngle(m_pMyEnt->yaw - m_pMyEnt->targetyaw)); + float pitchtoturn = fabs(WrapYZAngle(m_pMyEnt->pitch - m_pMyEnt->targetpitch)); + + if ((yawtoturn > 5) || (pitchtoturn > 15)) // UNDONE: Should be skill based + return; + } + + float flDist = GetDistance(enemypos); + + // Check if bot is in fire range + if ((flDist < WeaponInfoTable[m_pMyEnt->gunselect].flMinFireDistance) || + (flDist > WeaponInfoTable[m_pMyEnt->gunselect].flMaxFireDistance)) + return; + + // Now shoot! + m_pMyEnt->attacking = true; + + // Get the position the bot is aiming at + vec forward, right, up, dest; + traceresult_s tr; + + AnglesToVectors(GetViewAngles(), forward, right, up); + + dest = m_pMyEnt->o; + vmul(forward, 1000); + vadd(dest, forward); + + TraceLine(m_pMyEnt->o, dest, m_pMyEnt, false, &tr); + debugbeam(m_pMyEnt->o, tr.end); + + // Shoot + shoot(m_pMyEnt, tr.end); + + // Add shoot delay + m_iShootDelay = lastmillis + GetShootDelay(); + } + ChoosePreferredWeapon(); + } +#ifndef RELEASE_BUILD + else + { + char sz[64]; + sprintf(sz, "shootdelay: %d\n", (m_iShootDelay-lastmillis)); + AddDebugText(sz); + } +#endif +} + +bool CBot::ChoosePreferredWeapon() +{ + TMultiChoice WeaponChoices; + short sWeaponScore; + float flDist = GetDistance(m_pMyEnt->enemy->o); + + if ((m_iChangeWeaponDelay > lastmillis) && (m_pMyEnt->ammo[m_pMyEnt->gunselect])) + { + if ((WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType != TYPE_MELEE) || (flDist <= 3.5f)) + return true; + } + + // Choose a weapon + for(int i=0;iammo[i] == 0) continue; + + sWeaponScore = 5; // Minimal score for a weapon + + if ((flDist >= WeaponInfoTable[i].flMinDesiredDistance) && + (flDist <= WeaponInfoTable[i].flMaxDesiredDistance)) + { + // In desired range for this weapon + sWeaponScore += 5; // Increase score much + } + else if ((flDist < WeaponInfoTable[i].flMinFireDistance) || + (flDist > WeaponInfoTable[i].flMaxFireDistance)) + continue; // Wrong distance for this weapon + + // The ideal distance would be between the Min and Max desired distance. + // Score on the difference of the avarage of the Min and Max desired distance. + float flAvarage = (WeaponInfoTable[i].flMinDesiredDistance + + WeaponInfoTable[i].flMaxDesiredDistance) / 2.0f; + float flIdealDiff = fabs(flDist - flAvarage); + + if (flIdealDiff < 0.5f) // Close to ideal distance + sWeaponScore += 4; + else if (flIdealDiff <= 1.0f) + sWeaponScore += 2; + + // Now rate the weapon on available ammo... + if (WeaponInfoTable[i].sMinDesiredAmmo > 0) + { + // Calculate how much percent of the min desired ammo the bot has + float flDesiredPercent = (float(m_pMyEnt->ammo[i]) / + float(WeaponInfoTable[i].sMinDesiredAmmo)) * + 100.0f; + + if (flDesiredPercent >= 400.0f) + sWeaponScore += 4; + else if (flDesiredPercent >= 200.0f) + sWeaponScore += 3; + else if (flDesiredPercent >= 100.0f) + sWeaponScore += 1; + } + + WeaponChoices.Insert(i, sWeaponScore); + } + + int WeaponSelect; + if (WeaponChoices.GetSelection(WeaponSelect)) + { + m_iChangeWeaponDelay = lastmillis + RandomLong(2000, 8000); + m_bShootAtFeet = ((WeaponInfoTable[WeaponSelect].eWeaponType==TYPE_ROCKET) && + (RandomLong(1, 100) <= + m_pBotSkill->sShootAtFeetWithRLPercent)); + return SelectGun(WeaponSelect); + } + + return false; +} + +int CBot::GetShootDelay() +{ + // UNDONE + if ((WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) || + (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_AUTO)) + return m_pMyEnt->gunwait; + + float flMinShootDelay = m_pBotSkill->flMinAttackDelay; + float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; + return max(m_pMyEnt->gunwait, int(RandomFloat(flMinShootDelay, flMaxShootDelay) * 1000.0f)); +} + +void CBot::CheckReload() // reload gun if no enemies are around +{ + if(m_pMyEnt->enemy) return; + SelectGun(m_pMyEnt->primary); + reload(m_pMyEnt); + return; +} + +void CBot::MainAI() +{ + // Default bots will run forward + m_pMyEnt->move = 1; + + // Default bots won't strafe + m_pMyEnt->strafe = 0; + + if (!BotManager.BotsShoot() && m_pMyEnt->enemy) + m_pMyEnt->enemy = NULL; // Clear enemy when bots may not shoot + + if (m_bGoToDebugGoal) // For debugging the waypoint navigation + { + if (!HeadToGoal()) + { + ResetWaypointVars(); + m_vGoal = g_vecZero; + } + else + AddDebugText("Heading to debug goal..."); + } + if (BotManager.BotsShoot() && FindEnemy()) // Combat + { + AddDebugText("has enemy"); + + // Shoot at enemy + ShootEnemy(); + + if (m_eCurrentBotState != STATE_ENEMY) + { + m_vGoal = g_vecZero; + ResetWaypointVars(); + } + + m_eCurrentBotState = STATE_ENEMY; + if (!CheckJump()) + DoCombatNav(); + } + else if (CheckHunt() && HuntEnemy()) + { + CheckReload(); + AddDebugText("Hunting to %s", m_pHuntTarget->name); + m_eCurrentBotState = STATE_HUNT; + } + // Heading to an interesting entity(ammo, armour etc) + else if (CheckItems()) + { + CheckReload(); + AddDebugText("has ent"); + m_eCurrentBotState = STATE_ENT; + } + else if (m_classicsp && DoSPStuff()) // Home to goal, find/follow friends etc. + { + + AddDebugText("SP stuff"); + m_eCurrentBotState = STATE_SP; + } + else // Normal navigation + { + CheckReload(); + if (m_eCurrentBotState != STATE_NORMAL) + { + m_vGoal = g_vecZero; + ResetWaypointVars(); + } + + m_eCurrentBotState = STATE_NORMAL; + bool bDoNormalNav = true; + + AddDebugText("normal nav"); + + // Make sure the bot looks straight forward and not up or down + m_pMyEnt->pitch = 0; + + // if it is time to look for a waypoint AND if there are waypoints in this + // level... + if (WaypointClass.m_iWaypointCount >= 1) + { + // check if we need to find a waypoint... + if (CurrentWPIsValid() == false) + { + if (m_iLookForWaypointTime <= lastmillis) + { + // find the nearest reachable waypoint + waypoint_s *pWP = GetNearestWaypoint(10.0f); + + if (pWP && (pWP != m_pCurrentWaypoint)) + { + SetCurrentWaypoint(pWP); + condebug("New nav wp"); + bDoNormalNav = !HeadToWaypoint(); + if (bDoNormalNav) + ResetWaypointVars(); + } + else + ResetWaypointVars(); + + m_iLookForWaypointTime = lastmillis + 250; + } + } + else + { + bDoNormalNav = !HeadToWaypoint(); + if (bDoNormalNav) + ResetWaypointVars(); + AddDebugText("Using wps for nav"); + } + } + + // If nothing special, do regular (waypointless) navigation + if(bDoNormalNav) + { + // Is the bot underwater? + if (UnderWater(m_pMyEnt->o) && WaterNav()) + { + // Bot is under water, navigation happens in WaterNav + } + // Time to check the environment? + else if (m_iCheckEnvDelay < lastmillis) + { + if (!vis(m_vWaterGoal, g_vecZero)) m_vWaterGoal = g_vecZero; + + // Check for stuck and strafe + if (UnderWater(m_pMyEnt->o) || !CheckStuck()) + { + // Only do this when the bot is underwater or when the bot isn't stuck + + // Check field of view (FOV) + CheckFOV(); + } + } + + // Check if the bot has to strafe + CheckStrafe(); + + m_pMyEnt->move = 1; + } + } +} + +void CBot::DoCombatNav() +{ + if (m_iCombatNavTime > lastmillis) + { + // If bot has a lower skill and has to turn much, wait + if ((m_sSkillNr > 2) && (m_fYawToTurn > 90.0f)) + { + ResetMoveSpeed(); + } + else + { + SetMoveDir(m_iMoveDir, false); + } + return; + } + + if (m_bCombatJump) + { + m_pMyEnt->jumpnext = true; + m_bCombatJump = false; + m_iCombatJumpDelay = lastmillis + RandomLong(1500, 2800); + return; + } + + m_iMoveDir = DIR_NONE; + + // Check if bot is on top of his enemy + float r = m_pMyEnt->radius+m_pMyEnt->enemy->radius; + if ((fabs(m_pMyEnt->enemy->o.x-m_pMyEnt->o.x)enemy->o.y-m_pMyEnt->o.y)enemy->o.z+m_pMyEnt->enemy->aboveeye) < (m_pMyEnt->o.z + m_pMyEnt->aboveeye))) + { + // Try to get off him! + condebug("On enemy!"); + TMultiChoice AwayDirChoices; + + if (IsVisible(LEFT, 4.0f, false)) + AwayDirChoices.Insert(LEFT); + if (IsVisible(RIGHT, 4.0f, false)) + AwayDirChoices.Insert(RIGHT); + if (IsVisible(FORWARD, 4.0f, false)) + AwayDirChoices.Insert(FORWARD); + if (IsVisible(BACKWARD, 4.0f, false)) + AwayDirChoices.Insert(BACKWARD); + + int iDir; + if (AwayDirChoices.GetSelection(iDir)) + { + m_iMoveDir = iDir; + m_iCombatNavTime = lastmillis + 500; + } + } + + float flDist = GetDistance(m_pMyEnt->enemy->o); + + // Check for nearby items? + if (((m_iCheckEntsDelay < lastmillis) || m_pTargetEnt) && + m_pBotSkill->bCanSearchItemsInCombat) + { + m_iCheckEntsDelay = lastmillis + 125; + bool bSearchItems = false; + + if (m_pTargetEnt) + { + // Bot has already found an entity, still valid? + vec v = { m_pTargetEnt->x, m_pTargetEnt->y, + S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight }; + if ((GetDistance(v) > 25.0f) || !IsVisible(m_pTargetEnt)) + m_pTargetEnt = NULL; + } + + if (!m_pTargetEnt && (m_iCheckEntsDelay <= lastmillis)) + { + if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) + bSearchItems = (flDist >= 8.0f); + else + bSearchItems = (m_pMyEnt->ammo[m_pMyEnt->gunselect] <= + WeaponInfoTable[m_pMyEnt->gunselect].sMinDesiredAmmo); + + if (bSearchItems) + m_pTargetEnt = SearchForEnts(false, 25.0f, 1.0f); + } + + if (m_pTargetEnt) + { + condebug("Combat ent"); + vec v = { m_pTargetEnt->x, m_pTargetEnt->y, + S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight }; + + debugbeam(m_pMyEnt->o, v); + + float flHeightDiff = v.z - m_pMyEnt->o.z; + bool bToHigh = false; + + // Check he height for this ent + if (Get2DDistance(v) <= 2.0f) + { + if (flHeightDiff >= 1.5f) + { + if (flHeightDiff <= JUMP_HEIGHT) + { +#ifndef RELEASE_BUILD + char sz[64]; + sprintf(sz, "Ent z diff: %f", v.z-m_pMyEnt->o.z); + condebug(sz); +#endif + m_pMyEnt->jumpnext = true; // Jump if close to ent and the ent is high + } + else + bToHigh = true; + } + } + + if (!bToHigh) + { + int iMoveDir = GetDirection(GetViewAngles(), m_pMyEnt->o, v); + + if (iMoveDir != DIR_NONE) + { + m_iMoveDir = iMoveDir; + m_iCombatNavTime = lastmillis + RandomLong(125, 250); + } + + // Check if bot needs to jump over something + vec from = m_pMyEnt->o; + from.z -= 1.0f; + if (!IsVisible(from, iMoveDir, 3.0f, false)) + m_pMyEnt->jumpnext = true; + + return; + } + } + } + + // High skill and enemy is close? + if ((m_sSkillNr <= 1) && (m_fYawToTurn < 80.0f) && (flDist <= 20.0f) && + (m_iCombatJumpDelay < lastmillis)) + { + // Randomly jump a bit, to avoid some basic firepower ;) + + // How lower the distance to the enemy, how higher the chance for a jump + short sJumpPercent = (100 - ((short)flDist * 8)); + if (RandomLong(1, 100) <= sJumpPercent) + { + // Choose a nice direction to jump to + + // Is the enemy close? + if ((GetDistance(m_pMyEnt->enemy->o) <= 4.0f) || + (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE)) + { + m_iMoveDir = FORWARD; // Jump forward + SetMoveDir(FORWARD, false); + m_bCombatJump = true; + } + else if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType != TYPE_MELEE)// else jump to a random direction + { + /* + Directions to choose: + - Forward-right + - Right + - Backward-right + - Backward + - Backward-left + - Left + - Forward-left + + */ + + TMultiChoice JumpDirChoices; + short sForwardScore = ((flDist > 8.0f) || (flDist < 4.0f)) ? 20 : 10; + short sBackwardScore = (flDist <= 6.0f) ? 20 : 10; + short sStrafeScore = (flDist < 6.0f) ? 20 : 10; + + if (IsVisible((FORWARD | LEFT), 4.0f, false)) + JumpDirChoices.Insert((FORWARD | LEFT), sForwardScore); + if (IsVisible((FORWARD | RIGHT), 4.0f, false)) + JumpDirChoices.Insert((FORWARD | RIGHT), sForwardScore); + if (IsVisible(BACKWARD, 4.0f, false)) + JumpDirChoices.Insert(BACKWARD, sBackwardScore); + if (IsVisible((BACKWARD | LEFT), 4.0f, false)) + JumpDirChoices.Insert((BACKWARD | LEFT), sBackwardScore); + if (IsVisible((BACKWARD | RIGHT), 4.0f, false)) + JumpDirChoices.Insert((BACKWARD | RIGHT), sBackwardScore); + if (IsVisible(LEFT, 4.0f, false)) + JumpDirChoices.Insert(LEFT, sStrafeScore); + if (IsVisible(RIGHT, 4.0f, false)) + JumpDirChoices.Insert(RIGHT, sStrafeScore); + + int JumpDir; + if (JumpDirChoices.GetSelection(JumpDir)) + { + m_iMoveDir = JumpDir; + SetMoveDir(JumpDir, false); + m_bCombatJump = true; + } + } + + if (m_bCombatJump) + { + m_iCombatNavTime = lastmillis + RandomLong(125, 250); + return; + } + } + } + + if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) + return; // Simply walk towards enemy if using a melee type + + flDist = Get2DDistance(m_pMyEnt->enemy->o); + + // Out of desired range for current weapon? + if ((flDist <= WeaponInfoTable[m_pMyEnt->gunselect].flMinDesiredDistance) || + (flDist >= WeaponInfoTable[m_pMyEnt->gunselect].flMaxDesiredDistance)) + { + if (flDist >= WeaponInfoTable[m_pMyEnt->gunselect].flMaxDesiredDistance) + { + m_iMoveDir = FORWARD; + } + else + { + m_iMoveDir = BACKWARD; + } + + vec src, forward, right, up, dest, MyAngles = GetViewAngles(), o = m_pMyEnt->o; + traceresult_s tr; + + // Is it furthest or farthest? bleh + float flFurthestDist = 0; + int bestdir = -1, dir = 0; + bool moveback = (m_pMyEnt->move == -1); + + for(int j=-45;j<=45;j+=45) + { + src = MyAngles; + src.y = WrapYZAngle(src.y + j); + src.x = 0.0f; + + // If we're moving backwards, trace backwards + if (moveback) + src.y = WrapYZAngle(src.y + 180); + + AnglesToVectors(src, forward, right, up); + + dest = o; + vmul(forward, 40); + vadd(dest, forward); + + TraceLine(o, dest, m_pMyEnt, false, &tr); + + //debugbeam(origin, end); + flDist = GetDistance(tr.end); + + if (flFurthestDist < flDist) + { + flFurthestDist = flDist; + bestdir = dir; + } + dir++; + } + + switch(bestdir) + { + case 0: + if (moveback) + m_iMoveDir |= RIGHT; // Strafe right + else + m_iMoveDir |= LEFT; // Strafe left + break; + case 2: + if (moveback) + m_iMoveDir |= LEFT; // Strafe left + else + m_iMoveDir |= RIGHT; // Strafe right + break; + } + + if (m_iMoveDir != DIR_NONE) + { + SetMoveDir(m_iMoveDir, false); + m_iCombatNavTime = lastmillis + 500; + } + } + else if (m_pBotSkill->bCircleStrafe) // Circle strafe when in desired range... + { + traceresult_s tr; + vec angles, end, forward, right, up; + TMultiChoice StrafeDirChoices; + + // Check the left side... + angles = GetViewAngles(); + angles.y = WrapYZAngle(angles.y - 75.0f); // Not 90 degrees because the bot + // doesn't strafe in a straight line + // (aims still to enemy). + + AnglesToVectors(angles, forward, right, up); + end = m_pMyEnt->o; + vmul(forward, 15.0f); + vadd(end, forward); + + TraceLine(m_pMyEnt->o, end, m_pMyEnt, true, &tr); + StrafeDirChoices.Insert(LEFT, (int)GetDistance(m_pMyEnt->o, tr.end)); + + // Check the right side... + angles = GetViewAngles(); + angles.y = WrapYZAngle(angles.y + 75.0f); // Not 90 degrees because the bot + // doesn't strafe in a straight line + // (aims still to enemy). + + AnglesToVectors(angles, forward, right, up); + end = m_pMyEnt->o; + vmul(forward, 15.0f); + vadd(end, forward); + + TraceLine(m_pMyEnt->o, end, m_pMyEnt, true, &tr); + StrafeDirChoices.Insert(RIGHT, (int)GetDistance(m_pMyEnt->o, tr.end)); + + int StrafeDir; + if (StrafeDirChoices.GetSelection(StrafeDir)) + { + m_iMoveDir = StrafeDir; + SetMoveDir(StrafeDir, false); + m_iCombatNavTime = lastmillis + RandomLong(1500, 3000); + } + } + else // Bot can't circle strafe(low skill), just stand still + ResetMoveSpeed(); +} + +bool CBot::CheckStuck() +{ + if (m_iStuckCheckDelay >= lastmillis) + return false; + + if ((!vis(m_vGoal, g_vecZero)) && (GetDistance(m_vGoal) < 2.0f)) + return false; + + bool IsStuck = false; + + vec CurPos = m_pMyEnt->o, PrevPos = m_vPrevOrigin; + CurPos.z = PrevPos.z = 0; + // Did the bot hardly move the last frame? + if (GetDistance(CurPos, PrevPos) <= 0.1f) + { + if (m_bStuck) + { + if (m_iStuckTime < lastmillis) + IsStuck = true; + } + else + { + m_bStuck = true; + m_iStuckTime = lastmillis + 1000; + } + } + else + { + m_bStuck = false; + m_iStuckTime = 0; + } + + if (IsStuck) + { +#ifndef RELEASE_BUILD + char msg[64]; + sprintf(msg, "stuck (%f)", GetDistance(m_vPrevOrigin)); + condebug(msg); +#endif + + m_bStuck = false; + m_iStuckTime = 0; + + // Crap bot is stuck, lets just try some random things + + // Check if the bot can turn around + vec src = GetViewAngles(); + src.x = 0; + vec forward, right, up, dir, dest; + traceresult_s tr; + + AnglesToVectors(src, forward, right, up); + + // Check the left side... + dir = right; + dest = m_pMyEnt->o; + vmul(dir, 3); + vsub(dest, dir); + + TraceLine(m_pMyEnt->o, dest, m_pMyEnt, false, &tr); + //debugbeam(m_pMyEnt->o, end); + + if (!tr.collided) + { + // Bot can turn left, do so + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw - 90); + m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; + return true; + } + + // Check the right side... + dir = right; + dest = m_pMyEnt->o; + vmul(dir, 3); + vadd(dest, dir); + + TraceLine(m_pMyEnt->o, dest, m_pMyEnt, true, &tr); + //debugbeam(m_pMyEnt->o, end); + + if (!tr.collided) + { + // Bot can turn right, do so + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 90); + m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; + return true; + } + + // Check if bot can turn 180 degrees + dir = forward; + dest = m_pMyEnt->o; + vmul(dir, 3); + vsub(dest, dir); + + TraceLine(m_pMyEnt->o, dest, m_pMyEnt, true, &tr); + //debugbeam(m_pMyEnt->o, end); + + if (!tr.collided) + { + // Bot can turn around, do so + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 180); + m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; + return true; + } + + // Bleh bot couldn't turn, lets just randomly jump :| + + condebug("Randomly avoiding stuck..."); + if (RandomLong(0, 2) == 0) + m_pMyEnt->jumpnext = true; + else + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + RandomLong(60, 160)); + return true; + } + + return false; +} + +// Check if a near wall is blocking and we can jump over it +bool CBot::CheckJump() +{ + bool bHasGoal = (!vis(m_vGoal, g_vecZero)); + float flGoalDist = (bHasGoal) ? GetDistance(m_vGoal) : 0.0f; + +// if ((bHasGoal) && (flGoalDist < 2.0f)) + // return false; UNDONE? + + vec start = m_pMyEnt->o; + float flTraceDist = 3.0f; + + if (bHasGoal && (flGoalDist < flTraceDist)) + flTraceDist = flGoalDist; + + // Something blocks at eye hight? + if (!IsVisible(start, FORWARD, flTraceDist, false)) + { + // Check if the bot can jump over it + start.z += (JUMP_HEIGHT - 1.0f); + if (IsVisible(start) && !IsVisible(start, FORWARD, flTraceDist, false)) + { + // Jump + debugnav("High wall"); + m_pMyEnt->jumpnext = true; + return true; + } + } + else + { + // Check if something is blocking at feet height, so the bot can jump over it + start.z -= 1.7f; + + // Trace was blocked? + if (!IsVisible(start, FORWARD, flTraceDist, false)) + { + //debugbeam(start, end); + + // Jump + debugnav("Low wall"); + m_pMyEnt->jumpnext = true; + return true; + } + } + + return false; // Bot didn't had to jump(or couldn't) +} + +bool CBot::CheckStrafe() +{ + if (m_iStrafeTime >= lastmillis) + { + SetMoveDir(m_iMoveDir, true); + return true; + } + + if (m_iStrafeCheckDelay >= lastmillis) + return false; + + // Check for near walls + traceresult_s tr; + vec from = m_pMyEnt->o, to, forward, right, up, dir; + float flLeftDist = -1.0f, flRightDist = -1.0f; + bool bStrafe = false; + int iStrafeDir = DIR_NONE; + + AnglesToVectors(GetViewAngles(), forward, right, up); + + // Check for a near left wall + to = from; + dir = right; + vmul(dir, 3.0f); + vsub(to, dir); + TraceLine(from, to, m_pMyEnt, false, &tr); + if (tr.collided) + flLeftDist = GetDistance(from, tr.end); + //debugbeam(m_pMyEnt->o, to); + + // Check for a near right wall + to = from; + dir = right; + vmul(dir, 3.0f); + vadd(to, dir); + TraceLine(from, to, m_pMyEnt, false, &tr); + if (tr.collided) + flRightDist = GetDistance(from, tr.end); + //debugbeam(m_pMyEnt->o, to); + + if ((flLeftDist == -1.0f) && (flRightDist == -1.0f)) + { + dir = right; + vmul(dir, m_pMyEnt->radius); + + // Check left + from = m_pMyEnt->o; + vsub(from, dir); + if (IsVisible(from, FORWARD, 3.0f, false, &flLeftDist)) + flLeftDist = -1.0f; + + // Check right + from = m_pMyEnt->o; + vadd(from, dir); + if (IsVisible(from, FORWARD, 3.0f, false, &flRightDist)) + flRightDist = -1.0f; + } + + if ((flLeftDist != -1.0f) && (flRightDist != -1.0f)) + { + if (flLeftDist < flRightDist) + { + // Strafe right + bStrafe = true; + iStrafeDir = RIGHT; + } + else if (flRightDist < flLeftDist) + { + // Strafe left + bStrafe = true; + iStrafeDir = LEFT; + } + else + { + // Randomly choose a strafe direction + bStrafe = true; + if (RandomLong(0, 1)) + iStrafeDir = LEFT; + else + iStrafeDir = RIGHT; + } + } + else if (flLeftDist != -1.0f) + { + // Strafe right + bStrafe = true; + iStrafeDir = RIGHT; + } + else if (flRightDist != -1.0f) + { + // Strafe left + bStrafe = true; + iStrafeDir = LEFT; + } + + if (bStrafe) + { + SetMoveDir(iStrafeDir, true); + m_iMoveDir = iStrafeDir; + m_iStrafeTime = lastmillis + RandomLong(75, 150); + } + + return bStrafe; +} + +void CBot::CheckFOV() +{ + m_iCheckEnvDelay = lastmillis + RandomLong(125, 250); + vec MyAngles = GetViewAngles(); + vec src, forward, right, up, dest, best = {0,0,0}; + vec origin = m_pMyEnt->o; + float flDist, flFurthestDist = 0; + bool WallLeft = false; + traceresult_s tr; + + //origin.z -= 1.5; // Slightly under eye level + + // Scan 90 degrees FOV + for(int angle=-45;angle<=45;angle+=5) + { + src = MyAngles; + src.y = WrapYZAngle(src.y + angle); + + AnglesToVectors(src, forward, right, up); + + dest = origin; + vmul(forward, 40); + vadd(dest, forward); + + TraceLine(origin, dest, m_pMyEnt, false, &tr); + + //debugbeam(origin, end); + flDist = GetDistance(tr.end); + + if (flFurthestDist < flDist) + { + flFurthestDist = flDist; + best = tr.end; + } + } + + if (best.x && best.y && best.z) + { + AimToVec(best); + // Update MyAngles, since their (going to be) change(d) + MyAngles.x = m_pMyEnt->targetpitch; + MyAngles.y = m_pMyEnt->targetyaw; + } + + float flNearestHitDist = GetDistance(best); + + if (!UnderWater(m_pMyEnt->o) && m_pMyEnt->onfloor) + { + // Check if a near wall is blocking and we can jump over it + if (flNearestHitDist < 4) + { + // Check if the bot can jump over it + src = MyAngles; + src.x = 0; + + AnglesToVectors(src, forward, right, up); + + vec start = origin; + start.z += 2.0f; + dest = start; + vmul(forward, 6); + vadd(dest, forward); + + TraceLine(start, dest, m_pMyEnt, false, &tr); + //debugbeam(start, end); + + if (!tr.collided) + { + // Jump + debugnav("High wall"); + m_pMyEnt->jumpnext = true; + m_iStrafeCheckDelay = lastmillis + RandomLong(250, 500); + return; + } + } + else + { + // Check if something is blocking below us, so the bot can jump over it + src = MyAngles; + src.x = 0; + + AnglesToVectors(src, forward, right, up); + + vec start = origin; + start.z -= 1.7f; + dest = start; + vmul(forward, 4); + vadd(dest, forward); + + TraceLine(start, dest, m_pMyEnt, false, &tr); + + // Trace was blocked? + if (tr.collided) + { + //debugbeam(start, end); + + // Jump + debugnav("Low wall"); + m_pMyEnt->jumpnext = true; + m_iStrafeCheckDelay = lastmillis + RandomLong(250, 500); + return; + } + } + + // Check if the bot is going to fall... + src = MyAngles; + src.x = 0.0f; + AnglesToVectors(src, forward, right, up); + + dest = origin; + vmul(forward, 3.0f); + vadd(dest, forward); + + TraceLine(origin, dest, m_pMyEnt, false, &tr); + + int cx = int(tr.end.x), cy = int(tr.end.y); + short CubesInWater=0; + for(int x=cx-1;x<=(cx+1);x++) + { + for(int y=cy-1;y<=(cy+1);y++) + { + if (OUTBORD(x, y)) continue; + //sqr *s = S(fast_f2nat(x), fast_f2nat(y)); + //if (!SOLID(s)) + { + vec from = { x, y, m_pMyEnt->o.z }; + dest = from; + dest.z -= 6.0f; + TraceLine(from, dest, m_pMyEnt, false, &tr); + bool turn = false; + if (UnderWater(tr.end)) CubesInWater++; + if (CubesInWater > 2) turn = true; // Always avoid water + if (!tr.collided && RandomLong(0, 1)) + turn = true; // Randomly avoid a fall + + if (turn) + { + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 180); + m_iCheckEnvDelay = m_iStrafeCheckDelay = lastmillis + RandomLong(750, 1500); + debugnav("Water or a fall in front"); + return; + } + } + } + } + } + + // Is the bot about to head a corner? + if (flNearestHitDist <= 4.0f) + { + src = MyAngles; + src.y = WrapYZAngle(src.y - 45.0f); + AnglesToVectors(src, forward, right, up); + + dest = origin; + vmul(forward, 4.0f); + vadd(dest, forward); + + TraceLine(origin, dest, m_pMyEnt, false, &tr); + + WallLeft = (tr.collided); + + src = MyAngles; + src.y += WrapYZAngle(src.y + 45.0f); + AnglesToVectors(src, forward, right, up); + + dest = origin; + vmul(forward, 4.0f); + vadd(dest, forward); + + TraceLine(origin, dest, m_pMyEnt, false, &tr); + + if (WallLeft && tr.collided) + { + // We're about to hit a corner, turn away + debugnav("Corner"); + m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + RandomFloat(160.0f, 200.0f)); + m_iCheckEnvDelay = m_iStrafeCheckDelay = lastmillis + RandomLong(750, 1500); + return; + } + } +} + +// Called when bot is underwater +bool CBot::WaterNav() +{ + const int iSearchRange = 4; + + if (vis(m_vWaterGoal, g_vecZero)) + { + AddDebugText("WaterNav"); + // Find the nearest and reachable cube which isn't underwater + + int cx = int(m_pMyEnt->o.x); + int cy = int(m_pMyEnt->o.y); + float flNearestDist = 9999.0f, flDist; + + if (OUTBORD(cx, cy)) return false; + + // Check all cubes in range... + for (int x=(cx-iSearchRange);x<=(cx+iSearchRange);x++) + { + for (int y=(cy-iSearchRange);y<=(cy+iSearchRange);y++) + { + sqr *s = S(x, y); + + if (SOLID(s)) continue; + if ((x==cx) && (y==cy)) continue; + + vec v = { x, y, GetCubeFloor(x, y) }; + + if (UnderWater(v)) continue; // Skip, cube is underwater + + if (hdr.waterlevel < (v.z - 2.0f)) continue; // Cube is too high + + // Check if the bot 'can fit' on the cube(no near obstacles) + bool small = false; + for (int a=(x-2);a<=(x+2);a++) + { + if (small) break; + for (int b=(y-2);b<=(y+2);b++) + { + if ((x==a) && (y==b)) continue; + vec v2 = { a, b, GetCubeFloor(a, b) }; + if (v.z < (v2.z-1-JUMP_HEIGHT)) + { + small=true; + break; + } + + if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1))) + { + if ((v2.z) < (v.z-2.0f)) + { + small = true; + break; + } + } + + traceresult_s tr; + TraceLine(v, v2, NULL, false, &tr); + if (tr.collided) + { + small=true; + break; + } + } + if (small) break; + } + if (small) + { + debugbeam(m_pMyEnt->o, v); + continue; + } + + // Okay, cube is valid. + flDist = GetDistance(v); + if (flDist < flNearestDist) + { + flNearestDist = flDist; + m_vWaterGoal = v; + } + } + } + } + + if (!vis(m_vWaterGoal, g_vecZero)) + { + AddDebugText("WaterNav"); + //debugbeam(m_pMyEnt->o, m_vWaterGoal); + vec aim = m_vWaterGoal; + aim.z += 1.5f; // Aim a bit further up + AimToVec(aim); + if ((RandomLong(1, 100) <= 15) && (Get2DDistance(m_vWaterGoal) <= 7.0f)) + m_pMyEnt->jumpnext = true; + return true; + } + + return false; +} + +bool CBot::CheckItems() +{ + if (!m_pCurrentGoalWaypoint && !CheckJump() && CheckStuck()) + { + // Don't check for ents a while when stuck + m_iCheckEntsDelay = lastmillis + RandomLong(1000, 2000); + return false; + } + + if (vis(m_vGoal, g_vecZero)) + m_pTargetEnt = NULL; + + if (!m_pTargetEnt) + { + if (m_iCheckEntsDelay > lastmillis) + return false; + else + { + m_pTargetEnt = SearchForEnts(!m_classicsp); + m_iCheckEntsDelay = lastmillis + RandomLong(2500, 5000); + } + } + + if (m_pTargetEnt) + { + if (HeadToTargetEnt()) + return true; + } + + if (m_eCurrentBotState == STATE_ENT) + { + ResetWaypointVars(); + m_vGoal = g_vecZero; + m_pTargetEnt = NULL; + } + + return false; +} + +bool CBot::InUnreachableList(entity *e) +{ + TLinkedList::node_s *p = m_UnreachableEnts.GetFirst(); + while(p) + { + if (p->Entry->ent == e) return true; + p = p->next; + } + return false; +} + +bool CBot::IsReachable(vec to, float flMaxHeight) +{ + vec from = m_pMyEnt->o; + traceresult_s tr; + float curr_height, last_height; + + float distance = GetDistance(from, to); + + // is the destination close enough? + //if (distance < REACHABLE_RANGE) + { + if (IsVisible(to)) + { + // Look if bot can 'fit trough' + vec src = from, forward, right, up; + AnglesToVectors(GetViewAngles(), forward, right, up); + + // Trace from 1 cube to the left + vec temp = right; + vmul(temp, 1.0f); + vsub(src, temp); + if (!::IsVisible(src, to)) return false; + + // Trace from 1 cube to the right + vadd(src, temp); + if (!::IsVisible(src, to)) return false; + + if (UnderWater(from) && UnderWater(to)) + { + // No need to worry about heights in water + return true; + } +/* + if (to.z > (from.z + JUMP_HEIGHT)) + { + vec v_new_src = to; + vec v_new_dest = to; + + v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f); + + // check if we didn't hit anything, if so then it's in mid-air + if (::IsVisible(v_new_src, v_new_dest, NULL)) + { + condebug("to is in midair"); + debugbeam(from, to); + return false; // can't reach this one + } + } +*/ + + // check if distance to ground increases more than jump height + // at points between from and to... + + vec v_temp = to; vsub(v_temp, from); + vec v_direction = Normalize(v_temp); // 1 unit long + vec v_check = from; + vec v_down = from; + + v_down.z = v_down.z - 100.0f; // straight down + + TraceLine(v_check, v_down, NULL, false, &tr); + + // height from ground + last_height = GetDistance(v_check, tr.end); + + distance = GetDistance(to, v_check); // distance from goal + + while (distance > 2.0f) + { + // move 2 units closer to the goal + v_temp = v_direction; + vmul(v_temp, 2.0f); + vadd(v_check, v_temp); + + v_down = v_check; + v_down.z = v_down.z - 100.0f; + + TraceLine(v_check, v_down, NULL, false, &tr); + + curr_height = GetDistance(v_check, tr.end); + + // is the difference in the last height and the current height + // higher that the jump height? + if ((last_height - curr_height) >= flMaxHeight) + { + // can't get there from here... + //condebug("traces failed to to"); + debugbeam(from, to); + return false; + } + + last_height = curr_height; + + distance = GetDistance(to, v_check); // distance from goal + } + + return true; + } + } + + return false; +} + +void CBot::HearSound(int n, vec *o) +{ + // Has the bot already an enemy? + if (m_pMyEnt->enemy) return; + + // Is the sound not interesting? +//fixmebot +/* if ((n==S_DIE1) || (n==S_DIE2) || (n==S_DEATHR) || (n==S_DEATHE) || (n==S_DEATHS) || + (n==S_DEATHB) || (n==S_DEATHH) || (n==S_DEATHD) || (n==S_PIGGR2)) + return;*/ + + int soundvol = m_pBotSkill->iMaxHearVolume - + (int)(GetDistance(*o)*3*m_pBotSkill->iMaxHearVolume/255); + + if (soundvol == 0) return; + + // Look who made the sound(check for the nearest enemy) + float flDist, flNearestDist = 3.0f; // Range of 3 units + dynent *pNearest = NULL; + + /* edit -argh + if (m_sp) + { + // Check all monsters + loopv(monsters) + { + if (!monsters[i] || monsters[i]->state != CS_ALIVE) continue; + + flDist = GetDistance(*o, monsters[i]->o); + if ((flDist < flNearestDist) && IsVisible(monsters[i])) + { + pNearest = monsters[i]; + flNearestDist = flDist; + } + } + } */ + //else + //{ + // Check all players first + loopv(players) + { + if (!players[i] || (players[i]->state != CS_ALIVE) || + isteam(m_pMyEnt->team, players[i]->team)) + continue; + + flDist = GetDistance(*o, players[i]->o); + if ((flDist < flNearestDist) && IsVisible(players[i])) + { + pNearest = players[i]; + flNearestDist = flDist; + } + } + + // Check all bots + loopv(bots) + { + if (!bots[i] || (bots[i]->state != CS_ALIVE) || + isteam(m_pMyEnt->team, bots[i]->team) || (bots[i] == m_pMyEnt)) + continue; + + flDist = GetDistance(*o, bots[i]->o); + if ((flDist < flNearestDist) && IsVisible(bots[i])) + { + pNearest = bots[i]; + flNearestDist = flDist; + } + } + + // Check local player + if (player1 && (player1->state == CS_ALIVE) && + !isteam(m_pMyEnt->team, player1->team)) + { + flDist = GetDistance(*o, player1->o); + if ((flDist < flNearestDist) && IsVisible(player1)) + { + pNearest = player1; + flNearestDist = flDist; + } + } + //} + + if (pNearest) + { + if (m_pMyEnt->enemy != pNearest) + m_iShootDelay = lastmillis + GetShootDelay(); // Add shoot delay when new enemy found + + m_pMyEnt->enemy = pNearest; + } +} + +bool CBot::IsInFOV(const vec &o) +{ + vec v2, forward, right, up; + float flDot; + + AnglesToVectors(GetViewAngles(), forward, right, up); + + v2 = o; + vsub(v2, m_pMyEnt->o); + v2.z = 0.0f; // Make 2D + v2 = Normalize(v2); + forward.z = 0; // Make 2D + + flDot = dotprod(v2 , forward); + + return(flDot >= 0.5f); // sin2(0.5) == 60 degrees FOV +} + +// Code of CBot - End diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp new file mode 100644 index 00000000..ea53a0ae --- /dev/null +++ b/source/src/bot/bot_util.cpp @@ -0,0 +1,564 @@ +// +// C++ Implementation: bot_util +// +// Description: Basic util functions, mostly bot related +// +// +// Author: +// +// +// +// + +#include "../cube.h" + +#ifndef __linux__ +#include +#endif +#include +#if (defined __linux__) +#include +#include +#include +#else +#include +#endif + +extern dvector monsters; + +// Function code by PMB - Begin + + +// Random functions begin +// copied from +// http://forums.bots-united.com/showthread.php?t=244&page=1&pp=10&highlight=random +// So credits to PMB and the person(s) who actually made it :] + +// maximum value returned by our number generator (2^31 - 1 = 0x7FFFFFFF) +#define LRAND_MAX 2147483647L +long lseed; // our random number generator's seed + +long lrand (void) +{ + // this function is the equivalent of the rand() standard C library function, + // except that whereas rand() works only with short integers + // (i.e. not above 32767), this function is able to generate 32-bit random + // numbers. Isn't that nice ? + // credits go to Ray Gardner for his fast implementation of minimal random + // number generators + // http://c.snippets.org/snip_lister.php?fname=rg_rand.c + + // compose the two 16-bit parts of the long integer and assemble them + static unsigned long lrand_lo, lrand_hi; + lrand_lo = 16807 * (long) (lseed & 0xFFFF); // low part + lrand_hi = 16807 * (long) ((unsigned long) lseed >> 16); + // high part + lrand_lo += (lrand_hi & 0x7FFF) << 16; + // assemble both in lrand_lo + // is the resulting number greater than LRAND_MAX (half the capacity) ? + if (lrand_lo > LRAND_MAX) + { + lrand_lo &= LRAND_MAX; // then get rid of the disturbing bit + lrand_lo++; // and increase it a bit (to avoid overflow problems, I suppose) + } + + lrand_lo += lrand_hi >> 15; + // now do twisted maths to generate the next seed + // is the resulting number greater than LRAND_MAX (half the capacity) ? + if (lrand_lo > LRAND_MAX) + { + lrand_lo &= LRAND_MAX; // then get rid of the disturbing bit + lrand_lo++; // and increase it a bit (to avoid overflow problems, I suppose) + } + // now we've got our (pseudo-)random number. + lseed = (long) lrand_lo; // put it in the seed for next time + return (lseed); // and return it. Yeah, simple as that. +} + +void lsrand (unsigned long initial_seed) +{ + // this function initializes the random seed based on the initial seed value + // passed in the initial_seed parameter. Since random seeds are + // usually initialized with the time of day, and time is a value that + // changes slowly, we bump the seed twice to have it in a more + // random state for future calls of the random number generator. + + // fill in the initial seed of the random number generator + lseed = (long) initial_seed; + lseed = lrand (); // bump it once + lseed = lrand (); // bump it twice + return; // that's all folks +} + +long RandomLong (long from, long to) +{ + // this function returns a random integer number between (and including) + // the starting and ending values passed by parameters from and to. + if (to <= from) + return (from); + + return (from + lrand () / (LRAND_MAX / (to - from + 1))); +} + +float RandomFloat (float from, float to) +{ + // this function returns a random floating-point number between (and including) + // the starting and ending values passed by parameters from and to. + + if (to <= from) + return (from); + + return (from + (float) lrand () / (LRAND_MAX / (to - from))); +} + +// End random functions + +void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up) +{ + static float degrees_to_radians = 2 * PI / 360; + float angle; + float sin_pitch; + float sin_yaw; + float sin_roll; + float cos_pitch; + float cos_yaw; + float cos_roll; + + // For some reason this has to be done :) + // Me = math n00b + angles.x = -angles.x; + angles.y -= 90; + + // compute the sin and cosine of the pitch component + angle = angles.x * degrees_to_radians; + sin_pitch = sinf (angle); + cos_pitch = cosf (angle); + + // compute the sin and cosine of the yaw component + angle = angles.y * degrees_to_radians; + sin_yaw = sinf (angle); + cos_yaw = cosf (angle); + + // compute the sin and cosine of the roll component + angle = angles.z * degrees_to_radians; + sin_roll = sinf (angle); + cos_roll = cosf (angle); + + // build the FORWARD vector + forward.x = cos_pitch * cos_yaw; + forward.y = cos_pitch * sin_yaw; + forward.z = -sin_pitch; + + // build the RIGHT vector + right.x = -(-(sin_roll * sin_pitch * cos_yaw) - (cos_roll * -sin_yaw)); + right.y = -(-(sin_roll * sin_pitch * sin_yaw) - (cos_roll * cos_yaw)); + right.z = -(sin_roll * cos_pitch); + + // build the UPWARDS vector + up.x = ((cos_roll * sin_pitch * cos_yaw) - (sin_roll * -sin_yaw)); + up.y = ((cos_roll * sin_pitch * sin_yaw) - (sin_roll * cos_yaw)); + up.z = cos_roll * cos_pitch; + + return; +} + +// Function code by PMB - End + +float WrapXAngle(float angle) +{ + if (angle > 90) angle = 90; + else if (angle < -90) angle = -90; + + return angle; +} + +float WrapYZAngle(float angle) +{ + while (angle >= 360.0f) angle -= 360.0f; + while (angle < 0.0f) angle += 360.0f; + + return angle; +} + +// Sees how far it can come from 'from' to 'to' and puts the end vector in 'end' +// (1337 description :-) +// UNDONE: Optimize this as much as possible +void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, + bool SkipTags) +{ + tr->end = from; + tr->collided = false; + + static float flNearestDist, flDist; + static vec v; + static bool solid; + + flNearestDist = 9999.0f; + + if(OUTBORD((int)from.x, (int)from.y)) return; + + // Check if the 'line' collides with entities like mapmodels + loopv(ents) + { + entity &e = ents[i]; + if(e.type!=MAPMODEL) continue; // Only check map models for now + + mapmodelinfo &mmi = getmminfo(e.attr2); + if(!&mmi || !mmi.h) continue; + + float lo = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3); + float hi = lo+mmi.h; + float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi; + makevec(&v, e.x, e.y, z); + flDist = GetDistance(from, v); + + if ((flDist < flNearestDist) && (intersect(&e, from, to, &tr->end))) + { + flNearestDist = GetDistance(from, tr->end); + tr->collided = true; + } + } + + if (CheckPlayers) + { + // Check if the 'line' collides with players + loopv(players) + { + dynent *d = players[i]; + if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid players + + flDist = GetDistance(from, d->o); + + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) + { + flNearestDist = flDist; + tr->collided = true; + } + } + + // Check if the 'line' collides with bots + loopv(bots) + { + dynent *d = bots[i]; + if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid bots + + flDist = GetDistance(from, d->o); + + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) + { + flNearestDist = flDist; + tr->collided = true; + } + } + + // Check if the 'line' collides with monsters + /* we don't have monsters anymore, thanks for the bots :) -argh + dvector &mv = getmonsters(); + loopv(mv) + { + dynent *d = mv[i]; + if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid monsters + + flDist = GetDistance(from, d->o); + + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) + { + flNearestDist = flDist; + tr->collided = true; + } + } + */ + + + // Check if the 'line' collides with the local player(player1) + dynent *d = player1; // Shortcut + if (d && (d!=pTracer) && !BotManager.m_pBotToView && (d->state == CS_ALIVE)) + { + flDist = GetDistance(from, d->o); + + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) + { + flNearestDist = flDist; + tr->collided = true; + } + } + } + + + float dx = to.x-from.x; + float dy = to.y-from.y; + int steps = (int)(sqrt(dx*dx+dy*dy)/0.9); + if(!steps) // If from and to are on the same cube... + { + if (GetDistance(from, to) < flNearestDist) + { + tr->end = to; + sqr *s = S(int(from.x), int(from.y)); + float flr = GetCubeFloor(int(from.x), int(from.y)); + solid = ((!SkipTags || !s->tag) && SOLID(s)); + if (solid || (to.z < flr) || (to.z > s->ceil)) + { + tr->collided = true; + tr->end.z = (fabs(to.z-s->ceil) < fabs(to.z-flr)) ? s->ceil : flr; + } + } + return; + } + + float x = from.x; + float y = from.y; + int i = 0; + vec endcube = from; + + // Now check if the 'line' is hit by a cube + while(i= flNearestDist) break; + sqr *s = S(int(x), int(y)); + solid = ((!SkipTags || !s->tag) && SOLID(s)); + if(solid) break; + float floor = s->floor; + if(s->type==FHF) floor -= s->vdelta/4.0f; + float ceil = s->ceil; + if(s->type==CHF) ceil += s->vdelta/4.0f; + float rz = from.z-((from.z-to.z)*(i/(float)steps)); + if(rzceil) break; + + endcube.x = x; + endcube.y = y; + endcube.z = rz; + x += dx/(float)steps; + y += dy/(float)steps; + i++; + } + + if ((i>=steps) && !tr->collided) + { + tr->end = to; + } + else + { + tr->collided = true; + if (GetDistance(from, endcube) < flNearestDist) + tr->end = endcube; + } + + return; +} + +float GetDistance(vec v1, vec v2) +{ + if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0) && (v1.z == 0) && + (v2.z == 0)) + return 0.0f; + + vdist(flDist, vecto, v1, v2); + return flDist; +} + +// As GetDistance(), but doesn take height in account. +float Get2DDistance(vec v1, vec v2) +{ + if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0)) + return 0.0f; + + v1.z = v2.z = 0.0f; + vdist(flDist, vecto, v1, v2); + return flDist; +} + +bool IsVisible(vec v1, vec v2, dynent *tracer, bool SkipTags) +{ + traceresult_s tr; + TraceLine(v1, v2, tracer, (tracer!=NULL), &tr, SkipTags); + return !tr.collided; +} + +// Prediction: +// - pos: Current position +// - vel: Current velocity +// - Time: In seconds, predict how far it is in Time seconds +vec PredictPos(vec pos, vec vel, float Time) +{ + float flVelLength = sqrt(vel.x*vel.x + vel.y*vel.y + vel.z*vel.z); + + if (flVelLength <= 1.0) + return pos; // don't bother with low velocities... + + float speed = flVelLength * Time; + float flTemp = 1/flVelLength; + vec vecNormalize; + + vecNormalize.x = vel.x * flTemp; + vecNormalize.y = vel.y * flTemp; + vecNormalize.z = vel.z * flTemp; + + vec v_src = pos; + vmul(vecNormalize, speed); + vec v_end = v_src; + vadd(v_end, vecNormalize); + + return v_end; +} + +// returns true if the given file is valid +bool IsValidFile(const char *szFileName) +{ + FILE *fp = fopen(szFileName, "r"); + + if (fp) + { + fclose(fp); + return true; + } + + return false; +} + +bool FileIsOlder(const char *szFileName1, const char *szFileName2) +{ +/* int file1, file2; + struct stat stat1, stat2; + + file1 = open(szFileName1, O_RDONLY); + file2 = open(szFileName2, O_RDONLY); + + fstat(file1, &stat1); + fstat(file2, &stat2); + + close(file1); + close(file2); + + return(stat1.st_mtime < stat2.st_mtime);*/ return false; // FIXME +} + +vec Normalize(vec v) +{ + float flLen = sqrt(v.x*v.x + v.y*v.y + v.z*v.z); + static vec v_norm = g_vecZero; + if (flLen == 0) + { + v_norm.x=0;v_norm.y=0;v_norm.z=1; + } + else + { + flLen = 1 / flLen; + v_norm.x = v.x * flLen; v_norm.y = v.y * flLen; v_norm.z = v.z * flLen; + } + return v_norm; +} + +float GetYawDiff(float curyaw, vec v1, vec v2) +{ + float yaw = -(float)atan2(v2.x - v1.x, v2.y - v1.y)/PI*180+180; + return yaw-curyaw; +} + +vec CrossProduct(const vec &a, const vec &b) +{ + vec cross = { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x }; + return cross; +} + +int GetDirection(const vec &angles, const vec &v1, const vec &v2) +{ + vec tmp, forward, right, up, cross; + float flDot; + + AnglesToVectors(angles, forward, right, up); + + tmp = v2; + vsub(tmp, v1); + tmp.z = 0.0f; // Make 2D + tmp = Normalize(tmp); + forward.z = 0; // Make 2D + + flDot = dotprod(tmp , forward); + cross = CrossProduct(tmp, forward); + + int Dir = DIR_NONE; + + if (cross.z > 0.1f) Dir |= LEFT; + else if (cross.z < -0.1f) Dir |= RIGHT; + if (flDot < -0.1f) Dir |= BACKWARD; + else if (flDot > 0.1f) Dir |= FORWARD; + + if (v1.z > v2.z) Dir |= DOWN; + if (v1.z < v2.z) Dir |= UP; + + return Dir; +} + +float GetCubeFloor(int x, int y) +{ + sqr *s = S(x, y); + float floor = s->floor; + if (s->type == FHF) + floor -= (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; + return floor; +} + +float GetCubeHeight(int x, int y) +{ + sqr *s = S(x, y); + float ceil = s->ceil; + if(s->type == CHF) + ceil += (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; + return ceil; +} + +char *SkillNrToSkillName(short skillnr) +{ + if (skillnr == 0) return "best"; + else if (skillnr == 1) return "good"; + else if (skillnr == 2) return "medium"; + else if (skillnr == 3) return "worse"; + else if (skillnr == 4) return "bad"; + + return NULL; +} + +bool IsInGame(dynent *d) +{ + if (!d) return false; + + /*edit -argh + if (d->monsterstate) + { + loopv(monsters) + { + if (monsters[i] == d) + return true; + } + } + */ + //else + if (d->bIsBot) + { + loopv(bots) + { + if (bots[i] == d) + return true; + } + } + else + { + if (d == player1) + return true; + else + { + loopv(players) + { +#ifdef VANILLA_CUBE + if (!players[i] || (players[i]->state == CS_DEDHOST)) continue; +#elif defined AC_CUBE + if (!players[i]) continue; +#endif + if (players[i] == d) + return true; + } + } + } + return false; +} diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h new file mode 100644 index 00000000..1b9d4dd5 --- /dev/null +++ b/source/src/bot/bot_util.h @@ -0,0 +1,565 @@ +#ifndef BOT_UTIL_H +#define BOT_UTIL_H + +// Structure for storing traceresults +struct traceresult_s +{ + vec end; + bool collided; +}; + +long RandomLong(long from, long to); +float RandomFloat(float from, float to); +void lsrand(unsigned long initial_seed); + +void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up); +float WrapXAngle(float angle); +float WrapYZAngle(float angle); +void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, + bool SkipTags=false); +float GetDistance(vec v1, vec v2); +float Get2DDistance(vec v1, vec v2); +bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false); +bool IsValidFile(const char *szFileName); +bool FileIsOlder(const char *szFileName1, const char *szFileName2); +vec PredictPos(vec pos, vec vel, float Time); +vec Normalize(vec v); +inline void makevec(vec *v, float x, float y, float z) { v->x=x; v->y=y; v->z=z; }; +inline bool UnderWater(const vec &o) { return hdr.waterlevel>o.z-0.5f; }; +inline bool InWater(const vec &o) { return hdr.waterlevel>=o.z; }; +float GetYawDiff(float curyaw, vec v1, vec v2); +vec CrossProduct(const vec &a, const vec &b); +int GetDirection(const vec &angles, const vec &v1, const vec &v2); +float GetCubeFloor(int x, int y); +float GetCubeHeight(int x, int y); +char *SkillNrToSkillName(short skillnr); +bool IsInGame(dynent *d); + +// ================================================================== +// Code of TLinkedList - Start +// ================================================================== + +template class TLinkedList +{ +public: + struct node_s + { + C Entry; + node_s *next; + node_s *prev; + + node_s(void) : next(NULL), prev(NULL) + { + //memset(&Entry, 0, sizeof(Entry)); + }; + }; + + // member functions + + void AddNode(C entry) + { + if (!pNodeList) + { + pNodeList = new node_s; + pNodeList->Entry = entry; + pNodeList->next = NULL; + pNodeList->prev = NULL; + pLastNode = pNodeList; + iNodeCount = 1; + } + else + { + pLastNode->next = new node_s; + pLastNode->next->prev = pLastNode; + pLastNode = pLastNode->next; + pLastNode->Entry = entry; + pLastNode->next = NULL; + iNodeCount++; + } + } + + void PushNode(C Entry) + { + if (!pNodeList) + { + pNodeList = new node_s; + pNodeList->Entry = Entry; + pNodeList->next = NULL; + pNodeList->prev = NULL; + pLastNode = pNodeList; + iNodeCount = 1; + } + else + { + node_s *pNew = new node_s; + pNew->Entry = Entry; + pNew->prev = NULL; + pNew->next = pNodeList; + pNodeList->prev = pNew; + pNodeList = pNew; + iNodeCount++; + } + } + + void DeleteEntry(C Entry) + { + node_s *pNode = pNodeList; + if (!pNode) + return; + + if (pNode->Entry == Entry) // first node + { + if (pNodeList == pLastNode) + pLastNode = NULL; + + pNodeList = pNodeList->next; + if (pNodeList) + pNodeList->prev = NULL; + pNode->next = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + if (Entry == pLastNode->Entry) // last node + { + pNode = pLastNode; + pLastNode = pLastNode->prev; + pLastNode->next = NULL; + + pNode->next = NULL; + pNode->prev = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + // node is somewhere in the middle + pNode = SearchNode(Entry); + + if (!pNode) + return; + + node_s *pPrevNode = pNode->prev; + + if (!pPrevNode) + return; + + // unlink pNode + pNode->next->prev = pPrevNode; + pPrevNode->next = pNode->next; + + pNode->next = NULL; + pNode->prev = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + } + + void DeleteNode(node_s *pNode) + { + if (!pNode) + return; + + if (pNodeList == pNode) // first node + { + if (pNodeList == pLastNode) + pLastNode = pNodeList->next; + + pNodeList = pNodeList->next; + if (pNodeList) + pNodeList->prev = NULL; + pNode->next = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + if (pNode == pLastNode) // last node + { + pNode = pLastNode; + pLastNode = pLastNode->prev; + pLastNode->next = NULL; + + pNode->next = NULL; + pNode->prev = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + // node is somewhere in the middle + + node_s *pPrevNode = pNode->prev; + + if (!pPrevNode) + return; + + // unlink pNode + pNode->next->prev = pPrevNode; + pPrevNode->next = pNode->next; + + pNode->next = NULL; + pNode->prev = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + } + + void DeleteAllNodes(void) + { + node_s *pNode = pNodeList; + node_s *pTemp; + while (pNode != NULL) + { + pTemp = pNode; + pNode = pNode->next; + pTemp->next = NULL; + pTemp->prev = NULL; + delete pTemp; + } + pNodeList = pLastNode = NULL; + iNodeCount = 0; + } + + void Reset(void) // Special case, doesn't delete existing nodes + { + pNodeList = pLastNode = NULL; + iNodeCount = 0; + } + + node_s *SearchNode(C Entry) + { + node_s *pNode = pNodeList; + while(pNode) + { + if (pNode->Entry == Entry) + return pNode; + pNode = pNode->next; + } + return NULL; + } + + C Pop(void) + { + if (!pNodeList) + return static_cast(NULL); + + C Entry = pNodeList->Entry; + DeleteNode(pNodeList); + return Entry; + } + + node_s *GetFirst(void) { return pNodeList; }; + node_s *GetLast(void) { return pLastNode; }; + + void EditEntry(C OrigEntry, C NewVal) + { + node_s *pNode = SearchNode(OrigEntry); + + if (pNode) + pNode->Entry = NewVal; + } + + bool IsInList(C Entry) + { + return (SearchNode(Entry) != NULL); + } + + bool Empty(void) { return (pNodeList == NULL); }; + int NodeCount(void) { return iNodeCount; }; + + + // construction/destruction + TLinkedList(void) + { + pNodeList = NULL; + pLastNode = NULL; + iNodeCount = 0; + }; + + ~TLinkedList(void) + { + DeleteAllNodes(); + }; + +private: + node_s *pNodeList; + node_s *pLastNode; + int iNodeCount; +}; + +// ================================================================== +// Code of TLinkedList - End +// ================================================================== + +// ================================================================== +// Code of TPriorList - Begin +// ================================================================== + +template class TPriorList +{ +public: + struct node_s + { + C Entry; + D Priority; + node_s *next; + + node_s(C Ent, D Prior) : Entry(Ent), Priority(Prior), next(NULL) {}; + }; + + TPriorList(void) : pHeadNode(NULL), pLastNode(NULL) {}; + ~TPriorList(void) { Clear(); }; + + void AddEntry(C Entry, D Prior) + { + if (!pHeadNode) + { + pHeadNode = new node_s(Entry, Prior); + pLastNode = pHeadNode; + iNodeCount=1; + } + else + { + iNodeCount++; + node_s *pNew = new node_s(Entry, Prior); + node_s *pNode = pHeadNode; + node_s *pPrev = NULL; + + while(pNode) + { + if (Prior < pNode->Priority) + { + if (!pPrev) + { + pNew->next = pNode; + pHeadNode = pNew; + } + else + { + pPrev->next = pNew; + pNew->next = pNode; + } + break; + } + pPrev = pNode; + pNode = pNode->next; + } + + if (!pNode) + { + pLastNode = pNew; + if (pPrev) + pPrev->next = pNew; + } + } + } + + C Pop(void) + { + if (!pHeadNode) + return static_cast(NULL); + + C Entry = pHeadNode->Entry; + DeleteNode(pHeadNode); + return Entry; + } + + void Clear(void) + { + node_s *pTemp; + while(pHeadNode) + { + pTemp = pHeadNode; + pHeadNode = pHeadNode->next; + delete pTemp; + } + + pHeadNode = pLastNode = NULL; + } + + bool IsInList(C Entry, D Prior) + { + node_s *pNode = pHeadNode; + while(pNode) + { + if (pNode->Entry == Entry) + return true; + + if (Prior < pNode->Priority) + return false; + + pNode = pNode->next; + } + + return false; + } + + bool Empty(void) { return (pHeadNode == NULL); } + node_s *GetFirst(void) { return pHeadNode; } +private: + node_s *pHeadNode; + node_s *pLastNode; + int iNodeCount; + + node_s *GetPrevNode(node_s *pNode) + { + node_s *pTemp = pHeadNode; + while(pTemp) + { + if (pTemp->next == pNode) + return pTemp; + pTemp = pTemp->next; + } + + return NULL; + } + + void DeleteNode(node_s *pNode) + { + if (!pNode) + return; + + if (pHeadNode == pNode) // first node + { + if (pHeadNode == pLastNode) + pLastNode = pHeadNode->next; + + pHeadNode = pHeadNode->next; + pNode->next = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + if (pNode == pLastNode) // last node + { + pNode = pLastNode; + pLastNode->next = NULL; + + pNode->next = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + return; + } + + // node is somewhere in the middle + + node_s *pPrevNode = GetPrevNode(pNode); + if (!pPrevNode) + return; + + // unlink pNode + pPrevNode->next = pNode->next; + pNode->next = NULL; + delete pNode; + pNode = NULL; + iNodeCount--; + } +}; + +// ================================================================== +// Code of TPriorList - End +// ================================================================== + + +// ================================================================== +// Code of TMultiChoice - Begin +// ================================================================== + +template class TMultiChoice +{ + struct SMultiChoice + { + int MinVal; + int MaxVal; + C Choice; + SMultiChoice(void) : MinVal(0), MaxVal(0){}; + }; + + int TotalVal; + TLinkedList *pChoiceList; + +public: + TMultiChoice(void) : TotalVal(0) // Constructor + { + pChoiceList = new TLinkedList; + }; + + ~TMultiChoice(void) // Destructor + { + while(pChoiceList->Empty() == false) + { + SMultiChoice *pEntry = pChoiceList->Pop(); + if (pEntry) + delete pEntry; + else + break; + } + delete pChoiceList; + pChoiceList = NULL; + } + + void Insert(C Choice, short Percent = 50) + { + if (Percent == 0) + return; + + SMultiChoice *pChoiceEntry = new SMultiChoice; + + pChoiceEntry->MinVal = TotalVal; + pChoiceEntry->MaxVal = TotalVal + Percent; + pChoiceEntry->Choice = Choice; + + pChoiceList->AddNode(pChoiceEntry); + + TotalVal += Percent; + }; + + bool FindSelection(SMultiChoice *MS, int Choice) + { + if ((Choice >= MS->MinVal) && (Choice < MS->MaxVal)) + { + return true; + } + return false; + } + + void ClearChoices(void) + { + TotalVal = 0; + while(pChoiceList->Empty() == false) + delete pChoiceList->Pop(); + } + + bool GetSelection(C &Var) + { + int Choice = RandomLong(0, (TotalVal - 1)); + typename TLinkedList::node_s *pNode = pChoiceList->GetFirst(); + + while(pNode) + { + if ((Choice >= pNode->Entry->MinVal) && (Choice < pNode->Entry->MaxVal)) + { + Var = pNode->Entry->Choice; + return true; + } + pNode = pNode->next; + } + + return false; + } +}; + +// ================================================================== +// Code of TMutiChoice - End +// ================================================================== + +#endif diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp new file mode 100644 index 00000000..e928dce5 --- /dev/null +++ b/source/src/bot/bot_waypoint.cpp @@ -0,0 +1,3259 @@ +// +// C++ Implementation: bot_waypoint +// +// Description: Waypoint class for bots +// +// +// Author: Rick +// + +#include "../cube.h" + +vec v_debuggoal = g_vecZero; + +#if defined AC_CUBE +CACWaypointClass WaypointClass; +#elif defined VANILLA_CUBE +CCubeWaypointClass WaypointClass; +#endif + +// Waypoint class begin + +CWaypointClass::CWaypointClass(void) : m_bDrawWaypoints(false), m_bDrawWPPaths(true), + m_bAutoWaypoint(false), m_bAutoPlacePaths(true), + m_bDrawWPText(false), m_vLastCreatedWP(g_vecZero), + m_bFlooding(false), m_bFilteringNodes(false), + m_iFloodStartTime(0), m_iCurFloodX(0), + m_iCurFloodY(0), m_iFloodSize(0), + m_iFilteredNodes(0), m_iWaypointCount(0) +{ + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + while(!m_Waypoints[i][j].Empty()) + delete m_Waypoints[i][j].Pop(); + } + } + + m_szMapName[0] = 0; +} + +void CWaypointClass::Init() +{ + Clear(); // Free previously allocated path memory + + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + while(!m_Waypoints[i][j].Empty()) + delete m_Waypoints[i][j].Pop(); + } + } + + m_fPathDrawTime = 0.0; + m_iWaypointCount = 0; + m_vLastCreatedWP = g_vecZero; +} + +void CWaypointClass::Clear() +{ + for(int i=0;iConnectedWPs.DeleteAllNodes(); + p->ConnectedWPsWithMe.DeleteAllNodes(); + BotManager.DelWaypoint(p); + delete p; + } + } + } +} + +// returns true if waypoints succesfull loaded +bool CWaypointClass::LoadWaypoints() +{ + FILE *bfp; + char szWPFileName[64]; + char filename[256]; + waypoint_header_s header; + short num, triggernr, yaw; + int i, j, flags; + vec from, to; + + strcpy(szWPFileName, m_szMapName); + strcat(szWPFileName, ".wpt"); + + BotManager.MakeBotFileName(szWPFileName, "waypoints", NULL, filename); + + bfp = fopen(filename, "rb"); + + BotManager.m_sCurrentTriggerNr = -1; + + // if file exists, read the waypoint structure from it + if (bfp != NULL) + { + fread(&header, sizeof(header), 1, bfp); + + header.szFileType[10] = 0; + if (strcmp(header.szFileType, "cube_bot") == 0) + { + header.szMapName[31] = 0; + + if (strcmp(header.szMapName, m_szMapName) == 0) + { + Init(); // remove any existing waypoints + + // Check which waypoint file version this is, handle each of them different + if (header.iFileVersion == 1) + { + // First version, works with an big array and has a limit + + waypoint_version_1_s WPs[1024]; + int path_index; + + m_iWaypointCount = header.iWPCount; + for (i=0; i < header.iWPCount; i++) + { + fread(&WPs[i], sizeof(WPs[0]), 1, bfp); + WPs[i].ConnectedWPs.Reset(); // We get garbage when we read this from + // a file, so just clear it + + // Convert to new waypoint structure + node_s *pNode = new node_s(WPs[i].v_origin, WPs[i].iFlags, 0); + + short x, y; + GetNodeIndexes(pNode->v_origin, &x, &y); + + m_Waypoints[x][y].AddNode(pNode); + BotManager.AddWaypoint(pNode); + } + + // read and add waypoint paths... + for (i=0; i < m_iWaypointCount; i++) + { + // read the number of paths from this node... + fread(&num, sizeof(num), 1, bfp); + + // See which waypoint the current is + node_s *pCurrent = GetWaypointFromVec(WPs[i].v_origin); + + if (!pCurrent) + { + conoutf("Error: NULL path in waypoint file"); + continue; + } + + for (j=0; j < num; j++) + { + fread(&path_index, sizeof(path_index), 1, bfp); + + // See which waypoint this is + node_s *pTo = GetWaypointFromVec(WPs[path_index].v_origin); + + if (!pTo) + { + conoutf("Error: NULL path in waypoint file"); + continue; + } + + AddPath(pCurrent, pTo); + } + } + conoutf("Old waypoint version(%d) converted to new version(%d)", + header.iFileVersion, WAYPOINT_VERSION); + conoutf("Use the wpsave command to convert permently"); + + } + else if (header.iFileVersion == 2) + { + m_iWaypointCount = header.iWPCount; + + for (i=0; i < header.iWPCount; i++) + { + fread(&from, sizeof(from), 1, bfp); // Read origin + fread(&flags, sizeof(flags), 1, bfp); // Read waypoint flags + fread(&triggernr, sizeof(triggernr), 1, bfp); // Read trigger nr + fread(&yaw, sizeof(yaw), 1, bfp); // Read target yaw + + node_s *pNode = new node_s(from, flags, triggernr, yaw); + + short x, y; + GetNodeIndexes(pNode->v_origin, &x, &y); + + m_Waypoints[x][y].AddNode(pNode); + BotManager.AddWaypoint(pNode); + + if ((BotManager.m_sCurrentTriggerNr == -1) || + (triggernr < BotManager.m_sCurrentTriggerNr)) + BotManager.m_sCurrentTriggerNr = triggernr; + } + + for (i=0; i < header.iWPCount; i++) + { + // read the number of paths from this node... + fread(&num, sizeof(num), 1, bfp); + fread(&from, sizeof(from), 1, bfp); + + if (!num) + continue; + + node_s *pCurrent = GetWaypointFromVec(from); + + if (!pCurrent) + { + conoutf("Error: NULL path in waypoint file"); + + for(j=0;j WAYPOINT_VERSION) + { + conoutf("Error: Waypoint file is newer then current, upgrade cube bot."); + fclose(bfp); + return false; + } + else + { + conoutf("Error: Unknown waypoint version for cube bot"); + fclose(bfp); + return false; + } + } + else + { + conoutf("Waypoints aren't for map %s but for map %s", m_szMapName, + header.szMapName); + fclose(bfp); + return false; + } + } + else + { + conoutf("Waypoint file isn't for cube bot"); + //conoutf("Header FileType: %s", int(header.szFileType)); + + fclose(bfp); + return false; + } + + fclose(bfp); + + //RouteInit(); + } + else + { + conoutf("Waypoint file %s does not exist", (filename)); + return false; + } + + if (BotManager.m_sCurrentTriggerNr == -1) + BotManager.m_sCurrentTriggerNr = 0; + + ReCalcCosts(); + + conoutf("Waypoints for map %s loaded", (m_szMapName)); + return true; +} + +void CWaypointClass::SaveWaypoints() +{ + char filename[256]; + char mapname[64]; + waypoint_header_s header; + short int num; + TLinkedList::node_s *pPath; + + strcpy(header.szFileType, "cube_bot"); + + header.iFileVersion = WAYPOINT_VERSION; + + header.iFileFlags = 0; // not currently used + + header.iWPCount = m_iWaypointCount; + + memset(header.szMapName, 0, sizeof(header.szMapName)); + strncpy(header.szMapName, m_szMapName, 31); + header.szMapName[31] = 0; + + strcpy(mapname, m_szMapName); + strcat(mapname, ".wpt"); + + BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename); + + FILE *bfp = fopen(filename, "wb"); + + if (!bfp) + { + conoutf("Error writing waypoint file, check if the directory \"bot/waypoint\" exists and " + "the right permissions are set"); + return; + } + + // write the waypoint header to the file... + fwrite(&header, sizeof(header), 1, bfp); + + // write the waypoint data to the file... + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); + while(p) + { + fwrite(&p->Entry->v_origin, sizeof(p->Entry->v_origin), 1, bfp); // Write origin + fwrite(&p->Entry->iFlags, sizeof(p->Entry->iFlags), 1, bfp); // Write waypoint flags + fwrite(&p->Entry->sTriggerNr, sizeof(p->Entry->sTriggerNr), 1, bfp); // Write trigger nr + fwrite(&p->Entry->sYaw, sizeof(p->Entry->sYaw), 1, bfp); // Write target yaw + + p = p->next; + } + } + } + + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); + while(p) + { + // save the waypoint paths... + + // count the number of paths from this node... + pPath = p->Entry->ConnectedWPs.GetFirst(); + num = p->Entry->ConnectedWPs.NodeCount(); + + fwrite(&num, sizeof(num), 1, bfp); // write the count + fwrite(&p->Entry->v_origin, sizeof(p->Entry->v_origin), 1, bfp); // write the origin of this path + + // now write out each path... + while (pPath != NULL) + { + fwrite(&pPath->Entry->v_origin, sizeof(pPath->Entry->v_origin), 1, bfp); + pPath = pPath->next; // go to next node in linked list + } + p = p->next; + } + } + } + + fclose(bfp); +} + +bool CWaypointClass::LoadWPExpFile() +{ + FILE *bfp; + char szWPFileName[64]; + char filename[256]; + waypoint_header_s header; + short int num; + int i, j; + vec from, to; + + if (m_iWaypointCount == 0) + return false; + + strcpy(szWPFileName, m_szMapName); + strcat(szWPFileName, ".exp"); + + BotManager.MakeBotFileName(szWPFileName, "waypoints", NULL, filename); + + bfp = fopen(filename, "rb"); + + // if file exists, read the waypoint structure from it + if (bfp != NULL) + { + fread(&header, sizeof(header), 1, bfp); + + header.szFileType[10] = 0; + if (strcmp(header.szFileType, "cube_bot") == 0) + { + header.szMapName[31] = 0; + + if (strcmp(header.szMapName, m_szMapName) == 0) + { + // Check which waypoint file version this is, handle each of them different + if (header.iFileVersion == 1) + { + for (i=0; i < header.iWPCount; i++) + { + // read the number of paths from this node... + fread(&num, sizeof(num), 1, bfp); + fread(&from, sizeof(vec), 1, bfp); + + if (!num) continue; + + node_s *pCurrent = GetWaypointFromVec(from); + + if (!pCurrent) + { + conoutf("Error: NULL node in waypoint experience file"); + continue; + } + + for (j=0; j < num; j++) + { + fread(&to, sizeof(vec), 1, bfp); + node_s *p = GetWaypointFromVec(to); + if (p) + { + pCurrent->FailedGoalList.AddNode(p); + } + } + } + } + else if (header.iFileVersion > EXP_WP_VERSION) + { + conoutf("Error: Waypoint experience file is newer then current, upgrade cube bot."); + fclose(bfp); + return false; + } + else + { + conoutf("Error: Unknown waypoint experience file version for cube bot"); + fclose(bfp); + return false; + } + } + else + { + conoutf("Waypoint experience file isn't for map %s but for map %s", (m_szMapName), + (header.szMapName)); + fclose(bfp); + return false; + } + } + else + { + conoutf("Waypoint experience file isn't for cube bot"); + //conoutf("Header FileType: %s", int(header.szFileType)); + + fclose(bfp); + return false; + } + + fclose(bfp); + + //RouteInit(); + } + else + { + conoutf("Waypoint experience file %s does not exist", (filename)); + return false; + } + + conoutf("Waypoint experience file for map %s loaded", (m_szMapName)); + return true; +} + +void CWaypointClass::SaveWPExpFile() +{ + if (!m_iWaypointCount) + return; + + char filename[256]; + char mapname[64]; + waypoint_header_s header; + short int num; + + strcpy(header.szFileType, "cube_bot"); + + header.iFileVersion = EXP_WP_VERSION; + + header.iFileFlags = 0; // not currently used + + header.iWPCount = m_iWaypointCount; + + memset(header.szMapName, 0, sizeof(header.szMapName)); + strncpy(header.szMapName, m_szMapName, 31); + header.szMapName[31] = 0; + + strcpy(mapname, m_szMapName); + strcat(mapname, ".exp"); + + BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename); + + FILE *bfp = fopen(filename, "wb"); + + if (!bfp) + { + conoutf("Error writing waypoint experience file, check if the directory \"bot/waypoint\" exists and " + "the right permissions are set"); + return; + } + + // write the waypoint header to the file... + fwrite(&header, sizeof(header), 1, bfp); + + // save the waypoint experience data... + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); + while(p) + { + // count the number of paths from this node... + TLinkedList::node_s *p2 = p->Entry->FailedGoalList.GetFirst(); + num = p->Entry->FailedGoalList.NodeCount(); + + if (!num || !p2) continue; + + fwrite(&num, sizeof(num), 1, bfp); // write the count + fwrite(&p->Entry->v_origin, sizeof(vec), 1, bfp); // write the origin of this node + + while (p2 != NULL) + { + // Write out the node which a bot can't reach with the current node + fwrite(&p2->Entry->v_origin, sizeof(vec), 1, bfp); + p2 = p2->next; // go to next node in linked list + } + p = p->next; + } + } + } + + fclose(bfp); +} + +void CWaypointClass::Think() +{ + if (dedserv) return; + +#ifdef WP_FLOOD + FloodThink(); +#endif + + if (m_bAutoWaypoint) // is auto waypoint on? + { + // find the distance from the last used waypoint + float flDistance = GetDistance(m_vLastCreatedWP, player1->o); + + bool NoLastCreatedWP = ((m_vLastCreatedWP.x == 0) && (m_vLastCreatedWP.y == 0) && + (m_vLastCreatedWP.z == 0)); + + if ((flDistance > 3.0f) || NoLastCreatedWP) + { + // check that no other reachable waypoints are nearby... + if (!GetNearestWaypoint(player1, 10.0f)) + { + AddWaypoint(player1->o, true); // place a waypoint here + } + } + } + + // Draw info for nearest waypoint? + if (m_bDrawWPText) + { + node_s *nearestwp = GetNearestWaypoint(player1, 20.0f); + +#ifdef WP_FLOOD + if (!nearestwp) + nearestwp = GetNearestFloodWP(player1, 10.0f); +#endif + + if (nearestwp) + { + char szWPInfo[256]; + sprintf(szWPInfo, "Distance nearest waypoint: %f", GetDistance(player1->o, nearestwp->v_origin)); + AddScreenText(szWPInfo); + + strcpy(szWPInfo, "Flags: "); + if (nearestwp->iFlags & W_FL_TELEPORT) + strcat(szWPInfo, "Teleport "); + if (nearestwp->iFlags & W_FL_TELEPORTDEST) + strcat(szWPInfo, "Teleport destination "); + if (nearestwp->iFlags & W_FL_JUMP) + strcat(szWPInfo, "Jump "); + if (nearestwp->iFlags & W_FL_TRIGGER) + { + char sz[32]; + sprintf(sz, "Trigger(nr %d) ", nearestwp->sTriggerNr); + strcat(szWPInfo, sz); + } + if (nearestwp->iFlags & W_FL_INTAG) + strcat(szWPInfo, "In tagged cube(s) "); + if (strlen(szWPInfo) == 7) + strcat(szWPInfo, "None"); + + AddScreenText(szWPInfo); + + if (nearestwp->sYaw != -1) + AddScreenText("yaw %d", nearestwp->sYaw); + + sprintf(szWPInfo, "Waypoint has %d connections", + nearestwp->ConnectedWPs.NodeCount()); + AddScreenText(szWPInfo); + AddScreenText("Base Cost: %d", nearestwp->sCost); + } + } + + if (m_bDrawWaypoints) // display the waypoints if turned on... + { + DrawNearWaypoints(); + } +} + +void CWaypointClass::DrawNearWaypoints() +{ + TLinkedList::node_s *pNode; + node_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceilf(15.0f / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + GetNodeIndexes(player1->o, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + node_s *nearestwp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + +#ifdef WP_FLOOD + if (!nearestwp) + nearestwp = GetNearestFloodWP(player1, 20.0f); +#endif + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + pNode = m_Waypoints[x][y].GetFirst(); + + while(pNode) + { + flDist = GetDistance(player1->o, pNode->Entry->v_origin); + if (flDist <= 15) + { + vec o = pNode->Entry->v_origin; + vec e = o; + o.z -= 2; + e.z += 2; + + if (pNode->Entry->iFlags & W_FL_JUMP) + { + // draw a red waypoint + linestyle(2.5f, 0xFF, 0x40, 0x40); + } + else if (nearestwp == pNode->Entry) + { + // draw a green waypoint + linestyle(2.5f, 0x40, 0xFF, 0x40); + } + else + { + // draw a blue waypoint + linestyle(2.5f, 0x40, 0x40, 0xFF); + } + + line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); + + if (flNearestDist > flDist) + { + flNearestDist = flDist; + pNearest = pNode->Entry; + } + } + + pNode = pNode->next; + } + } + } + + if (pNearest) + { + pNode = pNearest->ConnectedWPs.GetFirst(); + + linestyle(2.0f, 0xFF, 0xFF, 0xFF); + + while(pNode) + { + vec o = pNode->Entry->v_origin; + vec e = pNearest->v_origin; + + line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); + + pNode = pNode->next; + } + + // Has this waypoint an target yaw? + if (pNearest->sYaw != -1) + { + vec angles = { 0, pNearest->sYaw, 0 }; + vec from = pNearest->v_origin, end = pNearest->v_origin; + vec forward, right, up; + + from.z = end.z = (pNearest->v_origin.z-1.0f); + + AnglesToVectors(angles, forward, right, up); + vmul(forward, 5.0f); + vadd(end, forward); + + linestyle(2.0f, 0xFF, 0x40, 0x40); + line(int(from.x), int(from.y), int(from.z), int(end.x), int(end.y), int(end.z)); + } + } + +#ifndef RELEASE_BUILD + // check if path waypointing is on... + if (m_bDrawWPPaths) + { + // Draw path from first bot + if (bots.length() && bots[0] && bots[0]->pBot && bots[0]->pBot->m_pCurrentWaypoint && + bots[0]->pBot->m_pCurrentGoalWaypoint) + { + CBot *pB = bots[0]->pBot; + if (!pB->m_bCalculatingAStarPath && !pB->m_AStarNodeList.Empty()) + { + TLinkedList::node_s *pNode = pB->m_AStarNodeList.GetFirst(), *pNext; + + linestyle(2.5f, 0xFF, 0x40, 0x40); + + line((int)pB->m_pCurrentWaypoint->pNode->v_origin.x, + (int)pB->m_pCurrentWaypoint->pNode->v_origin.y, + (int)pB->m_pCurrentWaypoint->pNode->v_origin.z, + (int)pNode->Entry->pNode->v_origin.x, + (int)pNode->Entry->pNode->v_origin.y, + (int)pNode->Entry->pNode->v_origin.z); + + while(pNode && pNode->next) + { + pNext = pNode->next; + vec &v1 = pNode->Entry->pNode->v_origin; + vec &v2 = pNext->Entry->pNode->v_origin; + + line(int(v1.x), int(v1.y), int(v1.z), int(v2.x), int(v2.y), int(v2.z)); + + pNode = pNode->next; + } + } + } + } + + extern bool intermission; + if (intermission) return; + + for(int i=0;iPrevLocations.prevloc[i], g_vecZero)) continue; + vec v1 = player1->PrevLocations.prevloc[i]; + v1.z -= 1.0f; + vec v2 = v1; + v2.z += 2.0f; + linestyle(2.5f, 0xFF, 0x40, 0x40); + line(int(v1.x), int(v1.y), int(v1.z), int(v2.x), int(v2.y), int(v2.z)); + } +#endif +} + +// Add waypoint at location o, returns pointer of created wp +node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) +{ + short x, y; + int flags = 0; + if (S((int)o.x, (int)o.y)->tag) flags |= W_FL_INTAG; + + node_s *pNode = new node_s(o, flags, 0); + m_vLastCreatedWP = o; + + GetNodeIndexes(o, &x, &y); + + m_Waypoints[x][y].AddNode(pNode); + BotManager.AddWaypoint(pNode); + + m_iWaypointCount++; + + if (connectwp && m_bAutoPlacePaths) + { + // Connect new waypoint with other near waypoints. + + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); + + while(p) + { + if (p->Entry == pNode) + { + p = p->next; + continue; // skip the waypoint that was just added + } + + // check if the waypoint is reachable from the new one (one-way) + if (WPIsReachable(o, p->Entry->v_origin)) + AddPath(pNode, p->Entry); // Add a path from a to b + if (WPIsReachable(p->Entry->v_origin, pNode->v_origin)) + AddPath(p->Entry, pNode); // Add a path from b to a + + p = p->next; + } + } + } + } + + return pNode; +} + +void CWaypointClass::DeleteWaypoint(dynent *d) +{ + node_s *pWP; + + pWP = GetNearestWaypoint(d, 7.0f); + + if (!pWP) + { + conoutf("Error: Couldn´t find near waypoint"); + return; + } + + BotManager.DelWaypoint(pWP); + + // delete any paths that lead to this index... + DeletePath(pWP); + + short x, y; + GetNodeIndexes(pWP->v_origin, &x, &y); + + m_Waypoints[x][y].DeleteEntry(pWP); + + pWP->ConnectedWPs.DeleteAllNodes(); + pWP->ConnectedWPsWithMe.DeleteAllNodes(); + + m_iWaypointCount--; + delete pWP; +} + +void CWaypointClass::AddPath(node_s *pWP1, node_s *pWP2) +{ + pWP1->ConnectedWPs.AddNode(pWP2); + pWP2->ConnectedWPsWithMe.AddNode(pWP1); +} + +// Deletes all paths connected to the given waypoint +void CWaypointClass::DeletePath(node_s *pWP) +{ + TLinkedList::node_s *p; + + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + p = m_Waypoints[i][j].GetFirst(); + while (p) + { + p->Entry->ConnectedWPs.DeleteEntry(pWP); + pWP->ConnectedWPsWithMe.DeleteEntry(p->Entry); + p = p->next; + } + } + } +} + +// Deletes path between 2 waypoints(1 way) +void CWaypointClass::DeletePath(node_s *pWP1, node_s *pWP2) +{ + pWP1->ConnectedWPs.DeleteEntry(pWP2); + pWP2->ConnectedWPsWithMe.DeleteEntry(pWP1); +} + +void CWaypointClass::ManuallyCreatePath(dynent *d, int iCmd, bool TwoWay) +{ + static node_s *waypoint1 = NULL; // initialized to unassigned + static node_s *waypoint2 = NULL; // initialized to unassigned + + if (iCmd == 1) // assign source of path + { + waypoint1 = GetNearestWaypoint(d, 7.0f); + + if (!waypoint1) + { + conoutf("Error: Couldn't find near waypoint"); + return; + } + + return; + } + + if (iCmd == 2) // assign dest of path and make path + { + if (!waypoint1) + { + conoutf("Error: First waypoint unset"); + return; + } + + waypoint2 = GetNearestWaypoint(d, 7.0f); + + if (!waypoint2) + { + conoutf("Error: Couldn't find near waypoint"); + return; + } + + AddPath(waypoint1, waypoint2); + + if (TwoWay) + AddPath(waypoint2, waypoint1); + } +} + +void CWaypointClass::ManuallyDeletePath(dynent *d, int iCmd, bool TwoWay) +{ + static node_s *waypoint1 = NULL; // initialized to unassigned + static node_s *waypoint2 = NULL; // initialized to unassigned + + if (iCmd == 1) // assign source of path + { + waypoint1 = GetNearestWaypoint(d, 7.0f); + + if (!waypoint1) + { + conoutf("Error: Couldn't find near waypoint"); + return; + } + + return; + } + + if (iCmd == 2) // assign dest of path and delete path + { + if (!waypoint1) + { + conoutf("Error: First waypoint unset"); + return; + } + + waypoint2 = GetNearestWaypoint(d, 7.0f); + + if (!waypoint2) + { + conoutf("Error: Couldn't find near waypoint"); + return; + } + + DeletePath(waypoint1, waypoint2); + + if (TwoWay) + DeletePath(waypoint2, waypoint1); + } +} + +bool CWaypointClass::WPIsReachable(vec from, vec to) +{ + traceresult_s tr; + float curr_height, last_height; + + float distance = GetDistance(from, to); + + // is the destination close enough? + if (distance < REACHABLE_RANGE) + { + if (IsVisible(from, to)) + { + if (UnderWater(from) && UnderWater(to)) + { + // No need to worry about heights in water + return true; + } +/* + if (to.z > (from.z + JUMP_HEIGHT)) + { + vec v_new_src = to; + vec v_new_dest = to; + + v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f); + + // check if we didn't hit anything, if so then it's in mid-air + if (::IsVisible(v_new_src, v_new_dest, NULL)) + { + conoutf("to is in midair"); + debugbeam(from, to); + return false; // can't reach this one + } + } +*/ + + // check if distance to ground increases more than jump height + // at points between from and to... + + vec v_temp = to; vsub(v_temp, from); + vec v_direction = Normalize(v_temp); // 1 unit long + vec v_check = from; + vec v_down = from; + + v_down.z = v_down.z - 100.0f; // straight down + + TraceLine(v_check, v_down, NULL, false, &tr); + + // height from ground + last_height = GetDistance(v_check, tr.end); + + distance = GetDistance(to, v_check); // distance from goal + + while (distance > 2.0f) + { + // move 2 units closer to the goal + v_temp = v_direction; + vmul(v_temp, 2.0f); + vadd(v_check, v_temp); + + v_down = v_check; + v_down.z = v_down.z - 100.0f; + + TraceLine(v_check, v_down, NULL, false, &tr); + + curr_height = GetDistance(v_check, tr.end); + + // is the difference in the last height and the current height + // higher that the jump height? + if ((last_height - curr_height) >= JUMP_HEIGHT) + { + // can't get there from here... + //conoutf("traces failed to to"); + return false; + } + + last_height = curr_height; + + distance = GetDistance(to, v_check); // distance from goal + } + + return true; + } + } + + return false; +} + +node_s *CWaypointClass::GetNearestWaypoint(vec v_src, float flRange) +{ + TLinkedList::node_s *pNode; + node_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + GetNodeIndexes(v_src, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + pNode = m_Waypoints[x][y].GetFirst(); + + while(pNode) + { + flDist = GetDistance(v_src, pNode->Entry->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (IsVisible(v_src, pNode->Entry->v_origin, NULL)) + { + pNearest = pNode->Entry; + flNearestDist = flDist; + } + } + + pNode = pNode->next; + } + } + } + return pNearest; +} + +node_s *CWaypointClass::GetNearestTriggerWaypoint(vec v_src, float flRange) +{ + TLinkedList::node_s *pNode; + node_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + GetNodeIndexes(v_src, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + pNode = m_Waypoints[x][y].GetFirst(); + + while(pNode) + { + if ((pNode->Entry->iFlags & W_FL_FLOOD) || !(pNode->Entry->iFlags & W_FL_TRIGGER)) + { + pNode = pNode->next; + continue; + } + + flDist = GetDistance(v_src, pNode->Entry->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (IsVisible(v_src, pNode->Entry->v_origin, NULL)) + { + pNearest = pNode->Entry; + flNearestDist = flDist; + } + } + + pNode = pNode->next; + } + } + } + return pNearest; +} + +node_s *CWaypointClass::GetWaypointFromVec(const vec &v_src) +{ + static TLinkedList::node_s *pNode; + static short x, y; + + GetNodeIndexes(v_src, &x, &y); + + pNode = m_Waypoints[x][y].GetFirst(); + + while(pNode) + { + if (vis(pNode->Entry->v_origin, v_src)) + return pNode->Entry; + + pNode = pNode->next; + } + return NULL; +} + +void CWaypointClass::CalcCost(node_s *pNode) +{ + float flCost = 10.0f; + + // Check nearby cubes... + int x = int(pNode->v_origin.x); + int y = int(pNode->v_origin.y); + int a, b, row; + + for (row=0;row<=1;row++) + { + if (row==0) b = y - 6; + else b = y + 6; + + for (a=(x-6);a<=(x+6);a++) + { + if (OUTBORD(a, b)) continue; + + vec to = { a, b, GetCubeFloor(a, b) + 1.0f }; + + // See if there is a obstacle(cube or mapmodel) nearby + traceresult_s tr; + TraceLine(pNode->v_origin, to, NULL, false, &tr); + if (tr.collided) + { + float flFraction = (GetDistance(pNode->v_origin, tr.end) / + GetDistance(pNode->v_origin, to)); + flCost += (1.0f-flFraction)*0.5f; + } + + if ((abs(a) > 4) || (abs(b) > 4)) continue; + + vec from = to; + to.z -= (JUMP_HEIGHT - 1.0f); + TraceLine(from, to, NULL, false, &tr); + if (!tr.collided) + flCost += 0.5f; + } + + if (row==0) a = x - 6; + else a = x + 6; + + for (b=(y-6);b<=(y+6);b++) + { + if (OUTBORD(a, b)) continue; + + vec to = { a, b, GetCubeFloor(a, b) + 1.0f }; + + // See if there is a obstacle(cube or mapmodel) nearby + traceresult_s tr; + TraceLine(pNode->v_origin, to, NULL, false, &tr); + if (tr.collided) + { + float flFraction = (GetDistance(pNode->v_origin, tr.end) / + GetDistance(pNode->v_origin, to)); + flCost += (1.0f-flFraction)*0.5f; + } + + if ((abs(a) > 4) || (abs(b) > 4)) continue; + + vec from = to; + to.z -= (JUMP_HEIGHT - 1.0f); + TraceLine(from, to, NULL, false, &tr); + if (!tr.collided) + flCost += 0.5f; + } + } + + if (UnderWater(pNode->v_origin)) // Water is annoying + flCost += 5.0f; + + pNode->sCost = (short)flCost; +} + +void CWaypointClass::ReCalcCosts(void) +{ + loopi(MAX_MAP_GRIDS) + { + loopj(MAX_MAP_GRIDS) + { + TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); + while(p) + { + CalcCost(p->Entry); + p = p->next; + } + } + } +} + +#ifdef WP_FLOOD + +void CWaypointClass::StartFlood() +{ + if (m_bFlooding) return; + + conoutf("Starting flood, this may take a while on large maps...."); + m_bFlooding = true; + m_iFloodStartTime = SDL_GetTicks(); + m_iCurFloodX = m_iCurFloodY = MINBORD; + m_iFloodSize = 0; +} + +void CWaypointClass::FloodThink() +{ + if (!m_bFlooding) return; + + static int x, y, count; + count = 0; + + if (!m_bFilteringNodes) + { + // loop through ALL cubes and check if we should add a waypoint here + for (x=m_iCurFloodX; x<(ssize-MINBORD); x+=4) + { + if (count >= 3) + { + AddScreenText("Flooding map with waypoints... %.2f %%", + ((float)x / float(ssize-MINBORD)) * 100.0f); + m_iCurFloodX = x; + return; + } + + count++; + + for (y=MINBORD; y<(ssize-MINBORD); y+=4) + { + vec from = { x, y, GetCubeFloor(x, y)+2.0f }; + bool bFound = CanPlaceNodeHere(from); + + if (!bFound) + { + for (int a=x-2;a<=(x+2);a++) + { + for (int b=y-2;b<=(y+2);b++) + { + if (OUTBORD(a, b)) continue; + if ((a==x) && (b==y)) continue; + makevec(&from, a, b, GetCubeFloor(a, b) + 2.0f); + if (CanPlaceNodeHere(from)) + { + bFound = true; + break; + } + } + + if (bFound) break; + } + } + + if (!bFound) continue; + + // Add WP + int flags = W_FL_FLOOD; + if (S((int)from.x, (int)from.y)->tag) flags |= W_FL_INTAG; + + node_s *pWP = new node_s(from, flags, 0); + + short i, j; + GetNodeIndexes(from, &i, &j); + m_Waypoints[i][j].PushNode(pWP); + BotManager.AddWaypoint(pWP); + m_iFloodSize += sizeof(node_s); + m_iWaypointCount++; + + // Connect with other nearby nodes + ConnectFloodWP(pWP); + } + } + } + + if (!m_bFilteringNodes) + { + m_bFilteringNodes = true; + m_iCurFloodX = m_iCurFloodY = 0; + m_iFilteredNodes = 0; + } + + count = 0; + + // Filter all nodes which aren't connected to any other nodes + for (x=m_iCurFloodX;x 3) + { + AddScreenText("Filtering useless waypoints and"); + AddScreenText("adding costs... %.2f %%", ((float)x / float(MAX_MAP_GRIDS)) * 100.0f); + m_iCurFloodX = x; + return; + } + + count++; + + for (y=0;y::node_s *pNode = m_Waypoints[x][y].GetFirst(), *pTemp; + while(pNode) + { + if (pNode->Entry->ConnectedWPs.Empty() || + pNode->Entry->ConnectedWPsWithMe.Empty()) + { + BotManager.DelWaypoint(pNode->Entry); + pTemp = pNode; + pNode = pNode->next; + delete pTemp->Entry; + m_Waypoints[x][y].DeleteNode(pTemp); + m_iFilteredNodes++; + m_iFloodSize -= sizeof(node_s); + m_iWaypointCount--; + continue; + } + else + CalcCost(pNode->Entry); + pNode = pNode->next; + } + } + } + + // Done with flooding + m_bFlooding = false; + m_bFilteringNodes = false; + + //ReCalcCosts(); + BotManager.PickNextTrigger(); + + m_iFloodSize += sizeof(m_Waypoints); + conoutf("Added %d wps in %d milliseconds", m_iWaypointCount, SDL_GetTicks()-m_iFloodStartTime); + conoutf("Filtered %d wps", m_iFilteredNodes); + + BotManager.CalculateMaxAStarCount(); + + char szSize[64]; + sprintf(szSize, "Total size: %.2f Kb", float(m_iFloodSize)/1024.0f); + conoutf(szSize); +} + +bool CWaypointClass::CanPlaceNodeHere(const vec &from) +{ + static short x, y, a, b; + static traceresult_s tr; + static vec to, v1, v2; + + x = short(from.x); + y = short(from.y); + + sqr *s = S(x, y); + if (SOLID(s)) + { + return false; + } + + if (fabs((float)(s->ceil - s->floor)) < player1->radius) + { + return false; + } + + if (GetNearestFloodWP(from, 2.0f, NULL)) return false; + + for (a=(x-1);a<=(x+1);a++) + { + for (b=(y-1);b<=(y+1);b++) + { + if ((x==a) && (y==b)) continue; + if (OUTBORD(a, b)) return false; + makevec(&v1, a, b, from.z); + v2 = v1; + v2.z -= 1000.0f; + + TraceLine(v1, v2, NULL, false, &tr, true); + to = tr.end; + + if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1))) + { + if (!tr.collided || (to.z < (from.z-4.0f))) + { + return false; + } + } + + to.z += 2.0f; + + if (from.z < (to.z-JUMP_HEIGHT)) + { + return false; + } + + TraceLine(from, to, NULL, false, &tr, true); + if (tr.collided) + return false; + } + } + + return true; +} + +void CWaypointClass::ConnectFloodWP(node_s *pWP) +{ + if (!pWP) return; + + static float flRange; + static TLinkedList::node_s *pNode; + static short i, j, MinI, MaxI, MinJ, MaxJ, x, y, Offset; + static float flDist; + static node_s *p; + + // Calculate range, based on distance to nearest node + p = GetNearestFloodWP(pWP->v_origin, 15.0f, pWP, true); + if (p) + { + flDist = GetDistance(pWP->v_origin, p->v_origin); + flRange = min(flDist+2.0f, 15.0f); + if (flRange < 5.0f) flRange = 5.0f; + } + else + return; + + Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + + GetNodeIndexes(pWP->v_origin, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (x=MinI;x<=MaxI;x++) + { + for(y=MinJ;y<=MaxJ;y++) + { + pNode = m_Waypoints[x][y].GetFirst(); + + while(pNode) + { + if (pNode->Entry == pWP) + { + pNode = pNode->next; + continue; + } + + flDist = GetDistance(pWP->v_origin, pNode->Entry->v_origin); + if (flDist <= flRange) + { + if (IsVisible(pWP->v_origin, pNode->Entry->v_origin, NULL, true)) + { + // Connect a with b + pWP->ConnectedWPs.AddNode(pNode->Entry); + pNode->Entry->ConnectedWPsWithMe.AddNode(pWP); + + // Connect b with a + pNode->Entry->ConnectedWPs.AddNode(pWP); + pWP->ConnectedWPsWithMe.AddNode(pNode->Entry); + + m_iFloodSize += (2 * sizeof(node_s *)); + } + } + + pNode = pNode->next; + } + } + } +} + +node_s *CWaypointClass::GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, + bool SkipTags) +{ + TLinkedList::node_s *p; + node_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + GetNodeIndexes(v_origin, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_Waypoints[x][y].GetFirst(); + + while(p) + { + if ((p->Entry == pIgnore) || (!(p->Entry->iFlags & W_FL_FLOOD))) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_origin, p->Entry->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (IsVisible(v_origin, p->Entry->v_origin, NULL, SkipTags)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +node_s *CWaypointClass::GetNearestTriggerFloodWP(vec v_origin, float flRange) +{ + TLinkedList::node_s *p; + node_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + GetNodeIndexes(v_origin, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_Waypoints[x][y].GetFirst(); + + while(p) + { + if (!(p->Entry->iFlags & (W_FL_FLOOD | W_FL_TRIGGER))) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_origin, p->Entry->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (IsVisible(v_origin, p->Entry->v_origin, NULL)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +void CWaypointClass::GetNodeIndexes(const vec &v_origin, short *i, short *j) +{ + // Function code by cheesy and PMB + //*i = abs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE)); + //*j = abs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE)); + //*i = (int)((v_origin.x) / ssize * MAX_MAP_GRIDS); + //*j = (int)((v_origin.y) / ssize * MAX_MAP_GRIDS); + *i = abs((int)((v_origin.x) / MAX_MAP_GRIDS)); + *j = abs((int)((v_origin.y) / MAX_MAP_GRIDS)); + + if (*i > MAX_MAP_GRIDS - 1) + *i = MAX_MAP_GRIDS - 1; + if (*j > MAX_MAP_GRIDS - 1) + *j = MAX_MAP_GRIDS - 1; +} + +#endif // WP_FLOOD +// Waypoint class end + +#if defined AC_CUBE + +// AC waypoint class begin +void CACWaypointClass::StartFlood() +{ + // UNDONE? + CWaypointClass::StartFlood(); +} + +// AC waypoint class end + +#elif defined VANILLA_CUBE + +// Cube waypoint class begin + +void CCubeWaypointClass::StartFlood() +{ + CWaypointClass::StartFlood(); + + // Add wps at triggers and teleporters and their destination + loopv(ents) + { + entity &e = ents[i]; + + if (OUTBORD(e.x, e.y)) continue; + + if (e.type == TELEPORT) + { + vec telepos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }, teledestpos = g_vecZero; + + // Find the teleport destination + int n = -1, tag = e.attr1, beenhere = -1; + for(;;) + { + n = findentity(TELEDEST, n+1); + if(n==beenhere || n<0) { conoutf("no teleport destination for tag %d", tag); break; }; + if(beenhere<0) beenhere = n; + if(ents[n].attr2==tag) + { + teledestpos.x = ents[n].x; + teledestpos.y = ents[n].y; + teledestpos.z = S(ents[n].x, ents[n].y)->floor+player1->eyeheight; + break; + } + } + + if (vis(teledestpos, g_vecZero)) continue; + + int flags = (W_FL_FLOOD | W_FL_TELEPORT); + if (S((int)telepos.x, (int)telepos.y)->tag) flags |= W_FL_INTAG; + + // Add waypoint at teleporter and teleport destination + node_s *pWP = new node_s(telepos, flags, 0); + + short i, j; + GetNodeIndexes(telepos, &i, &j); + m_Waypoints[i][j].PushNode(pWP); + BotManager.AddWaypoint(pWP); + m_iFloodSize += sizeof(node_s); + m_iWaypointCount++; + + flags = (W_FL_FLOOD | W_FL_TELEPORTDEST); + if (S((int)teledestpos.x, (int)teledestpos.y)->tag) flags |= W_FL_INTAG; + + node_s *pWP2 = new node_s(teledestpos, flags, 0); + + GetNodeIndexes(teledestpos, &i, &j); + m_Waypoints[i][j].PushNode(pWP2); + BotManager.AddWaypoint(pWP2); + m_iFloodSize += sizeof(node_s); + m_iWaypointCount++; + + // Connect the teleporter waypoint with the teleport-destination waypoint(1 way) + AddPath(pWP, pWP2); + + // Connect with other nearby nodes + ConnectFloodWP(pWP); + } + else if (e.type == CARROT) + { + vec pos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + + int flags = (W_FL_FLOOD | W_FL_TRIGGER); + if (S(e.x, e.y)->tag) flags |= W_FL_INTAG; + + node_s *pWP = new node_s(pos, flags, 0); + + short i, j; + GetNodeIndexes(pos, &i, &j); + m_Waypoints[i][j].PushNode(pWP); + BotManager.AddWaypoint(pWP); + m_iFloodSize += sizeof(node_s); + m_iWaypointCount++; + + // Connect with other nearby nodes + ConnectFloodWP(pWP); + } + else if (e.type == MAPMODEL) + { + mapmodelinfo &mmi = getmminfo(e.attr2); + if(!&mmi || !mmi.h || !mmi.rad) continue; + + float floor = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3)+mmi.h; + + float x1 = e.x - mmi.rad; + float x2 = e.x + mmi.rad; + float y1 = e.y - mmi.rad; + float y2 = e.y + mmi.rad; + + // UNDONE? + for (float x=(x1+1.0f);x<=(x2-1.0f);x++) + { + for (float y=(y1+1.0f);y<=(y2-1.0f);y++) + { + vec from = { x, y, floor+2.0f }; + if (GetNearestFloodWP(from, 2.0f, NULL)) continue; + + // Add WP + int flags = W_FL_FLOOD; + if (S((int)x, (int)y)->tag) flags |= W_FL_INTAG; + + node_s *pWP = new node_s(from, flags, 0); + + short i, j; + GetNodeIndexes(from, &i, &j); + m_Waypoints[i][j].PushNode(pWP); + BotManager.AddWaypoint(pWP); + m_iFloodSize += sizeof(node_s); + m_iWaypointCount++; + + // Connect with other nearby nodes + ConnectFloodWP(pWP); + } + } + } + } + CWaypointClass::StartFlood(); +} + +void CCubeWaypointClass::CreateWPsAtTeleporters() +{ + loopv(ents) + { + entity &e = ents[i]; + + if (e.type != TELEPORT) continue; + if (OUTBORD(e.x, e.y)) continue; + + vec telepos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }, teledestpos = g_vecZero; + + // Find the teleport destination + int n = -1, tag = e.attr1, beenhere = -1; + for(;;) + { + n = findentity(TELEDEST, n+1); + if(n==beenhere || n<0) { conoutf("no teleport destination for tag %d", tag); continue; }; + if(beenhere<0) beenhere = n; + if(ents[n].attr2==tag) + { + teledestpos.x = ents[n].x; + teledestpos.y = ents[n].y; + teledestpos.z = S(ents[n].x, ents[n].y)->floor+player1->eyeheight; + break; + } + } + + if (vis(teledestpos, g_vecZero)) continue; + + // Add waypoint at teleporter and teleport destination + node_s *telewp = AddWaypoint(telepos, false); + node_s *teledestwp = AddWaypoint(teledestpos, false); + + if (telewp && teledestwp) + { + // Connect the teleporter waypoint with the teleport-destination waypoint(1 way) + AddPath(telewp, teledestwp); + + // Flag waypoints + telewp->iFlags = W_FL_TELEPORT; + teledestwp->iFlags = W_FL_TELEPORTDEST; + } + } +} + +void CCubeWaypointClass::CreateWPsAtTriggers() +{ + loopv(ents) + { + entity &e = ents[i]; + + if (e.type != CARROT) continue; + if (OUTBORD(e.x, e.y)) continue; + + vec pos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + + node_s *wp = AddWaypoint(pos, false); + + if (wp) + { + // Flag waypoints + wp->iFlags = W_FL_TRIGGER; + } + } +} + +#endif + +// Cube waypoint class end + +// Waypoint commands begin + +void addwp(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.AddWaypoint(player1->o, true); +} + +COMMAND(addwp, ARG_NONE); + +void delwp(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.DeleteWaypoint(player1); +} + +COMMAND(delwp, ARG_NONE); + +void wpvisible(int on) +{ + WaypointClass.SetWaypointsVisible(bool(on)); +} + +COMMAND(wpvisible, ARG_1INT); + +void wpsave(void) +{ + WaypointClass.SaveWaypoints(); +} + +COMMAND(wpsave, ARG_NONE); + +void wpload(void) +{ + WaypointClass.LoadWaypoints(); +} + +COMMAND(wpload, ARG_NONE); + +void wpclear(void) +{ + WaypointClass.Clear(); +} + +COMMAND(wpclear, ARG_NONE); + +void autowp(int on) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.SetAutoWaypoint(bool(on)); +} + +COMMAND(autowp, ARG_1INT); + +void wpinfo(int on) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.SetWPInfo(bool(on)); +} + +COMMAND(wpinfo, ARG_1INT); + +void addpath1way1(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyCreatePath(player1, 1, false); +} + +COMMAND(addpath1way1, ARG_NONE); + +void addpath1way2(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyCreatePath(player1, 2, false); +} + +COMMAND(addpath1way2, ARG_NONE); + +void addpath2way1(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyCreatePath(player1, 1, true); +} + +COMMAND(addpath2way1, ARG_NONE); + +void addpath2way2(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyCreatePath(player1, 2, true); +} + +COMMAND(addpath2way2, ARG_NONE); + +void delpath1way1(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyDeletePath(player1, 1, false); +} + +COMMAND(delpath1way1, ARG_NONE); + +void delpath1way2(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyDeletePath(player1, 2, false); +} + +COMMAND(delpath1way2, ARG_NONE); + +void delpath2way1(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyDeletePath(player1, 1, true); +} + +COMMAND(delpath2way1, ARG_NONE); + +void delpath2way2(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.ManuallyDeletePath(player1, 2, true); +} + +COMMAND(delpath2way2, ARG_NONE); + +void setjumpwp(void) +{ + node_s *wp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + if (wp) + { + WaypointClass.SetWPFlags(wp, W_FL_JUMP); + } +} + +COMMAND(setjumpwp, ARG_NONE); + +void unsetjumpwp(void) +{ + node_s *wp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + if (wp) + { + WaypointClass.UnsetWPFlags(wp, W_FL_JUMP); + } +} + +COMMAND(unsetjumpwp, ARG_NONE); + +void setwptriggernr(int nr) +{ + node_s *wp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + if (wp) + { + WaypointClass.SetWPTriggerNr(wp, nr); + } +} + +COMMAND(setwptriggernr, ARG_1INT); + +void setwpyaw(void) +{ + node_s *wp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + if (wp) + { + WaypointClass.SetWPYaw(wp, short(player1->yaw)); + } +} + +COMMAND(setwpyaw, ARG_NONE); + +#ifdef WP_FLOOD +void wpflood(void) +{ + WaypointClass.StartFlood(); +} + +COMMAND(wpflood, ARG_NONE); +#endif + +#ifdef VANILLA_CUBE +// Commands specific for cube +void addtelewps(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.CreateWPsAtTeleporters(); +} + +COMMAND(addtelewps, ARG_NONE); + +void addtriggerwps(void) +{ + WaypointClass.SetWaypointsVisible(true); + WaypointClass.CreateWPsAtTriggers(); +} + +COMMAND(addtriggerwps, ARG_NONE); +#endif + +// Debug functions +#ifdef WP_FLOOD + +#ifndef RELEASE_BUILD +void botsheadtome(void) +{ + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + + bots[i]->pBot->GoToDebugGoal(player1->o); + } +} + +COMMAND(botsheadtome, ARG_NONE); + +void setdebuggoal(void) { v_debuggoal = player1->o; }; +COMMAND(setdebuggoal, ARG_NONE); + +void botsheadtodebuggoal(void) +{ + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + + bots[i]->pBot->GoToDebugGoal(v_debuggoal); + } +} + +COMMAND(botsheadtodebuggoal, ARG_NONE); + +#endif // RELEASE_BUILD + +#endif // WP_FLOOD + +// End debug functions +// Waypoint commands end + + +// Bot class begin + +bool CBot::FindWaypoint() +{ + waypoint_s *wp, *wpselect; + int index; + float distance, min_distance[3]; + waypoint_s *min_wp[3]; + + for (index=0; index < 3; index++) + { + min_distance[index] = 9999.0; + min_wp[index] = NULL; + } + + TLinkedList::node_s *pNode = m_pCurrentWaypoint->pNode->ConnectedWPs.GetFirst(); + + while (pNode) + { + if ((pNode->Entry->iFlags & W_FL_INTAG) && + SOLID(S((int)pNode->Entry->v_origin.x, (int)pNode->Entry->v_origin.y))) + { + pNode = pNode->next; + continue; + } + + wp = GetWPFromNode(pNode->Entry); + if (!wp) + { + pNode = pNode->next; + continue; + } + + // if index is not a current or recent previous waypoint... + if ((wp != m_pCurrentWaypoint) && + (wp != m_pPrevWaypoints[0]) && + (wp != m_pPrevWaypoints[1]) && + (wp != m_pPrevWaypoints[2]) && + (wp != m_pPrevWaypoints[3]) && + (wp != m_pPrevWaypoints[4])) + { + // find the distance from the bot to this waypoint + distance = GetDistance(wp->pNode->v_origin); + + if (distance < min_distance[0]) + { + min_distance[2] = min_distance[1]; + min_wp[2] = min_wp[1]; + + min_distance[1] = min_distance[0]; + min_wp[1] = min_wp[0]; + + min_distance[0] = distance; + min_wp[0] = wp; + } + else if (distance < min_distance [1]) + { + min_distance[2] = min_distance[1]; + min_wp[2] = min_wp[1]; + + min_distance[1] = distance; + min_wp[1] = wp; + } + else if (distance < min_distance[2]) + { + min_distance[2] = distance; + min_wp[2] = wp; + } + } + pNode = pNode->next; + } + + wpselect = NULL; + + // about 20% of the time choose a waypoint at random + // (don't do this any more often than every 10 seconds) + + if ((RandomLong(1, 100) <= 20) && (m_iRandomWaypointTime <= lastmillis)) + { + m_iRandomWaypointTime = lastmillis + 10000; + + if (min_wp[2]) + index = RandomLong(0, 2); + else if (min_wp[1]) + index = RandomLong(0, 1); + else if (min_wp[0]) + index = 0; + else + return false; // no waypoints found! + + wpselect = min_wp[index]; + } + else + { + // use the closest waypoint that has been recently used + wpselect = min_wp[0]; + } + + if (wpselect) // was a waypoint found? + { + m_pPrevWaypoints[4] = m_pPrevWaypoints[3]; + m_pPrevWaypoints[3] = m_pPrevWaypoints[2]; + m_pPrevWaypoints[2] = m_pPrevWaypoints[1]; + m_pPrevWaypoints[1] = m_pPrevWaypoints[0]; + m_pPrevWaypoints[0] = m_pCurrentWaypoint; + + SetCurrentWaypoint(wpselect); + return true; + } + + return false; // couldn't find a waypoint +} + +bool CBot::HeadToWaypoint() +{ + if (!m_pCurrentWaypoint) + return false; // Can't head to waypoint + + bool Touching = false; + float WPDist = GetDistance(m_pCurrentWaypoint->pNode->v_origin); + +#ifndef RELEASE_BUILD + if (m_pCurrentGoalWaypoint && vis(m_vGoal, g_vecZero)) + condebug("Warning: m_vGoal unset"); +#endif + + // did the bot run past the waypoint? (prevent the loop-the-loop problem) + if ((m_fPrevWaypointDistance > 1.0) && (WPDist > m_fPrevWaypointDistance) && + (WPDist <= 5.0f)) + Touching = true; + // bot needs to be close for jump and trigger waypoints + else if ((m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) || + (m_pCurrentWaypoint->pNode->iFlags & W_FL_TRIGGER)) + Touching = (WPDist <= 1.5f); + else if (m_pCurrentWaypoint->pNode->iFlags & W_FL_TELEPORT) + Touching = (WPDist <= 4.0f); + // are we close enough to a target waypoint... + else if (WPDist <= 3.0f) + { + if (!m_pCurrentGoalWaypoint || (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) || + IsVisible(m_vGoal) || (WPDist <= 1.5f)) + Touching = true; + // If the bot has a goal check if he can see his next wp + if (m_pCurrentGoalWaypoint && (m_pCurrentGoalWaypoint != m_pCurrentWaypoint) && + !m_AStarNodeList.Empty() && (WPDist >= 1.0f) && + !IsVisible(m_AStarNodeList.GetFirst()->Entry->pNode->v_origin)) + Touching = false; + } + + // save current distance as previous + m_fPrevWaypointDistance = WPDist; + + // Reached the waypoint? + if (Touching) + { + // Does this waypoint has a targetyaw? + if (m_pCurrentWaypoint->pNode->sYaw != -1) + { + // UNDONE: Inhuman + m_pMyEnt->yaw = m_pMyEnt->targetyaw = m_pCurrentWaypoint->pNode->sYaw; + } + + // Reached a jump waypoint? + if (m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) + m_pMyEnt->jumpnext = true; + + m_fPrevWaypointDistance = 0.0f; + + // Does the bot has a goal? + if (m_pCurrentGoalWaypoint) + { + if (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) + { + if (m_AStarNodeList.Empty()) + { + if (!AStar()) + { + // Bot is calculating a new path, just stand still for now + ResetMoveSpeed(); + m_iWaypointTime += 200; + return true; + } + else + { + if (m_AStarNodeList.Empty()) + { + //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); + return false; // Couldn't get a new wp to go to + } + } + } + + m_pCurrentWaypoint = m_AStarNodeList.Pop(); + + if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) + //(!(m_pCurrentWaypoint->iFlags & W_FL_TELEPORT))) + { + //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); + condebug("Next WP not visible"); + return false; + } + + SetCurrentWaypoint(m_pCurrentWaypoint); + } + else + { + // Bot reached the goal waypoint but couldn't reach the goal itself + // (otherwise we wouldn't be in this function) + //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); + return false; + } + } + else + { + short index = 4; + bool status; + + // try to find the next waypoint + while (((status = FindWaypoint()) == false) && (index > 0)) + { + // if waypoint not found, clear oldest previous index and try again + + m_pPrevWaypoints[index] = NULL; + index--; + } + + if (status == false) + { + ResetWaypointVars(); + condebug("Couldn't find new random waypoint"); + return false; + } + } + m_iWaypointHeadPauseTime = lastmillis + 75; + m_iWaypointTime += 75; + } + + // keep turning towards the waypoint... + /*if (m_pCurrentWaypoint->pNode->iFlags & W_FL_FLOOD) + {UNDONE? + vec aim = m_pCurrentWaypoint->pNode->v_origin; + aim.x+=0.5f; + aim.y+=0.5f; + AimToVec(aim); + } + else*/ + AimToVec(m_pCurrentWaypoint->pNode->v_origin); + + if (m_fYawToTurn <= 25.0f) + m_iWaypointHeadLastTurnLessTime = lastmillis; + + // Bot had to turn much for a while? + if ((m_iWaypointHeadLastTurnLessTime > 0) && + (m_iWaypointHeadLastTurnLessTime < (lastmillis - 1000))) + { + m_iWaypointHeadPauseTime = lastmillis + 200; + m_iWaypointTime += 200; + } + + if (m_iWaypointHeadPauseTime >= lastmillis) + { + m_pMyEnt->move = 0; + //conoutf("Pause in HeadToWaypoint()"); + } + else + { + // Check if bot has to jump + vec from = m_pMyEnt->o; + from.z -= (m_pMyEnt->eyeheight - 1.25f); + float flEndDist; + if (!IsVisible(from, FORWARD, 3.0f, false, &flEndDist) && + (GetDistance(from, m_pCurrentWaypoint->pNode->v_origin) > flEndDist)) + { + m_pMyEnt->jumpnext = true; + condebug("Low wall in HeadToWaypoint()"); + } + + // Check if bot has to strafe + if (m_iStrafeTime > lastmillis) + SetMoveDir(m_iMoveDir, true); + else + { + m_iStrafeTime = 0; + m_iMoveDir = DIR_NONE; + + vec forward, up, right; + AnglesToVectors(GetViewAngles(), forward, right, up); + + float flLeftDist = -1.0f, flRightDist = -1.0f; + vec dir = right; + bool bStrafe = false; + int iStrafeDir = 0; + + vmul(dir, m_pMyEnt->radius); + + // Check left + from = m_pMyEnt->o; + vsub(from, dir); + if (IsVisible(from, FORWARD, 3.0f, false, &flLeftDist)) + flLeftDist = -1.0f; + + // Check right + from = m_pMyEnt->o; + vadd(from, dir); + if (IsVisible(from, FORWARD, 3.0f, false, &flRightDist)) + flRightDist = -1.0f; + + if ((flLeftDist != -1.0f) && (flRightDist != -1.0f)) + { + if (flLeftDist < flRightDist) + { + // Strafe right + bStrafe = true; + iStrafeDir = RIGHT; + } + else if (flRightDist < flLeftDist) + { + // Strafe left + bStrafe = true; + iStrafeDir = LEFT; + } + else + { + // Randomly choose a strafe direction + bStrafe = true; + if (RandomLong(0, 1)) + iStrafeDir = LEFT; + else + iStrafeDir = RIGHT; + } + } + else if (flLeftDist != -1.0f) + { + // Strafe right + bStrafe = true; + iStrafeDir = RIGHT; + } + else if (flRightDist != -1.0f) + { + // Strafe left + bStrafe = true; + iStrafeDir = LEFT; + } + + if (bStrafe) + { + SetMoveDir(iStrafeDir, true); + m_iMoveDir = iStrafeDir; + m_iStrafeTime = lastmillis + RandomLong(30, 50); + } + } + } + + return true; +} + +// returns true when done or failure +bool CBot::HeadToGoal() +{ + // Does the bot has a goal(waypoint)? + if (m_pCurrentGoalWaypoint) + { + if (ReachedGoalWP()) + { + return false; + } + else + { + if (CurrentWPIsValid()) + { + if (m_bCalculatingAStarPath) + { + // Bot is calculating a new path, just stand still for now + ResetMoveSpeed(); + m_iWaypointTime += 200; + + // Done calculating the path? + if (AStar()) + { + if (m_AStarNodeList.Empty()) + { + return false; // Couldn't find a path + } + //else + // SetCurrentWaypoint(m_AStarNodeList.Pop()); + } + else + return true; // else just wait a little bit longer + } + //ResetMoveSpeed(); + //return true; + } + else + { + // Current waypoint isn't reachable, search new one + waypoint_s *pWP = NULL; + +#ifdef WP_FLOOD + if (m_pCurrentGoalWaypoint->pNode->iFlags & W_FL_FLOOD) + pWP = GetNearestFloodWP(8.0f); + else +#endif + pWP = GetNearestWaypoint(15.0f); + + if (!pWP || (pWP == m_pCurrentWaypoint)) + return false; + + SetCurrentWaypoint(pWP); + if (AStar()) + { + if (m_AStarNodeList.Empty()) return false; + } + else + { + m_iWaypointTime += 200; + ResetMoveSpeed(); + return true; + } + } + + //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); + } + } + else + return false; + + return HeadToWaypoint(); +} + +// return true when done calculating +bool CBot::AStar() +{ + if (!m_pCurrentGoalWaypoint || !m_pCurrentWaypoint) + { + if (m_bCalculatingAStarPath) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + } + return true; + } + + // Ideas by PMB : + // * Make locals static to speed up a bit + // * MaxCycles per frame and make it fps dependent + + static int iMaxCycles; + static int iCurrentCycles; + static short newg; + static waypoint_s *n, *n2; + static TLinkedList::node_s *pPath = NULL; + static bool bPathFailed; + + iMaxCycles = BotManager.m_iFrameTime / 10; + if (iMaxCycles < 10) iMaxCycles = 10; + //condebug("MaxCycles: %d", iMaxCycles); + iCurrentCycles = 0; + bPathFailed = false; + + if (!m_bCalculatingAStarPath) + { + if ((BotManager.m_sUsingAStarBotsCount+1) > BotManager.m_sMaxAStarBots) + { + return true; + } + + BotManager.m_sUsingAStarBotsCount++; + + CleanAStarLists(false); + + m_pCurrentWaypoint->g[0] = m_pCurrentWaypoint->g[1] = 0; + m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = NULL; + m_pCurrentGoalWaypoint->g[0] = m_pCurrentGoalWaypoint->g[1] = 0; + m_pCurrentGoalWaypoint->pParent[0] = m_pCurrentGoalWaypoint->pParent[1] = NULL; + + m_AStarNodeList.DeleteAllNodes(); + + m_AStarOpenList[0].Clear(); + m_AStarOpenList[1].Clear(); + m_AStarClosedList[0].DeleteAllNodes(); + m_AStarClosedList[1].DeleteAllNodes(); + + m_AStarOpenList[0].AddEntry(m_pCurrentWaypoint, + GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); + m_AStarOpenList[1].AddEntry(m_pCurrentGoalWaypoint, + GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); + + m_pCurrentWaypoint->bIsOpen[0] = m_pCurrentGoalWaypoint->bIsOpen[1] = true; + m_pCurrentWaypoint->bIsOpen[1] = m_pCurrentGoalWaypoint->bIsOpen[0] = false; + m_pCurrentWaypoint->bIsClosed[0] = m_pCurrentGoalWaypoint->bIsClosed[1] = false; + m_pCurrentWaypoint->bIsClosed[1] = m_pCurrentGoalWaypoint->bIsClosed[0] = false; + } + + while(!m_AStarOpenList[0].Empty()) + { + if (iCurrentCycles >= (iMaxCycles/2)) + { + m_bCalculatingAStarPath = true; + break; + } + + n = m_AStarOpenList[0].Pop(); + n->bIsOpen[0] = false; + + if (n->pNode->FailedGoalList.IsInList(m_pCurrentGoalWaypoint->pNode)) + { + bPathFailed = true; + break; // Can't make path to goal + } + + // Done with calculating + if (n == m_pCurrentGoalWaypoint) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + + while(n) + { + m_AStarNodeList.PushNode(n); + n = n->pParent[0]; + } + + CleanAStarLists(false); + + return true; + } + + pPath = n->pNode->ConnectedWPs.GetFirst(); + while(pPath) + { + if ((pPath->Entry->iFlags & W_FL_INTAG) && + SOLID(S((int)pPath->Entry->v_origin.x, (int)pPath->Entry->v_origin.y))) + { + pPath = pPath->next; + continue; + } + + n2 = GetWPFromNode(pPath->Entry); + + if (!n2) + { + pPath = pPath->next; + continue; + } + + if (n2->bIsClosed[1]) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + + while(n2) + { + m_AStarNodeList.AddNode(n2); + n2 = n2->pParent[1]; + } + + while(n) + { + m_AStarNodeList.PushNode(n); + n = n->pParent[0]; + } + + CleanAStarLists(false); + + return true; + } + + newg = n->g[0] + (short)AStarCost(n, n2); + + if ((n2->g[0] <= newg) && (n2->bIsOpen[0] || n2->bIsClosed[0])) + { + pPath = pPath->next; + continue; + } + + n2->pParent[0] = n; + n2->g[0] = newg; + n2->bIsClosed[0] = false; + + if (!n2->bIsOpen[0]) + { + m_AStarOpenList[0].AddEntry(n2, n2->g[1] + GetDistance(n2->pNode->v_origin, + m_pCurrentGoalWaypoint->pNode->v_origin)); + n2->bIsOpen[0] = true; + } + pPath = pPath->next; + } + + m_AStarClosedList[0].PushNode(n); + n->bIsClosed[0] = true; + iCurrentCycles++; + } + + if (!bPathFailed) + { + while(!m_AStarOpenList[1].Empty()) + { + if (iCurrentCycles >= iMaxCycles) + { + m_bCalculatingAStarPath = true; + return false; + } + + n = m_AStarOpenList[1].Pop(); + n->bIsOpen[1] = false; + + if (n->pNode->FailedGoalList.IsInList(m_pCurrentWaypoint->pNode)) + { + bPathFailed = true; + break; // Can't make path to goal + } + + // Done with calculating + if (n == m_pCurrentWaypoint) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + + while(n) + { + m_AStarNodeList.AddNode(n); + n = n->pParent[1]; + } + + CleanAStarLists(false); + + return true; + } + + pPath = n->pNode->ConnectedWPsWithMe.GetFirst(); + while(pPath) + { + if ((pPath->Entry->iFlags & W_FL_INTAG) && + SOLID(S((int)pPath->Entry->v_origin.x, (int)pPath->Entry->v_origin.y))) + { + pPath = pPath->next; + continue; + } + + n2 = GetWPFromNode(pPath->Entry); + + if (!n2) + { + pPath = pPath->next; + continue; + } + + if (n2->bIsClosed[0]) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + + while(n2) + { + m_AStarNodeList.PushNode(n2); + n2 = n2->pParent[0]; + } + + while(n) + { + m_AStarNodeList.AddNode(n); + n = n->pParent[1]; + } + + CleanAStarLists(false); + + return true; + } + + newg = n->g[1] + (short)AStarCost(n, n2); + + if ((n2->g[1] <= newg) && (n2->bIsOpen[1] || n2->bIsClosed[1])) + { + pPath = pPath->next; + continue; + } + + n2->pParent[1] = n; + n2->g[1] = newg; + n2->bIsClosed[1] = false; + + if (!n2->bIsOpen[1]) + { + m_AStarOpenList[1].AddEntry(n2, n2->g[1] + GetDistance(n2->pNode->v_origin, + m_pCurrentWaypoint->pNode->v_origin)); + n2->bIsOpen[1] = true; + } + pPath = pPath->next; + } + + m_AStarClosedList[1].PushNode(n); + n->bIsClosed[1] = true; + iCurrentCycles++; + } + } + + // Failed making path + condebug("Path failed"); + + CleanAStarLists(true); + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + return true; +} + +float CBot::AStarCost(waypoint_s *pWP1, waypoint_s *pWP2) +{ + // UNDONE? + return (GetDistance(pWP1->pNode->v_origin, pWP2->pNode->v_origin) * pWP2->pNode->sCost); +} + +void CBot::CleanAStarLists(bool bPathFailed) +{ + while(m_AStarOpenList[0].Empty() == false) + { + waypoint_s *p = m_AStarOpenList[0].Pop(); + p->bIsOpen[0] = p->bIsOpen[1] = false; + p->bIsClosed[0] = p->bIsClosed[1] = false; + p->pParent[0] = p->pParent[1] = NULL; + p->g[0] = p->g[1] = 0; + } + + while(m_AStarOpenList[1].Empty() == false) + { + waypoint_s *p = m_AStarOpenList[1].Pop(); + p->bIsOpen[0] = p->bIsOpen[1] = false; + p->bIsClosed[0] = p->bIsClosed[1] = false; + p->pParent[0] = p->pParent[1] = NULL; + p->g[0] = p->g[1] = 0; + } + + while(m_AStarClosedList[0].Empty() == false) + { + waypoint_s *p = m_AStarClosedList[0].Pop(); + p->bIsOpen[0] = p->bIsOpen[1] = false; + p->bIsClosed[0] = p->bIsClosed[1] = false; + p->pParent[0] = p->pParent[1] = NULL; + p->g[0] = p->g[1] = 0; + if (bPathFailed) + p->pNode->FailedGoalList.AddNode(m_pCurrentGoalWaypoint->pNode); + } + + while(m_AStarClosedList[1].Empty() == false) + { + waypoint_s *p = m_AStarClosedList[1].Pop(); + p->bIsOpen[0] = p->bIsOpen[1] = false; + p->bIsClosed[0] = p->bIsClosed[1] = false; + p->pParent[0] = p->pParent[1] = NULL; + p->g[0] = p->g[1] = 0; + if (bPathFailed) + p->pNode->FailedGoalList.AddNode(m_pCurrentWaypoint->pNode); + } +} + +void CBot::ResetWaypointVars() +{ + m_iWaypointTime = 0; + m_pCurrentWaypoint = NULL; + m_pCurrentGoalWaypoint = NULL; + m_pPrevWaypoints[0] = NULL; + m_pPrevWaypoints[1] = NULL; + m_pPrevWaypoints[2] = NULL; + m_pPrevWaypoints[3] = NULL; + m_pPrevWaypoints[4] = NULL; + m_fPrevWaypointDistance = 0; + m_iWaypointHeadLastTurnLessTime = 0; + m_iWaypointHeadPauseTime = 0; + if (m_bCalculatingAStarPath) + { + m_bCalculatingAStarPath = false; + BotManager.m_sUsingAStarBotsCount--; + } + m_AStarNodeList.DeleteAllNodes(); + CleanAStarLists(false); + m_bGoToDebugGoal = false; +} + +void CBot::SetCurrentWaypoint(node_s *pNode) +{ + waypoint_s *pWP = GetWPFromNode(pNode); +#ifndef RELEASE_BUILD + if (!pWP || !pNode) condebug("NULL WP In SetCurrentWP"); +#endif + + m_pCurrentWaypoint = pWP; + m_iWaypointTime = lastmillis; +} + +void CBot::SetCurrentWaypoint(waypoint_s *pWP) +{ +#ifndef RELEASE_BUILD + if (!pWP) condebug("NULL WP In SetCurrentWP(2)"); +#endif + + m_pCurrentWaypoint = pWP; + m_iWaypointTime = lastmillis; +} + +void CBot::SetCurrentGoalWaypoint(node_s *pNode) +{ + waypoint_s *pWP = GetWPFromNode(pNode); +#ifndef RELEASE_BUILD + if (!pWP || !pNode) condebug("NULL WP In SetCurrentGoalWP"); +#endif + + m_pCurrentGoalWaypoint = pWP; +} + +void CBot::SetCurrentGoalWaypoint(waypoint_s *pWP) +{ +#ifndef RELEASE_BUILD + if (!pWP) condebug("NULL WP In SetCurrentGoalWP(2)"); +#endif + + m_pCurrentGoalWaypoint = pWP; +} + +bool CBot::CurrentWPIsValid() +{ + if (!m_pCurrentWaypoint) + { + //condebug("Invalid WP: Is NULL"); + return false; + } + + // check if the bot has been trying to get to this waypoint for a while... + if ((m_iWaypointTime + 5000) < lastmillis) + { + condebug("Invalid WP: time over"); + return false; + } + +#ifndef RELEASE_BUILD + if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) + condebug("Invalid WP: Not visible"); +#endif + + return (IsVisible(m_pCurrentWaypoint->pNode->v_origin)); +} + +bool CBot::ReachedGoalWP() +{ + if ((!m_pCurrentWaypoint) || (!m_pCurrentGoalWaypoint)) + return false; + + if (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) + return false; + + return ((GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin) <= 3.0f) && + (IsVisible(m_pCurrentGoalWaypoint->pNode->v_origin))); +} + +waypoint_s *CBot::GetWPFromNode(node_s *pNode) +{ + if (!pNode) return NULL; + + short x, y; + WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); + + TLinkedList::node_s *p = m_WaypointList[x][y].GetFirst(); + while(p) + { + if (p->Entry->pNode == pNode) + return p->Entry; + + p = p->next; + } + + return NULL; +} + +waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange) +{ + TLinkedList::node_s *p; + waypoint_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + WaypointClass.GetNodeIndexes(v_src, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_WaypointList[x][y].GetFirst(); + + while(p) + { + if (p->Entry->pNode->iFlags & W_FL_FLOOD) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_src, p->Entry->pNode->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +waypoint_s *CBot::GetNearestTriggerWaypoint(vec v_src, float flRange) +{ + TLinkedList::node_s *p; + waypoint_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + WaypointClass.GetNodeIndexes(v_src, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_WaypointList[x][y].GetFirst(); + + while(p) + { + if (!(p->Entry->pNode->iFlags & W_FL_TRIGGER)) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_src, p->Entry->pNode->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +// Makes a waypoint list for this bot based on the list from WaypointClass +void CBot::SyncWaypoints() +{ + short x, y; + TLinkedList::node_s *p; + + // Clean everything first + for (x=0;xpNode = p->Entry; + m_WaypointList[x][y].AddNode(pWP); + +#ifndef RELEASE_BUILD + if (!GetWPFromNode(p->Entry)) condebug("Error adding bot wp!"); +#endif + + p = p->next; + } + } + } +} + +#ifdef WP_FLOOD +waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange) +{ + TLinkedList::node_s *p; + waypoint_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + WaypointClass.GetNodeIndexes(v_origin, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_WaypointList[x][y].GetFirst(); + + while(p) + { + if (!(p->Entry->pNode->iFlags & W_FL_FLOOD)) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange) +{ + TLinkedList::node_s *p; + waypoint_s *pNearest = NULL; + short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); + float flNearestDist = 9999.99, flDist; + + WaypointClass.GetNodeIndexes(v_origin, &i, &j); + MinI = i - Offset; + MaxI = i + Offset; + MinJ = j - Offset; + MaxJ = j + Offset; + + if (MinI < 0) + MinI = 0; + if (MaxI > MAX_MAP_GRIDS - 1) + MaxI = MAX_MAP_GRIDS - 1; + if (MinJ < 0) + MinJ = 0; + if (MaxJ > MAX_MAP_GRIDS - 1) + MaxJ = MAX_MAP_GRIDS - 1; + + for (int x=MinI;x<=MaxI;x++) + { + for(int y=MinJ;y<=MaxJ;y++) + { + p = m_WaypointList[x][y].GetFirst(); + + while(p) + { + if (!(p->Entry->pNode->iFlags & (W_FL_FLOOD | W_FL_TRIGGER))) + { + p = p->next; + continue; + } + + flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); + if ((flDist < flNearestDist) && (flDist <= flRange)) + { + if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL)) + { + pNearest = p->Entry; + flNearestDist = flDist; + } + } + + p = p->next; + } + } + } + return pNearest; +} + +void CBot::GoToDebugGoal(vec o) +{ + ResetWaypointVars(); + + node_s *wp = WaypointClass.GetNearestWaypoint(m_pMyEnt, 20.0f); + node_s *goalwp = WaypointClass.GetNearestWaypoint(player1, 20.0f); + + if (!wp || !goalwp) + { + wp = WaypointClass.GetNearestFloodWP(m_pMyEnt, 8.0f); + goalwp = WaypointClass.GetNearestFloodWP(player1, 5.0f); + } + if (!wp || !goalwp) { condebug("No near WP"); return; } + + SetCurrentWaypoint(wp); + SetCurrentGoalWaypoint(goalwp); + m_vGoal = o; + m_bGoToDebugGoal = true; +} +#endif + +// Bot class end diff --git a/source/src/bot/bot_waypoint.h b/source/src/bot/bot_waypoint.h new file mode 100644 index 00000000..934e9d55 --- /dev/null +++ b/source/src/bot/bot_waypoint.h @@ -0,0 +1,191 @@ +// +// C++ Implementation: bot_waypoint.h +// +// Description: Containts all defintions for bot waypoint code +// +// +// Author: Rick Helmus +// + +// Enable this for flood support +#define WP_FLOOD + +#ifndef BOT_WAYPOINT_H +#define BOT_WAYPOINT_H + +#define WAYPOINT_VERSION 2 +#define EXP_WP_VERSION 1 +#define REACHABLE_RANGE 15.0f +#define MAX_MAP_GRIDS 64 +#define SECTOR_SIZE 18 + +#define W_FL_TELEPORT (1<<1) // used if waypoint is at a teleporter +#define W_FL_TELEPORTDEST (1<<2) // used if waypoint is at a teleporter destination +#define W_FL_FLOOD (1<<3) // used if this waypoint is made by flooding the map +#define W_FL_JUMP (1<<4) // if set, bot jumps when reached this waypoint +#define W_FL_TRIGGER (1<<5) // used if this waypoint is at a trigger +#define W_FL_INTAG (1<<6) // used if this waypoint is in a tagged cube + +#define MAX_FLOODWPCONNECTDIST 2 +#define MAX_FLOODWPDIST 4.0f + +struct waypoint_header_s +{ + char szFileType[10]; + int iFileVersion; + int iFileFlags; // not currently used + int iWPCount; + char szMapName[32]; // name of map for these waypoints +}; + +// Old waypoint structure, used for waypoint version 1 +struct waypoint_version_1_s +{ + int iFlags; + vec v_origin; + TLinkedList ConnectedWPs; + + // A* stuff + float f, g; + waypoint_version_1_s *pParent; + + // Construction + waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { }; +}; + +struct node_s +{ + vec v_origin; + int iFlags; + short sTriggerNr; + short sYaw; + short sCost; // Base and static cost + TLinkedList ConnectedWPs; + TLinkedList ConnectedWPsWithMe; + + TLinkedList FailedGoalList; + + // Construction + node_s(void) : iFlags(0), sTriggerNr(0), sYaw(-1), sCost(10) { }; + node_s(const vec &o, const int &f, const short t=0, const short y=-1) : v_origin(o), + iFlags(f), + sTriggerNr(t), + sYaw(y), + sCost(0) { }; +}; + +struct waypoint_s +{ + node_s *pNode; + short g[2]; + waypoint_s *pParent[2]; + bool bIsOpen[2], bIsClosed[2]; + + // Construction + waypoint_s(void) : pNode(NULL) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] = + bIsClosed[1] = false; pParent[0] = pParent[1] = NULL; + g[0] = g[1] = 0; }; +}; + +class CWaypointClass +{ +protected: + bool m_bDrawWaypoints; + bool m_bDrawWPPaths; + bool m_bAutoWaypoint; + bool m_bAutoPlacePaths; + bool m_bDrawWPText; + vec m_vLastCreatedWP; + float m_fPathDrawTime; + char m_szMapName[32]; + +#ifdef WP_FLOOD + bool m_bFlooding; // True if flooding map with waypoints + bool m_bFilteringNodes; + int m_iFloodStartTime; + int m_iCurFloodX, m_iCurFloodY; + int m_iFloodSize; + int m_iFilteredNodes; +#endif + friend class CBot; + +public: + TLinkedList m_Waypoints[MAX_MAP_GRIDS][MAX_MAP_GRIDS]; + int m_iWaypointCount; // number of waypoints currently in use + + CWaypointClass(void); + virtual ~CWaypointClass(void) { Clear(); }; + + void Think(void); + void Init(void); + void Clear(void); + bool LoadWaypoints(void); + void SaveWaypoints(void); + bool LoadWPExpFile(void); + void SaveWPExpFile(void); + void SetMapName(char *map) { strcpy(m_szMapName, map); }; + + void SetWaypointsVisible(bool Visible) { m_bDrawWaypoints = Visible; }; + void SetPathsVisible(bool Visible) { m_bDrawWPPaths = Visible; }; + void SetAutoWaypoint(bool On) { m_bAutoWaypoint = On; }; + void SetWPInfo(bool on) { m_bDrawWPText = on; }; + void SetWPFlags(node_s *wp, int iFlags) { wp->iFlags |= iFlags; }; + void UnsetWPFlags(node_s *wp, int iFlags) { wp->iFlags &= ~iFlags; }; + void SetWPTriggerNr(node_s *wp, short sTriggerNr) { wp->sTriggerNr = sTriggerNr; }; + void SetWPYaw(node_s *wp, short sYaw) { wp->sYaw = sYaw; }; + bool WaypointsAreVisible(void) { return m_bDrawWaypoints; }; + node_s *AddWaypoint(vec o, bool connectwp); + void DeleteWaypoint(dynent *d); + void AddPath(node_s *pWP1, node_s *pWP2); + void DeletePath(node_s *pWP); + void DeletePath(node_s *pWP1, node_s *pWP2); + void ManuallyCreatePath(dynent *d, int iCmd, bool TwoWay); + void ManuallyDeletePath(dynent *d, int iCmd, bool TwoWay); + + bool WPIsReachable(vec from, vec to); + //node_s *GetNearestWaypoint(vec v_src, float flRange, bool CheckVisible = true, bool SkipFloodWPs = true); + node_s *GetNearestWaypoint(vec v_src, float flRange); + node_s *GetNearestWaypoint(dynent *d, float flRange) { return GetNearestWaypoint(d->o, flRange); }; + node_s *GetNearestTriggerWaypoint(vec v_src, float flRange); + node_s *GetWaypointFromVec(const vec &v_src); + void DrawNearWaypoints(); + void GetNodeIndexes(const vec &v_origin, short *i, short *j); + void CalcCost(node_s *pNode); + void ReCalcCosts(void); + + +#ifdef WP_FLOOD + // Flood functions + virtual void StartFlood(void); + void StopFlood(void); + void FloodThink(void); + bool CanPlaceNodeHere(const vec &from); + void ConnectFloodWP(node_s *pWP); + node_s *GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, bool SkipTags=false); + node_s *GetNearestFloodWP(dynent *d, float flRange) { return GetNearestFloodWP(d->o, flRange, NULL); }; + node_s *GetNearestTriggerFloodWP(vec v_origin, float flRange); +#endif +}; + +class CACWaypointClass: public CWaypointClass +{ +public: +#ifdef WP_FLOOD + // Flood functions + virtual void StartFlood(void); +#endif +}; + +class CCubeWaypointClass: public CWaypointClass +{ +public: + void CreateWPsAtTeleporters(void); + void CreateWPsAtTriggers(void); + +#ifdef WP_FLOOD + // Flood functions + virtual void StartFlood(void); +#endif +}; + +#endif // BOT_WAYPOINT_H diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp new file mode 100644 index 00000000..77c6b0e4 --- /dev/null +++ b/source/src/bot/botmanager.cpp @@ -0,0 +1,1442 @@ +// +// C++ Implementation: bot +// +// Description: Code for botmanager +// +// Main bot file +// +// Author: Rick +// +// +// + +#include "../cube.h" + +#ifndef VANILLA_CUBE // UNDONE +bool dedserv = false; +#define CS_DEDHOST -1 +#endif + +extern ENetHost *clienthost; + +extern void respawnself(); + +CBotManager BotManager; + +// Bot manager class begin + +CBotManager::~CBotManager(void) +{ + EndMap(); + + while(m_StoredBots.Empty() == false) + delete m_StoredBots.Pop(); +} + +void CBotManager::Init() +{ + m_pBotToView = NULL; + + if (!ishost()) + return; + + m_bBotsShoot = true; + m_bIdleBots = false; + m_iFrameTime = 0; + m_iPrevTime = lastmillis; + m_sBotSkill = 1; // Default all bots have the skill 'Good' + + CreateSkillData(); + LoadBotNamesFile(); + LoadBotTeamsFile(); + WaypointClass.Init(); + lsrand(time(NULL)); +} + +void CBotManager::Think() +{ + if (m_bInit) + { + Init(); + m_bInit = false; + } + + if (m_pBotToView) + ViewBot(); + + if (!ishost()) + return; + + AddDebugText("m_sMaxAStarBots: %d", m_sMaxAStarBots); + AddDebugText("m_sCurrentTriggerNr: %d", m_sCurrentTriggerNr); + short x, y; + WaypointClass.GetNodeIndexes(player1->o, &x, &y); + AddDebugText("x: %d y: %d", x, y); + + m_iFrameTime = lastmillis - m_iPrevTime; + if (m_iFrameTime > 250) m_iFrameTime = 250; + m_iPrevTime = lastmillis; + + // Is it time to re-add bots? + if ((m_fReAddBotDelay < lastmillis) && (m_fReAddBotDelay != -1.0f)) + { + while(m_StoredBots.Empty() == false) + { + CStoredBot *pStoredBot = m_StoredBots.Pop(); + pStoredBot->ReAddBot(); + delete pStoredBot; + } + + m_fReAddBotDelay = -1.0f; + } + + // If this is a ded server check if there are any players, if not bots should be idle + if (dedserv) + { + bool botsbeidle = true; + loopv(players) + { + if (players[i] && (players[i]->state != CS_DEDHOST)) { botsbeidle = false; break; } + } + + if (botsbeidle) return; + } + + // Let all bots 'think' + loopv(bots) + { + if (!bots[i]) + continue; + + if (bots[i]->pBot) + bots[i]->pBot->Think(); + else + condebug("Error: pBot == NULL in bot ent\n"); + } +} + +void CBotManager::LoadBotNamesFile() +{ + if (!ishost()) + return; + + // Init bot names array first + for (int i=0;i<100;i++) + strcpy(m_szBotNames[i], "Bot"); + + m_sBotNameCount = 0; + + // Load bot file + char szNameFileName[256]; + MakeBotFileName("bot_names.txt", NULL, NULL, szNameFileName); + FILE *fp = fopen(szNameFileName, "r"); + char szNameBuffer[256]; + int iIndex, iStrIndex; + + if (!fp) + { + conoutf("Warning: Couldn't load bot names file"); + return; + } + + while (fgets(szNameBuffer, 80, fp) != NULL) + { + if (m_sBotNameCount >= 150) + { + conoutf("Warning: Max bot names reached(150), ignoring the rest of the" + "names"); + break; + } + + short length = strlen(szNameBuffer); + + if (szNameBuffer[length-1] == '\n') + { + szNameBuffer[length-1] = 0; // remove '\n' + length--; + } + + iStrIndex = 0; + while (iStrIndex < length) + { + if ((szNameBuffer[iStrIndex] < ' ') || (szNameBuffer[iStrIndex] > '~') || + (szNameBuffer[iStrIndex] == '"')) + { + for (iIndex=iStrIndex; iIndex < length; iIndex++) + szNameBuffer[iIndex] = szNameBuffer[iIndex+1]; + } + + iStrIndex++; + } + + if (szNameBuffer[0] != 0) + { + if (strlen(szNameBuffer) >= 16) + { conoutf("Warning: bot name \"%s\" has to many characters(16 is max)", + szNameBuffer); + } + s_strncpy(m_szBotNames[m_sBotNameCount], szNameBuffer, 16); + m_sBotNameCount++; + } + } + fclose(fp); +} + +char *CBotManager::GetBotName() +{ + char *szOutput = NULL; + TMultiChoice BotNameChoices; + short ChoiceVal; + + for(int j=0;jstate != CS_DEDHOST) && + !strcasecmp(players[i]->name, m_szBotNames[j])) + ChoiceVal -= 10; + } + + loopv(bots) + { + if (bots[i] && (!strcasecmp(bots[i]->name, m_szBotNames[j]))) + ChoiceVal -= 10; + } + + if ((player1->state != CS_DEDHOST) && !strcasecmp(player1->name, m_szBotNames[j])) + ChoiceVal -= 10; + + if (ChoiceVal <= 0) + ChoiceVal = 1; + + BotNameChoices.Insert(m_szBotNames[j], ChoiceVal); + } + + // Couldn't find a selection? + if (!BotNameChoices.GetSelection(szOutput)) + szOutput = "Bot"; + + return szOutput; +} + +void CBotManager::LoadBotTeamsFile() +{ + if (!ishost()) + return; + + // Init bot teams array first + for (int i=0;i<20;i++) + strcpy(m_szBotTeams[i], "b0ts"); + + m_sBotTeamCount = 0; + + // Load bot file + char szNameFileName[256]; + MakeBotFileName("bot_teams.txt", NULL, NULL, szNameFileName); + FILE *fp = fopen(szNameFileName, "r"); + char szNameBuffer[256]; + int iIndex, iStrIndex; + + if (!fp) + { + conoutf("Warning: Couldn't load bot teams file"); + return; + } + + while ((m_sBotTeamCount < 20) && (fgets(szNameBuffer, 80, fp) != NULL)) + { + short length = strlen(szNameBuffer); + + if (szNameBuffer[length-1] == '\n') + { + szNameBuffer[length-1] = 0; // remove '\n' + length--; + } + + iStrIndex = 0; + while (iStrIndex < length) + { + if ((szNameBuffer[iStrIndex] < ' ') || (szNameBuffer[iStrIndex] > '~') || + (szNameBuffer[iStrIndex] == '"')) + { + for (iIndex=iStrIndex; iIndex < length; iIndex++) + szNameBuffer[iIndex] = szNameBuffer[iIndex+1]; + } + + iStrIndex++; + } + + if (szNameBuffer[0] != 0) + { + s_strncpy(m_szBotTeams[m_sBotTeamCount], szNameBuffer, 5); + m_sBotTeamCount++; + } + } + fclose(fp); +} + +char *CBotManager::GetBotTeam() +{ + char *szOutput = NULL; + TMultiChoice BotTeamChoices; + short ChoiceVal; + + for(int j=0;jname, m_szBotNames[j]))) + ChoiceVal -= 10; + } + + loopv(bots) + { + if (bots[i] && (!strcasecmp(bots[i]->name, m_szBotNames[j]))) + ChoiceVal -= 10; + } + + if (!strcasecmp(player1->name, m_szBotNames[j])) + ChoiceVal -= 10; + + if (ChoiceVal <= 0) + ChoiceVmonsterclearal = 1;*/ + + BotTeamChoices.Insert(m_szBotTeams[j], ChoiceVal); + } + + // Couldn't find a selection? + if (!BotTeamChoices.GetSelection(szOutput)) + szOutput = "b0t"; + + return szOutput; +} + +extern void renderplayer(dynent *d); + +void CBotManager::RenderBots() +{ + //static bool drawblue; + + loopv(bots) + { + if (bots[i] && (bots[i] != m_pBotToView)) + { + /*drawblue = (m_sp || isteam(player1->team, bots[i]->team)); + renderclient(bots[i], drawblue, "playermodels/counterterrorist", 1.6f);*/ + renderplayer(bots[i]); + } + } +} + +void CBotManager::EndMap() +{ + // Remove all bots + loopv(bots) + { + if (!bots[i]) + continue; + + if (ishost()) // Store bots so they can be re-added after map change + { + if (bots[i]->pBot && bots[i]->name[0] && bots[i]->team[0]) + { + CStoredBot *pStoredBot = new CStoredBot(bots[i]->name, bots[i]->team, + bots[i]->pBot->m_sSkillNr); + m_StoredBots.AddNode(pStoredBot); + } + delete bots[i]->pBot; + } + + bots[i]->pBot = NULL; + zapdynent(bots[i]); + } + bots.setsize(0); + condebug("Cleared all bots"); + m_fReAddBotDelay = lastmillis + 7500; + //if(ishost()) WaypointClass.SaveWPExpFile(); //UNDONE +} + +void CBotManager::BeginMap(char *szMapName) +{ + EndMap(); // End previous map + + if (!ishost()) return; + + WaypointClass.Init(); + WaypointClass.SetMapName(szMapName); + if (!WaypointClass.LoadWaypoints()) + WaypointClass.StartFlood(); + //WaypointClass.LoadWPExpFile(); // UNDONE + + CalculateMaxAStarCount(); + m_sUsingAStarBotsCount = 0; + PickNextTrigger(); +} + +int CBotManager::GetBotIndex(dynent *m) +{ + loopv(bots) + { + if (!bots[i]) + continue; + + if (bots[i] == m) + return i; + } + + return -1; +} + +void CBotManager::LetBotsUpdateStats() +{ + loopv(bots) if (bots[i] && bots[i]->pBot) bots[i]->pBot->m_bSendC2SInit = false; +} + +void CBotManager::LetBotsHear(int n, vec *loc) +{ + if (bots.length() == 0) return; + + if (!loc) return; + + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot || (bots[i]->state == CS_DEAD)) continue; + bots[i]->pBot->HearSound(n, loc); + } +} + +// Notify all bots of a new waypoint +void CBotManager::AddWaypoint(node_s *pNode) +{ + if (bots.length()) + { + short x, y; + waypoint_s *pWP; + + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + + pWP = new waypoint_s; + pWP->pNode = pNode; + WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); + bots[i]->pBot->m_WaypointList[x][y].AddNode(pWP); + +#ifndef RELEASE_BUILD + if (!bots[i]->pBot->GetWPFromNode(pNode)) condebug("Error adding bot wp!"); +#endif + } + } + + CalculateMaxAStarCount(); +} + +// Notify all bots of a deleted waypoint +void CBotManager::DelWaypoint(node_s *pNode) +{ + if (bots.length()) + { + short x, y; + TLinkedList::node_s *p; + + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + + WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); + p = bots[i]->pBot->m_WaypointList[x][y].GetFirst(); + + while(p) + { + if (p->Entry->pNode == pNode) + { + delete p->Entry; + bots[i]->pBot->m_WaypointList[x][y].DeleteNode(p); + break; + } + p = p->next; + } + } + } + + CalculateMaxAStarCount(); +} + +void CBotManager::MakeBotFileName(const char *szFileName, const char *szDir1, const char *szDir2, char *szOutput) +{ + char *DirSeperator; + +#ifndef __linux__ + DirSeperator = "\\"; + strcpy(szOutput, "bot\\"); +#else + DirSeperator = "/"; + strcpy(szOutput, "bot/"); +#endif + + if (szDir1) + { + strcat(szOutput, szDir1); + strcat(szOutput, DirSeperator); + } + + if (szDir2) + { + strcat(szOutput, szDir2); + strcat(szOutput, DirSeperator); + } + + strcat(szOutput, szFileName); +} + +void CBotManager::CreateSkillData() +{ + // First give the bot skill structure some default data + InitSkillData(); + + // Now see if we can load the skill.cfg file + char SkillFileName[256] = ""; + FILE *pSkillFile = NULL; + int SkillNr = -1; + float value = 0; + + MakeBotFileName("bot_skill.cfg", NULL, NULL, SkillFileName); + + pSkillFile = fopen(SkillFileName, "r"); + + conoutf("Reading bot_skill.cfg file... "); + + if (pSkillFile == NULL) // file doesn't exist + { + conoutf("skill file not found, default settings will be used\n"); + return; + } + + int ch; + char cmd_line[256]; + int cmd_index; + char *cmd, *arg1; + + while (pSkillFile) + { + cmd_index = 0; + cmd_line[cmd_index] = 0; + + ch = fgetc(pSkillFile); + + // skip any leading blanks + while (ch == ' ') + ch = fgetc(pSkillFile); + + while ((ch != EOF) && (ch != '\r') && (ch != '\n')) + { + if (ch == '\t') // convert tabs to spaces + ch = ' '; + + cmd_line[cmd_index] = ch; + + ch = fgetc(pSkillFile); + + // skip multiple spaces in input file + while ((cmd_line[cmd_index] == ' ') && (ch == ' ')) + ch = fgetc(pSkillFile); + + cmd_index++; + } + + if (ch == '\r') // is it a carriage return? + { + ch = fgetc(pSkillFile); // skip the linefeed + } + + // if reached end of file, then close it + if (ch == EOF) + { + fclose(pSkillFile); + pSkillFile = NULL; + } + + cmd_line[cmd_index] = 0; // terminate the command line + + cmd_index = 0; + cmd = cmd_line; + arg1 = NULL; + + // skip to blank or end of string... + while ((cmd_line[cmd_index] != ' ') && (cmd_line[cmd_index] != 0)) + cmd_index++; + + if (cmd_line[cmd_index] == ' ') + { + cmd_line[cmd_index++] = 0; + arg1 = &cmd_line[cmd_index]; + } + + if ((cmd_line[0] == '#') || (cmd_line[0] == 0)) + continue; // skip if comment or blank line + + + if (strcasecmp(cmd, "[SKILL1]") == 0) + SkillNr = 0; + else if (strcasecmp(cmd, "[SKILL2]") == 0) + SkillNr = 1; + else if (strcasecmp(cmd, "[SKILL3]") == 0) + SkillNr = 2; + else if (strcasecmp(cmd, "[SKILL4]") == 0) + SkillNr = 3; + else if (strcasecmp(cmd, "[SKILL5]") == 0) + SkillNr = 4; + + if ((arg1 == NULL) || (*arg1 == 0)) + continue; + + if (SkillNr == -1) // Not in a skill block yet? + continue; + + value = atof(arg1); + + if (strcasecmp(cmd, "min_x_aim_speed") == 0) + { + m_BotSkills[SkillNr].flMinAimXSpeed = value; + } + else if (strcasecmp(cmd, "max_x_aim_speed") == 0) + { + m_BotSkills[SkillNr].flMaxAimXSpeed = value; + } + else if (strcasecmp(cmd, "min_y_aim_speed") == 0) + { + m_BotSkills[SkillNr].flMinAimYSpeed = value; + } + else if (strcasecmp(cmd, "max_y_aim_speed") == 0) + { + m_BotSkills[SkillNr].flMaxAimYSpeed = value; + } + else if (strcasecmp(cmd, "min_x_aim_offset") == 0) + { + m_BotSkills[SkillNr].flMinAimXOffset = value; + } + else if (strcasecmp(cmd, "max_x_aim_offset") == 0) + { + m_BotSkills[SkillNr].flMaxAimXOffset = value; + } + else if (strcasecmp(cmd, "min_y_aim_offset") == 0) + { + m_BotSkills[SkillNr].flMinAimYOffset = value; + } + else if (strcasecmp(cmd, "max_y_aim_offset") == 0) + { + m_BotSkills[SkillNr].flMaxAimYOffset = value; + } + else if (strcasecmp(cmd, "min_attack_delay") == 0) + { + m_BotSkills[SkillNr].flMinAttackDelay = value; + } + else if (strcasecmp(cmd, "max_attack_delay") == 0) + { + m_BotSkills[SkillNr].flMaxAttackDelay = value; + } + else if (strcasecmp(cmd, "min_enemy_search_delay") == 0) + { + m_BotSkills[SkillNr].flMinEnemySearchDelay = value; + } + else if (strcasecmp(cmd, "max_enemy_search_delay") == 0) + { + m_BotSkills[SkillNr].flMaxEnemySearchDelay = value; + } + else if (strcasecmp(cmd, "shoot_at_feet_percent") == 0) + { + if (value < 0) value = 0; + else if (value > 100) value = 100; + m_BotSkills[SkillNr].sShootAtFeetWithRLPercent = (short)value; + } + else if (strcasecmp(cmd, "can_predict_position") == 0) + { + m_BotSkills[SkillNr].bCanPredict = value; + } + else if (strcasecmp(cmd, "max_hear_volume") == 0) + { + if (value < 0) value = 0; + else if (value > 255) value = 100; + m_BotSkills[SkillNr].iMaxHearVolume = (int)value; + } + else if (strcasecmp(cmd, "can_circle_strafe") == 0) + { + m_BotSkills[SkillNr].bCircleStrafe = value; + } + else if (strcasecmp(cmd, "can_search_items_in_combat") == 0) + { + m_BotSkills[SkillNr].bCanSearchItemsInCombat = value; + } + } + + conoutf("done\n"); +} + +void CBotManager::InitSkillData() +{ + // Best skill + m_BotSkills[0].flMinReactionDelay = 0.015f; + m_BotSkills[0].flMaxReactionDelay = 0.035f; + m_BotSkills[0].flMinAimXOffset = 15.0f; + m_BotSkills[0].flMaxAimXOffset = 20.0f; + m_BotSkills[0].flMinAimYOffset = 10.0f; + m_BotSkills[0].flMaxAimYOffset = 15.0f; + m_BotSkills[0].flMinAimXSpeed = 330.0f; + m_BotSkills[0].flMaxAimXSpeed = 355.0f; + m_BotSkills[0].flMinAimYSpeed = 400.0f; + m_BotSkills[0].flMaxAimYSpeed = 450.0f; + m_BotSkills[0].flMinAttackDelay = 0.1f; + m_BotSkills[0].flMaxAttackDelay = 0.4f; + m_BotSkills[0].flMinEnemySearchDelay = 0.09f; + m_BotSkills[0].flMaxEnemySearchDelay = 0.12f; + m_BotSkills[0].sShootAtFeetWithRLPercent = 85; + m_BotSkills[0].bCanPredict = true; + m_BotSkills[0].iMaxHearVolume = 75; + m_BotSkills[0].bCircleStrafe = true; + m_BotSkills[0].bCanSearchItemsInCombat = true; + + // Good skill + m_BotSkills[1].flMinReactionDelay = 0.035f; + m_BotSkills[1].flMaxReactionDelay = 0.045f; + m_BotSkills[1].flMinAimXOffset = 20.0f; + m_BotSkills[1].flMaxAimXOffset = 25.0f; + m_BotSkills[1].flMinAimYOffset = 15.0f; + m_BotSkills[1].flMaxAimYOffset = 20.0f; + m_BotSkills[1].flMinAimXSpeed = 250.0f; + m_BotSkills[1].flMaxAimXSpeed = 265.0f; + m_BotSkills[1].flMinAimYSpeed = 260.0f; + m_BotSkills[1].flMaxAimYSpeed = 285.0f; + m_BotSkills[1].flMinAttackDelay = 0.3f; + m_BotSkills[1].flMaxAttackDelay = 0.6f; + m_BotSkills[1].flMinEnemySearchDelay = 0.12f; + m_BotSkills[1].flMaxEnemySearchDelay = 0.17f; + m_BotSkills[1].sShootAtFeetWithRLPercent = 60; + m_BotSkills[1].bCanPredict = true; + m_BotSkills[1].iMaxHearVolume = 60; + m_BotSkills[1].bCircleStrafe = true; + m_BotSkills[1].bCanSearchItemsInCombat = true; + + // Medium skill + m_BotSkills[2].flMinReactionDelay = 0.075f; + m_BotSkills[2].flMaxReactionDelay = 0.010f; + m_BotSkills[2].flMinAimXOffset = 25.0f; + m_BotSkills[2].flMaxAimXOffset = 30.0f; + m_BotSkills[2].flMinAimYOffset = 20.0f; + m_BotSkills[2].flMaxAimYOffset = 25.0f; + m_BotSkills[2].flMinAimXSpeed = 190.0f; + m_BotSkills[2].flMaxAimXSpeed = 125.0f; + m_BotSkills[2].flMinAimYSpeed = 210.0f; + m_BotSkills[2].flMaxAimYSpeed = 240.0f; + m_BotSkills[2].flMinAttackDelay = 0.75f; + m_BotSkills[2].flMaxAttackDelay = 1.0f; + m_BotSkills[2].flMinEnemySearchDelay = 0.18f; + m_BotSkills[2].flMaxEnemySearchDelay = 0.22f; + m_BotSkills[2].sShootAtFeetWithRLPercent = 25; + m_BotSkills[2].bCanPredict = false; + m_BotSkills[2].iMaxHearVolume = 45; + m_BotSkills[2].bCircleStrafe = true; + m_BotSkills[2].bCanSearchItemsInCombat = false; + + // Worse skill + m_BotSkills[3].flMinReactionDelay = 0.15f; + m_BotSkills[3].flMaxReactionDelay = 0.20f; + m_BotSkills[3].flMinAimXOffset = 30.0f; + m_BotSkills[3].flMaxAimXOffset = 35.0f; + m_BotSkills[3].flMinAimYOffset = 25.0f; + m_BotSkills[3].flMaxAimYOffset = 30.0f; + m_BotSkills[3].flMinAimXSpeed = 155.0f; + m_BotSkills[3].flMaxAimXSpeed = 170.0f; + m_BotSkills[3].flMinAimYSpeed = 160.0f; + m_BotSkills[3].flMaxAimYSpeed = 210.0f; + m_BotSkills[3].flMinAttackDelay = 1.2f; + m_BotSkills[3].flMaxAttackDelay = 1.6f; + m_BotSkills[3].flMinEnemySearchDelay = 0.25f; + m_BotSkills[3].flMaxEnemySearchDelay = 0.30f; + m_BotSkills[3].sShootAtFeetWithRLPercent = 10; + m_BotSkills[3].bCanPredict = false; + m_BotSkills[3].iMaxHearVolume = 30; + m_BotSkills[3].bCircleStrafe = false; + m_BotSkills[3].bCanSearchItemsInCombat = false; + + // Bad skill + m_BotSkills[4].flMinReactionDelay = 0.30f; + m_BotSkills[4].flMaxReactionDelay = 0.50f; + m_BotSkills[4].flMinAimXOffset = 35.0f; + m_BotSkills[4].flMaxAimXOffset = 40.0f; + m_BotSkills[4].flMinAimYOffset = 30.0f; + m_BotSkills[4].flMaxAimYOffset = 35.0f; + m_BotSkills[4].flMinAimXSpeed = 45.0f; + m_BotSkills[4].flMaxAimXSpeed = 60.0f; + m_BotSkills[4].flMinAimYSpeed = 125.0f; + m_BotSkills[4].flMaxAimYSpeed = 180.0f; + m_BotSkills[4].flMinAttackDelay = 1.5f; + m_BotSkills[4].flMaxAttackDelay = 2.0f; + m_BotSkills[4].flMinEnemySearchDelay = 0.30f; + m_BotSkills[4].flMaxEnemySearchDelay = 0.36f; + m_BotSkills[4].sShootAtFeetWithRLPercent = 0; + m_BotSkills[4].bCanPredict = false; + m_BotSkills[4].iMaxHearVolume = 15; + m_BotSkills[4].bCircleStrafe = false; + m_BotSkills[4].bCanSearchItemsInCombat = false; +} + +void CBotManager::ChangeBotSkill(short Skill, dynent *bot) +{ + static char *SkillNames[5] = { "best", "good", "medium", "worse", "bad" }; + + if (bot && bot->pBot) + { + // Only change skill of a single bot + bot->pBot->m_pBotSkill = &m_BotSkills[Skill]; + bot->pBot->m_sSkillNr = Skill; + conoutf("Skill of %s is now %s", bot->name, SkillNames[Skill]); + return; + } + + // Change skill of all bots + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + + bots[i]->pBot->m_pBotSkill = &m_BotSkills[Skill]; + bots[i]->pBot->m_sSkillNr = Skill; + } + + // Change default bot skill + m_sBotSkill = Skill; + + conoutf("Skill of all bots is now %s", (int)SkillNames[Skill]); +} + +void CBotManager::ViewBot() +{ + // Check if this bot is still in game + bool bFound = false; + loopv(bots) + { + if (bots[i] == m_pBotToView) + { + bFound = true; + break; + } + } + + if (!bFound) + { + DisableBotView(); + return; + } + + player1->state = CS_DEAD; // Fake dead + + player1->o = m_pBotToView->o; + player1->o.z += 1.0f; + player1->yaw = m_pBotToView->yaw; + player1->pitch = m_pBotToView->pitch; + player1->roll = m_pBotToView->roll; + player1->radius = 0; // Don't collide +} + +void CBotManager::DisableBotView() +{ + m_pBotToView = NULL; + respawnself(); + player1->radius = 1.1f; +} + +void CBotManager::CalculateMaxAStarCount() +{ + if (WaypointClass.m_iWaypointCount > 0) // Are there any waypoints? + { + m_sMaxAStarBots = 8 - short(ceil((float)WaypointClass.m_iWaypointCount / + 1000.0f)); + if (m_sMaxAStarBots < 1) + m_sMaxAStarBots = 1; + } + else + m_sMaxAStarBots = 1; +} + +void CBotManager::PickNextTrigger() +{ + if (!ishost()) return; + + short lowest = -1; + bool found0 = false; // True if found a trigger with nr 0 + + loopv(ents) + { + entity &e = ents[i]; + +#if defined AC_CUBE +/* if ((e.type != TRIGGER) || !e.spawned) + continue;*/ +#elif defined VANILLA_CUBE + if ((e.type != CARROT) || !e.spawned) + continue; +#endif + if (OUTBORD(e.x, e.y)) continue; + + vec o = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + + node_s *pWptNearEnt = NULL; + + pWptNearEnt = WaypointClass.GetNearestTriggerWaypoint(o, 2.0f); + + if (pWptNearEnt) + { + if ((pWptNearEnt->sTriggerNr > 0) && + ((pWptNearEnt->sTriggerNr < lowest) || (lowest == -1))) + lowest = pWptNearEnt->sTriggerNr; + if (pWptNearEnt->sTriggerNr == 0) found0 = true; + } + +#ifdef WP_FLOOD + pWptNearEnt = WaypointClass.GetNearestTriggerFloodWP(o, 2.0f); + + if (pWptNearEnt) + { + if ((pWptNearEnt->sTriggerNr > 0) && + ((pWptNearEnt->sTriggerNr < lowest) || (lowest == -1))) + lowest = pWptNearEnt->sTriggerNr; + if (pWptNearEnt->sTriggerNr == 0) found0 = true; + } + +#endif + } + + if ((lowest == -1) && found0) lowest = 0; + + if (lowest != -1) + m_sCurrentTriggerNr = lowest; +} + +dynent *CBotManager::CreateBot(const char *team, const char *skill, const char *name) +{ + dynent *m = newdynent(); + if (!m) return NULL; + loopi(NUMGUNS) m->ammo[i] = m->mag[i] = 0; + // Create new bot class, dependand on the current mod +#if defined VANILLA_CUBE + m->pBot = new CCubeBot; +#elif defined AC_CUBE + m->pBot = new CACBot; +#else + #error "Unsupported mod!" +#endif + m->bIsBot = true; + m->pBot->m_pMyEnt = m; + m->pBot->m_iLastBotUpdate = 0; + m->pBot->m_bSendC2SInit = false; + + if (name && *name) + s_strncpy(m->name, name, 16); + else + s_strncpy(m->name, BotManager.GetBotName(), 16); + + if (team && *team && strcmp(team, "random")) + s_strncpy(m->team, team, 5); + else + s_strncpy(m->team, BotManager.GetBotTeam(), 5); + + if (skill && *skill && strcmp(skill, "random")) + { + if (!strcasecmp(skill, "best")) + m->pBot->m_sSkillNr = 0; + else if (!strcasecmp(skill, "good")) + m->pBot->m_sSkillNr = 1; + else if (!strcasecmp(skill, "medium")) + m->pBot->m_sSkillNr = 2; + else if (!strcasecmp(skill, "worse")) + m->pBot->m_sSkillNr = 3; + else if (!strcasecmp(skill, "bad")) + m->pBot->m_sSkillNr = 4; + else + { + conoutf("Wrong skill specified. Should be best, good, medium, " + "worse or bad"); + conoutf("Using default skill instead..."); + m->pBot->m_sSkillNr = BotManager.m_sBotSkill; + } + } + else // No skill specified, use default + m->pBot->m_sSkillNr = BotManager.m_sBotSkill; + + m->pBot->m_pBotSkill = &BotManager.m_BotSkills[m->pBot->m_sSkillNr]; + + // Sync waypoints + m->pBot->SyncWaypoints(); + + m->pBot->Spawn(); + + bots.add(m); + + return m; +} + +bool botmode() +{ + if(m_botmode) return true; + conoutf("the current game mode does not support bots"); + return false; +} + +// Bot manager class end + +void addbot(char *arg1, char *arg2, char *arg3) +{ + if(!botmode()) return; + if (ishost()) + { + conoutf("Creating bot...\n"); + dynent *b = BotManager.CreateBot(arg1, arg2, arg3); + if (b) + conoutf("connected: %s", b->name); + else + { + conoutf("Error: Couldn't create bot!"); + return; + } + } + else if (clienthost) + { + char team[32], name[32]; + int skill = -1; + + team[0] = name[0] = 0; + + if (arg1 && arg1[0]) strcpy(team, arg1); + if (arg3 && arg3[0]) strcpy(name, arg3); + if (arg2 && arg2[0]) + { + if (!strcasecmp(arg2, "best")) skill = 0; + else if (!strcasecmp(arg2, "good")) skill = 1; + else if (!strcasecmp(arg2, "medium")) skill = 2; + else if (!strcasecmp(arg2, "worse")) skill = 3; + else if (!strcasecmp(arg2, "bad")) skill = 4; + } + + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_BOTCOMMAND); + putint(p, int(COMMAND_ADDBOT)); // Bot command type + putint(p, 1); // Bot count + putint(p, skill); // Bot skill + sendstring(team, p); // Bot team + sendstring(name, p); // Bot name + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + } +} + +COMMAND(addbot, ARG_3STR); + +void addnbot(char *arg1, char *arg2, char *arg3) +{ + if(!botmode()) return; + if (!arg1 || !arg1[0]) return; + + int i = atoi(arg1); + + if (ishost()) + { + while(i > 0) + { + addbot(arg2, arg3, NULL); + i--; + } + } + else if (clienthost) + { + char team[32], name[32]; + int skill = -1; + + team[0] = name[0] = 0; + + if (arg2 && arg2[0]) strcpy(team, arg2); +// if (arg4 && arg4[0]) strcpy(name, arg4); + if (arg3 && arg3[0]) + { + if (!strcasecmp(arg2, "best")) skill = 0; + else if (!strcasecmp(arg2, "good")) skill = 1; + else if (!strcasecmp(arg2, "medium")) skill = 2; + else if (!strcasecmp(arg2, "worse")) skill = 3; + else if (!strcasecmp(arg2, "bad")) skill = 4; + } + + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_BOTCOMMAND); + putint(p, int(COMMAND_ADDBOT)); // Bot command type + putint(p, i); // Bot count + putint(p, skill); // Bot skill + sendstring(team, p); // Bot team + sendstring(name, p); // Bot name + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + } +} + +COMMAND(addnbot, ARG_3STR); + +void botsshoot(int Shoot) +{ + if (!ishost()) return; + if (Shoot) + { + BotManager.SetBotsShoot(true); + conoutf("Bots will shoot"); + } + else + { + BotManager.SetBotsShoot(false); + conoutf("Bots won't shoot"); + } +} + +COMMAND(botsshoot, ARG_1INT); + +void idlebots(int Idle) +{ + if (!ishost()) return; + if (Idle) + { + BotManager.SetIdleBots(true); + conoutf("Bots are idle"); + } + else + { + BotManager.SetIdleBots(false); + conoutf("Bots aren't idle"); + } +} + +COMMAND(idlebots, ARG_1INT); + +void drawbeamtobots() +{ + if(!botmode()) return; + loopv(bots) + { + if (bots[i]) + particle_trail(1, 500, player1->o, bots[i]->o); + } +} + +COMMAND(drawbeamtobots, ARG_NONE); + +void kickbot(const char *szName) +{ + if(!botmode()) return; + if (!szName || !(*szName)) + return; + + int iBotInd = -1; + loopv(bots) + { + if (!bots[i]) continue; + + if (!strcmp(bots[i]->name, szName)) + { + iBotInd = i; + break; + } + } + + if (iBotInd != -1) + { + if (ishost()) + { + addmsg(SV_BOTDIS, "ri", iBotInd); + + conoutf("bot %s disconnected", (int)(bots[iBotInd]->name[0] ? bots[iBotInd]->name : + "[incompatible client]")); + delete bots[iBotInd]->pBot; + zapdynent(bots[iBotInd]); + bots.remove(iBotInd); + } + else if (clienthost) // Ask server to destroy bot(with voting) + { + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_BOTCOMMAND); + putint(p, int(COMMAND_KICKBOT)); // Bot command type + putint(p, 1); // 0==kick all bots, 1==kick one specific bot + char tmp[20]; + strcpy(tmp, szName); + sendstring(tmp, p); // Bot name + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + } + } +} + +COMMAND(kickbot, ARG_1STR); + +void kickallbots(void) +{ + loopv(bots) + { + if (bots[i]) + { + if (ishost()) + { + addmsg(SV_BOTDIS, "ri", i); + + conoutf("bot %s disconnected",(bots[i]->name[0] ? + bots[i]->name : "[incompatible client]")); + delete bots[i]->pBot; + zapdynent(bots[i]); + } + else if (clienthost) // Ask the server to destroy all bots + { + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, + ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_BOTCOMMAND); + putint(p, int(COMMAND_KICKBOT)); // Bot command type + putint(p, 0); // 0==kick all bots, 1==kick one specific bot + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + } + } + } + + bots.setsize(0); +} + +COMMAND(kickallbots, ARG_NONE); + +void togglegrap() +{ + if(!botmode()) return; + if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GrabMode(0)) + SDL_WM_GrabInput(SDL_GRAB_ON); + else + SDL_WM_GrabInput(SDL_GrabMode(0)); +} + +COMMAND(togglegrap, ARG_NONE); + +void togglebotview(char *bot) +{ + if(!botmode()) return; + if (BotManager.m_pBotToView) + BotManager.DisableBotView(); + else if (bot && *bot) + { + loopv(bots) + { + if (!bots[i]) continue; + + if (!strcmp(bots[i]->name, bot)) + { + BotManager.EnableBotView(bots[i]); + break; + } + } + } +} + +COMMAND(togglebotview, ARG_1STR); + +void botskill(char *bot, char *skill) +{ + if (!skill || !(*skill)) + return; + + short SkillNr; + + if (!strcasecmp(skill, "best")) + SkillNr = 0; + else if (!strcasecmp(skill, "good")) + SkillNr = 1; + else if (!strcasecmp(skill, "medium")) + SkillNr = 2; + else if (!strcasecmp(skill, "worse")) + SkillNr = 3; + else if (!strcasecmp(skill, "bad")) + SkillNr = 4; + else + { + conoutf("Wrong skill specified. Should be best, good, medium, worse or bad"); + return; + } + + if (ishost()) + { + if (bot) + { + loopv(bots) + { + if (bots[i] && !strcmp(bots[i]->name, bot)) + { + BotManager.ChangeBotSkill(SkillNr, bots[i]); + break; + } + } + } + else + BotManager.ChangeBotSkill(SkillNr); + } + else if (clienthost) // ask server to change botskill + { + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_BOTCOMMAND); + putint(p, int(COMMAND_BOTSKILL)); // Bot command type + putint(p, SkillNr); + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + } +} + +COMMAND(botskill, ARG_2STR); + +void botskillall(char *skill) +{ + botskill(NULL, skill); +} + +COMMAND(botskillall, ARG_1STR); + +#ifndef RELEASE_BUILD + +#ifdef VANILLA_CUBE +void drawbeamtocarrots() +{ + loopv(ents) + { + entity &e = ents[i]; + vec o = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + if ((e.type != CARROT) || !e.spawned) continue; + particle_trail(1, 500, player1->o, o); + } +} + +COMMAND(drawbeamtocarrots, ARG_NONE); + +void drawbeamtoteleporters() +{ + loopv(ents) + { + entity &e = ents[i]; + vec o = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; + if (e.type != TELEPORT) continue; + particle_trail(1, 500, player1->o, o); + } +} + +COMMAND(drawbeamtoteleporters, ARG_NONE); +#endif + +void telebot(void) +{ + vec dest = player1->o, forward, right, up; + vec angles = { player1->pitch, player1->yaw, player1->roll }; + traceresult_s tr; + + AnglesToVectors(angles, forward, right, up); + vmul(forward, 4.0f); + vadd(dest, forward); + + TraceLine(player1->o, dest, player1, true, &tr); + + if (!tr.collided) + { + // Get the first bot + loopv(bots) + { + if (!bots[i] || !bots[i]->pBot) continue; + bots[i]->o = tr.end; + break; + } + } +} + +COMMAND(telebot, ARG_NONE); + +void testvisible(int iDir) +{ + + vec angles, end, forward, right, up; + traceresult_s tr; + int Dir; + + switch(iDir) + { + case 0: default: Dir = FORWARD; break; + case 1: Dir = BACKWARD; break; + case 2: Dir = LEFT; break; + case 3: Dir = RIGHT; break; + case 4: Dir = UP; break; + case 5: Dir = DOWN; break; + } + + vec from = player1->o; + from.z -= (player1->eyeheight - 1.25f); + end = from; + makevec(&angles, player1->pitch, player1->yaw, player1->roll); + angles.x=0; + + if (Dir & UP) + angles.x = WrapXAngle(angles.x + 45.0f); + else if (Dir & DOWN) + angles.x = WrapXAngle(angles.x - 45.0f); + + if ((Dir & FORWARD) || (Dir & BACKWARD)) + { + if (Dir & BACKWARD) + angles.y = WrapYZAngle(angles.y + 180.0f); + + if (Dir & LEFT) + { + if (Dir & FORWARD) + angles.y = WrapYZAngle(angles.y - 45.0f); + else + angles.y = WrapYZAngle(angles.y + 45.0f); + } + else if (Dir & RIGHT) + { + if (Dir & FORWARD) + angles.y = WrapYZAngle(angles.y + 45.0f); + else + angles.y = WrapYZAngle(angles.y - 45.0f); + } + } + else if (Dir & LEFT) + angles.y = WrapYZAngle(angles.y - 90.0f); + else if (Dir & RIGHT) + angles.y = WrapYZAngle(angles.y + 90.0f); + else if (Dir & UP) + angles.x = WrapXAngle(angles.x + 90.0f); + else if (Dir & DOWN) + angles.x = WrapXAngle(angles.x - 90.0f); + + AnglesToVectors(angles, forward, right, up); + + vmul(forward, 20.0f); + vadd(end, forward); + + TraceLine(from, end, player1, false, &tr); + + //debugbeam(from, tr.end); + char sz[250]; + sprintf(sz, "dist: %f; hit: %d", GetDistance(from, tr.end), tr.collided); + condebug(sz); +} + +COMMAND(testvisible, ARG_1INT); + +void mapsize(void) +{ + conoutf("ssize: %d", ssize); +} + +COMMAND(mapsize, ARG_NONE); + +#endif diff --git a/source/src/client.cpp b/source/src/client.cpp new file mode 100644 index 00000000..1a1bc1df --- /dev/null +++ b/source/src/client.cpp @@ -0,0 +1,367 @@ +// client.cpp, mostly network related client game code + +#include "cube.h" + +ENetHost *clienthost = NULL; +int connecting = 0; +int connattempts = 0; +int disconnecting = 0; +int clientnum = -1; // our client id in the game +bool c2sinit = false; // whether we need to tell the other clients our stats + +int getclientnum() { return clientnum; }; + +bool multiplayer() +{ + // check not correct on listen server? + if(clienthost) conoutf("operation not available in multiplayer"); + return clienthost!=NULL; +}; + +bool allowedittoggle() +{ + bool allow = !clienthost || gamemode==1; + if(!allow) conoutf("editing in multiplayer requires coopedit mode (1)"); + return allow; +}; + +VARF(rate, 0, 0, 25000, if(clienthost && (!rate || rate>1000)) enet_host_bandwidth_limit (clienthost, rate, rate)); + +void throttle(); + +VARF(throttle_interval, 0, 5, 30, throttle()); +VARF(throttle_accel, 0, 2, 32, throttle()); +VARF(throttle_decel, 0, 2, 32, throttle()); + +void throttle() +{ + if(!clienthost || connecting) return; + ASSERT(ENET_PEER_PACKET_THROTTLE_SCALE==32); + enet_peer_throttle_configure(clienthost->peers, throttle_interval*1000, throttle_accel, throttle_decel); +}; + +void ctf_team(char *name) +{ + bool isvalidteam = strcmp(name, "RVSF") == 0 || strcmp(name, "CLA") == 0; + if(strcmp(name, player1->team) == 0 && isvalidteam) return; + c2sinit = false; + ctf_death(); + if(isvalidteam) strcpy(player1->team, name); + else strcpy(player1->team, rb_team_string(rnd(2))); + player1->lastaction = lastmillis; + player1->state = CS_DEAD; +}; + +void newname(char *name) { c2sinit = false; s_strncpy(player1->name, name, 16); }; +void newskin(int skin) { player1->nextskin = max(0, min(skin, (rb_team_int(player1->team)==TEAM_CLA ? 3 : 5))); }; +void newteam(char *name) +{ + if(m_teammode) ctf_team(name); + else { s_strncpy(player1->team, name, 5); c2sinit=false; }; +}; + +COMMANDN(team, newteam, ARG_1STR); +COMMANDN(name, newname, ARG_1STR); +COMMANDN(skin, newskin, ARG_1INT); + +void connects(char *servername) +{ + disconnect(1); // reset state + + ENetAddress address; + address.port = CUBE_SERVER_PORT; + + if(servername) + { + addserver(servername); + conoutf("attempting to connect to %s", servername); + if(!resolverwait(servername, &address)) + { + conoutf("could not resolve server %s", servername); + return; + }; + } + else + { + conoutf("attempting to connect over LAN"); + address.host = ENET_HOST_BROADCAST; + }; + + clienthost = enet_host_create(NULL, 1, rate, rate); + + if(clienthost) + { + enet_host_connect(clienthost, &address, 4); + enet_host_flush(clienthost); + connecting = lastmillis; + connattempts = 0; + } + else + { + conoutf("could not connect to server"); + disconnect(); + }; +}; + +void disconnect(int onlyclean, int async) +{ + if(clienthost) + { + if(!connecting && !disconnecting) + { + enet_peer_disconnect(clienthost->peers, DISC_NONE); + enet_host_flush(clienthost); + disconnecting = lastmillis; + }; + if(clienthost->peers->state != ENET_PEER_STATE_DISCONNECTED) + { + if(async) return; + enet_peer_reset(clienthost->peers); + }; + enet_host_destroy(clienthost); + }; + + if(clienthost && !connecting) conoutf("disconnected"); + clienthost = NULL; + connecting = 0; + connattempts = 0; + disconnecting = 0; + clientnum = -1; + c2sinit = false; + player1->lifesequence = 0; + loopv(players) zapdynent(players[i]); + + localdisconnect(); + + if(!onlyclean) { stop(); localconnect(); }; +}; + +void trydisconnect() +{ + if(!clienthost) + { + conoutf("not connected"); + return; + }; + if(connecting) + { + conoutf("aborting connection attempt"); + disconnect(); + return; + }; + conoutf("attempting to disconnect..."); + disconnect(0, !disconnecting); +}; + +void toserver(char *text) { conoutf("%s:\f %s", player1->name, text); addmsg(SV_TEXT, "rs", text); }; +void echo(char *text) { conoutf("%s", text); }; + +void lanconnect() +{ + connects(0); +}; + +COMMAND(echo, ARG_VARI); +COMMANDN(say, toserver, ARG_VARI); +COMMANDN(connect, connects, ARG_1STR); +COMMAND(lanconnect, ARG_NONE); +COMMANDN(disconnect, trydisconnect, ARG_NONE); + +// collect c2s messages conveniently + +vector messages; + +void addmsg(int type, const char *fmt, ...) +{ + if(demoplayback) return; + static uchar buf[MAXTRANS]; + ucharbuf p(buf, MAXTRANS); + putint(p, type); + int numi = 1, nums = 0; + bool reliable = false; + if(fmt) + { + va_list args; + va_start(args, fmt); + while(*fmt) switch(*fmt++) + { + case 'r': reliable = true; break; + case 'i': + { + int n = isdigit(*fmt) ? *fmt++-'0' : 1; + loopi(n) putint(p, va_arg(args, int)); + numi += n; + break; + }; + case 's': sendstring(va_arg(args, const char *), p); nums++; break; + }; + va_end(args); + }; + int num = nums?0:numi; + if(num!=msgsizelookup(type)) { s_sprintfd(s)("inconsistant msg size for %d (%d != %d)", type, num, msgsizelookup(type)); fatal(s); }; + int len = p.length(); + messages.add(len&0xFF); + messages.add((len>>8)|(reliable ? 0x80 : 0)); + loopi(len) messages.add(buf[i]); +}; + +int lastupdate = 0, lastping = 0; +bool senditemstoserver = false; // after a map change, since server doesn't have map data + +string clientpassword; +char *toserverpwd = NULL; +void password(char *p) { s_strcpy(clientpassword, p); }; +COMMAND(password, ARG_1STR); + +bool netmapstart() { senditemstoserver = true; return clienthost!=NULL; }; + +void initclientnet() +{ + clientpassword[0] = 0; + newname("unnamed"); + ctf_team("red"); +}; + +void sendpackettoserv(int chan, ENetPacket *packet) +{ + if(clienthost) { enet_host_broadcast(clienthost, chan, packet); enet_host_flush(clienthost); } + else localclienttoserver(chan, packet); +} + +void c2skeepalive() +{ + if(clientnum<0 || !clienthost) return; + if(lastmillis-lastupdate<40) return; + + ENetEvent event; + while(clienthost!=NULL && enet_host_service(clienthost, &event, 0)>0) {}; // fixme + + lastupdate = SDL_GetTicks(); +}; + +extern string masterpwd; + +void c2sinfo(dynent *d) // send update to the server +{ + if(clientnum<0) return; // we haven't had a welcome message from the server yet + if(lastmillis-lastupdate<40) return; // don't update faster than 25fps + ENetPacket *packet = enet_packet_create(NULL, 100, 0); + ucharbuf q(packet->data, packet->dataLength); + + putint(q, SV_POS); + putint(q, clientnum); + putuint(q, (int)(d->o.x*DMF)); // quantize coordinates to 1/16th of a cube, between 1 and 3 bytes + putuint(q, (int)(d->o.y*DMF)); + putuint(q, (int)(d->o.z*DMF)); + putuint(q, (int)(d->yaw*DAF)); + putint(q, (int)(d->pitch*DAF)); + putint(q, (int)(d->roll*DAF)); + putint(q, (int)(d->vel.x*DVF)); // quantize to 1/100, almost always 1 byte + putint(q, (int)(d->vel.y*DVF)); + putint(q, (int)(d->vel.z*DVF)); + // pack rest in 1 byte: strafe:2, move:2, onfloor:1, state:3 + putint(q, (d->strafe&3) | ((d->move&3)<<2) | (((int)d->onfloor)<<4) | ((editmode ? CS_EDITING : d->state)<<5) ); + + enet_packet_resize(packet, q.length()); + incomingdemodata(0, q.buf, q.length(), true); + sendpackettoserv(0, packet); + + bool serveriteminitdone = false; + if(gun_changed || senditemstoserver || !c2sinit || messages.length() || lastmillis-lastping>250) + { + packet = enet_packet_create (NULL, MAXTRANS, 0); + ucharbuf p(packet->data, packet->dataLength); + + if(gun_changed) + { + packet->flags = ENET_PACKET_FLAG_RELIABLE; + putint(p, SV_WEAPCHANGE); + putint(p, player1->gunselect); + gun_changed = false; + }; + if(senditemstoserver) + { + packet->flags = ENET_PACKET_FLAG_RELIABLE; + putint(p, SV_ITEMLIST); + if(!m_noitems) putitems(p); + putint(p, -1); + senditemstoserver = false; + serveriteminitdone = true; + }; + if(!c2sinit) // tell other clients who I am + { + packet->flags = ENET_PACKET_FLAG_RELIABLE; + c2sinit = true; + putint(p, SV_INITC2S); + sendstring(player1->name, p); + sendstring(player1->team, p); + putint(p, player1->skin); + putint(p, player1->lifesequence); + }; + int i = 0; + while(i < messages.length()) // send messages collected during the previous frames + { + int len = messages[i] | ((messages[i+1]&0x7F)<<8); + if(p.remaining() < len) break; + if(messages[i+1]&0x80) packet->flags = ENET_PACKET_FLAG_RELIABLE; + p.put(&messages[i+2], len); + i += 2 + len; + }; + messages.remove(0, i); + if(lastmillis-lastping>250) + { + putint(p, SV_PING); + putint(p, lastmillis); + lastping = lastmillis; + }; + if(!p.length()) enet_packet_destroy(packet); + else + { + enet_packet_resize(packet, p.length()); + sendpackettoserv(1, packet); + }; + }; + lastupdate = lastmillis; + if(serveriteminitdone) loadgamerest(); // hack +}; + +void gets2c() // get updates from the server +{ + ENetEvent event; + if(!clienthost) return; + if(connecting && lastmillis/3000 > connecting/3000) + { + conoutf("attempting to connect..."); + connecting = lastmillis; + ++connattempts; + if(connattempts > 3) + { + conoutf("could not connect to server"); + disconnect(); + return; + }; + }; + while(clienthost!=NULL && enet_host_service(clienthost, &event, 0)>0) + switch(event.type) + { + case ENET_EVENT_TYPE_CONNECT: + conoutf("connected to server"); + connecting = 0; + throttle(); + break; + + case ENET_EVENT_TYPE_RECEIVE: + if(disconnecting) + conoutf("attempting to disconnect..."); + else localservertoclient(event.channelID, event.packet->data, event.packet->dataLength); + enet_packet_destroy(event.packet); + break; + + case ENET_EVENT_TYPE_DISCONNECT: + extern char *disc_reasons[]; + if(event.data>DISC_MAXCLIENTS) event.data = DISC_NONE; + if(!disconnecting || event.data) conoutf("\fserver network error, disconnecting (%s) ...", disc_reasons[event.data]); + disconnect(); + return; + } +}; diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp new file mode 100644 index 00000000..52d94310 --- /dev/null +++ b/source/src/clientextras.cpp @@ -0,0 +1,213 @@ +// clientextras.cpp: stuff that didn't fit in client.cpp or clientgame.cpp :) + +#include "cube.h" + +// render players & monsters +// very messy ad-hoc handling of animation frames, should be made more configurable +// idle, run, attack, pain, jump, land, flipoff, salute, taunt, wave, point, crouch idle, crouch walk, crouch attack, crouch pain, crouch death, death, lying dead +// I R A P P P J L F S T W P CI CW CA CP CD D D D LD LD LD +int frame[] = { 0, 40, 46, 54, 58, 62, 66, 69, 72, 84, 95, 112,123,135,154,160,169,173,178,184,190,183,189,197 }; +int range[] = { 40, 5, 8, 4, 4, 4, 3, 3, 12, 11, 17, 11, 13, 19, 6, 9, 4, 5, 6, 6, 8, 1, 1, 1 }; + +// D D D D' D D D D' A A' P P' I I' R, R' Q L J J' +/*int frame[] = { 178, 184, 190, 137, 183, 189, 197, 164, 46, 51, 54, 32, 0, 0, 40, 1, 154, 162, 67, 168 }; +int range[] = { 6, 6, 8, 28, 1, 1, 1, 1, 8, 19, 4, 18, 40, 1, 6, 15, 6, 1, 1, 1 };*/ + +VAR(die,0,0,1); + +void renderclient(dynent *d, bool team, char *mdlname, float scale) +{ + int n = 3; + int oldaniminterpt = -1; + float speed = 100.0f; + float mz = d->o.z-d->eyeheight+1.55f*scale; + int basetime = -((int)d&0xFFF); + if(d->state==CS_DEAD) + { + loopv(physents) if(physents[i]->state==GIB && physents[i]->owner==d) return; + d->pitch = 0.1f; + int r; + n = (d->lastaction%3)+18; + r = range[n]; + basetime = d->lastaction; + int t = lastmillis-d->lastaction; + if(t<0 || t>20000) return; + if(t>(r-1)*100-50) + { + n += 3; + if(t>(r+10)*100) + { + t -= (r+10)*100; + mz -= t*t/10000000000.0f*t; + }; + oldaniminterpt = getvar("animationinterpolationtime"); // disable anim interp. temporarly + setvar("animationinterpolationtime", 0); + }; + //if(mz<-1000) return; + } + else if(d->state==CS_EDITING) { n = 8; } + else if(d->state==CS_LAGGED) { n = 13; } + else if((!d->move && !d->strafe) /*|| !d->moving*/) { n = 0; } + else if(!d->onfloor && d->timeinair>100) { n = 6; } + else { n = 1; speed = 1200/d->maxspeed*scale; }; + rendermodel(mdlname, frame[n], range[n], 0, 1.5f, d->o.x, mz, d->o.y, d->yaw+90, d->pitch/4, team, scale, speed, 0, basetime, true, d); + if(oldaniminterpt!=-1) setvar("animationinterpolationtime", oldaniminterpt); +}; + +extern int democlientnum; + +void renderplayer(dynent *d) +{ + if(!d) return; + + int team = rb_team_int(d->team); + s_sprintfd(mdl)("playermodels/%s/0%i", team==TEAM_CLA ? "terrorist" : "counterterrorist", 1 + max(0, min(d->skin, (team==TEAM_CLA ? 3 : 5)))); + renderclient(d, isteam(player1->team, d->team), mdl, 1.55f); + + if(d->gunselect>=0 && d->gunselectgunselect]); + renderclient(d, isteam(player1->team, d->team), vwep, 1.55f); + }; +} + +void renderclients() +{ + dynent *d; + loopv(players) + if((d = players[i]) && (!demoplayback || i!=democlientnum)) + { + if(strcmp(d->name, "dummy") == 0) + { + d->gunselect = player1->gunselect; + d->moving = true; + d->health != 1 ? d->state=CS_ALIVE : d->state=CS_DEAD; + }; + renderplayer(d); + }; + + if(player1->state==CS_DEAD) renderplayer(player1); +}; + +// creation of scoreboard pseudo-menu + +bool scoreson = false; + +void showscores(bool on) +{ + scoreson = on; +// menuset(((int)on)-1); + menuset(on ? (m_ctf ? 2 : 0) : -1); // EDIT: AH +}; + +struct sline { string s; }; +vector scorelines; +int menu = 0; + +void renderscore(dynent *d) +{ + s_sprintfd(lag)("%d", d->plag); + s_sprintfd(name) ("(%s)", d->name); + if(m_ctf) s_sprintf(scorelines.add().s)("%d\t%d\t%s\t%d\t%s\t%s", d->flagscore, d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->state==CS_DEAD ? name : d->name); + else s_sprintf(scorelines.add().s)("%d\t%s\t%d\t%s\t%s", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, m_teammode ? d->team : "", d->state==CS_DEAD ? name : d->name); + menumanual(menu, scorelines.length()-1, scorelines.last().s); +}; + +const int maxteams = 4; +char *teamname[maxteams]; +int teamscore[maxteams], teamflagscore[maxteams], teamsused; // EDIT: AH +string teamscores; +int timeremain = 0; + +void addteamscore(dynent *d) +{ + if(!d) return; + loopi(teamsused) if(strcmp(teamname[i], d->team)==0) + { + teamscore[i] += d->frags; + if(m_ctf) teamflagscore[i] += d->flagscore; + return; + }; + if(teamsused==maxteams) return; + teamname[teamsused] = d->team; + teamscore[teamsused] = d->frags; + if(m_ctf) teamflagscore[teamsused] = d->flagscore; + teamsused++; +}; + +void renderscores() +{ + if(!scoreson) return; + menu = m_ctf ? 2 : 0; + scorelines.setsize(0); + if(!demoplayback) renderscore(player1); + loopv(players) if(players[i]) renderscore(players[i]); + + // Added by Rick: Render Score for bots + BotManager.RenderBotScore(); + + sortmenu(menu, 0, scorelines.length()); + if(m_teammode) + { + teamsused = 0; + loopv(players) addteamscore(players[i]); + // Added by Rick: Add team scores for bots + BotManager.AddBotTeamScore(); + if(!demoplayback) addteamscore(player1); + teamscores[0] = 0; + loopj(teamsused) + { + string sc; + if(m_ctf) s_sprintf(sc)("[ %s: %d flags %d frags ]", teamname[j], teamflagscore[j], teamscore[j]); + else s_sprintf(sc)("[ %s: %d ]", teamname[j], teamscore[j]); + s_strcat(teamscores, sc); + }; + menumanual(menu, scorelines.length(), ""); + menumanual(menu, scorelines.length()+1, teamscores); + }; +}; + +// sendmap/getmap commands, should be replaced by more intuitive map downloading + +void sendmap(char *mapname) +{ + if(*mapname) save_world(mapname); + changemap(mapname); + mapname = getclientmap(); + int mapsize; + uchar *mapdata = readmap(mapname, &mapsize); + if(!mapdata) return; + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS + mapsize, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_SENDMAP); + sendstring(mapname, p); + putint(p, mapsize); + if(65535 - p.length() < mapsize) + { + conoutf("map %s is too large to send", (int)mapname); + delete[] mapdata; + enet_packet_destroy(packet); + return; + }; + p.put(mapdata, mapsize); + delete[] mapdata; + enet_packet_resize(packet, p.length()); + sendpackettoserv(2, packet); + conoutf("sending map %s to server...", mapname); + s_sprintfd(msg)("[map %s uploaded to server, \"getmap\" to receive it]", mapname); + toserver(msg); +} + +void getmap() +{ + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_RECVMAP); + enet_packet_resize(packet, p.length()); + sendpackettoserv(2, packet); + conoutf("requesting map from server..."); +} + +COMMAND(sendmap, ARG_1STR); +COMMAND(getmap, ARG_NONE); + diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp new file mode 100644 index 00000000..7224b51a --- /dev/null +++ b/source/src/clientgame.cpp @@ -0,0 +1,711 @@ +// clientgame.cpp: core game related stuff + +#include "cube.h" +int nextmode = 0; // nextmode becomes gamemode after next map load +VAR(gamemode, 1, 0, 0); + +flaginfo flaginfos[2]; + +void mode(int n) +{ + if(n==7 && clienthost) conoutf("this mode is for singleplayer only"); + else addmsg(SV_GAMEMODE, "ri", nextmode = n); +}; +COMMAND(mode, ARG_1INT); + +bool intermission = false; + +dynent *player1 = newdynent(); // our client +dvector players; // other clients + +vector physents; + +VAR(sensitivity, 0, 10, 1000); +VAR(sensitivityscale, 1, 1, 100); +VAR(invmouse, 0, 0, 1); + +int lastmillis = 0; +int curtime; +string clientmap; + +extern int framesinmap; + +char *getclientmap() { return clientmap; }; + +void resetmovement(dynent *d) +{ + d->k_left = false; + d->k_right = false; + d->k_up = false; + d->k_down = false; + d->jumpnext = false; + d->strafe = 0; + d->move = 0; +}; + +extern bool c2sinit; +extern int dblend; + +void spawnstate(dynent *d) // reset player state not persistent accross spawns +{ + resetmovement(d); + d->vel.x = d->vel.y = d->vel.z = 0; + d->onfloor = false; + d->timeinair = 0; + d->health = 100; + d->armour = 0; + //d->hasarmour = false; + //d->armourtype = A_BLUE; + d->akimbomillis = 0; + d->gunselect = GUN_PISTOL; + d->gunwait = 0; + d->attacking = false; + d->lastaction = lastmillis; + d->weaponchanging = false; + if(d==player1) + { + gun_changed = true; + player1->primary = player1->nextprimary; + if(player1->skin!=player1->nextskin) + { + c2sinit=false; + player1->skin=player1->nextskin; + } + scoped = false; + }; + radd(d); + dblend = 0; + d->akimbo = false; +}; + +dynent *newdynent() // create a new blank player or monster +{ + dynent *d = new dynent; + d->o.x = 0; + d->o.y = 0; + d->o.z = 0; + d->yaw = 270; + d->pitch = 0; + d->roll = 0; + d->maxspeed = 16; //16 max speed, 14 max with armour + d->outsidemap = false; + d->inwater = false; + d->radius = 1.1f; + d->eyeheight = 4.5f; //4.25f; + d->aboveeye = 0.7f; + d->frags = 0; + d->flagscore = 0; // EDIT: AH + d->plag = 0; + d->ping = 0; + d->lastupdate = lastmillis; + d->enemy = NULL; + d->monsterstate = 0; + d->name[0] = d->team[0] = 0; + d->blocked = false; + d->lifesequence = 0; + d->state = CS_ALIVE; + d->shots = 0; + d->reloading = false; + d->primary = d->nextprimary = GUN_ASSAULT; + d->hasarmour = false; + d->gunselect = GUN_PISTOL; + d->onladder = false; + d->isphysent = false; + d->inhandnade = NULL; + d->skin = d->nextskin = 0; + d->bIsBot = false; + d->pBot = NULL; + d->weaponchanging = false; + d->lastanimswitchtime = -1; + loopi(NUMGUNS) d->ammo[i] = d->mag[i] = 0; + d->skin = rnd(1 + rb_team_int(d->team) == TEAM_CLA ? 3 : 5); + spawnstate(d); + return d; +}; + +void ctf_death() // EDIT: AH +{ + int flag = rb_opposite(rb_team_int(player1->team)); + flaginfo &f = flaginfos[flag]; + if(f.state==CTFF_STOLEN && f.thief==player1) + { + addmsg(SV_FLAGDROP, "ri", flag); + f.flag->spawned = false; + f.state = CTFF_DROPPED; + }; +}; + +void respawnself() +{ + spawnplayer(player1); + showscores(false); +}; + +void respawn() +{ + if(player1->state==CS_DEAD && lastmillis>player1->lastaction+(m_ctf ? 5000 : 2000)) + { + player1->attacking = false; + if(m_arena) { conoutf("waiting for new round to start..."); return; }; + respawnself(); + weaponswitch(player1->primary); + player1->lastaction -= WEAPONCHANGE_TIME/2; + }; +}; + +void arenacount(dynent *d, int &alive, int &dead, char *&lastteam, char *&lastname, bool &oneteam) +{ + if(d->state!=CS_DEAD) + { + alive++; + if(lastteam && strcmp(lastteam, d->team)) oneteam = false; + lastteam = d->team; + lastname = d->name; + } + else + { + dead++; + }; +}; + +int arenarespawnwait = 0; +int arenadetectwait = 0; + +void arenarespawn() +{ + if (!m_arena) return; + + if(arenarespawnwait) + { + if(arenarespawnwait0 && (alive<=1 || (m_teammode && oneteam))) + { + conoutf("arena round is over! next round in 5 seconds..."); + if(alive) + { + if(m_teammode) + conoutf("team %s has won the round", lastteam); + else + conoutf("%s is the survior!", lastname); + } + else conoutf("everyone died!"); + arenarespawnwait = lastmillis+5000; + arenadetectwait = lastmillis+10000; + player1->roll = 0; + }; + }; +}; + + +void checkakimbo() +{ + if(player1->akimbo && player1->akimbomillis && player1->akimbomillis<=lastmillis) + { + player1->akimbo = false; + player1->akimbomillis = 0; + player1->mag[GUN_PISTOL] = min(magsize(GUN_PISTOL), player1->mag[GUN_PISTOL]); + if(player1->gunselect==GUN_PISTOL) weaponswitch(GUN_PISTOL); + playsoundc(S_PUPOUT); + } +}; + +void zapdynent(dynent *&d) +{ + DELETEP(d); +}; + +extern int democlientnum; + +void otherplayers() +{ + loopv(players) if(players[i]) + { + const int lagtime = lastmillis-players[i]->lastupdate; + if(lagtime>1000 && players[i]->state==CS_ALIVE) + { + players[i]->state = CS_LAGGED; + continue; + }; + if(lagtime && players[i]->state != CS_DEAD && (!demoplayback || i!=democlientnum)) moveplayer(players[i], 2, false); // use physics to extrapolate player position + }; + // Added by Rick + if (!ishost()) + { + loopv(bots) + { + if(bots[i] && bots[i]->state != CS_DEAD && (!demoplayback)) + moveplayer(bots[i], 2, false); // use physics to extrapolate bot position + } + } + // End add +}; + +struct scriptsleep +{ + int wait; + string cmd; + scriptsleep(int msec, char *command) { wait = msec+lastmillis; s_strcpy(cmd, command); }; +}; + +vector sleeps; + +/*int sleepwait = 0; +string sleepcmd;*/ +//void addsleep(char *msec, char *cmd) { sleepwait = atoi(msec)+lastmillis; strcpy_s(sleepcmd, cmd); }; +void addsleep(char *msec, char *cmd) { scriptsleep s(atoi(msec), cmd); sleeps.add(s); }; +COMMANDN(sleep, addsleep, ARG_2STR); + +void updateworld(int curtime, int lastmillis) // main game update loop +{ + //if(sleepwait && lastmillis>sleepwait) { sleepwait = 0; execute(sleepcmd); }; + loopv(sleeps) if(sleeps[i].wait && lastmillis > sleeps[i].wait) { execute(sleeps[i].cmd); sleeps.remove(i); i--; }; + physicsframe(); + checkakimbo(); + checkweaponswitch(); + //if(m_arena) arenarespawn(); + arenarespawn(); + moveprojectiles((float)curtime); + demoplaybackstep(); + if(!demoplayback) + { + if(getclientnum()>=0) shoot(player1, worldpos); // only shoot when connected to server + gets2c(); // do this first, so we have most accurate information when our player moves + }; + mphysents(); + otherplayers(); + if(!demoplayback) + { + //monsterthink(); + + // Added by Rick: let bots think + BotManager.Think(); + + //put game mode extra call here + if(player1->state==CS_DEAD) + { + if(lastmillis-player1->lastaction<2000) + { + player1->move = player1->strafe = 0; + moveplayer(player1, 10, false); + }; + } + else if(!intermission) + { + moveplayer(player1, 20, true); + checkitems(); + }; + c2sinfo(player1); // do this last, to reduce the effective frame lag + }; +}; + +void entinmap(dynent *d) // brute force but effective way to find a free spawn spot in the map +{ + loopi(100) // try max 100 times + { + float dx = (rnd(21)-10)/10.0f*i; // increasing distance + float dy = (rnd(21)-10)/10.0f*i; + d->o.x += dx; + d->o.y += dy; + if(collide(d, true, 0, 0)) return; + d->o.x -= dx; + d->o.y -= dy; + }; + conoutf("can't find entity spawn spot! (%d, %d)", d->o.x, d->o.y); + // leave ent at original pos, possibly stuck +}; + +// EDIT: AH +int securespawndist = 15; + +// Returns -1 for a free place, if not it returns the vdist to the nearest enemy +int nearestenemy(vec *v, string team) +{ + float nearestPlayerDistSquared = -1; + loopv(players) + { + dynent *other = players[i]; + if(!other) continue; + if(isteam(team,other->team))continue; // its a teammate + vec place = {v->x, v->y, v->z}; + vdistsquared(distsquared, t, place, other->o); + if(nearestPlayerDistSquared == -1) nearestPlayerDistSquared = distsquared; // first run + else if(distsquared < nearestPlayerDistSquared) nearestPlayerDistSquared = distsquared; // if a player is closer + }; + if(nearestPlayerDistSquared >= securespawndist * securespawndist || nearestPlayerDistSquared == -1) return -1; // a distance more than securespawndist means the place is free + else return (int)sqrtf(nearestPlayerDistSquared); +}; + +int spawncycle = -1; +int fixspawn = 2; + +void spawnplayer(dynent *d, bool secure) // place at random spawn +{ + loopj(10) // EDIT: AH + { + int r = fixspawn-->0 ? 4 : rnd(10)+1; + loopi(r) spawncycle = findplayerstart(m_teammode ? rb_team_int(d->team) : 100, spawncycle+1); + if(spawncycle!=-1 && secure) + { + entity &e = ents[spawncycle]; + vec pos = { e.x, e.y, e.z }; + if(nearestenemy(&pos, d->team) == -1) break; + } else break; + }; + if(spawncycle!=-1) + { + d->o.x = ents[spawncycle].x; + d->o.y = ents[spawncycle].y; + d->o.z = ents[spawncycle].z; + d->yaw = ents[spawncycle].attr1; + d->pitch = 0; + d->roll = 0; + } + else + { + d->o.x = d->o.y = (float)ssize/2; + d->o.z = 4; + }; + entinmap(d); + spawnstate(d); + d->state = CS_ALIVE; +}; + +// movement input code + +#define dir(name,v,d,s,os) void name(bool isdown) { player1->s = isdown; player1->v = isdown ? d : (player1->os ? -(d) : 0); player1->lastmove = lastmillis; }; + +dir(backward, move, -1, k_down, k_up); +dir(forward, move, 1, k_up, k_down); +dir(left, strafe, 1, k_left, k_right); +dir(right, strafe, -1, k_right, k_left); + +void attack(bool on) +{ + if(intermission) return; + if(editmode) editdrag(on); + else if(player1->state==CS_DEAD) respawn(); + else player1->attacking = on; +}; + +void jumpn(bool on) { if(!intermission && (player1->jumpnext = on) ) respawn(); }; + +COMMAND(backward, ARG_DOWN); +COMMAND(forward, ARG_DOWN); +COMMAND(left, ARG_DOWN); +COMMAND(right, ARG_DOWN); +COMMANDN(jump, jumpn, ARG_DOWN); +COMMAND(attack, ARG_DOWN); +COMMAND(showscores, ARG_DOWN); + +void fixplayer1range() +{ + const float MAXPITCH = 90.0f; + if(player1->pitch>MAXPITCH) player1->pitch = MAXPITCH; + if(player1->pitch<-MAXPITCH) player1->pitch = -MAXPITCH; + while(player1->yaw<0.0f) player1->yaw += 360.0f; + while(player1->yaw>=360.0f) player1->yaw -= 360.0f; +}; + +void mousemove(int dx, int dy) +{ + if(player1->state==CS_DEAD || intermission) return; + const float SENSF = 33.0f; // try match quake sens + player1->yaw += (dx/SENSF)*(sensitivity/(float)sensitivityscale); + player1->pitch -= (dy/SENSF)*(sensitivity/(float)sensitivityscale)*(invmouse ? -1 : 1); + fixplayer1range(); +}; + +// damage arriving from the network, monsters, yourself, all ends up here. + +void selfdamage(int damage, int actor, dynent *act, bool gib) +{ + if(!act) return; + if(player1->state!=CS_ALIVE || editmode || intermission) return; + damageblend(damage); + demoblend(damage); + int ad = damage*30/100; // let armour absorb when possible + if(ad>player1->armour) ad = player1->armour; + player1->armour -= ad; + damage -= ad; + float droll = damage/0.5f; + player1->roll += player1->roll>0 ? droll : (player1->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage + if((player1->health -= damage)<=0) + { + if(actor==-2) + { + conoutf("you got killed by %s!", &act->name); + } + else if(actor==-1) + { + actor = getclientnum(); + conoutf("you suicided!"); + addmsg(SV_FRAGS, "ri", --player1->frags); + } + else + { + // Modified by Rick + //dynent *a = getclient(actor); + dynent *a; + if(act->bIsBot) a = act; + else a = getclient(actor); + // End mod + + if(a) + { + if(isteam(a->team, player1->team)) + { + conoutf("you got fragged by a teammate (%s)", a->name); + } + else + { + conoutf("you got fragged by %s", a->name); + }; + }; + }; + // EDIT: AH + if(m_ctf) ctf_death(); + showscores(true); + setscope(false); + if(act->bIsBot) addmsg(SV_DIEDBYBOT, "ri", actor); + else addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor); + player1->lifesequence++; + player1->attacking = false; + player1->state = CS_DEAD; + player1->oldpitch = player1->pitch; + player1->pitch = 0; + player1->roll = 60; + playsound(S_DIE1+rnd(2)); + if(gib) addgib(player1); + spawnstate(player1); + //player1->lastaction = lastmillis; + //fixme + if (act->bIsBot) addmsg(SV_BOTFRAGS, "rii", BotManager.GetBotIndex(act), ++act->frags); + } + else + { + playsound(S_PAIN6); + }; +}; + +void timeupdate(int timeremain) +{ + if(!timeremain) + { + intermission = true; + player1->attacking = false; + conoutf("intermission:"); + conoutf("game has ended!"); + showscores(true); + execute("start_intermission"); + } + else + { + conoutf("time remaining: %d minutes", timeremain); + }; +}; + +dynent *getclient(int cn) // ensure valid entity +{ + if(cn<0 || cn>=MAXCLIENTS) + { + neterr("clientnum"); + return NULL; + }; + while(cn>=players.length()) players.add(NULL); + return players[cn] ? players[cn] : (players[cn] = newdynent()); +}; + +// Added by Rick +dynent *getbot(int cn) // ensure valid entity +{ + if(cn<0 || cn>=MAXCLIENTS) + { + neterr("botnum"); + return NULL; + }; + + while(cn>=bots.length()) bots.add(NULL); + if (!bots[cn]) + { + bots[cn] = newdynent(); + if (bots[cn]) + { + bots[cn]->pBot = NULL; + bots[cn]->bIsBot = true; + } + } + + return bots[cn]; +}; +// End add by Rick + +void initclient() +{ + clientmap[0] = 0; + initclientnet(); +}; + +entity flagdummies[2]; // in case the map does not provide flags + +void preparectf(bool cleanonly=false) +{ + loopi(2) flaginfos[i].flag = &flagdummies[i]; + if(!cleanonly) + { + loopv(ents) + { + entity &e = ents[i]; + if(e.type==CTF_FLAG) + { + e.spawned = true; + if(e.attr2>2) { conoutf("invalid ctf-flag entity (%i)", i); e.attr2 = 0; }; + flaginfo &f = flaginfos[e.attr2]; + f.flag = &e; + f.state = CTFF_INBASE; + f.originalpos.x = (float) e.x; + f.originalpos.y = (float) e.y; + f.originalpos.z = (float) e.z; + }; + }; + newteam(player1->team); // ensure valid team + }; +}; + +extern void kickallbots(void); + +void startmap(char *name) // called just after a map load +{ + //if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? + netmapstart(); //should work + //monsterclear(); + // Added by Rick + kickallbots(); + if(m_botmode) BotManager.BeginMap(name); +// else sleepwait = 0; + // End add by Rick + projreset(); + if(m_ctf) preparectf(); + shotlinereset(); + spawncycle = -1; + spawnplayer(player1, true); + player1->frags = 0; + player1->flagscore = 0; + loopv(players) if(players[i]) players[i]->frags = 0; + resetspawns(); + s_strcpy(clientmap, name); + if(editmode) toggleedit(); + setvar("gamespeed", 100); + setvar("fog", 180); + setvar("fogcolour", 0x8099B3); + showscores(false); + intermission = false; + framesinmap = 0; + conoutf("game mode is %s", modestr(gamemode)); +}; + +COMMANDN(map, changemap, ARG_1STR); + +void suicide() +{ + if(player1->state==CS_DEAD) return; + selfdamage(1000, -1, player1); + demodamage(1000, player1->o); +}; + +COMMAND(suicide, ARG_NONE); + +// EDIT: AH +void flagaction(int flag, int action) +{ + flaginfo &f = flaginfos[flag]; + if(!f.thief) return; + bool ownflag = flag == rb_team_int(player1->team); + switch(action) + { + case SV_FLAGPICKUP: + { + playsound(S_FLAGPICKUP); + if(f.thief==player1) + { + conoutf("you got the enemy flag"); + f.pick_ack = true; + } + else conoutf("%s got %s flag", f.thief->name, (ownflag ? "your": "the enemy")); + break; + }; + case SV_FLAGDROP: + { + playsound(S_FLAGDROP); + if(f.thief==player1) conoutf("you lost the flag"); + else conoutf("%s lost %s flag", f.thief->name, (ownflag ? "your" : "the enemy")); + break; + }; + case SV_FLAGRETURN: + { + playsound(S_FLAGRETURN); + if(f.thief==player1) conoutf("you returned your flag"); + else conoutf("%s returned %s flag", f.thief->name, (ownflag ? "your" : "the enemy")); + break; + }; + case SV_FLAGSCORE: + { + playsound(S_FLAGSCORE); + if(f.thief==player1) + { + conoutf("you scored"); + addmsg(SV_FLAGS, "ri", ++player1->flagscore); + } + else conoutf("%s scored for %s team", f.thief->name, (ownflag ? "the enemy" : "your")); + break; + }; + default: break; + }; +}; + +void getmaster(char *pwd) +{ + if(!pwd[0]) return; + if(strlen(pwd)>15) { conoutf("the master password has a maximum length of 15 characters"); return; }; + addmsg(SV_GETMASTER, "rs", pwd); +}; + +void mastercommand(int cmd, int a) +{ + addmsg(SV_MASTERCMD, "rii", cmd, a); +}; + +void showmastermenu(int m) // 0=kick, 1=ban +{ + int menu = (m == MCMD_KICK ? 3 : 4); + purgemenu(menu); + + loopv(players) + { + if(players[i]) menumanual(menu, i, players[i]->name, (char *) i); // ugly hack + }; + menuset(menu); +}; + +COMMANDN(masterlogin, getmaster, ARG_1STR); +COMMAND(mastercommand, ARG_2INT); +COMMAND(showmastermenu, ARG_1INT); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp new file mode 100644 index 00000000..d3598b56 --- /dev/null +++ b/source/src/clients2c.cpp @@ -0,0 +1,715 @@ +// client processing of the incoming network stream + +#include "cube.h" + +extern int clientnum; +extern bool c2sinit, senditemstoserver; +extern string clientpassword; + +void neterr(char *s) +{ + conoutf("illegal network message (%s)", s); + disconnect(); +}; + +void changemapserv(char *name, int mode) // forced map change from the server +{ + gamemode = mode; + load_world(name); +}; + +void changemap(char *name) // request map change, server may ignore +{ + addmsg(SV_MAPCHANGE, "rsi", name, nextmode); +}; + +// Added by Rick +void botcommand(ucharbuf &p, char *text) +{ + int type = getint(p); + switch(EBotCommands(type)) + { + case COMMAND_ADDBOT: + getint(p); + getint(p); + getstring(text, p); + getstring(text, p); + break; + case COMMAND_KICKBOT: + if (getint(p)==1) // Kick a specific bot + getstring(text, p); + break; + case COMMAND_BOTSKILL: + getint(p); + break; + } +} +// End add + + +// update the position of other clients in the game in our world +// don't care if he's in the scenery or other players, +// just don't overlap with our client + +void updatepos(dynent *d) +{ + const float r = player1->radius+d->radius; + const float dx = player1->o.x-d->o.x; + const float dy = player1->o.y-d->o.y; + const float dz = player1->o.z-d->o.z; + const float rz = player1->aboveeye+d->eyeheight; + const float fx = (float)fabs(dx), fy = (float)fabs(dy), fz = (float)fabs(dz); + if(fxstate!=CS_DEAD) + { + if(fxo.y += dy<0 ? r-fy : -(r-fy); // push aside + else d->o.x += dx<0 ? r-fx : -(r-fx); + }; + int lagtime = lastmillis-d->lastupdate; + if(lagtime) + { + d->plag = (d->plag*5+lagtime)/6; + d->lastupdate = lastmillis; + }; +}; + +extern void trydisconnect(); + +#define CN_CHECK if(!players.inrange(cn)) { conoutf("invalid client (msg %i)", type); return; }; +//#define SENDER_CHECK if(sender<0) { conoutf("invalid sender (msg %i)", type); return; }; + +void parsepositions(ucharbuf &p) +{ + int cn = -1, type; + dynent *d = NULL; + while(p.remaining()) switch(type = getint(p)) + { + case SV_POS: // position of another client + { + cn = getint(p); + d = getclient(cn); + if(!d) return; + d->o.x = getuint(p)/DMF; + d->o.y = getuint(p)/DMF; + d->o.z = getuint(p)/DMF; + d->yaw = getuint(p)/DAF; + d->pitch = getint(p)/DAF; + d->roll = getint(p)/DAF; + d->vel.x = getint(p)/DVF; + d->vel.y = getint(p)/DVF; + d->vel.z = getint(p)/DVF; + int f = getint(p); + d->strafe = (f&3)==3 ? -1 : f&3; + f >>= 2; + d->move = (f&3)==3 ? -1 : f&3; + d->onfloor = (f>>2)&1; + int state = f>>3; + if(state==CS_DEAD && d->state!=CS_DEAD) d->lastaction = lastmillis; + d->state = state; + if(!demoplayback) updatepos(d); + break; + }; + + case SV_BOTUPDATE: + { + int n = getint(p); + dynent *b = getbot(n); + if(!b) return; + b->o.x = getint(p)/DMF; + b->o.y = getint(p)/DMF; + b->o.z = getint(p)/DMF; + b->yaw = getint(p)/DAF; + b->pitch = getint(p)/DAF; + b->roll = getint(p)/DAF; + b->vel.x = getint(p)/DVF; + b->vel.y = getint(p)/DVF; + b->vel.z = getint(p)/DVF; + int f = getint(p); + b->strafe = (f&3)==3 ? -1 : f&3; + f >>= 2; + b->move = (f&3)==3 ? -1 : f&3; + b->onfloor = (f>>2)&1; + int state = f>>3; + if(state==CS_DEAD && b->state!=CS_DEAD) b->lastaction = lastmillis; + b->state = state; + + if (!b->bIsBot) + b->bIsBot = true; + + if(!demoplayback) updatepos(b); + break; + }; + + default: + neterr("type"); + return; + }; +}; + +void parsemessages(int cn, dynent *d, ucharbuf &p) +{ + char text[MAXTRANS]; + int type; + bool mapchanged = false; + bool c2si = false, killedbybot=false; + bool gib=false; + + while(p.remaining()) switch(type = getint(p)) + { + case SV_INITS2C: // welcome messsage from the server + { + int mycn = getint(p), prot = getint(p); + if(prot!=PROTOCOL_VERSION) + { + conoutf("you are using a different game protocol (you: %d, server: %d)", PROTOCOL_VERSION, prot); + disconnect(); + return; + }; + clientnum = mycn; // we are now fully connectedss + bool firstplayer = !getint(p); + if(getint(p) > 0) + { + conoutf("INFO: this server is password protected"); + addmsg(SV_PWD, "rs", clientpassword); + }; + if(firstplayer) changemap(getclientmap()); // we are the first client on this server, set map + break; + }; + + case SV_SOUND: + playsound(getint(p), &d->o); + break; + + case SV_TEXT: + getstring(text, p); + conoutf("%s:\f %s", d->name, &text); + break; + + case SV_MAPCHANGE: + getstring(text, p); + changemapserv(text, getint(p)); + mapchanged = true; + break; + + case SV_ITEMLIST: + { + int n; + if(mapchanged) { senditemstoserver = false; resetspawns(); }; + while((n = getint(p))!=-1) if(mapchanged) setspawn(n, true); + break; + }; + + case SV_MAPRELOAD: // server requests next map + { + getint(p); + s_sprintfd(nextmapalias)("nextmap_%s", getclientmap()); + char *map = getalias(nextmapalias); // look up map in the cycle + changemap(map ? map : getclientmap()); + break; + }; + + case SV_INITC2S: // another client either connected or changed name/team + { + getstring(text, p); + if(d->name[0]) // already connected + { + if(strcmp(d->name, text)) + conoutf("%s is now known as %s", d->name, &text); + } + else // new client + { + c2sinit = false; // send new players my info again + conoutf("connected: %s", &text); + gun_changed = true; + // Added by Rick: If we are the host("the bot owner"), tell the bots + // to update their stats + if (ishost()) + BotManager.LetBotsUpdateStats(); + // End add by Rick + }; + s_strcpy(d->name, text); + getstring(text, p); + s_strcpy(d->team, text); + d->skin = getint(p); + d->lifesequence = getint(p); + c2si = true; + break; + }; + + case SV_CDIS: + { + int cn = getint(p); + if(!(d = getclient(cn))) break; + if(d->name[0]) conoutf("player %s disconnected", d->name); + zapdynent(players[cn]); + break; + }; + + case SV_SHOT: + { + int gun = getint(p); + vec s, e; + s.x = getint(p)/DMF; + s.y = getint(p)/DMF; + s.z = getint(p)/DMF; + e.x = getint(p)/DMF; + e.y = getint(p)/DMF; + e.z = getint(p)/DMF; + if(gun==GUN_SHOTGUN) createrays(s, e); + shootv(gun, s, e, d, false, getint(p)); + break; + }; + case SV_GIBDAMAGE: + gib = true; + case SV_DAMAGE: + { + int target = getint(p); + int damage = getint(p); + int ls = getint(p); + if(target==clientnum) { if(ls==player1->lifesequence) selfdamage(damage, cn, d, gib); } + else playsound(S_PAIN1+rnd(5), &getclient(target)->o); + gib = false; + break; + } + + case SV_BOT2CLIENTDMG: + { + + int target = getint(p); + int damage = getint(p); + int ls = getint(p); + int damager = getint(p); + + if(target==clientnum) + { + dynent *a = getbot(damager); + if(ls==player1->lifesequence) + selfdamage(damage, cn, a); + } + else playsound(S_PAIN1+rnd(5), &getclient(target)->o); + break; + } + + + case SV_DIEDBYBOT: + killedbybot = true; + case SV_GIBDIED: + if(type!=SV_DIEDBYBOT) gib = true; // uargl.. fixme + case SV_DIED: + { + int actor = getint(p); + + if(actor==cn && !killedbybot) + { + conoutf("%s suicided", d->name); + } + else if(actor==clientnum && !killedbybot) + { + int frags; + if(isteam(player1->team, d->team)) + { + frags = -1; + conoutf("you fragged a teammate (%s)", d->name); + } + else + { + frags = 1; + conoutf("you fragged %s", d->name); + }; + addmsg(SV_FRAGS, "ri", player1->frags += frags); + if(gib) addgib(d); + } + else + { + dynent *a = killedbybot ? getbot(actor) : getclient(actor); + if(a) + { + if(isteam(a->team, d->name)) + { + conoutf("%s fragged his teammate (%s)", a->name, d->name); + } + else + { + conoutf("%s fragged %s", a->name, d->name); + }; + if(gib) addgib(d); + }; + }; + playsound(S_DIE1+rnd(2), &d->o); + if(!c2si) d->lifesequence++; + killedbybot = gib = false; + break; + }; + + + + case SV_FRAGS: + CN_CHECK; + players[cn]->frags = getint(p); + break; + + case SV_RESUME: + { + int cn = getint(p), frags = getint(p); + if(cn==clientnum) player1->frags = frags; + else + { + dynent *d = getclient(cn); + if(d) d->frags = frags; + }; + break; + }; + + case SV_ITEMPICKUP: + case SV_BOTITEMPICKUP: + setspawn(getint(p), false); + getint(p); + break; + + case SV_ITEMSPAWN: + { + uint i = getint(p); + setspawn(i, true); + break; + }; + + case SV_ITEMACC: // server acknowledges that I picked up this item + realpickup(getint(p), player1); + break; + + case SV_EDITH: // coop editing messages, should be extended to include all possible editing ops + case SV_EDITT: + case SV_EDITS: + case SV_EDITD: + case SV_EDITE: + { + int x = getint(p); + int y = getint(p); + int xs = getint(p); + int ys = getint(p); + int v = getint(p); + block b = { x, y, xs, ys }; + switch(type) + { + case SV_EDITH: editheightxy(v!=0, getint(p), b); break; + case SV_EDITT: edittexxy(v, getint(p), b); break; + case SV_EDITS: edittypexy(v, b); break; + case SV_EDITD: setvdeltaxy(v, b); break; + case SV_EDITE: editequalisexy(v!=0, b); break; + }; + break; + }; + + case SV_EDITENT: // coop edit of ent + { + uint i = getint(p); + while((uint)ents.length()<=i) ents.add().type = NOTUSED; + int to = ents[i].type; + ents[i].type = getint(p); + ents[i].x = getint(p); + ents[i].y = getint(p); + ents[i].z = getint(p); + ents[i].attr1 = getint(p); + ents[i].attr2 = getint(p); + ents[i].attr3 = getint(p); + ents[i].attr4 = getint(p); + ents[i].spawned = false; + if(ents[i].type==LIGHT || to==LIGHT) calclight(); + break; + }; + + case SV_PONG: + addmsg(SV_CLIENTPING, "i", player1->ping = (player1->ping*5+lastmillis-getint(p))/6); + break; + + case SV_CLIENTPING: + CN_CHECK; + players[cn]->ping = getint(p); + break; + + case SV_GAMEMODE: + nextmode = getint(p); + break; + + case SV_TIMEUP: + timeupdate(getint(p)); + break; + + case SV_RECVMAP: + { + getstring(text, p); + conoutf("received map \"%s\" from server, reloading..", &text); + int mapsize = getint(p); + if(p.remaining() < mapsize) + { + p.forceoverread(); + break; + }; + writemap(text, mapsize, &p.buf[p.len]); + p.len += mapsize; + changemapserv(text, gamemode); + break; + }; + + case SV_WEAPCHANGE: + { + CN_CHECK; + players[cn]->gunselect = getint(p); + break; + }; + + case SV_SERVMSG: + getstring(text, p); + conoutf("%s", text); + break; + + // EDIT: AH + case SV_FLAGINFO: + { + int flag = getint(p); + if(flag<0||flag>1) return; + flaginfo &f = flaginfos[flag]; + f.state = getint(p); + int action = getint(p); + if(f.state==CTFF_STOLEN) + { + int thief_cn = getint(p); + f.thief = thief_cn == getclientnum() ? player1 : getclient(thief_cn); + f.flag->spawned = false; + } + else if(f.state==CTFF_DROPPED) + { + f.flag->x = (ushort) (getint(p)/DMF); + f.flag->y = (ushort) (getint(p)/DMF); + f.flag->z = (ushort) (getint(p)/DMF); + f.flag->z -= 4; + float floor = (float)S(f.flag->x, f.flag->y)->floor; + if(f.flag->z > hdr.waterlevel) // above water + { + if(floor < hdr.waterlevel) + f.flag->z = hdr.waterlevel; // avoid dropping into water + else + f.flag->z = (short)floor; + }; + f.flag->spawned = true; + } + else if(f.state==CTFF_INBASE) + { + if(action==SV_FLAGRETURN) + { + int returnerer_cn = getint(p); + f.thief = returnerer_cn == getclientnum() ? player1 : getclient(returnerer_cn); + } + f.flag->x = (ushort) f.originalpos.x; + f.flag->y = (ushort) f.originalpos.y; + f.flag->z = (ushort) f.originalpos.z; + f.flag->spawned = true; + }; + flagaction(flag, action); + break; + }; + + case SV_FLAGS: + { + CN_CHECK; + players[cn]->flagscore = getint(p); + break; + }; + + case SV_FLAGPICKUP: + { + int flag = getint(p); + if(flag<0||flag>1) return; + flaginfos[flag].state=CTFF_STOLEN; + break; + }; + + // Added by Rick: Bot specific messages + case SV_BOTSOUND: + { + int Sound = getint(p); + dynent *pBot = getbot(getint(p)); + + if (pBot) + playsound(Sound, &pBot->o); + + break; + } + + case SV_ADDBOT: // Bot joined the game + { + dynent *b = getbot(getint(p)); + if (!b) break; + + getstring(text, p); + if(b->name[0]) // already connected + { + if(strcmp(b->name, text)) + conoutf("%s is now known as %s", b->name, &text); + } + else // new client + { + //c2sinit = false; // send new players my info again + conoutf("connected: %s", &text); + }; + s_strcpy(b->name, text); + getstring(text, p); + s_strcpy(b->team, text); + b->lifesequence = getint(p); + b->bIsBot = true; + b->pBot = NULL; + break; + }; + + case SV_BOTDIS: + { + int n = getint(p); + dynent *b = getbot(n); + + if (!b) + break; + + conoutf("bot %s disconnected", b->name[0] ? b->name : "[incompatible client]"); + delete b->pBot; + zapdynent(bots[n]); + bots.remove(n); + break; + } + + case SV_CLIENT2BOTDMG: + case SV_BOT2BOTDMG: + { + int target = getint(p); + int damage = getint(p); + int damager = getint(p); + dynent *b = getbot(target); + + dynent *a; + if (damager == -1) + { + // HACK! if the local client who sended the message is the damager, its -1 + a = d; + } + else if (type == SV_CLIENT2BOTDMG) + { + if (damager == clientnum) a = player1; + else a = getclient(damager); + } + else + a = getbot(damager); + + if (b && a) + { + // Do we know the bot info? if so we are the host... + if (b->pBot) b->pBot->BotPain(damage, a); + playsound(S_PAIN1+rnd(5), &b->o); + } + break; + } + + case SV_BOTDIED: + { + int b = getint(p); + int killer = getint(p); + bool KilledByABot = getint(p) > 0; //fixmebot + dynent *bot = getbot(b); + + if((b==killer) && KilledByABot) + { + conoutf("%s suicided", bot->name); + } + else if((killer==clientnum) && !KilledByABot) + { + int frags; + if(isteam(player1->team, bot->team)) + { + frags = -1; + conoutf("you fragged a teammate (%s)", bot->name); + } + else + { + frags = 1; + conoutf("you fragged %s", bot->name); + }; + addmsg(SV_FRAGS, "ri", player1->frags += frags); + if(player1->gunselect==GUN_KNIFE) + addgib(bot); + } + else + { + dynent *k; + if (KilledByABot) + k = getbot(killer); + else if (killer == -1) + // if killer = -1, 'a player1' sended the message(hack) + k = d; + else + k = getclient(killer); + + if(bot && k) + { + if(isteam(bot->team, k->name)) + { + conoutf("%s fragged his teammate (%s)", bot->name, k->name); + } + else + { + conoutf("%s fragged %s", bot->name, k->name); + } + if(k->gunselect==GUN_KNIFE) addgib(bot); + } + } + playsound(S_DIE1+rnd(2), &bot->o); + bot->lifesequence++; + break; + }; + + case SV_BOTFRAGS: + { + dynent *b = getbot(getint(p)); + if (b) b->frags = getint(p); + break; + }; + + case SV_BOTCOMMAND: + botcommand(p, text); + break; + + case SV_NOP: + { + getint(p); break; + }; + + // End add + + default: + neterr("type"); + return; + }; +}; + +void localservertoclient(int chan, uchar *buf, int len) // processes any updates from the server +{ + incomingdemodata(chan, buf, len); + + ucharbuf p(buf, len); + + switch(chan) + { + case 0: parsepositions(p); break; + case 1: parsemessages(-1, NULL, p); break; + case 2: + while(p.remaining()) + { + int cn = p.get(); + dynent *d = getclient(cn); + int len = p.get(); + len += p.get()<<8; + ucharbuf q(&p.buf[p.len], min(len, p.maxlen-p.len)); + if(d) parsemessages(cn, d, q); + p.len += min(len, p.maxlen-p.len); + }; + break; + case 3: parsemessages(-1, NULL, p); break; + }; +}; + diff --git a/source/src/command.cpp b/source/src/command.cpp new file mode 100644 index 00000000..5630f9b1 --- /dev/null +++ b/source/src/command.cpp @@ -0,0 +1,335 @@ +// command.cpp: implements the parsing and execution of a tiny script language which +// is largely backwards compatible with the quake console language. + +#include "cube.h" + +enum { ID_VAR, ID_COMMAND, ID_ALIAS }; + +struct ident +{ + int type; // one of ID_* above + char *name; + int min, max; // ID_VAR + int *storage; // ID_VAR + void (*fun)(); // ID_VAR, ID_COMMAND + int narg; // ID_VAR, ID_COMMAND + char *action; // ID_ALIAS + bool persist; +}; + +void itoa(char *s, int i) { s_sprintf(s)("%d", i); }; +char *exchangestr(char *o, char *n) { delete[] o; return newstring(n); }; + +hashtable *idents = NULL; // contains ALL vars/commands/aliases + +void alias(char *name, char *action) +{ + ident *b = idents->access(name); + if(!b) + { + name = newstring(name); + ident b = { ID_ALIAS, name, 0, 0, 0, 0, 0, newstring(action) }; + idents->access(name, &b); + } + else + { + if(b->type==ID_ALIAS) b->action = exchangestr(b->action, action); + else conoutf("cannot redefine builtin %s with an alias", name); + }; +}; + +COMMAND(alias, ARG_2STR); + +// variable's and commands are registered through globals, see cube.h + +int variable(char *name, int min, int cur, int max, int *storage, void (*fun)(), bool persist) +{ + if(!idents) idents = new hashtable; + ident v = { ID_VAR, name, min, max, storage, fun, 0, 0, persist }; + idents->access(name, &v); + return cur; +}; + +void setvar(char *name, int i) { *idents->access(name)->storage = i; }; +int getvar(char *name) { return *idents->access(name)->storage; }; +bool identexists(char *name) { return idents->access(name)!=NULL; }; + +char *getalias(char *name) +{ + ident *i = idents->access(name); + return i && i->type==ID_ALIAS ? i->action : NULL; +}; + +bool addcommand(char *name, void (*fun)(), int narg) +{ + if(!idents) idents = new hashtable; + ident c = { ID_COMMAND, name, 0, 0, 0, fun, narg, 0 }; + idents->access(name, &c); + return false; +}; + +char *parseexp(char *&p, int right) // parse any nested set of () or [] +{ + int left = *p++; + char *word = p; + for(int brak = 1; brak; ) + { + int c = *p++; + if(c==left) brak++; + else if(c==right) brak--; + else if(!c) { p--; conoutf("missing \"%c\"", right); return NULL; }; + }; + char *s = newstring(word, p-word-1); + if(left=='(') + { + string t; + itoa(t, execute(s)); // evaluate () exps directly, and substitute result + s = exchangestr(s, t); + }; + return s; +}; + +char *parseword(char *&p) // parse single argument, including expressions +{ + p += strspn(p, " \t\r"); + if(p[0]=='/' && p[1]=='/') p += strcspn(p, "\n\0"); + if(*p=='\"') + { + p++; + char *word = p; + p += strcspn(p, "\"\r\n\0"); + char *s = newstring(word, p-word); + if(*p=='\"') p++; + return s; + }; + if(*p=='(') return parseexp(p, ')'); + if(*p=='[') return parseexp(p, ']'); + char *word = p; + p += strcspn(p, "; \t\r\n\0"); + if(p-word==0) return NULL; + return newstring(word, p-word); +}; + +char *lookup(char *n) // find value of ident referenced with $ in exp +{ + ident *id = idents->access(n+1); + if(id) switch(id->type) + { + case ID_VAR: string t; itoa(t, *(id->storage)); return exchangestr(n, t); + case ID_ALIAS: return exchangestr(n, id->action); + }; + conoutf("unknown alias lookup: %s", n+1); + return n; +}; + +int execute(char *p, bool isdown) // all evaluation happens here, recursively +{ + const int MAXWORDS = 25; // limit, remove + char *w[MAXWORDS]; + int val = 0; + for(bool cont = true; cont;) // for each ; seperated statement + { + int numargs = MAXWORDS; + loopi(MAXWORDS) // collect all argument values + { + w[i] = ""; + if(i>numargs) continue; + char *s = parseword(p); // parse and evaluate exps + if(!s) { numargs = i; s = ""; }; + if(*s=='$') s = lookup(s); // substitute variables + w[i] = s; + }; + + p += strcspn(p, ";\n\0"); + cont = *p++!=0; // more statements if this isn't the end of the string + char *c = w[0]; + if(*c=='/') c++; // strip irc-style command prefix + if(!*c) continue; // empty statement + + ident *id = idents->access(c); + if(!id) + { + val = ATOI(c); + if(!val && *c!='0') conoutf("unknown command: %s", c); + } + else switch(id->type) + { + case ID_COMMAND: // game defined commands + switch(id->narg) // use very ad-hoc function signature, and just call it + { + case ARG_1INT: if(isdown) ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; + case ARG_2INT: if(isdown) ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; + case ARG_3INT: if(isdown) ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; + case ARG_4INT: if(isdown) ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; + case ARG_NONE: if(isdown) ((void (__cdecl *)())id->fun)(); break; + case ARG_1STR: if(isdown) ((void (__cdecl *)(char *))id->fun)(w[1]); break; + case ARG_2STR: if(isdown) ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; + case ARG_3STR: if(isdown) ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; + case ARG_5STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; + case ARG_6STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6]); break; + case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(isdown); break; + case ARG_DWN1: ((void (__cdecl *)(bool, char *))id->fun)(isdown, w[1]); break; + case ARG_1EXP: if(isdown) val = ((int (__cdecl *)(int))id->fun)(execute(w[1])); break; + case ARG_2EXP: if(isdown) val = ((int (__cdecl *)(int, int))id->fun)(execute(w[1]), execute(w[2])); break; + case ARG_1EST: if(isdown) val = ((int (__cdecl *)(char *))id->fun)(w[1]); break; + case ARG_2EST: if(isdown) val = ((int (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; + case ARG_VARI: if(isdown) + { + string r; // limit, remove + r[0] = 0; + for(int i = 1; ifun)(r); + break; + } + }; + break; + + case ID_VAR: // game defined variabled + if(isdown) + { + if(!w[1][0]) conoutf("%s = %d", c, *id->storage); // var with no value just prints its current value + else + { + if(id->min>id->max) + { + conoutf("variable is read-only"); + } + else + { + int i1 = ATOI(w[1]); + if(i1min || i1>id->max) + { + i1 = i1min ? id->min : id->max; // clamp to valid range + conoutf("valid range for %s is %d..%d", c, id->min, id->max); + } + *id->storage = i1; + }; + if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available + }; + }; + break; + + case ID_ALIAS: // alias, also used as functions and (global) variables + for(int i = 1; iaction); // create new string here because alias could rebind itself + val = execute(action, isdown); + delete[] action; + break; + }; + loopj(numargs) delete[] w[j]; + }; + return val; +}; + +// tab-completion of all idents + +int completesize = 0, completeidx = 0; + +void resetcomplete() { completesize = 0; }; + +void complete(char *s) +{ + if(*s!='/') + { + string t; + s_strcpy(t, s); + s_strcpy(s, "/"); + s_strcat(s, t); + }; + if(!s[1]) return; + if(!completesize) { completesize = strlen(s)-1; completeidx = 0; }; + int idx = 0; + enumerate(*idents, ident, id, + if(strncmp(id.name, s+1, completesize)==0 && idx++==completeidx) + { + s_strcpy(s, "/"); + s_strcat(s, id.name); + }; + ); + completeidx++; + if(completeidx>=idx) completeidx = 0; +}; + +bool execfile(char *cfgfile) +{ + string s; + s_strcpy(s, cfgfile); + char *buf = loadfile(path(s), NULL); + if(!buf) return false; + execute(buf); + delete[] buf; + return true; +}; + +void exec(char *cfgfile) +{ + if(!execfile(cfgfile)) conoutf("could not read \"%s\"", cfgfile); +}; + +// below the commands that implement a small imperative language. thanks to the semantics of +// () and [] expressions, any control construct can be defined trivially. + +void intset(char *name, int v) { string b; itoa(b, v); alias(name, b); }; + +void ifthen(char *cond, char *thenp, char *elsep) { execute(cond[0]!='0' ? thenp : elsep); }; +void loopa(char *times, char *body) { int t = atoi(times); loopi(t) { intset("i", i); execute(body); }; }; +void whilea(char *cond, char *body) { while(execute(cond)) execute(body); }; // can't get any simpler than this :) +void onrelease(bool on, char *body) { if(!on) execute(body); }; + +void concat(char *s) { alias("s", s); }; + +void concatword(char *s) +{ + for(char *a = s, *b = s; *a = *b; b++) if(*a!=' ') a++; + concat(s); +}; + +int listlen(char *a) +{ + if(!*a) return 0; + int n = 0; + while(*a) if(*a++==' ') n++; + return n+1; +}; + +void at(char *s, char *pos) +{ + int n = atoi(pos); + loopi(n) s += strspn(s += strcspn(s, " \0"), " "); + s[strcspn(s, " \0")] = 0; + concat(s); +}; + +COMMANDN(loop, loopa, ARG_2STR); +COMMANDN(while, whilea, ARG_2STR); +COMMANDN(if, ifthen, ARG_3STR); +COMMAND(onrelease, ARG_DWN1); +COMMAND(exec, ARG_1STR); +COMMAND(concat, ARG_VARI); +COMMAND(concatword, ARG_VARI); +COMMAND(at, ARG_2STR); +COMMAND(listlen, ARG_1EST); + +int add(int a, int b) { return a+b; }; COMMANDN(+, add, ARG_2EXP); +int mul(int a, int b) { return a*b; }; COMMANDN(*, mul, ARG_2EXP); +int sub(int a, int b) { return a-b; }; COMMANDN(-, sub, ARG_2EXP); +int divi(int a, int b) { return b ? a/b : 0; }; COMMANDN(div, divi, ARG_2EXP); +int mod(int a, int b) { return b ? a%b : 0; }; COMMAND(mod, ARG_2EXP); +int equal(int a, int b) { return (int)(a==b); }; COMMANDN(=, equal, ARG_2EXP); +int lt(int a, int b) { return (int)(ab); }; COMMANDN(>, gt, ARG_2EXP); + +int strcmpa(char *a, char *b) { return strcmp(a,b)==0; }; COMMANDN(strcmp, strcmpa, ARG_2EST); + +int rndn(int a) { return a>0 ? rnd(a) : 0; }; COMMANDN(rnd, rndn, ARG_1EXP); + + diff --git a/source/src/console.cpp b/source/src/console.cpp new file mode 100644 index 00000000..9eb98904 --- /dev/null +++ b/source/src/console.cpp @@ -0,0 +1,246 @@ +// console.cpp: the console buffer, its display, and command line control + +#include "cube.h" +#include + +struct cline { char *cref; int outtime; }; +vector conlines; + +const int ndraw = 6; +const int WORDWRAP = 80; +int conskip = 0; + +bool saycommandon = false; +string commandbuf; + +void setconskip(int n) +{ + conskip += n; + if(conskip<0) conskip = 0; +}; + +COMMANDN(conskip, setconskip, ARG_1INT); + +void conline(const char *sf, bool highlight) // add a line to the console buffer +{ + cline cl; + cl.cref = conlines.length()>100 ? conlines.pop().cref : newstringbuf(""); // constrain the buffer size + cl.outtime = lastmillis; // for how long to keep line on screen + conlines.insert(0,cl); + if(highlight) // show line in a different colour, for chat etc. + { + cl.cref[0] = '\f'; + cl.cref[1] = 0; + s_strcat(cl.cref, sf); + } + else + { + s_strcpy(cl.cref, sf); + }; +}; + +void conoutf(const char *s, ...) +{ + s_sprintfdv(sf, s); + puts(sf); + s = sf; + int n = 0, visible; + while((visible = text_visible(s, VIRTW*4/3 - FONTH))) // cut strings to fit on screen + { + const char *newline = (const char *)memchr(s, '\n', visible); + if(newline) visible = newline+1-s; + string t; + s_strncpy(t, s, visible+1); + conline(t, n++!=0); + s += visible; + }; +}; + +void renderconsole() // render buffer taking into account time & scrolling +{ + int nd = 0; + char *refs[ndraw]; + loopv(conlines) if(conskip ? i>=conskip-1 || i>=conlines.length()-ndraw : lastmillis-conlines[i].outtime<20000) + { + refs[nd++] = conlines[i].cref; + if(nd==ndraw) break; + }; + loopj(nd) + { + draw_text(refs[j], FONTH/3, (FONTH/4*5)*(nd-j-1)+FONTH/3); + }; +}; + +// keymap is defined externally in keymap.cfg + +struct keym { int code; char *name; char *action; } keyms[256]; +int numkm = 0; + +void keymap(char *code, char *key, char *action) +{ + keyms[numkm].code = atoi(code); + keyms[numkm].name = newstring(key); + keyms[numkm++].action = newstringbuf(action); +}; + +COMMAND(keymap, ARG_3STR); + +void bindkey(char *key, char *action) +{ + for(char *x = key; *x; x++) *x = toupper(*x); + loopi(numkm) if(strcmp(keyms[i].name, key)==0) + { + s_strcpy(keyms[i].action, action); + return; + }; + conoutf("unknown key \"%s\"", key); +}; + +COMMANDN(bind, bindkey, ARG_2STR); + +void saycommand(char *init) // turns input to the command line on or off +{ + SDL_EnableUNICODE(saycommandon = (init!=NULL)); + setscope(false); + if(!editmode) keyrepeat(saycommandon); + if(!init) init = ""; + s_strcpy(commandbuf, init); +}; + +void mapmsg(char *s) { s_strncpy(hdr.maptitle, s, 128); }; + +COMMAND(saycommand, ARG_VARI); +COMMAND(mapmsg, ARG_1STR); + +#if !defined(WIN32) && !defined(__APPLE__) +#include +#include +#endif + +void pasteconsole() +{ + #ifdef WIN32 + if(!IsClipboardFormatAvailable(CF_TEXT)) return; + if(!OpenClipboard(NULL)) return; + char *cb = (char *)GlobalLock(GetClipboardData(CF_TEXT)); + s_strcat(commandbuf, cb); + GlobalUnlock(cb); + CloseClipboard(); + #elif !defined(__APPLE__) + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version); + wminfo.subsystem = SDL_SYSWM_X11; + if(!SDL_GetWMInfo(&wminfo)) return; + int cbsize; + char *cb = XFetchBytes(wminfo.info.x11.display, &cbsize); + if(!cb || !cbsize) return; + int commandlen = strlen(commandbuf); + for(char *cbline = cb, *cbend; commandlen + 1 < _MAXDEFSTR && cbline < &cb[cbsize]; cbline = cbend + 1) + { + cbend = (char *)memchr(cbline, '\0', &cb[cbsize] - cbline); + if(!cbend) cbend = &cb[cbsize]; + if(commandlen + cbend - cbline + 1 > _MAXDEFSTR) cbend = cbline + _MAXDEFSTR - commandlen - 1; + memcpy(&commandbuf[commandlen], cbline, cbend - cbline); + commandlen += cbend - cbline; + commandbuf[commandlen] = '\n'; + if(commandlen + 1 < _MAXDEFSTR && cbend < &cb[cbsize]) ++commandlen; + commandbuf[commandlen] = '\0'; + }; + XFree(cb); + #endif +}; + +cvector vhistory; +int histpos = 0; + +void history(int n) +{ + static bool rec = false; + if(!rec && n>=0 && n + +#ifdef __GNUC__ +#undef gamma +#endif + +#include +#include +#include +#include +#include +#ifdef __GNUC__ +#include +#else +#include +#endif + +#ifdef WIN32 + #define strcasecmp strcmp // fixme + #define WIN32_LEAN_AND_MEAN + #include "windows.h" + #define _WINDOWS + #define ZLIB_DLL + #define cos(x) cos((float)(x)) + #define sin(x) sin((float)(x)) +#else + #include +#endif + +#include +#include + +#define GL_GLEXT_LEGACY +#define __glext_h__ +#define NO_SDL_GLEXT +#include +#undef __glext_h__ +#include "GL/glext.h" + +#include + +#include + +#include "tools.h" + +enum // block types, order matters! +{ + SOLID = 0, // entirely solid cube [only specifies wtex] + CORNER, // half full corner of a wall + FHF, // floor heightfield using neighbour vdelta values + CHF, // idem ceiling + SPACE, // entirely empty cube + SEMISOLID, // generated by mipmapping + MAXTYPE +}; + +struct sqr +{ + uchar type; // one of the above + char floor, ceil; // height, in cubes + uchar wtex, ftex, ctex; // wall/floor/ceil texture ids + uchar r, g, b; // light value at upper left vertex + uchar vdelta; // vertex delta, used for heightfield cubes + char defer; // used in mipmapping, when true this cube is not a perfect mip + char occluded; // true when occluded + uchar utex; // upper wall tex id + uchar tag; // used by triggers +}; + +enum // hardcoded texture numbers +{ + DEFAULT_SKY = 0, + DEFAULT_LIQUID, + DEFAULT_WALL, + DEFAULT_FLOOR, + DEFAULT_CEIL +}; + +enum // static entity types +{ + NOTUSED = 0, // entity slot not in use in map + LIGHT, // lightsource, attr1 = radius, attr2 = intensity + PLAYERSTART, // attr1 = angle + I_CLIPS, I_AMMO,I_GRENADE, + I_HEALTH, I_ARMOUR, I_AKIMBO, + MAPMODEL, // attr1 = angle, attr2 = idx + CARROT, // attr1 = tag, attr2 = type + LADDER, + CTF_FLAG, // attr1 = angle, attr2 = red/blue + MAXENTTYPES +}; + +struct persistent_entity // map entity +{ + short x, y, z; // cube aligned position + short attr1; + uchar type; // type is one of the above + uchar attr2, attr3, attr4; +}; + +struct entity : public persistent_entity +{ + bool spawned; // the only dynamic state of a map entity +}; + +#define MAPVERSION 6 // bump if map format changes, see worldio.cpp + +struct header // map file format header +{ + char head[4]; // "CUBE" + int version; // any >8bit quantity is a little indian + int headersize; // sizeof(header) + int sfactor; // in bits + int numents; + char maptitle[128]; + uchar texlists[3][256]; + int waterlevel; + int reserved[15]; +}; + +#define SWS(w,x,y,s) (&(w)[(y)*(s)+(x)]) +#define SW(w,x,y) SWS(w,x,y,ssize) +#define S(x,y) SW(world,x,y) // convenient lookup of a lowest mip cube +#define SMALLEST_FACTOR 6 // determines number of mips there can be +#define DEFAULT_FACTOR 8 +#define LARGEST_FACTOR 11 // 10 is already insane +#define SOLID(x) ((x)->type==SOLID) +#define MINBORD 2 // 2 cubes from the edge of the world are always solid +#define OUTBORD(x,y) ((x)=ssize-MINBORD || (y)>=ssize-MINBORD) + +struct vec { float x, y, z; }; +struct block { int x, y, xs, ys; }; +struct mapmodelinfo { int rad, h, zoff, snap; char *name; }; + +enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSAULT, GUN_GRENADE, NUMGUNS }; +enum { G_PRIMARY=0, G_SECONDARY, G_MELEE, G_GRENADE, G_NUM }; + + +enum { MCMD_KICK = 0, MCMD_BAN, MCMD_REMBANS }; + + +// Added by Rick +class CBot; + +#define MAX_STORED_LOCATIONS 7 + +extern int lastmillis; // last time (Moved up by Rick) + +class CPrevLocation +{ + int nextupdate; + +public: + vec prevloc[MAX_STORED_LOCATIONS]; + + CPrevLocation(void) : nextupdate(0) { Reset(); }; + void Reset(void) { loopi(MAX_STORED_LOCATIONS) prevloc[i].x=prevloc[i].y=prevloc[i].z=0.0f; }; + void Update(const vec &o) + { + extern float GetDistance(vec v1, vec v2); + + if (nextupdate > lastmillis) return; + if (GetDistance(o, prevloc[0]) >= 4.0f) + { + for(int i=(MAX_STORED_LOCATIONS-1);i>=1;i--) + prevloc[i] = prevloc[i-1]; + prevloc[0] = o; + } + nextupdate = lastmillis + 100; + }; +}; + +struct itemstat { int add, start, max, sound; }; +// End add + + +struct md2state +{ + int anim, frame, range, basetime; + float speed; + //md2state() : anim(0), frame(0), range(0), basetime(0), speed(100.0f) { }; + md2state() + { + anim = frame = range = basetime = 0; + speed = 100.0f; + } + + bool operator==(const md2state &o) const { return frame==o.frame && range==o.range && basetime==o.basetime && speed==o.speed; }; + bool operator!=(const md2state &o) const { return frame!=o.frame || range!=o.range || basetime!=o.basetime || speed!=o.speed; }; +}; + + +struct md3state +{ + int anim; + int frm; + int lastTime; +}; + +enum // md3 animations +{ + BOTH_DEATH1 = 0, + BOTH_DEAD1, + BOTH_DEATH2, + BOTH_DEAD2, + BOTH_DEATH3, + BOTH_DEAD3, + TORSO_GESTURE, + TORSO_ATTACK, + TORSO_ATTACK2, + TORSO_DROP, + TORSO_RAISE, + TORSO_STAND, + TORSO_STAND2, + LEGS_WALKCR, + LEGS_WALK, + LEGS_RUN, + LEGS_BACK, + LEGS_SWIM, + LEGS_JUMP, + LEGS_LAND, + LEGS_JUMPB, + LEGS_LANDB, + LEGS_IDLE, + LEGS_IDLECR, + LEGS_TURN +}; + +struct dynent // players & monsters +{ + vec o, vel; // origin, velocity + float yaw, pitch, roll; // used as vec in one place + float oldpitch; + float maxspeed; // cubes per second, 24 for player + bool outsidemap; // from his eyes + bool inwater; + bool onfloor, jumpnext; + int move, strafe; + bool k_left, k_right, k_up, k_down; // see input code + int timeinair; // used for fake gravity + float radius, eyeheight, aboveeye; // bounding box size + int lastupdate, plag, ping; + int lifesequence; // sequence id for each respawn, used in damage test + int state; // one of CS_* below + int frags; + int health, armour; //armourtype, quadmillis; + int akimbomillis; + int gunselect, gunwait; + int lastaction, lastattackgun, lastmove; + bool attacking; + int ammo[NUMGUNS]; + int mag[NUMGUNS]; + int monsterstate; // one of M_* below, M_NONE means human + int mtype; // see monster.cpp + dynent *enemy; // monster wants to kill this entity + // Added by Rick: targetpitch + float targetpitch; // monster wants to look in this direction + // End add + float targetyaw; // monster wants to look in this direction + bool blocked, moving; // used by physics to signal ai + int trigger; // millis at which transition to another monsterstate takes place + vec attacktarget; // delayed attacks + int anger; // how many times already hit by fellow monster + int flagscore; // EDIT: AH + string name, team; + //int startheight; + int shots; //keeps track of shots from auto weapons + bool reloading, hasarmour, weaponchanging; + int nextweapon; // weapon we switch to + int primary; //primary gun + int nextprimary; // primary after respawning + int skin, nextskin; // skin after respawning + md3state animstate[3]; + int lastanimswitchtime; + md2state current, prev; + int attackmillis; + + bool onladder; + int gravity; + bool isphysent; // hack + + int thrownademillis; + struct physent *inhandnade; + int akimbo; + int akimbolastaction[2]; + float rotspeed; + + // Added by Rick + CBot *pBot; // Only used if this is a bot, points to the bot class if we are the host, + // for other clients its NULL + bool bIsBot; // Is this dynent a bot? + CPrevLocation PrevLocations; // Previous stored locations of this player + // End add by Rick +}; +// Moved from server.cpp by Rick +struct server_entity // server side version of "entity" type +{ + bool spawned; + int spawnsecs; +}; +// End move + +// EDIT: AH +enum { CTFF_INBASE = 0, CTFF_STOLEN, CTFF_DROPPED }; + +struct flaginfo +{ + entity *flag; + dynent *thief; + vec originalpos; + int state; // one of the types above + bool pick_ack; + flaginfo() : flag(0), thief(0), state(CTFF_INBASE), pick_ack(false) {}; +}; + +enum { PHYSENT_NONE = 0, NADE_ACTIVATED, NADE_THROWED, GIB}; + +struct physent : dynent // nades, gibs +{ + int millis, timetolife, state; // see enum above + dynent *owner; +}; + +#define NADE_IN_HAND (player1->gunselect==GUN_GRENADE && player1->inhandnade) +#define NADE_THROWING (player1->gunselect==GUN_GRENADE && player1->thrownademillis && !player1->inhandnade) + +#define has_akimbo(d) ((d)->gunselect==GUN_PISTOL && (d)->akimbo) + +#define SAVEGAMEVERSION 6 // bump if dynent/netprotocol changes or any other savegame/demo data bumped from 5 + +//enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off +enum { M_NONE = 0, M_SEARCH, M_HOME, M_ATTACKING, M_PAIN, M_SLEEP, M_AIMING, M_NADE /* bloody hack*/ }; // monster states + +#define MAXCLIENTS 256 // in a multiplayer game, can be arbitrarily changed +#define MAXTRANS 5000 // max amount of data to swallow in 1 go +#define CUBE_SERVER_PORT 28763 +#define CUBE_SERVINFO_PORT 28764 +#define PROTOCOL_VERSION 1123 // bump when protocol changes + +#define WEAPONCHANGE_TIME 400 + +// network messages codes, c2s, c2c, s2c +enum +{ + SV_INITS2C = 0, SV_INITC2S, SV_POS, SV_TEXT, SV_SOUND, SV_CDIS, + SV_GIBDIED, SV_DIED, SV_GIBDAMAGE, SV_DAMAGE, SV_SHOT, SV_FRAGS, SV_RESUME, + SV_TIMEUP, SV_EDITENT, SV_MAPRELOAD, SV_ITEMACC, + SV_MAPCHANGE, SV_ITEMSPAWN, SV_ITEMPICKUP, SV_DENIED, + SV_PING, SV_PONG, SV_CLIENTPING, SV_GAMEMODE, + SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, + SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE, + SV_MODELSKIN, + SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGINFO, SV_FLAGS, //EDIT: AH + // Added by Rick: Bot specific messages + SV_BOTSOUND, SV_BOTDIS, SV_BOTDIED, SV_CLIENT2BOTDMG, SV_BOT2BOTDMG, + SV_BOTFRAGS, SV_ADDBOT, SV_BOTUPDATE, SV_BOTCOMMAND, + // End add + SV_BOTITEMPICKUP, SV_BOT2CLIENTDMG, SV_DIEDBYBOT, + SV_GETMASTER, SV_MASTERCMD, + SV_PWD, + SV_NOP, + SV_EXT, +}; + +enum { CS_ALIVE = 0, CS_DEAD, CS_LAGGED, CS_EDITING }; + +// hardcoded sounds, defined in sounds.cfg +enum +{ + S_JUMP = 0, S_LAND, + S_KNIFE, + S_PISTOL, S_RPISTOL, + S_SHOTGUN, S_RSHOTGUN, + S_SUBGUN, S_RSUBGUN, + S_SNIPER, S_RSNIPER, + S_ASSAULT, S_RASSAULT, + S_ITEMAMMO, S_ITEMHEALTH, + S_ITEMARMOUR, S_ITEMPUP, + S_NOAMMO, S_PUPOUT, + S_PAIN1, S_PAIN2, S_PAIN3, S_PAIN4, S_PAIN5, S_PAIN6, //24 + S_DIE1, S_DIE2, + S_FEXPLODE, + S_SPLASH1, S_SPLASH2, + S_GRUNT1, S_GRUNT2, S_RUMBLE, + S_FLAGDROP, S_FLAGPICKUP, S_FLAGRETURN, S_FLAGSCORE, + S_GRENADEPULL, S_GRENADETHROW, + S_RAKIMBO, S_GUNCHANGE, S_GIB, + S_NULL +}; + +// vertex array format + +struct vertex { float u, v, x, y, z; uchar r, g, b, a; }; + +typedef vector dvector; +typedef vector cvector; +typedef vector ivector; + +// globals ooh naughty + +extern sqr *world, *wmip[]; // map data, the mips are sequential 2D arrays in memory +extern header hdr; // current map header +extern int sfactor, ssize; // ssize = 2^sfactor +extern int cubicsize, mipsize; // cubicsize = ssize^2 +extern dynent *player1; // special client ent that receives input and acts as camera +extern dvector players; // all the other clients (in multiplayer) +extern vectorphysents; +extern bool editmode; +extern vector ents; // map entities +extern vec worldpos; // current target of the crosshair in the world +extern int lastmillis; // last time +extern int curtime; // current frame time +extern int gamemode, nextmode; +extern int xtraverts; +extern bool demoplayback; + + +#define DMF 16.0f +#define DAF 1.0f +#define DVF 100.0f + +#define VIRTW 2400 // virtual screen size for text & HUD +#define VIRTH 1800 +#define FONTH 64 +#define PIXELTAB (VIRTW/12) + +#define PI (3.1415927f) +#define PI2 (2*PI) + +// simplistic vector ops +#define dotprod(u,v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z) +#define vmul(u,f) { (u).x *= (f); (u).y *= (f); (u).z *= (f); } +#define vdiv(u,f) { (u).x /= (f); (u).y /= (f); (u).z /= (f); } +#define vadd(u,v) { (u).x += (v).x; (u).y += (v).y; (u).z += (v).z; }; +#define vsub(u,v) { (u).x -= (v).x; (u).y -= (v).y; (u).z -= (v).z; }; +#define vdist(d,v,e,s) vec v = s; vsub(v,e); float d = (float)sqrt(dotprod(v,v)); +#define vdistsquared(d,v,e,s) vec v = s; vsub(v,e); float d = (dotprod(v,v)); +#define vreject(v,u,max) ((v).x>(u).x+(max) || (v).x<(u).x-(max) || (v).y>(u).y+(max) || (v).y<(u).y-(max)) +#define vlinterp(v,f,u,g) { (v).x = (v).x*f+(u).x*g; (v).y = (v).y*f+(u).y*g; (v).z = (v).z*f+(u).z*g; } +// Added by Rick (compares 2 vectors) +#define vis(v1,v2) ((v1.x==v2.x) && (v1.y==v2.y) && (v1.z==v2.z)) +// End add by Rick + +/* Gamemodes +0 - tdm +1 - coop edit +2 - dm +3 - survivor +4 - team survior +5 - ctf +6 - pistols +7 - bot tdm +8 - bot dm +9 - last swiss standing +*/ + +#define m_noitems (gamemode==3 || gamemode==4) +#define m_noitemsnade (gamemode==9) +#define m_nogun (gamemode==9) +#define m_noitemsrail (false) +#define m_arena (gamemode==3 || gamemode==4 || gamemode==9) +#define m_tarena (gamemode==4) +#define m_teammode (gamemode==0 || gamemode==4 || gamemode==5 || gamemode==7) +#define m_botmode (gamemode==7 || gamemode == 8) +#define m_ctf (gamemode==5) +#define m_pistol (gamemode==6) +#define m_lss (gamemode==9) +//#define m_sp (gamemode<0) +//#define m_dmsp (gamemode==-1) +//#define m_classicsp (gamemode==-2) +#define isteam(a,b) (m_teammode && strcmp(a, b)==0) + +#define TEAM_CLA 0 // +#define TEAM_RVSF 1 // +// rb means red/blue +#define rb_team_string(t) ((t) ? "RVSF" : "CLA") +#define rb_team_int(t) (strcmp((t), "CLA") == 0 ? TEAM_CLA : TEAM_RVSF) +#define rb_opposite(o) ((o) == TEAM_CLA ? TEAM_RVSF : TEAM_CLA) + +enum // function signatures for script functions, see command.cpp +{ + ARG_1INT, ARG_2INT, ARG_3INT, ARG_4INT, + ARG_NONE, + ARG_1STR, ARG_2STR, ARG_3STR, ARG_5STR, ARG_6STR, + ARG_DOWN, ARG_DWN1, + ARG_1EXP, ARG_2EXP, + ARG_1EST, ARG_2EST, + ARG_VARI +}; + +// nasty macros for registering script functions, abuses globals to avoid excessive infrastructure +#define COMMANDN(name, fun, nargs) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, nargs) +#define COMMAND(name, nargs) COMMANDN(name, name, nargs) +#define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true) +#define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false) +#define VARF(name, min, cur, max, body) void var_##name(); static int name = variable(#name, min, cur, max, &name, var_##name, false); void var_##name() { body; } +#define VARFP(name, min, cur, max, body) void var_##name(); static int name = variable(#name, min, cur, max, &name, var_##name, true); void var_##name() { body; } + +#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers + +// Added by Rick +extern ENetHost *clienthost; +inline bool ishost(void) { return !clienthost; }; + +void splaysound(int n, vec *loc=0); +void addteamscore(dynent *d); +void renderscore(dynent *d); +extern void conoutf(const char *s, ...); // Moved from protos.h +extern void particle_trail(int type, int fade, vec &from, vec &to); // Moved from protos.h +extern bool listenserv; +extern bool intermission; +#include "bot/bot.h" +// End add by Rick + +#include "protos.h" // external function decls + diff --git a/source/src/editing.cpp b/source/src/editing.cpp new file mode 100644 index 00000000..e331dfba --- /dev/null +++ b/source/src/editing.cpp @@ -0,0 +1,484 @@ +// editing.cpp: most map editing commands go here, entity editing commands are in world.cpp + +#include "cube.h" + +bool editmode = false; + +// the current selection, used by almost all editing commands +// invariant: all code assumes that these are kept inside MINBORD distance of the edge of the map + +block sel = +{ + variable("selx", 0, 0, 4096, &sel.x, NULL, false), + variable("sely", 0, 0, 4096, &sel.y, NULL, false), + variable("selxs", 0, 0, 4096, &sel.xs, NULL, false), + variable("selys", 0, 0, 4096, &sel.ys, NULL, false), +}; + +int selh = 0; +bool selset = false; + +#define loopselxy(b) { makeundo(); loop(x,sel.xs) loop(y,sel.ys) { sqr *s = S(sel.x+x, sel.y+y); b; }; remip(sel); } + +int cx, cy, ch; + +int curedittex[] = { -1, -1, -1 }; + +bool dragging = false; +int lastx, lasty, lasth; + +int lasttype = 0, lasttex = 0; +sqr rtex; + +VAR(editing,0,0,1); + +void toggleedit() +{ + if(player1->state==CS_DEAD) return; // do not allow dead players to edit to avoid state confusion + if(!editmode && !allowedittoggle()) return; // not in most multiplayer modes + if(!(editmode = !editmode)) + { + settagareas(); // reset triggers to allow quick playtesting + entinmap(player1); // find spawn closest to current floating pos + } + else + { + resettagareas(); // clear trigger areas to allow them to be edited + player1->health = 100; + //put call to clear/restar gamemode + projreset(); + }; + keyrepeat(editmode); + selset = false; + editing = editmode; +}; + +COMMANDN(edittoggle, toggleedit, ARG_NONE); + +void correctsel() // ensures above invariant +{ + selset = !OUTBORD(sel.x, sel.y); + int bsize = ssize-MINBORD; + if(sel.xs+sel.x>bsize) sel.xs = bsize-sel.x; + if(sel.ys+sel.y>bsize) sel.ys = bsize-sel.y; + if(sel.xs<=0 || sel.ys<=0) selset = false; +}; + +bool noteditmode() +{ + correctsel(); + if(!editmode) conoutf("this function is only allowed in edit mode"); + return !editmode; +}; + +bool noselection() +{ + if(!selset) conoutf("no selection"); + return !selset; +}; + +#define EDITSEL if(noteditmode() || noselection()) return; +#define EDITSELMP if(noteditmode() || noselection() || multiplayer()) return; +#define EDITMP if(noteditmode() || multiplayer()) return; + +void selectpos(int x, int y, int xs, int ys) +{ + block s = { x, y, xs, ys }; + sel = s; + selh = 0; + correctsel(); +}; + +void makesel() +{ + block s = { min(lastx,cx), min(lasty,cy), abs(lastx-cx)+1, abs(lasty-cy)+1 }; + sel = s; + selh = max(lasth,ch); + correctsel(); + if(selset) rtex = *S(sel.x, sel.y); +}; + +VAR(flrceil,0,0,2); + +float sheight(sqr *s, sqr *t, float z) // finds out z height when cursor points at wall +{ + return !flrceil //z-s->floorceil-z + ? (s->type==FHF ? s->floor-t->vdelta/4.0f : (float)s->floor) + : (s->type==CHF ? s->ceil+t->vdelta/4.0f : (float)s->ceil); +}; + +void cursorupdate() // called every frame from hud +{ + flrceil = ((int)(player1->pitch>=0))*2; + + volatile float x = worldpos.x; // volatile needed to prevent msvc7 optimizer bug? + volatile float y = worldpos.y; + volatile float z = worldpos.z; + + cx = (int)x; + cy = (int)y; + + if(OUTBORD(cx, cy)) return; + sqr *s = S(cx,cy); + + if(fabs(sheight(s,s,z)-z)>1) // selected wall + { + x += x>player1->o.x ? 0.5f : -0.5f; // find right wall cube + y += y>player1->o.y ? 0.5f : -0.5f; + + cx = (int)x; + cy = (int)y; + + if(OUTBORD(cx, cy)) return; + }; + + if(dragging) makesel(); + + const int GRIDSIZE = 5; + const float GRIDW = 0.5f; + const float GRID8 = 2.0f; + const float GRIDS = 2.0f; + const int GRIDM = 0x7; + + // render editing grid + + for(int ix = cx-GRIDSIZE; ix<=cx+GRIDSIZE; ix++) for(int iy = cy-GRIDSIZE; iy<=cy+GRIDSIZE; iy++) + { + if(OUTBORD(ix, iy)) continue; + sqr *s = S(ix,iy); + if(SOLID(s)) continue; + float h1 = sheight(s, s, z); + float h2 = sheight(s, SWS(s,1,0,ssize), z); + float h3 = sheight(s, SWS(s,1,1,ssize), z); + float h4 = sheight(s, SWS(s,0,1,ssize), z); + if(s->tag) linestyle(GRIDW, 0xFF, 0x40, 0x40); + else if(s->type==FHF || s->type==CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80); + else linestyle(GRIDW, 0x80, 0x80, 0x80); + block b = { ix, iy, 1, 1 }; + box(b, h1, h2, h3, h4); + linestyle(GRID8, 0x40, 0x40, 0xFF); + if(!(ix&GRIDM)) line(ix, iy, h1, ix, iy+1, h4); + if(!(ix+1&GRIDM)) line(ix+1, iy, h2, ix+1, iy+1, h3); + if(!(iy&GRIDM)) line(ix, iy, h1, ix+1, iy, h2); + if(!(iy+1&GRIDM)) line(ix, iy+1, h4, ix+1, iy+1, h3); + }; + + if(!SOLID(s)) + { + float ih = sheight(s, s, z); + linestyle(GRIDS, 0xFF, 0xFF, 0xFF); + block b = { cx, cy, 1, 1 }; + box(b, ih, sheight(s, SWS(s,1,0,ssize), z), sheight(s, SWS(s,1,1,ssize), z), sheight(s, SWS(s,0,1,ssize), z)); + linestyle(GRIDS, 0xFF, 0x00, 0x00); + dot(cx, cy, ih); + ch = (int)ih; + }; + + if(selset) + { + linestyle(GRIDS, 0xFF, 0x40, 0x40); + box(sel, (float)selh, (float)selh, (float)selh, (float)selh); + }; +}; + +vector undos; // unlimited undo +VAR(undomegs, 0, 1, 10); // bounded by n megs + +void pruneundos(int maxremain) // bound memory +{ + int t = 0; + loopvrev(undos) + { + t += undos[i]->xs*undos[i]->ys*sizeof(sqr); + if(t>maxremain) delete undos.remove(i); + }; +}; + +void makeundo() +{ + undos.add(blockcopy(sel)); + pruneundos(undomegs<<20); +}; + +void editundo() +{ + EDITMP; + if(undos.empty()) { conoutf("nothing more to undo"); return; }; + block *p = undos.pop(); + blockpaste(*p); + freeblock(p); +}; + +block *copybuf = NULL; + +void copy() +{ + EDITSELMP; + freeblock(copybuf); + copybuf = blockcopy(sel); +}; + +void paste() +{ + EDITMP; + if(!copybuf) { conoutf("nothing to paste"); return; }; + sel.xs = copybuf->xs; + sel.ys = copybuf->ys; + correctsel(); + if(!selset || sel.xs!=copybuf->xs || sel.ys!=copybuf->ys) { conoutf("incorrect selection"); return; }; + makeundo(); + copybuf->x = sel.x; + copybuf->y = sel.y; + blockpaste(*copybuf); +}; + +void tofronttex() // maintain most recently used of the texture lists when applying texture +{ + loopi(3) + { + int c = curedittex[i]; + if(c>=0) + { + uchar *p = hdr.texlists[i]; + int t = p[c]; + for(int a = c-1; a>=0; a--) p[a+1] = p[a]; + p[0] = t; + curedittex[i] = -1; + }; + }; +}; + +void editdrag(bool isdown) +{ + if(dragging = isdown) + { + lastx = cx; + lasty = cy; + lasth = ch; + selset = false; + tofronttex(); + }; + makesel(); +}; + +// the core editing function. all the *xy functions perform the core operations +// and are also called directly from the network, the function below it is strictly +// triggered locally. They all have very similar structure. + +void editheightxy(bool isfloor, int amount, block &sel) +{ + loopselxy(if(isfloor) + { + s->floor += amount; + if(s->floor>=s->ceil) s->floor = s->ceil-1; + } + else + { + s->ceil += amount; + if(s->ceil<=s->floor) s->ceil = s->floor+1; + }); +}; + +void editheight(int flr, int amount) +{ + EDITSEL; + bool isfloor = flr==0; + editheightxy(isfloor, amount, sel); + addmsg(SV_EDITH, "ri6", sel.x, sel.y, sel.xs, sel.ys, isfloor, amount); +}; + +COMMAND(editheight, ARG_2INT); + +void edittexxy(int type, int t, block &sel) +{ + loopselxy(switch(type) + { + case 0: s->ftex = t; break; + case 1: s->wtex = t; break; + case 2: s->ctex = t; break; + case 3: s->utex = t; break; + }); +}; + +void edittex(int type, int dir) +{ + EDITSEL; + if(type<0 || type>3) return; + if(type!=lasttype) { tofronttex(); lasttype = type; }; + int atype = type==3 ? 1 : type; + int i = curedittex[atype]; + i = i<0 ? 0 : i+dir; + curedittex[atype] = i = min(max(i, 0), 255); + int t = lasttex = hdr.texlists[atype][i]; + edittexxy(type, t, sel); + addmsg(SV_EDITT, "ri6", sel.x, sel.y, sel.xs, sel.ys, type, t); +}; + +void replace() +{ + EDITSELMP; + loop(x,ssize) loop(y,ssize) + { + sqr *s = S(x, y); + switch(lasttype) + { + case 0: if(s->ftex == rtex.ftex) s->ftex = lasttex; break; + case 1: if(s->wtex == rtex.wtex) s->wtex = lasttex; break; + case 2: if(s->ctex == rtex.ctex) s->ctex = lasttex; break; + case 3: if(s->utex == rtex.utex) s->utex = lasttex; break; + }; + }; + block b = { 0, 0, ssize, ssize }; + remip(b); +}; + +void edittypexy(int type, block &sel) +{ + loopselxy(s->type = type); +}; + +void edittype(int type) +{ + EDITSEL; + if(type==CORNER && (sel.xs!=sel.ys || sel.xs==3 || sel.xs>4 && sel.xs!=8 + || sel.x&~-sel.xs || sel.y&~-sel.ys)) + { conoutf("corner selection must be power of 2 aligned"); return; }; + edittypexy(type, sel); + addmsg(SV_EDITS, "ri5", sel.x, sel.y, sel.xs, sel.ys, type); +}; + +void heightfield(int t) { edittype(t==0 ? FHF : CHF); }; +void solid(int t) { edittype(t==0 ? SPACE : SOLID); }; +void corner() { edittype(CORNER); }; + +COMMAND(heightfield, ARG_1INT); +COMMAND(solid, ARG_1INT); +COMMAND(corner, ARG_NONE); + +void editequalisexy(bool isfloor, block &sel) +{ + int low = 127, hi = -128; + loopselxy( + { + if(s->floorfloor; + if(s->ceil>hi) hi = s->ceil; + }); + loopselxy( + { + if(isfloor) s->floor = low; else s->ceil = hi; + if(s->floor>=s->ceil) s->floor = s->ceil-1; + }); +}; + +void equalize(int flr) +{ + bool isfloor = flr==0; + EDITSEL; + editequalisexy(isfloor, sel); + addmsg(SV_EDITE, "ri5", sel.x, sel.y, sel.xs, sel.ys, isfloor); +}; + +COMMAND(equalize, ARG_1INT); + +void setvdeltaxy(int delta, block &sel) +{ + loopselxy(s->vdelta = max(s->vdelta+delta, 0)); +}; + +void setvdelta(int delta) +{ + EDITSEL; + setvdeltaxy(delta, sel); + addmsg(SV_EDITD, "ri5", sel.x, sel.y, sel.xs, sel.ys, delta); +}; + +const int MAXARCHVERT = 50; +int archverts[MAXARCHVERT][MAXARCHVERT]; +bool archvinit = false; + +void archvertex(int span, int vert, int delta) +{ + if(!archvinit) + { + archvinit = true; + loop(s,MAXARCHVERT) loop(v,MAXARCHVERT) archverts[s][v] = 0; + }; + if(span>=MAXARCHVERT || vert>=MAXARCHVERT || span<0 || vert<0) return; + archverts[span][vert] = delta; +}; + +void arch(int sidedelta, int _a) +{ + EDITSELMP; + sel.xs++; + sel.ys++; + if(sel.xs>MAXARCHVERT) sel.xs = MAXARCHVERT; + if(sel.ys>MAXARCHVERT) sel.ys = MAXARCHVERT; + loopselxy(s->vdelta = + sel.xs>sel.ys + ? (archverts[sel.xs-1][x] + (y==0 || y==sel.ys-1 ? sidedelta : 0)) + : (archverts[sel.ys-1][y] + (x==0 || x==sel.xs-1 ? sidedelta : 0))); +}; + +void slope(int xd, int yd) +{ + EDITSELMP; + int off = 0; + if(xd<0) off -= xd*sel.xs; + if(yd<0) off -= yd*sel.ys; + sel.xs++; + sel.ys++; + loopselxy(s->vdelta = xd*x+yd*y+off); +}; + +void perlin(int scale, int seed, int psize) +{ + EDITSELMP; + sel.xs++; + sel.ys++; + makeundo(); + sel.xs--; + sel.ys--; + perlinarea(sel, scale, seed, psize); + sel.xs++; + sel.ys++; + remip(sel); + sel.xs--; + sel.ys--; +}; + +VARF(fullbright, 0, 0, 1, + if(fullbright) + { + if(noteditmode()) return; + loopi(mipsize) world[i].r = world[i].g = world[i].b = 176; + }; +); + +void edittag(int tag) +{ + EDITSELMP; + loopselxy(s->tag = tag); +}; + +void newent(char *what, char *a1, char *a2, char *a3, char *a4) +{ + EDITSEL; + newentity(sel.x, sel.y, (int)player1->o.z, what, ATOI(a1), ATOI(a2), ATOI(a3), ATOI(a4)); +}; + +COMMANDN(select, selectpos, ARG_4INT); +COMMAND(edittag, ARG_1INT); +COMMAND(replace, ARG_NONE); +COMMAND(archvertex, ARG_3INT); +COMMAND(arch, ARG_2INT); +COMMAND(slope, ARG_2INT); +COMMANDN(vdelta, setvdelta, ARG_1INT); +COMMANDN(undo, editundo, ARG_NONE); +COMMAND(copy, ARG_NONE); +COMMAND(paste, ARG_NONE); +COMMAND(edittex, ARG_2INT); +COMMAND(newent, ARG_5STR); +COMMAND(perlin, ARG_3INT); + + diff --git a/source/src/entities.cpp b/source/src/entities.cpp new file mode 100644 index 00000000..22c4b0b3 --- /dev/null +++ b/source/src/entities.cpp @@ -0,0 +1,351 @@ +// entities.cpp: map entity related functions (pickup etc.) + +#include "cube.h" + +vector ents; + +char *entmdlnames[] = +{ +//FIXME : fix the "pickups" infront + "pickups/pistolclips", "pickups/ammobox", "pickups/nades", "pickups/health", "pickups/kevlar", "pickups/akimbo", +}; + +int triggertime = 0; + +void renderent(entity &e, char *mdlname, float z, float yaw, int frame = 0, int numf = 1, int basetime = 0, float speed = 10.0f) +{ + rendermodel(mdlname, frame, numf, 0, 1.1f, e.x, z+S(e.x, e.y)->floor, e.y, yaw, 0, false, 1.0f, speed, 0, basetime); +}; + +extern void newparticle(vec &o, vec &d, int fade, int type, int tex = -1); + +void renderentities() +{ + if(lastmillis>triggertime+1000) triggertime = 0; + loopv(ents) + { + entity &e = ents[i]; + if(e.type==MAPMODEL) + { + mapmodelinfo &mmi = getmminfo(e.attr2); + if(!&mmi) continue; + rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad, e.x, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3, e.y, (float)((e.attr1+7)-(e.attr1+7)%15), 0, false, 1.0f, 10.0f, mmi.snap); + } + else if(e.type==CTF_FLAG && m_ctf) // EDIT: AH + { + flaginfo &f = flaginfos[e.attr2]; + if(f.state==CTFF_STOLEN && f.thief) + { + if(f.thief == player1) continue; + s_sprintfd(path)("pickups/flags/small_%s", rb_team_string(e.attr2)); + mapmodelinfo mmi = {10, 4, 0, 0, path}; + if(!&mmi) continue; + rendermodel(mmi.name, 0, 1, 0, 0, f.thief->o.x, f.thief->o.z+0.3f+(sin(lastmillis/100.0f)+1)/10, f.thief->o.y, lastmillis/2.5f, 0, false, 0.6f, 120.0f, mmi.snap); + } + else + { + s_sprintfd(path)("pickups/flags/%s", rb_team_string(e.attr2)); + mapmodelinfo mmi = {10, 4, 0, 0, path}; + if(!&mmi) continue; + rendermodel(mmi.name, 0, 7, 0, (float)mmi.rad, e.x, f.state==CTFF_INBASE ? (float)S(e.x, e.y)->floor : e.z, e.y, (float)((e.attr1+7)-(e.attr1+7)%15), 0, false, 1.0f, 120.0f, mmi.snap); + }; + } + else + { + if(OUTBORD(e.x, e.y)) continue; + if(e.type!=CARROT) + { + if(!e.spawned) continue; + if(e.typeI_AKIMBO) continue; + renderent(e, entmdlnames[e.type-I_CLIPS], (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/10.0f); + } + else switch(e.attr2) + { + case 1: + case 3: + continue; + + case 2: + case 0: + if(!e.spawned) continue; + renderent(e, "carrot", (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/(e.attr2 ? 1.0f : 10.0f)); + break; + + case 4: renderent(e, "switch2", 3, (float)e.attr3*90, (!e.spawned && !triggertime) ? 1 : 0, (e.spawned || !triggertime) ? 1 : 2, triggertime, 1050.0f); break; + case 5: renderent(e, "switch1", -0.15f, (float)e.attr3*90, (!e.spawned && !triggertime) ? 30 : 0, (e.spawned || !triggertime) ? 1 : 30, triggertime, 35.0f); break; + }; + }; + }; +}; + +itemstat itemstats[] = +{ + {1, 1, 1, S_ITEMAMMO}, //knife dummy + {16, 32, 72, S_ITEMAMMO}, //pistol + {14, 28, 21, S_ITEMAMMO}, //shotgun + {60, 90, 90, S_ITEMAMMO}, //subgun + {10, 20, 15, S_ITEMAMMO}, //sniper + {40, 60, 60, S_ITEMAMMO}, //assault + {2, 0, 2, S_ITEMAMMO}, //grenade + {33, 100, 100, S_ITEMHEALTH}, //health + {50, 100, 100, S_ITEMARMOUR}, //armour + {16, 0, 72, S_ITEMPUP}, //powerup +}; + +void baseammo(int gun) { player1->ammo[gun] = itemstats[gun].add*2; }; +// Added by Rick: baseammo for bots +void botbaseammo(int gun, dynent *d) { d->ammo[gun] = itemstats[gun].add*2; }; +// End add + +// these two functions are called when the server acknowledges that you really +// picked up the item (in multiplayer someone may grab it before you). + +void radditem(int i, int &v, int t) +{ + itemstat &is = itemstats[t]; + ents[i].spawned = false; + v += is.add; + if(v>is.max) v = is.max; + playsoundc(is.sound); +}; + +extern void weapon(int gun); + +void realpickup(int n, dynent *d) +{ + switch(ents[n].type) + { + case I_CLIPS: + radditem(n, d->ammo[1], 1); + break; + case I_AMMO: + radditem(n, d->ammo[d->primary], d->primary); + break; + case I_GRENADE: + radditem(n, d->mag[6], 6); + player1->thrownademillis = 0; + break; + case I_HEALTH: + radditem(n, d->health, 7); + break; + case I_ARMOUR: + radditem(n, d->armour, 8); + //d->hasarmour = true; + break; + case I_AKIMBO: + d->akimbomillis = lastmillis+30000; + d->mag[GUN_PISTOL] = 16; + radditem(n, d->ammo[1], 9); + weaponswitch(GUN_PISTOL); + break; + }; +}; + +// these functions are called when the client touches the item + +void additem(int i, int &v, int spawnsec, int t) +{ + if(v4 ? 2 : 3); // spawn times are dependent on number of players + int ammo = np*2; + switch(ents[n].type) + { + case I_CLIPS: + additem(n, d->ammo[1], ammo, 1); + break; + case I_AMMO: + additem(n, d->ammo[d->primary], ammo, d->primary); + break; + case I_GRENADE: additem(n, d->mag[6], ammo, 6); break; + case I_HEALTH: additem(n, d->health, np*5, 7); break; + + case I_ARMOUR: + additem(n, d->armour, 20, 8); + break; + + case I_AKIMBO: + //additem(n, d->ammo[1], 60, 9); + additem(n, d->akimbo, 60, 9); + break; + + case CARROT: + ents[n].spawned = false; + triggertime = lastmillis; + trigger(ents[n].attr1, ents[n].attr2, false); // needs to go over server for multiplayer + break; + + case LADDER: + { + d->onladder = true; + break; + }; + + // EDIT: AH + case CTF_FLAG: + { + int team = ents[n].attr2; + flaginfo &f = flaginfos[team]; + if(f.state == CTFF_STOLEN) break; + else if(team == rb_team_int(player1->team) && f.state == CTFF_DROPPED) + { + addmsg(SV_FLAGRETURN, "ri", team); + ents[n].spawned = false; + } + else if(team != rb_team_int(player1->team)) + { + addmsg(SV_FLAGPICKUP, "ri", team); + ents[n].spawned = false; + f.thief = player1; // do this although we don't know if we picked the flag to avoid getting it after a possible respawn + f.state = CTFF_STOLEN; + f.pick_ack = false; + } + else if(team == rb_team_int(player1->team) && f.state == CTFF_INBASE && flaginfos[rb_opposite(team)].state == CTFF_STOLEN && flaginfos[rb_opposite(team)].thief == player1) addmsg(SV_FLAGSCORE, "ri", rb_opposite(team)); + break; + }; + }; +}; + +void checkitems() +{ + if(editmode) return; + player1->onladder = false; + loopv(ents) + { + entity &e = ents[i]; + if(e.type==NOTUSED) continue; + if(e.type==LADDER) + { + if(OUTBORD(e.x, e.y)) continue; + vec v = { e.x, e.y, player1->o.z }; + vdist(dist1, t, player1->o, v); + float dist2 = player1->o.z - (S(e.x, e.y)->floor+player1->eyeheight); + if(dist1<1.5 && dist2floor+player1->eyeheight }; + vdist(dist, t, player1->o, v); + if(dist<2.5) pickup(i, player1); + }; +}; + +void putitems(ucharbuf &p) // puts items in network stream and also spawns them locally +{ + loopv(ents) if((ents[i].type>=I_CLIPS && ents[i].type<=I_AKIMBO) || ents[i].type==CARROT) + { + if(m_noitemsnade && ents[i].type!=I_GRENADE) continue; + else if(m_pistol && ents[i].type==I_AMMO) continue; + putint(p, i); + ents[i].spawned = true; + }; +}; + +void resetspawns() +{ + loopv(ents) ents[i].spawned = false; + if(m_noitemsnade || m_pistol) + loopv(ents) + { + entity &e = ents[i]; + if(m_noitemsnade && e.type == I_CLIPS) e.type = I_GRENADE; + else if(m_pistol && e.type==I_AMMO) e.type = I_CLIPS; + } +}; +void setspawn(int i, bool on) { if(i=0) ents[i].spawned = on; }; + +void radd(dynent *d) +{ + loopi(NUMGUNS) if(d->nextprimary!=i) d->ammo[i] = 0; + + d->mag[GUN_KNIFE] = d->ammo[GUN_KNIFE] = 1; + d->mag[GUN_GRENADE] = d->ammo[GUN_GRENADE] = 0; + + if(m_pistol || d->primary==GUN_PISTOL) // pistol only mode + { + d->primary = GUN_PISTOL; + d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].max; + } + if(m_lss) + { + d->mag[d->primary] = d->mag[GUN_PISTOL] = 0; + d->primary = GUN_KNIFE; + } + else if(!m_nogun) + { + d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].start-magsize(GUN_PISTOL); + d->mag[GUN_PISTOL] = magsize(GUN_PISTOL); + d->ammo[d->primary] = itemstats[d->primary].start-magsize(d->primary); + d->mag[d->primary] = magsize(d->primary); + }; + + if (d->hasarmour) + { + if(gamemode==m_arena) d->armour = 100; + }; + + d->gunselect = d->primary; +}; + +void item(int num) +{ + if (num>0 && num<7) player1->nextprimary = num; + + //if (num==6) conoutf("sorry, no nades yet"); + + if (num==7) { player1->hasarmour=!player1->hasarmour; /*toggle armour*/ }; +}; + +COMMAND(item,ARG_1INT); + +// Added by Rick +bool intersect(entity *e, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box(entity version) +{ + mapmodelinfo &mmi = getmminfo(e->attr2); + if(!&mmi || !mmi.h) return false; + + float lo = (float)(S(e->x, e->y)->floor+mmi.zoff+e->attr3); + float hi = lo+mmi.h; + vec v = to, w = { e->x, e->y, lo + (fabs(hi-lo)/2.0f) }, *p; + vsub(v, from); + vsub(w, from); + float c1 = dotprod(w, v); + + if(c1<=0) p = &from; + else + { + float c2 = dotprod(v, v); + if(c2<=c1) p = &to; + else + { + float f = c1/c2; + vmul(v, f); + vadd(v, from); + p = &v; + }; + }; + + if (p->x <= e->x+mmi.rad + && p->x >= e->x-mmi.rad + && p->y <= e->y+mmi.rad + && p->y >= e->y-mmi.rad + && p->z <= hi + && p->z >= lo) + { + if (end) *end = *p; + return true; + } + return false; +}; +// End add by Ricks diff --git a/source/src/main.cpp b/source/src/main.cpp new file mode 100644 index 00000000..e1f54677 --- /dev/null +++ b/source/src/main.cpp @@ -0,0 +1,425 @@ +// main.cpp: initialisation & main loop + +#include "cube.h" + +void cleanup(char *msg) // single program exit point; +{ + stop(); + disconnect(true); + cleangl(); + cleansound(); + cleanupserver(); + SDL_ShowCursor(1); + if(msg) + { + #ifdef WIN32 + MessageBox(NULL, msg, "cube fatal error", MB_OK|MB_SYSTEMMODAL); + #else + printf(msg); + #endif + }; + SDL_Quit(); + exit(1); +}; + +void quit() // normal exit +{ + writeservercfg(); + cleanup(NULL); +}; + +void fatal(char *s, char *o) // failure exit +{ + s_sprintfd(msg)("%s%s (%s)\n", s, o, SDL_GetError()); + cleanup(msg); +}; + +int scr_w = 640; +int scr_h = 480; + +void screenshot() +{ + SDL_Surface *image; + SDL_Surface *temp; + int idx; + if(image = SDL_CreateRGBSurface(SDL_SWSURFACE, scr_w, scr_h, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0)) + { + if(temp = SDL_CreateRGBSurface(SDL_SWSURFACE, scr_w, scr_h, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0)) + { + glReadPixels(0, 0, scr_w, scr_h, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); + for (idx = 0; idxpixels+3*scr_w*idx; + memcpy(dest, (char *)image->pixels+3*scr_w*(scr_h-1-idx), 3*scr_w); + endianswap(dest, 3, scr_w); + }; + s_sprintfd(buf)("screenshots/screenshot_%d.bmp", lastmillis); + SDL_SaveBMP(temp, path(buf)); + SDL_FreeSurface(temp); + }; + SDL_FreeSurface(image); + }; +}; + +COMMAND(screenshot, ARG_NONE); +COMMAND(quit, ARG_NONE); + +static void bar(float bar, int w, int o, float r, float g, float b) +{ + int side = 50; + glColor3f(r, g, b); + glVertex2f(side, o*FONTH); + glVertex2f(bar*(w*3-2*side)+side, o*FONTH); + glVertex2f(bar*(w*3-2*side)+side, (o+2)*FONTH); + glVertex2f(side, (o+2)*FONTH); +}; + +void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2, const char *text2) // also used during loading +{ + int w = scr_w, h = scr_h; + + glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, w*3, h*3, 0, -1, 1); + + glBegin(GL_QUADS); + + if(text1) + { + bar(1, w, 4, 0, 0, 0.8f); + bar(bar1, w, 4, 0, 0.5f, 1); + }; + + if(bar2>0) + { + bar(1, w, 6, 0.5f, 0, 0); + bar(bar2, w, 6, 0.75f, 0, 0); + }; + + glEnd(); + + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + + if(text1) draw_text(text1, 70, 4*FONTH + FONTH/2); + if(bar2>0) draw_text(text2, 70, 6*FONTH + FONTH/2); + + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glEnable(GL_DEPTH_TEST); + SDL_GL_SwapBuffers(); +}; + +SDL_Surface *screen = NULL; + +void setfullscreen(bool enable) +{ + if(enable == !(screen->flags&SDL_FULLSCREEN)) + { +#ifdef WIN32 + conoutf("\"fullscreen\" variable not supported on this platform. Use the -t command-line option."); + extern int fullscreen; + fullscreen = !enable; +#else + SDL_WM_ToggleFullScreen(screen); + SDL_WM_GrabInput((screen->flags&SDL_FULLSCREEN) ? SDL_GRAB_ON : SDL_GRAB_OFF); +#endif + }; +}; + +void screenres(int *w, int *h, int *bpp = 0) +{ +#ifdef WIN32 + conoutf("\"screenres\" command not supported on this platform. Use the -w and -h command-line options."); +#else + SDL_Surface *surf = SDL_SetVideoMode(*w, *h, bpp ? *bpp : 0, SDL_OPENGL|SDL_RESIZABLE|(screen->flags&SDL_FULLSCREEN)); + if(!surf) return; + scr_w = *w; + scr_h = *h; + screen = surf; + glViewport(0, 0, *w, *h); +#endif +}; + +VARF(fullscreen, 0, 0, 1, setfullscreen(fullscreen!=0)); + +COMMAND(screenres, ARG_3INT); + +VAR(maxfps, 5, 200, 500); + +void limitfps(int &millis, int curmillis) +{ + static int fpserror = 0; + int delay = 1000/maxfps - (millis-curmillis); + if(delay < 0) fpserror = 0; + else + { + fpserror += 1000%maxfps; + if(fpserror >= maxfps) + { + ++delay; + fpserror -= maxfps; + }; + if(delay > 0) + { + SDL_Delay(delay); + millis += delay; + }; + }; +}; + +int lowfps, highfps; + +void fpsrange(int low, int high) +{ + if(low>high || low<1) return; + lowfps = low; + highfps = high; +}; + +COMMAND(fpsrange, ARG_2INT); + +void keyrepeat(bool on) +{ + SDL_EnableKeyRepeat(on ? SDL_DEFAULT_REPEAT_DELAY : 0, + SDL_DEFAULT_REPEAT_INTERVAL); +}; + +VARF(gamespeed, 10, 100, 1000, if(multiplayer()) gamespeed = 100); + +int islittleendian = 1; +int framesinmap = 0; + +int main(int argc, char **argv) +{ + int fs = SDL_FULLSCREEN, par = 0, uprate = 0, maxcl = 4; + char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = NULL; + islittleendian = *((char *)&islittleendian); + + #define log(s) puts("init: " s) + log("sdl"); + + for(int i = 1; i200) curtime = 200; + else if(curtime<1) curtime = 1; + + cleardlights(); + if(lastmillis) updateworld(curtime, lastmillis); + + lastmillis += curtime; + curmillis = millis; + + if(!demoplayback) serverslice((int)time(NULL), 0); + + frames++; + fps = (1000.0f/elapsed+fps*10)/11; + + computeraytable(player1->o.x, player1->o.y); + readdepth(scr_w, scr_h); + SDL_GL_SwapBuffers(); + extern void updatevol(); updatevol(); + if(framesinmap++<5) // cheap hack to get rid of initial sparklies, even when triple buffering etc. + { + player1->yaw += 5; + gl_drawframe(scr_w, scr_h, 1.0f, fps); + player1->yaw -= 5; + }; + gl_drawframe(scr_w, scr_h, fpshighfps ? fps/highfps : 1.0f), fps); + //SDL_Delay(100); + SDL_Event event; + int lasttype = 0, lastbut = 0; + while(SDL_PollEvent(&event)) + { + switch(event.type) + { + case SDL_QUIT: + quit(); + break; + + #ifndef WIN32 + case SDL_VIDEORESIZE: + screenres(&event.resize.w, &event.resize.h); + break; + #endif + + case SDL_KEYDOWN: + case SDL_KEYUP: + keypress(event.key.keysym.sym, event.key.state==SDL_PRESSED, event.key.keysym.unicode); + break; + + case SDL_ACTIVEEVENT: + if(event.active.state & SDL_APPINPUTFOCUS) + grabmouse = event.active.gain; + else + if(event.active.gain) + grabmouse = 1; + break; + + case SDL_MOUSEMOTION: + if(ignore) { ignore--; break; }; + if(!(screen->flags&SDL_FULLSCREEN) && grabmouse) + { + #ifdef __APPLE__ + if(event.motion.y == 0) break; //let mac users drag windows via the title bar + #endif + if(event.motion.x == scr_w / 2 && event.motion.y == scr_h / 2) break; + SDL_WarpMouse(scr_w / 2, scr_h / 2); + }; + #ifndef WIN32 + if((screen->flags&SDL_FULLSCREEN) || grabmouse) + #endif + mousemove(event.motion.xrel, event.motion.yrel); + break; + + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + if(lasttype==event.type && lastbut==event.button.button) break; // why?? get event twice without it + keypress(-event.button.button, event.button.state!=0, 0); + lasttype = event.type; + lastbut = event.button.button; + break; + }; + }; +#ifdef _DEBUG + if(millis>lastflush+60000) { + fflush(stdout); lastflush = millis; + } +#endif + }; + quit(); + return 1; + +}; + +void loadcrosshair(char *c) +{ + s_sprintfd(p)("packages/misc/crosshairs/%s", c); + path(p); + int xs, ys; + installtex(1, p, xs, ys); + +}; + +COMMAND(loadcrosshair, ARG_1STR); diff --git a/source/src/menus.cpp b/source/src/menus.cpp new file mode 100644 index 00000000..2c16bd76 --- /dev/null +++ b/source/src/menus.cpp @@ -0,0 +1,258 @@ +// menus.cpp: ingame menu system (also used for scores and serverlist) + +#include "cube.h" + +#define FIRSTMENU 120 + +struct mitem { char *text, *action, *hoveraction; }; + +struct gmenu +{ + char *name; + vector items; + int mwidth; + int menusel; + char *mdl; // (optional) md2 mdl + int frame, range, rotspeed, scale; +}; + +vector menus; + +int vmenu = -1; + +ivector menustack; + +void menuset(int menu) // EDIT: AH +{ + if((vmenu = menu)>=1 && menu != 2) resetmovement(player1); + if(vmenu==1) menus[1].menusel = 0; +}; + +void showmenu(char *name) +{ + loopv(menus) if(i>1 && strcmp(menus[i].name, name)==0) + { + menuset(i); + return; + }; +}; + +int menucompare(mitem *a, mitem *b) +{ + int x = atoi(a->text); + int y = atoi(b->text); + if(x>y) return -1; + if(x0 && vmenu!=2 ? "[ %s menu ]" : "%s", m.name); // EDIT: AH + int mdisp = m.items.length(); + int w = 0; + loopi(mdisp) + { + int x = text_width(m.items[i].text); + if(x>w) w = x; + }; + int tw = text_width(title); + if(tw>w) w = tw; + int step = FONTH/4*5; + int h = (mdisp+2)*step; + int y = (VIRTH-h)/2; + int x = (VIRTW-w)/2; + blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true, 6); + draw_text(title, x, y); + y += FONTH*2; + if(vmenu && vmenu!=2) + { + int bh = y+m.menusel*step; + blendbox(x-FONTH, bh-10, x+w+FONTH, bh+FONTH+10, false); + }; + loopj(mdisp) + { + draw_text(m.items[j].text, x, y); + y += step; + }; + return true; +}; + +void rendermenumdl() +{ + if(vmenu<0) { menustack.setsize(0); return; }; + if(vmenu==1) refreshservers(); + gmenu &m = menus[vmenu]; + if(!m.mdl) return; + + glPushMatrix (); + + float t = (lastmillis-player1->lastaction)/1000.0f; + if(t >= 1.6f) t = 1.6f; + + if(player1->state==CS_DEAD) + { + player1->pitch = (float) sin(t)*(-70.0f-player1->oldpitch)+player1->oldpitch; + glTranslatef(player1->o.x, -(player1->eyeheight-sin(t)*7.0f-player1->o.z), player1->o.y); + } + else + { + glTranslatef(player1->o.x, player1->o.z, player1->o.y); + } + glRotatef(player1->yaw+90+180, 0, -1, 0); + glRotatef(player1->pitch, 0, 0, 1); + + vec pos = { 0.0f, 0.0f, 0.0f }; + bool isplayermodel = !strncmp(m.mdl, "playermodels", strlen("playermodels")); + + if(isplayermodel) + { + glTranslatef(2.0f, 1.0f, 1.5f); + pos.z = -1.0f; + } + else + { + glTranslatef(2.0f, 1.7f, 0); + }; + + if(m.rotspeed) glRotatef(lastmillis/5.0f/100.0f*m.rotspeed, 0, 1, 0); + rendermodel(m.mdl, m.frame, m.range, 0, 0.0f, pos.x, pos.z, pos.y, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1.0f), 100, 0, 0, false); + + if(isplayermodel) + { + string vwep; + s_strcpy(vwep, "weapons/subgun/world"); + path(vwep); + rendermodel(vwep, m.frame, m.range, 0, 0.0f, pos.x, pos.z, pos.y, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1.0f), 100, 0, 0, false); + }; + + glPopMatrix(); +} + +void newmenu(char *name) +{ + gmenu &menu = menus.add(); + menu.name = newstring(name); + menu.menusel = 0; + menu.mdl = NULL; +}; + +void menumanual(int m, int n, char *text, char *action) +{ + if(!n) menus[m].items.setsize(0); + mitem &mitem = menus[m].items.add(); + mitem.text = text; + mitem.action = action; + mitem.hoveraction = NULL; +} + +void purgemenu(int m) +{ + menus[m].items.setsize(0); +} + +void menuitem(char *text, char *action, char *hoveraction) +{ + gmenu &menu = menus.last(); + mitem &mi = menu.items.add(); + mi.text = newstring(text); + mi.action = action[0] ? newstring(action) : mi.text; + mi.hoveraction = hoveraction[0] ? newstring(hoveraction) : NULL; +}; + +void menumdl(char *mdl, char *frame, char *range, char *rotspeed, char *scale) +{ + if(!mdl || !frame || !range) return; + gmenu &menu = menus.last(); + menu.mdl = newstring(mdl, _MAXDEFSTR); + menu.frame = max(0, atoi(frame)); + menu.range = max(1, atoi(range)); + menu.rotspeed = max(0, min(atoi(rotspeed), 100)); + menu.scale = max(0, min(atoi(scale), 100)); +}; + +void chmenumdl(char *menu, char *mdl, char *frame, char *range, char *rotspeed, char *scale) +{ + if(!menu || !mdl) return; + loopv(menus) + { + gmenu &m = menus[i]; + if(strcmp(m.name, menu) == 0) + { + if(m.mdl) s_strcpy(m.mdl, mdl); + else m.mdl = newstring(mdl, _MAXDEFSTR); + m.frame = atoi(frame); + m.range = atoi(range); + m.rotspeed = max(0, min(atoi(rotspeed), 100)); + m.scale = max(0, min(atoi(scale), 100)); + return; + }; + }; +}; + + +COMMAND(menuitem, ARG_3STR); +COMMAND(showmenu, ARG_1STR); +COMMAND(newmenu, ARG_1STR); +COMMAND(menumdl, ARG_5STR); +COMMAND(chmenumdl, ARG_6STR); + +bool menukey(int code, bool isdown) +{ + if(vmenu<=0 || vmenu == 2) return false; // EDIT: AH + int menusel = menus[vmenu].menusel; + + if(isdown) + { + setscope(false); + int oldmenusel = menusel; + if(code==SDLK_ESCAPE) + { + menuset(-1); + if(!menustack.empty()) menuset(menustack.pop()); + return true; + } + else if(code==SDLK_UP || code==-4) menusel--; + else if(code==SDLK_DOWN || code==-5) menusel++; + int n = menus[vmenu].items.length(); + if(menusel<0) menusel = n>0 ? n-1 : 0; + else if(menusel>=n) menusel = 0; + menus[vmenu].menusel = menusel; + char *haction = menus[vmenu].items[menusel].hoveraction; + if(menusel != oldmenusel && haction) execute(haction, true); + } + else + { + if(code==SDLK_RETURN || code==-2) + { + if(menusel<0 || menusel >= menus[vmenu].items.length()) { menuset(-1); return true; }; + char *action = menus[vmenu].items[menusel].action; + if(vmenu==1) connects(getservername(menusel)); + else if(vmenu==3 || vmenu==4) + { + int cn = (int)action; + mastercommand(vmenu==3 ? MCMD_KICK : MCMD_BAN, cn); + purgemenu(vmenu); + menuset(-1); + return true; + } + menustack.add(vmenu); + menuset(-1); + if(action) execute(action, true); + }; + }; + return true; +}; diff --git a/source/src/pch.cpp b/source/src/pch.cpp new file mode 100644 index 00000000..5b241e7f --- /dev/null +++ b/source/src/pch.cpp @@ -0,0 +1 @@ +#include "cube.h" diff --git a/source/src/physics.cpp b/source/src/physics.cpp new file mode 100644 index 00000000..71d961be --- /dev/null +++ b/source/src/physics.cpp @@ -0,0 +1,459 @@ +// physics.cpp: no physics books were hurt nor consulted in the construction of this code. +// All physics computations and constants were invented on the fly and simply tweaked until +// they "felt right", and have no basis in reality. Collision detection is simplistic but +// very robust (uses discrete steps at fixed fps). + +#include "cube.h" + +/* Modified by Rick: Fix, so we can jump on players aswell +bool plcollide(dynent *d, dynent *o, float &headspace) // collide with player or monster +{ + if(o->state!=CS_ALIVE) return true; + const float r = o->radius+d->radius; + if(fabs(o->o.x-d->o.x)o.y-d->o.y)o.z-d->o.z)aboveeye+d->eyeheight) return false; + if(d->monsterstate) return false; // hack + headspace = d->o.z-o->o.z-o->aboveeye-d->eyeheight; + if(headspace<0) headspace = 10; + }; + return true; +}; +*/ + +bool plcollide(dynent *d, dynent *o, float &headspace, float &hi, float &lo) // collide with player or monster +{ + if(o->state!=CS_ALIVE) return true; + const float r = o->radius+d->radius; + if(fabs(o->o.x-d->o.x)o.y-d->o.y)o.z-d->eyeheighto.z-o->eyeheight) { if(o->o.z-o->eyeheighto.z-o->eyeheight-1; } + else if(o->o.z+o->aboveeye>lo) lo = o->o.z+o->aboveeye+1; + + if(fabs(o->o.z-d->o.z)aboveeye+d->eyeheight) return false; + //if(d->monsterstate) return false; // hack + headspace = d->o.z-o->o.z-o->aboveeye-d->eyeheight; + if(headspace<0) headspace = 10; + }; + return true; +}; + +bool cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by, int &bs) // recursively collide with a mipmapped corner cube +{ + sqr *w = wmip[mip]; + int sz = ssize>>mip; + bool stest = SOLID(SWS(w, x+dx, y, sz)) && SOLID(SWS(w, x, y+dy, sz)); + mip++; + x /= 2; + y /= 2; + if(SWS(wmip[mip], x, y, ssize>>mip)->type==CORNER) + { + bx = x<radius; + if(fabs(e.x-d->o.x)o.y)floor+mmi.zoff+e.attr3); + if(d->o.z-d->eyeheightlo) lo = mmz+mmi.h; + }; + }; +}; + +// all collision happens here +// spawn is a dirty side effect used in spawning +// drop & rise are supplied by the physics below to indicate gravity/push for current mini-timestep + +bool collide(dynent *d, bool spawn, float drop, float rise) +{ + const float fx1 = d->o.x-d->radius; // figure out integer cube rectangle this entity covers in map + const float fy1 = d->o.y-d->radius; + const float fx2 = d->o.x+d->radius; + const float fy2 = d->o.y+d->radius; + const int x1 = int(fx1); + const int y1 = int(fy1); + const int x2 = int(fx2); + const int y2 = int(fy2); + float hi = 127, lo = -128; + float minfloor = (d->monsterstate && !spawn && d->health>100) ? d->o.z-d->eyeheight-4.5f : -1000.0f; // big monsters are afraid of heights, unless angry :) + + for(int x = x1; x<=x2; x++) for(int y = y1; y<=y2; y++) // collide with map + { + if(OUTBORD(x,y)) return false; + sqr *s = S(x,y); + float ceil = s->ceil; + float floor = s->floor; + switch(s->type) + { + case SOLID: + return false; + + case CORNER: + { + int bx = x, by = y, bs = 1; + if(x==x1 && y==y1 && cornertest(0, x, y, -1, -1, bx, by, bs) && fx1-bx+fy1-by<=bs + || x==x2 && y==y1 && cornertest(0, x, y, 1, -1, bx, by, bs) && fx2-bx>=fy1-by + || x==x1 && y==y2 && cornertest(0, x, y, -1, 1, bx, by, bs) && fx1-bx<=fy2-by + || x==x2 && y==y2 && cornertest(0, x, y, 1, 1, bx, by, bs) && fx2-bx+fy2-by>=bs) + return false; + break; + }; + + case FHF: // FIXME: too simplistic collision with slopes, makes it feels like tiny stairs + floor -= (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; + break; + + case CHF: + ceil += (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; + + }; + if(ceillo) lo = floor; + if(flooreyeheight+d->aboveeye) return false; + + // Modified by Rick: plcollide now takes hi and lo in account aswell, that way we can jump/walk on players + + float headspace = 10; + loopv(players) // collide with other players + { + dynent *o = players[i]; + if(!o || o==d) continue; + if(!plcollide(d, o, headspace, hi, lo)) return false; + }; + loopv(bots) // Added by Rick: collide with other bots + { + dynent *o = bots[i]; + if(!o || o==d) continue; + if(!plcollide(d, o, headspace, hi, lo)) return false; + }; + + if(d!=player1 && d->mtype!=M_NADE) if(!plcollide(d, player1, headspace, hi, lo)) return false; + //dvector &v = getmonsters(); + // this loop can be a performance bottleneck with many monster on a slow cpu, + // should replace with a blockmap but seems mostly fast enough + // Modified by Rick: Added v[i] pointer check + //loopv(v) if(v[i] && !vreject(d->o, v[i]->o, 7.0f) && d!=v[i] && !plcollide(d, v[i], headspace, hi, lo)) return false; + headspace -= 0.01f; + + mmcollide(d, hi, lo); // collide with map models + + if(spawn) + { + d->o.z = lo+d->eyeheight; // just drop to floor (sideeffect) + d->onfloor = true; + } + else + { + const float space = d->o.z-d->eyeheight-lo; + if(space<0) + { + if(space>-0.01) + { + d->o.z = lo+d->eyeheight; // stick on step + } + else if(space>-1.26f && !d->isphysent) d->o.z += rise; // rise thru stair + else return false; + } + else + { + d->o.z -= min(min(drop, space), headspace); // gravity + }; + + const float space2 = hi-(d->o.z+d->aboveeye); + if(space2<0) + { + if(space2<-0.1) return false; // hack alert! + d->o.z = hi-d->aboveeye; // glue to ceiling + d->vel.z = 0; // cancel out jumping velocity + }; + + d->onfloor = d->o.z-d->eyeheight-lo<0.01f; + }; + return true; +} + +float rad(float x) { return x*3.14159f/180; }; + +VAR(maxroll, 0, 3, 20); + +int physicsfraction = 0, physicsrepeat = 0; +const int MINFRAMETIME = 20; // physics always simulated at 50fps or better + +void physicsframe() // optimally schedule physics frames inside the graphics frames +{ + if(curtime>=MINFRAMETIME) + { + int faketime = curtime+physicsfraction; + physicsrepeat = faketime/MINFRAMETIME; + physicsfraction = faketime-physicsrepeat*MINFRAMETIME; + } + else + { + physicsrepeat = 1; + }; +}; + +void selfdamage(dynent *d, int dm) +{ + if(d==player1) selfdamage(dm, -1, d); + else { addmsg(SV_DAMAGE, "ri3", d, dm, d->lifesequence); }; + //playsound(S_FALL1+rnd(5), &d->o); }; // fixme sound + particle_splash(3, dm, 1000, d->o); //edit out? + demodamage(dm, d->o); +}; + + +// main physics routine, moves a player/monster for a curtime step +// moveres indicated the physics precision (which is lower for monsters and multiplayer prediction) +// local is false for multiplayer prediction + +void moveplayer(dynent *pl, int moveres, bool local, int curtime) +{ + const bool water = hdr.waterlevel>pl->o.z-0.5f; + const bool floating = (editmode && local) || pl->state==CS_EDITING; + + vec d; // vector of direction we ideally want to move in + + + int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // fix movement on ladder + + d.x = (float)(move*cos(rad(pl->yaw-90))); + d.y = (float)(move*sin(rad(pl->yaw-90))); + d.z = (float) pl->isphysent ? pl->vel.z : 0; + + if(floating || water) + { + d.x *= (float)cos(rad(pl->pitch)); + d.y *= (float)cos(rad(pl->pitch)); + d.z = (float)(move*sin(rad(pl->pitch))); + }; + + d.x += (float)(pl->strafe*cos(rad(pl->yaw-180))); + d.y += (float)(pl->strafe*sin(rad(pl->yaw-180))); + + const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed; + const float friction = water ? 20.0f : (pl->onfloor || floating ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); + + const float fpsfric = friction/curtime*20.0f; + + vmul(pl->vel, fpsfric-1); // slowly apply friction and direction to velocity, gives a smooth movement + vadd(pl->vel, d); + vdiv(pl->vel, fpsfric); + d = pl->vel; + vmul(d, speed); // d is now frametime based velocity vector + + if(pl->isphysent) + { + pl->pitch += ((float) sqrt(dotprod(pl->vel, pl->vel)))*speed*pl->rotspeed*5.0f; + if(pl->pitch>360.0f) pl->pitch = 0.0f; + pl->yaw += ((float) sqrt(dotprod(pl->vel, pl->vel)))*speed*pl->rotspeed*5.0f; + if(pl->yaw>360.0f) pl->yaw = 0.0f; + } + + pl->blocked = false; + pl->moving = true; + + if(floating) // just apply velocity + { + vadd(pl->o, d); + if(pl->jumpnext) { pl->jumpnext = false; pl->vel.z = 2; } + } + else // apply velocity with collision + { + if(pl->onladder) + { + if(pl->k_up) pl->vel.z = 0.75; + else if(pl->k_down) pl->vel.z = -0.75; + pl->timeinair = 0; + } + else + { + if(pl->onfloor || water) + { + if(pl->jumpnext) + { + pl->jumpnext = false; + pl->vel.z = 2.0f; //1.7f; // physics impulse upwards + if(water) { pl->vel.x /= 8; pl->vel.y /= 8; }; // dampen velocity change even harder, gives correct water feel + if(local) playsoundc(S_JUMP); + else if(pl->monsterstate) playsound(S_JUMP, &pl->o); + else if(pl->bIsBot) botplaysound(S_JUMP, pl); // Added by Rick + } + pl->timeinair = 0; + if(pl->isphysent) pl->vel.z *= 0.7f; + } + else + { + pl->timeinair += curtime; + }; + }; + + const float gravity = pl->isphysent ? pl->gravity : 20; + const float f = 1.0f/moveres; + float dropf = pl->isphysent ? ((gravity-1)+pl->timeinair/14.0f) : ((gravity-1)+pl->timeinair/15.0f); // incorrect, but works fine + if(water) { dropf = 5; pl->timeinair = 0; }; // float slowly down in water + if(pl->onladder) { dropf = 0; pl->timeinair = 0; }; + float drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast + const float rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs + + loopi(moveres) // discrete steps collision detection & sliding + { + // try move forward + pl->o.x += f*d.x; + pl->o.y += f*d.y; + pl->o.z += f*d.z; + if(collide(pl, false, drop, rise)) continue; + // player stuck, try slide along y axis + pl->blocked = true; + pl->o.x -= f*d.x; + if(collide(pl, false, drop, rise)) + { + d.x = 0; + if(pl->isphysent) pl->vel.x = -pl->vel.x; + continue; + }; + pl->o.x += f*d.x; + // still stuck, try x axis + pl->o.y -= f*d.y; + if(collide(pl, false, drop, rise)) + { + d.y = 0; + if(pl->isphysent) pl->vel.y = -pl->vel.y; + continue; + }; + pl->o.y += f*d.y; + // try just dropping down + pl->moving = false; + pl->o.x -= f*d.x; + pl->o.y -= f*d.y; + if(collide(pl, false, drop, rise)) + { + d.y = d.x = 0; + continue; + }; + pl->o.z -= f*d.z; + break; + }; + }; + + // detect wether player is outside map, used for skipping zbuffer clear mostly + + if(pl->o.x < 0 || pl->o.x >= ssize || pl->o.y <0 || pl->o.y > ssize) + { + pl->outsidemap = true; + } + else + { + sqr *s = S((int)pl->o.x, (int)pl->o.y); + pl->outsidemap = SOLID(s) + || pl->o.z < s->floor - (s->type==FHF ? s->vdelta/4 : 0) + || pl->o.z > s->ceil + (s->type==CHF ? s->vdelta/4 : 0); + }; + + // automatically apply smooth roll when strafing + + if(pl->strafe==0) + { + pl->roll = pl->roll/(1+(float)sqrt((float)curtime)/25); + } + else + { + pl->roll += pl->strafe*curtime/-30.0f; + if(pl->roll>maxroll) pl->roll = (float)maxroll; + if(pl->roll<-maxroll) pl->roll = (float)-maxroll; + }; + + // play sounds on water transitions + + if(!pl->inwater && water) { playsound(S_SPLASH2, &pl->o); pl->vel.z = 0; } + else if(pl->inwater && !water) playsound(S_SPLASH1, &pl->o); + pl->inwater = water; + // Added by Rick: Easy hack to store previous locations of all players/monsters/bots + pl->PrevLocations.Update(pl->o); + // End add +}; + +void moveplayer(dynent *pl, int moveres, bool local) +{ + loopi(physicsrepeat) moveplayer(pl, moveres, local, i ? curtime/physicsrepeat : curtime-curtime/physicsrepeat*(physicsrepeat-1)); +}; + +physent *new_physent() +{ + physent *p = new physent; + + p->yaw = 270; + p->pitch = 0; + p->roll = 0; + p->isphysent = true; + p->rotspeed = 1.0f; + + p->maxspeed = 40; + p->outsidemap = false; + p->inwater = false; + p->radius = 0.2f; + p->eyeheight = 0.3f; + p->aboveeye = 0.0f; + p->frags = 0; + p->plag = 0; + p->ping = 0; + p->lastupdate = lastmillis; + p->enemy = NULL; + p->monsterstate = 0; + p->name[0] = p->team[0] = 0; + p->blocked = false; + p->lifesequence = 0; + p->dynent::state = CS_ALIVE; + p->state = PHYSENT_NONE; + p->shots = 0; + p->reloading = false; + p->nextprimary = 1; + p->hasarmour = false; + + p->k_left = false; + p->k_right = false; + p->k_up = false; + p->k_down = false; + p->jumpnext = false; + p->onladder = false; + p->strafe = 0; + p->move = 0; + + physents.add(p); + return p; +} + +extern void explode_nade(physent *i); + +void mphysents() +{ + loopv(physents) if(physents[i]) + { + physent *p = physents[i]; + if(p->state == NADE_THROWED || p->state == GIB) moveplayer(p, 2, false); + + if(lastmillis - p->millis >= p->timetolife) + { + if(p->state==NADE_ACTIVATED || p->state==NADE_THROWED) explode_nade(physents[i]); + physents.remove(i); + i--; + }; + }; +}; diff --git a/source/src/protos.h b/source/src/protos.h new file mode 100644 index 00000000..686abcb7 --- /dev/null +++ b/source/src/protos.h @@ -0,0 +1,296 @@ +// protos for ALL external functions in cube... + +// command +extern int variable(char *name, int min, int cur, int max, int *storage, void (*fun)(), bool persist); +extern void setvar(char *name, int i); +extern int getvar(char *name); +extern bool identexists(char *name); +extern bool addcommand(char *name, void (*fun)(), int narg); +extern int execute(char *p, bool down = true); +extern void exec(char *cfgfile); +extern bool execfile(char *cfgfile); +extern void resetcomplete(); +extern void complete(char *s); +extern void alias(char *name, char *action); +extern char *getalias(char *name); +extern void writecfg(); + +// console +extern void keypress(int code, bool isdown, int cooked); +extern void renderconsole(); +// extern void conoutf(const char *s, int a = 0, int b = 0, int c = 0); Moved to cube.h by Rick +extern char *getcurcommand(); + +// menus +extern bool rendermenu(); +extern void menuset(int menu); +extern void menumanual(int m, int n, char *text, char *action=NULL); +extern void sortmenu(int m, int start, int num); +extern bool menukey(int code, bool isdown); +extern void newmenu(char *name); +extern void rendermenumdl(); +extern void purgemenu(int m); + +// serverbrowser +extern void addserver(char *servername); +extern char *getservername(int n); +extern bool resolverwait(const char *name, ENetAddress *address); +extern void writeservercfg(); + +// rendergl +extern void gl_init(int w, int h); +extern void cleangl(); +extern void gl_drawframe(int w, int h, float changelod, float curfps); +extern bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp = false, bool highqual=false); +extern void mipstats(int a, int b, int c); +extern void vertf(float v1, float v2, float v3, sqr *ls, float t1, float t2); +extern void addstrip(int tex, int start, int n); +extern int lookuptexture(int tex, int &xs, int &ys); +extern char *hudgunnames[]; + +// rendercubes +extern void resetcubes(); +extern void render_flat(int tex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil); +extern void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, float h4, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil); +extern void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, bool topleft); +extern void render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s, sqr *t, sqr *u, sqr *v); +extern void addwaterquad(int x, int y, int size); +extern int renderwater(float hf); +extern void finishstrips(); +extern void setarraypointers(); + +// client +extern void localservertoclient(int chan, uchar *buf, int len); +extern void connects(char *servername); +extern void disconnect(int onlyclean = 0, int async = 0); +extern void toserver(char *text); +extern void addmsg(int type, const char *fmt = NULL, ...); +extern bool multiplayer(); +extern bool allowedittoggle(); +extern void sendpackettoserv(int chan, struct _ENetPacket *packet); +extern void gets2c(); +extern void c2sinfo(dynent *d); +extern void c2skeepalive(); +extern void neterr(char *s); +extern void initclientnet(); +extern bool netmapstart(); +extern int getclientnum(); +extern void changemapserv(char *name, int mode); +extern void newteam(char *name); + +// clientgame +extern flaginfo flaginfos[2]; +extern void mousemove(int dx, int dy); +extern void updateworld(int curtime, int lastmillis); +extern void startmap(char *name); +extern void changemap(char *name); +extern void initclient(); +extern void spawnplayer(dynent *d, bool secure=false); +extern void selfdamage(int damage, int actor, dynent *act, bool gib=false); +extern dynent *newdynent(); +extern char *getclientmap(); +extern const char *modestr(int n); +extern void zapdynent(dynent *&d); +extern dynent *getclient(int cn); +extern dynent *getbot(int cn); // Added by Rick +extern void timeupdate(int timeremain); +extern void resetmovement(dynent *d); +extern void fixplayer1range(); +extern void respawnself(); // EDIT: AH +extern void ctf_death(); +//game mode extras +extern void arenarespawn(); +extern void respawn(); +extern void mastercommand(int cmd, int arg1); + +// clientextras +extern void renderclients(); +extern void renderclient(dynent *d, bool team, char *mdlname, float scale); +void showscores(bool on); +extern void renderscores(); + +// world +extern void setupworld(int factor); +extern void empty_world(int factor, bool force); +extern void remip(block &b, int level = 0); +extern void remipmore(block &b, int level = 0); +extern int closestent(); +extern int findentity(int type, int index = 0); +extern int findplayerstart(int team, int index); +extern void trigger(int tag, int type, bool savegame); +extern void resettagareas(); +extern void settagareas(); +extern entity *newentity(int x, int y, int z, char *what, int v1, int v2, int v3, int v4); + +// worldlight +extern void calclight(); +extern void dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner); +extern void cleardlights(); +extern block *blockcopy(block &b); +extern void blockpaste(block &b); +extern void freeblock(block *&b); + +// worldrender +extern void render_world(float vx, float vy, float vh, float changelod, int yaw, int pitch, float widef, int w, int h); +extern int lod_factor(); + +// worldocull +extern void computeraytable(float vx, float vy); +extern int isoccluded(float vx, float vy, float cx, float cy, float csize); + +// main +extern void fatal(char *s, char *o = ""); +extern void keyrepeat(bool on); +extern void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2 = 0, const char *text2 = NULL); + +// rendertext +extern void draw_text(const char *str, int left, int top); +extern void draw_textf(const char *fstr, int left, int top, ...); +extern int text_width(const char *str, int limit = -1); +extern int text_visible(const char *str, int max); +extern void draw_envbox(int t, int fogdist); + +// editing +extern void cursorupdate(); +extern void toggleedit(); +extern void editdrag(bool isdown); +extern void setvdeltaxy(int delta, block &sel); +extern void editequalisexy(bool isfloor, block &sel); +extern void edittypexy(int type, block &sel); +extern void edittexxy(int type, int t, block &sel); +extern void editheightxy(bool isfloor, int amount, block &sel); +extern bool noteditmode(); +extern void pruneundos(int maxremain = 0); + +// renderextras +extern void line(int x1, int y1, float z1, int x2, int y2, float z2); +extern void box(block &b, float z1, float z2, float z3, float z4); +extern void dot(int x, int y, float z); +extern void linestyle(float width, int r, int g, int b); +extern void newsphere(vec &o, float max, int type); +extern void renderspheres(int time); +extern void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater); +extern void readdepth(int w, int h); +extern void blendbox(int x1, int y1, int x2, int y2, bool border, int tex = -1); +extern void damageblend(int n); +extern void addshotline(dynent *d, vec &from, vec &to); +extern void rendershotlines(); +extern void shotlinereset(); +extern void renderphysents(); +extern bool scoped; +extern void addgib(dynent *d); +extern void loadingscreen(); + +// renderparticles +extern void setorient(vec &r, vec &u); +extern void particle_splash(int type, int num, int fade, vec &p); +//extern void particle_splash(int num, int fade, vec &p); +// extern void particle_trail(int type, int fade, vec &from, vec &to); Moved to cube.h by Rick +extern void render_particles(int time); + +// worldio +extern void save_world(char *fname); +extern void load_world(char *mname); +extern void writemap(char *mname, int msize, uchar *mdata); +extern uchar *readmap(char *mname, int *msize); +extern void loadgamerest(); +extern void incomingdemodata(int chan, uchar *buf, int len, bool extras = false); +extern void demoplaybackstep(); +extern void stop(); +extern void stopifrecording(); +extern void demodamage(int damage, vec &o); +extern void demoblend(int damage); + +// physics +extern void moveplayer(dynent *pl, int moveres, bool local); +extern bool collide(dynent *d, bool spawn, float drop, float rise); +extern void entinmap(dynent *d); +extern void setentphysics(int mml, int mmr); +extern void physicsframe(); +extern void movephysent(physent *pl); +extern physent *new_physent(); +extern void mphysents(); + +// sound +extern void playsound(int n, vec *loc = 0); +extern void playsoundc(int n); +extern void initsound(); +extern void cleansound(); +extern void botplaysound(int n, dynent *b); // Added by Rick +extern void music(char *name); + +// rendermd2 +extern void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap = 0, int basetime = 0, bool oculling=true, dynent *d=NULL); +extern mapmodelinfo &getmminfo(int i); + +// rendermd3 +extern void rendermd3gun(); +extern void loadweapons(); + +// server +enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_MLOGINFAIL, DISC_MAXCLIENTS }; + +extern void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master, char *passwd, int maxcl, char *maprot, char *masterpwd); // EDIT: AH +extern void cleanupserver(); +extern void localconnect(); +extern void localdisconnect(); +extern void localclienttoserver(int chan, struct _ENetPacket *); +extern void serverslice(int seconds, unsigned int timeout); +extern void putint(ucharbuf &p, int n); +extern int getint(ucharbuf &p); +extern void putuint(ucharbuf &p, int n); +extern int getuint(ucharbuf &p); +extern void sendstring(const char *t, ucharbuf &p); +extern void getstring(char *t, ucharbuf &p, int len = MAXTRANS); +extern void startintermission(); +extern void restoreserverstate(vector &ents); +extern uchar *retrieveservers(uchar *buf, int buflen); +extern char msgsizelookup(int msg); +extern void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds, bool isfull); +extern void servermsinit(const char *master, char *sdesc, bool listen); +extern void sendmaps(int n, string mapname, int mapsize, uchar *mapdata); +extern ENetPacket *recvmap(int n); + +// weapon +//extern void selectgun(int a = -1, int b = -1, int c =-1); +extern void shoot(dynent *d, vec &to); +extern void shootv(int gun, vec &from, vec &to, dynent *d = 0, bool local = false, int nademillis=0); +extern void createrays(vec &from, vec &to); +extern void moveprojectiles(float time); +extern void projreset(); +extern dynent *playerincrosshair(); +extern int reloadtime(int gun); +extern void reload(dynent *d); +extern int attackdelay(int gun); +extern int magsize(int gun); +extern int kick_rot(int gun); +extern int kick_back(int gun); +extern bool gun_changed; +extern bool akimboside; +extern void checkweaponswitch(); +extern void weaponswitch(int gun); +extern void setscope(bool activate); +// Added by Rick +extern dynent *botincrosshair(); +extern bool intersect(dynent *d, vec &from, vec &to, vec *end = NULL); +// End add by Rick + +// entities +extern void renderents(); +extern void putitems(ucharbuf &p); +extern void realpickup(int n, dynent *d); +extern void flagaction(int team, int action); +extern void renderentities(); +extern void resetspawns(); +extern void setspawn(int i, bool on); +extern void baseammo(int gun); +extern void checkitems(); +extern void radd(dynent *d); +// Added by Rick +extern void botbaseammo(int gun, dynent *d); +extern bool intersect(entity *e, vec &from, vec &to, vec *end=NULL); +// End add by Rick + +// rndmap +extern void perlinarea(block &b, int scale, int seed, int psize); + diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp new file mode 100644 index 00000000..25e5fb3f --- /dev/null +++ b/source/src/rendercubes.cpp @@ -0,0 +1,342 @@ +// rendercubes.cpp: sits in between worldrender.cpp and rendergl.cpp and fills the vertex array for different cube surfaces. + +#include "cube.h" + +vector verts; + +void setarraypointers() +{ + glVertexPointer(3, GL_FLOAT, sizeof(vertex), &verts[0].x); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), &verts[0].r); + glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), &verts[0].u); +}; + +// generating the actual vertices is done dynamically every frame and sits at the +// leaves of all these functions, and are part of the cpu bottleneck on really slow +// machines, hence the macros. + +#define vertf(v1, v2, v3, ls, t1, t2) { vertex &v = verts.add(); \ + v.u = t1; v.v = t2; \ + v.x = v1; v.y = v2; v.z = v3; \ + v.r = ls->r; v.g = ls->g; v.b = ls->b; v.a = 255; }; + +#define vert(v1, v2, v3, ls, t1, t2) { vertf((float)(v1), (float)(v2), (float)(v3), ls, t1, t2); } + +int nquads; +const float TEXTURESCALE = 32.0f; +bool floorstrip = false, deltastrip = false; +int oh, oy, ox, ogltex; // the o* vars are used by the stripification +int ol3r, ol3g, ol3b, ol4r, ol4g, ol4b; +int firstindex; +bool showm = false; + +void showmip() { showm = !showm; }; +void mipstats(int a, int b, int c) { if(showm) conoutf("1x1/2x2/4x4: %d / %d / %d", a, b, c); }; + +COMMAND(showmip, ARG_NONE); + +#define stripend() { if(floorstrip || deltastrip) { addstrip(ogltex, firstindex, verts.length()-firstindex); floorstrip = deltastrip = false; }; }; +void finishstrips() { stripend(); }; + +sqr sbright, sdark; +VAR(lighterror,1,8,100); + +void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil) // floor/ceil quads +{ + if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; }; + + int sx, sy; + int gltex = lookuptexture(wtex, sx, sy); + float xf = TEXTURESCALE/sx; + float yf = TEXTURESCALE/sy; + float xs = size*xf; + float ys = size*yf; + float xo = xf*x; + float yo = yf*y; + + bool first = !floorstrip || y!=oy+size || ogltex!=gltex || h!=oh || x!=ox; + + if(first) // start strip here + { + stripend(); + firstindex = verts.length(); + ogltex = gltex; + oh = h; + ox = x; + floorstrip = true; + if(isceil) + { + vert(x+size, h, y, l2, xo+xs, yo); + vert(x, h, y, l1, xo, yo); + } + else + { + vert(x, h, y, l1, xo, yo); + vert(x+size, h, y, l2, xo+xs, yo); + }; + ol3r = l1->r; + ol3g = l1->g; + ol3b = l1->b; + ol4r = l2->r; + ol4g = l2->g; + ol4b = l2->b; + } + else // continue strip + { + int lighterr = lighterror*2; + if((abs(ol3r-l3->r)r)g)g)b)b)r; + ol3g = l1->g; + ol3b = l1->b; + ol4r = l2->r; + ol4g = l2->g; + ol4b = l2->b; + }; + + if(isceil) + { + vertf((float)x+size, h3, (float)y+size, l3, xo+xs, yo+ys); + vertf((float)x, h4, (float)y+size, l4, xo, yo+ys); + } + else + { + vertf((float)x, h4, (float)y+size, l4, xo, yo+ys); + vertf((float)x+size, h3, (float)y+size, l3, xo+xs, yo+ys); + }; + + oy = y; + nquads++; +}; + +void render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3, sqr *l1, sqr *l2, sqr *l3) // floor/ceil tris on a corner cube +{ + stripend(); + + int sx, sy; + int gltex = lookuptexture(h->ftex, sx, sy); + float xf = TEXTURESCALE/sx; + float yf = TEXTURESCALE/sy; + + vertf((float)x1, h->floor, (float)y1, l1, xf*x1, yf*y1); + vertf((float)x2, h->floor, (float)y2, l2, xf*x2, yf*y2); + vertf((float)x3, h->floor, (float)y3, l3, xf*x3, yf*y3); + addstrip(gltex, verts.length()-3, 3); + + gltex = lookuptexture(h->ctex, sx, sy); + xf = TEXTURESCALE/sx; + yf = TEXTURESCALE/sy; + + vertf((float)x3, h->ceil, (float)y3, l3, xf*x3, yf*y3); + vertf((float)x2, h->ceil, (float)y2, l2, xf*x2, yf*y2); + vertf((float)x1, h->ceil, (float)y1, l1, xf*x1, yf*y1); + addstrip(gltex, verts.length()-3, 3); + nquads++; +}; + +void render_tris(int x, int y, int size, bool topleft, + sqr *h1, sqr *h2, sqr *s, sqr *t, sqr *u, sqr *v) +{ + if(topleft) + { + if(h1) render_2tris(h1, s, x+size, y+size, x, y+size, x, y, u, v, s); + if(h2) render_2tris(h2, s, x, y, x+size, y, x+size, y+size, s, t, v); + } + else + { + if(h1) render_2tris(h1, s, x, y, x+size, y, x, y+size, s, t, u); + if(h2) render_2tris(h2, s, x+size, y, x+size, y+size, x, y+size, t, u, v); + }; +}; + +void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, bool flip) // wall quads +{ + stripend(); + if(showm) { l1 = &sbright; l2 = &sdark; }; + + int sx, sy; + int gltex = lookuptexture(wtex, sx, sy); + float xf = TEXTURESCALE/sx; + float yf = TEXTURESCALE/sy; + float xs = size*xf; + float xo = xf*(x1==x2 ? min(y1,y2) : min(x1,x2)); + + if(!flip) + { + vertf((float)x2, ceil2, (float)y2, l2, xo+xs, -yf*ceil2); + vertf((float)x1, ceil1, (float)y1, l1, xo, -yf*ceil1); + vertf((float)x2, floor2, (float)y2, l2, xo+xs, -floor2*yf); + vertf((float)x1, floor1, (float)y1, l1, xo, -floor1*yf); + } + else + { + vertf((float)x1, ceil1, (float)y1, l1, xo, -yf*ceil1); + vertf((float)x2, ceil2, (float)y2, l2, xo+xs, -yf*ceil2); + vertf((float)x1, floor1, (float)y1, l1, xo, -floor1*yf); + vertf((float)x2, floor2, (float)y2, l2, xo+xs, -floor2*yf); + }; + + nquads++; + addstrip(gltex, verts.length()-4, 4); +}; + +int wx1, wy1, wx2, wy2; + +VAR(watersubdiv, 1, 4, 64); +VARF(waterlevel, -128, -128, 127, if(!noteditmode()) hdr.waterlevel = waterlevel); + +inline void vertw(int v1, float v2, int v3, sqr *c, float t1, float t2, float t) +{ + vertf((float)v1, v2-(float)sin(v1*v3*0.1+t)*0.2f, (float)v3, c, t1, t2); +}; + +inline float dx(float x) { return x+(float)sin(x*2+lastmillis/1000.0f)*0.04f; }; +inline float dy(float x) { return x+(float)sin(x*2+lastmillis/900.0f+PI/5)*0.05f; }; + +// renders water for bounding rect area that contains water... simple but very inefficient + +int renderwater(float hf) +{ + if(wx1<0) return nquads; + + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_SRC_COLOR); + int sx, sy; + glBindTexture(GL_TEXTURE_2D, lookuptexture(DEFAULT_LIQUID, sx, sy)); + + wx1 &= ~(watersubdiv-1); + wy1 &= ~(watersubdiv-1); + + float xf = TEXTURESCALE/sx; + float yf = TEXTURESCALE/sy; + float xs = watersubdiv*xf; + float ys = watersubdiv*yf; + float t1 = lastmillis/300.0f; + float t2 = lastmillis/4000.0f; + + sqr dl; + dl.r = dl.g = dl.b = 255; + + for(int xx = wx1; xxwx2) wx2 = x2; + if(y2>wy2) wy2 = y2; + }; +}; + +void resetcubes() +{ + floorstrip = deltastrip = false; + wx1 = -1; + nquads = 0; + sbright.r = sbright.g = sbright.b = 255; + sdark.r = sdark.g = sdark.b = 0; +}; + + diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp new file mode 100644 index 00000000..a124c51c --- /dev/null +++ b/source/src/renderextras.cpp @@ -0,0 +1,690 @@ +// renderextras.cpp: misc gl render code and the HUD + +#include "cube.h" + +void line(int x1, int y1, float z1, int x2, int y2, float z2) +{ + glBegin(GL_POLYGON); + glVertex3f((float)x1, z1, (float)y1); + glVertex3f((float)x1, z1, y1+0.01f); + glVertex3f((float)x2, z2, y2+0.01f); + glVertex3f((float)x2, z2, (float)y2); + glEnd(); + xtraverts += 4; +}; + +void linestyle(float width, int r, int g, int b) +{ + glLineWidth(width); + glColor3ub(r,g,b); +}; + +void box(block &b, float z1, float z2, float z3, float z4) +{ + glBegin(GL_POLYGON); + glVertex3f((float)b.x, z1, (float)b.y); + glVertex3f((float)b.x+b.xs, z2, (float)b.y); + glVertex3f((float)b.x+b.xs, z3, (float)b.y+b.ys); + glVertex3f((float)b.x, z4, (float)b.y+b.ys); + glEnd(); + xtraverts += 4; +}; + +void dot(int x, int y, float z) +{ + const float DOF = 0.1f; + glBegin(GL_POLYGON); + glVertex3f(x-DOF, (float)z, y-DOF); + glVertex3f(x+DOF, (float)z, y-DOF); + glVertex3f(x+DOF, (float)z, y+DOF); + glVertex3f(x-DOF, (float)z, y+DOF); + glEnd(); + xtraverts += 4; +}; + +void blendbox(int x1, int y1, int x2, int y2, bool border, int tex) +{ + glDepthMask(GL_FALSE); + glDisable(GL_TEXTURE_2D); + if(tex>=0) + { + glBindTexture(GL_TEXTURE_2D, tex); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glColor3d(1.0, 1.0, 1.0); + + int texw = 512; + int texh = texw; + int cols = (int)((x2-x1)/texw+1); + int rows = (int)((y2-y1)/texh+1); + xtraverts += cols*rows*4; + + loopj(rows) + { + float ytexcut = 0.0f; + float yboxcut = 0.0f; + if((j+1)*texh>y2-y1) // cut last row to match the box height + { + yboxcut = (float)(((j+1)*texh)-(y2-y1)); + ytexcut = (float)(((j+1)*texh)-(y2-y1))/texh; + } + + loopi(cols) + { + float xtexcut = 0.0f; + float xboxcut = 0.0f; + if((i+1)*texw>x2-x1) + { + xboxcut = (float)(((i+1)*texw)-(x2-x1)); + xtexcut = (float)(((i+1)*texw)-(x2-x1))/texw; + } + + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex2f((float)x1+texw*i, (float)y1+texh*j); + glTexCoord2f(1-xtexcut, 0); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*j); + glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*(j+1)-yboxcut); + glTexCoord2f(0, 1-ytexcut); glVertex2f((float)x1+texw*i, y1+texh*(j+1)-yboxcut); + glEnd(); + } + } + } + else + { + if(border) glColor3d(0.7, 0.7, 0.7); //glColor3d(0.5, 0.3, 0.4); + else glColor3d(1.0, 1.0, 1.0); + glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(x1, y1); + glTexCoord2f(1, 0); glVertex2i(x2, y1); + glTexCoord2f(1, 1); glVertex2i(x2, y2); + glTexCoord2f(0, 1); glVertex2i(x1, y2); + glEnd(); + xtraverts += 4; + }; + + glDisable(GL_BLEND); + if(tex>=0) glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glBegin(GL_POLYGON); + glColor3d(0.6, 0.6, 0.6); //glColor3d(0.2, 0.7, 0.4); + glVertex2i(x1, y1); + glVertex2i(x2, y1); + glVertex2i(x2, y2); + glVertex2i(x1, y2); + glEnd(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glDepthMask(GL_TRUE); +}; + +const int MAXSPHERES = 50; +struct sphere { vec o; float size, max; int type; sphere *next; }; +sphere spheres[MAXSPHERES], *slist = NULL, *sempty = NULL; +bool sinit = false; + +void newsphere(vec &o, float max, int type) +{ + if(!sinit) + { + loopi(MAXSPHERES) + { + spheres[i].next = sempty; + sempty = &spheres[i]; + }; + sinit = true; + }; + if(sempty) + { + sphere *p = sempty; + sempty = p->next; + p->o = o; + p->max = max; + p->size = 1; + p->type = type; + p->next = slist; + slist = p; + }; +}; + +void renderspheres(int time) +{ + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBindTexture(GL_TEXTURE_2D, 4); + + for(sphere *p, **pp = &slist; p = *pp;) + { + glPushMatrix(); + float size = p->size/p->max; + glColor4f(1.0f, 1.0f, 1.0f, 1.0f-size); + glTranslatef(p->o.x, p->o.z, p->o.y); + glRotatef(lastmillis/5.0f, 1, 1, 1); + glScalef(p->size, p->size, p->size); + glCallList(1); + glScalef(0.8f, 0.8f, 0.8f); + glCallList(1); + glPopMatrix(); + xtraverts += 12*6*2; + + if(p->size>p->max) + { + *pp = p->next; + p->next = sempty; + sempty = p; + } + else + { + p->size += time/100.0f; + pp = &p->next; + }; + }; + + glDisable(GL_BLEND); + glDepthMask(GL_TRUE); +}; + +string closeent; +char *entnames[] = +{ + "none?", "light", "playerstart", + "clips", "ammobox","grenades", + "health", "armour", "akimbo", + "mapmodel", "trigger", + "ladder", "ctf-flag", "?", "?", "?", +}; + +void renderents() // show sparkly thingies for map entities in edit mode +{ + closeent[0] = 0; + if(!editmode) return; + loopv(ents) + { + entity &e = ents[i]; + if(e.type==NOTUSED) continue; + vec v = { e.x, e.y, e.z }; + particle_splash(2, 2, 40, v); + }; + int e = closestent(); + if(e>=0) + { + entity &c = ents[e]; + s_sprintf(closeent)("closest entity = %s (%d, %d, %d, %d), selection = (%d, %d)", entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4, getvar("selxs"), getvar("selys")); + }; +}; + +void loadsky(char *basename) +{ + static string lastsky = ""; + if(strcmp(lastsky, basename)==0) return; + char *side[] = { "ft", "bk", "lf", "rt", "dn", "up" }; + int texnum = 14; + loopi(6) + { + s_sprintfd(name)("packages/%s_%s.jpg", basename, side[i]); + int xs, ys; + if(!installtex(texnum+i, path(name), xs, ys, true)) conoutf("could not load sky textures"); + }; + s_strcpy(lastsky, basename); +}; + +COMMAND(loadsky, ARG_1STR); + +float cursordepth = 0.9f; +GLint viewport[4]; +GLdouble mm[16], pm[16]; +vec worldpos; + +void readmatrices() +{ + glGetIntegerv(GL_VIEWPORT, viewport); + glGetDoublev(GL_MODELVIEW_MATRIX, mm); + glGetDoublev(GL_PROJECTION_MATRIX, pm); +}; + +// stupid function to cater for stupid ATI linux drivers that return incorrect depth values + +float depthcorrect(float d) +{ + return (d<=1/256.0f) ? d*256 : d; +}; + +// find out the 3d target of the crosshair in the world easily and very acurately. +// sadly many very old cards and drivers appear to fuck up on glReadPixels() and give false +// coordinates, making shooting and such impossible. +// also hits map entities which is unwanted. +// could be replaced by a more acurate version of monster.cpp los() if needed + +void readdepth(int w, int h) +{ + glReadPixels(w/2, h/2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &cursordepth); + double worldx = 0, worldy = 0, worldz = 0; + gluUnProject(w/2, h/2, depthcorrect(cursordepth), mm, pm, viewport, &worldx, &worldz, &worldy); + worldpos.x = (float)worldx; + worldpos.y = (float)worldy; + worldpos.z = (float)worldz; + vec r = { (float)mm[0], (float)mm[4], (float)mm[8] }; + vec u = { (float)mm[1], (float)mm[5], (float)mm[9] }; + setorient(r, u); +}; + +void drawicon(float tx, float ty, int x, int y, int tex = 5, float scaling = 1/3.0f) // EDIT: AH +{ + glBindTexture(GL_TEXTURE_2D, tex); + glBegin(GL_QUADS); + tx /= 192; + ty /= 192; + float o = scaling; + int s = 120; + glTexCoord2f(tx, ty); glVertex2i(x, y); + glTexCoord2f(tx+o, ty); glVertex2i(x+s, y); + glTexCoord2f(tx+o, ty+o); glVertex2i(x+s, y+s); + glTexCoord2f(tx, ty+o); glVertex2i(x, y+s); + glEnd(); + xtraverts += 4; +}; + +void invertperspective() +{ + // This only generates a valid inverse matrix for matrices generated by gluPerspective() + GLdouble inv[16]; + memset(inv, 0, sizeof(inv)); + + inv[0*4+0] = 1.0/pm[0*4+0]; + inv[1*4+1] = 1.0/pm[1*4+1]; + inv[2*4+3] = 1.0/pm[3*4+2]; + inv[3*4+2] = -1.0; + inv[3*4+3] = pm[2*4+2]/pm[3*4+2]; + + glLoadMatrixd(inv); +}; + +VAR(crosshairsize, 0, 15, 50); + +int dblend = 0; +void damageblend(int n) { dblend += n; }; + +VAR(hidestats, 0, 0, 1); +VAR(crosshairfx, 0, 1, 1); + +/*VAR(scopefov, 5, 50, 50); +bool scoped = false; +int oldfov = 100; + +void togglescope(bool deactivate) +{ + if(player1->gunselect==GUN_SNIPER) + { + if(!scoped) oldfov = getvar("fov"); + scoped = !scoped; + setvar("fov", scoped ? scopefov : oldfov); + } +}*/ + +void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) +{ + readmatrices(); + if(editmode) + { + if(cursordepth==1.0f) worldpos = player1->o; + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + cursorupdate(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + }; + + glDisable(GL_DEPTH_TEST); + invertperspective(); + glPushMatrix(); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + glEnable(GL_BLEND); + + if(dblend || underwater) + { + glDepthMask(GL_FALSE); + glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + glBegin(GL_QUADS); + if(dblend) glColor3d(0.0f, 0.9f, 0.9f); + else glColor3d(0.9f, 0.5f, 0.0f); + glVertex2i(0, 0); + glVertex2i(VIRTW, 0); + glVertex2i(VIRTW, VIRTH); + glVertex2i(0, VIRTH); + glEnd(); + glDepthMask(GL_TRUE); + dblend -= min(1, curtime/3); + if(dblend<0) dblend = 0; + }; + + glEnable(GL_TEXTURE_2D); + + char *command = getcurcommand(); + dynent *player = playerincrosshair(); + dynent *bot = botincrosshair(); + if(command) draw_textf("> %s_", 20, 1570, command); + else if(closeent[0]) draw_text(closeent, 20, 1570); + else if(player || (bot && (player=bot))) draw_text(player->name, 20, 1570); + + renderscores(); + if(!rendermenu()) + { + if(scoped && player1->gunselect == GUN_SNIPER) + { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.9f); + glBindTexture(GL_TEXTURE_2D, 10); + glBegin(GL_QUADS); + glColor3ub(255,255,255); + + glTexCoord2d(0.0, 0.0); glVertex2f(0, 0); + glTexCoord2d(1.0, 0.0); glVertex2f(VIRTW, 0); + glTexCoord2d(1.0, 1.0); glVertex2f(VIRTW, VIRTH); + glTexCoord2d(0.0, 1.0); glVertex2f(0, VIRTH); + + glEnd(); + glDisable(GL_ALPHA_TEST); + } + else if(player1->gunselect != GUN_SNIPER && !player1->reloading && !player1->state==CS_DEAD) + { + glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); + bool teammate_in_xhair = player ? (isteam(player->team, player1->team) && player->state!=CS_DEAD) : false; + glBindTexture(GL_TEXTURE_2D, teammate_in_xhair ? 9 : 1); + glBegin(GL_QUADS); + glColor3ub(255,255,255); + if(crosshairfx) + { + if(player1->gunwait && !teammate_in_xhair) glColor3ub(128,128,128); + else if(player1->health<=25 || teammate_in_xhair) glColor3ub(255,0,0); + else if(player1->health<=50) glColor3ub(255,128,0); + }; + float chsize = (float)crosshairsize * (player1->gunselect==GUN_ASSAULT && player1->shots > 3 ? 1.4f : 1.0f) * (teammate_in_xhair ? 2.0f : 1.0f); + glTexCoord2d(0.0, 0.0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); + glTexCoord2d(1.0, 0.0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); + glTexCoord2d(1.0, 1.0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 + chsize); + glTexCoord2d(0.0, 1.0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 + chsize); + glEnd(); + } + }; + + glPopMatrix(); + + glPushMatrix(); + glOrtho(0, VIRTW*4/3, VIRTH*4/3, 0, -1, 1); + renderconsole(); + + if(!hidestats) + { + glPopMatrix(); + glPushMatrix(); + glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); + draw_textf("fps %d", 3200, 2320, curfps); + draw_textf("lod %d", 3200, 2390, lod_factor()); + draw_textf("wqd %d", 3200, 2460, nquads); + draw_textf("wvt %d", 3200, 2530, curvert); + draw_textf("evt %d", 3200, 2600, xtraverts); + }; + + glPopMatrix(); + + if(player1->state==CS_ALIVE) + { + glPushMatrix(); + glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); + draw_textf("%d", 90, 827, player1->health); + if(player1->armour) draw_textf("%d", 390, 827, player1->armour); + //draw_textf("%d", 690, 827, player1->mag[player1->gunselect]); + if (player1->gunselect!=GUN_KNIFE) + { + //draw_textf("%d", 690, 827, player1->mag[player1->gunselect]); + char gunstats [64]; + if (player1->gunselect!=GUN_GRENADE) + sprintf(gunstats,"%i/%i",player1->mag[player1->gunselect],player1->ammo[player1->gunselect]); + else sprintf(gunstats,"%i",player1->mag[player1->gunselect]); + draw_text(gunstats, 690, 827); + //clean up pointer? + //delete gunstats; + } + + glPopMatrix(); + + // EDIT: AH - ctf + #define ctf_scl 0.75 + if(m_ctf) + { + glPushMatrix(); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + if(flaginfos[TEAM_CLA].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); + drawicon(64*ctf_scl, 0, 1940, 1650, 11, 1.0f/4.0f); + if(flaginfos[TEAM_RVSF].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); + drawicon(0, 0, 1820, 1650, 11, 1.0f/4.0f); + glDisable(GL_BLEND); + drawicon((float)(rb_team_int(player1->team)*64*ctf_scl), (float)(64*ctf_scl), VIRTW-128-10, 10, 11, 1.0/4.0); // shows which team you are + glPopMatrix(); + + // big flag icon + flaginfo &f = flaginfos[rb_opposite(rb_team_int(player1->team))]; + if(f.state==CTFF_STOLEN && f.thief == player1 && f.pick_ack ) + { + glPushMatrix(); + glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glColor4f(1.0f, 1.0f, 1.0f, (float)(sin(lastmillis / 100.0) + 1) / 2); + glEnable(GL_BLEND); + drawicon((float)(rb_opposite(rb_team_int(player1->team))*128*ctf_scl),(float)(128*ctf_scl), 1065, VIRTH/2/3*2, 11, 1.0/2.0); + glPopMatrix(); + }; + }; + + glPushMatrix(); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + glDisable(GL_BLEND); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(1.0f, 1.0f, 1.0f, (float) 0.2f+(sin(lastmillis/100)+1)/2); + + if(player1->health <= 20) + { + glEnable(GL_BLEND); + drawicon(64, 0, 20, 1650); //drawicon(128, 128, 20, 1650); + glDisable(GL_BLEND); + } + else drawicon(64, 0, 20, 1650); //drawicon(128, 128, 20, 1650); + if(player1->armour) drawicon((float)(128), 0, 620, 1650); //if(player1->armour) drawicon((float)(player1->armourtype*64), 0, 620, 1650); + int g = player1->gunselect; + int r = 64; + if(g>2) { g -= 3; r = 128; }; + + if(!player1->mag[player1->gunselect] && player1->gunselect != GUN_KNIFE && player1->gunselect != GUN_GRENADE) + { + glEnable(GL_BLEND); + drawicon((float)(g*64), (float)r, 1220, 1650); + glDisable(GL_BLEND); + } + else + { + if (player1->gunselect==GUN_GRENADE) drawicon(0, 0, 1220, 1650); + else drawicon((float)(g*64), (float)r, 1220, 1650); + } + glPopMatrix(); + }; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); +}; + +#define MAXSHOTLINES 100 +struct shotline +{ + vec from, to; + bool inuse; + int millis; +}; +shotline shotlines[MAXSHOTLINES]; + +void shotlinereset() { loopi(MAXSHOTLINES) shotlines[i].inuse = false; }; + +void addshotline(dynent *d, vec &from, vec &to) +{ + if(d == player1) return; + if(rnd(3) != 0) return; + loopi(MAXSHOTLINES) + { + shotline *s = &shotlines[i]; + if(s->inuse) continue; + int start = 10; + vdist(_dist, _unitv, player1->o, to); + if(_dist <= 10.0f) start = 8; + else start = 5; + + vdist(dist, unitv, from, to); + vdiv(unitv, dist); + s->inuse = true; + s->from = unitv; + vmul(s->from, dist/10*start); + vadd(s->from, from); + s->to = unitv; + vmul(s->to, dist/10*-(10-start-2)); + vadd(s->to, to); + s->millis = lastmillis; + return; + }; +}; + +VAR(shotline_duration, 0, 75, 10000); + +void rendershotlines() +{ + loopi(MAXSHOTLINES) + { + shotline *s = &shotlines[i]; + if(!s->inuse) continue; + if(lastmillis-s->millis > shotline_duration) { s->inuse = false; continue; } + glPushMatrix(); + glDisable(GL_TEXTURE_2D); + + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); + glDisable(GL_FOG); + + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glBegin(GL_LINES); + glColor4f(1.0f, 1.0f, 0.7f, 0.5f); + glVertex3f(s->from.x, s->from.z, s->from.y); + glVertex3f(s->to.x, s->to.z, s->to.y); + glEnd(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glEnable(GL_FOG); + glDisable(GL_BLEND); + glDepthMask(GL_TRUE); + + glEnable(GL_TEXTURE_2D); + glPopMatrix(); + }; +}; + +void renderphysents() +{ + loopv(physents) + { + physent *p = physents[i]; + if(!p) continue; + string model; + float z = p->o.z; + + switch(p->state) + { + case NADE_THROWED: + s_strcpy(model, "weapons/grenade/static"); + break; + case GIB: + default: + { + uint n = (((4*(uint)p)+(uint)p->timetolife)%3)+1; + s_sprintf(model)("misc/gib0%u", n); + int t = lastmillis-p->millis; + if(t>p->timetolife-2000) + { + t -= p->timetolife-2000; + z -= t*t/4000000000.0f*t; + } + break; + }; + }; + path(model); + rendermodel(model, 0, 1, 0, 0, p->o.x, z, p->o.y, p->yaw, p->pitch, false, 2.0f, 100.0f, 0, 0); + }; +}; + +VAR(gibnum, 0, 6, 1000); +VAR(gibttl, 0, 5000, 15000); +VAR(gibspeed, 1, 5, 20); + +void addgib(dynent *d) +{ + if(!d) return; + playsound(S_GIB, &d->o); + + loopi(gibnum) + { + physent *p = new_physent(); + p->owner = d; + p->millis = lastmillis; + p->timetolife = gibttl+rnd(10)*100; + + p->state = GIB; + + p->isphysent = true; + p->gravity = 20; + p->timeinair = 0; + p->onfloor = false; + + p->o = d->o; + p->o.z -= d->aboveeye; + + float gibvelangle = (float) rnd(360); + float speed = (float) gibspeed; + p->vel.x = sin(gibvelangle)*speed*rnd(1000)/1000.0f; + p->vel.y = cos(gibvelangle)*speed*rnd(1000)/1000.0f; + p->vel.z = speed*rnd(1000)/1000.0f; + vdiv(p->vel, 10.0f); + + p->yaw = (float)rnd(360); + p->pitch = (float)rnd(360); + p->rotspeed = 3.0f; + } +}; + +void loadingscreen() +{ + glPushMatrix(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + + glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + glColor3f(1, 1, 1); + glBindTexture(GL_TEXTURE_2D, 8); + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); glVertex2i(0, 0); + glTexCoord2f(1, 0); glVertex2i(VIRTW, 0); + glTexCoord2f(1, 1); glVertex2i(VIRTW, VIRTH); + glTexCoord2f(0, 1); glVertex2i(0, VIRTH); + + glEnd(); + + SDL_GL_SwapBuffers(); + + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + glPopMatrix(); +} diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp new file mode 100644 index 00000000..40cc9984 --- /dev/null +++ b/source/src/rendergl.cpp @@ -0,0 +1,420 @@ +// rendergl.cpp: core opengl rendering stuff + +#include "cube.h" + +#ifdef DARWIN +#define GL_COMBINE_EXT GL_COMBINE_ARB +#define GL_COMBINE_RGB_EXT GL_COMBINE_RGB_ARB +#define GL_SOURCE0_RBG_EXT GL_SOURCE0_RGB_ARB +#define GL_SOURCE1_RBG_EXT GL_SOURCE1_RGB_ARB +#define GL_RGB_SCALE_EXT GL_RGB_SCALE_ARB +#endif + +bool hasoverbright = false; + +void purgetextures(); + +GLUquadricObj *qsphere = NULL; +int glmaxtexsize = 256; + +void gl_init(int w, int h) +{ + //#define fogvalues 0.5f, 0.6f, 0.7f, 1.0f + + glViewport(0, 0, w, h); + glClearDepth(1.0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_SMOOTH); + + + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_DENSITY, 0.25); + glHint(GL_FOG_HINT, GL_NICEST); + + + glEnable(GL_LINE_SMOOTH); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glEnable(GL_POLYGON_OFFSET_LINE); + glPolygonOffset(-3.0, -3.0); + + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + + char *exts = (char *)glGetString(GL_EXTENSIONS); + + if(strstr(exts, "GL_EXT_texture_env_combine")) hasoverbright = true; + else conoutf("WARNING: cannot use overbright lighting, using old lighting model!"); + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); + + purgetextures(); + + if(!(qsphere = gluNewQuadric())) fatal("glu sphere"); + gluQuadricDrawStyle(qsphere, GLU_FILL); + gluQuadricOrientation(qsphere, GLU_INSIDE); + gluQuadricTexture(qsphere, GL_TRUE); + glNewList(1, GL_COMPILE); + gluSphere(qsphere, 1, 12, 6); + glEndList(); +}; + +void cleangl() +{ + if(qsphere) gluDeleteQuadric(qsphere); +}; + +bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool highqual) +{ + SDL_Surface *s = IMG_Load(texname); + if(!s) { conoutf("couldn't load texture %s", texname); return false; }; + if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32) { conoutf("texture must be 24bpp or 32bpp: %s", texname); return false; }; + // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; }; + glBindTexture(GL_TEXTURE_2D, tnum); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, highqual ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); //NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + xs = s->w; + ys = s->h; + while(xs>glmaxtexsize || ys>glmaxtexsize) { xs /= 2; ys /= 2; }; + uchar *scaledimg = (uchar *)s->pixels; + if(xs!=s->w) + { + conoutf("warning: quality loss: scaling %s", texname); // for voodoo cards under linux + scaledimg = new uchar[xs*ys*3]; + gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, xs, ys, GL_UNSIGNED_BYTE, scaledimg); + }; + int mode = s->format->BitsPerPixel==24 ? GL_RGB : GL_RGBA; + if(gluBuild2DMipmaps(GL_TEXTURE_2D, mode, xs, ys, mode, GL_UNSIGNED_BYTE, scaledimg)) fatal("could not build mipmaps"); + if(xs!=s->w) delete[] scaledimg; + SDL_FreeSurface(s); + return true; +}; + +// management of texture slots +// each texture slot can have multople texture frames, of which currently only the first is used +// additional frames can be used for various shaders + +const int MAXTEX = 1000; +int texx[MAXTEX]; // ( loaded texture ) -> ( name, size ) +int texy[MAXTEX]; +string texname[MAXTEX]; +int curtex = 0; +const int FIRSTTEX = 160; // opengl id = loaded id + FIRSTTEX +// std 1+, sky 14+, md3's 30+,md2's 40+ + +const int MAXFRAMES = 2; // increase to allow more complex shader defs +int mapping[256][MAXFRAMES]; // ( cube texture, frame ) -> ( opengl id, name ) +string mapname[256][MAXFRAMES]; + +void purgetextures() +{ + loopi(256) loop(j,MAXFRAMES) mapping[i][j] = 0; +}; + +int curtexnum = 0; + +void texturereset() { curtexnum = 0; }; + +void texture(char *aframe, char *name) +{ + int num = curtexnum++, frame = atoi(aframe); + if(num<0 || num>=256 || frame<0 || frame>=MAXFRAMES) return; + mapping[num][frame] = 1; + char *n = mapname[num][frame]; + s_strcpy(n, name); + path(n); +}; + +COMMAND(texturereset, ARG_NONE); +COMMAND(texture, ARG_2STR); + +int lookuptexture(int tex, int &xs, int &ys) +{ + int frame = 0; // other frames? + int tid = mapping[tex][frame]; + + if(tid>=FIRSTTEX) + { + xs = texx[tid-FIRSTTEX]; + ys = texy[tid-FIRSTTEX]; + return tid; + }; + + xs = ys = 16; + if(!tid) return 1; // crosshair :) + + loopi(curtex) // lazily happens once per "texture" command, basically + { + if(strcmp(mapname[tex][frame], texname[i])==0) + { + mapping[tex][frame] = tid = i+FIRSTTEX; + xs = texx[i]; + ys = texy[i]; + return tid; + }; + }; + + if(curtex==MAXTEX) fatal("loaded too many textures"); + + int tnum = curtex+FIRSTTEX; + s_strcpy(texname[curtex], mapname[tex][frame]); + + s_sprintfd(name)("packages%ctextures%c%s", PATHDIV, PATHDIV, texname[curtex]); + + if(installtex(tnum, name, xs, ys)) + { + mapping[tex][frame] = tnum; + texx[curtex] = xs; + texy[curtex] = ys; + curtex++; + return tnum; + } + else + { + return mapping[tex][frame] = FIRSTTEX; // temp fix + }; +}; + +void setupworld() +{ + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + setarraypointers(); + + if(hasoverbright) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); + }; +}; + +int skyoglid; + +struct strip { int tex, start, num; }; +vector strips; + +void renderstripssky() +{ + glBindTexture(GL_TEXTURE_2D, skyoglid); + loopv(strips) if(strips[i].tex==skyoglid) glDrawArrays(GL_TRIANGLE_STRIP, strips[i].start, strips[i].num); +}; + +void renderstrips() +{ + int lasttex = -1; + loopv(strips) if(strips[i].tex!=skyoglid) + { + if(strips[i].tex!=lasttex) + { + glBindTexture(GL_TEXTURE_2D, strips[i].tex); + lasttex = strips[i].tex; + }; + glDrawArrays(GL_TRIANGLE_STRIP, strips[i].start, strips[i].num); + }; +}; + +void overbright(float amount) { if(hasoverbright) glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, amount ); }; + +void addstrip(int tex, int start, int n) +{ + strip &s = strips.add(); + s.tex = tex; + s.start = start; + s.num = n; +}; + +VARF(gamma, 30, 100, 300, +{ + float f = gamma/100.0f; + if(SDL_SetGamma(f,f,f)==-1) + { + conoutf("Could not set gamma (card/driver doesn't support it?)"); + conoutf("sdl: %s", SDL_GetError()); + }; +}); + +void trypitch(int i) { player1->pitch = (float)i; } +COMMAND(trypitch, ARG_1INT); + +void transplayer() +{ + glLoadIdentity(); + + if(player1->state==CS_DEAD) + { + float t = (lastmillis-player1->lastaction)/1000.0f; + if(t >= 1.6f) t = 1.6f; + + player1->pitch = (float) sin(t)*(-70.0f-player1->oldpitch)+player1->oldpitch; + glRotated(player1->pitch,-1.0,0.0,0.0); + glRotated(player1->yaw,0.0,1.0,0.0); + + glTranslated(-player1->o.x, player1->eyeheight-sin(t)*7.0f-player1->o.z, -player1->o.y); + //glTranslated(-player1->o.x, -player1->o.z, -player1->o.y); + } + else + { + glRotated(player1->roll,0.0,0.0,1.0); + glRotated(player1->pitch,-1.0,0.0,0.0); + glRotated(player1->yaw,0.0,1.0,0.0); + + glTranslated(-player1->o.x, -player1->o.z, -player1->o.y); + }; +}; + +VAR(fov, 90, 105, 120); + +int xtraverts; + +VAR(fog, 64, 180, 1024); +VAR(fogcolour, 0, 0x8099B3, 0xFFFFFF); + +VAR(hudgun,0,1,1); + +char *hudgunnames[] = { "knife", "pistol", "shotgun", "subgun", "sniper", "assault", "grenade"}; + +void drawhudmodel(int start, int end, float speed, int base) +{ + s_sprintfd(mdl)("hudguns/%s", hudgunnames[player1->gunselect]); + rendermodel(mdl, start, end, 0, 1.0f, player1->o.x, player1->o.z, player1->o.y, player1->yaw+90, player1->pitch, false, 1.0f, speed, 0, base); +}; + + +void drawhudgun(int w, int h, float aspect, int farplane) +{ + if(scoped && player1->gunselect==GUN_SNIPER) return; + + glEnable(GL_CULL_FACE); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective((float)100.0f*h/w, aspect, 0.3f, farplane); // fov fixed at 100° + glMatrixMode(GL_MODELVIEW); + + if(hudgun && player1->state!=CS_DEAD)rendermd3gun(); + rendermenumdl(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective((float)fov*h/w, aspect, 0.15f, farplane); + glMatrixMode(GL_MODELVIEW); + + glDisable(GL_CULL_FACE); +}; + +void gl_drawframe(int w, int h, float changelod, float curfps) +{ + float hf = hdr.waterlevel-0.3f; + float fovy = (float)fov*h/w; + float aspect = w/(float)h; + bool underwater = player1->o.z>16)/256.0f, ((fogcolour>>8)&255)/256.0f, (fogcolour&255)/256.0f, 1.0f }; + glFogfv(GL_FOG_COLOR, fogc); + glClearColor(fogc[0], fogc[1], fogc[2], 1.0f); + + if(underwater) + { + fovy += (float)sin(lastmillis/1000.0)*2.0f; + aspect += (float)sin(lastmillis/1000.0+PI)*0.1f; + glFogi(GL_FOG_START, 0); + glFogi(GL_FOG_END, (fog+96)/8); + }; + + glClear((player1->outsidemap ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + int farplane = fog*5/2; + gluPerspective(fovy, aspect, 0.15f, farplane); + glMatrixMode(GL_MODELVIEW); + + transplayer(); + + glEnable(GL_TEXTURE_2D); + + int xs, ys; + skyoglid = lookuptexture(DEFAULT_SKY, xs, ys); + + resetcubes(); + + extern vector verts; + verts.setsizenodelete(0); + strips.setsizenodelete(0); + + render_world(player1->o.x, player1->o.y, player1->o.z, changelod, + (int)player1->yaw, (int)player1->pitch, (float)fov, w, h); + finishstrips(); + + setupworld(); + + renderstripssky(); + + glLoadIdentity(); + glRotated(player1->pitch, -1.0, 0.0, 0.0); + glRotated(player1->yaw, 0.0, 1.0, 0.0); + glRotated(90.0, 1.0, 0.0, 0.0); + glColor3f(1.0f, 1.0f, 1.0f); + glDisable(GL_FOG); + glDepthFunc(GL_GREATER); + draw_envbox(14, fog*4/3); + glDepthFunc(GL_LESS); + glEnable(GL_FOG); + + transplayer(); + + overbright(2); + + renderstrips(); + + xtraverts = 0; + + renderclients(); + //monsterrender(); + BotManager.RenderBots(); // Added by Rick + + renderentities(); + + renderspheres(curtime); + renderents(); + + renderphysents(); + + rendershotlines(); + + glDisable(GL_CULL_FACE); + + // Added by Rick: Need todo here because of drawing the waypoints + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + WaypointClass.Think(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + // end add + + drawhudgun(w, h, aspect, farplane); + + overbright(1); + int nquads = renderwater(hf); + + overbright(2); + render_particles(curtime); + overbright(1); + + glDisable(GL_FOG); + + glDisable(GL_TEXTURE_2D); + + gl_drawhud(w, h, (int)curfps, nquads, verts.length(), underwater); + + glEnable(GL_CULL_FACE); + glEnable(GL_FOG); +}; diff --git a/source/src/rendermd2.cpp b/source/src/rendermd2.cpp new file mode 100644 index 00000000..196e3741 --- /dev/null +++ b/source/src/rendermd2.cpp @@ -0,0 +1,368 @@ +// rendermd2.cpp: loader code adapted from a nehe tutorial + +#include "cube.h" + +VARP(animationinterpolationtime, 0, 150, 1000); + +struct md2_anpos +{ + int fr1, fr2; + float frac1, frac2; + + void setframes(md2state &a) + { + int time = lastmillis-a.basetime; + fr1 = (int)(time/a.speed); + frac1 = (time-fr1*a.speed)/a.speed; + frac2 = 1-frac1; + //if(a.anim&ANIM_LOOP) // FIXME + { + fr1 = fr1%a.range+a.frame; + fr2 = fr1+1; + if(fr2>=a.frame+a.range) fr2 = a.frame; + } +/* else + { + fr1 = min(fr1, a.range-1)+a.frame; + fr2 = min(fr1+1, a.frame+a.range-1); + }; + if(a.anim&ANIM_REVERSE) + { + fr1 = (a.frame+a.range-1)-(fr1-a.frame); + fr2 = (a.frame+a.range-1)-(fr2-a.frame); + };*/ + }; +}; + +struct md2_header +{ + int magic; + int version; + int skinWidth, skinHeight; + int frameSize; + int numSkins, numVertices, numTexcoords; + int numTriangles, numGlCommands, numFrames; + int offsetSkins, offsetTexcoords, offsetTriangles; + int offsetFrames, offsetGlCommands, offsetEnd; +}; + +struct md2_vertex +{ + uchar vertex[3], lightNormalIndex; +}; + +struct md2_frame +{ + float scale[3]; + float translate[3]; + char name[16]; + md2_vertex vertices[1]; +}; + +struct md2 +{ + int numGlCommands; + int* glCommands; + int numTriangles; + int frameSize; + int numFrames; + int numVerts; + char* frames; + vec **mverts; + int displaylist; + int displaylistverts; + + mapmodelinfo mmi; + char *loadname; + int mdlnum; + bool loaded; + + bool load(char* filename); + void render(vec &light, int numFrame, int range, float x, float y, float z, float yaw, float pitch, float scale, float speed, int snap, int basetime, dynent *d=NULL); + void scale(int frame, float scale, int sn); + + md2() : numGlCommands(0), frameSize(0), numFrames(0), displaylist(0), loaded(false) {}; + + ~md2() + { + if(glCommands) + delete [] glCommands; + if(frames) + delete [] frames; + } +}; + + +bool md2::load(char* filename) +{ + FILE* file; + md2_header header; + + if((file= fopen(filename, "rb"))==NULL) return false; + + fread(&header, sizeof(md2_header), 1, file); + endianswap(&header, sizeof(int), sizeof(md2_header)/sizeof(int)); + + if(header.magic!= 844121161 || header.version!=8) return false; + + frames = new char[header.frameSize*header.numFrames]; + if(frames==NULL) return false; + + fseek(file, header.offsetFrames, SEEK_SET); + fread(frames, header.frameSize*header.numFrames, 1, file); + + for(int i = 0; i < header.numFrames; ++i) + { + endianswap(frames + i * header.frameSize, sizeof(float), 6); + } + + glCommands = new int[header.numGlCommands]; + if(glCommands==NULL) return false; + + fseek(file, header.offsetGlCommands, SEEK_SET); + fread(glCommands, header.numGlCommands*sizeof(int), 1, file); + + endianswap(glCommands, sizeof(int), header.numGlCommands); + + numFrames = header.numFrames; + numGlCommands= header.numGlCommands; + frameSize = header.frameSize; + numTriangles = header.numTriangles; + numVerts = header.numVertices; + + fclose(file); + + mverts = new vec*[numFrames]; + loopj(numFrames) mverts[j] = NULL; + + return true; +}; + +float snap(int sn, float f) { return sn ? (float)(((int)(f+sn*0.5f))&(~(sn-1))) : f; }; + +void md2::scale(int frame, float scale, int sn) +{ + mverts[frame] = new vec[numVerts]; + md2_frame *cf = (md2_frame *) ((char*)frames+frameSize*frame); + float sc = 16.0f/scale; + loop(vi, numVerts) + { + uchar *cv = (uchar *)&cf->vertices[vi].vertex; + vec *v = &(mverts[frame])[vi]; + v->x = (snap(sn, cv[0]*cf->scale[0])+cf->translate[0])/sc; + v->y = -(snap(sn, cv[1]*cf->scale[1])+cf->translate[1])/sc; + v->z = (snap(sn, cv[2]*cf->scale[2])+cf->translate[2])/sc; + }; +}; + +void md2::render(vec &light, int frame, int range, float x, float y, float z, float yaw, float pitch, float sc, float speed, int snap, int basetime, dynent *d) +{ + if(range==0 || frame+range-1>numFrames) + { + printf("warning: model %s, invalid frame (%i) or range (%i)", loadname, frame, range); + return; + } + + md2state ai; + ai.frame = frame; + ai.basetime = basetime; + ai.range = range; + ai.speed = speed; + + loopi(ai.range) if(!mverts[ai.frame+i]) scale(ai.frame+i, sc, snap); + + if(d) + { + if(d->lastanimswitchtime==-1) { d->current = ai; d->lastanimswitchtime = lastmillis-animationinterpolationtime*2; } + else if(d->current != ai) + { + if(lastmillis-d->lastanimswitchtime>animationinterpolationtime/2) d->prev = d->current; + d->current = ai; + d->lastanimswitchtime = lastmillis; + }; + }; + + glPushMatrix (); + glTranslatef(x, y, z); + glRotatef(yaw+180, 0, -1, 0); + glRotatef(pitch, 0, 0, 1); + + glColor3fv((float *)&light); + + if(displaylist && ai.frame==0 && ai.range==1) + { + glCallList(displaylist); + xtraverts += displaylistverts; + } + else + { + if(ai.frame==0 && ai.range==1) + { + static int displaylistn = 10; + glNewList(displaylist = displaylistn++, GL_COMPILE); + displaylistverts = xtraverts; + }; + + md2_anpos prev, current; + current.setframes(d ? d->current : ai); +#ifdef _DEBUG + prev.setframes(ai); +#endif + vec *verts1 = mverts[current.fr1], *verts2 = mverts[current.fr2], *verts1p, *verts2p; + float aifrac1, aifrac2; + bool doai = d && lastmillis-d->lastanimswitchtimeprev); + verts1p = mverts[prev.fr1]; + verts2p = mverts[prev.fr2]; + aifrac1 = (lastmillis-d->lastanimswitchtime)/(float)animationinterpolationtime; + aifrac2 = 1-aifrac1; + if(!verts1p || !verts2p) return; //fixme + }; + + for(int *command = glCommands; (*command)!=0;) + { + int numVertex = *command++; + if(numVertex>0) { glBegin(GL_TRIANGLE_STRIP); } + else { glBegin(GL_TRIANGLE_FAN); numVertex = -numVertex; }; + + loopi(numVertex) + { + float tu = *((float*)command++); + float tv = *((float*)command++); + glTexCoord2f(tu, tv); + int vn = *command++; + vec &v1 = verts1[vn]; + vec &v2 = verts2[vn]; + #define ip(v1, v2, c) (v1.c*current.frac2+v2.c*current.frac1) + #define ipv(v1, v2, c) (v1 ## p.c*prev.frac2+v2 ## p.c*prev.frac1) + #define ipa(v1, v2, c) (ip(v1, v2, c)*aifrac1+ipv(v1, v2, c)*aifrac2) + if(doai) + { + vec &v1p = verts1p[vn], &v2p = verts2p[vn]; + glVertex3f(ipa(v1, v2, x), ipa(v1, v2, z), ipa(v1, v2, y)); + } + else glVertex3f(ip(v1, v2, x), ip(v1, v2, z), ip(v1, v2, y)); + }; + + xtraverts += numVertex; + + glEnd(); + }; + + if(displaylist) + { + glEndList(); + displaylistverts = xtraverts-displaylistverts; + }; + }; + + glPopMatrix(); +} + +hashtable *mdllookup = NULL; +vector mapmodels; +const int FIRSTMDL = 40; + +void delayedload(md2 *m) +{ + if(!m->loaded) + { + s_sprintfd(name1)("packages/models/%s/tris.md2", m->loadname); + if(!m->load(path(name1))) fatal("loadmodel: ", name1); + s_sprintfd(name2)("packages/models/%s/skin.jpg", m->loadname); + int xs, ys; + installtex(FIRSTMDL+m->mdlnum, path(name2), xs, ys); + m->loaded = true; + }; +}; + +int modelnum = 0; + +md2 *loadmodel(char *name) +{ + + if(!mdllookup) mdllookup = new hashtable; + md2 **mm = mdllookup->access(name); + if(mm) return *mm; + md2 *m = new md2(); + m->mdlnum = modelnum++; + mapmodelinfo mmi = { 2, 2, 0, 0, "" }; + m->mmi = mmi; + m->loadname = newstring(name); + mdllookup->access(m->loadname, &m); + + return m; +}; + +void mapmodel(char *rad, char *h, char *zoff, char *snap, char *name) +{ + char *mpdir = "mapmodels/"; + char *lname = new char[ strlen(mpdir) + strlen(name) + 1 ]; + strcpy(lname, mpdir); + strcat(lname, name); + md2 *m = loadmodel(lname); + mapmodelinfo mmi = { atoi(rad), atoi(h), atoi(zoff), atoi(snap), m->loadname }; + m->mmi = mmi; + mapmodels.add(m); +}; + +void mapmodelreset() { mapmodels.setsize(0); }; + +mapmodelinfo &getmminfo(int i) { return immi : *(mapmodelinfo *)0; }; + +COMMAND(mapmodel, ARG_5STR); +COMMAND(mapmodelreset, ARG_NONE); + +void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap, int basetime, bool oculling, dynent *d) +{ + md2 *m = loadmodel(mdl); + + if(oculling && isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2)) return; + + delayedload(m); + + int xs, ys; + glBindTexture(GL_TEXTURE_2D, tex ? lookuptexture(tex, xs, ys) : FIRSTMDL+m->mdlnum); + + int ix = (int)x; + int iy = (int)z; + vec light = { 1.0f, 1.0f, 1.0f }; + + if(!OUTBORD(ix, iy)) + { + sqr *s = S(ix,iy); + float ll = 256.0f; // 0.96f; + float of = 0.0f; // 0.1f; + light.x = s->r/ll+of; + light.y = s->g/ll+of; + light.z = s->b/ll+of; + }; + +/* + if(teammate) + { + light.x *= 0.6f; + light.y *= 0.7f; + light.z *= 1.2f; + }; +*/ + + m->render(light, frame, range, x, y, z, yaw, pitch, scale, speed, snap, basetime, d); +}; + + +void preload_mapmodels() +{ + int xs, ys; + loopv(ents) + { + entity &e = ents[i]; + mapmodelinfo &mmi = getmminfo(e.attr2); + if(!&mmi) continue; + md2 *m = loadmodel(mmi.name); + delayedload(m); + lookuptexture(e.attr4 ? lookuptexture(e.attr4, xs, ys) : FIRSTMDL+m->mdlnum, xs, ys); + } +} diff --git a/source/src/rendermd3.cpp b/source/src/rendermd3.cpp new file mode 100644 index 00000000..dc8273bb --- /dev/null +++ b/source/src/rendermd3.cpp @@ -0,0 +1,524 @@ +// code for loading, linking and rendering md3 models +// See http://www.icculus.org/homepages/phaethon/q3a/formats/md3format.html for informations about the md3 format + +#include "cube.h" + +const int FIRSTMD3 = 20; +enum { MDL_LOWER = 0, MDL_UPPER, MDL_HEAD }; + +enum { MDL_GUN_IDLE = 0, MDL_GUN_ATTACK, MDL_GUN_RELOAD, MDL_GUN_ATTACK2}; // attack2 is for grenade only + +#define MD3_DEFAULT_SCALE 0.08f + +struct vec2 +{ + float x, y; +}; + +struct md3tag +{ + char name[64]; + float pos[3]; + float rotation[3][3]; +}; + +struct md3vertex +{ + signed short vertex[3]; + uchar normal[2]; +}; + +struct md3triangle +{ + int vertexindices[3]; +}; + +struct md3animinfo +{ + int start; + int num; + bool loop; + int fps; +}; + +struct md3header +{ + char id[4]; + int version; + char name[64]; + int flags; + int numframes, numtags, nummeshes, numskins; + int ofs_frames, ofs_tags, ofs_meshes, ofs_eof; // offsets +}; + +struct md3meshheader +{ + char id[4]; + char name[64]; + int flags; + int numframes, numshaders, numvertices, numtriangles; + int ofs_triangles, ofs_shaders, ofs_uv, ofs_vertices, meshsize; // offsets +}; + +struct md3mesh +{ + char name[64]; + md3triangle *triangles; + vec *vertices; + vec2 *uv; + int numtriangles, numvertices; // numvertices == numUV + int tex; +}; + +struct md3model +{ + vector meshes; + vector animations; + md3state *animstate; + md3model **links; + md3tag *tags; + int numframes, numtags; + bool loaded; + vec scale; + bool mirrored; + void setanim(int anim); + void setanimstate(md3state &as); + bool link(md3model *link, char *tag); + bool load(char *path, bool _mirrored); + void render(); + void draw(float x, float y, float z, float yaw, float pitch, float rad, vec &light); + md3model(); + ~md3model(); +}; + +md3model::md3model() +{ + mirrored = false; + loaded = false; + scale.x = scale.y = scale.z = MD3_DEFAULT_SCALE; +// animstate = NULL; + animstate = new md3state(); + animstate->lastTime = lastmillis; +}; + +md3model::~md3model() +{ + loopv(meshes){ + if(meshes[i].vertices) delete [] meshes[i].vertices; + if(meshes[i].triangles) delete [] meshes[i].triangles; + if(meshes[i].uv) delete [] meshes[i].uv; + }; + if(links) delete[] links; + if(tags) delete [] tags; +}; + +void md3model::setanimstate(md3state &as) +{ + animstate->anim = as.anim; + animstate->frm = as.frm; + animstate->lastTime = as.lastTime; +}; + +void md3model::setanim(int anim) +{ + if(animstate->anim != anim) animstate->lastTime = lastmillis; + animstate->anim = anim; +}; + +bool md3model::link(md3model *link, char *tag) +{ + loopi(numtags) + if(strcmp(tags[i].name, tag) == 0) + { + links[i] = link; + return true; + }; + return false; +}; + +bool md3model::load(char *path, bool _mirrored=false) +{ + mirrored = _mirrored; + if(!path) return false; + FILE *f = fopen(path, "rb"); + if(!f) return false; + md3header header; + fread(&header, sizeof(md3header), 1, f); + if(header.id[0] != 'I' || header.id[1] != 'D' || header.id[2] != 'P' || header.id[3] != '3' || header.version != 15) // header check + { printf("corruped header in md3 model: %s", path); return false; }; + + tags = new md3tag[header.numframes * header.numtags]; + fseek(f, header.ofs_tags, SEEK_SET); + fread(tags, sizeof(md3tag), header.numframes * header.numtags, f); + numframes = header.numframes; + numtags = header.numtags; + + links = new md3model *[header.numtags]; + loopi(header.numtags) links[i] = NULL; + + int mesh_offset = ftell(f); + + loopi(header.nummeshes) + { + md3mesh mesh; + md3meshheader mheader; + fseek(f, mesh_offset, SEEK_SET); + fread(&mheader, sizeof(md3meshheader), 1, f); + s_strncpy(mesh.name, mheader.name, 64); + + mesh.triangles = new md3triangle[mheader.numtriangles]; + fseek(f, mesh_offset + mheader.ofs_triangles, SEEK_SET); + fread(mesh.triangles, sizeof(md3triangle), mheader.numtriangles, f); // read the triangles + mesh.numtriangles = mheader.numtriangles; + + mesh.uv = new vec2[mheader.numvertices]; + fseek(f, mesh_offset + mheader.ofs_uv , SEEK_SET); + fread(mesh.uv, sizeof(vec2), mheader.numvertices, f); // read the UV data + + md3vertex *vertices = new md3vertex[mheader.numframes * mheader.numvertices]; + fseek(f, mesh_offset + mheader.ofs_vertices, SEEK_SET); + fread(vertices, sizeof(md3vertex), mheader.numframes * mheader.numvertices, f); // read the vertices + mesh.vertices = new vec[mheader.numframes * mheader.numvertices]; // transform to our own structure + loopj(mheader.numframes * mheader.numvertices) + { + mesh.vertices[j].x = vertices[j].vertex[0] / 64.0f * (mirrored ? -1 : 1); + mesh.vertices[j].y = vertices[j].vertex[1] / 64.0f; + mesh.vertices[j].z = vertices[j].vertex[2] / 64.0f; + }; + mesh.numvertices = mheader.numvertices; + + meshes.add(mesh); + mesh_offset += mheader.meshsize; + delete [] vertices; + }; + + loaded = true; + return true; +}; + + +void md3model::render() +{ + if(!loaded || meshes.length() <= 0) return; + int nextfrm; + float t = 0.0f; + md3state *a = animstate; + + if(a && animations.length() > a->anim) + { + md3animinfo *info = &animations[a->anim]; + + int time = lastmillis - a->lastTime; + float speed = 1000.0f / (float)info->fps; + a->frm = (int) (time / speed); + + if(!info->loop && a->frm >= info->num-1) + { + a->frm = info->start + info->num-1; + nextfrm = a->frm; + } + else + { + t = (time-a->frm*speed)/speed; + a->frm = info->start+(a->frm % info->num); + nextfrm = a->frm + 1; + if(nextfrm>=info->start+info->num) nextfrm=a->frm; + }; + } + else + { + if(!a) a = new md3state(); + a->frm = 0; + nextfrm = a->frm + 1; + } + + #define interpolate(p1,p2) ((p1) + t * ((p2) - (p1))) + + loopv(meshes) + { + md3mesh *mesh = &meshes[i]; + + glBindTexture(GL_TEXTURE_2D, FIRSTMD3 + mesh->tex); + + glBegin(GL_TRIANGLES); + loopj(mesh->numtriangles) // triangles + { + loopk(3) // vertices + { + int index = mesh->triangles[j].vertexindices[k]; + vec *point1 = &mesh->vertices[index + a->frm * mesh->numvertices]; + vec *point2 = &mesh->vertices[index + nextfrm * mesh->numvertices]; + + if(mesh->uv) + glTexCoord2f(mesh->uv[index].x, mesh->uv[index].y); + + glVertex3f( interpolate(point1->x, point2->x), + interpolate(point1->y, point2->y), + interpolate(point1->z, point2->z)); + }; + }; + glEnd(); + }; + + + loopi(numtags) // render the linked models - interpolate rotation and position of the 'link-tags' + { + md3model *link = links[i]; + if(!link) continue; + GLfloat matrix[16] = {0}; // fixme: un-obfuscate it! + loopj(3) matrix[j] = interpolate(tags[a->frm * numtags + i].rotation[0][j], tags[nextfrm * numtags + i].rotation[0][j]); // rotation + loopj(3) matrix[4 + j] = interpolate(tags[a->frm * numtags + i].rotation[1][j], tags[nextfrm * numtags + i].rotation[1][j]); + loopj(3) matrix[8 + j] = interpolate(tags[a->frm * numtags + i].rotation[2][j], tags[nextfrm * numtags + i].rotation[2][j]); + loopj(3) matrix[12 + j] = interpolate(tags[a->frm * numtags + i].pos[j] , tags[nextfrm * numtags + i].pos[j]); // position + matrix[15] = 1.0f; + glPushMatrix(); + glMultMatrixf(matrix); + link->render(); + glPopMatrix(); + }; +}; + +void md3model::draw(float x, float y, float z, float yaw, float pitch, float rad, vec &light) +{ + glPushMatrix(); + glColor3fv((float *)&light); + glTranslatef(x, y, z); + + glRotatef(yaw+180, 0, -1, 0); + glRotatef(pitch, 0, 0, 1); + glRotatef(-90, 0, 1, 0); + glRotatef(-90, 1, 0, 0); + + glScalef(scale.x, scale.y, scale.z); + + if(mirrored) glCullFace(GL_BACK); + render(); + if(mirrored) glCullFace(GL_FRONT); + + glPopMatrix(); +}; + +void md3setanim(dynent *d, int anim) +{ + if(anim <= BOTH_DEAD3) // assign to both, legs and torso + { + d->animstate[MDL_LOWER].anim = anim; + d->animstate[MDL_UPPER].anim = anim; + } + else if(anim <= TORSO_STAND2) + d->animstate[MDL_UPPER].anim = anim; + else + d->animstate[MDL_LOWER].anim = anim - 7; +}; + +vector models; +vector tmp_animations; +int firstweapon = -1; +int numskins = 0; +string basedir; // necessary for relative path's + +void md3skin(char *objname, char *skin) // called by the {lower|upper|head}.cfg (originally .skin in Q3A) +{ + md3model *mdl = models.last(); + loopv(mdl->meshes) + { + md3mesh *mesh = &mdl->meshes[i]; + if(strcmp(mesh->name, objname) == 0) + { + int xs, ys; + s_sprintfd(path)("%s/%s", basedir, skin); // 'skin' is a relative url + bool highqual = strstr(basedir, "weapons") != NULL; + installtex(FIRSTMD3 + numskins, path, xs, ys, true, highqual); + mesh->tex = numskins; + numskins++; + }; + }; +}; + +COMMAND(md3skin, ARG_2STR); + +void md3animation(char *first, char *nums, char *loopings, char *fps) /* configurable animations */ +{ + md3animinfo &a = tmp_animations.add(); + a.start = atoi(first); + int n = atoi(nums); + if(n<=0) n = 1; + a.num = n; + (atoi(loopings) > 0) ? a.loop = true : a.loop = false; + a.fps = atoi(fps); +}; + +COMMAND(md3animation, ARG_5STR); + +bool loadweapon(char *name, bool isakimbo=false) +{ + if(!name) return false; + sprintf(basedir, "packages/models/weapons/%s", name); + + md3model *mdl = new md3model(); + s_sprintfd(mdl_path)("%s/tris_high.md3", basedir); + s_sprintfd(cfg_path)("%s/default.skin", basedir); + s_sprintfd(modelcfg_path) ("%s/animations.cfg", basedir); + + if(!mdl->load(mdl_path, isakimbo)) + { + printf("could not load: %s\n", mdl_path); + delete mdl; + return false; + } + + models.add(mdl); + exec(cfg_path); + tmp_animations.setsize(0); + exec(modelcfg_path); // load animations + loopj(tmp_animations.length()) mdl->animations.add(tmp_animations[j]); + return true; +} + +void loadweapons() +{ + firstweapon = models.length(); + loopi(NUMGUNS) loadweapon(hudgunnames[i]); + loadweapon(hudgunnames[GUN_PISTOL], true); // akimbo +}; + +VAR(swayspeeddiv, 1, 125, 1000); +VAR(swaymovediv, 1, 200, 1000); + +VAR(swayupspeeddiv, 1, 125, 1000); +VAR(swayupmovediv, 1, 200, 1000); + +VAR(x, 0, 0, 1000); +VAR(y, 0, 0, 1000); +VAR(z, 0, 0, 1000); + +struct weaponmove +{ + float k_rot, kick; + vec pos; + int anim; + + weaponmove() : k_rot(0), kick(0), anim(0) { pos.x = pos.y = pos.z = 0.0f; }; + + void calcmove(vec base, int basetime) + { + int timediff = NADE_THROWING ? (lastmillis-player1->thrownademillis) : lastmillis-basetime; + int animtime = attackdelay(player1->gunselect); + int rtime = reloadtime(player1->gunselect); + + kick = k_rot = 0.0f; + pos = player1->o; + anim = MDL_GUN_IDLE; + + if(player1->weaponchanging) + { + anim = MDL_GUN_RELOAD; + float percent_done = (float)(timediff)*100.0f/(float) WEAPONCHANGE_TIME; + if(percent_done>=100 || percent_done<0) percent_done = 100; + k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90); + } + else if(player1->reloading) + { + anim = MDL_GUN_RELOAD; + float percent_done = (float)(timediff)*100.0f/(float)rtime; + if(percent_done>=100 || percent_done<0) percent_done = 100; + k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90); + } + else + { + vec sway = base; + float percent_done = 0.0f; + float k_back = 0.0f; + + if(player1->gunselect==player1->lastattackgun) + { + percent_done = timediff*100.0f/(float)animtime; + if(percent_done > 100.0f) percent_done = 100.0f; + // f(x) = -sin(x-1.5)^3 + kick = -sin(pow((1.5f/100.0f*percent_done)-1.5f,3)); + }; + + if(player1->lastaction && player1->lastattackgun==player1->gunselect) + { + if(NADE_THROWING && timedifflastactiongunselect!=GUN_GRENADE && player1->gunselect!=GUN_KNIFE) + { + k_rot = kick_rot(player1->gunselect)*kick; + k_back = kick_back(player1->gunselect)*kick/10; + }; + + float swayspeed = (float) (sin((float)lastmillis/swayspeeddiv))/(swaymovediv/10.0f); + float swayupspeed = (float) (sin((float)lastmillis/swayupspeeddiv-90))/(swayupmovediv/10.0f); + + #define g0(x) ((x) < 0.0f ? -(x) : (x)) + float plspeed = min(1.0f, sqrt(g0(player1->vel.x*player1->vel.x) + g0(player1->vel.y*player1->vel.y))); + + swayspeed *= plspeed/2; + swayupspeed *= plspeed/2; + + float tmp = sway.x; + sway.x = sway.y; + sway.y = -tmp; + + if(swayupspeed<0.0f)swayupspeed = -swayupspeed; // sway a semicirle only + sway.z = 1.0f; + + sway.x *= swayspeed; + sway.y *= swayspeed; + sway.z *= swayupspeed; + + pos.x = player1->o.x-base.x*k_back+sway.x; + pos.y = player1->o.y-base.y*k_back+sway.y; + pos.z = player1->o.z-base.z*k_back+sway.z; + }; + }; +}; + + +void rendergun(md3model *weapon, int lastaction) +{ + int ix = (int)player1->o.x; + int iy = (int)player1->o.y; + vec light = { 1.0f, 1.0f, 1.0f }; + + if(!OUTBORD(ix, iy)) + { + sqr *s = S(ix,iy); + float ll = 256.0f; // 0.96f; + float of = 0.0f; // 0.1f; + light.x = s->r/ll+of; + light.y = s->g/ll+of; + light.z = s->b/ll+of; + }; + + vdist(dist, unitv, player1->o, worldpos); + vdiv(unitv, dist); + + weaponmove wm; + if(!intermission) wm.calcmove(unitv, lastaction); + weapon->setanim(wm.anim); + weapon->draw(wm.pos.x, wm.pos.z, wm.pos.y, player1->yaw + 90, player1->pitch+wm.k_rot, 1.0f, light); +}; + +void rendermd3gun() +{ + if(firstweapon >= 0) + { + if(player1->akimbo && player1->gunselect==GUN_PISTOL) // akimbo + { + rendergun(models[firstweapon+GUN_PISTOL], player1->akimbolastaction[0]); + rendergun(models[firstweapon+NUMGUNS], player1->akimbolastaction[1]); + } + else + { + md3model *weapon = models[firstweapon + player1->gunselect]; + rendergun(weapon, player1->lastaction); + }; + }; +}; + + diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp new file mode 100644 index 00000000..04609f52 --- /dev/null +++ b/source/src/renderparticles.cpp @@ -0,0 +1,144 @@ +// renderparticles.cpp + +#include "cube.h" + +const int MAXPARTICLES = 10500; +const int NUMPARTCUTOFF = 20; +struct particle { vec o, d; int fade, type; int millis; particle *next; int tex; }; // EDIT: AH +particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL; +bool parinit = false; + +VAR(maxparticles, 100, 2000, MAXPARTICLES-500); + +void newparticle(vec &o, vec &d, int fade, int type, int tex = -1) +{ + if(!parinit) + { + loopi(MAXPARTICLES) + { + particles[i].next = parempty; + parempty = &particles[i]; + }; + parinit = true; + }; + if(parempty) + { + particle *p = parempty; + parempty = p->next; + p->o = o; + p->d = d; + p->fade = fade; + p->type = type; + p->millis = lastmillis; + p->next = parlist; + p->tex = tex; + parlist = p; + }; +}; + +VAR(demotracking, 0, 0, 1); +VAR(particlesize, 20, 100, 500); + +vec right, up; + +void setorient(vec &r, vec &u) { right = r; up = u; }; + +void render_particles(int time) +{ + if(demoplayback && demotracking) + { + vec nom = { 0, 0, 0 }; + newparticle(player1->o, nom, 100000000, 8); + }; + + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); + glDisable(GL_FOG); + + struct parttype { float r, g, b; int gr, tex; float sz; } parttypes[] = + { + { 0.2f, 0.2f, 0.2f, 2, 3, 0.06f }, // yellow: sparks + { 0.5f, 0.5f, 0.5f, 20, 7, 0.15f }, // grey: small smoke + { 0.2f, 0.2f, 1.0f, 20, 3, 0.08f }, // blue: edit mode entities + { 1.0f, 0.1f, 0.1f, 1, 7, 0.06f }, // red: blood spats + { 1.0f, 0.8f, 0.8f, 20, 6, 1.2f }, // yellow: fireball1 + { 0.5f, 0.5f, 0.5f, 20, 7, 0.6f }, // grey: big smoke + { 1.0f, 1.0f, 1.0f, 20, 8, 1.2f }, // blue: fireball2 + { 1.0f, 1.0f, 1.0f, 20, 9, 1.2f }, // green: fireball3 + { 1.0f, 0.1f, 0.1f, 0, 7, 0.2f }, // red: demotrack + { 1.0f, 1.0f, 1.0f, 2, 3, 0.06f }, // + }; + + int numrender = 0; + + for(particle *p, **pp = &parlist; p = *pp;) + { + if(p->type==9 && p->tex!=-1) parttypes[9].tex = p->tex; // hack, AH + parttype *pt = &parttypes[p->type]; + + glBindTexture(GL_TEXTURE_2D, pt->tex); + glBegin(GL_QUADS); + + glColor3d(pt->r, pt->g, pt->b); + float sz = pt->sz*particlesize/100.0f; + // perf varray? + glTexCoord2f(0.0, 1.0); glVertex3d(p->o.x+(-right.x+up.x)*sz, p->o.z+(-right.y+up.y)*sz, p->o.y+(-right.z+up.z)*sz); + glTexCoord2f(1.0, 1.0); glVertex3d(p->o.x+( right.x+up.x)*sz, p->o.z+( right.y+up.y)*sz, p->o.y+( right.z+up.z)*sz); + glTexCoord2f(1.0, 0.0); glVertex3d(p->o.x+( right.x-up.x)*sz, p->o.z+( right.y-up.y)*sz, p->o.y+( right.z-up.z)*sz); + glTexCoord2f(0.0, 0.0); glVertex3d(p->o.x+(-right.x-up.x)*sz, p->o.z+(-right.y-up.y)*sz, p->o.y+(-right.z-up.z)*sz); + glEnd(); + xtraverts += 4; + + if(numrender++>maxparticles || (p->fade -= time)<0) + { + *pp = p->next; + p->next = parempty; + parempty = p; + } + else + { + if(pt->gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*curtime/(pt->gr*10000); + vec a = p->d; + vmul(a,time); + vdiv(a,20000.0f); + vadd(p->o, a); + pp = &p->next; + }; + }; + + glEnable(GL_FOG); + glDisable(GL_BLEND); + glDepthMask(GL_TRUE); +}; + +void particle_splash(int type, int num, int fade, vec &p) +{ + loopi(num) + { + const int radius = type==5 ? 50 : 150; + int x, y, z; + do + { + x = rnd(radius*2)-radius; + y = rnd(radius*2)-radius; + z = rnd(radius*2)-radius; + } + while(x*x+y*y+z*z>radius*radius); + vec d = { (float)x, (float)y, (float)z }; + newparticle(p, d, rnd(fade*3), type); + }; +}; + +void particle_trail(int type, int fade, vec &s, vec &e) +{ + vdist(d, v, s, e); + vdiv(v, d*2+0.1f); + vec p = s; + loopi((int)d*2) + { + vadd(p, v); + vec d = { float(rnd(11)-5), float(rnd(11)-5), float(rnd(11)-5) }; + newparticle(p, d, rnd(fade)+fade, type); + }; +}; diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp new file mode 100644 index 00000000..556c5d52 --- /dev/null +++ b/source/src/rendertext.cpp @@ -0,0 +1,236 @@ +// rendertext.cpp: based on Don's gl_text.cpp + +#include "cube.h" + +short char_coords[96][4] = +{ + {0,0,25,64}, //! + {25,0,54,64}, //" + {54,0,107,64}, //# + {107,0,148,64}, //$ + {148,0,217,64}, //% + {217,0,263,64}, //& + {263,0,280,64}, //' + {280,0,309,64}, //( + {309,0,338,64}, //) + {338,0,379,64}, //* + {379,0,432,64}, //+ + {432,0,455,64}, //, + {455,0,484,64}, //- + {0,64,21,128}, //. + {23,64,52,128}, /// + {52,64,93,128}, //0 + {93,64,133,128}, //1 + {133,64,174,128}, //2 + {174,64,215,128}, //3 + {215,64,256,128}, //4 + {256,64,296,128}, //5 + {296,64,337,128}, //6 + {337,64,378,128}, //7 + {378,64,419,128}, //8 + {419,64,459,128}, //9 + {459,64,488,128}, //: + {0,128,29,192}, //; + {29,128,81,192}, //< + {81,128,134,192}, //= + {134,128,186,192}, //> + {186,128,221,192}, //? + {221,128,285,192}, //@ + {285,128,329,192}, //A + {329,128,373,192}, //B + {373,128,418,192}, //C + {418,128,467,192}, //D + {0,192,40,256}, //E + {40,192,77,256}, //F + {77,192,127,256}, //G + {127,192,175,256}, //H + {175,192,202,256}, //I + {202,192,231,256}, //J + {231,192,275,256}, //K + {275,192,311,256}, //L + {311,192,365,256}, //M + {365,192,413,256}, //N + {413,192,463,256}, //O + {1,256,38,320}, //P + {38,256,89,320}, //Q + {89,256,133,320}, //R + {133,256,176,320}, //S + {177,256,216,320}, //T + {217,256,263,320}, //U + {263,256,307,320}, //V + {307,256,370,320}, //W + {370,256,414,320}, //X + {414,256,453,320}, //Y + {453,256,497,320}, //Z + {0,320,29,384}, //[ + {29,320,58,384}, //"\" + {59,320,87,384}, //] + {87,320,139,384}, //^ + {139,320,180,384}, //_ + {180,320,221,384}, //` + {221,320,259,384}, //a + {259,320,299,384}, //b + {299,320,332,384}, //c + {332,320,372,384}, //d + {372,320,411,384}, //e + {411,320,433,384}, //f + {435,320,473,384}, //g + {0,384,40,448}, //h + {40,384,56,448}, //i + {58,384,80,448}, //j + {80,384,118,448}, //k + {118,384,135,448}, //l + {135,384,197,448}, //m + {197,384,238,448}, //n + {238,384,277,448}, //o + {277,384,317,448}, //p + {317,384,356,448}, //q + {357,384,384,448}, //r + {385,384,417,448}, //s + {417,384,442,448}, //t + {443,384,483,448}, //u + {0,448,38,512}, //v + {38,448,90,512}, //w + {90,448,128,512}, //x + {128,448,166,512}, //y + {166,448,200,512}, //z + {200,448,241,512}, //{ + {241,448,270,512}, //| + {270,448,310,512}, //} + {310,448,363,512}, //~ +}; + +int char_width(int c, int x = 0) +{ + if(c=='\t') x = (x+PIXELTAB)/PIXELTAB*PIXELTAB; + else if(c==' ') x += FONTH/2; + else if(c>=33 && c<=126) + { + c -= 33; + int in_width = char_coords[c][2] - char_coords[c][0]; + x += in_width + 1; + }; + return x; +}; + +int text_width(const char *str, int limit) +{ + int x = 0; + for(int i = 0; str[i] && (limit<0 || i max) return i; + ++i; + }; + return i; +}; + +void draw_textf(const char *fstr, int left, int top, ...) +{ + s_sprintfdlv(str, top, fstr); + draw_text(str, left, top); +}; + +void draw_text(const char *str, int left, int top) +{ + glBlendFunc(GL_ONE, GL_ONE); + glBindTexture(GL_TEXTURE_2D, 2); + glColor3ub(255,255,255); + + int x = left; + int y = top; + + int i; + float in_left, in_top, in_right, in_bottom; + int in_width, in_height; + + for (i = 0; str[i] != 0; i++) + { + int c = str[i]; + if(c=='\t') { x = (x-left+PIXELTAB)/PIXELTAB*PIXELTAB+left; continue; }; + if(c=='\f') { glColor3ub(64,255,128); continue; }; + if(c==' ') { x += FONTH/2; continue; }; + c -= 33; + if(c<0 || c>=95) continue; + + in_left = ((float) char_coords[c][0]) / 512.0f; + in_top = ((float) char_coords[c][1]+2) / 512.0f; + in_right = ((float) char_coords[c][2]) / 512.0f; + in_bottom = ((float) char_coords[c][3]-2) / 512.0f; + + in_width = char_coords[c][2] - char_coords[c][0]; + in_height = char_coords[c][3] - char_coords[c][1]; + + glBegin(GL_QUADS); + glTexCoord2f(in_left, in_top ); glVertex2i(x, y); + glTexCoord2f(in_right, in_top ); glVertex2i(x + in_width, y); + glTexCoord2f(in_right, in_bottom); glVertex2i(x + in_width, y + in_height); + glTexCoord2f(in_left, in_bottom); glVertex2i(x, y + in_height); + glEnd(); + + xtraverts += 4; + x += in_width + 1; + } +} + +// also Don's code, so goes in here too :) + +void draw_envbox_aux(float s0, float t0, int x0, int y0, int z0, + float s1, float t1, int x1, int y1, int z1, + float s2, float t2, int x2, int y2, int z2, + float s3, float t3, int x3, int y3, int z3, + int texture) +{ + glBindTexture(GL_TEXTURE_2D, texture); + glBegin(GL_QUADS); + glTexCoord2f(s3, t3); glVertex3d(x3, y3, z3); + glTexCoord2f(s2, t2); glVertex3d(x2, y2, z2); + glTexCoord2f(s1, t1); glVertex3d(x1, y1, z1); + glTexCoord2f(s0, t0); glVertex3d(x0, y0, z0); + glEnd(); + xtraverts += 4; +} + +void draw_envbox(int t, int w) +{ + glDepthMask(GL_FALSE); + + draw_envbox_aux(1.0f, 1.0f, -w, -w, w, + 0.0f, 1.0f, w, -w, w, + 0.0f, 0.0f, w, -w, -w, + 1.0f, 0.0f, -w, -w, -w, t); + + draw_envbox_aux(1.0f, 1.0f, +w, w, w, + 0.0f, 1.0f, -w, w, w, + 0.0f, 0.0f, -w, w, -w, + 1.0f, 0.0f, +w, w, -w, t+1); + + draw_envbox_aux(0.0f, 0.0f, -w, -w, -w, + 1.0f, 0.0f, -w, w, -w, + 1.0f, 1.0f, -w, w, w, + 0.0f, 1.0f, -w, -w, w, t+2); + + draw_envbox_aux(1.0f, 1.0f, +w, -w, w, + 0.0f, 1.0f, +w, w, w, + 0.0f, 0.0f, +w, w, -w, + 1.0f, 0.0f, +w, -w, -w, t+3); + + draw_envbox_aux(0.0f, 1.0f, -w, w, w, + 0.0f, 0.0f, +w, w, w, + 1.0f, 0.0f, +w, -w, w, + 1.0f, 1.0f, -w, -w, w, t+4); + + draw_envbox_aux(0.0f, 1.0f, +w, w, -w, + 0.0f, 0.0f, -w, w, -w, + 1.0f, 0.0f, -w, -w, -w, + 1.0f, 1.0f, +w, -w, -w, t+5); + + glDepthMask(GL_TRUE); +} diff --git a/source/src/rndmap.cpp b/source/src/rndmap.cpp new file mode 100644 index 00000000..5b56a61c --- /dev/null +++ b/source/src/rndmap.cpp @@ -0,0 +1,70 @@ +// rndmap.cpp: perlin noise landscape generation and some experimental random map stuff, currently not used + +#include "cube.h" + +float noise(int x, int y, int seed) +{ + int n = x+y*57; + n = (n<<13)^n; + return 1.0f-((n*(n*n*15731+789221)+1376312589)&0x7fffffff)/1073741824.0f; +} + +float smoothednoise(int x, int y, int seed) +{ + float corners = (noise(x-1, y-1, seed)+noise(x+1, y-1, seed)+noise(x-1, y+1, seed)+noise(x+1, y+1, seed))/16; + float sides = (noise(x-1, y, seed)+noise(x+1, y, seed)+noise(x, y-1, seed)+noise(x, y+1, seed))/8; + float center = noise(x, y, seed)/4; + return corners+sides+center; +} + +float interpolate(float a, float b, float x) +{ + float ft = x*3.1415927f; + float f = (1.0f-(float)cos(ft))*0.5f; + return a*(1-f)+b*f; +} + +float interpolatednoise(float x, float y, int seed) +{ + int ix = (int)x; + float fx = x-ix; + int iy = (int)y; + float fy = y-iy; + float v1 = smoothednoise(ix, iy, seed); + float v2 = smoothednoise(ix+1, iy, seed); + float v3 = smoothednoise(ix, iy+1, seed); + float v4 = smoothednoise(ix+1, iy+1, seed); + float i1 = interpolate(v1, v2, fx); + float i2 = interpolate(v3, v4, fy); + return interpolate(i1, i2, fy); +} + +float perlinnoise_2D(float x, float y, int seedstep, float pers) +{ + float total = 0; + int seed = 0; + for(int i = 0; i<7; i++) + { + float frequency = (float)(2^i); + float amplitude = (float)pow(pers, i); + total += interpolatednoise(x*frequency, y*frequency, seed)*amplitude; + seed += seedstep; + } + return total; +} + +void perlinarea(block &b, int scale, int seed, int psize) +{ + srand(seed); + seed = rnd(10000); + if(!scale) scale = 10; + for(int x = b.x; x<=b.x+b.xs; x++) for(int y = b.y; y<=b.y+b.ys; y++) + { + sqr *s = S(x,y); + if(!SOLID(s) && x!=b.x+b.xs && y!=b.y+b.ys) s->type = FHF; + s->vdelta = (int)(perlinnoise_2D(x/((float)scale)+seed, y/((float)scale)+seed, 1000, 0.01f)*50+25); + if(s->vdelta>128) s->vdelta = 0; + }; +}; + + diff --git a/source/src/savegamedemo.cpp b/source/src/savegamedemo.cpp new file mode 100644 index 00000000..2f4d601e --- /dev/null +++ b/source/src/savegamedemo.cpp @@ -0,0 +1,353 @@ +// loading and saving of savegames & demos, dumps the spawn state of all mapents, the full state of all dynents (monsters + player) + +#include "cube.h" + +extern int islittleendian; + +gzFile f = NULL; +bool demorecording = false; +bool demoplayback = false; +bool demoloading = false; +dvector playerhistory; +int democlientnum = 0; + +void startdemo(); + +void gzput(int i) { gzputc(f, i); }; +void gzputi(int i) { gzwrite(f, &i, sizeof(int)); }; +void gzputv(vec &v) { gzwrite(f, &v, sizeof(vec)); }; + +void gzcheck(int a, int b) { if(a!=b) fatal("savegame file corrupt (short)"); }; +int gzget() { char c = gzgetc(f); return c; }; +int gzgeti() { int i; gzcheck(gzread(f, &i, sizeof(int)), sizeof(int)); return i; }; +void gzgetv(vec &v) { gzcheck(gzread(f, &v, sizeof(vec)), sizeof(vec)); }; + +void stop() +{ + if(f) + { + if(demorecording) gzputi(-1); + gzclose(f); + }; + f = NULL; + demorecording = false; + demoplayback = false; + demoloading = false; + loopv(playerhistory) zapdynent(playerhistory[i]); + playerhistory.setsize(0); + // Added by Rick: Remove bots + loopv(bots) + { + if (!bots[i]) continue; + delete bots[i]->pBot; + bots[i]->pBot = NULL; + zapdynent(bots[i]); + } + bots.setsize(0); +}; + +void stopifrecording() { if(demorecording) stop(); }; + +void savestate(char *fn) +{ + stop(); + f = gzopen(fn, "wb9"); + if(!f) { conoutf("could not write %s", fn); return; }; + gzwrite(f, (void *)"CUBESAVE", 8); + gzputc(f, islittleendian); + gzputi(SAVEGAMEVERSION); + gzputi(sizeof(dynent)); + gzwrite(f, getclientmap(), _MAXDEFSTR); + gzputi(gamemode); + gzputi(ents.length()); + loopv(ents) gzputc(f, ents[i].spawned); + gzwrite(f, player1, sizeof(dynent)); + gzputi(players.length()); + loopv(players) + { + gzput(players[i]==NULL); + gzwrite(f, players[i], sizeof(dynent)); + }; +}; + +void savegame(char *name) +{ + conoutf("can only save classic sp games"); + return; +}; + +void loadstate(char *fn) +{ + stop(); + if(multiplayer()) return; + f = gzopen(fn, "rb9"); + if(!f) { conoutf("could not open %s", fn); return; }; + + string buf; + gzread(f, buf, 8); + if(strncmp(buf, "CUBESAVE", 8)) goto out; + if(gzgetc(f)!=islittleendian) goto out; // not supporting save->load accross incompatible architectures simpifies things a LOT + if(gzgeti()!=SAVEGAMEVERSION || gzgeti()!=sizeof(dynent)) goto out; + string mapname; + gzread(f, mapname, _MAXDEFSTR); + nextmode = gzgeti(); + changemap(mapname); // continue below once map has been loaded and client & server have updated + return; + out: + conoutf("aborting: savegame/demo from a different version of cube or cpu architecture"); + stop(); +}; + +void loadgame(char *name) +{ + s_sprintfd(fn)("savegames/%s.csgz", name); + loadstate(fn); +}; + +void loadgameout() +{ + stop(); + conoutf("loadgame incomplete: savegame from a different version of this map"); +}; + +void loadgamerest() +{ + if(demoplayback || !f) return; + + if(gzgeti()!=ents.length()) return loadgameout(); + loopv(ents) + { + ents[i].spawned = gzgetc(f)!=0; + if(ents[i].type==CARROT && !ents[i].spawned) trigger(ents[i].attr1, ents[i].attr2, true); + }; + restoreserverstate(ents); + + gzread(f, player1, sizeof(dynent)); + player1->lastaction = lastmillis; + + int nplayers = gzgeti(); + loopi(nplayers) if(!gzget()) + { + dynent *d = getclient(i); + ASSERT(d); + gzread(f, d, sizeof(dynent)); + }; + + conoutf("savegame restored"); + if(demoloading) startdemo(); else stop(); +}; + +// demo functions + +int starttime = 0; +int playbacktime = 0; +int ddamage, bdamage; +vec dorig; + +void record(char *name) +{ + int cn = getclientnum(); + if(cn<0) return; + s_sprintfd(fn)("demos/%s.cdgz", name); + savestate(fn); + gzputi(cn); + conoutf("started recording demo to %s", fn); + demorecording = true; + starttime = lastmillis; + ddamage = bdamage = 0; +}; + +void demodamage(int damage, vec &o) { ddamage = damage; dorig = o; }; +void demoblend(int damage) { bdamage = damage; }; + +void incomingdemodata(int chan, uchar *buf, int len, bool extras) +{ + if(!demorecording) return; + gzputi(lastmillis-starttime); + gzputi(len); + gzput(chan); + gzwrite(f, buf, len); + gzput(extras); + if(extras) + { + gzput(player1->gunselect); + gzput(player1->lastattackgun); + gzputi(player1->lastaction-starttime); + gzputi(player1->gunwait); + gzputi(player1->health); + gzputi(player1->armour); + //gzput(player1->armourtype); + loopi(NUMGUNS) gzput(player1->ammo[i]); + gzput(player1->state); + gzputi(bdamage); + bdamage = 0; + gzputi(ddamage); + if(ddamage) { gzputv(dorig); ddamage = 0; }; + // FIXME: add all other client state which is not send through the network + }; +}; + +void demo(char *name) +{ + s_sprintfd(fn)("demos/%s.cdgz", name); + loadstate(fn); + demoloading = true; +}; + +void stopreset() +{ + conoutf("demo stopped (%d msec elapsed)", lastmillis-starttime); + stop(); + loopv(players) zapdynent(players[i]); + disconnect(0, 0); +}; + +VAR(demoplaybackspeed, 10, 100, 1000); +int scaletime(int t) { return (int)(t*(100.0f/demoplaybackspeed))+starttime; }; + +void readdemotime() +{ + if(gzeof(f) || (playbacktime = gzgeti())==-1) + { + stopreset(); + return; + }; + playbacktime = scaletime(playbacktime); +}; + +void startdemo() +{ + democlientnum = gzgeti(); + demoplayback = true; + starttime = lastmillis; + conoutf("now playing demo"); + dynent *d = getclient(democlientnum); + ASSERT(d); + *d = *player1; + readdemotime(); +}; + +VAR(demodelaymsec, 0, 120, 500); + +void catmulrom(vec &z, vec &a, vec &b, vec &c, float s, vec &dest) // spline interpolation +{ + vec t1 = b, t2 = c; + + vsub(t1, z); vmul(t1, 0.5f) + vsub(t2, a); vmul(t2, 0.5f); + + float s2 = s*s; + float s3 = s*s2; + + dest = a; + vec t = b; + + vmul(dest, 2*s3 - 3*s2 + 1); + vmul(t, -2*s3 + 3*s2); vadd(dest, t); + vmul(t1, s3 - 2*s2 + s); vadd(dest, t1); + vmul(t2, s3 - s2); vadd(dest, t2); +}; + +void fixwrap(dynent *a, dynent *b) +{ + while(b->yaw-a->yaw>180) a->yaw += 360; + while(b->yaw-a->yaw<-180) a->yaw -= 360; +}; + +void demoplaybackstep() +{ + while(demoplayback && lastmillis>=playbacktime) + { + int len = gzgeti(); + if(len<1 || len>MAXTRANS) + { + conoutf("error: huge packet during demo play (%d)", len); + stopreset(); + return; + }; + int chan = gzget(); + uchar buf[MAXTRANS]; + gzread(f, buf, len); + localservertoclient(chan, buf, len); // update game state + + dynent *target = players[democlientnum]; + ASSERT(target); + + int extras; + if(extras = gzget()) // read additional client side state not present in normal network stream + { + target->gunselect = gzget(); + target->lastattackgun = gzget(); + target->lastaction = scaletime(gzgeti()); + target->gunwait = gzgeti(); + target->health = gzgeti(); + target->armour = gzgeti(); + //target->armourtype = gzget(); + loopi(NUMGUNS) target->ammo[i] = gzget(); + target->state = gzget(); + target->lastmove = playbacktime; + if(bdamage = gzgeti()) damageblend(bdamage); + if(ddamage = gzgeti()) { gzgetv(dorig); particle_splash(3, ddamage, 1000, dorig); }; + // FIXME: set more client state here + }; + + // insert latest copy of player into history + if(extras && (playerhistory.empty() || playerhistory.last()->lastupdate!=playbacktime)) + { + dynent *d = newdynent(); + *d = *target; + d->lastupdate = playbacktime; + playerhistory.add(d); + if(playerhistory.length()>20) + { + zapdynent(playerhistory[0]); + playerhistory.remove(0); + }; + }; + + readdemotime(); + }; + + if(demoplayback) + { + int itime = lastmillis-demodelaymsec; + loopvrev(playerhistory) if(playerhistory[i]->lastupdate=0) z = playerhistory[i-1]; + //if(a==z || b==c) printf("* %d\n", lastmillis); + float bf = (itime-a->lastupdate)/(float)(b->lastupdate-a->lastupdate); + fixwrap(a, player1); + fixwrap(c, player1); + fixwrap(z, player1); + vdist(dist, v, z->o, c->o); + if(dist<16) // if teleport or spawn, dont't interpolate + { + catmulrom(z->o, a->o, b->o, c->o, bf, player1->o); + catmulrom(*(vec *)&z->yaw, *(vec *)&a->yaw, *(vec *)&b->yaw, *(vec *)&c->yaw, bf, *(vec *)&player1->yaw); + }; + fixplayer1range(); + }; + break; + }; + //if(player1->state!=CS_DEAD) showscores(false); + }; +}; + +void stopn() { if(demoplayback) stopreset(); else stop(); conoutf("demo stopped"); }; + +// sorry :/ +/*COMMAND(record, ARG_1STR); +COMMAND(demo, ARG_1STR); +COMMANDN(stop, stopn, ARG_NONE);*/ + +COMMAND(savegame, ARG_1STR); +COMMAND(loadgame, ARG_1STR); diff --git a/source/src/server.cpp b/source/src/server.cpp new file mode 100644 index 00000000..58b1d893 --- /dev/null +++ b/source/src/server.cpp @@ -0,0 +1,1316 @@ +// server.cpp: little more than enhanced multicaster +// runs dedicated or as client coroutine + +#include "cube.h" + +#define m_ctf_s (mode==5) +#define m_teammode_s (mode==0 || mode==4 || mode==5) + +#define valid_client(c) (clients.inrange(c) && clients[c]->type!=ST_EMPTY) +#define valid_flag(f) (f >= 0 && f < 2) + +enum { ST_EMPTY, ST_LOCAL, ST_TCPIP }; + +struct clientscore +{ + int frags; +}; + +struct savedscore : clientscore +{ + string name; + uint ip; +}; + +static vector scores; + +struct client // server side version of "dynent" type +{ + int type; + int clientnum; + ENetPeer *peer; + string hostname; + string mapvote; + string name; + int modevote; + clientscore score; + // Added by Rick: For bot voting +#ifndef STANDALONE + bool addbot, kickbot, changebotskill; + short botcount; + string botteam, botname; + short botskill; + bool kickallbots; +#endif + // End add + bool ismaster; + bool isauthed; // for passworded servers + vector position, messages; + int positionoffset, messageoffset; + + void reset() + { + name[0] = 0; + score.frags = 0; + position.setsizenodelete(0); + messages.setsizenodelete(0); + }; +}; + +vector clients; + +struct worldstate +{ + enet_uint32 uses; + vector positions, messages; +}; + +vector worldstates; + +void cleanworldstate(ENetPacket *packet) +{ + loopv(worldstates) + { + worldstate *ws = worldstates[i]; + if(packet->data >= ws->positions.getbuf() && packet->data <= &ws->positions.last()) ws->uses--; + else if(packet->data >= ws->messages.getbuf() && packet->data <= &ws->messages.last()) ws->uses--; + else continue; + if(!ws->uses) + { + delete ws; + worldstates.remove(i); + }; + break; + }; +}; + +int bsend = 0, brec = 0, laststatus = 0, lastsec = 0; + +void sendpacket(int n, int chan, ENetPacket *packet) +{ + switch(clients[n]->type) + { + case ST_TCPIP: + { + enet_peer_send(clients[n]->peer, chan, packet); + bsend += packet->dataLength; + break; + }; + + case ST_LOCAL: + localservertoclient(chan, packet->data, (int)packet->dataLength); + break; + }; +}; + +static bool reliablemessages = false; + +bool buildworldstate() +{ + worldstate &ws = *new worldstate; + loopv(clients) + { + client &c = *clients[i]; + if(c.type!=ST_TCPIP) continue; + if(c.position.empty()) c.positionoffset = -1; + else + { + c.positionoffset = ws.positions.length(); + loopvj(c.position) ws.positions.add(c.position[j]); + }; + if(c.messages.empty()) c.messageoffset = -1; + else + { + c.messageoffset = ws.messages.length(); + ws.messages.add(c.clientnum); + ws.messages.add(c.messages.length()&0xFF); + ws.messages.add(c.messages.length()>>8); + loopvj(c.messages) ws.messages.add(c.messages[j]); + }; + }; + int psize = ws.positions.length(), msize = ws.messages.length(); + loopi(psize) { uchar c = ws.positions[i]; ws.positions.add(c); }; + loopi(msize) { uchar c = ws.messages[i]; ws.messages.add(c); }; + ws.uses = 0; + loopv(clients) + { + client &c = *clients[i]; + if(c.type!=ST_TCPIP) continue; + ENetPacket *packet; + if(psize && (c.positionoffset<0 || psize-c.position.length()>0)) + { + packet = enet_packet_create(&ws.positions[c.positionoffset<0 ? 0 : c.positionoffset+c.position.length()], + c.positionoffset<0 ? psize : psize-c.position.length(), + ENET_PACKET_FLAG_NO_ALLOCATE); + sendpacket(c.clientnum, 0, packet); + if(!packet->referenceCount) enet_packet_destroy(packet); + else { ++ws.uses; packet->freeCallback = cleanworldstate; }; + }; + c.position.setsizenodelete(0); + + if(msize && (c.messageoffset<0 || msize-3-c.messages.length()>0)) + { + packet = enet_packet_create(&ws.messages[c.messageoffset<0 ? 0 : c.messageoffset+3+c.messages.length()], + c.messageoffset<0 ? msize : msize-3-c.messages.length(), + (reliablemessages ? ENET_PACKET_FLAG_RELIABLE : 0) | ENET_PACKET_FLAG_NO_ALLOCATE); + sendpacket(c.clientnum, 2, packet); + if(!packet->referenceCount) enet_packet_destroy(packet); + else { ++ws.uses; packet->freeCallback = cleanworldstate; }; + }; + c.messages.setsizenodelete(0); + }; + reliablemessages = false; + if(!ws.uses) + { + delete &ws; + return false; + } + else + { + worldstates.add(&ws); + return true; + }; +}; + +int maxclients = 8; +string smapname; + +char *masterpasswd = NULL; + +int numclients() +{ + int num = 0; + loopv(clients) if(clients[i]->type!=ST_EMPTY) num++; + return num; +}; + +void zapclient(int c) +{ + if(c<0 || c>=clients.length()) return; + clients[c]->type = ST_EMPTY; + clients[c]->ismaster = clients[c]->isauthed = false; +}; + +clientscore *findscore(client &c, bool insert) +{ + if(c.type!=ST_TCPIP) return NULL; + if(!insert) loopv(clients) + { + client &o = *clients[i]; + if(o.type!=ST_TCPIP) + if(o.clientnum!=c.clientnum && o.peer->address.host==c.peer->address.host && !strcmp(o.name, c.name)) return &o.score; + }; + loopv(scores) + { + savedscore &sc = scores[i]; + if(!strcmp(sc.name, c.name) && sc.ip==c.peer->address.host) return ≻ + }; + if(!insert) return NULL; + savedscore &sc = scores.add(); + s_strcpy(sc.name, c.name); + sc.ip = c.peer->address.host; + (clientscore &)sc = c.score; + return ≻ +}; + +void resetscores() +{ + loopv(clients) if(clients[i]->type==ST_TCPIP) + { + clients[i]->score.frags = 0; + }; + scores.setsize(0); +}; + +vector sents; + +bool notgotitems = true; // true when map has changed and waiting for clients to send item +int mode = 0; + +// Added by Rick +#ifndef STANDALONE +extern void kickbot(const char *szName); +extern void kickallbots(void); +#endif +// End add + + +void restoreserverstate(vector &ents) // hack: called from savegame code, only works in SP +{ + loopv(sents) + { + sents[i].spawned = ents[i].spawned; + sents[i].spawnsecs = 0; + }; +}; + +int interm = 0, minremain = 0, mapend = 0; +bool mapreload = false; + +char *serverpassword = ""; + +bool isdedicated; +ENetHost *serverhost = NULL; + +void process(ENetPacket *packet, int sender, int chan); +void multicast(ENetPacket *packet, int sender, int chan); +void disconnect_client(int n, int reason); + +void sendf(int cn, int chan, const char *format, ...) +{ + bool reliable = false; + if(*format=='r') { reliable = true; ++format; }; + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); + ucharbuf p(packet->data, packet->dataLength); + va_list args; + va_start(args, format); + while(*format) switch(*format++) + { + case 'i': + { + int n = isdigit(*format) ? *format++-'0' : 1; + loopi(n) putint(p, va_arg(args, int)); + break; + }; + case 's': sendstring(va_arg(args, const char *), p); break; + }; + va_end(args); + enet_packet_resize(packet, p.length()); + if(cn<0) multicast(packet, -1, chan); + else sendpacket(cn, chan, packet); + if(packet->referenceCount==0) enet_packet_destroy(packet); +}; + +struct ctfflag +{ + int state; + int thief_cn; + int pos[3]; + int lastupdate; +} ctfflags[2]; + +bool ctfbroadcast = false; + +void sendflaginfo(int flag, int action, int cn = -1) +{ + ctfflag &f = ctfflags[flag]; + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_FLAGINFO); + putint(p, flag); + putint(p, f.state); + putint(p, action); + if(f.state==CTFF_STOLEN || action==SV_FLAGRETURN) putint(p, f.thief_cn); + else if(f.state==CTFF_DROPPED) loopi(3) putint(p, f.pos[i]); + enet_packet_resize(packet, p.length()); + if(cn<0) multicast(packet, -1, 1); + else sendpacket(cn, 1, packet); + if(packet->referenceCount==0) enet_packet_destroy(packet); +}; + +void ctfreset(bool send=true) +{ + if(!m_ctf_s) return; + loopi(2) + { + ctfflags[i].thief_cn = 0; + ctfflags[i].state = CTFF_INBASE; + ctfflags[i].lastupdate = -1; + if(send) sendflaginfo(i, -1); + }; +} + +void sendservmsg(char *msg, int client=-1) +{ + sendf(client, 1, "ris", SV_SERVMSG, msg); +}; + +char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL (maxclients)"}; + +void disconnect_client(int n, int reason) +{ + if(n<0 || n>=clients.length() || clients[n]->type!=ST_TCPIP) return; + clientscore *sc = findscore(*clients[n], true); + if(sc) *sc = clients[n]->score; + printf("disconnecting client (%s) [%s]\n", clients[n]->hostname, disc_reasons[reason]); + enet_peer_disconnect(clients[n]->peer, reason); + zapclient(n); + sendf(-1, 1, "rii", SV_CDIS, n); +}; + +void resetitems() { sents.setsize(0); notgotitems = true; }; + +void pickup(uint i, int sec, int sender) // server side item pickup, acknowledge first client that gets it +{ + if(i>=(uint)sents.length()) return; + if(sents[i].spawned) + { + sents[i].spawned = false; + sents[i].spawnsecs = sec; + sendf(sender, 1, "rii", SV_ITEMACC, i); + }; +}; + +// EDIT: AH +struct configset +{ + string mapname; + int mode; + int time; + bool vote; +}; + +vector configsets; +int curcfgset = -1; + +void readscfg(char *cfg) +{ + configsets.setsize(0); + + string s; + s_strcpy(s, cfg); + char *buf = loadfile(path(s), NULL); + if(!buf) return; + char *p, *l; + + p = buf; + while((p = strstr(p, "//")) != NULL) // remove comments + while(p[0] != '\n' && p[0] != '\0') p++[0] = ' '; + + l = buf; + bool lastline = false; + while((p = strstr(l, "\n")) != NULL || (l && (lastline=true))) // remove empty/invalid lines + { + size_t len = lastline ? strlen(l) : p-l; + string line; + s_strncpy(line, l, len+1); + char *d = line; + int n = 0; + while((p = strstr(d, ":")) != NULL && (d = p+1)) n++; + if(n!=3) memset(l, ' ', len+1); + if(lastline) break; + l += len+1; + }; + + configset c; + int argc = 0; + string argv[4]; + + p = strtok(buf, ":\n\0"); + while(p != NULL) + { + strcpy(argv[argc], p); + if(++argc==4) + { + int numspaces; + for(numspaces = 0; argv[0][numspaces]==' '; numspaces++){}; // ingore space crap + strcpy(c.mapname, argv[0]+numspaces); + c.mode = atoi(argv[1]); + c.time = atoi(argv[2]); + c.vote = atoi(argv[3]) > 0; + configsets.add(c); + argc = 0; + }; + p = strtok(NULL, ":\n\0"); + }; +}; + +void nextcfgset() // load next maprotation set +{ + curcfgset++; + if(curcfgset>=configsets.length() || curcfgset<0) curcfgset=0; + + configset &c = configsets[curcfgset]; + mode = c.mode; + minremain = c.time; + s_strcpy(smapname, c.mapname); + + mapend = lastsec+minremain*60; + mapreload = false; + interm = 0; + laststatus = lastsec-61; + resetitems(); +}; + +void resetvotes() +{ + loopv(clients) clients[i]->mapvote[0] = 0; +}; + +bool vote(char *map, int reqmode, int sender) +{ + if(!valid_client(sender)) return false; + + if(configsets.length() && curcfgset < configsets.length() && !configsets[curcfgset].vote && !clients[sender]->ismaster) + { + s_sprintfd(msg)("%s voted, but voting is currently disabled", clients[sender]->name); + sendservmsg(msg); + return false; + }; + + s_strcpy(clients[sender]->mapvote, map); + clients[sender]->modevote = reqmode; + int yes = 0, no = 0; + loopv(clients) if(clients[i]->type!=ST_EMPTY) + { + if(clients[i]->mapvote[0]) { if(strcmp(clients[i]->mapvote, map)==0 && clients[i]->modevote==reqmode) yes++; else no++; } + else no++; + }; + if(yes==1 && no==0) return true; // single player + s_sprintfd(msg)("%s suggests %s on map %s (set map to vote)", clients[sender]->name, modestr(reqmode), map); + sendservmsg(msg); + if(yes/(float)(yes+no) <= 0.5f && !clients[sender]->ismaster) return false; + sendservmsg("vote passed"); + resetvotes(); + return true; +}; + +//fixmebot +// Added by Rick: Vote for bot commands + +#ifndef STANDALONE +void resetbotvotes() +{ + loopv(clients) + { + clients[i]->addbot = false; + clients[i]->kickbot = false; + clients[i]->changebotskill = false; + clients[i]->kickallbots = false; + clients[i]->botcount = 0; + clients[i]->botteam[0] = 0; + clients[i]->botname[0] = 0; + clients[i]->botskill = -1; + }; +}; + +bool addbotvote(int count, char *team, int skill, char *name, int sender) +{ + clients[sender]->addbot = true; + clients[sender]->kickbot = false; + clients[sender]->changebotskill = false; + clients[sender]->botcount = (count>=0) ? count : 0; + if (team && team[0]) s_strcpy(clients[sender]->botteam, team); + else clients[sender]->botteam[0] = 0; + clients[sender]->botskill = skill; + if (name && name[0]) s_strcpy(clients[sender]->botname, name); + else clients[sender]->botname[0] = 0; + int yes = 0, no = 0; + loopv(clients) if(clients[i]->type!=ST_EMPTY) + { + if (clients[i]->addbot) + { + if (!strcmp(clients[i]->botteam, team) && !strcmp(clients[i]->botname, name) && + (clients[i]->botskill == skill) && + (clients[i]->botcount == clients[sender]->botcount)) + yes++; + else + no++; + } + else no++; + }; + if(yes==1 && no==0) return true; // single player + s_sprintfd(msg)("%s suggests to add a bot", clients[sender]->name); + if(team && team[0]) + { + strcat(msg, " on team "); + strcat(msg, team); + }; + + if(skill!=-1) + { + strcat(msg, ", with skill "); + strcat(msg, SkillNrToSkillName(skill)); + }; + + if(name && name[0]) + { + strcat(msg, " named "); + strcat(msg, name); + } + + sendservmsg(msg); + if(yes/(float)(yes+no) <= 0.5f) return false; + sendservmsg("vote passed"); + resetbotvotes(); + + return true; +}; + + +bool kickbotvote(int specific, char *name, int sender) +{ + clients[sender]->addbot = false; + clients[sender]->kickbot = true; + clients[sender]->changebotskill = false; + clients[sender]->kickallbots = !specific; + if(name && name[0]) s_strcpy(clients[sender]->botname, name); + else clients[sender]->botname[0] = 0; + int yes = 0, no = 0; + loopv(clients) if(clients[i]->type!=ST_EMPTY) + { + if(clients[i]->kickbot) + { + if(clients[sender]->kickallbots) + { + if(clients[i]->kickallbots) yes++; + else no++; + } + else + { + if(!clients[i]->kickallbots && !strcmp(clients[i]->botname, name)) + yes++; + else + no++; + } + } + else no++; + } + if(yes==1 && no==0) return true; // single player + + char msg[256]; + if(clients[sender]->kickallbots) + sprintf(msg, "%s suggests to kick all bots", clients[sender]->name); + else + sprintf(msg, "%s suggests to kick bot %s", clients[sender]->name, + clients[sender]->botname); + + sendservmsg(msg); + if(yes/(float)(yes+no) <= 0.5f) return false; + sendservmsg("vote passed"); + resetbotvotes(); + return true; +}; + +bool botskillvote(int skill, int sender) +{ + clients[sender]->addbot = false; + clients[sender]->kickbot = false; + clients[sender]->changebotskill = true; + clients[sender]->botskill = skill; + int yes = 0, no = 0; + loopv(clients) if(clients[i]->type!=ST_EMPTY) + { + if(clients[i]->changebotskill) + { + if(clients[sender]->botskill == clients[i]->botskill) yes++; + else no++; + } + else no++; + } + if(yes==1 && no==0) return true; // single player + + s_sprintfd(msg)("%s suggests to change the skill of all bots to: %s", clients[sender]->name, + SkillNrToSkillName(clients[sender]->botskill)); + sendservmsg(msg); + if(yes/(float)(yes+no) <= 0.5f) return false; + sendservmsg("vote passed"); + resetbotvotes(); + return true; +}; + +void botcommand(ucharbuf &p, char *text, int sender) +{ + if(!valid_client(sender)) return; + int type = getint(p); + switch(EBotCommands(type)) + { + case COMMAND_ADDBOT: + { + string name, team; + int count = getint(p); + int skill = getint(p); + getstring(text, p); + strcpy(team, text); + getstring(text, p); + strcpy(name, text); + if (addbotvote(count, team, skill, name, sender)) + { + while(count>0) + { + BotManager.CreateBot(team, SkillNrToSkillName(skill), name); + count--; + } + } + break; + } + case COMMAND_KICKBOT: + { + int specific = getint(p); + + if (specific) + getstring(text, p); + + if (kickbotvote(specific, text, sender)) + { + if (specific) + kickbot(text); + else + kickallbots(); + } + } + case COMMAND_BOTSKILL: + { + int skill = getint(p); + if (botskillvote(skill, sender)) + { + BotManager.ChangeBotSkill(skill, NULL); + } + } + } +} +#endif +// End add + + +// force map change, EDIT: AH +void changemap() +{ + sendf(-1, 1, "risi", SV_MAPCHANGE, smapname, mode); +}; + +struct ban +{ + ENetAddress address; + int secs; +}; + +vector bans; + +bool isbanned(int cn) +{ + if(!valid_client(cn)) return false; + client &c = *clients[cn]; + loopv(bans) + { + ban &b = bans[i]; + if(b.secs < lastsec) { bans.remove(i--); }; + if(b.address.host == c.peer->address.host) { return true; }; + }; + return false; +}; + +void getmaster(int sender, char *pwd) +{ + if(!pwd[0] || !isdedicated) return; + if(masterpasswd && !strcmp(masterpasswd, pwd)) + { + clients[sender]->ismaster = true; + sendservmsg("master login successful", sender); + } + else disconnect_client(sender, DISC_MLOGINFAIL); +}; + +void mastercmd(int sender, int cmd, int a) +{ + if(!isdedicated) return; + if(clients[sender]->ismaster==false) return; + switch(cmd) + { + case MCMD_KICK: + { + if(!valid_client(a)) return; + disconnect_client(a, DISC_MKICK); + sendservmsg("player kicked"); + break; + }; + case MCMD_BAN: + { + if(!valid_client(a)) return; + ban b = { clients[a]->peer->address, lastsec+20*60 }; + bans.add(b); + disconnect_client(a, DISC_MBAN); + sendservmsg("player banned"); + break; + }; + case MCMD_REMBANS: + { + if(bans.length()) bans.setsize(0); + sendservmsg("bans removed"); + break; + }; + }; +}; + +void sendmapinfo(int c) +{ + if(!valid_client(c)) return; + if(smapname[0]) + { + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_MAPCHANGE); + sendstring(smapname, p); + putint(p, mode); + putint(p, SV_ITEMLIST); + loopv(sents) if(sents[i].spawned) putint(p, i); + putint(p, -1); + enet_packet_resize(packet, p.length()); + sendpacket(c, 1, packet); + }; +}; + +// server side processing of updates: does very little and most state is tracked client only +// could be extended to move more gameplay to server (at expense of lag) + +#ifdef STANDALONE +#define CN_CHECK if((cn>=0 && cn!=sender) || !valid_client(cn)) { if(sender>=0) disconnect_client(sender, DISC_CN); return; }; +#define SENDER_CHECK if(sender<0) return; +#else +#define CN_CHECK if((cn>=0 && cn!=sender) || !valid_client(cn)) { if(sender>=0) disconnect_client(sender, DISC_CN); conoutf("invalid client (msg %i)", type); return; }; +#define SENDER_CHECK if(sender<0) { conoutf("invalid sender (msg %i)", type); return; }; +#endif + +void process(ENetPacket *packet, int sender, int chan) // sender may be -1 +{ + ucharbuf p(packet->data, packet->dataLength); + char text[MAXTRANS]; + client *cl = sender>=0 ? clients[sender] : NULL; + int cn = sender, type; + int tmp_pos[3]; + + if(serverpassword[0] && sender>=0 && sender<=clients.length() && !clients[sender]->isauthed) + { + int msg = getint(p); + getstring(text, p); + if(msg != SV_PWD || !text[0] || strcmp(text, serverpassword)) disconnect_client(sender, DISC_WRONGPW); + else + { + clients[sender]->isauthed = true; + sendmapinfo(sender); + }; + return; + }; + + if(packet->flags&ENET_PACKET_FLAG_RELIABLE) reliablemessages = true; + + #define QUEUE_MSG { while(curmsgmessages.add(p.buf[curmsg++]); } + int curmsg; + while((curmsg = p.length()) < p.maxlen) switch(type = getint(p)) + { + case SV_CDIS: + { + int n = getint(p); + if(m_ctf_s) + loopi(2) if(ctfflags[i].state==CTFF_STOLEN && ctfflags[i].thief_cn==n) + sendf(-1, 1, "rii", SV_FLAGDROP, i); + QUEUE_MSG; + break; + }; + + case SV_TEXT: + getstring(text, p); + QUEUE_MSG; + break; + + case SV_INITC2S: + { + CN_CHECK; + bool newclient = false; + if(!clients[cn]->name[0]) newclient = true; + getstring(text, p); + if(!text[0]) s_strcpy(text, "unarmed"); + s_strcpy(clients[cn]->name, text); + if(newclient) + { + clientscore *sc = findscore(*clients[cn], false); + if(sc) sendf(-1, 1, "riii", SV_RESUME, cn, sc->frags); + }; + getstring(text, p); + getint(p); + getint(p); + QUEUE_MSG; + break; + }; + + case SV_MAPCHANGE: + { + SENDER_CHECK; + getstring(text, p); + int reqmode = getint(p); + if(reqmode<0) reqmode = 0; + if(smapname[0] && !mapreload && !vote(text, reqmode, sender)) return; + mapreload = false; + mode = reqmode; + minremain = m_ctf_s ? 10 : (m_teammode_s ? 15 : 10); + mapend = lastsec+minremain*60; + interm = 0; + s_strcpy(smapname, text); + resetitems(); + laststatus = lastsec-61; + ctfbroadcast = true; + resetscores(); + changemap(); + break; + }; + + case SV_ITEMLIST: + { + int n; + while((n = getint(p))!=-1) if(notgotitems) + { + server_entity se = { false, 0 }; + while(sents.length()<=n) sents.add(se); + sents[n].spawned = true; + }; + notgotitems = false; + QUEUE_MSG; + break; + }; + + case SV_ITEMPICKUP: + { + SENDER_CHECK; + int n = getint(p); + pickup(n, getint(p), sender); + QUEUE_MSG; + break; + }; + + case SV_BOTITEMPICKUP: + { + loopi(2) getint(p); + QUEUE_MSG; + break; + }; + + case SV_PING: + CN_CHECK; + sendf(cn, 1, "ii", SV_PONG, getint(p)); + break; + + case SV_POS: + { + cn = getint(p); + CN_CHECK; + loopi(3) tmp_pos[i] = getuint(p); + getuint(p); + loopi(6) getint(p); + cl->position.setsizenodelete(0); + while(curmsgposition.add(p.buf[curmsg++]); + break; + }; + + case SV_SENDMAP: + { + SENDER_CHECK; + getstring(text, p); + int mapsize = getint(p); + if(p.remaining() < mapsize) + { + p.forceoverread(); + break; + }; + sendmaps(sender, text, mapsize, &p.buf[p.len]); + p.len += mapsize; + break; + }; + + case SV_RECVMAP: + SENDER_CHECK; + sendpacket(sender, 3, recvmap(sender)); + break; + + // Added by Rick: Bot specifc messages +#ifndef STANDALONE + case SV_ADDBOT: + getint(p); + getstring(text, p); + //s_strcpy(clients[cn]->name, text); + getstring(text, p); + getint(p); + QUEUE_MSG; + break; + case SV_BOTCOMMAND: // Client asked server for a bot command + botcommand(p, text, sender); + QUEUE_MSG; + break; +#endif + // End add by Rick + + + // EDIT: AH + case SV_FLAGPICKUP: + { + int flag = getint(p); + if(!valid_flag(flag)) return; + ctfflag &f = ctfflags[flag]; + if(f.state!=CTFF_STOLEN) + { + f.state = CTFF_STOLEN; + f.thief_cn = sender; + f.lastupdate = lastsec; + sendflaginfo(flag, SV_FLAGPICKUP); + }; + QUEUE_MSG; + break; + }; + + case SV_FLAGDROP: + { + int flag = getint(p); + if(!valid_flag(flag)) return; + ctfflag &f = ctfflags[flag]; + if(f.state==CTFF_STOLEN && (sender==-1 || f.thief_cn==sender)) + { + f.state = CTFF_DROPPED; + f.lastupdate = lastsec; + loopi(3) f.pos[i] = tmp_pos[i]; + sendflaginfo(flag, SV_FLAGDROP); + }; + break; + }; + + case SV_FLAGRETURN: + { + int flag = getint(p); + if(!valid_flag(flag)) return; + ctfflag &f = ctfflags[flag]; + if(f.state==CTFF_DROPPED) + { + f.state = CTFF_INBASE; + f.thief_cn = sender; + f.lastupdate = lastsec; + sendflaginfo(flag, SV_FLAGRETURN); + }; + break; + }; + + case SV_FLAGSCORE: + { + int flag = getint(p); + if(!valid_flag(flag)) return; + ctfflag &f = ctfflags[flag]; + if(f.state==CTFF_STOLEN) + { + f.state = CTFF_INBASE; + f.thief_cn = sender; + f.lastupdate = lastsec; + sendflaginfo(flag, SV_FLAGSCORE); + }; + break; + }; + + case SV_GETMASTER: + { + SENDER_CHECK; + getstring(text, p); + getmaster(sender, text); + break; + }; + + case SV_MASTERCMD: + { + SENDER_CHECK; + int cmd = getint(p); + int arg = getint(p); + mastercmd(sender, cmd, arg); + break; + }; + + case SV_PWD: + { + getstring(text, p); + break; + }; + + case SV_FRAGS: + { + CN_CHECK; + cl->score.frags = getint(p); + QUEUE_MSG; + break; + }; + + default: + { + int size = msgsizelookup(type); + if(size==-1) { if(sender>=0) disconnect_client(sender, DISC_TAGT); return; }; + loopi(size-1) getint(p); + QUEUE_MSG; + break; + }; + }; + + if(p.overread()) { if(sender>=0) disconnect_client(sender, DISC_EOP); return; }; +}; + +void send_welcome(int n) +{ + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_INITS2C); + putint(p, n); + putint(p, PROTOCOL_VERSION); + if(!smapname[0] && configsets.length()) nextcfgset(); // EDIT:AH + putint(p, smapname[0]); + putint(p, serverpassword[0] ? 1 : 0); + int numcl = numclients(); + if(smapname[0] && !serverpassword[0]) + { + putint(p, SV_MAPCHANGE); + sendstring(smapname, p); + putint(p, mode); + if(!configsets.length() || numcl > 1) + { + putint(p, SV_ITEMLIST); + loopv(sents) if(sents[i].spawned) putint(p, i); + putint(p, -1); + }; + }; + enet_packet_resize(packet, p.length()); + sendpacket(n, 1, packet); + if(smapname[0] && m_ctf_s) loopi(2) sendflaginfo(i, -1, n); // EDIT: AH +}; + +void multicast(ENetPacket *packet, int sender, int chan) +{ + loopv(clients) + { + if(i==sender) continue; + sendpacket(i, chan, packet); + }; +}; + +void localclienttoserver(int chan, ENetPacket *packet) +{ + process(packet, 0, chan); + if(!packet->referenceCount) enet_packet_destroy(packet); +}; + +client &addclient() +{ + client *c = NULL; + loopv(clients) if(clients[i]->type==ST_EMPTY) { c = clients[i]; break; }; + if(!c) + { + c = new client; + c->clientnum = clients.length(); + clients.add(c); + }; + c->reset(); + return *c; +}; + +void checkintermission() +{ + if(!minremain) + { + interm = lastsec+10; + mapend = lastsec+1000; + }; + sendf(-1, 1, "rii", SV_TIMEUP, minremain--); +}; + +/*void startintermission() { minremain = 0; checkintermission(); };*/ + +void resetserverifempty() +{ + loopv(clients) if(clients[i]->type!=ST_EMPTY) return; + //clients.setsize(0); + smapname[0] = 0; + resetvotes(); +#ifndef STANDALONE + resetbotvotes(); // Added by Rick +#endif + resetitems(); + mode = 0; + mapreload = false; + minremain = 10; + mapend = lastsec+minremain*60; + interm = 0; + ctfreset(false); +}; + +int nonlocalclients = 0; + +int refuseconnect(int i) +{ + if(valid_client(i) && isbanned(i)) return DISC_BANREFUSE; + return DISC_NONE; +}; + +void sendworldstate() +{ + static enet_uint32 lastsend = 0; + if(clients.empty()) return; + enet_uint32 curtime = enet_time_get()-lastsend; + if(curtime<40) return; + bool flush = buildworldstate(); + lastsend += curtime - (curtime%40); + if(flush) enet_host_flush(serverhost); +}; + +void serverslice(int seconds, unsigned int timeout) // main server update, called from cube main loop in sp, or dedicated server loop +{ + loopv(sents) // spawn entities when timer reached + { + if(sents[i].spawnsecs && (sents[i].spawnsecs -= seconds-lastsec)<=0) + { + sents[i].spawnsecs = 0; + sents[i].spawned = true; + sendf(-1, 1, "rii", SV_ITEMSPAWN, i); + }; + }; + + if(m_ctf_s) + { + loopi(2) + { + ctfflag &f = ctfflags[i]; + if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30) + { + f.state=CTFF_INBASE; + sendflaginfo(i, -1); + s_sprintfd(msg)("the server reset the %s flag", rb_team_string(i)); + sendservmsg(msg); + sendf(-1, 1, "rii", SV_SOUND, S_FLAGRETURN); + }; + }; + }; + + lastsec = seconds; + + if((mode>1 || (mode==0 && nonlocalclients)) && seconds>mapend-minremain*60) checkintermission(); + if(interm && seconds>interm) + { + interm = 0; + + if(configsets.length()) // EDIT: AH + { + nextcfgset(); + changemap(); + ctfbroadcast = true; + } + else loopv(clients) if(clients[i]->type!=ST_EMPTY) + { + sendf(i, 1, "rii", SV_MAPRELOAD, 0); // ask a client to trigger map reload + mapreload = true; + break; + }; + }; + + if(ctfbroadcast) + { + ctfreset(); + ctfbroadcast = false; + }; + + resetserverifempty(); + + if(!isdedicated) return; // below is network only + + int numplayers = numclients(); + serverms(mode, numplayers, minremain, smapname, seconds, numclients()>=maxclients); + + if(seconds-laststatus>60) // display bandwidth stats, useful for server ops + { + nonlocalclients = 0; + loopv(clients) if(clients[i]->type==ST_TCPIP) nonlocalclients++; + laststatus = seconds; + if(nonlocalclients || bsend || brec) + { + printf("status: %d remote clients, %.1f send, %.1f rec (K/sec)\n", nonlocalclients, bsend/60.0f/1024, brec/60.0f/1024); +#ifdef _DEBUG + fflush(stdout); +#endif + } + bsend = brec = 0; + }; + + ENetEvent event; + if(enet_host_service(serverhost, &event, timeout) > 0) + { + switch(event.type) + { + case ENET_EVENT_TYPE_CONNECT: + { + client &c = addclient(); + c.type = ST_TCPIP; + c.peer = event.peer; + c.peer->data = (void *)c.clientnum; + c.ismaster = c.isauthed = false; + char hn[1024]; + s_strcpy(c.hostname, (enet_address_get_host(&c.peer->address, hn, sizeof(hn))==0) ? hn : "unknown"); + printf("client connected (%s)\n", c.hostname); + int reason = DISC_MAXCLIENTS; + if(nonlocalclientsdataLength; + int cn = (int)event.peer->data; + if(valid_client(cn)) process(event.packet, cn, event.channelID); + if(event.packet->referenceCount==0) enet_packet_destroy(event.packet); + break; + }; + + case ENET_EVENT_TYPE_DISCONNECT: + { + if(!valid_client((int)event.peer->data)) break; + client &c = *clients[(int)event.peer->data]; + printf("disconnected client (%s)\n", c.hostname); + clientscore *sc = findscore(c, true); + if(sc) *sc = c.score; + zapclient((int)event.peer->data); + sendf(-1, 1, "rii", SV_CDIS, (int)event.peer->data); + event.peer->data = (void *)-1; + break; + }; + }; + }; + sendworldstate(); +}; + +void cleanupserver() +{ + if(serverhost) enet_host_destroy(serverhost); +}; + +void localdisconnect() +{ + loopv(clients) if(clients[i]->type==ST_LOCAL) zapclient(i); +}; + +void localconnect() +{ + client &c = addclient(); + c.type = ST_LOCAL; + s_strcpy(c.hostname, "local"); + send_welcome(c.clientnum); +}; + +void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master, char *passwd, int maxcl, char *maprot, char *masterpwd) // EDIT: AH +{ + serverpassword = passwd; + maxclients = maxcl; + servermsinit(master ? master : "masterserver.cubers.net/cgi-bin/actioncube.pl/", sdesc, dedicated); + + if(isdedicated = dedicated) + { + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT }; + if(*ip && enet_address_set_host(&address, ip)<0) printf("WARNING: server ip not resolved"); + serverhost = enet_host_create(&address, maxclients, 0, uprate); + if(!serverhost) fatal("could not create server host\n"); + loopi(maxclients) serverhost->peers[i].data = (void *)-1; + if(!maprot || !maprot[0]) maprot = newstring("config/maprot.cfg"); + readscfg(path(maprot)); // EDIT: AH + if(masterpwd && masterpwd[0]) masterpasswd = masterpwd; + }; + + resetserverifempty(); + + if(isdedicated) // do not return, this becomes main loop + { + #ifdef WIN32 + SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); + #endif + printf("dedicated server started, waiting for clients...\nCtrl-C to exit\n\n"); + atexit(cleanupserver); + atexit(enet_deinitialize); + for(;;) serverslice(/*enet_time_get_sec()*/time(NULL), 5); + }; +}; diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp new file mode 100644 index 00000000..2b48fa56 --- /dev/null +++ b/source/src/serverbrowser.cpp @@ -0,0 +1,375 @@ +// serverbrowser.cpp: eihrul's concurrent resolver, and server browser window management + +#include "cube.h" +#include "SDL_thread.h" + +struct resolverthread +{ + SDL_Thread *thread; + const char *query; + int starttime; +}; + +struct resolverresult +{ + const char *query; + ENetAddress address; +}; + +vector resolverthreads; +vector resolverqueries; +vector resolverresults; +SDL_mutex *resolvermutex; +SDL_cond *querycond, *resultcond; + +#define RESOLVERTHREADS 1 +#define RESOLVERLIMIT 3000 + +int resolverloop(void * data) +{ + resolverthread *rt = (resolverthread *)data; + SDL_LockMutex(resolvermutex); + SDL_Thread *thread = rt->thread; + SDL_UnlockMutex(resolvermutex); + if(!thread || SDL_GetThreadID(thread) != SDL_ThreadID()) + return 0; + while(thread == rt->thread) + { + SDL_LockMutex(resolvermutex); + while(resolverqueries.empty()) SDL_CondWait(querycond, resolvermutex); + rt->query = resolverqueries.pop(); + rt->starttime = lastmillis; + SDL_UnlockMutex(resolvermutex); + + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; + enet_address_set_host(&address, rt->query); + + SDL_LockMutex(resolvermutex); + if(thread == rt->thread) + { + resolverresult &rr = resolverresults.add(); + rr.query = rt->query; + rr.address = address; + rt->query = NULL; + rt->starttime = 0; + SDL_CondSignal(resultcond); + }; + SDL_UnlockMutex(resolvermutex); + }; + return 0; +}; + +void resolverinit() +{ + resolvermutex = SDL_CreateMutex(); + querycond = SDL_CreateCond(); + resultcond = SDL_CreateCond(); + + SDL_LockMutex(resolvermutex); + loopi(RESOLVERTHREADS) + { + resolverthread &rt = resolverthreads.add(); + rt.query = NULL; + rt.starttime = 0; + rt.thread = SDL_CreateThread(resolverloop, &rt); + }; + SDL_UnlockMutex(resolvermutex); +}; + +void resolverstop(resolverthread &rt) +{ + SDL_LockMutex(resolvermutex); + if(rt.query) + { +#ifndef __APPLE__ + SDL_KillThread(rt.thread); +#endif + rt.thread = SDL_CreateThread(resolverloop, &rt); + }; + rt.query = NULL; + rt.starttime = 0; + SDL_UnlockMutex(resolvermutex); +}; + +void resolverclear() +{ + if(resolverthreads.empty()) return; + + SDL_LockMutex(resolvermutex); + resolverqueries.setsize(0); + resolverresults.setsize(0); + loopv(resolverthreads) + { + resolverthread &rt = resolverthreads[i]; + resolverstop(rt); + }; + SDL_UnlockMutex(resolvermutex); +}; + +void resolverquery(const char *name) +{ + if(resolverthreads.empty()) resolverinit(); + + SDL_LockMutex(resolvermutex); + resolverqueries.add(name); + SDL_CondSignal(querycond); + SDL_UnlockMutex(resolvermutex); +}; + +bool resolvercheck(const char **name, ENetAddress *address) +{ + bool resolved = false; + SDL_LockMutex(resolvermutex); + if(!resolverresults.empty()) + { + resolverresult &rr = resolverresults.pop(); + *name = rr.query; + address->host = rr.address.host; + resolved = true; + } + else loopv(resolverthreads) + { + resolverthread &rt = resolverthreads[i]; + if(rt.query && lastmillis - rt.starttime > RESOLVERLIMIT) + { + resolverstop(rt); + *name = rt.query; + resolved = true; + }; + }; + SDL_UnlockMutex(resolvermutex); + return resolved; +}; + +bool resolverwait(const char *name, ENetAddress *address) +{ + if(resolverthreads.empty()) resolverinit(); + + s_sprintfd(text)("resolving %s... (esc to abort)", name); + show_out_of_renderloop_progress(0, text); + + SDL_LockMutex(resolvermutex); + resolverqueries.add(name); + SDL_CondSignal(querycond); + int starttime = SDL_GetTicks(), timeout = 0; + bool resolved = false; + for(;;) + { + SDL_CondWaitTimeout(resultcond, resolvermutex, 250); + loopv(resolverresults) if(resolverresults[i].query == name) + { + address->host = resolverresults[i].address.host; + resolverresults.remove(i); + resolved = true; + break; + }; + if(resolved) break; + + timeout = SDL_GetTicks() - starttime; + show_out_of_renderloop_progress(min(float(timeout)/RESOLVERLIMIT, 1), text); + SDL_Event event; + while(SDL_PollEvent(&event)) + { + if(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) timeout = RESOLVERLIMIT + 1; + }; + + if(timeout > RESOLVERLIMIT) break; + }; + if(!resolved && timeout > RESOLVERLIMIT) + { + loopv(resolverthreads) + { + resolverthread &rt = resolverthreads[i]; + if(rt.query == name) { resolverstop(rt); break; }; + }; + }; + SDL_UnlockMutex(resolvermutex); + return resolved; +}; + +struct serverinfo +{ + string name; + string full; + string map; + string sdesc; + int mode, numplayers, ping, protocol, minremain, resolved; + ENetAddress address; +}; + +enum { UNRESOLVED = 0, RESOLVING, RESOLVED }; + +vector servers; +ENetSocket pingsock = ENET_SOCKET_NULL; +int lastinfo = 0; + +char *getservername(int n) { return servers[n].name; }; + +void addserver(char *servername) +{ + loopv(servers) if(strcmp(servers[i].name, servername)==0) return; + serverinfo &si = servers.insert(0, serverinfo()); + s_strcpy(si.name, servername); + si.full[0] = 0; + si.mode = 0; + si.numplayers = 0; + si.ping = 9999; + si.protocol = 0; + si.minremain = 0; + si.map[0] = 0; + si.sdesc[0] = 0; + si.resolved = UNRESOLVED; + si.address.host = ENET_HOST_ANY; + si.address.port = CUBE_SERVINFO_PORT; +}; + +void pingservers() +{ + ENetBuffer buf; + uchar ping[MAXTRANS]; + loopv(servers) + { + serverinfo &si = servers[i]; + if(si.address.host == ENET_HOST_ANY) continue; + ucharbuf p(ping, sizeof(ping)); + putint(p, lastmillis); + buf.data = ping; + buf.dataLength = p.length(); + enet_socket_send(pingsock, &si.address, &buf, 1); + }; + lastinfo = lastmillis; +}; + +void checkresolver() +{ + int resolving = 0; + loopv(servers) + { + serverinfo &si = servers[i]; + if(si.resolved == RESOLVED) continue; + if(si.address.host == ENET_HOST_ANY) + { + if(si.resolved == UNRESOLVED) { si.resolved = RESOLVING; resolverquery(si.name); }; + resolving++; + }; + }; + if(!resolving) return; + + const char *name = NULL; + ENetAddress addr = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; + while(resolvercheck(&name, &addr)) + { + loopv(servers) + { + serverinfo &si = servers[i]; + if(name == si.name) + { + si.resolved = RESOLVED; + si.address = addr; + addr.host = ENET_HOST_ANY; + break; + } + } + } +} + +void checkpings() +{ + enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; + ENetBuffer buf; + ENetAddress addr; + uchar ping[MAXTRANS]; + char text[MAXTRANS]; + buf.data = ping; + buf.dataLength = sizeof(ping); + while(enet_socket_wait(pingsock, &events, 0) >= 0 && events) + { + int len = enet_socket_receive(pingsock, &addr, &buf, 1); + if(len <= 0) return; + loopv(servers) + { + serverinfo &si = servers[i]; + if(addr.host == si.address.host) + { + ucharbuf p(ping, len); + si.ping = lastmillis - getint(p); + si.protocol = getint(p); + if(si.protocol!=PROTOCOL_VERSION) si.ping = 9998; + si.mode = getint(p); + si.numplayers = getint(p); + si.minremain = getint(p); + getstring(text, p); + s_strcpy(si.map, text); + getstring(text, p); + s_strcpy(si.sdesc, text); + break; + }; + }; + }; +}; + +int sicompare(const serverinfo *a, const serverinfo *b) +{ + return a->ping>b->ping ? 1 : (a->pingping ? -1 : strcmp(a->name, b->name)); +}; + +void refreshservers() +{ + checkresolver(); + checkpings(); + if(lastmillis - lastinfo >= 5000) pingservers(); + servers.sort(sicompare); + int maxmenu = 16; + loopv(servers) + { + serverinfo &si = servers[i]; + if(si.address.host != ENET_HOST_ANY && si.ping != 9999) + { + if(si.protocol!=PROTOCOL_VERSION) s_sprintf(si.full)("%s [different cube protocol]", si.name); + else s_sprintf(si.full)("%d\t%d\t%s, %s: %s %s", si.ping, si.numplayers, si.map[0] ? si.map : "[unknown]", modestr(si.mode), si.name, si.sdesc); + } + else + { + s_sprintf(si.full)(si.address.host != ENET_HOST_ANY ? "%s [waiting for server response]" : "%s [unknown host]\t", si.name); + } + si.full[50] = 0; // cut off too long server descriptions + menumanual(1, i, si.full); + if(!--maxmenu) return; + }; +}; + +void servermenu() +{ + if(pingsock == ENET_SOCKET_NULL) + { + pingsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM, NULL); + resolverinit(); + }; + resolverclear(); + loopv(servers) resolverquery(servers[i].name); + refreshservers(); + menuset(1); +}; + +void updatefrommaster() +{ + const int MAXUPD = 32000; + uchar buf[MAXUPD]; + uchar *reply = retrieveservers(buf, MAXUPD); + if(!*reply || strstr((char *)reply, "") || strstr((char *)reply, "")) conoutf("master server not replying"); + else { servers.setsize(0); execute((char *)reply); }; + servermenu(); +}; + +COMMAND(addserver, ARG_1STR); +COMMAND(servermenu, ARG_NONE); +COMMAND(updatefrommaster, ARG_NONE); + +void writeservercfg() +{ + FILE *f = fopen("config/servers.cfg", "w"); + if(!f) return; + fprintf(f, "// servers connected to are added here automatically\n\n"); + loopvrev(servers) fprintf(f, "addserver %s\n", servers[i].name); + fclose(f); +}; diff --git a/source/src/serverms.cpp b/source/src/serverms.cpp new file mode 100644 index 00000000..b6a4d190 --- /dev/null +++ b/source/src/serverms.cpp @@ -0,0 +1,147 @@ +// all server side masterserver and pinging functionality + +#include "cube.h" + +#ifdef STANDALONE +bool resolverwait(const char *name, ENetAddress *address) +{ + return enet_address_set_host(address, name) >= 0; +}; +#endif + +ENetSocket mssock = ENET_SOCKET_NULL; + +void httpgetsend(ENetAddress &ad, char *hostname, char *req, char *ref, char *agent) +{ + if(ad.host==ENET_HOST_ANY) + { + printf("looking up %s...\n", hostname); + if(!resolverwait(hostname, &ad)) return; + }; + if(mssock!=ENET_SOCKET_NULL) enet_socket_destroy(mssock); + mssock = enet_socket_create(ENET_SOCKET_TYPE_STREAM, NULL); + if(mssock==ENET_SOCKET_NULL) { printf("could not open socket\n"); return; }; + if(enet_socket_connect(mssock, &ad)<0) { printf("could not connect\n"); return; }; + ENetBuffer buf; + s_sprintfd(httpget)("GET %s HTTP/1.0\nHost: %s\nReferer: %s\nUser-Agent: %s\n\n", req, hostname, ref, agent); + buf.data = httpget; + buf.dataLength = strlen((char *)buf.data); + printf("sending request to %s...\n", hostname); + enet_socket_send(mssock, NULL, &buf, 1); +}; + +void httpgetrecieve(ENetBuffer &buf) +{ + if(mssock==ENET_SOCKET_NULL) return; + enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; + if(enet_socket_wait(mssock, &events, 0) >= 0 && events) + { + int len = enet_socket_receive(mssock, NULL, &buf, 1); + if(len<=0) + { + enet_socket_destroy(mssock); + mssock = ENET_SOCKET_NULL; + return; + }; + buf.data = ((char *)buf.data)+len; + ((char*)buf.data)[0] = 0; + buf.dataLength -= len; + }; +}; + +uchar *stripheader(uchar *b) +{ + char *s = strstr((char *)b, "\n\r\n"); + if(!s) s = strstr((char *)b, "\n\n"); + return s ? (uchar *)s : b; +}; + +ENetAddress masterserver = { ENET_HOST_ANY, 80 }; +int updmaster = 0; +string masterbase; +string masterpath; +uchar masterrep[MAXTRANS]; +ENetBuffer masterb; + +void updatemasterserver(int seconds) +{ + if(seconds>updmaster) // send alive signal to masterserver every hour of uptime + { + s_sprintfd(path)("%sregister.do?action=add", masterpath); + httpgetsend(masterserver, masterbase, path, "actioncubeserver", "ActionCube Server"); + masterrep[0] = 0; + masterb.data = masterrep; + masterb.dataLength = MAXTRANS-1; + updmaster = seconds+60*60; + }; +}; + +void checkmasterreply() +{ + bool busy = mssock!=ENET_SOCKET_NULL; + httpgetrecieve(masterb); + if(busy && mssock==ENET_SOCKET_NULL) printf("masterserver reply: %s\n", stripheader(masterrep)); +}; + +uchar *retrieveservers(uchar *buf, int buflen) +{ + s_sprintfd(path)("%sretrieve.do?item=list", masterpath); + httpgetsend(masterserver, masterbase, path, "actioncubeserver", "ActionCube Server"); + ENetBuffer eb; + buf[0] = 0; + eb.data = buf; + eb.dataLength = buflen-1; + while(mssock!=ENET_SOCKET_NULL) httpgetrecieve(eb); + return stripheader(buf); +}; + +ENetSocket pongsock = ENET_SOCKET_NULL; +string serverdesc; + +void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds, bool isfull) +{ + checkmasterreply(); + updatemasterserver(seconds); + + // reply all server info requests + ENetBuffer buf; + ENetAddress addr; + uchar pong[MAXTRANS]; + int len; + enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; + buf.data = pong; + while(enet_socket_wait(pongsock, &events, 0) >= 0 && events) + { + buf.dataLength = sizeof(pong); + len = enet_socket_receive(pongsock, &addr, &buf, 1); + if(len < 0) return; + ucharbuf p(&pong[len], sizeof(pong)-len); + putint(p, PROTOCOL_VERSION); + putint(p, mode); + putint(p, numplayers); + putint(p, minremain); + string mname; + s_strcpy(mname, isfull ? "[FULL] " : ""); + s_strcat(mname, smapname); + sendstring(mname, p); + sendstring(serverdesc, p); + buf.dataLength = len + p.length(); + enet_socket_send(pongsock, &addr, &buf, 1); + }; +}; + +void servermsinit(const char *master, char *sdesc, bool listen) +{ + const char *mid = strstr(master, "/"); + if(!mid) mid = master; + s_strcpy(masterpath, mid); + s_strncpy(masterbase, master, mid-master+1); + s_strcpy(serverdesc, sdesc); + + if(listen) + { + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; + pongsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM, &address); + if(pongsock == ENET_SOCKET_NULL) fatal("could not create server info socket\n"); + }; +}; diff --git a/source/src/serverutil.cpp b/source/src/serverutil.cpp new file mode 100644 index 00000000..4a0a7a9e --- /dev/null +++ b/source/src/serverutil.cpp @@ -0,0 +1,178 @@ +// misc useful functions used by the server + +#include "cube.h" + +// all network traffic is in 32bit ints, which are then compressed using the following simple scheme (assumes that most values are small). + +void putint(ucharbuf &p, int n) +{ + if(n<128 && n>-127) p.put(n); + else if(n<0x8000 && n>=-0x8000) { p.put(0x80); p.put(n); p.put(n>>8); } + else { p.put(0x81); p.put(n); p.put(n>>8); p.put(n>>16); p.put(n>>24); }; +}; + +int getint(ucharbuf &p) +{ + int c = (char)p.get(); + if(c==-128) { int n = p.get(); n |= char(p.get())<<8; return n; } + else if(c==-127) { int n = p.get(); n |= p.get()<<8; n |= p.get()<<16; return n|(p.get()<<24); } + else return c; +}; + +// much smaller encoding for unsigned integers up to 28 bits, but can handle signed +void putuint(ucharbuf &p, int n) +{ + if(n < 0 || n >= (1<<21)) + { + p.put(0x80 | (n & 0x7F)); + p.put(0x80 | ((n >> 7) & 0x7F)); + p.put(0x80 | ((n >> 14) & 0x7F)); + p.put(n >> 21); + } + else if(n < (1<<7)) p.put(n); + else if(n < (1<<14)) + { + p.put(0x80 | (n & 0x7F)); + p.put(n >> 7); + } + else + { + p.put(0x80 | (n & 0x7F)); + p.put(0x80 | ((n >> 7) & 0x7F)); + p.put(n >> 14); + }; +}; + +int getuint(ucharbuf &p) +{ + int n = p.get(); + if(n & 0x80) + { + n += (p.get() << 7) - 0x80; + if(n & (1<<14)) n += (p.get() << 14) - (1<<14); + if(n & (1<<21)) n += (p.get() << 21) - (1<<21); + if(n & (1<<28)) n |= 0xF0000000; + }; + return n; +}; + +void sendstring(const char *t, ucharbuf &p) +{ + while(*t) putint(p, *t++); + putint(p, 0); +}; + +void getstring(char *text, ucharbuf &p, int len) +{ + char *t = text; + do + { + if(t>=&text[len]) { text[len-1] = 0; return; }; + if(!p.remaining()) { *t = 0; return; }; + *t = getint(p); + } + while(*t++); +}; + +const char *modenames[] = +{ + "team deathmatch", "coopedit", "deathmatch", "survior", + "team survior", "ctf", "pistols frenzy", "bot team deathmatch", "bot deathmatch", "last swiss standing", +}; + +//const char *modestr(int n) { return (n>=-2 && n<12) ? modenames[n+2] : "unknown"; }; +const char *modestr(int n) { return (n>=0 && n<=9) ? modenames[n] : "unknown"; }; + +char msgsizesl[] = // size inclusive message token, 0 for variable or not-checked sizes +{ + SV_INITS2C, 4, SV_INITC2S, 0, SV_POS, 0, SV_TEXT, 0, SV_SOUND, 2, SV_CDIS, 2, + SV_GIBDIED, 2, SV_DIED, 2, SV_GIBDAMAGE, 4, SV_DAMAGE, 4, SV_SHOT, 9, SV_FRAGS, 2, SV_RESUME, 3, + SV_TIMEUP, 2, SV_EDITENT, 10, SV_MAPRELOAD, 2, SV_ITEMACC, 2, + SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 3, SV_DENIED, 2, + SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2, + SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6, + SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2, + SV_MODELSKIN, 2, + SV_FLAGPICKUP, 2, SV_FLAGDROP, 2, SV_FLAGRETURN, 2, SV_FLAGSCORE, 2, SV_FLAGINFO, 0, SV_FLAGS, 2, // EDIT: AH + // Added by Rick: Bot specific messages + SV_BOTSOUND, 3, SV_BOTDIS, 2, SV_BOTDIED, 4, SV_CLIENT2BOTDMG, 4, SV_BOT2BOTDMG, 2, + SV_BOTFRAGS, 3, SV_ADDBOT, 5, SV_BOTUPDATE, 12, SV_BOTCOMMAND, 0, + // End add + SV_BOTITEMPICKUP, 3, SV_BOT2CLIENTDMG, 5, SV_DIEDBYBOT, 2, + SV_GETMASTER, 0, SV_MASTERCMD, 3, + SV_PWD, 0, + SV_NOP, 1, + SV_EXT, 0, + -1 +}; + +char msgsizelookup(int msg) +{ + for(char *p = msgsizesl; *p>=0; p += 2) if(*p==msg) return p[1]; + return -1; +}; + +// sending of maps between clients + +string copyname; +int copysize; +uchar *copydata = NULL; + +void sendmaps(int n, string mapname, int mapsize, uchar *mapdata) +{ + if(mapsize <= 0 || mapsize > 256*256) return; + s_strcpy(copyname, mapname); + copysize = mapsize; + DELETEA(copydata); + copydata = new uchar[mapsize]; + memcpy(copydata, mapdata, mapsize); +} + +ENetPacket *recvmap(int n) +{ + if(!copydata) return NULL; + ENetPacket *packet = enet_packet_create(NULL, MAXTRANS + copysize, ENET_PACKET_FLAG_RELIABLE); + ucharbuf p(packet->data, packet->dataLength); + putint(p, SV_RECVMAP); + sendstring(copyname, p); + putint(p, copysize); + p.put(copydata, copysize); + enet_packet_resize(packet, p.length()); + return packet; +} + +#ifdef STANDALONE + +void localservertoclient(int chan, uchar *buf, int len) {}; +void fatal(char *s, char *o) { cleanupserver(); printf("servererror: %s\n", s); exit(1); }; + +int main(int argc, char* argv[]) // EDIT: AH +{ + int uprate = 0, maxcl = 4; + char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *masterpwd = NULL; + + for(int i = 1; i 255 || musicvol < 0) return; + musicvol = vol; + if(nosound) return; + #ifdef USE_MIXER + if(mod) Mix_VolumeMusic((musicvol*MAXVOL)/255); + #else + if(mod) FMUSIC_SetMasterVolume(mod, musicvol); + else if(stream && musicchan>=0) FSOUND_SetVolume(musicchan, (musicvol*MAXVOL)/255); + #endif +} + +COMMANDN(musicvol, setmusicvol, ARG_1INT); + +void stopsound() +{ + if(nosound) return; + if(mod) + { + #ifdef USE_MIXER + Mix_HaltMusic(); + Mix_FreeMusic(mod); + #else + FMUSIC_FreeSong(mod); + #endif + mod = NULL; + }; + if(stream) + { + #ifndef USE_MIXER + FSOUND_Stream_Close(stream); + #endif + stream = NULL; + }; +}; + +VAR(soundbufferlen, 128, 1024, 4096); + +void initsound() +{ + memset(soundlocs, 0, sizeof(soundloc)*MAXCHAN); + #ifdef USE_MIXER + if(Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen)<0) + { + conoutf("sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); + nosound = true; + }; + Mix_AllocateChannels(MAXCHAN); + #else + if(FSOUND_GetVersion()=0) { FSOUND_SetVolume(chan, (musicvol*MAXVOL)/255); FSOUND_SetPaused(chan, false); }; + } + #endif + else + { + conoutf("could not play music: %s", sn); + }; + + }; +}; + +COMMAND(music, ARG_1STR); + + +#ifdef USE_MIXER +vector samples; +#else +vector samples; +#endif + +cvector snames; + +int registersound(char *name) +{ + loopv(snames) if(strcmp(snames[i], name)==0) return i; + snames.add(newstring(name)); + samples.add(NULL); + return samples.length()-1; +}; + +COMMAND(registersound, ARG_1EST); + +void cleansound() +{ + if(nosound) return; + stopsound(); + #ifdef USE_MIXER + Mix_CloseAudio(); + #else + FSOUND_Close(); + #endif +}; + +VAR(stereo, 0, 1, 1); + +void updatechanvol(int chan, vec *loc) +{ + int vol = soundvol, pan = 255/2; + if(loc) + { + vdist(dist, v, *loc, player1->o); + vol -= (int)(dist*3*soundvol/255); // simple mono distance attenuation + if(vol<0) vol = 0; + if(stereo && (v.x != 0 || v.y != 0)) + { + float yaw = -atan2(v.x, v.y) - player1->yaw*(PI / 180.0f); // relative angle of sound along X-Y axis + pan = int(255.9f*(0.5*sin(yaw)+0.5f)); // range is from 0 (left) to 255 (right) + }; + }; + vol = (vol*MAXVOL)/255; + #ifdef USE_MIXER + Mix_Volume(chan, vol); + Mix_SetPanning(chan, 255-pan, pan); + #else + FSOUND_SetVolume(chan, vol); + FSOUND_SetPan(chan, pan); + #endif +}; + +void newsoundloc(int chan, vec *loc) +{ + ASSERT(chan>=0 && chano); +} +// End add by Rick + +int soundsatonce = 0, lastsoundmillis = 0; + +void playsound(int n, vec *loc) +{ + if(nosound) return; + if(!soundvol) return; + if(n==S_NULL) return; + if(lastmillis==lastsoundmillis) soundsatonce++; else soundsatonce = 1; + lastsoundmillis = lastmillis; + if(soundsatonce>5) return; // avoid bursts of sounds with heavy packetloss and in sp + if(n<0 || n>=samples.length()) { conoutf("unregistered sound: %d", n); return; }; + + if(!samples[n]) + { + s_sprintfd(buf)("packages/audio/sounds/%s.wav", snames[n]); + + #ifdef USE_MIXER + samples[n] = Mix_LoadWAV(path(buf)); + #else + samples[n] = FSOUND_Sample_Load(n, path(buf), FSOUND_LOOP_OFF, 0, 0); + #endif + + if(!samples[n]) { conoutf("failed to load sample: %s", buf); return; }; + }; + + #ifdef USE_MIXER + int chan = Mix_PlayChannel(-1, samples[n], 0); + #else + int chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[n], NULL, true); + #endif + if(chan<0) return; + if(loc) newsoundloc(chan, loc); + updatechanvol(chan, loc); + #ifndef USE_MIXER + FSOUND_SetPaused(chan, false); + #endif +}; + +void sound(int n) { playsound(n, NULL); }; +COMMAND(sound, ARG_1INT); diff --git a/source/src/tools.cpp b/source/src/tools.cpp new file mode 100644 index 00000000..d7e9d7a6 --- /dev/null +++ b/source/src/tools.cpp @@ -0,0 +1,48 @@ +// implementation of generic tools + +#include "cube.h" + +//////////////////////////// pool /////////////////////////// + +///////////////////////// misc tools /////////////////////// + +char *path(char *s) +{ + for(char *t = s; t = strpbrk(t, "/\\"); *t++ = PATHDIV); + return s; +}; + +char *loadfile(char *fn, int *size) +{ + FILE *f = fopen(fn, "rb"); + if(!f) return NULL; + fseek(f, 0, SEEK_END); + int len = ftell(f); + if(len<=0) { fclose(f); return NULL; }; + fseek(f, 0, SEEK_SET); + char *buf = new char[len+1]; + if(!buf) { fclose(f); return NULL; }; + buf[len] = 0; + size_t rlen = fread(buf, 1, len, f); + fclose(f); + if(size_t(len)!=rlen) + { + delete[] buf; + return NULL; + }; + if(size!=NULL) *size = len; + return buf; +}; + +void endianswap(void *memory, int stride, int length) // little endian as storage format +{ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + loop(w, length) loop(i, stride/2) + { + uchar *p = (uchar *)memory+w*stride; + uchar t = p[i]; + p[i] = p[stride-i-1]; + p[stride-i-1] = t; + }; +#endif +} diff --git a/source/src/tools.h b/source/src/tools.h new file mode 100644 index 00000000..98b46ed6 --- /dev/null +++ b/source/src/tools.h @@ -0,0 +1,438 @@ +// generic useful stuff for any C++ program + +#ifndef _TOOLS_H +#define _TOOLS_H + +#ifdef NULL +#undef NULL +#endif +#define NULL 0 + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; + +#ifdef _DEBUG +#ifdef __GNUC__ +#define ASSERT(c) if(!(c)) { asm("int $3"); }; +#else +#define ASSERT(c) if(!(c)) { __asm int 3 }; +#endif +#else +#define ASSERT(c) if(c) {}; +#endif + +#define swap(t,a,b) { t m=a; a=b; b=m; } +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#define rnd(max) (rand()%(max)) +#define rndreset() (srand(1)) +#define rndtime() { loopi(lastmillis&0xF) rnd(i+1); } + +#define loop(v,m) for(int v = 0; v void _swap(T &a, T &b) { T t = a; a = b; b = t; }; + + + +extern char *path(char *s); +extern char *parentdir(char *directory); +extern char *loadfile(char *fn, int *size); +extern void endianswap(void *, int, int); +extern void seedMT(uint seed); +extern uint randomMT(void); + +#define loopv(v) if(false) {} else for(int i = 0; i<(v).length(); i++) +#define loopvj(v) if(false) {} else for(int j = 0; j<(v).length(); j++) +#define loopvk(v) if(false) {} else for(int k = 0; k<(v).length(); k++) +#define loopvrev(v) if(false) {} else for(int i = (v).length()-1; i>=0; i--) + +template struct vector +{ + T *buf; + int alen; + int ulen; + + vector() + { + alen = 8; + buf = (T *)new uchar[alen*sizeof(T)]; + ulen = 0; + }; + vector(const vector &v) + { + alen = v.length(); + buf = (T *)new uchar[alen*sizeof(T)]; + ulen = 0; + *this = v; + }; + + ~vector() { setsize(0); delete[] (uchar *)buf; }; + + vector &operator=(const vector &v) + { + setsize(0); + loopv(v) add(v[i]); + return *this; + }; + + T &add(const T &x) + { + if(ulen==alen) vrealloc(); + new (&buf[ulen]) T(x); + return buf[ulen++]; + }; + + T &add() + { + if(ulen==alen) vrealloc(); + new (&buf[ulen]) T; + return buf[ulen++]; + }; + + bool inrange(size_t i) const { return i=0 && i=0 && i= 0 && ii) drop(); }; + void setsizenodelete(int i) { ASSERT(i<=ulen); ulen = i; }; + + void deletecontentsp() { while(!empty()) delete pop(); }; + void deletecontentsa() { while(!empty()) delete[] pop(); }; + + T *getbuf() { return buf; }; + const T *getbuf() const { return buf; }; + + template + void sort(int (__cdecl *cf)(ST *, ST *), int i = 0, int n = -1) { qsort(&buf[i], n<0?ulen:n, sizeof(T), (int (__cdecl *)(const void *,const void *))cf); }; + + void *_realloc(void *p, int oldsize, int newsize) + { + void *np = new uchar[newsize]; + if(!oldsize) return np; + memcpy(np, p, newsize>oldsize ? oldsize : newsize); + delete[] (char *)p; + return np; + }; + + void vrealloc() + { + int olen = alen; + buf = (T *)_realloc(buf, olen*sizeof(T), (alen *= 2)*sizeof(T)); + }; + + void remove(int i, int n) + { + for(int p = i+n; pi; p--) buf[p] = buf[p-1]; + buf[i] = e; + return buf[i]; + }; +}; + +typedef vector cvector; +typedef vector ivector; +typedef vector usvector; + +static inline uint hthash(const char *key) +{ + uint h = 5381; + for(int i = 0, k; (k = key[i]); i++) h = ((h<<5)+h)^k; // bernstein k=33 xor + return h; +}; + +static inline bool htcmp(const char *x, const char *y) +{ + return !strcmp(x, y); +}; + +static inline uint hthash(int key) +{ + return key; +}; + +static inline bool htcmp(int x, int y) +{ + return x==y; +}; + +static inline uint hthash(uint key) +{ + return key; +}; + +static inline bool htcmp(uint x, uint y) +{ + return x==y; +}; + +template struct hashtable +{ + typedef K key; + typedef const K const_key; + typedef T value; + typedef const T const_value; + + enum { CHUNKSIZE = 16 }; + + struct chain { T data; K key; chain *next; }; + struct chainchunk { chain chunks[CHUNKSIZE]; chainchunk *next; }; + + int size; + int numelems; + chain **table; + chain *enumc; + + int chunkremain; + chainchunk *lastchunk; + + hashtable(int size = 1<<10) + : size(size) + { + numelems = 0; + chunkremain = 0; + lastchunk = NULL; + table = new chain *[size]; + loopi(size) table[i] = NULL; + }; + + ~hashtable() + { + DELETEA(table); + }; + + chain *insert(const K &key, uint h) + { + if(!chunkremain) + { + chainchunk *chunk = new chainchunk; + chunk->next = lastchunk; + lastchunk = chunk; + chunkremain = CHUNKSIZE; + } + chain *c = &lastchunk->chunks[--chunkremain]; + c->key = key; + c->next = table[h]; + table[h] = c; + numelems++; + return c; + }; + + chain *find(const K &key, bool doinsert) + { + uint h = hthash(key)&(size-1); + for(chain *c = table[h]; c; c = c->next) + { + if(htcmp(key, c->key)) return c; + } + if(doinsert) return insert(key, h); + return NULL; + }; + + T *access(const K &key, const T *data = NULL) + { + chain *c = find(key, data != NULL); + if(data) c->data = *data; + if(c) return &c->data; + return NULL; + }; + + T &operator[](const K &key) + { + return find(key, true)->data; + }; + + void clear() + { + loopi(size) + { + /* + for(chain *c = table[i], *next; c; c = next) + { + next = c->next; + delete c; + };*/ + table[i] = NULL; + }; + numelems = 0; + chunkremain = 0; + for(chainchunk *chunk; lastchunk; lastchunk = chunk) + { + chunk = lastchunk->next; + delete lastchunk; + } + }; +}; + +#define enumeratekt(ht,k,e,t,f,b) loopi((ht).size) for(hashtable::chain *enumc = (ht).table[i]; enumc; enumc = enumc->next) { hashtable::const_key &e = enumc->key; t &f = enumc->data; b; } +#define enumerate(ht,t,e,b) loopi((ht).size) for((ht).enumc = (ht).table[i]; (ht).enumc; (ht).enumc = (ht).enumc->next) { t &e = (ht).enumc->data; b; } + +inline char *newstring(size_t l) { return new char[l+1]; }; +inline char *newstring(const char *s, size_t l) { return s_strncpy(newstring(l), s, l+1); }; +inline char *newstring(const char *s) { return newstring(s, strlen(s)); }; +inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); }; + +template +struct databuf +{ + enum + { + OVERREAD = 1<<0, + OVERWROTE = 1<<1 + }; + + T *buf; + int len, maxlen; + uchar flags; + + databuf(T *buf, int maxlen) : buf(buf), len(0), maxlen(maxlen), flags(0) {}; + + const T &get() + { + static T overreadval; + if(len charbuf; +typedef databuf ucharbuf; + +#ifndef __GNUC__ +#ifdef _DEBUG +//#define _CRTDBG_MAP_ALLOC +#include +inline void *__cdecl operator new(size_t n, const char *fn, int l) { return ::operator new(n, 1, fn, l); }; +inline void __cdecl operator delete(void *p, const char *fn, int l) { ::operator delete(p, 1, fn, l); }; +#define new new(__FILE__,__LINE__) +#endif +#endif + + +#endif + diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp new file mode 100644 index 00000000..53a375b3 --- /dev/null +++ b/source/src/weapon.cpp @@ -0,0 +1,727 @@ +// weapon.cpp: all shooting and effects code + +#include "cube.h" + +struct guninfo { short sound, reload, reloadtime, attackdelay, damage, projspeed, part, spread, recoil, magsize, mdl_kick_rot, mdl_kick_back; bool isauto; char *name; }; + +const int SGRAYS = 20; //down from 20 (default) +const float SGSPREAD = 2; +vec sg[SGRAYS]; + +//change the particales +guninfo guns[NUMGUNS] = +{ + { S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, false, "knife" }, + { S_PISTOL, S_RPISTOL, 1400, 170, 20, 0, 0, 80, 10, 8, 6, 5, false, "pistol" }, // *SGRAYS + { S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 6, 0, 0, 1, 35, 7, 9, 9, false, "shotgun" }, //reload time is for 1 shell from 7 too powerful to 6 + { S_SUBGUN, S_RSUBGUN, 1650, 80, 17, 0, 0, 70, 15, 30, 1, 2, true, "subgun" }, + { S_SNIPER, S_RSNIPER, 1950, 1500, 72, 0, 0, 60, 50, 5, 4, 4, false, "sniper" }, + { S_ASSAULT, S_RASSAULT, 2000, 130, /*20*/25, 0, 0, 20, 40, 20, 0, 2, true, "assault" }, //recoil was 44 + { S_NULL, S_NULL, 1000, 1200, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" }, +}; + +int nadetimer = 2000; // detonate after $ms +bool gun_changed = false; + +void checkweaponswitch() +{ + if(!player1->weaponchanging) return; + int timeprogress = lastmillis-player1->lastaction; + if(timeprogress>WEAPONCHANGE_TIME) { player1->weaponchanging = false; player1->lastaction = 0; } + else if(timeprogress>WEAPONCHANGE_TIME/2) + { + gun_changed = true; + if((!player1->akimbo && player1->akimbomillis && player1->nextweapon==GUN_PISTOL) || + (player1->akimbo && !player1->akimbomillis && player1->gunselect==GUN_PISTOL)) + player1->akimbo = !player1->akimbo; + player1->gunselect = player1->nextweapon; + }; +}; + +void weaponswitch(int gun) +{ + player1->weaponchanging = true; + player1->lastaction = player1->akimbolastaction[0] = player1->akimbolastaction[1] = lastmillis; + player1->nextweapon = gun; + playsound(S_GUNCHANGE); +}; + +void weapon(int gun) +{ + if(m_nogun && gun!=G_MELEE && gun!=G_GRENADE) return; + setscope(false); + if(NADE_IN_HAND || player1->reloading) return; + + gun %= G_NUM; + if(gun<0) gun = G_NUM+gun; + switch(gun) + { + case G_PRIMARY: gun=player1->primary; break; + case G_SECONDARY: gun=GUN_PISTOL; break; + case G_MELEE: gun=GUN_KNIFE; break; + case G_GRENADE: if(player1->mag[GUN_GRENADE]) gun=GUN_GRENADE; else return; + }; + + if(gun!=player1->gunselect) weaponswitch(gun); +}; + +void shiftweapon(int i) +{ + if(player1->weaponchanging) return; + int gun; + switch(player1->gunselect) + { + case GUN_KNIFE: gun=G_MELEE; break; + case GUN_PISTOL: gun=G_SECONDARY; break; + case GUN_GRENADE: gun=G_GRENADE; break; + default: gun=G_PRIMARY; break; + }; + gun += i; + weapon(gun); + for(int j = 0; j <= G_NUM && !player1->weaponchanging; j++) { gun += i > 0 ? 1 : -1; weapon(gun); } +} + +COMMAND(weapon, ARG_1INT); +COMMAND(shiftweapon, ARG_1INT); + +VAR(scopefov, 5, 50, 50); +bool scoped = false; +int oldfov = 100; + +void setscope(bool activate) +{ + if(activate == scoped) return; + if(activate) + { + oldfov = getvar("fov"); + setvar("fov", scopefov); + } + else + { + setvar("fov", oldfov); + } + scoped = activate; +} + +void altaction(int activate) +{ + //if(player1->gunselect == GUN_SNIPER && player1->state!=CS_DEAD) togglescope(); + if(player1->gunselect == GUN_SNIPER && player1->state!=CS_DEAD) setscope(activate); +} + +COMMAND(altaction, ARG_1INT); + +void reload(dynent *d) +{ + if(!d || d->reloading) return; + if(d == player1) setscope(false); + bool akimbo = d->gunselect==GUN_PISTOL && d->akimbo!=0; + + if(d->gunselect==GUN_KNIFE || d->gunselect==GUN_GRENADE) return; + if(akimbo && d->mag[d->gunselect]>=(guns[d->gunselect].magsize * 2)) return; + else if(d->mag[d->gunselect]>=guns[d->gunselect].magsize && d->akimbo==0) return; + if(d->ammo[d->gunselect]<=0) return; + + d->reloading = true; + d->lastaction = lastmillis; + d->akimbolastaction[0] = d->akimbolastaction[1] = lastmillis; + + d->gunwait = guns[d->gunselect].reloadtime; + + int a = guns[d->gunselect].magsize - d->mag[d->gunselect]; + if(d->gunselect==GUN_PISTOL && d->akimbo!=0) + a = guns[d->gunselect].magsize * 2 - d->mag[d->gunselect]; + + if (a >= d->ammo[d->gunselect]) + { + d->mag[d->gunselect] += d->ammo[d->gunselect]; + d->ammo[d->gunselect] = 0; + } + else + { + d->mag[d->gunselect] += a; + d->ammo[d->gunselect] -= a; + } + + if(akimbo) playsoundc(S_RAKIMBO); + else if(d->bIsBot) playsound(guns[d->gunselect].reload, &d->o); + else playsoundc(guns[d->gunselect].reload); +}; + +void selfreload() { reload(player1); }; +COMMANDN(reload, selfreload, ARG_NONE); + +int reloadtime(int gun) { return guns[gun].reloadtime; }; +int attackdelay(int gun) { return guns[gun].attackdelay; }; +int magsize(int gun) { return guns[gun].magsize; }; +int kick_rot(int gun) { return guns[gun].mdl_kick_rot; }; +int kick_back(int gun) { return guns[gun].mdl_kick_back; }; + + +void createrays(vec &from, vec &to) // create random spread of rays for the shotgun +{ + vdist(dist, dvec, from, to); + float f = dist*SGSPREAD/1000; + loopi(SGRAYS) + { + #define RNDD (rnd(101)-50)*f + vec r = { RNDD, RNDD, RNDD }; + sg[i] = to; + vadd(sg[i], r); + #undef RNDD + }; +}; + +//bool intersect(dynent *d, vec &from, vec &to) // if lineseg hits entity bounding box +bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box +{ + vec v = to, w = d->o, *p; + vsub(v, from); + vsub(w, from); + float c1 = dotprod(w, v); + + if(c1<=0) p = &from; + else + { + float c2 = dotprod(v, v); + if(c2<=c1) p = &to; + else + { + float f = c1/c2; + vmul(v, f); + vadd(v, from); + p = &v; + }; + }; + + return p->x <= d->o.x+d->radius + && p->x >= d->o.x-d->radius + && p->y <= d->o.y+d->radius + && p->y >= d->o.y-d->radius + && p->z <= d->o.z+d->aboveeye + && p->z >= d->o.z-d->eyeheight; +}; + +dynent *playerincrosshair() +{ + if(demoplayback) return NULL; + loopv(players) + { + dynent *o = players[i]; + if(!o) continue; + if(intersect(o, player1->o, worldpos)) return o; + }; + return NULL; +}; +// Added by Rick +dynent *botincrosshair() +{ + if(demoplayback) return NULL; + loopv(bots) + { + dynent *o = bots[i]; + if(!o) continue; + if(intersect(o, player1->o, worldpos)) return o; + }; + return NULL; +}; +// End add by Rick + +const int MAXPROJ = 100; +struct projectile { vec o, to; float speed; dynent *owner; int gun; bool inuse, local; }; +projectile projs[MAXPROJ]; + +void projreset() { loopi(MAXPROJ) projs[i].inuse = false; }; + +void newprojectile(vec &from, vec &to, float speed, bool local, dynent *owner, int gun) +{ + loopi(MAXPROJ) + { + projectile *p = &projs[i]; + if(p->inuse) continue; + p->inuse = true; + p->o = from; + p->to = to; + p->speed = speed; + p->local = local; + p->owner = owner; + p->gun = gun; + return; + }; +}; + +void hit(int target, int damage, dynent *d, dynent *at, bool gib=false) +{ + if(d==player1) selfdamage(damage, at==player1 ? -1 : -2, at, gib); + //else if(d->monsterstate) monsterpain(d, damage, at); + // Added by Rick: Let bots take damage + else if(d->pBot) d->pBot->BotPain(damage, at, gib); + else if(d->bIsBot) + { + int PlayerIndex = -1; + if (at->bIsBot) PlayerIndex = BotManager.GetBotIndex(at); + else + { + loopv(players) + { + if (!players[i]) continue; + + if (players[i] == at) + { + PlayerIndex = i; + break; + } + } + } + + int msgtype = (at->bIsBot) ? SV_BOT2BOTDMG : SV_CLIENT2BOTDMG; + addmsg(msgtype, "ri3", BotManager.GetBotIndex(d), damage, PlayerIndex); + playsound(S_PAIN1+rnd(5), &d->o); + } + // End add by Rick + //else { addmsg(SV_DAMAGE, "ri3", target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); }; Modified by Rick: Added IsBot and PlayerIndex to message + else + { + // Modified by Rick: Added IsBot and PlayerIndex to message + int PlayerIndex = -1; + if (at->bIsBot) + PlayerIndex = BotManager.GetBotIndex(at); + else + { + loopv(players) + { + if (!players[i]) + continue; + + if (players[i] == at) + { + PlayerIndex = i; + break; + } + } + } + if(at->bIsBot) addmsg(SV_BOT2CLIENTDMG, "ri4", target, damage, d->lifesequence, PlayerIndex); + else addmsg(gib ? SV_GIBDAMAGE : SV_DAMAGE, "ri3", target, damage, d->lifesequence); + playsound(S_PAIN1+rnd(5), &d->o); + }; + + particle_splash(3, damage, 1000, d->o); + demodamage(damage, d->o); +}; + +const float RL_RADIUS = 7; +const float RL_DAMRAD = 10; // hack + +void radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at) +{ + if(o->state!=CS_ALIVE) return; + vdist(dist, temp, v, o->o); + dist -= 2; // account for eye distance imprecision + if(distvel, temp); + }; +}; + +// Modified by Rick: Added notthisbot +void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster, int notthisbot, int qdam) +{ + particle_splash(0, 50, 300, v); + p->inuse = false; + if(p->gun!=GUN_GRENADE) + { + playsound(S_FEXPLODE, &v); + // no push? + } + else + { + //playsound(S_RLHIT, &v); + newsphere(v, RL_RADIUS, 0); + dodynlight(vold, v, 0, 0, p->owner); + if(!p->local) return; + radialeffect(player1, v, -1, qdam, p->owner); + loopv(players) + { + if(i==notthisplayer) continue; + dynent *o = players[i]; + if(!o) continue; + radialeffect(o, v, i, qdam, p->owner); + }; + // Added by Rick + loopv(bots) + { + if(i==notthisbot) continue; + dynent *o = bots[i]; + if(!o) continue; + radialeffect(o, v, i, qdam, p->owner); + } + // End add by Rick + //dvector &mv = getmonsters(); + //loopv(mv) if(i!=notthismonster) radialeffect(mv[i], v, i, qdam, p->owner); + }; +}; + +// Modified by Rick +// inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam) +inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int ib, int qdam) +{ + if(o->state!=CS_ALIVE) return; + if(intersect(o, p->o, v)) + { + // splash(p, v, p->o, i, im, qdam); Modified by Rick + splash(p, v, p->o, i, im, ib, qdam); + hit(i, qdam, o, p->owner, true); //fixme + }; +}; + +void moveprojectiles(float time) +{ + loopi(MAXPROJ) + { + projectile *p = &projs[i]; + if(!p->inuse) continue; + //int qdam = guns[p->gun].damage*(p->owner->quadmillis ? 4 : 1); + int qdam = guns[p->gun].damage; + vdist(dist, v, p->o, p->to); + float dtime = dist*1000/p->speed; + if(time>dtime) dtime = time; + vmul(v, time/dtime); + vadd(v, p->o) + if(p->local) + { + loopv(players) + { + dynent *o = players[i]; + if(!o) continue; + // projdamage(o, p, v, i, -1, qdam); Modified by Rick + projdamage(o, p, v, i, -1, -1, qdam); + }; + // Added by Rick: Damage bots aswell + loopv(bots) + { + dynent *o = bots[i]; + if(!o || (o == p->owner)) continue; + projdamage(o, p, v, -1, -1, i, qdam); + }; + // End add by Rick + // if(p->owner!=player1) projdamage(player1, p, v, -1, -1, qdam); Modified by Rick + if(p->owner!=player1) projdamage(player1, p, v, -1, -1, -1, qdam); + //dvector &mv = getmonsters(); + //loopv(mv) if(!vreject(mv[i]->o, v, 10.0f) && mv[i]!=p->owner) projdamage(mv[i], p, v, -1, i, qdam); Modified by Rick + //loopv(mv) if(!vreject(mv[i]->o, v, 10.0f) && mv[i]!=p->owner) projdamage(mv[i], p, v, -1, i, -1, qdam); + }; + if(p->inuse) + { + // if(time==dtime) splash(p, v, p->o, -1, -1, qdam); Modified by Rick + if(time==dtime) splash(p, v, p->o, -1, -1, -1, qdam); + else + { + if(p->gun==GUN_GRENADE) { dodynlight(p->o, v, 0, 255, p->owner); particle_splash(5, 2, 200, v); } + else { particle_splash(1, 1, 200, v); particle_splash(guns[p->gun].part, 1, 1, v); }; + // Added by Rick + traceresult_s tr; + TraceLine(p->o, v, p->owner, true, &tr); + if (tr.collided) splash(p, v, p->o, -1, -1, -1, qdam); + // End add + }; + }; + p->o = v; + }; +}; + +extern float rad(float x); + +void throw_nade(dynent *d, vec &to, physent *p) +{ + if(!p || !d) return; + playsound(S_GRENADETHROW); + + p->isphysent = true; + p->gravity = 20; + p->state = NADE_THROWED; + + p->timeinair = 0; + p->onfloor = false; + + p->o = d->o; + p->vel.z = sin(rad(d->pitch)); + float speed = cos(rad(d->pitch)); + p->vel.x = sin(rad(d->yaw))*speed; + p->vel.y = -cos(rad(d->yaw))*speed; + + vmul(p->vel, 1.7f); + + vec throwdir = p->vel; + vmul(throwdir, d->radius); + vadd(p->o, throwdir); + vadd(p->o, throwdir); + + vec &from = d->o; + + d->thrownademillis = lastmillis; + d->inhandnade = NULL; + + if(d==player1) + { + player1->lastaction = lastmillis; + addmsg(SV_SHOT, "ri8", d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), lastmillis-p->millis); + }; +}; + +physent *new_nade(dynent *d, int millis = 0) +{ + physent *p = new_physent(); + p->owner = d; + p->millis = lastmillis; + p->timetolife = 2000-millis; + p->state = NADE_ACTIVATED; + + d->inhandnade = p; + d->thrownademillis = 0; + playsound(S_GRENADEPULL, (d==player1 ? NULL : &d->o)); + return p; +}; + +void explode_nade(physent *i) +{ + if(!i) return; + + if(i->state != NADE_THROWED) + { + vec o = i->owner->o; + vec dist = { 0.1f, 0.1f, 0.1f }; + vadd(o, dist); + throw_nade(i->owner, o, i); + }; + playsound(S_FEXPLODE, &i->o); + newprojectile(i->o, i->o, 1, i->owner==player1, i->owner, GUN_GRENADE); +}; + +void shootv(int gun, vec &from, vec &to, dynent *d, bool local, int nademillis) // create visual effect from a shot +{ + playsound(guns[gun].sound, d==player1 ? NULL : &d->o); + int pspeed = 25; + switch(gun) + { + case GUN_KNIFE: + break; + + case GUN_SHOTGUN: + { + loopi(SGRAYS) particle_splash(0, 5, 200, sg[i]); + break; + }; + + case GUN_PISTOL: + case GUN_SUBGUN: + case GUN_ASSAULT: + addshotline(d, from, to); + particle_splash(0, 5, 250, to); + //particle_trail(1, 10, from, to); + break; + + case GUN_GRENADE: + { + if(d!=player1) + { + /*int nademillis = nadetimer/100*nadepercent; + if(nademillis<0 || nademillis>100) nademillis = 100;*/ + physent *p = new_nade(d, nademillis); + throw_nade(d, to, p); + } + }; + break; + + case GUN_SNIPER: + addshotline(d, from, to); + particle_splash(0, 50, 200, to); + particle_trail(1, 500, from, to); + break; + }; +}; + +void hitpush(int target, int damage, dynent *d, dynent *at, vec &from, vec &to) +{ + hit(target, damage, d, at, at->gunselect==GUN_KNIFE ? true : false); + vdist(dist, v, from, to); + vmul(v, damage/dist/50); + vadd(d->vel, v); +}; + +void raydamage(dynent *o, vec &from, vec &to, dynent *d, int i) +{ + if(o->state!=CS_ALIVE) return; + int qdam = guns[d->gunselect].damage; + //if(d->quadmillis) qdam *= 4; + if(d->gunselect==GUN_SHOTGUN) + { + int damage = 0; + loop(r, SGRAYS) if(intersect(o, from, sg[r])) damage += qdam; + if(damage) hitpush(i, damage, o, d, from, to); + } + else if(intersect(o, from, to)) hitpush(i, qdam, o, d, from, to); +}; + +void spreadandrecoil(vec &from, vec &to, dynent *d) +{ + //nothing special for a knife + if (d->gunselect==GUN_KNIFE || d->gunselect==GUN_GRENADE) return; + + //spread + vdist(dist, unitv, from, to); + float f = dist/1000; + int spd = guns[d->gunselect].spread; + + //recoil + float rcl = guns[d->gunselect].recoil*-0.01f; + + if(d->gunselect==GUN_ASSAULT) + { + if(d->shots > 3) + spd = 70; + rcl += (rnd(8)*-0.01f); + }; + + if((d->gunselect==GUN_SNIPER) && (d->vel.x<.25f && d->vel.y<.25f) && scoped) + { + spd = 1; + rcl = rcl / 3; + }; + + if(d->gunselect!=GUN_SHOTGUN) //no spread on shotgun + { + #define RNDD (rnd(spd)-spd/2)*f + vec r = { RNDD, RNDD, RNDD }; + vadd(to, r); + #undef RNDD + }; + + //increase pitch for recoil + vdiv(unitv, dist); + vec recoil = unitv; + vmul(recoil, rcl); + vadd(d->vel, recoil); + + if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f; +}; + +bool hasammo(dynent *d) // bot mod +{ + if(!d->mag[d->gunselect]) + { + if (d->bIsBot) botplaysound(S_NOAMMO, d); + else playsoundc(S_NOAMMO); + d->gunwait = 250; + d->lastattackgun = -1; + return false; + } else return true; +} + +const int grenadepulltime = 650; +bool akimboside = false; + +void shoot(dynent *d, vec &targ) +{ + int attacktime = lastmillis-d->lastaction; + + vec from = d->o; + vec to = targ; + + if(d->gunselect==GUN_GRENADE) + { + d->shots = 0; + + if(d->thrownademillis && attacktime >= 13*(1000/25)) + { + d->weaponchanging = true; + d->nextweapon = d->mag[GUN_GRENADE] ? GUN_GRENADE : d->primary; + d->thrownademillis = 0; + d->lastaction = lastmillis-1-WEAPONCHANGE_TIME/2; + }; + + if(d->weaponchanging || attacktimegunwait) return; + d->gunwait = 0; + d->reloading = false; + + if(d->attacking && !d->inhandnade) // activate + { + if(!hasammo(d)) return; + d->mag[d->gunselect]--; + new_nade(d); + d->gunwait = grenadepulltime; + d->lastaction = lastmillis; + d->lastattackgun = d->gunselect; + } + else if(!d->attacking && d->inhandnade && attacktime>grenadepulltime) // throw + { + throw_nade(d, targ, d->inhandnade); + } + return; + } + else + { + if(d->weaponchanging || attacktimegunwait) return; + d->gunwait = 0; + d->reloading = false; + + if(!d->attacking) { d->shots = 0; return; }; + d->lastaction = lastmillis; + d->lastattackgun = d->gunselect; + + if(!hasammo(d)) { d->shots = 0; return; }; + + if(guns[d->gunselect].isauto) d->shots++; + else d->attacking = false; + + if(d->gunselect==GUN_PISTOL && d->akimbo) + { + d->attacking = true; //make akimbo auto + d->akimbolastaction[akimboside?1:0] = lastmillis; + akimboside = !akimboside; + } + + if(d->gunselect) d->mag[d->gunselect]--; + from.z -= 0.2f; // below eye + }; + + spreadandrecoil(from,to,d); + vdist(dist, unitv, from, to); + vdiv(unitv, dist); + + if(d->gunselect==GUN_KNIFE) + { + vmul(unitv, 3); // punch range + to = from; + vadd(to, unitv); + }; + if(d->gunselect==GUN_SHOTGUN) createrays(from, to); + + if(has_akimbo(d)) d->gunwait = guns[d->gunselect].attackdelay / 2; //make akimbo pistols shoot twice as fast as normal pistol + else d->gunwait = guns[d->gunselect].attackdelay; + + shootv(d->gunselect, from, to, d, 0); + addmsg(SV_SHOT, "ri8", d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), 0 ); + if(guns[d->gunselect].projspeed || d->gunselect==GUN_GRENADE) return; + + loopv(players) + { + dynent *o = players[i]; + if(!o) continue; + raydamage(o, from, to, d, i); + }; + + // Added by Rick: raydamage on bots too + loopv(bots) + { + dynent *o = bots[i]; + if(!o || (o == d)) continue; + raydamage(o, from, to, d, i); + }; + // End add by Rick + + if(d->bIsBot) raydamage(player1, from, to, d, -1); +}; diff --git a/source/src/world.cpp b/source/src/world.cpp new file mode 100644 index 00000000..c4e8ee5e --- /dev/null +++ b/source/src/world.cpp @@ -0,0 +1,389 @@ +// world.cpp: core map management stuff + +#include "cube.h" + +extern char *entnames[]; // lookup from map entities above to strings + +sqr *world = NULL; +int sfactor, ssize, cubicsize, mipsize; + +header hdr; + +void settag(int tag, int type) // set all cubes with "tag" to space, if tag is 0 then reset ALL tagged cubes according to type +{ + int maxx = 0, maxy = 0, minx = ssize, miny = ssize; + loop(x, ssize) loop(y, ssize) + { + sqr *s = S(x, y); + if(s->tag) + { + if(tag) + { + if(tag==s->tag) s->type = SPACE; + else continue; + } + else + { + s->type = type ? SOLID : SPACE; + }; + if(x>maxx) maxx = x; + if(y>maxy) maxy = y; + if(x=SMALLEST_FACTOR) return; + int lighterr = getvar("lighterror")*3; + sqr *w = wmip[level]; + sqr *v = wmip[level+1]; + int ws = ssize>>level; + int vs = ssize>>(level+1); + block s = b; + if(s.x&1) { s.x--; s.xs++; }; + if(s.y&1) { s.y--; s.ys++; }; + s.xs = (s.xs+1)&~1; + s.ys = (s.ys+1)&~1; + for(int x = s.x; xtype]++; + r->type = SEMISOLID; // cube contains both solid and space, treated specially in the renderer + loopk(MAXTYPE) if(nums[k]==4) r->type = k; + if(!SOLID(r)) + { + int floor = 127, ceil = -128, num = 0; + loopi(4) if(!SOLID(o[i])) + { + num++; + int fh = o[i]->floor; + int ch = o[i]->ceil; + if(r->type==SEMISOLID) + { + if(o[i]->type==FHF) fh -= o[i]->vdelta/4+2; // crap hack, needed for rendering large mips next to hfs + if(o[i]->type==CHF) ch += o[i]->vdelta/4+2; // FIXME: needs to somehow take into account middle vertices on higher mips + }; + if(fhceil) ceil = ch; + }; + r->floor = floor; + r->ceil = ceil; + }; + if(r->type==CORNER) goto mip; // special case: don't ever split even if textures etc are different + r->defer = 1; + if(SOLID(r)) + { + loopi(3) + { + if(o[i]->wtex!=o[3]->wtex) goto c; // on an all solid cube, only thing that needs to be equal for a perfect mip is the wall texture + }; + } + else + { + loopi(3) + { + if(o[i]->type!=o[3]->type + || o[i]->floor!=o[3]->floor + || o[i]->ceil!=o[3]->ceil + || o[i]->ftex!=o[3]->ftex + || o[i]->ctex!=o[3]->ctex + || abs(o[i+1]->r-o[0]->r)>lighterr // perfect mip even if light is not exactly equal + || abs(o[i+1]->g-o[0]->g)>lighterr + || abs(o[i+1]->b-o[0]->b)>lighterr + || o[i]->utex!=o[3]->utex + || o[i]->wtex!=o[3]->wtex) goto c; + }; + if(r->type==CHF || r->type==FHF) // can make a perfect mip out of a hf if slopes lie on one line + { + if(o[0]->vdelta-o[1]->vdelta != o[1]->vdelta-SWS(w,x+2,y,ws)->vdelta + || o[0]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+2,y+2,ws)->vdelta + || o[0]->vdelta-o[3]->vdelta != o[3]->vdelta-SWS(w,x,y+2,ws)->vdelta + || o[3]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+2,y+1,ws)->vdelta + || o[1]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+1,y+2,ws)->vdelta) goto c; + }; + }; + { loopi(4) if(o[i]->defer) goto c; }; // if any of the constituents is not perfect, then this one isn't either + mip: + r->defer = 0; + c:; + }; + s.x /= 2; + s.y /= 2; + s.xs /= 2; + s.ys /= 2; + remip(s, level+1); +}; + +void remipmore(block &b, int level) +{ + block bb = b; + if(bb.x>1) bb.x--; + if(bb.y>1) bb.y--; + if(bb.xso, v); + if(dist64) v1 = 64;//if(v1>32) v1=32; + if(!v1) e.attr1 = 16; + if(!v2 && !v3 && !v4) e.attr2 = 255; + break; + + case MAPMODEL: + e.attr4 = e.attr3; + e.attr3 = e.attr2; + e.attr2 = (uchar)e.attr1; + case PLAYERSTART: + case CTF_FLAG: + e.attr2 = v1; + e.attr1 = (int)player1->yaw; + break; + }; + addmsg(SV_EDITENT, "ri9", ents.length(), type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4); + ents.add(*((entity *)&e)); // unsafe! + if(type==LIGHT) calclight(); + return &ents.last(); +}; + +void clearents(char *name) +{ + int type = findtype(name); + if(noteditmode() || multiplayer()) return; + loopv(ents) + { + entity &e = ents[i]; + if(e.type==type) e.type = NOTUSED; + }; + if(type==LIGHT) calclight(); +}; + +COMMAND(clearents, ARG_1STR); + +void scalecomp(uchar &c, int intens) +{ + int n = c*intens/100; + if(n>255) n = 255; + c = n; +}; + +void scalelights(int f, int intens) +{ + loopv(ents) + { + entity &e = ents[i]; + if(e.type!=LIGHT) continue; + e.attr1 = e.attr1*f/100; + if(e.attr1<2) e.attr1 = 2; + if(e.attr1>32) e.attr1 = 32; + if(intens) + { + scalecomp(e.attr2, intens); + scalecomp(e.attr3, intens); + scalecomp(e.attr4, intens); + }; + }; + calclight(); +}; + +COMMAND(scalelights, ARG_2INT); + +int findentity(int type, int index) +{ + for(int i = index; i>(i*2); }; +}; + +void empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1 +{ + if(!force && noteditmode()) return; + cleardlights(); + pruneundos(); + sqr *oldworld = world; + bool copy = false; + if(oldworld && factor<0) { factor = sfactor+1; copy = true; }; + if(factorLARGEST_FACTOR) factor = LARGEST_FACTOR; + setupworld(factor); + + loop(x,ssize) loop(y,ssize) + { + sqr *s = S(x,y); + s->r = s->g = s->b = 150; + s->ftex = DEFAULT_FLOOR; + s->ctex = DEFAULT_CEIL; + s->wtex = s->utex = DEFAULT_WALL; + s->type = SOLID; + s->floor = 0; + s->ceil = 16; + s->vdelta = 0; + s->defer = 0; + }; + + strncpy(hdr.head, "ACMP", 4); + hdr.version = MAPVERSION; + hdr.headersize = sizeof(header); + hdr.sfactor = sfactor; + + if(copy) + { + loop(x,ssize/2) loop(y,ssize/2) + { + *S(x+ssize/4, y+ssize/4) = *SWS(oldworld, x, y, ssize/2); + }; + loopv(ents) + { + ents[i].x += ssize/4; + ents[i].y += ssize/4; + }; + } + else + { + s_strncpy(hdr.maptitle, "Untitled Map by Unknown", 128); + hdr.waterlevel = -100000; + loopi(15) hdr.reserved[i] = 0; + loopk(3) loopi(256) hdr.texlists[k][i] = i; + ents.setsize(0); + block b = { 8, 8, ssize-16, ssize-16 }; + edittypexy(SPACE, b); + }; + + calclight(); + startmap("maps/unnamed"); + if(oldworld) + { + delete[] oldworld; + toggleedit(); + execfile("config/default_map_settings.cfg"); + execute("fullbright 1"); + }; +}; + +void mapenlarge() { empty_world(-1, false); }; +void newmap(int i) { empty_world(i, false); }; + +COMMAND(mapenlarge, ARG_NONE); +COMMAND(newmap, ARG_1INT); +COMMANDN(recalc, calclight, ARG_NONE); +COMMAND(delent, ARG_NONE); +COMMAND(entproperty, ARG_2INT); + diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp new file mode 100644 index 00000000..a54632c9 --- /dev/null +++ b/source/src/worldio.cpp @@ -0,0 +1,376 @@ +// worldio.cpp: loading & saving of maps and savegames + +#include "cube.h" + +void backup(char *name, char *backupname) +{ + remove(backupname); + rename(name, backupname); +}; + +string cgzname, bakname, pcfname, mcfname; + +void setnames(char *name) +{ + string pakname, mapname; + char *slash = strpbrk(name, "/\\"); + if(slash) + { + s_strncpy(pakname, name, slash-name+1); + s_strcpy(mapname, slash+1); + } + else + { + s_strcpy(pakname, "maps"); + s_strcpy(mapname, name); + }; + s_sprintf(cgzname)("packages/%s/%s.cgz", pakname, mapname); + s_sprintf(bakname)("packages/%s/%s_%d.BAK", pakname, mapname, lastmillis); + s_sprintf(pcfname)("packages/%s/package.cfg", pakname); + s_sprintf(mcfname)("packages/%s/%s.cfg", pakname, mapname); + + path(cgzname); + path(bakname); +}; + +// the optimize routines below are here to reduce the detrimental effects of messy mapping by +// setting certain properties (vdeltas and textures) to neighbouring values wherever there is no +// visible difference. This allows the mipmapper to generate more efficient mips. +// the reason it is done on save is to reduce the amount spend in the mipmapper (as that is done +// in realtime). + +inline bool nhf(sqr *s) { return s->type!=FHF && s->type!=CHF; }; + +void voptimize() // reset vdeltas on non-hf cubes +{ + loop(x, ssize) loop(y, ssize) + { + sqr *s = S(x, y); + if(x && y) { if(nhf(s) && nhf(S(x-1, y)) && nhf(S(x-1, y-1)) && nhf(S(x, y-1))) s->vdelta = 0; } + else s->vdelta = 0; + }; +}; + +void topt(sqr *s, bool &wf, bool &uf, int &wt, int &ut) +{ + sqr *o[4]; + o[0] = SWS(s,0,-1,ssize); + o[1] = SWS(s,0,1,ssize); + o[2] = SWS(s,1,0,ssize); + o[3] = SWS(s,-1,0,ssize); + wf = true; + uf = true; + if(SOLID(s)) + { + loopi(4) if(!SOLID(o[i])) + { + wf = false; + wt = s->wtex; + ut = s->utex; + return; + }; + } + else + { + loopi(4) if(!SOLID(o[i])) + { + if(o[i]->floorfloor) { wt = s->wtex; wf = false; }; + if(o[i]->ceil>s->ceil) { ut = s->utex; uf = false; }; + }; + }; +}; + +void toptimize() // FIXME: only does 2x2, make atleast for 4x4 also +{ + bool wf[4], uf[4]; + sqr *s[4]; + for(int x = 2; xwtex, ut = s[0]->utex; + topt(s[0], wf[0], uf[0], wt, ut); + topt(s[1] = SWS(s[0],0,1,ssize), wf[1], uf[1], wt, ut); + topt(s[2] = SWS(s[0],1,1,ssize), wf[2], uf[2], wt, ut); + topt(s[3] = SWS(s[0],1,0,ssize), wf[3], uf[3], wt, ut); + loopi(4) + { + if(wf[i]) s[i]->wtex = wt; + if(uf[i]) s[i]->utex = ut; + }; + }; +}; + +// these two are used by getmap/sendmap.. transfers compressed maps directly + +void writemap(char *mname, int msize, uchar *mdata) +{ + setnames(mname); + backup(cgzname, bakname); + FILE *f = fopen(cgzname, "wb"); + if(!f) { conoutf("could not write map to %s", cgzname); return; }; + fwrite(mdata, 1, msize, f); + fclose(f); + conoutf("wrote map %s as file %s", mname, cgzname); +} + +uchar *readmap(char *mname, int *msize) +{ + setnames(mname); + uchar *mdata = (uchar *)loadfile(cgzname, msize); + if(!mdata) { conoutf("could not read map %s", cgzname); return NULL; }; + return mdata; +} + +// save map as .cgz file. uses 2 layers of compression: first does simple run-length +// encoding and leaves out data for certain kinds of cubes, then zlib removes the +// last bits of redundancy. Both passes contribute greatly to the miniscule map sizes. + +void save_world(char *mname) +{ + resettagareas(); // wouldn't be able to reproduce tagged areas otherwise + voptimize(); + toptimize(); + if(!*mname) mname = getclientmap(); + setnames(mname); + backup(cgzname, bakname); + gzFile f = gzopen(cgzname, "wb9"); + if(!f) { conoutf("could not write map to %s", cgzname); return; }; + hdr.version = MAPVERSION; + hdr.numents = 0; + loopv(ents) if(ents[i].type!=NOTUSED) hdr.numents++; + header tmp = hdr; + endianswap(&tmp.version, sizeof(int), 4); + endianswap(&tmp.waterlevel, sizeof(int), 16); + gzwrite(f, &tmp, sizeof(header)); + loopv(ents) + { + if(ents[i].type!=NOTUSED) + { + entity tmp = ents[i]; + endianswap(&tmp, sizeof(short), 4); + gzwrite(f, &tmp, sizeof(persistent_entity)); + }; + }; + sqr *t = NULL; + int sc = 0; + #define spurge while(sc) { gzputc(f, 255); if(sc>255) { gzputc(f, 255); sc -= 255; } else { gzputc(f, sc); sc = 0; } }; + loopk(cubicsize) + { + sqr *s = &world[k]; + #define c(f) (s->f==t->f) + // 4 types of blocks, to compress a bit: + // 255 (2): same as previous block + count + // 254 (3): same as previous, except light // deprecated + // SOLID (5) + // anything else (9) + + if(SOLID(s)) + { + if(t && c(type) && c(wtex) && c(vdelta)) + { + sc++; + } + else + { + spurge; + gzputc(f, s->type); + gzputc(f, s->wtex); + gzputc(f, s->vdelta); + }; + } + else + { + if(t && c(type) && c(floor) && c(ceil) && c(ctex) && c(ftex) && c(utex) && c(wtex) && c(vdelta) && c(tag)) + { + sc++; + } + else + { + spurge; + gzputc(f, s->type); + gzputc(f, s->floor); + gzputc(f, s->ceil); + gzputc(f, s->wtex); + gzputc(f, s->ftex); + gzputc(f, s->ctex); + gzputc(f, s->vdelta); + gzputc(f, s->utex); + gzputc(f, s->tag); + }; + }; + t = s; + }; + spurge; + gzclose(f); + conoutf("wrote map file %s", cgzname); + settagareas(); +}; + +extern void preparectf(bool cleanonly = false); +extern void preload_mapmodels(); + +void load_world(char *mname) // still supports all map formats that have existed since the earliest cube betas! +{ + preparectf(true); + stopifrecording(); + cleardlights(); + pruneundos(); + setnames(mname); + gzFile f = gzopen(cgzname, "rb9"); + if(!f) { conoutf("could not read map %s", cgzname); return; }; + loadingscreen(); + gzread(f, &hdr, sizeof(header)-sizeof(int)*16); + endianswap(&hdr.version, sizeof(int), 4); + if(strncmp(hdr.head, "CUBE", 4)!=0 && strncmp(hdr.head, "ACMP",4)!=0) fatal("while reading map: header malformatted"); + if(hdr.version>MAPVERSION) fatal("this map requires a newer version of cube"); + if(sfactorLARGEST_FACTOR) fatal("illegal map size"); + if(hdr.version>=4) + { + gzread(f, &hdr.waterlevel, sizeof(int)*16); + endianswap(&hdr.waterlevel, sizeof(int), 16); + } + else + { + hdr.waterlevel = -100000; + }; + ents.setsize(0); + loopi(hdr.numents) + { + entity &e = ents.add(); + gzread(f, &e, sizeof(persistent_entity)); + endianswap(&e, sizeof(short), 4); + e.spawned = false; + if(e.type==LIGHT) + { + if(!e.attr2) e.attr2 = 255; // needed for MAPVERSION<=2 + if(e.attr1>32) e.attr1 = 32; // 12_03 and below + }; + + if (hdr.versionr = s->g = s->b = gzgetc(f); + gzgetc(f); + break; + }; + case SOLID: + { + s->type = SOLID; + s->wtex = gzgetc(f); + s->vdelta = gzgetc(f); + if(hdr.version<=2) { gzgetc(f); gzgetc(f); }; + s->ftex = DEFAULT_FLOOR; + s->ctex = DEFAULT_CEIL; + s->utex = s->wtex; + s->tag = 0; + s->floor = 0; + s->ceil = 16; + break; + }; + default: + { + if(type<0 || type>=MAXTYPE) + { + s_sprintfd(t)("%d @ %d", type, k); + fatal("while reading map: type out of range: ", t); + }; + s->type = type; + s->floor = gzgetc(f); + s->ceil = gzgetc(f); + if(s->floor>=s->ceil) s->floor = s->ceil-1; // for pre 12_13 + s->wtex = gzgetc(f); + s->ftex = gzgetc(f); + s->ctex = gzgetc(f); + if(hdr.version<=2) { gzgetc(f); gzgetc(f); }; + s->vdelta = gzgetc(f); + s->utex = (hdr.version>=2) ? gzgetc(f) : s->wtex; + s->tag = (hdr.version>=5) ? gzgetc(f) : 0; + s->type = type; + }; + }; + s->defer = 0; + t = s; + texuse[s->wtex] = 1; + if(!SOLID(s)) texuse[s->utex] = texuse[s->ftex] = texuse[s->ctex] = 1; + }; + gzclose(f); + c2skeepalive(); + calclight(); + settagareas(); + conoutf("read map %s (%d milliseconds)", cgzname, SDL_GetTicks()-lastmillis); + conoutf("%s", hdr.maptitle); + startmap(mname); + loopl(256) + { + s_sprintfd(aliasname)("level_trigger_%d", l); // can this be done smarter? + if(identexists(aliasname)) alias(aliasname, ""); + }; + execfile("config/default_map_settings.cfg"); + execfile(pcfname); + execfile(mcfname); + int xs, ys; + c2skeepalive(); + loopi(256) if(texuse) lookuptexture(i, xs, ys); + c2skeepalive(); + preload_mapmodels(); + c2skeepalive(); +}; + +COMMANDN(savemap, save_world, ARG_1STR); + diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp new file mode 100644 index 00000000..8e42ea88 --- /dev/null +++ b/source/src/worldlight.cpp @@ -0,0 +1,217 @@ +// worldlight.cpp + +#include "cube.h" + +extern bool hasoverbright; + +VAR(lightscale,1,4,100); + +void lightray(float bx, float by, persistent_entity &light) // done in realtime, needs to be fast +{ + float lx = light.x+(rnd(21)-10)*0.1f; + float ly = light.y+(rnd(21)-10)*0.1f; + float dx = bx-lx; + float dy = by-ly; + float dist = (float)sqrt(dx*dx+dy*dy); + if(dist<1.0f) return; + int reach = light.attr1; + int steps = (int)(reach*reach*1.6f/dist); // can change this for speedup/quality? + const int PRECBITS = 12; + const float PRECF = 4096.0f; + int x = (int)(lx*PRECF); + int y = (int)(ly*PRECF); + int l = light.attr2<>PRECBITS, y>>PRECBITS)) return; + + int g = light.attr3<>PRECBITS, y>>PRECBITS); + int tl = (l>>PRECBITS)+s->r; + s->r = tl>255 ? 255 : tl; + tl = (g>>PRECBITS)+s->g; + s->g = tl>255 ? 255 : tl; + tl = (b>>PRECBITS)+s->b; + s->b = tl>255 ? 255 : tl; + if(SOLID(s)) return; + x += stepx; + y += stepy; + l -= stepl; + g -= stepg; + b -= stepb; + stepl -= 25; + stepg -= 25; + stepb -= 25; + }; + } + else // white light, special optimized version + { + int dimness = rnd((255-light.attr2)/16+1); + x += stepx*dimness; + y += stepy*dimness; + + if(OUTBORD(x>>PRECBITS, y>>PRECBITS)) return; + + loopi(steps) + { + sqr *s = S(x>>PRECBITS, y>>PRECBITS); + int tl = (l>>PRECBITS)+s->r; + s->r = s->g = s->b = tl>255 ? 255 : tl; + if(SOLID(s)) return; + x += stepx; + y += stepy; + l -= stepl; + stepl -= 25; + }; + }; + } + else // the old (white) light code, here for the few people with old video cards that don't support overbright + { + loopi(steps) + { + sqr *s = S(x>>PRECBITS, y>>PRECBITS); + int light = l>>PRECBITS; + if(light>s->r) s->r = s->g = s->b = (uchar)light; + if(SOLID(s)) return; + x += stepx; + y += stepy; + l -= stepl; + }; + }; + +}; + +void calclightsource(persistent_entity &l) +{ + int reach = l.attr1; + int sx = l.x-reach; + int ex = l.x+reach; + int sy = l.y-reach; + int ey = l.y+reach; + + rndreset(); + + const float s = 0.8f; + + for(float sx2 = (float)sx; sx2<=ex; sx2+=s*2) { lightray(sx2, (float)sy, l); lightray(sx2, (float)ey, l); }; + for(float sy2 = sy+s; sy2<=ey-s; sy2+=s*2) { lightray((float)sx, sy2, l); lightray((float)ex, sy2, l); }; + + rndtime(); +}; + +void postlightarea(block &a) // median filter, smooths out random noise in light and makes it more mipable +{ + loop(x,a.xs) loop(y,a.ys) // assumes area not on edge of world + { + sqr *s = S(x+a.x,y+a.y); + #define median(m) s->m = (s->m*2 + SW(s,1,0)->m*2 + SW(s,0,1)->m*2 \ + + SW(s,-1,0)->m*2 + SW(s,0,-1)->m*2 \ + + SW(s,1,1)->m + SW(s,1,-1)->m \ + + SW(s,-1,1)->m + SW(s,-1,-1)->m)/14; // median is 4/2/1 instead + median(r); + median(g); + median(b); + }; + + remip(a); +}; + +void calclight() +{ + loop(x,ssize) loop(y,ssize) + { + sqr *s = S(x,y); + s->r = s->g = s->b = 10; + }; + + loopv(ents) + { + entity &e = ents[i]; + if(e.type==LIGHT) calclightsource(e); + }; + + block b = { 1, 1, ssize-2, ssize-2 }; + postlightarea(b); + setvar("fullbright", 0); +}; + +VAR(dynlight, 0, 16, 32); + +vector dlights; + +void cleardlights() +{ + while(!dlights.empty()) + { + block *backup = dlights.pop(); + blockpaste(*backup); + freeblock(backup); + }; +}; + +void dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner) +{ + if(!reach) reach = dynlight; + if(owner->monsterstate) reach = reach/2; + if(!reach) return; + + int creach = reach+16; // dependant on lightray random offsets! + block b = { (int)v.x-creach, (int)v.y-creach, creach*2+1, creach*2+1 }; + + if(b.x<1) b.x = 1; + if(b.y<1) b.y = 1; + if(b.xs+b.x>ssize-2) b.xs = ssize-2-b.x; + if(b.ys+b.y>ssize-2) b.ys = ssize-2-b.y; + + dlights.add(blockcopy(b)); // backup area before rendering in dynlight + + persistent_entity l = { (int)v.x, (int)v.y, (int)v.z, reach, LIGHT, strength, 0, 0 }; + calclightsource(l); + postlightarea(b); +}; + +// utility functions also used by editing code + +block *blockcopy(block &s) +{ + block *b = (block *)new uchar[sizeof(block)+s.xs*s.ys*sizeof(sqr)]; + *b = s; + sqr *q = (sqr *)(b+1); + for(int x = s.x; xstate==CS_DEAD ? -90.0f : player1->pitch); + float af = getvar("fov")/2+apitch/1.5f+3; + float byaw = (player1->yaw-90+af)/360*PI2; + float syaw = (player1->yaw-90-af)/360*PI2; + + loopi(NUMRAYS) + { + float angle = i*PI2/NUMRAYS; + if((apitch>45 // must be bigger if fov>120 + || (anglesyaw) + || (anglesyaw-PI2) + || (anglesyaw+PI2)) + && !OUTBORD(vx, vy) + && !SOLID(S(int(vx), int(vy)))) // try to avoid tracing ray if outside of frustrum + { + float ray = i*8/(float)NUMRAYS; + float dx, dy; + if(ray>1 && ray<3) { dx = -(ray-2); dy = 1; } + else if(ray>=3 && ray<5) { dx = -1; dy = -(ray-4); } + else if(ray>=5 && ray<7) { dx = ray-6; dy = -1; } + else { dx = 1; dy = ray>4 ? ray-8 : ray; }; + float sx = vx; + float sy = vy; + for(;;) + { + sx += dx; + sy += dy; + if(SOLID(S(int(sx), int(sy)))) // 90% of time spend in this function is on this line + { + rdist[i] = (float)(fabs(sx-vx)+fabs(sy-vy)); + break; + }; + }; + } + else + { + rdist[i] = 2; + }; + }; +}; + +// test occlusion for a cube... one of the most computationally expensive functions in the engine +// as its done for every cube and entity, but its effect is more than worth it! + +inline float ca(float x, float y) { return x>y ? y/x : 2-x/y; }; +inline float ma(float x, float y) { return x==0 ? (y>0 ? 2 : -2) : y/x; }; + +int isoccluded(float vx, float vy, float cx, float cy, float csize) // v = viewer, c = cube to test +{ + if(!ocull) return 0; + + float nx = vx, ny = vy; // n = point on the border of the cube that is closest to v + if(nxcx+csize) nx = cx+csize; + if(nycy+csize) ny = cy+csize; + float xdist = (float)fabs(nx-vx); + float ydist = (float)fabs(ny-vy); + if(xdist>odist || ydist>odist) return 2; + float dist = xdist+ydist-1; // 1 needed? + + // ABC + // D E + // FGH + + // - check middle cube? BG + + // find highest and lowest angle in the occlusion map that this cube spans, based on its most left and right + // points on the border from the viewer pov... I see no easier way to do this than this silly code below + + float h, l; + if(cx<=vx) // ABDFG + { + if(cx+csizetype==SEMISOLID) + { + float c1 = s->floor; + float c2 = s->floor; + if(s->type==FHF) { c1 -= d1->vdelta/4.0f; c2 -= d2->vdelta/4.0f; }; + float f1 = s->ceil; + float f2 = s->ceil; + if(s->type==CHF) { f1 += d1->vdelta/4.0f; f2 += d2->vdelta/4.0f; }; + //if(f1-c1<=0 && f2-c2<=0) return; + render_square(o->wtex, c1, c2, f1, f2, x1<floor; + float f2 = s->floor; + float c1 = o->floor; + float c2 = o->floor; + if(o->type==FHF && s->type!=FHF) + { + c1 -= d1->vdelta/4.0f; + c2 -= d2->vdelta/4.0f; + } + if(s->type==FHF && o->type!=FHF) + { + f1 -= d1->vdelta/4.0f; + f2 -= d2->vdelta/4.0f; + } + if(f1>=c1 && f2>=c2) goto skip; + render_square(o->wtex, f1, f2, c1, c2, x1<ceil; + float f2 = o->ceil; + float c1 = s->ceil; + float c2 = s->ceil; + if(o->type==CHF && s->type!=CHF) + { + f1 += d1->vdelta/4.0f; + f2 += d2->vdelta/4.0f; + } + else if(s->type==CHF && o->type!=CHF) + { + c1 += d1->vdelta/4.0f; + c2 += d2->vdelta/4.0f; + } + if(c1<=f1 && c2<=f2) return; + render_square(o->utex, f1, f2, c1, c2, x1<>mip; + x *= 2; + y *= 2; + switch(SWS(w, x+x1, y+y1, msize)->type) + { + case SEMISOLID: if(issemi(mip, x+x1, y+y1, x1, y1, x2, y2)) return true; + case CORNER: + case SOLID: break; + default: return true; + }; + switch(SWS(w, x+x2, y+y2, msize)->type) + { + case SEMISOLID: if(issemi(mip, x+x2, y+y2, x1, y1, x2, y2)) return true; + case CORNER: + case SOLID: break; + default: return true; + }; + return false; +}; + +bool render_floor, render_ceil; + +// the core recursive function, renders a rect of cubes at a certain mip level from a viewer perspective +// call itself for lower mip levels, on most modern machines however this function will use the higher +// mip levels only for perfect mips. + +void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs, int ys) +{ + sqr *w = wmip[mip]; + int sz = ssize>>mip; + int vxx = ((int)vx+(1<>mip; + int vyy = ((int)vy+(1<>mip; + int lx = vxx-lodleft; // these mark the rect inside the current rest that we want to render using a lower mip level + int ly = vyy-lodtop; + int rx = vxx+lodright; + int ry = vyy+lodbot; + + float fsize = (float)(1<occluded = isoccluded(player1->o.x, player1->o.y, (float)(ox<>mip; + int pvy = (int)vy>>mip; + if(pvx>=0 && pvy>=0 && pvxoccluded = 0; + SWS(w, pvx, pvy, sz)->occluded = 0; // player cell never occluded + }; + + #define df(x) s->floor-(x->vdelta/4.0f) + #define dc(x) s->ceil+(x->vdelta/4.0f) + + // loop through the rect 3 times (for floor/ceil/walls seperately, to facilitate dynamic stripify) + // for each we skip occluded cubes (occlusion at higher mip levels is a big time saver!). + // during the first loop (ceil) we collect cubes that lie within the lower mip rect and are + // also deferred, and render them recursively. Anything left (perfect mips and higher lods) we + // render here. + + #define LOOPH {for(int xx = x; xxoccluded==1) continue; \ + if(s->defer && !s->occluded && mip && xx>=lx && xx=ly && yydefer && !next->occluded) yy++; // collect 2xN rect of lower mip + render_seg_new(vx, vy, vh, mip-1, xx*2, start*2, xx*2+2, yy*2+2); + continue; + }; + stats[mip]++; + LOOPD + if((s->type==SPACE || s->type==FHF) && s->ceil>=vh && render_ceil) + render_flat(s->ctex, xx<ceil, s, t, u, v, true); + if(s->type==CHF) //if(s->ceil>=vh) + render_flatdelta(s->ctex, xx<type==SPACE || s->type==CHF) && s->floor<=vh && render_floor) + { + render_flat(s->ftex, xx<floor, s, t, u, v, false); + if(s->floortype==FHF) + { + render_flatdelta(s->ftex, xx<floor-s->vdelta/4.0ftype==CORNER) + { + // cull also + bool topleft = true; + sqr *h1 = NULL; + sqr *h2 = NULL; + if(SOLID(z)) + { + if(SOLID(w)) { render_wall(w, h2 = s, xx+1, yy, xx, yy+1, mip, t, v, false); topleft = false; } + else if(SOLID(v)) { render_wall(v, h2 = s, xx, yy, xx+1, yy+1, mip, s, u, false); }; + } + else if(SOLID(t)) + { + if(SOLID(w)) { render_wall(w, h1 = s, xx+1, yy+1, xx, yy, mip, u, s, false); } + else if(SOLID(v)) { render_wall(v, h1 = s, xx, yy+1, xx+1, yy, mip, v, t, false); topleft = false; }; + } + else + { + normalwall = false; + bool wv = w->ceil-w->floor < v->ceil-v->floor; + if(z->ceil-z->floor < t->ceil-t->floor) + { + if(wv) { render_wall(h1 = s, h2 = v, xx+1, yy, xx, yy+1, mip, t, v, false); topleft = false; } + else { render_wall(h1 = s, h2 = w, xx, yy, xx+1, yy+1, mip, s, u, false); }; + } + else + { + if(wv) { render_wall(h2 = s, h1 = v, xx+1, yy+1, xx, yy, mip, u, s, false); } + else { render_wall(h2 = s, h1 = w, xx, yy+1, xx+1, yy, mip, v, t, false); topleft = false; }; + }; + }; + render_tris(xx<=vxx && xx!=0 && yy!=sz-1 && !SOLID(z) && (!SOLID(s) || z->type!=CORNER) + && (z->type!=SEMISOLID || issemi(mip, xx-1, yy, 1, 0, 1, 1))) + render_wall(s, z, xx, yy, xx, yy+1, mip, s, v, true); + if(xx<=vxx && inner && !SOLID(t) && (!SOLID(s) || t->type!=CORNER) + && (t->type!=SEMISOLID || issemi(mip, xx+1, yy, 0, 0, 0, 1))) + render_wall(s, t, xx+1, yy, xx+1, yy+1, mip, t, u, false); + if(yy>=vyy && yy!=0 && xx!=sz-1 && !SOLID(w) && (!SOLID(s) || w->type!=CORNER) + && (w->type!=SEMISOLID || issemi(mip, xx, yy-1, 0, 1, 1, 1))) + render_wall(s, w, xx, yy, xx+1, yy, mip, s, t, false); + if(yy<=vyy && inner && !SOLID(v) && (!SOLID(s) || v->type!=CORNER) + && (v->type!=SEMISOLID || issemi(mip, xx, yy+1, 0, 0, 1, 0))) + render_wall(s, v, xx, yy+1, xx+1, yy+1, mip, v, u, true); + }; + }}; + +}; + +void distlod(int &low, int &high, int angle, float widef) +{ + float f = 90.0f/lod/widef; + low = (int)((90-angle)/f); + high = (int)(angle/f); + if(lowMAX_LOD) lod = MAX_LOD; + lodtop = lodbot = lodleft = lodright = min_lod; + if(yaw>45 && yaw<=135) + { + lodleft = lod; + distlod(lodtop, lodbot, yaw-45, widef); + } + else if(yaw>135 && yaw<=225) + { + lodbot = lod; + distlod(lodleft, lodright, yaw-135, widef); + } + else if(yaw>225 && yaw<=315) + { + lodright = lod; + distlod(lodbot, lodtop, yaw-225, widef); + } + else + { + lodtop = lod; + distlod(lodright, lodleft, yaw<=45 ? yaw+45 : yaw-315, widef); + }; + float hyfov = fov*h/w/2; + render_floor = pitch>MAX_MIP, ssize>>MAX_MIP); + mipstats(stats[0], stats[1], stats[2]); +}; +