commit 5eda6e2fe7d9c4cda8af51939ab58bb4d1812218 Author: stpohle Date: Wed Apr 23 15:59:59 2003 +0000 Initial revision diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..60549be --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..09c65a1 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,223 @@ +Version 0.9.6 +============= + +2003-04-23 +- better handling with the masterserver menu. If you want to join + a game you don't need anymore to refresh the list. + Because the game will get some updates from the MasterServer. + +- You can finaly get more as only one illness. And you can get the + Ill now from another player. + +- Some work in the menu. + +- In the game you will see now the little Player Graphic left from + the name. It will help you to see who is who in the game. + +- Fixed Problem with PI_keys Illness. (that the one with the mixed + up keys) + + +Version 0.9.5 +============= + +2003-04-13 +- Add: Chatting you are able to chat now.. it's connecting all + running games together into the chat. You will see Chats who + are not from your server beginning with BC: or IRC: depends + who this message come from. + +- Better Graphics + +- Better Network, the option for how many packets will be send + is chaning within the game. Depends on how much packets timed + out. + + +4) 2003-04-06 +- You can no join into running games. + +- Fixed some network bugs. Which had to do with joining and + leaving running games + +0-3) 2003-03-29 +- internal change for the positions on the field to 16bit. + player moves smother now. + +- diffrent screen resolutions + +- random player start positions + +- the size of the field can be changed + +- playergraphic is better now. + +- menus are diffrent now. + +- configuration is saved in a special file. + on linux $HOME/.bomberclone.cfg + on windows bomberclone.cfg + + +Version 0.8 +=========== + +0-2) 2003-03-15 +- Added two more Powerups (diffrent speeds, and ilness) + +- Fixed some problems with the bombes which didn't wanted + to explode. + +- Debug-Messages can now be switched off. + this improve the speed in the game on slow computers. + + +Version 0.7 +=========== + +1) 2003-03-06 +- Master GameServer Support, So everyone will see + running games. You don't need to deal anymore with the + Servernames. + +- GFX: New Playerfile now we have three diffrent Players + + +Version 0.6 +=========== + +12) 2003-02-27 +- Fixed: The ServerMode Packet will be send with the PKGF_ackreq Flag. + Because sometimes the clients haven't got the packet. And couldn't play + in the game. + +- Fixed: Single Player Problem after trying to open a Multiplayer server + is the Single Player mode not working right.. the Player could not die. + +- Fixed: Multiplayer, the game was counting the poinbts wrong and there + was always a winner marked even if everybody died. + +11) 2003-02-24 +- Fixed: bombs which are exploding more times on slow networks. + I had some little misstake in the inpkg_check function. + +- I am sending now only needed packages, moving packages will be + only every second time maybe every third time. The user is able + to choose how often the package should be send. + +- Finaly there is a playerstatistic in the end of the game. + It will hold the points and who have won the game. + +- The game is not ending right there where the last player died. + I put a timeout in the game of 5 seconds. So the last few bombs + will explode. + +- pkg_error: will be shown on the screen. + +- version controll: old bomberclone versions will be ignored and + they get a error message back. + +10) 2003-02-21 +- Some work on the Network Protocoll, because there are + still some problems with sending the Data + + +Version 0.5 +=========== + +9) 2003-02-14 +- In Multiplayergames, only the Server will let the + Bombs explode. Manny tests have shown that this + is the best way to prevent some difficults in the + game with the field, bomb and explosion data. + +- code optimized in working with struct _sockaddr + because sockaddr_in6 is larger as sockaddr which is + usualy used for all/the most type of network + connection. + + +5-8) 2003-02-13 +- i made some experiments with sending bomb information + and field information over the network. + +- created a inpkg_index to check for incoming packets + which we have already got. + +4) 2003-02-12 +- bomb explosion will be send over the network + +3) 2003-02-12 +- Better Network Handling + Check for important packages (pkg_field, pkg_bomb) + and send them again. Created a resend_cache. + +- Windows: i put now WSAStartup and WASCleanup in the + network_init and network_shutdown function. Windows + User should now able to join more times games without + restarting the game. + +- MSVC: moved the function "explosion_check_field" + in file bomb.c out of the function "do_explosion" + and the function "check_field" in file player.c + out of the function "move_player". The same i + have done with "draw_netupdatestate" and + "wait_draw_select". Because MSVC had some + problems with function in function declaration. + + +Version 0.4 +=========== + +2) 2003-02-11: +- if the server don't reply after a while we will + get back in the join menu. + +1) 2003-02-10: +- mouse cursor is not anymore on the windows/screen. + +- Fixed: Bomb Under Player Bug + +- Build Number is now included. + It will show up in the Main Menu. + +2003-02-07: +- Save every sockaddr in the in_pl struct so we don't have to look up + them again and again + +- Making changes in the Data Download Sequence. + +- Chaning the Network Protocol from TCP to UDP. And putting + everything inside what is needed for a basic work. + +- Linux supports IPv6 and IPv4, you can choose it in the settings + +- I have got the first animated player for the game. + I hope the next will follow soon. + + +Version 0.3 +=========== + +- First Try to Compile everything on Windows and Linux. + +- Network doesn't work fine with more as two Players and a Windows Client + It works only with more as two players on Linux Systems. + + +Version 0.2 +=========== + +- Added functions for animations. + +- Network Support does now work somehow on Linux + + +Version 0.1 +=========== + +- You can finally move your player + the bombs are exploding. + +- Basic Graphics, just some experiments within the game + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..b42a17a --- /dev/null +++ b/INSTALL @@ -0,0 +1,182 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..c306e35 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,27 @@ +## Process this file with automake to produce Makefile.in +## Created by Anjuta - will be overwritten +## If you don't want it to overwrite it, +## Please disable it in the Anjuta project configuration + +SUBDIRS = src + +bomberclonedocdir = ${prefix}/doc/bomberclone +bomberclonedoc_DATA = \ + README\ + COPYING\ + AUTHORS\ + ChangeLog\ + INSTALL\ + NEWS\ + TODO + +EXTRA_DIST = bomberclone.prj $(bomberclonedoc_DATA) + +# Copy all the spec files. Of cource, only one is actually used. +dist-hook: + for specfile in *.spec; do \ + if test -f $$specfile; then \ + cp -p $$specfile $(distdir); \ + fi \ + done + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..f851e71 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,450 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# 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@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AMTAR = @AMTAR@ +AWK = @AWK@ +CC = @CC@ +DEPDIR = @DEPDIR@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +NO_PREFIX_PACKAGE_DATA_DIR = @NO_PREFIX_PACKAGE_DATA_DIR@ +NO_PREFIX_PACKAGE_DOC_DIR = @NO_PREFIX_PACKAGE_DOC_DIR@ +NO_PREFIX_PACKAGE_HELP_DIR = @NO_PREFIX_PACKAGE_HELP_DIR@ +NO_PREFIX_PACKAGE_MENU_DIR = @NO_PREFIX_PACKAGE_MENU_DIR@ +NO_PREFIX_PACKAGE_PIXMAPS_DIR = @NO_PREFIX_PACKAGE_PIXMAPS_DIR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_DATA_DIR = @PACKAGE_DATA_DIR@ +PACKAGE_DOC_DIR = @PACKAGE_DOC_DIR@ +PACKAGE_HELP_DIR = @PACKAGE_HELP_DIR@ +PACKAGE_MENU_DIR = @PACKAGE_MENU_DIR@ +PACKAGE_PIXMAPS_DIR = @PACKAGE_PIXMAPS_DIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = src + +bomberclonedocdir = ${prefix}/doc/bomberclone +bomberclonedoc_DATA = \ + README\ + COPYING\ + AUTHORS\ + ChangeLog\ + INSTALL\ + NEWS\ + TODO + + +EXTRA_DIST = bomberclone.prj $(bomberclonedoc_DATA) +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DATA = $(bomberclonedoc_DATA) + + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ + Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 \ + config.h.in configure configure.in depcomp install-sh missing \ + mkinstalldirs +DIST_SUBDIRS = $(SUBDIRS) +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$@ $(SHELL) ./config.status + +$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +$(ACLOCAL_M4): configure.in + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h stamp-hT + @echo timestamp > stamp-hT 2> /dev/null + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @mv stamp-hT stamp-h +$(srcdir)/config.h.in: $(srcdir)/./stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/./stamp-h.in; \ + $(MAKE) $(srcdir)/./stamp-h.in; \ + else :; fi +$(srcdir)/./stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h + @rm -f $(srcdir)/./stamp-h.in $(srcdir)/./stamp-h.inT + @echo timestamp > $(srcdir)/./stamp-h.inT 2> /dev/null + cd $(top_srcdir) && $(AUTOHEADER) + @mv $(srcdir)/./stamp-h.inT $(srcdir)/./stamp-h.in + +distclean-hdr: + -rm -f config.h +uninstall-info-am: +install-bomberclonedocDATA: $(bomberclonedoc_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bomberclonedocdir) + @list='$(bomberclonedoc_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(bomberclonedocdir)/$$f"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(bomberclonedocdir)/$$f; \ + done + +uninstall-bomberclonedocDATA: + @$(NORMAL_UNINSTALL) + @list='$(bomberclonedoc_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(bomberclonedocdir)/$$f"; \ + rm -f $(DESTDIR)$(bomberclonedocdir)/$$f; \ + done + +# 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): + @set fnord $(MAKEFLAGS); amf=$$2; \ + 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) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + 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: + @set fnord $(MAKEFLAGS); amf=$$2; \ + 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) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(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 $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = . +# Avoid unsightly `./'. +distdir = $(PACKAGE)-$(VERSION) + +GZIP_ENV = --best + +distdir: $(DISTFILES) + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) + mkdir $(distdir) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="${top_distdir}" distdir="$(distdir)" \ + dist-hook + -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: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(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 + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + chmod a-w $(distdir) + dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \ + && cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ + || (echo "Error: files left after uninstall" 1>&2; \ + exit 1) ) \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && $(MAKE) $(AM_MAKEFLAGS) distclean \ + && rm -f $(distdir).tar.gz \ + && (test `find . -type f -print | wc -l` -eq 0 \ + || (echo "Error: files left after distclean" 1>&2; \ + exit 1) ) + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + @echo "$(distdir).tar.gz is ready for distribution" | \ + sed 'h;s/./=/g;p;x;p;x' +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) config.h +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(bomberclonedocdir) + +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)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +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 + +dist-all: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) +distclean: distclean-recursive + -rm -f config.status config.cache config.log +distclean-am: clean-am distclean-generic distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: install-bomberclonedocDATA + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-bomberclonedocDATA uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-recursive dist dist-all distcheck distclean \ + distclean-generic distclean-hdr distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-bomberclonedocDATA \ + install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-recursive tags tags-recursive uninstall \ + uninstall-am uninstall-bomberclonedocDATA uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + + +# Copy all the spec files. Of cource, only one is actually used. +dist-hook: + for specfile in *.spec; do \ + if test -f $$specfile; then \ + cp -p $$specfile $(distdir); \ + fi \ + done +# 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/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..7954400 --- /dev/null +++ b/README @@ -0,0 +1,97 @@ + +Compilation +=========== + +Windows: + On Windows i used cygwin with mingw-gcc compiler. (http://www.cygwin.com) + You will even need the Source from the "Simply DirectMedia Layer" Library. + (http://www.libsdl.org/index.php) + + 1. Install Cygwin and Compile the SDL Library into it. + + ./configure --prefix=/usr + make + make install + + The SDL.DLL file you will find under /usr/lib + + 2. Compile the Source of BomberClone + + ./configure + make + + if this doesn't work try + + aclocal -f + autoheader -f + autoconf -f + automake -a + ./configure + make + + then run the game with + + src/bomberclone.exe + +Linux: + if everything goes right, you only need to run + + ./configure + make + + if nothing goes right, you will need : + + aclocal + autoheader + autoconf + automake + ./configure + make + src/bomberclone + + +Network +======= + +(Ver. 0.3) +The Game uses TCP port 11000, and it needs that other clients can +connect to this port. So check your network configuration. + +(Ver. 0.4) +This Version uses only UDP Port 11000, so check it again.. :o) + + +Animations +========== + +How to save the single frames into one big image for the animations +The Dieing sequence will be in version 0.4 + +Image: + + left | right | up | down | dieing + F1 | F1 | F1 | F1 | F1 + F2 | F2 | F2 | F2 | F2 + F3 | F3 | F3 | F3 | F3 + F4 | F4 | F4 | F4 | F4 + F5 | F5 | F5 | F5 | F5 + + +Testers +======= + + Linux : Marcus, Patty, x-coder + Windows: boogieman, deadlock + + +Contact +======= + +programming : Steffen Pohle stpohle@gmx.net +graphic : TekkRat -no email yet- + +You can find us on : + irc://irc.d-t-net.de #programmierer + + +http://stpohle.bei.t-online.de/bomberclone diff --git a/TODO b/TODO new file mode 100644 index 0000000..a24c057 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ + +- better gfx, more players, a better fire. + +- we need some sound + +- find better way for menus.. diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 0000000..caac01b --- /dev/null +++ b/acconfig.h @@ -0,0 +1,13 @@ +#undef ENABLE_NLS +#undef HAVE_CATGETS +#undef HAVE_GETTEXT +#undef HAVE_LC_MESSAGES +#undef HAVE_STPCPY +#undef HAVE_LIBSM +#undef PACKAGE_LOCALE_DIR +#undef PACKAGE_DOC_DIR +#undef PACKAGE_DATA_DIR +#undef PACKAGE_PIXMAPS_DIR +#undef PACKAGE_HELP_DIR +#undef PACKAGE_MENU_DIR +#undef PACKAGE_SOURCE_DIR diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..f30e315 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,842 @@ +# aclocal.m4 generated automatically by aclocal 1.5 + +# Copyright 1996, 1997, 1998, 1999, 2000, 2001 +# 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. + +# Do all the work for Automake. 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. + +# serial 5 + +# 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... + + +# We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED. +# The purpose of this macro is to provide the user with a means to +# check macros which are provided without letting her know how the +# information is coded. +# If this macro is not defined by Autoconf, define it here. +ifdef([AC_PROVIDE_IFELSE], + [], + [define([AC_PROVIDE_IFELSE], + [ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE]) +# ---------------------------------------------- +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first]) +fi + +# Define the identity of the package. +PACKAGE=$1 +AC_SUBST(PACKAGE)dnl +VERSION=$2 +AC_SUBST(VERSION)dnl +ifelse([$3],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])]) + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. +ifdef([m4_pattern_allow], + [m4_pattern_allow([^AM_[A-Z]+FLAGS])])dnl + +# Autoconf 2.50 always computes EXEEXT. However we need to be +# compatible with 2.13, for now. So we always define EXEEXT, but we +# don't compute it. +AC_SUBST(EXEEXT) +# Similar for OBJEXT -- only we only use OBJEXT if the user actually +# requests that it be used. This is a bit dumb. +: ${OBJEXT=o} +AC_SUBST(OBJEXT) + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG(AMTAR, tar) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +# 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_DEP_TRACK])dnl +AC_REQUIRE([AM_SET_DEPDIR])dnl +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 +]) + +# +# Check to make sure that the build environment is sane. +# + +# serial 3 + +# 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)]) + + +# serial 2 + +# 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= + am_backtick='`' + AC_MSG_WARN([${am_backtick}missing' script is too old or missing]) +fi +]) + +# AM_AUX_DIR_EXPAND + +# 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], [ +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` +]) + +# 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)]) + +# 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 +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# serial 4 -*- Autoconf -*- + + + +# 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" 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 + + 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 + # 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. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +$1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type" +AC_SUBST([$1DEPMODE]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null +AC_SUBST(DEPDIR) +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking Speeds up one-time builds + --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]) +pushdef([subst], defn([AC_SUBST])) +subst(AMDEPBACKSLASH) +popdef([subst]) +]) + +# Generate code to set up dependency tracking. +# This macro should only be invoked once -- use via AC_REQUIRE. +# Usage: +# AM_OUTPUT_DEPENDENCY_COMMANDS + +# +# 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_OUTPUT_COMMANDS([ +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # 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 -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //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=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +], [AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir"])]) + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +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 | fgrep -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 +]) + +# serial 3 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +# +# FIXME: Once using 2.50, use this: +# m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_DEFUN([AM_CONDITIONAL], +[ifelse([$1], [TRUE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +ifelse([$1], [FALSE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +# serial 3 + +# 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. We must strip everything past the first ":", +# and everything past the last "/". + +AC_PREREQ([2.12]) + +AC_DEFUN([AM_CONFIG_HEADER], +[ifdef([AC_FOREACH],dnl + [dnl init our file count if it isn't already + m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0])) + dnl prepare to store our destination file list for use in config.status + AC_FOREACH([_AM_File], [$1], + [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*])) + m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index)) + dnl and add it to the list of files AC keeps track of, along + dnl with our hook + AC_CONFIG_HEADERS(_AM_File, +dnl COMMANDS, [, INIT-CMDS] +[# update the timestamp +echo timestamp >"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index[" +][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS + m4_popdef([_AM_Dest])])],dnl +[AC_CONFIG_HEADER([$1]) + AC_OUTPUT_COMMANDS( + ifelse(patsubst([$1], [[^ ]], []), + [], + [test -z "$CONFIG_HEADERS" || echo timestamp >dnl + patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl +[am_indx=1 +for am_file in $1; do + case " \$CONFIG_HEADERS " in + *" \$am_file "*) + am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\` + if test -n "\$am_dir"; then + am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\` + for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do + am_tmpdir=\$am_tmpdir\$am_subdir/ + if test ! -d \$am_tmpdir; then + mkdir \$am_tmpdir + fi + done + fi + echo timestamp > "\$am_dir"stamp-h\$am_indx + ;; + esac + am_indx=\`expr \$am_indx + 1\` +done]) +])]) # AM_CONFIG_HEADER + +# _AM_DIRNAME(PATH) +# ----------------- +# Like AS_DIRNAME, only do it during macro expansion +AC_DEFUN([_AM_DIRNAME], + [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, + m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1, + m4_if(m4_regexp([$1], [^/.*]), -1, + [.], + m4_patsubst([$1], [^\(/\).*], [\1])), + m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), + m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl +]) # _AM_DIRNAME + +#serial 1 +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) + + +# serial 1 + +# @defmac AC_PROG_CC_STDC +# @maindex PROG_CC_STDC +# @ovindex CC +# If the C compiler in not in ANSI C mode by default, try to add an option +# to output variable @code{CC} to make it so. This macro tries various +# options that select ANSI C on some system or another. It considers the +# compiler to be in ANSI C mode if it handles function prototypes correctly. +# +# If you use this macro, you should check after calling it whether the C +# compiler has been set to accept ANSI C; if not, the shell variable +# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +# code in ANSI C, you can make an un-ANSIfied copy of it by using the +# program @code{ansi2knr}, which comes with Ghostscript. +# @end defmac + +AC_DEFUN([AM_PROG_CC_STDC], +[AC_REQUIRE([AC_PROG_CC]) +AC_BEFORE([$0], [AC_C_INLINE]) +AC_BEFORE([$0], [AC_C_CONST]) +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C]) +AC_CACHE_VAL(am_cv_prog_cc_stdc, +[am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#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; +} +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; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[am_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" +]) +if test -z "$am_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT([$am_cv_prog_cc_stdc]) +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac +]) + +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN(AM_PATH_SDL, +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + AC_REQUIRE([AC_CANONICAL_TARGET]) + AC_PATH_PROG(SDL_CONFIG, sdl-config, no) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..afd9615 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,150 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +PKG_NAME="the package." + +DIE=0 + +aclocal + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`autoconf' installed to." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && { + (libtool --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`libtool' installed." + echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && { + grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ + (gettext --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`gettext' installed." + echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && { + grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ + (gettext --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`gettext' installed." + echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`automake' installed." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + NO_AUTOMAKE=yes +} + + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing \`aclocal'. The version of \`automake'" + echo "installed doesn't appear recent enough." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "**Warning**: I am going to run \`configure' with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo \`$0\'" command line." + echo +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + +for coin in `find $srcdir -name configure.in -print` +do + dr=`dirname $coin` + if test -f $dr/NO-AUTO-GEN; then + echo skipping $dr -- flagged as no auto-gen + else + echo processing $dr + macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin` + ( cd $dr + aclocalinclude="$ACLOCAL_FLAGS" + for k in $macrodirs; do + if test -d $k; then + aclocalinclude="$aclocalinclude -I $k" + ##else + ## echo "**Warning**: No such directory \`$k'. Ignored." + fi + done + if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then + if grep "sed.*POTFILES" configure.in >/dev/null; then + : do nothing -- we still have an old unmodified configure.in + else + echo "Creating $dr/aclocal.m4 ..." + test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 + echo "Running gettextize... Ignore non-fatal messages." + echo "no" | gettextize --force --copy + echo "Making $dr/aclocal.m4 writable ..." + test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 + fi + fi + if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then + echo "Creating $dr/aclocal.m4 ..." + test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 + echo "Running gettextize... Ignore non-fatal messages." + echo "no" | gettextize --force --copy + echo "Making $dr/aclocal.m4 writable ..." + test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 + fi + if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then + echo "Running libtoolize..." + libtoolize --force --copy + fi + echo "Running aclocal $aclocalinclude ..." + aclocal $aclocalinclude + if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then + echo "Running autoheader..." + autoheader + fi + echo "Running automake --gnu $am_opt ..." + automake --add-missing --gnu $am_opt + echo "Running autoconf ..." + autoconf + ) + fi +done + +#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c + +if test x$NOCONFIGURE = x; then + echo Running $srcdir/configure $conf_flags "$@" ... + $srcdir/configure $conf_flags "$@" \ + && echo Now type \`make\' to compile $PKG_NAME +else + echo Skipping configure process. +fi diff --git a/bomberclone.cfg b/bomberclone.cfg new file mode 100644 index 0000000..5ba29c1 --- /dev/null +++ b/bomberclone.cfg @@ -0,0 +1,13 @@ +resolutionx=640 +resolutiony=480 +fullscreen=0 +ai_family=2 +fieldsizex=25 +fieldsizey=15 +notify=1 +debug=0 +pkgsend=4 +maxplayer=5 +masterserver=x.yz.to:11100 +selectplayer=1 +playername= \ No newline at end of file diff --git a/bomberclone.prj b/bomberclone.prj new file mode 100644 index 0000000..95def7b --- /dev/null +++ b/bomberclone.prj @@ -0,0 +1,157 @@ +# Anjuta Version 0.1.9 +Compatibility Level: 1 + + +it's a Bomberman Clone + + + +dnl Check for SDL + AM_PATH_SDL(1.1.0, + :, + AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix) + ) + + CFLAGS="$SDL_CFLAGS $CFLAGS" + LIBS="$SDL_LIBS $LIBS" + + + + +case "$target" in + *-*-cygwin* | *-*-mingw32*) + CFLAGS="$CFLAGS" + LIBS="$LIBS -liberty -lwsock32" + ;; +esac + CFLAGS="$CFLAGS -Wall" + + + + + + + + + + +props.file.type=project + +anjuta.version=0.1.9 +anjuta.compatibility.level=1 + +project.name=bomberclone +project.type=GENERIC +project.target.type=EXECUTABLE +project.version=0.9 +project.author=steffen +project.source.target=bomberclone + +project.excluded.modules= + +project.has.gettext=0 + +project.programming.language=C + +project.menu.entry=bomberclone Version 0.9 +project.menu.group=Games +project.menu.comment=bomberclone Version 0.9 +project.menu.icon= +project.menu.need.terminal=0 + +project.configure.options= + +anjuta.program.arguments= + +project.config.blocked=0 + +project.config.disable.overwriting=0 0 1 0 0 0 0 0 0 +project.config.extra.modules.before= +project.config.extra.modules.after= + +module.include.name=include +module.include.type= +module.include.expanded=0 +module.include.files= + +module.source.name=src +module.source.type= +module.source.expanded=1 +module.source.files=\ + main.c\ + bomb.c\ + bomberclone.h\ + debug.c\ + packets.c\ + font.c\ + gfx.c\ + player.c\ + packets.h\ + game.c\ + netmenu.c\ + network.c\ + menu.c\ + field.c\ + network.h\ + configuration.c\ + udp.c\ + sysfunc.c\ + pkgcache.c\ + gamesrv.h\ + gamesrv.c\ + gfx.h\ + basic.h\ + chat.c\ + multiwait.c\ + chat.h\ + keybinput.c\ + keybinput.h + +module.pixmap.name=pixmaps +module.pixmap.type= +module.pixmap.expanded=0 +module.pixmap.files= + +module.data.name=data +module.data.type= +module.data.expanded=0 +module.data.files= + +module.help.name=help +module.help.type= +module.help.expanded=0 +module.help.files= + +module.doc.name=doc +module.doc.type= +module.doc.expanded=0 +module.doc.files= + +module.po.expanded=0 +module.po.files= + +compiler.options.supports= + +compiler.options.include.paths= + +compiler.options.library.paths= + +compiler.options.libraries= +compiler.options.libraries.selected= + +compiler.options.defines= + +compiler.options.warning.buttons=0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 + +compiler.options.optimize.buttons=0 1 0 0 + +compiler.options.other.buttons=1 0 + +compiler.options.other.c.flags= + +compiler.options.other.l.flags= + +compiler.options.other.l.libs= + +project.source.paths= + diff --git a/bomberclone.pws b/bomberclone.pws new file mode 100644 index 0000000..4266a86 --- /dev/null +++ b/bomberclone.pws @@ -0,0 +1,51 @@ + +[executer] +RunInTerminal=false + +[Project DBase] +ShowLocals=true + +[filenumbers] +0=1028 +1=10 +2=7 +3=477 +4=33 +5=129 +6=370 +7=252 +8=144 +9=8 +10=1 + +[filemarkers] +0= +1= +2= +3= +4= +5= +6= +7= +8= +9= +10= + +[replace_text] +0=fieldsize +1=(struct _net_addr *addr +2=struct _net_addr *addr) +3=&addr + +[find_text] +0=set_ill +1=playercol +2=GFX INIT +3=gameloop +4=do_playerdata +5=player_die +6=net_pl +7=pingack + +[find_in_files] +0=old diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..f497108 --- /dev/null +++ b/config.h.in @@ -0,0 +1,25 @@ +/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */ + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +#undef ENABLE_NLS +#undef HAVE_CATGETS +#undef HAVE_GETTEXT +#undef HAVE_LC_MESSAGES +#undef HAVE_STPCPY +#undef HAVE_LIBSM +#undef PACKAGE_LOCALE_DIR +#undef PACKAGE_DOC_DIR +#undef PACKAGE_DATA_DIR +#undef PACKAGE_PIXMAPS_DIR +#undef PACKAGE_HELP_DIR +#undef PACKAGE_MENU_DIR +#undef PACKAGE_SOURCE_DIR + +/* Name of package */ +#undef PACKAGE + +/* Version number of package */ +#undef VERSION + diff --git a/config.log b/config.log new file mode 100644 index 0000000..82823cf --- /dev/null +++ b/config.log @@ -0,0 +1,42 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +configure:569: checking for a BSD compatible install +configure:622: checking whether build environment is sane +configure:693: checking for mawk +configure:723: checking whether make sets ${MAKE} +configure:845: checking for strerror in -lcposix +configure:864: cc -o conftest conftest.c -lcposix 1>&5 +/usr/bin/ld: cannot find -lcposix +collect2: ld returned 1 exit status +configure: failed program was: +#line 853 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror(); + +int main() { +strerror() +; return 0; } +configure:889: checking for gcc +configure:1002: checking whether the C compiler (gcc ) works +configure:1018: gcc -o conftest conftest.c 1>&5 +configure:1044: checking whether the C compiler (gcc ) is a cross-compiler +configure:1049: checking whether we are using GNU C +configure:1058: gcc -E conftest.c +configure:1077: checking whether gcc accepts -g +configure:1116: checking for style of include used by make +configure:1150: checking dependency style of gcc +configure:1220: checking for gcc option to accept ANSI C +configure:1274: gcc -c -g -O2 conftest.c 1>&5 +configure:1298: checking how to run the C preprocessor +configure:1319: gcc -E conftest.c >/dev/null 2>conftest.out +configure:1378: checking for ANSI C header files +configure:1391: gcc -E conftest.c >/dev/null 2>conftest.out +configure:1458: gcc -o conftest -g -O2 conftest.c 1>&5 +configure:1483: checking target system type +configure:1542: checking for sdl-config +configure:1577: checking for SDL - version >= 1.1.0 +configure:1662: gcc -o conftest -g -O2 -I/usr/include/SDL -D_REENTRANT conftest.c -L/usr/lib -lSDL -lpthread 1>&5 diff --git a/config.status b/config.status new file mode 100755 index 0000000..422725e --- /dev/null +++ b/config.status @@ -0,0 +1,366 @@ +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host steffenp: +# +# ./configure +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]" +for ac_option +do + case "$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion" + exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "./config.status generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "$ac_cs_usage"; exit 0 ;; + *) echo "$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=. +ac_given_INSTALL="/usr/bin/install -c" + +trap 'rm -fr +Makefile +src/Makefile + config.h conftest*; exit 1' 1 2 15 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +/^[ ]*VPATH[ ]*=[^:]*$/d + +s%@SHELL@%/bin/sh%g +s%@CFLAGS@%-I/usr/include/SDL -D_REENTRANT -g -O2 -Wall%g +s%@CPPFLAGS@%%g +s%@CXXFLAGS@%%g +s%@FFLAGS@%%g +s%@DEFS@%-DHAVE_CONFIG_H%g +s%@LDFLAGS@%%g +s%@LIBS@%-L/usr/lib -lSDL -lpthread %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%@datadir@%${prefix}/share%g +s%@sysconfdir@%${prefix}/etc%g +s%@sharedstatedir@%${prefix}/com%g +s%@localstatedir@%${prefix}/var%g +s%@libdir@%${exec_prefix}/lib%g +s%@includedir@%${prefix}/include%g +s%@oldincludedir@%/usr/include%g +s%@infodir@%${prefix}/info%g +s%@mandir@%${prefix}/man%g +s%@INSTALL_PROGRAM@%${INSTALL}%g +s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g +s%@INSTALL_DATA@%${INSTALL} -m 644%g +s%@PACKAGE@%bomberclone%g +s%@VERSION@%0.9%g +s%@EXEEXT@%%g +s%@OBJEXT@%o%g +s%@ACLOCAL@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run aclocal%g +s%@AUTOCONF@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run autoconf%g +s%@AUTOMAKE@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run automake%g +s%@AUTOHEADER@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run autoheader%g +s%@MAKEINFO@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run makeinfo%g +s%@AMTAR@%${SHELL} /home/steffen/Daten/Programmierung/Linux/bomberclone/missing --run tar%g +s%@install_sh@%/home/steffen/Daten/Programmierung/Linux/bomberclone/install-sh%g +s%@INSTALL_STRIP_PROGRAM@%${SHELL} $(install_sh) -c -s%g +s%@AWK@%mawk%g +s%@SET_MAKE@%%g +s%@AMDEP_TRUE@%%g +s%@AMDEP_FALSE@%#%g +s%@AMDEPBACKSLASH@%\%g +s%@DEPDIR@%.deps%g +s%@CC@%gcc%g +s%@am__include@%include%g +s%@am__quote@%%g +s%@CCDEPMODE@%depmode=gcc%g +s%@CPP@%gcc -E%g +s%@target@%%g +s%@target_alias@%%g +s%@target_cpu@%%g +s%@target_vendor@%%g +s%@target_os@%%g +s%@SDL_CONFIG@%/usr/bin/sdl-config%g +s%@SDL_CFLAGS@%-I/usr/include/SDL -D_REENTRANT%g +s%@SDL_LIBS@%-L/usr/lib -lSDL -lpthread%g +s%@NO_PREFIX_PACKAGE_DATA_DIR@%share/bomberclone%g +s%@PACKAGE_DATA_DIR@%/usr/local/share/bomberclone%g +s%@NO_PREFIX_PACKAGE_DOC_DIR@%doc/bomberclone%g +s%@PACKAGE_DOC_DIR@%/usr/local/doc/bomberclone%g +s%@NO_PREFIX_PACKAGE_PIXMAPS_DIR@%share/bomberclone/pixmaps%g +s%@PACKAGE_PIXMAPS_DIR@%/usr/local/share/bomberclone/pixmaps%g +s%@NO_PREFIX_PACKAGE_HELP_DIR@%share/bomberclone/help%g +s%@PACKAGE_HELP_DIR@%/usr/local/share/bomberclone/help%g +s%@NO_PREFIX_PACKAGE_MENU_DIR@%share/bomberclone%g +s%@PACKAGE_MENU_DIR@%/usr/local/share/bomberclone%g + +CEOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi + +CONFIG_FILES=${CONFIG_FILES-"Makefile +src/Makefile +"} +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then + CONFIG_HEADERS="config.h" +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +am_indx=1 +for am_file in config.h; do + case " $CONFIG_HEADERS " in + *" $am_file "*) + am_dir=`echo $am_file |sed 's%:.*%%;s%[^/]*$%%'` + if test -n "$am_dir"; then + am_tmpdir=`echo $am_dir |sed 's%^\(/*\).*$%\1%'` + for am_subdir in `echo $am_dir |sed 's%/% %'`; do + am_tmpdir=$am_tmpdir$am_subdir/ + if test ! -d $am_tmpdir; then + mkdir $am_tmpdir + fi + done + fi + echo timestamp > "$am_dir"stamp-h$am_indx + ;; + esac + am_indx=`expr $am_indx + 1` +done +AMDEP_TRUE="" +ac_aux_dir="." + +test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h + +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # 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 -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //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=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + + +exit 0 diff --git a/configure b/configure new file mode 100755 index 0000000..07b319a --- /dev/null +++ b/configure @@ -0,0 +1,2286 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors" +ac_help="$ac_help + --with-sdl-prefix=PFX Prefix where SDL is installed (optional)" +ac_help="$ac_help + --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)" +ac_help="$ac_help + --disable-sdltest Do not try to compile and run a test SDL program" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -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 ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$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" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + 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) + # 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 << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --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 +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$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" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + 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) + 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" ;; + + -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 ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + 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 "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=configure.in + +# 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 its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + 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 + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +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 + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` + +# 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 +# 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" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:569: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/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 + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_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. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&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_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 +echo "configure:622: checking whether build environment is sane" >&5 +# 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 "configure: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" 1>&2; exit 1; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { echo "configure: error: newly created file is older than distributed files! +Check your system clock" 1>&2; exit 1; } +fi +echo "$ac_t""yes" 1>&6 +if test "$program_transform_name" = s,x,x,; then + program_transform_name= +else + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed +fi +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" + +# sed with no file args requires a program. +test "$program_transform_name" = "" && program_transform_name="s,x,x," + +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= + am_backtick='`' + echo "configure: warning: ${am_backtick}missing' script is too old or missing" 1>&2 +fi + +for ac_prog in mawk gawk 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:693: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AWK="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AWK="$ac_cv_prog_AWK" +if test -n "$AWK"; then + echo "$ac_t""$AWK" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AWK" && break +done + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:723: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Check whether --enable-dependency-tracking or --disable-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 + + + + +rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null + + +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { echo "configure: error: source directory already configured; run \"make distclean\" there first" 1>&2; exit 1; } +fi + +# Define the identity of the package. +PACKAGE=bomberclone +VERSION=0.9 +cat >> confdefs.h <> confdefs.h <&6 +echo "configure:845: checking for strerror in -lcposix" >&5 +ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lcposix $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lcposix" +else + echo "$ac_t""no" 1>&6 +fi + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:889: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:919: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_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 $# -gt 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 + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:970: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:1002: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 1013 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:1018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1044: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:1049: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1077: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&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 + + +am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +echo $ac_n "checking for style of include used by $am_make""... $ac_c" 1>&6 +echo "configure:1116: checking for style of include used by $am_make" >&5 +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 | fgrep -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 "$ac_t""$_am_result" 1>&6 +rm -f confinc confmf + + +depcc="$CC" am_compiler_list= + +echo $ac_n "checking dependency style of $depcc""... $ac_c" 1>&6 +echo "configure:1150: checking dependency style of $depcc" >&5 +if eval "test \"`echo '$''{'am_cv_CC_dependencies_compiler_type'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&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 + + 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 + # 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. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi + +echo "$ac_t""$am_cv_CC_dependencies_compiler_type" 1>&6 +CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" + + + + + +echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 +echo "configure:1220: checking for ${CC-cc} option to accept ANSI C" >&5 +if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + cat > conftest.$ac_ext < +#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; +} +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; } +EOF +if { (eval echo configure:1274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + am_cv_prog_cc_stdc="$ac_arg"; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +CC="$ac_save_CC" + +fi + +if test -z "$am_cv_prog_cc_stdc"; then + echo "$ac_t""none needed" 1>&6 +else + echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1298: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1319: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1336: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1353: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1378: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + + echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:1483: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +# Check whether --with-sdl-prefix or --without-sdl-prefix was given. +if test "${with_sdl_prefix+set}" = set; then + withval="$with_sdl_prefix" + sdl_prefix="$withval" +else + sdl_prefix="" +fi + +# Check whether --with-sdl-exec-prefix or --without-sdl-exec-prefix was given. +if test "${with_sdl_exec_prefix+set}" = set; then + withval="$with_sdl_exec_prefix" + sdl_exec_prefix="$withval" +else + sdl_exec_prefix="" +fi + +# Check whether --enable-sdltest or --disable-sdltest was given. +if test "${enable_sdltest+set}" = set; then + enableval="$enable_sdltest" + : +else + enable_sdltest=yes +fi + + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + + # Extract the first word of "sdl-config", so it can be a program name with args. +set dummy sdl-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1542: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_SDL_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$SDL_CONFIG" in + /*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_SDL_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" + ;; +esac +fi +SDL_CONFIG="$ac_cv_path_SDL_CONFIG" +if test -n "$SDL_CONFIG"; then + echo "$ac_t""$SDL_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + min_sdl_version=1.1.0 + echo $ac_n "checking for SDL - version >= $min_sdl_version""... $ac_c" 1>&6 +echo "configure:1577: checking for SDL - version >= $min_sdl_version" >&5 + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + rm -f conf.sdltest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat > conftest.$ac_ext < +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + + +EOF +if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + no_sdl=yes +fi +rm -fr conftest* +fi + + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + echo "$ac_t""yes" 1>&6 + : + else + echo "$ac_t""no" 1>&6 + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + cat > conftest.$ac_ext < +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main + +int main() { + return 0; +; return 0; } +EOF +if { (eval echo configure:1711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" +fi +rm -f conftest* + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + { echo "configure: error: SDL not found. Make sure sdl-config is in your PATH" 1>&2; exit 1; } + + fi + + + rm -f conf.sdltest + + + CFLAGS="$SDL_CFLAGS $CFLAGS" + LIBS="$SDL_LIBS $LIBS" + + +case "$target" in + *-*-cygwin* | *-*-mingw32*) + CFLAGS="$CFLAGS" + LIBS="$LIBS -liberty -lwsock32" + ;; +esac + CFLAGS="$CFLAGS -Wall" + + + +packagesrcdir=`cd $srcdir && pwd` + +if test "x${prefix}" = "xNONE"; then + packageprefix=${ac_default_prefix} +else + packageprefix=${prefix} +fi + +packagedatadir=share/${PACKAGE} +packagedocdir=doc/${PACKAGE} + +packagepixmapsdir=${packagedatadir}/pixmaps +packagehelpdir=${packagedatadir}/help +packagemenudir=${packagedatadir} + +NO_PREFIX_PACKAGE_DATA_DIR="${packagedatadir}" + +PACKAGE_DATA_DIR="${packageprefix}/${packagedatadir}" + + +NO_PREFIX_PACKAGE_DOC_DIR="${packagedocdir}" + +PACKAGE_DOC_DIR="${packageprefix}/${packagedocdir}" + + +NO_PREFIX_PACKAGE_PIXMAPS_DIR="${packagepixmapsdir}" + +PACKAGE_PIXMAPS_DIR="${packageprefix}/${packagepixmapsdir}" + + +NO_PREFIX_PACKAGE_HELP_DIR="${packagehelpdir}" + +PACKAGE_HELP_DIR="${packageprefix}/${packagehelpdir}" + + +NO_PREFIX_PACKAGE_MENU_DIR="${packagemenudir}" + +PACKAGE_MENU_DIR="${packageprefix}/${packagemenudir}" + + +cat >> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h < confcache <<\EOF +# 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. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# 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. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo " +Makefile +src/Makefile + config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@PACKAGE@%$PACKAGE%g +s%@VERSION@%$VERSION%g +s%@EXEEXT@%$EXEEXT%g +s%@OBJEXT@%$OBJEXT%g +s%@ACLOCAL@%$ACLOCAL%g +s%@AUTOCONF@%$AUTOCONF%g +s%@AUTOMAKE@%$AUTOMAKE%g +s%@AUTOHEADER@%$AUTOHEADER%g +s%@MAKEINFO@%$MAKEINFO%g +s%@AMTAR@%$AMTAR%g +s%@install_sh@%$install_sh%g +s%@INSTALL_STRIP_PROGRAM@%$INSTALL_STRIP_PROGRAM%g +s%@AWK@%$AWK%g +s%@SET_MAKE@%$SET_MAKE%g +s%@AMDEP_TRUE@%$AMDEP_TRUE%g +s%@AMDEP_FALSE@%$AMDEP_FALSE%g +s%@AMDEPBACKSLASH@%$AMDEPBACKSLASH%g +s%@DEPDIR@%$DEPDIR%g +s%@CC@%$CC%g +s%@am__include@%$am__include%g +s%@am__quote@%$am__quote%g +s%@CCDEPMODE@%$CCDEPMODE%g +s%@CPP@%$CPP%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@SDL_CONFIG@%$SDL_CONFIG%g +s%@SDL_CFLAGS@%$SDL_CFLAGS%g +s%@SDL_LIBS@%$SDL_LIBS%g +s%@NO_PREFIX_PACKAGE_DATA_DIR@%$NO_PREFIX_PACKAGE_DATA_DIR%g +s%@PACKAGE_DATA_DIR@%$PACKAGE_DATA_DIR%g +s%@NO_PREFIX_PACKAGE_DOC_DIR@%$NO_PREFIX_PACKAGE_DOC_DIR%g +s%@PACKAGE_DOC_DIR@%$PACKAGE_DOC_DIR%g +s%@NO_PREFIX_PACKAGE_PIXMAPS_DIR@%$NO_PREFIX_PACKAGE_PIXMAPS_DIR%g +s%@PACKAGE_PIXMAPS_DIR@%$PACKAGE_PIXMAPS_DIR%g +s%@NO_PREFIX_PACKAGE_HELP_DIR@%$NO_PREFIX_PACKAGE_HELP_DIR%g +s%@PACKAGE_HELP_DIR@%$PACKAGE_HELP_DIR%g +s%@NO_PREFIX_PACKAGE_MENU_DIR@%$NO_PREFIX_PACKAGE_MENU_DIR%g +s%@PACKAGE_MENU_DIR@%$PACKAGE_MENU_DIR%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS < "\$am_dir"stamp-h\$am_indx + ;; + esac + am_indx=\`expr \$am_indx + 1\` +done +AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir" + +EOF +cat >> $CONFIG_STATUS <<\EOF +test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h + +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # 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 -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //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=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..7104b2b --- /dev/null +++ b/configure.in @@ -0,0 +1,101 @@ +dnl Process this file with autoconf to produce a configure script. +dnl Created by Anjuta - will be overwritten +dnl If you don't want it to overwrite it, +dnl Please disable it in the Anjuta project configuration + +AC_INIT(configure.in) +AM_INIT_AUTOMAKE(bomberclone, 0.9) +AM_CONFIG_HEADER(config.h) + +AC_ISC_POSIX +AC_PROG_CC +AM_PROG_CC_STDC +AC_HEADER_STDC + +dnl Checks for programs. +dnl Checks for libraries. +dnl Check for SDL + AM_PATH_SDL(1.1.0, + :, + AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix) + ) + + CFLAGS="$SDL_CFLAGS $CFLAGS" + LIBS="$SDL_LIBS $LIBS" + + +dnl Checks for header files. +dnl Checks for typedefs, structures, and compiler characteristics. +case "$target" in + *-*-cygwin* | *-*-mingw32*) + CFLAGS="$CFLAGS" + LIBS="$LIBS -liberty -lwsock32" + ;; +esac + CFLAGS="$CFLAGS -Wall" + + +dnl Checks for library functions. +dnl Checks for Additional stuffs. + +dnl Set PACKAGE SOURCE DIR in config.h. +packagesrcdir=`cd $srcdir && pwd` + +dnl Set PACKAGE PREFIX +if test "x${prefix}" = "xNONE"; then + packageprefix=${ac_default_prefix} +else + packageprefix=${prefix} +fi + +dnl Set PACKAGE DATA & DOC DIR +packagedatadir=share/${PACKAGE} +packagedocdir=doc/${PACKAGE} + +dnl Set PACKAGE DIRS in config.h. +packagepixmapsdir=${packagedatadir}/pixmaps +packagehelpdir=${packagedatadir}/help +packagemenudir=${packagedatadir} + +dnl Subst PACKAGE_DATA_DIR. +NO_PREFIX_PACKAGE_DATA_DIR="${packagedatadir}" +AC_SUBST(NO_PREFIX_PACKAGE_DATA_DIR) +PACKAGE_DATA_DIR="${packageprefix}/${packagedatadir}" +AC_SUBST(PACKAGE_DATA_DIR) + +dnl Subst PACKAGE_DOC_DIR. +NO_PREFIX_PACKAGE_DOC_DIR="${packagedocdir}" +AC_SUBST(NO_PREFIX_PACKAGE_DOC_DIR) +PACKAGE_DOC_DIR="${packageprefix}/${packagedocdir}" +AC_SUBST(PACKAGE_DOC_DIR) + +dnl Subst PACKAGE_PIXMAPS_DIR. +NO_PREFIX_PACKAGE_PIXMAPS_DIR="${packagepixmapsdir}" +AC_SUBST(NO_PREFIX_PACKAGE_PIXMAPS_DIR) +PACKAGE_PIXMAPS_DIR="${packageprefix}/${packagepixmapsdir}" +AC_SUBST(PACKAGE_PIXMAPS_DIR) + +dnl Subst PACKAGE_HELP_DIR. +NO_PREFIX_PACKAGE_HELP_DIR="${packagehelpdir}" +AC_SUBST(NO_PREFIX_PACKAGE_HELP_DIR) +PACKAGE_HELP_DIR="${packageprefix}/${packagehelpdir}" +AC_SUBST(PACKAGE_HELP_DIR) + +dnl Subst PACKAGE_MENU_DIR. +NO_PREFIX_PACKAGE_MENU_DIR="${packagemenudir}" +AC_SUBST(NO_PREFIX_PACKAGE_MENU_DIR) +PACKAGE_MENU_DIR="${packageprefix}/${packagemenudir}" +AC_SUBST(PACKAGE_MENU_DIR) + +AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${packageprefix}/${packagedatadir}") +AC_DEFINE_UNQUOTED(PACKAGE_DOC_DIR, "${packageprefix}/${packagedocdir}") +AC_DEFINE_UNQUOTED(PACKAGE_PIXMAPS_DIR, "${packageprefix}/${packagepixmapsdir}") +AC_DEFINE_UNQUOTED(PACKAGE_HELP_DIR, "${packageprefix}/${packagehelpdir}") +AC_DEFINE_UNQUOTED(PACKAGE_MENU_DIR, "${packageprefix}/${packagemenudir}") +AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}") + +AC_OUTPUT([ +Makefile +src/Makefile +]) + diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..6589965 --- /dev/null +++ b/depcomp @@ -0,0 +1,411 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000 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 . + +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 +# `libtool' can also be set to `yes' or `no'. + +depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} +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. 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. + stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + outname="$stripped.o" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + # 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" + ;; + +tru64) + # The Tru64 AIX 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. + + tmpdepfile1="$object.d" + tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` + if test "$libtool" = yes; then + "$@" -Wc,-MD + else + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a space and a tab 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 proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + test -z "$dashmflag" && dashmflag=-M + ( IFS=" " + case " $* " in + *" --mode=compile "*) # this is libtool, let us make it quiet + for arg + do # cycle over the arguments + case "$arg" in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + 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) + # 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;; + -*) + ;; + *) + set fnord "$@" "$arg"; shift;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tail +3 "$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 proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + 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 proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + 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 diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..e9de238 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/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/missing b/missing new file mode 100755 index 0000000..0a7fb5a --- /dev/null +++ b/missing @@ -0,0 +1,283 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. +# Originally by Fran,cois 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. + +# 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. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +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 + --run try to run the given command, and emulate it if it fails + +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 + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing 0.3 - GNU automake" + ;; + + -*) + 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_ac}'. 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_ac}'. 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_ac}'. 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_ac}` + 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_ac}'. + 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 + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + 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 + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar ${1+"$@"} && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar ${1+"$@"} && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + 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/mkinstalldirs b/mkinstalldirs new file mode 100755 index 0000000..b28dedf --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1 2003/04/23 16:00:11 stpohle 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/src/Makefile.MINGW b/src/Makefile.MINGW new file mode 100644 index 0000000..2988139 --- /dev/null +++ b/src/Makefile.MINGW @@ -0,0 +1,38 @@ +# .SILENT: +LIBS=-L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -mno-cygwin -liberty -lwsock32 +CFLAGS=-I/usr/local/include/SDL -Dmain=SDL_main -I/usr/include/mingw -DWIN32 -Uunix -mno-cygwin + +OBJS=bomb.o configuration.o debug.o gfx.o main.o field.o font.o game.o gamesrv.o menu.o netmenu.o network.o packets.o pkgcache.o player.o sysfunc.o udp.o chat.o multiwait.o keybinput.o + + +all: config bomberclone + +config: + echo "#define VERSION \"0.9\"" >../config.h + +rebuild: clean all + +bomberclone: $(OBJS) + gcc -o $@ $^ $(LIBS) + +%.o: %.c + gcc $(CFLAGS) -c -o $@ $^ $(DFLAGS) + +clean: + del *.o + del bomberclone.exe + +cleanall: clean + del *.*~ + +source: cleanall + + + + + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..187b62f --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,35 @@ + +INCLUDES = + +bin_PROGRAMS = bomberclone + +bomberclone_SOURCES = \ + main.c\ + bomb.c\ + bomberclone.h\ + debug.c\ + packets.c\ + font.c\ + gfx.c\ + player.c\ + packets.h\ + game.c\ + netmenu.c\ + network.c\ + udp.c\ + menu.c\ + field.c\ + network.h\ + sysfunc.c\ + configuration.c\ + pkgcache.c\ + gamesrv.h\ + gamesrv.c \ + chat.c \ + multiwait.c \ + chat.h \ + keybinput.h \ + keybinput.c + +## bomberclone_LDADD = + diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..fc87441 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,374 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# 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@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AMTAR = @AMTAR@ +AWK = @AWK@ +CC = @CC@ +DEPDIR = @DEPDIR@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +NO_PREFIX_PACKAGE_DATA_DIR = @NO_PREFIX_PACKAGE_DATA_DIR@ +NO_PREFIX_PACKAGE_DOC_DIR = @NO_PREFIX_PACKAGE_DOC_DIR@ +NO_PREFIX_PACKAGE_HELP_DIR = @NO_PREFIX_PACKAGE_HELP_DIR@ +NO_PREFIX_PACKAGE_MENU_DIR = @NO_PREFIX_PACKAGE_MENU_DIR@ +NO_PREFIX_PACKAGE_PIXMAPS_DIR = @NO_PREFIX_PACKAGE_PIXMAPS_DIR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_DATA_DIR = @PACKAGE_DATA_DIR@ +PACKAGE_DOC_DIR = @PACKAGE_DOC_DIR@ +PACKAGE_HELP_DIR = @PACKAGE_HELP_DIR@ +PACKAGE_MENU_DIR = @PACKAGE_MENU_DIR@ +PACKAGE_PIXMAPS_DIR = @PACKAGE_PIXMAPS_DIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +INCLUDES = + +bin_PROGRAMS = bomberclone + +bomberclone_SOURCES = \ + main.c\ + bomb.c\ + bomberclone.h\ + debug.c\ + packets.c\ + font.c\ + gfx.c\ + player.c\ + packets.h\ + game.c\ + netmenu.c\ + network.c\ + udp.c\ + menu.c\ + field.c\ + network.h\ + sysfunc.c\ + configuration.c\ + pkgcache.c\ + gamesrv.h\ + gamesrv.c \ + chat.c \ + multiwait.c \ + chat.h \ + keybinput.h \ + keybinput.c + +subdir = src +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = bomberclone$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +am_bomberclone_OBJECTS = main.$(OBJEXT) bomb.$(OBJEXT) debug.$(OBJEXT) \ + packets.$(OBJEXT) font.$(OBJEXT) gfx.$(OBJEXT) player.$(OBJEXT) \ + game.$(OBJEXT) netmenu.$(OBJEXT) network.$(OBJEXT) \ + udp.$(OBJEXT) menu.$(OBJEXT) field.$(OBJEXT) sysfunc.$(OBJEXT) \ + configuration.$(OBJEXT) pkgcache.$(OBJEXT) gamesrv.$(OBJEXT) \ + chat.$(OBJEXT) multiwait.$(OBJEXT) keybinput.$(OBJEXT) +bomberclone_OBJECTS = $(am_bomberclone_OBJECTS) +bomberclone_LDADD = $(LDADD) +bomberclone_DEPENDENCIES = +bomberclone_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/bomb.Po $(DEPDIR)/chat.Po \ +@AMDEP_TRUE@ $(DEPDIR)/configuration.Po $(DEPDIR)/debug.Po \ +@AMDEP_TRUE@ $(DEPDIR)/field.Po $(DEPDIR)/font.Po \ +@AMDEP_TRUE@ $(DEPDIR)/game.Po $(DEPDIR)/gamesrv.Po \ +@AMDEP_TRUE@ $(DEPDIR)/gfx.Po $(DEPDIR)/keybinput.Po \ +@AMDEP_TRUE@ $(DEPDIR)/main.Po $(DEPDIR)/menu.Po \ +@AMDEP_TRUE@ $(DEPDIR)/multiwait.Po $(DEPDIR)/netmenu.Po \ +@AMDEP_TRUE@ $(DEPDIR)/network.Po $(DEPDIR)/packets.Po \ +@AMDEP_TRUE@ $(DEPDIR)/pkgcache.Po $(DEPDIR)/player.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sysfunc.Po $(DEPDIR)/udp.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(bomberclone_SOURCES) +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(bomberclone_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +bomberclone$(EXEEXT): $(bomberclone_OBJECTS) $(bomberclone_DEPENDENCIES) + @rm -f bomberclone$(EXEEXT) + $(LINK) $(bomberclone_LDFLAGS) $(bomberclone_OBJECTS) $(bomberclone_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/bomb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/configuration.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/debug.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/field.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/font.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/game.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gamesrv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gfx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/keybinput.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/menu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/multiwait.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/netmenu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/network.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/packets.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pkgcache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/player.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sysfunc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/udp.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(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 $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || 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 $(PROGRAMS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) + +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)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +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-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +.PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic distclean distclean-compile distclean-depend \ + distclean-generic distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-binPROGRAMS install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic tags uninstall uninstall-am \ + uninstall-binPROGRAMS 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/src/basic.h b/src/basic.h new file mode 100644 index 0000000..632d40a --- /dev/null +++ b/src/basic.h @@ -0,0 +1,150 @@ +/* basic types which we need everywhere */ + +#ifndef _BC_BASIC_H_ + +#define _BC_BASIC_H_ + +#define SUB_VERSION 6 + +#define GAME_SPECIAL_ITEMBOMB 10 +#define GAME_SPECIAL_ITEMFIRE 10 +#define GAME_SPECIAL_ITEMSHOE 15 +#define GAME_SPECIAL_ITEMDEATH 25 + +#define PKG_RESENDCACHE_SIZE (64*1024) +#define PKG_IN_INDEX_NUM 256 +#define RESENDCACHE_TIMEOUT 500 +#define RESENDCACHE_RETRY 10 + +#define START_BOMBS 1 +#define START_RANGE 2 +#define START_SPEED 16 +#define SPEEDMUL 1.2 + +#define MAX_PLAYERS 8 +#define MAX_BOMBS 12 +#define MAX_RANGE 10 +#define MAX_SPEED 40 +#define MAX_UPDATERECTS 2048 +#define MAX_CONNECTS 16 /* maximal number of connection data */ +#define MAX_SERVERENTRYS 8 /* number of entrys in the server tab */ +#define MAX_GAMESRVENTRYS 255 /* number of entry which can be get */ +#define MAX_FIELDSIZE_X 51 +#define MAX_FIELDSIZE_Y 31 +#define MIN_FIELDSIZE_X 21 +#define MIN_FIELDSIZE_Y 13 + + +#define ANI_FIRETIMEOUT 20 +#define ANI_BOMBTIMEOUT 1 +#define ANI_PLAYERTIMEOUT 1 +#define ANI_PLAYERILLTIMEOUT 1 +#define ANI_STONETIMEOUT 10 + +#define TIME_FACTOR 50 +#define BOMB_TIMEOUT 5 +#define IL_TIMEOUT 20 + +#define LEN_PLAYERNAME 10 +#define LEN_SERVERNAME 41 +#define LEN_PORT 6 +#define LEN_GAMENAME 32 + + +#define DEFAULT_UDPPORT 11000 +#define DEFAULT_GMUDPPORT "11100" +#define DEFAULT_GAMEMASTER "x.yz.to:11100" +#define GAMESRV_TIMEOUT 2000 /* Timeout of the GameSrv_GetEntry */ + +#define UDP_TIMEOUT 15000 +#define BUF_SIZE 1024 + + +enum _backgound { // to load some diffrent logos.. + BG_start = 0, + BG_net, + BG_conf +}; + + +enum _gametype { + GT_single = 0, + GT_multi +}; + + +enum _multitype { + MT_ptpm, // udp ptp master + MT_ptps // udp ptp client +}; + + +enum _gamestate { + GS_startup = 0, + GS_quit, + GS_wait, // waiting for players to join + GS_update, + GS_ready, + GS_running +}; + + +enum _fieldtype { + FT_nothing = 0, // Nothing in here + FT_stone, // Stones you can bomb away + FT_block, // Stones which can't bomb away + FT_death, // The bad Powerup + FT_fire, // Special Field for the fire + FT_bomb, + FT_shoe, + + FT_max // just to know how many types there are +}; + + +enum _playerillnestype { + PI_keys = 0, + PI_range, + PI_slow, + PI_bomb, + + PI_max // just to know what is the last number +}; + + +enum _bombstate { + BS_off = 0, + BS_ticking, + BS_exploding +}; + + +enum _playerstateflags { + PSF_used = 1, // Player Unused | Player Used + PSF_net = 2, // Local Player | AI / Network Player + PSF_alife = 4, // Player is Dead | Player is Alife + PSF_playing = 8, // Watching Player | Playing Player -- as long as one don't delete +}; + +#define PSFM_used (PSF_used + PSF_playing) +#define PSFM_alife (PSF_used + PSF_alife + PSF_playing) +#define PS_IS_dead(__ps) (((__ps) & (PSFM_alife)) == (PSFM_used)) +#define PS_IS_alife(__ps) (((__ps) & (PSFM_alife)) == (PSFM_alife)) +#define PS_IS_netplayer(__ps) (((__ps) & (PSFM_alife + PSF_net)) == (PSF_net + PSFM_alife)) +#define PS_IS_playing(__ps) (((__ps) & (PSFM_used)) == (PSFM_used)) +#define PS_IS_used(__ps) (((__ps) & (PSFM_used)) != 0) + +enum _direction { // to handle directions better + left = 0, + right, + up, + down +}; + + +struct __point { + short int x; + short int y; +} typedef _point; + +#endif diff --git a/src/bomb.c b/src/bomb.c new file mode 100644 index 0000000..002908b --- /dev/null +++ b/src/bomb.c @@ -0,0 +1,339 @@ +/* everything what have to do with the bombs */ + +#include "bomberclone.h" +#include "network.h" +#include "gfx.h" + +void +restore_bomb_screen () +{ + int p, + i; + _bomb *bomb; + + for (p = 0; p < MAX_PLAYERS; p++) + for (i = 0; i < MAX_BOMBS; i++) { + bomb = &bman.players[p].bombs[i]; + if (bomb->state == BS_ticking) { + draw_stone (bomb->pos.x, bomb->pos.y); + if (bomb->pos.x > 1) + draw_stone (bomb->pos.x - 1, bomb->pos.y); + if (bomb->pos.y > 1) + draw_stone (bomb->pos.x, bomb->pos.y - 1); + if (bomb->pos.x < bman.fieldsize.x) + draw_stone (bomb->pos.x + 1, bomb->pos.y); + if (bomb->pos.y < bman.fieldsize.y) + draw_stone (bomb->pos.x, bomb->pos.y + 1); + } + } +}; + + +void +draw_bomb (_bomb * bomb) +{ + SDL_Rect src, + dest; + + /* check the framenumber */ + if (bomb->frameto-- == 0) { + bomb->frameto = ANI_BOMBTIMEOUT; + bomb->frame++; + }; + if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames || bomb->frameto > 20) { + bomb->frame = 0; + bomb->frameto = ANI_BOMBTIMEOUT; + } + + src.w = src.w = gfx.bomb.image->w; + dest.h = src.h = gfx.block.y; + + dest.x = gfx.offset.x + (bomb->pos.x * gfx.block.x); + dest.y = gfx.offset.y + (bomb->pos.y * gfx.block.y); + + src.x = 0; + src.y = src.h * bomb->frame; + + SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest); + + gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); +}; + + +void +bomb_explode (int p, int b) +{ + int d; + _bomb *bomb = &bman.players[p].bombs[b]; + + d_printf ("Bomb Explode p:%d, b:%d [%d,%d]\n", p, b, bomb->pos.x, bomb->pos.y); + + if (bomb->ex_nr == -1) + bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id + + bomb->to = ANI_FIRETIMEOUT; /* set the timeout for the fireexplosion */ + bomb->state = BS_exploding; + for (d = 0; d < 4; d++) { + bomb->firer[d] = 0; + bomb->firerst[d] = -1; + } + + if (GT_MP_PTPM) /* from now on only the server let the bomb explode */ + net_game_send_bomb (p, b); +}; + + +void +bomb_loop () +{ + int p, + i; + _player *player; + _bomb *bomb; + + for (p = 0; p < MAX_PLAYERS; p++) { + player = &bman.players[p]; + if ((bman.players[p].state & PSFM_used) != 0) { + for (i = 0; i < MAX_BOMBS; i++) { + bomb = &player->bombs[i]; + if (bomb->state == BS_ticking) { + if (GT_MP_PTPM || bman.gametype == GT_single) { + if (--bomb->to == 0) // bomb will have to explode in the next loop + bomb_explode (p, i); + else + draw_bomb (bomb); + } + else { + if (--bomb->to == 0) { // bomb did not explode -> resend bombdata + bomb->to = BOMB_TIMEOUT * TIME_FACTOR; + net_game_send_bomb (bman.p_nr, i); + bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); + } + draw_bomb (bomb); + } + } + else if (bomb->state == BS_exploding) { + if (bomb->to > 0) { + do_explosion (p, i); + } + if (bomb->to == 0) { // explosion done + restore_explosion (bomb); + bomb->to = 0; + bomb->state = BS_off; + } + bomb->to--; + } + } + } + } +}; + +void +get_bomb_on (int x, int y, _point bombs[]) +{ + int p, + b, + i; + _bomb *bomb; + + for (i = 0, p = 0; p < MAX_PLAYERS; p++) + if ((bman.players[p].state & PSFM_used) != 0) { + for (b = 0; b < MAX_BOMBS; b++) { + bomb = &bman.players[p].bombs[b]; + if (bomb->state == BS_ticking) { + if (bomb->pos.x == x && bomb->pos.y == y) { + bombs[i].x = p; + bombs[i].y = b; + i++; + } + } + } + } + bombs[i].x = bombs[i].y = -1; +}; + + +void +draw_fire (int x, int y, int d) +{ + SDL_Rect src, + dest; + + src.w = src.w = gfx.block.x; + dest.h = src.h = gfx.block.y; + + dest.x = gfx.offset.x + x * gfx.block.x; + dest.y = gfx.offset.y + y * gfx.block.y; + + src.y = 0; + src.x = d * src.w; + + SDL_BlitSurface (gfx.fire.image, &src, gfx.screen, &dest); + gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); +}; + + +void +restore_explosion (_bomb * bomb) +{ + int i, + d; + int dx = 0, + dy = 0; + int _x, + _y; + + for (d = 0; d < 4; d++) { + switch (d) { + case (left): + dx = -1; + dy = 0; + break; + case (right): + dx = 1; + dy = 0; + break; + case (up): + dx = 0; + dy = -1; + break; + case (down): + dx = 0; + dy = 1; + break; + } + + _x = bomb->pos.x; + _y = bomb->pos.y; + + for (i = 0; i < bomb->firer[d]; i++) { + bman.field[_x][_y].ex[d]--; + if (i == 0 && d == 3) + draw_stone (_x, _y); + if (i > 0) + draw_stone (_x, _y); + _x = _x + dx; + _y = _y + dy; + } + + // delete the stone completly if there was any in the way + if (bomb->firer[d] <= bomb->r && bman.field[_x][_y].type != FT_block + && bomb->ex_nr != bman.field[_x][_y].ex_nr) { + + bman.field[_x][_y].ex_nr = bomb->ex_nr; + bman.field[_x][_y].frame = 0; + bman.field[_x][_y].frameto = 0; + if (bman.field[_x][_y].special != FT_nothing) { + bman.field[_x][_y].type = bman.field[_x][_y].special; + bman.field[_x][_y].special = FT_nothing; + d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, bman.field[_x][_y].ex_nr); + } + else + bman.field[_x][_y].type = FT_nothing; + + draw_stone (_x, _y); + + if (GT_MP_PTPM) /* send only if we are the master */ + net_game_send_field (_x, _y); + } + } +}; + + + +/* + check the field on which the explosion is +*/ +int +explosion_check_field (int x, int y, int p, int b) +{ + _bomb *bomb = &bman.players[p].bombs[b]; + int pl[MAX_PLAYERS]; + int i; + _point bo[MAX_PLAYERS * MAX_BOMBS]; + _bomb *tmpbomb; + _player *tmpplayer; + + if (x < 0 || x >= bman.fieldsize.x || y < 0 || y >= bman.fieldsize.y) + return FT_block; + + get_player_on (x << 8, y << 8, pl); + get_bomb_on (x, y, bo); + + // check if any bomb have to explode.. + for (i = 0; bo[i].x != -1; i++) { + tmpbomb = &bman.players[bo[i].x].bombs[bo[i].y]; + if (tmpbomb != bomb && tmpbomb->state != BS_exploding) { + tmpbomb->ex_nr = bomb->ex_nr; // set the ex_nr to identify explosions + bomb_explode (bo[i].x, bo[i].y); + } + } + + // check if any player is in the explosion + for (i = 0; pl[i] != -1; i++) { + tmpplayer = &bman.players[pl[i]]; + if (((tmpplayer->state & PSF_alife) != 0) + && (bman.gametype == GT_single + || (GT_MP_PTP && (&bman.players[bman.p_nr] == tmpplayer)))) + player_died (tmpplayer, p); + } + + // let the stones right beside explode + if (bman.field[x][y].type != FT_nothing + && bman.field[x][y].type != FT_block && bomb->ex_nr != bman.field[x][y].ex_nr) { + if (bman.field[x][y].frame == 0) { + bman.field[x][y].frameto = ANI_STONETIMEOUT; + bman.field[x][y].frame = 1; + } + draw_stone (x, y); + } + + return bman.field[x][y].type; +}; + + +void +do_explosion (int p, int b) +{ + _bomb *bomb = &bman.players[p].bombs[b]; + int dx = 0, + dy = 0, + d; + + for (d = 0; d < 4; d++) { + switch (d) { + case (left): + dx = -1; + dy = 0; + break; + case (right): + dx = 1; + dy = 0; + break; + case (up): + dx = 0; + dy = -1; + break; + case (down): + dx = 0; + dy = 1; + break; + } + + if (bomb->firer[d] <= bomb->r) { + dx = bomb->firer[d] * dx; + dy = bomb->firer[d] * dy; + + if (explosion_check_field (bomb->pos.x + dx, bomb->pos.y + dy, p, b) == + BS_off && bomb->firerst[d] == -1) { + bomb->firer[d]++; + bman.field[bomb->pos.x + dx][bomb->pos.y + dy].ex[d]++; + draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d); + } + else { + bomb->firerst[d] = bomb->firer[d]; + draw_stone (bomb->pos.x + dx, bomb->pos.y + dy); + } + } + } +}; diff --git a/src/bomberclone.h b/src/bomberclone.h new file mode 100644 index 0000000..e810ee2 --- /dev/null +++ b/src/bomberclone.h @@ -0,0 +1,213 @@ +/* bomberman.h */ + +#ifndef _BOMBERCLONE_H_ +#define _BOMBERCLONE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#else +#include +#include +#include +#include +#endif +#include +#include "../config.h" +#include "gfx.h" +#include "network.h" + +struct __playerilness { + int to; // if (to > 0) the ilness is still working + int data; +} typedef _playerilness; + + +struct __bomb { + _point pos; // lower byte = _X Higher Byte = FX + int firer[4]; // range of the fire for the fire for each direction + int firerst[4]; /* just save here where the direction was going to stop (-1) + if the exp is still growing */ + int to; // timeout in ms after dropping the bomb. (loops * 0.0005sec) + int frame; // frame of the animation + int frameto; // timeout for the frame + unsigned char r; // range of the bomb + unsigned char state; // state of the bomb + int ex_nr; // explosion number +} typedef _bomb; + + +struct __player { + _gfxplayer *gfx; // pointer to the gfx information + int gfx_nr; // number of the player GFX + + int frame; // step of the animation + int frameto; // timeout for the animation + + int illframe; + int illframeto; + + _point pos; /* position (without the offset) + _x = pos.x & 255; fx = pos.x >> 8; */ + _point old; // the old position + signed char d; // direction + signed char m; // player is moving ? + signed char old_m; // to save the old state.. + + int bombs_n; // maximal number of bombs for the player + _bomb bombs[MAX_BOMBS]; // number of bombs who are ticking. + int range; // range of the bombs + int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest) + int speeddat; // some data i need to do the speed thing + _playerilness ill[PI_max]; // all possible types + + char name[LEN_PLAYERNAME]; // name oder name[0] == 0 + unsigned char state; // status of the player + signed char in_nr; // number of the connected player entry + + int points; // points + int wins; // wins + signed char dead_by; // player who killed this player + + _net_player net; // holds all important network data +} typedef _player; + + +struct __field { + unsigned char type; + int frame; // frame (frame > 0 && FS_stone) + int frameto; // frame to + unsigned char special; // to save special stones + signed char ex[4]; // count up every explosion there is on this field for ever direction + int ex_nr; // number to identify the explosion. +} typedef _field; + + +struct __serverlist { + char name[255]; +} typedef _serverlist; + + +struct __bomberclone { + _point fieldsize; // dimension of the field + char datapath[512]; + + _player players[MAX_PLAYERS]; + int p_nr; // Playernumber 0 if you host a game or the number of the one you are. + + _field field[MAX_FIELDSIZE_X][MAX_FIELDSIZE_Y]; + + int last_ex_nr; // number of the last explosion + + unsigned char gametype; + unsigned char multitype; + unsigned char state; + char playername[LEN_PLAYERNAME]; + int players_nr_s; // number of players at the beginning + int players_nr; // number of player who are alife + signed char lastwinner; // number of the last winnet + + int maxplayer; // number of max players for the server + + int sock; // the server socket + unsigned char net_ai_family; + char port[LEN_PORT]; // what port we're using + char servername[LEN_SERVERNAME + LEN_PORT + 2]; // holds the name of the current server + _serverlist serverlist[MAX_SERVERENTRYS]; // ** CONFIG name of the server we are connected to + char gamename[LEN_GAMENAME]; // this will hold the game name + char gamemaster[LEN_SERVERNAME + LEN_PORT + 2]; // ** CONFIG ... GameMaster Address + unsigned char notifygamemaster; + signed char net_pkgsend_to; + signed char net_pkgsend_set; // ** CONFIG + unsigned char selectplayer; // ask player for name at startup + signed char debug; // 0 = off 1 = on +} typedef _bomberclone; + + +struct __menu { + int index; + char text[255]; +} typedef _menu; + +extern _bomberclone bman; +extern Uint32 timestamp; +extern int debug; + +// Game routines.. +extern void game_draw_info (); +extern void game_loop (); +extern void single_game_new (); +extern void multi_new_game (); +extern void game_end (); + +// everything is declared in field.c +extern void draw_field (); +extern void draw_stone (int x, int y); +extern void field_new (); + +// everything what is declared in players.c +extern void dead_playerani (); +extern void draw_player (_player * player); +extern void restore_players_screen (); +extern void move_player (); +extern int stepmove_player (); +extern void player_drop_bomb (); +extern void get_player_on (short int x, short int y, int pl_nr[]); +extern void player_died (_player * player, signed char dead_by); +extern void draw_players (); +extern void player_animation (_player * player); +extern int check_field (short int fx, short int fy, _player * p); +extern void player_calcstep (_player * pl); +extern void player_calcpos (); +extern void player_set_ilness (_player *p, int t); +extern void player_clear_ilness (_player *p, int type); +extern void player_ilness_loop (); +extern void player_check_powerup (_player * p); +extern void player_set_gfx (_player *p, signed char gfx_nr); + +// for the bomb.. +extern void bomb_loop (); +extern void restore_bomb_screen (); +extern void get_bomb_on (int x, int y, _point bombs[]); +extern void draw_fire (int x, int y, int frame); +extern void do_explosion (int p, int b); +extern void restore_explosion (_bomb * bomb); +extern int explosion_check_field (int x, int y, int p, int b); +extern void bomb_explode (int p, int b); + +// menus +extern void draw_select (int select, _menu menu[], int x, int y); +extern int menu_loop (char *menutitle, _menu menu[], int lastselect); +extern void draw_menu (char *text, _menu menu[], int *x, int *y); +extern void menu_get_text (char *title, char *text, int len); +extern void menu_displaymessage (char *title, char *text); +extern void menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b); + +// configuration +extern void configuration (); +extern void game_init (); +extern int ReadConfig(); +extern int WriteConfig(); +extern void ReadPrgArgs (int argc, char **argv); + +// sysfunc.c +extern void s_delay (int ms); +extern int s_random (int maxnr); +extern char *s_gethomedir (); + +// debug.c +extern void d_in_pl_detail (char *head); +extern void d_playerdetail (char *head); +extern void d_gamedetail (char *head); +extern void d_printf (char *fmt,...); + +#endif + diff --git a/src/chat.c b/src/chat.c new file mode 100644 index 0000000..ea25574 --- /dev/null +++ b/src/chat.c @@ -0,0 +1,233 @@ +/* + chat.c - this file will do everything what have to do with the chat.. +*/ + +#include "bomberclone.h" +#include "network.h" +#include "packets.h" +#include "gfx.h" +#include "keybinput.h" +#include "chat.h" + +_chat chat; + +/* find a free line or delete the oldest one */ +int +chat_findfreeline () +{ + int i; + + for (i = 0; (i < CHAT_MAX_LINES && chat.lines[i][0] != 0); i++); + + if (i >= CHAT_MAX_LINES) { + memcpy (chat.lines[1], chat.lines[0], 255); + i = 255; + } + + chat.changed = 1; + + return i; +} + +void +chat_addline (char *text) +{ + int l; + + l = chat_findfreeline (); + + strncpy (chat.lines[l], text, 255); + chat.lineschanged = 1; +} + +void +chat_drawbox () +{ + SDL_Rect src; + int i; + + if (chat.visible == 0) + chat.oldscreen = gfx_copyscreen (&chat.window); + + chat.visible = 1; + + if (gfx_locksurface (gfx.screen)) + return; + + for (i = 0; i < 2; i++) { + src.x = chat.window.x + i; + src.w = src.x + chat.window.w - 2; + src.y = chat.window.y + i; + src.h = src.y + chat.window.h - 2; + draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_BRIGHT); + } + + gfx_unlocksurface (gfx.screen); + + src.x = chat.window.x + 2; + src.y = chat.window.y + 2; + src.w = src.x + chat.window.w - 4; + src.h = src.y + chat.window.h - 4 - 16; + draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK); + src.x = chat.window.x + 2; + src.y = chat.window.y + chat.window.h - 18; + src.w = src.x + chat.window.w - 4; + src.h = src.y + 16; + draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1); +}; + + +void +chat_deletebox () +{ + SDL_Rect src, + dest; + + src.x = 0; + src.y = 0; + src.w = dest.w = chat.oldscreen->w; + src.h = dest.h = chat.oldscreen->h; + + dest.x = chat.window.x; + dest.y = chat.window.y; + + SDL_BlitSurface (chat.oldscreen, &src, gfx.screen, &dest); + gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h); + + chat.visible = 0; + SDL_FreeSurface (chat.oldscreen); + chat.oldscreen = NULL; +}; + + +void +chat_show (int x1, int y1, int x2, int y2) +{ + if (chat.visible != 0) + chat_deletebox (); + + if (x1 == -1 || x2 == -1 || y1 == -1 || y2 == -1 || x2 <= x1 || y2 <= y1) + chat.visible = 0; + else { + chat.window.x = x1; + chat.window.y = y1; + chat.window.w = x2 - x1; + chat.window.h = y2 - y1; + chat_drawbox (); + keybinput_new (&chat.input); + gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h); + chat.changed = 1; + chat.lineschanged = 1; + } +}; + + +void +chat_clearscreen (signed char all) +{ + SDL_Rect src, + dest; + + if (all == 1) { + dest.x = chat.window.x + 2; + dest.y = chat.window.y + 2; + dest.w = dest.x + chat.window.w - 4; + dest.h = dest.y + chat.window.h - 4; + + src.x = 2; + src.y = 2; + src.w = chat.window.w - 4; + src.h = chat.window.h - 4; + } + else { + /* redraw only the textline of out input box */ + dest.x = chat.window.x + 2; + dest.y = chat.window.y + chat.window.h - 18; + dest.w = src.w = chat.window.w - 4; + dest.h = src.h = 16; + + src.x = 2; + src.y = chat.window.h - 18; + } + SDL_BlitSurface (chat.oldscreen, &src, gfx.screen, &dest); + + if (all == 1) { + dest.w = dest.x + chat.window.w - 4; + dest.h = dest.y + chat.window.h - 4 - 16; + draw_shadefield (gfx.screen, &dest, CHAT_BG_SHADE_DARK); + } + + src.x = chat.window.x + 2; + src.y = chat.window.y + chat.window.h - 18; + src.w = src.x + chat.window.w - 4; + src.h = src.y + 16; + draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1); + + gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h); +}; + + +void +chat_loop (SDL_Event * event) +{ + int i, + y, + l, + p1, + p2, + maxchar; + char text[255]; + + i = keybinput_loop (&chat.input, event); + + if (i == 1 && chat.input.text[0] != 0) { + sprintf (text, "%s: %s", bman.playername, chat.input.text); + net_send_chat (text, 1); + chat_addline (text); + keybinput_new (&chat.input); + i = 0; + } + + if (((i == 0 && chat.input.changed == 1) || chat.changed == 1) && chat.visible == 1) { + /* draw the new field */ + chat_clearscreen (chat.lineschanged); + p1 = p2 = 0; + maxchar = (chat.window.w - 4) / (gfx.font.size.x - 4); + if (chat.lineschanged) { + y = chat.window.y + 4; + l = chat.startline; + while (y < (chat.window.y + chat.window.h - 32) && chat.lines[l][0] != 0) { + for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++) + text[p1] = chat.lines[l][p2++]; + text[p1] = 0; + draw_text (chat.window.x + 4, y, text, 1); + if (chat.lines[l][p2] == 0) { // the end of the line + l++; + p2 = 0; + } + y = y + gfx.font.size.y; + } + if (chat.lines[l][0] != 0) { + chat.startline++; + chat.changed = 1; + chat.lineschanged = 1; + } + else { + chat.changed = 0; + chat.lineschanged = 0; + } + } + if (chat.startline >= CHAT_MAX_LINES) + chat.startline = CHAT_MAX_LINES - 5; + + /* draw the input line */ + if (chat.input.len > maxchar) + p2 = chat.input.len - maxchar; + + for (p1 = 0; (p1 < maxchar && chat.input.text[p2] != 0); p1++) + text[p1] = chat.input.text[p2++]; + text[p1] = 0; + draw_text (chat.window.x + 4, (chat.window.y + chat.window.h) - 4 - gfx.font.size.y, text, + 1); + } +}; diff --git a/src/chat.h b/src/chat.h new file mode 100644 index 0000000..f3f3b14 --- /dev/null +++ b/src/chat.h @@ -0,0 +1,28 @@ + +#ifndef _CHAT_H_ +#define _CHAT_H_ + +#include "keybinput.h" + +#define CHAT_MAX_LINES 255 +#define CHAT_BG_SHADE_DARK -64 +#define CHAT_BG_SHADE_BRIGHT 64 + +struct __chat { + SDL_Rect window; + signed char visible; + signed char changed; + SDL_Surface *oldscreen; + short int startline; + char lines[CHAT_MAX_LINES][255]; + signed char lineschanged; + _keybinput input; +} typedef _chat; + +extern _chat chat; + +extern void chat_show (int x1, int y1, int x2, int y2); +extern void chat_addline (char *text); +extern void chat_loop (SDL_Event *event); + +#endif diff --git a/src/configuration.c b/src/configuration.c new file mode 100644 index 0000000..335d770 --- /dev/null +++ b/src/configuration.c @@ -0,0 +1,374 @@ +/* configuration */ + +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +#include "bomberclone.h" +#include "network.h" +#include "packets.h" +#include "gfx.h" +#include "chat.h" + +void +game_init () +{ + int i; + + srandom (((int) time (NULL))); + + // do some init stuff + for (i = 0; i < MAX_SERVERENTRYS; i++) + bman.serverlist[i].name[0] = 0; + + for (i = 0; i < MAX_PLAYERS; i++) { + bman.players[i].gfx = NULL; /* we will select them in the wait_for_players loop */ + bman.players[i].gfx_nr = -1; /* and even now in the singleplayer menu */ + } + + chat.visible = 0; + chat.startline = 0; + for (i = 0; i < CHAT_MAX_LINES; i++) + chat.lines[i][0] = 0; + + bman.maxplayer = MAX_PLAYERS; + bman.net_ai_family = PF_INET; + bman.net_pkgsend_set = 2; + bman.gamename[0] = 0; + sprintf (bman.port, "%d", DEFAULT_UDPPORT); + sprintf (bman.gamemaster, DEFAULT_GAMEMASTER); + resend_cache.data = NULL; + resend_cache.fill = -1; + bman.notifygamemaster = 1; + bman.selectplayer = 1; + debug = 0; + gfx.res.x = 640; + gfx.res.y = 480; + bman.fieldsize.x = 25; + bman.fieldsize.y = 17; + sprintf (bman.datapath, "data/bomberclone.gfx"); +}; + +int +ReadConfig () +{ + FILE *config; + char buf[200], + key2[50]; + char *findit, + *keyword, + *value; + int i; + char filename[512]; + +#ifdef _WIN32 + sprintf (filename, "%sbomberclone.cfg", s_gethomedir ()); +#else + sprintf (filename, "%s.bomberclone.cfg", s_gethomedir ()); +#endif + + config = fopen (filename, "r"); + if (config == NULL) { + d_printf ("Error: Config file not found!\n"); + return -1; + } + d_printf ("Reading Config-file: %s", filename); + /* printf("Reading config file...\n"); */ + + while (fgets (buf, sizeof (buf), config) != NULL) { + findit = strchr (buf, '\n'); + if (findit) + findit[0] = '\0'; + if (buf[0] == '\0') + continue; + + keyword = buf; + while (isspace (*keyword)) + keyword++; + + value = strchr (buf, '='); + if (value == NULL) + continue; + *value = 0; + value++; + while (*value == ' ') + value++; + while (keyword[strlen (keyword) - 1] == ' ') + keyword[strlen (keyword) - 1] = 0; + while (value[strlen (value) - 1] == ' ') + value[strlen (value) - 1] = 0; + if (strlen (value) == 0) + continue; + for (i = 0; i < (int) strlen (keyword); i++) + keyword[i] = tolower (keyword[i]); + + if (!strcmp (keyword, "playername")) { + if (strlen (value) > LEN_PLAYERNAME) { + d_printf + ("*** Error - playername too long (maximum size permitted is %d characters)!\n\n", + LEN_PLAYERNAME); + } + value[LEN_PLAYERNAME - 1] = 0; + strcpy (bman.playername, value); + } + + if (!strcmp (keyword, "gamename")) { + if (strlen (value) > LEN_GAMENAME) { + d_printf + ("*** Error - servername too long (maximum size permitted is %d characters)!\n\n", + LEN_GAMENAME); + } + value[LEN_GAMENAME - 1] = 0; + strcpy (bman.gamename, value); + } + + if (!strcmp (keyword, "selectplayer")) { + bman.selectplayer = atoi (value); + } + if (!strcmp (keyword, "resolutionx")) { + gfx.res.x = atoi (value); + } + if (!strcmp (keyword, "resolutiony")) { + gfx.res.y = atoi (value); + } + if (!strcmp (keyword, "fieldsizex")) { + bman.fieldsize.x = atoi (value); + } + if (!strcmp (keyword, "fieldsizey")) { + bman.fieldsize.y = atoi (value); + } + if (!strcmp (keyword, "fullscreen")) { + gfx.fullscreen = atoi (value); + } + if (!strcmp (keyword, "ai_family")) { + bman.net_ai_family = atoi (value); + } + if (!strcmp (keyword, "debug")) { + debug = atoi (value); + } + if (!strcmp (keyword, "notify")) { + bman.notifygamemaster = atoi (value); + } + if (!strcmp (keyword, "masterserver")) { + strcpy (bman.gamemaster, value); + } + if (!strcmp (keyword, "maxplayer")) { + bman.maxplayer = atoi (value); + } + for (i = 0; i < MAX_SERVERENTRYS; i++) { + sprintf (key2, "ip%d", i); + if (!strcmp (keyword, key2)) { + strcpy (bman.serverlist[i].name, value); + } + } + } + fclose (config); + return 0; +} + +int +WriteConfig () +{ + FILE *config; + int i; + char filename[512]; +#ifdef _WIN32 + sprintf (filename, "%sbomberclone.cfg", s_gethomedir ()); +#else + sprintf (filename, "%s.bomberclone.cfg", s_gethomedir ()); +#endif + if ((config = fopen (filename, "w")) == NULL) + return -1; + fprintf (config, "resolutionx=%d\n", gfx.res.x); + fprintf (config, "resolutiony=%d\n", gfx.res.y); + fprintf (config, "fullscreen=%d\n", gfx.fullscreen); + fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x); + fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y); + fprintf (config, "notify=%d\n", bman.notifygamemaster); + fprintf (config, "ai_family=%d\n", bman.net_ai_family); + fprintf (config, "masterserver=%s\n", bman.gamemaster); + fprintf (config, "gamename=%s\n", bman.gamename); + fprintf (config, "maxplayer=%d\n", bman.maxplayer); + for (i = 0; i < MAX_SERVERENTRYS; i++) + fprintf (config, "ip%d=%s\n", i, bman.serverlist[i].name); + fprintf (config, "debug=%d\n", debug); + fprintf (config, "selectplayer=%d\n", bman.selectplayer); + fprintf (config, "playername=%s\n", bman.playername); + fclose (config); + return 0; +} + + + +void +change_res () +{ + int menuselect = 0; + _menu menu[] = { + {0, "Full Screen"}, + {1, "640x480"}, + {2, "800x600"}, + {3, "1024x768"}, + {4, "1280x1024"}, + {5, "Return To Configuration Menu"}, + {-1, ""} + }; + while (1) { + if (gfx.fullscreen) + sprintf (menu[0].text, "Disable Fullscreen"); + else + sprintf (menu[0].text, "Enable Full Screen"); + + + menuselect = menu_loop ("Video Options", menu, menuselect); + + switch (menuselect) { + case (0): // Fullscreen + if (gfx.fullscreen) + gfx.fullscreen = 0; + else + gfx.fullscreen = 1; + break; + + case (1): // 640x480 + gfx.res.x = 640; + gfx.res.y = 480; + break; + case (2): // 800x600 + gfx.res.x = 800; + gfx.res.y = 600; + break; + case (3): // 1024x768 + gfx.res.x = 1024; + gfx.res.y = 768; + break; + case (4): // 1280x1024 + gfx.res.x = 1280; + gfx.res.y = 1024; + break; + case (5): // Return + menuselect = -1; + break; + } + if (menuselect != -1) { + gfx_shutdown (); + gfx_init (); + } + else + return; + + } +}; + + + +void +configuration () +{ + int menuselect = 0; + char text[255]; + _menu menu[] = { + {0, "Player Name:"}, + {1, "Video Options"}, + {2, "Sound Options"}, + {3, "Customize Keyboard"}, + {4, "Field Size X:"}, + {5, "Field Size Y:"}, + {6, "Prompt For Player Name"}, + {7, "Debug"}, + {8, "Save Config"}, + {9, "Return To Main Manu"}, + {-1, ""} + }; + + while (menuselect != -1) { + + sprintf (menu[0].text, "Player Name: %s", bman.playername); + + sprintf (menu[4].text, "Field Size X: %d", bman.fieldsize.x); + sprintf (menu[5].text, "Field Size Y: %d", bman.fieldsize.y); + + if (debug == 1) + sprintf (menu[6].text, "Debug Messages ON"); + else + sprintf (menu[6].text, "Debug Messages OFF"); + + if (bman.selectplayer == 1) + sprintf (menu[6].text, "Prompt For Name: Yes"); + else + sprintf (menu[6].text, "Prompt For Name: No"); + + menuselect = menu_loop ("Configuration", menu, menuselect); + + + switch (menuselect) { + case (0): // Playername + menu_get_text ("Enter Playername", bman.playername, LEN_PLAYERNAME - 1); + bman.playername[LEN_PLAYERNAME - 1] = 0; + break; + case (1): // Screen Options + change_res (); + break; + case (2): // Sound Options + case (3): // Customize Keyboard + break; + case (4): // Change X Fieldsize + sprintf (menu[4].text, "%d", bman.fieldsize.x); + sprintf (text, "Field Size X (%d - %d)", MIN_FIELDSIZE_X, MAX_FIELDSIZE_X); + menu_get_text (text, menu[4].text, 3); + bman.fieldsize.x = atoi (menu[4].text) | 1; + if (bman.fieldsize.x < MIN_FIELDSIZE_X) + bman.fieldsize.x = MIN_FIELDSIZE_X; + if (bman.fieldsize.x > MAX_FIELDSIZE_X) + bman.fieldsize.x = MAX_FIELDSIZE_X; + break; + + case (5): // Change Y Fieldsize + sprintf (menu[5].text, "%d", bman.fieldsize.y); + sprintf (text, "Field Size Y (%d - %d)", MIN_FIELDSIZE_Y, MAX_FIELDSIZE_Y); + menu_get_text (text, menu[5].text, 3); + bman.fieldsize.y = atoi (menu[5].text) | 1; + if (bman.fieldsize.y < MIN_FIELDSIZE_Y) + bman.fieldsize.y = MIN_FIELDSIZE_Y; + if (bman.fieldsize.y > MAX_FIELDSIZE_Y) + bman.fieldsize.y = MAX_FIELDSIZE_Y; + break; + + case (6): // Debugging On / Off + if (bman.selectplayer == 1) + bman.selectplayer = 0; + else + bman.selectplayer = 1; + break; + case (7): // Debugging On / Off + if (debug == 1) + debug = 0; + else { + debug = 1; + d_printf ("BomberClone ver.%s (%d) \n", VERSION, SUB_VERSION); + } + break; + case (8): // Save Configuration + WriteConfig (); + break; + case (9): // Return to main menu + menuselect = -1; + break; + } + } +}; + +void +ReadPrgArgs (int argc, char **argv) +{ + int i = 0; + + while (argv[++i] != NULL) { + if (!strcmp (argv[i], "-port")) + strncpy (bman.port, argv[++i], LEN_PORT); + } +}; diff --git a/src/debug.c b/src/debug.c new file mode 100644 index 0000000..379462c --- /dev/null +++ b/src/debug.c @@ -0,0 +1,39 @@ + +#include "bomberclone.h" +#include "network.h" +#include "packets.h" + +int debug; + +void d_gamedetail (char *head) { + d_playerdetail (head); + + d_printf ("bman.players_nr = %d\n", bman.players_nr); + d_printf ("bman.players_nr_s = %d\n", bman.players_nr_s); + d_printf ("bman.gametype = %d\n", bman.gametype); + d_printf ("bman.multitype = %d\n", bman.multitype); + d_printf ("bman.state = %d\n", bman.state); +}; + + +void d_printf (char *fmt,...) { + va_list args; + + if (debug == 0) + return; + + va_start (args, fmt); + fprintf (stdout, "[%8d] :", timestamp); + vfprintf (stdout, fmt, args); + va_end (args); +}; + + +void d_playerdetail (char *head) { + int i; + + d_printf ("---------------> %s\n", head); + d_printf ("Nr Name GFX Sta Pkt Win [Addr]\n"); + for (i = 0; i < MAX_PLAYERS; i++) + d_printf ("%2d %16s %3d %3d %3d %3d [%s:%s]\n",i, bman.players[i].name, bman.players[i].gfx_nr, bman.players[i].state, bman.players[i].points, bman.players[i].wins, bman.players[i].net.addr.host, bman.players[i].net.addr.port); +}; diff --git a/src/field.c b/src/field.c new file mode 100644 index 0000000..cfa2698 --- /dev/null +++ b/src/field.c @@ -0,0 +1,172 @@ +/* field.c - procedures which are needed to control the field */ + +#include +#include + +#include "bomberclone.h" +#include "gfx.h" + +void +draw_stone (int x, int y) +{ + _field *stone = &bman.field[x][y]; + SDL_Rect dest, + src; + SDL_Surface *srcimg; + int i, + d; + + src.w = dest.w = gfx.block.x; + src.h = dest.h = gfx.block.y; + + dest.x = x * gfx.block.x + gfx.offset.x; + dest.y = y * gfx.block.y + gfx.offset.y; + + src.x = 0; + + if (stone->frame == 0 || stone->type != FT_stone) { + srcimg = gfx.field[stone->type].image; + src.y = 0; + } + else { + if (stone->frameto == 0) { + if (stone->frame < gfx.field[stone->type].frames) { + stone->frame++; + stone->frameto = ANI_STONETIMEOUT; + } + } + if (stone->frameto > 0) + stone->frameto--; + if (stone->frame < gfx.field[stone->type].frames) { + src.y = stone->frame * gfx.block.y; + srcimg = gfx.field[stone->type].image; + } + else { + src.y = 0; + srcimg = gfx.field[FT_nothing].image; + } + + } + + if (stone->frame > 0) + SDL_BlitSurface (gfx.field[FT_nothing].image, NULL, gfx.screen, &dest); + + SDL_BlitSurface (srcimg, &src, gfx.screen, &dest); + + // draw explosions if there is any + for (d = 0, i = 0; d < 4; d++) + if (stone->ex[d] > 0) { + i = 1; // mark that there is already an explosion + draw_fire (x, y, d); + } + + if (i == 0) // we don't have to do this anymore because this was happend in draw_fire + gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); + + return; +}; + + +void +draw_field () +{ + int x, + y; + + for (x = 0; x < bman.fieldsize.x; x++) + for (y = 0; y < bman.fieldsize.y; y++) + draw_stone (x, y); +}; + + +void +field_new () +{ + int x, + y, + d; + + float fkt = ((float)(bman.fieldsize.x * bman.fieldsize.y))/(25.0 * 17.0); + + // Clean the field // + for (x = 0; x < bman.fieldsize.x; x++) + for (y = 0; y < bman.fieldsize.y; y++) { + if ((y == 0) || (y == bman.fieldsize.y - 1)) + bman.field[x][y].type = FT_block; + else if ((x == 0) || (x == bman.fieldsize.x - 1)) + bman.field[x][y].type = FT_block; + else if (((x & 1) == 0) && ((y & 1) == 0)) + bman.field[x][y].type = FT_block; + else { + // create random field + if ((random () & 3) == 0) + bman.field[x][y].type = FT_nothing; + else + bman.field[x][y].type = FT_stone; + } + + for (d = 0; d < 4; d++) + bman.field[x][y].ex[d] = 0; + bman.field[x][y].ex_nr = -1; + bman.field[x][y].frame = 0; + bman.field[x][y].frameto = 0; + bman.field[x][y].special = FT_nothing; + } + + /* get some free space for the playerstart position */ + for (d = 0; d < MAX_PLAYERS; d++) + if ((PS_IS_alife (bman.players[d].state)) != 0) { + x = bman.players[d].pos.x >> 8; + y = bman.players[d].pos.y >> 8; + + bman.field[x][y].type = FT_nothing; + if (x > 1) + bman.field[x-1][y].type = FT_nothing; + if (x < bman.fieldsize.x-2) + bman.field[x+1][y].type = FT_nothing; + if (y > 1) + bman.field[x][y-1].type = FT_nothing; + if (y < bman.fieldsize.y -2) + bman.field[x][y+1].type = FT_nothing; + } + + /* put the fire powerups in the field */ + for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMFIRE * fkt; d++) { + while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) { + x = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.x-1); + y = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.y-1); + } + bman.field[x][y].special = FT_fire; + x = y = 0; + } + + /* put the bomb powerups in the field */ + for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMBOMB * fkt; d++) { + while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) { + x = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.x-1); + y = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.y-1); + } + bman.field[x][y].special = FT_bomb; + x = y = 0; + } + + /* put the shoe powerup in the field */ + for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMSHOE * fkt; d++) { + while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) { + x = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.x-1); + y = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.y-1); + } + bman.field[x][y].special = FT_shoe; + x = y = 0; + } + + /* put the death ?powerups? in the field */ + for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMDEATH * fkt; d++) { + while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) { + x = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.x-1); + y = ((float) rand() / (float) RAND_MAX) * (bman.fieldsize.y-1); + } + bman.field[x][y].special = FT_death; + x = y = 0; + } +} diff --git a/src/font.c b/src/font.c new file mode 100644 index 0000000..ea091fd --- /dev/null +++ b/src/font.c @@ -0,0 +1,36 @@ +// Using Fonts in SDL + +#include +#include + +#include "bomberclone.h" +#include "gfx.h" + +void +draw_text (int x, int y, char *text, int white) +{ + int i, + c; + SDL_Rect src, + dest; + + src.y = 0; + dest.w = src.w = gfx.font.size.x; + dest.h = src.h = gfx.font.size.y; + dest.x = x; + dest.y = y; + + for (i = 0; text[i] != 0; i++) { + c = text[i]; + src.x = gfx.font.size.x * (c & 15); + src.y = gfx.font.size.y * ((c & 240) >> 4); + if (white) + SDL_BlitSurface (gfx.font.image, &src, gfx.screen, &dest); + else + SDL_BlitSurface (gfx.font1.image, &src, gfx.screen, &dest); + dest.x += gfx.font.size.x-4; + } + + gfx_AddUpdateRect (x, y, dest.x - x, dest.h); +}; + diff --git a/src/game.c b/src/game.c new file mode 100644 index 0000000..a7eb2e7 --- /dev/null +++ b/src/game.c @@ -0,0 +1,374 @@ +/* game.c - procedures for the game. */ + +#include +#include + +#include "bomberclone.h" +#include "gfx.h" +#include "network.h" +#include "packets.h" +#include "chat.h" + +extern int UpdateRects_nr; + +void +game_draw_info () +{ + int i, + x, + j, + gfx_oldRects; + char text[255]; + char scrtext[255]; + SDL_Rect src, dest; + + redraw_logo (0, 0, gfx.res.x, 3*16); + gfx_AddUpdateRect (0,0, gfx.res.x, 3*16); + gfx_oldRects = UpdateRects_nr; + bman.players_nr = 0; + + /* draw Player names */ + if (GT_MP_PTP) { + for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++) + if ((bman.players[i].state & PSFM_used) != 0) { + + if (bman.players[i].gfx_nr != -1 && PS_IS_used (bman.players[i].state)) { + src.x = 3 * bman.players[i].gfx->smal_size.x; + src.y = 0; + src.w = dest.w = bman.players[i].gfx->smal_size.x; + src.h = dest.h = bman.players[i].gfx->smal_size.y; + + dest.x = x; + dest.y = j - 4; + + SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest); + } + + + sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points); + if ((bman.players[i].state & PSFM_alife) != PSFM_alife) { // Player is dead + draw_text (x, j, scrtext, 0); + if ((bman.players[i].state & PSF_used) != PSF_used) + draw_text (x, j, "-------------", 1); + } + else { // players is alife + draw_text (x, j, scrtext, 1); + bman.players_nr++; + } + + x = x + 170; + if (x >= gfx.res.x - (120 + 170)) { + x = 0; + j = j + 14; + } + } + } + + x = gfx.res.x - 120; + sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n); + draw_text (x, 0, text, 1); + sprintf (text, "Range: %2d", bman.players[bman.p_nr].range); + draw_text (x, 16, text, 1); + sprintf (text, "Speed: %2d", bman.players[bman.p_nr].speed); + draw_text (x, 32, text, 1); + + if (bman.state == GS_ready && GT_MP_PTPM) + draw_text (100, 32, "Press F4 to start the game", 1); + else if (bman.state == GS_ready) + draw_text (100, 32, "Waiting for the Server to Start", 1); + gfx_AddUpdateRect (100, 32, gfx.res.x - 100, 16); + + if (chat.visible == 0) { + SDL_Flip (gfx.screen); + chat_show (4, 3*16, gfx.res.x - 4, gfx.offset.y); + } +}; + + +void +game_loop () +{ + SDL_Event event; + Uint8 *keys; + int done = 0; + Uint32 timeloop1; + int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout + unsigned char key_bomb = 0; // last state of the bomb key + + draw_logo (); + draw_field (); + if (GT_MP_PTP) + net_game_fillsockaddr (); + + SDL_Flip (gfx.screen); + + timestamp = SDL_GetTicks (); // needed for time sync. + + d_gamedetail ("GAME START"); + + while (!done && (bman.state == GS_running || bman.state == GS_ready)) { + if (SDL_PollEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + done = 1; + bman.state = GS_quit; + } + + /* keyboard handling */ + keys = SDL_GetKeyState (NULL); + + /* only do movements if we're alife and GS_running */ + if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife && bman.state == GS_running) { + if (keys[SDLK_UP]) { + bman.players[bman.p_nr].d = up; + bman.players[bman.p_nr].m = 1; + } + if (keys[SDLK_DOWN]) { + bman.players[bman.p_nr].d = down; + bman.players[bman.p_nr].m = 1; + } + if (keys[SDLK_RIGHT]) { + bman.players[bman.p_nr].d = right; + bman.players[bman.p_nr].m = 1; + } + if (keys[SDLK_LEFT]) { + bman.players[bman.p_nr].d = left; + bman.players[bman.p_nr].m = 1; + } + if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) { + if (key_bomb == 0) + player_drop_bomb (); + key_bomb = 1; + } + else + key_bomb = 0; + if (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) { + d_printf ("not in use yet\n"); + } + } + else if (GT_MP_PTPM && keys[SDLK_F4] && event.type == SDL_KEYDOWN) { + /* Server is starting the game */ + bman.state = GS_running; + net_send_servermode (); + } + + if (event.key.keysym.sym == SDLK_ESCAPE && event.type == SDL_KEYDOWN) { + bman.state = GS_startup; + done = 1; + } + + chat_loop (&event); + + restore_players_screen (); + restore_bomb_screen (); + player_ilness_loop (); + if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife) + move_player (); + + player_calcpos (); + dead_playerani (); /* we need it to draw dead players */ + + if (bman.gametype != GT_single) + network_loop (); + + /* this will even set the variable "bman.player_nr" + to let us know how much Players are still left */ + game_draw_info (); + + bomb_loop (); + draw_players (); + + gfx_UpdateRects (); + + /* check if there is only one player left and the game is in multiplayer mode + and if there the last dieing animation is done */ + if ((GT_MP_PTPM) && bman.players_nr < 2) + gameovertimeout--; + + /* check if we died and we are in single mode and the animation is done */ + if (bman.gametype == GT_single && !PS_IS_alife(bman.players[bman.p_nr].state)) + gameovertimeout--; + + if (gameovertimeout <= 0) { + d_printf ("GAME: Game Over 'Cause only one or noone anymore alife\n"); + done = 1; + } + + // calculate time sync. + timeloop1 = SDL_GetTicks (); + while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < 20) { + s_delay (timeloop1 - timestamp - 1); + timeloop1 = SDL_GetTicks (); + } + + timestamp = timeloop1; + } + + chat_show (-1, -1, -1, -1); + + d_gamedetail ("GAME END"); + d_printf ("done = %d\n", done); +}; + + +void +single_game_new () +{ + int p, + i; + + // set players on field 1,1 + for (p = 0; p < MAX_PLAYERS; p++) { + bman.players[p].pos.x = 1 << 8; + bman.players[p].pos.y = 1 << 8; + bman.players[p].state = 0; + + // reset bombs + bman.players[p].bombs_n = START_BOMBS; + bman.players[p].range = START_RANGE; + bman.players[p].speed = START_SPEED; + for (i = 0; i < MAX_BOMBS; i++) { + bman.players[p].bombs[i].state = BS_off; + bman.players[p].bombs[i].ex_nr = -1; + } + + for (i = 0; i < PI_max; i++) + bman.players[p].ill[i].to = 0; + bman.players[p].frame = 0; + bman.players[p].frameto = 0; + bman.players[p].d = 0; + } + + bman.p_nr = 0; + bman.players[bman.p_nr].state = PSFM_alife; + player_set_gfx (&bman.players[bman.p_nr], 0); + bman.last_ex_nr = 1; + + field_new (); + + bman.players_nr_s = 1; + bman.players_nr = 1; + bman.gametype = GT_single; + bman.state = GS_running; +}; + + +/* + this routine is only for the server. + after this the data should be transfered to the other clients. +*/ +void +multi_new_game () +{ + int p, + i, + j, + dx, + dy, + mx, + my, + dist; + + // set players thier fields + for (i = 0; i < MAX_PLAYERS; i++) + bman.players[i].pos.y = bman.players[i].pos.x = -1; + + bman.players_nr = 0; + + p = 50; + dist = 8; + while (p == 50) { + p = 0; + dist--; + for (i = 0; (p < 50 && i < MAX_PLAYERS);) { + bman.players[i].pos.x = 2 * (s_random ((bman.fieldsize.x - 1) / 2)) + 1; + bman.players[i].pos.y = 2 * (s_random ((bman.fieldsize.y - 1) / 2)) + 1; + mx = my = 100; + for (j = 0; j <= i; j++) { /* search smalest distance */ + dy = bman.players[i].pos.y - bman.players[j].pos.y; + dx = bman.players[i].pos.x - bman.players[j].pos.x; + if (dy < 0) + dy = -dy; + if (dx < 0) + dx = -dx; + + if (mx > dx && i != j) + mx = dx; + if (my > dy && i != j) + my = dy; + } + + if (mx > dist || my > dist) + i++; + else + p++; + } + } + + bman.players_nr_s = 0; + for (p = 0; p < MAX_PLAYERS; p++) { + bman.players[p].pos.x = bman.players[p].pos.x << 8; + bman.players[p].pos.y = bman.players[p].pos.y << 8; + + bman.players[p].frame = 0; + bman.players[p].frameto = 0; + + if (PS_IS_used (bman.players[p].state)) { + bman.players_nr_s++; + if (bman.players[p].gfx_nr == -1) { + bman.players[p].gfx = NULL; + bman.players[p].state &= (0xff - (PSF_alife + PSF_playing)); + } + else { + bman.players[p].state |= PSF_alife + PSF_playing; + bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr]; + } + } + else + bman.players[p].state = 0; + + bman.players[p].bombs_n = START_BOMBS; + bman.players[p].range = START_RANGE; + bman.players[p].speed = START_SPEED; + for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */ + bman.players[p].ill[i].to = 0; + bman.players[p].frame = 0; + bman.players[p].frameto = 0; + bman.players[p].d = 0; + + // reset bombs + for (i = 0; i < MAX_BOMBS; i++) { + bman.players[p].bombs[i].state = BS_off; + bman.players[p].bombs[i].ex_nr = -1; + } + } + + field_new (); + + bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player + bman.last_ex_nr = 1; +}; + + +/* check which player won */ +void +game_end () +{ + int i; + + /* count the points */ + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state)) { + if (PS_IS_alife (bman.players[i].state)) { + bman.lastwinner = i; + bman.players[i].wins++; + bman.players[i].points += bman.players_nr_s; + } + } + + /* check which player is now free ,i.e. disconnected during the game and was playing */ + for (i = 0; i < MAX_PLAYERS; i++) + if ((bman.players[i].state & PSF_used ) == 0) + bman.players[i].state = 0; +} + diff --git a/src/gamesrv.c b/src/gamesrv.c new file mode 100644 index 0000000..a2bba2a --- /dev/null +++ b/src/gamesrv.c @@ -0,0 +1,469 @@ +/* + GameServer: this file will hold the protocol for the gameserver communication +*/ +#include "bomberclone.h" +#include "network.h" +#include "gamesrv.h" + +static int sock = -1; +struct game_entry gse[MAX_GAMESRVENTRYS]; +_menu menu[22]; +int menuselect = 0; + +/* + We want to get a server +*/ +void +gamesrv_getserver () +{ + int i, + keypressed = 0, + done = 0, + ds = 0, + gserv = bman.notifygamemaster, + bx, + by; + SDL_Event event; + Uint8 *keys; + + menuselect = 0; + for (i = 0; i < MAX_GAMESRVENTRYS; i++) { + gse[i].name[0] = 0; + gse[i].host[0] = 0; + gse[i].port[0] = 0; + } + for (i = 0; i < 21; i++) { + menu[i].index = 0; + menu[i].text[0] = 0; + } + if (!gserv) { + menu[0].index = 1; + sprintf (menu[0].text, "Scan for Games on the MasterServer"); + } + sprintf (menu[10].text, "User defined Server List"); + menu[20].index = 1; + sprintf (menu[20].text, "Enter an IP-Address"); + menu[21].index = -1; + for (i = 1; i <= MAX_SERVERENTRYS; i++) { + menu[i + 10].index = 1; + sprintf (menu[i + 10].text, "%d) %s", i, bman.serverlist[i - 1].name); + } + + draw_logo (); + draw_menu ("Select Server", menu, &bx, &by); + if (gserv) { + if (gamesrv_startudp () == -1) + return; + gamesrv_browse (1); + } + draw_select (menuselect, menu, bx, by); + + SDL_Flip (gfx.screen); + + while (menuselect != -1 && done == 0) { + + if (gserv) + i = gamesrv_getglist (); + /*keyboard */ + if (SDL_PollEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + bman.state = GS_quit; + menuselect = -1; + done = 1; + } + + keys = SDL_GetKeyState (NULL); + + if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + /* we want to quit */ + done = 1; + keypressed = 1; + menuselect = -1; + } + + if (keys[SDLK_DOWN] && (!keypressed)) { + d_printf ("down:%d\n", menu[menuselect].index); + menuselect++; + while (menu[menuselect].index == 0) + menuselect++; + if (menu[menuselect].index == -1) { + menuselect = 0; + while (menu[menuselect].index == 0) + menuselect++; + } + keypressed = 1; + ds = 1; + } + + if (keys[SDLK_UP] && (!keypressed)) { + d_printf ("up\n"); + menuselect--; + while (menu[menuselect].index == 0 && menuselect >= 0) + menuselect--; + if (menuselect == -1) + menuselect = 20; + keypressed = 1; + ds = 1; + } + if (keys[SDLK_RETURN] && (!keypressed)) { + if (menuselect == 0 && !gserv) { + gserv = 1; + if (gamesrv_startudp () == -1) + return; + gamesrv_browse (1); + } else done=1; + + + keypressed = 1; + } + + if (event.type == SDL_KEYUP) + keypressed = 0; + else if (event.type == SDL_KEYDOWN) + keypressed = 1; + + if (i) { + draw_logo (); + draw_menu ("Select Server", menu, &bx, &by); + draw_select (menuselect, menu, bx, by); + ds = 0; + SDL_Flip (gfx.screen); + } + else if (ds) { + draw_select (menuselect, menu, bx, by); + ds = 0; + SDL_Flip (gfx.screen); + } + s_delay (250); + } + + + if (menuselect > 0 && menuselect < 10) { + i = (menuselect - 1); + if (gse[i].name[0] != 0 && gse[i].host[0] != 0 && gse[i].port[0] != 0 && + (gse[i].state == GS_wait || gse[i].state == GS_running + || gse[i].state == GS_ready)) { + /* add if we are on Linux + and Windows and ai_family == PF_INET */ +#ifdef _WIN32 + if (gse[i].ai_family == PF_INET) { + sprintf (bman.servername, "%s:%s", gse[i].host, gse[i].port); + bman.net_ai_family = gse[i].ai_family; + } +#else + sprintf (bman.servername, "%s:%s", gse[i].host, gse[i].port); + d_printf("%s xxx %s xxx %s",gse[i].host,gse[i].port,bman.servername); + bman.net_ai_family = gse[i].ai_family; +#endif + } + } else if (menuselect >= 11 && menuselect < 19) + /* User defined Servers */ + strncpy (bman.servername, bman.serverlist[menuselect - 11].name, + LEN_SERVERNAME + LEN_PORT + 2); + else if (menuselect == 20) { + /* enter address */ + menu_get_text ("Enter Address", bman.servername, LEN_SERVERNAME + LEN_PORT + 2);} + + + if (gserv) { + gamesrv_browse (0); + udp_close (sock); + sock = -1; + +#ifdef _WIN32 + WSACleanup (); +#endif + } +}; + + +int +gamesrv_getglist () +{ + int i, + i1, + i2, + i3, + y, + nr, + rebuild = 0; + char buf[BUF_SIZE]; + char *pos; + char txt[255]; + struct _sockaddr addr; + struct game_entry entry; + + while (udp_get (sock, buf, BUF_SIZE, &addr, PF_INET) > 0) { + d_printf ("GOT:\n%s\n", buf); + + if (buf[0] == 'E') { + for (i = 0; i < MAX_GAMESRVENTRYS; i++) { + gse[i].name[0] = 0; + gse[i].host[0] = 0; + gse[i].port[0] = 0; + } + for (i = 0; i < 10; i++ ) { + menu[i].index = 0; + menu[i].text[0] = 0; + } + sprintf (menu[0].text, "No Games found on Masterserver"); + menu[0].index = 1; + rebuild = 1; + if (menuselect<10) menuselect=0; + } + else { + for (pos = buf; pos != 0;) { + // go throught the incoming data + switch (pos[0]) { + case ('P'): + sscanf (pos + 1, "%d,%d", &i1, &i2); + entry.curplayers = i1; + entry.maxplayers = i2; + break; + case ('V'): + sscanf (pos + 1, "%d.%d.%d", &i1, &i2, &i3); + entry.version.major = i1; + entry.version.minor = i2; + entry.version.sub = i3; + break; + case ('S'): + sscanf (pos + 1, "%d,%d,%d", &i1, &i2, &i3); + entry.state = i1; + entry.multitype = i2; + entry.gametype = i3; + break; + case ('I'): + if (pos[1] == '4') + entry.ai_family = PF_INET; + else if (pos[1] == '6') +#ifndef _WIN32 + entry.ai_family = PF_INET6; +#else + entry.ai_family = 0; +#endif + break; + case ('N'): + for (i = 1; (i - 1 < LEN_GAMENAME) && (pos[i] != 0) + && (pos[i] != '\n'); i++) + entry.name[i - 1] = pos[i]; + entry.name[i-1]=0; + break; + case ('H'): + for (i = 1; (i - 1 < LEN_SERVERNAME) && (pos[i] != 0) + && (pos[i] != '\n'); i++) + entry.host[i - 1] = pos[i]; + entry.host[i-1]=0; + break; + case ('O'): + for (i = 1; (i - 1 < LEN_PORT) && (pos[i] != 0) + && (pos[i] != '\n'); i++) + entry.port[i - 1] = pos[i]; + entry.port[i-1]=0; + break; + } + pos = strchr (pos, '\n'); + if (pos != 0) + pos++; + if (pos != 0 && pos[0] == 0) + pos = 0; + } + nr = gamesrv_findentry (entry.host, entry.port); + if (nr == -1) { + nr = gamesrv_findfree (); + if (nr == -1) + return -1; + } + gse[nr] = entry; + + + sprintf (txt, "%16s ", gse[nr].name); + + if (gse[nr].state == GS_wait) + sprintf (txt, "%s Wait ", txt); + else if (gse[nr].state == GS_running || gse[nr].state == GS_ready) + sprintf (txt, "%sRunning ", txt); + else if (gse[nr].state == GS_update) + sprintf (txt, "%s Update ", txt); + + sprintf (txt, "%s%d/%d ", txt, gse[nr].curplayers, gse[nr].maxplayers); + + if (gse[nr].ai_family == PF_INET) + sprintf (txt, "%s %d.%d.%d IPv4", txt, gse[nr].version.major, gse[nr].version.minor, + gse[nr].version.sub); + else + sprintf (txt, "%s %d.%d.%d IPv6", txt, gse[nr].version.major, gse[nr].version.minor, + gse[nr].version.sub); + + for (y = 0; y < 255; y++) + menu[nr + 1].text[y] = 0; + strncpy (menu[nr + 1].text, txt, 40); + rebuild = 1; + sprintf (menu[0].text, "Games on the Masterserver"); + menu[0].index = 0; + if (menuselect == 0) + menuselect = 1; + menu[nr + 1].index = 1; + } + } + return rebuild; +} + +int +gamesrv_startudp () +{ +#ifdef _WIN32 + WSADATA wsaData; + + if (WSAStartup (MAKEWORD (1, 1), &wsaData) != 0) { + d_printf ("WSAStartup failed.\n"); + exit (1); + } +#endif + + sock = udp_server (DEFAULT_GMUDPPORT, bman.net_ai_family); + if (sock == -1) { +#ifdef _WIN32 + WSACleanup (); +#endif + } + return sock; +} + + + +/* find the entry */ +int +gamesrv_findentry (char *host, char *port) +{ + int i, + y; + + for (i = 0, y = -1; (i < MAX_GAMESRVENTRYS) && (y == -1); i++) { + if (strcmp (gse[i].host, host) == 0 && strcmp (gse[i].port, port) == 0) + y = i; + } + return y; +}; + +/* Find first free entry */ +int +gamesrv_findfree () +{ + int i, + y; + + for (i = 0, y = -1; (y == -1) && (i < MAX_GAMESRVENTRYS); i++) + if (gse[i].host[0] == 0) + y = i; + + return y; +}; + + + +/* + Add and Delete Browsers from Serverbrowselist +*/ + + +void +gamesrv_browse (int i) +{ + char data[255]; + struct _sockaddr addr; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + + d_printf ("** Notify Browser Master Server\n"); + if (i) + sprintf (data, "B\n"); + else + sprintf (data, "E\n"); + + network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT); + dns_filladdr (host, LEN_SERVERNAME, port, LEN_PORT, bman.net_ai_family, &addr); + udp_send (sock, data, strlen (data), &addr, bman.net_ai_family); + d_printf ("Send: %s\n", data); +}; + +/* + The Server should know that we quit. + Delete every entry from our client. +*/ + + +void +gamesrv_quit () +{ + char data[255]; + struct _sockaddr addr; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + int len; + + d_printf ("** Notify GameMaster Server\n"); + sprintf (data, "D\n"); + + len = 4; + + network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT); + dns_filladdr (host, LEN_SERVERNAME, port, LEN_PORT, bman.net_ai_family, &addr); + + udp_send (bman.sock, data, len, &addr, bman.net_ai_family); + d_printf ("** Send \n\n%s\n\n", data); +}; + + +/* + send the mode of the game from the current bman.state and bman.gamename + parameter +*/ +void +gamesrv_sendmode (int maxplayer, int curplayers) +{ + char data[255]; + int len = 0; + struct _sockaddr addr; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + + d_printf ("** Notify GameMaster Server\n"); + + sprintf (data, "AV%s.%d\n", VERSION, SUB_VERSION); + sprintf (data, "%sP%d,%d\n", data, curplayers, maxplayer); + sprintf (data, "%sS%d,%d,%d\n", data, bman.state, bman.multitype, bman.gametype); + if (bman.net_ai_family == PF_INET) + sprintf (data, "%sI4\n", data); + else + sprintf (data, "%sI6\n", data); + sprintf (data, "%sN%s\n", data, bman.gamename); + + len = strlen (data); + + network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT); + dns_filladdr (host, LEN_SERVERNAME, port, LEN_PORT, bman.net_ai_family, &addr); + + host[0] = 0; + port[0] = 0; + dns_filladdr (host, LEN_SERVERNAME, port, LEN_PORT, bman.net_ai_family, &addr); + + udp_send (bman.sock, data, len, &addr, bman.net_ai_family); + d_printf ("** Send To (%s[:%s])\n\n%s\n\n", host, port, data); +}; + + +void +gamesrv_sendchat (char *text) +{ + char data[255]; + struct _sockaddr addr; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + + network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT); + dns_filladdr (host, LEN_SERVERNAME, port, LEN_PORT, bman.net_ai_family, &addr); + + sprintf (data, "C%s", text); + + udp_send (bman.sock, data, strlen (data), &addr, bman.net_ai_family); +}; diff --git a/src/gamesrv.h b/src/gamesrv.h new file mode 100644 index 0000000..a711708 --- /dev/null +++ b/src/gamesrv.h @@ -0,0 +1,30 @@ +/* + include file for the gamesrv.c file +*/ + +struct game_entry { + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + char name[LEN_GAMENAME]; + struct _version { + unsigned char major; + unsigned char minor; + unsigned char sub; + } version; + signed char curplayers; + signed char maxplayers; + signed char ai_family; + unsigned char state; + unsigned char multitype; + unsigned char gametype; +}; + +extern int gamesrv_findentry (char *host, char *port); +extern int gamesrv_findfree (); +extern int gamesrv_startudp (); +extern int gamesrv_getglist (); +extern void gamesrv_getserver (); +extern void gamesrv_quit (); +extern void gamesrv_browse (); +extern void gamesrv_sendmode (int maxplayer, int curplayers); +extern void gamesrv_sendchat (char *text); diff --git a/src/gfx.c b/src/gfx.c new file mode 100644 index 0000000..d67abbe --- /dev/null +++ b/src/gfx.c @@ -0,0 +1,765 @@ +/* gfx.c */ + +#include +#include "bomberclone.h" +#include "gfx.h" + +int UpdateRects_nr = 0; +SDL_Rect UpdateRects[MAX_UPDATERECTS]; + +_gfx gfx; + + +void getRGBpixel (SDL_Surface *surface, int x, int y, int *R, int *G, int *B) { + + Uint32 pixel = 0; + Uint8 r,g,b; + + /* Lock the screen for direct access to the pixels */ + if ( SDL_MUSTLOCK(surface) ) + if ( SDL_LockSurface(surface) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + return; + } + + pixel = getpixel (surface, x, y); + + if ( SDL_MUSTLOCK(surface) ) { + SDL_UnlockSurface(surface); + } + + SDL_GetRGB(pixel, surface->format, &r, &g, &b); + *R = r; + *G = g; + *B = b; +}; + + +Uint32 getpixel(SDL_Surface *surface, int x, int y) +{ + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch(bpp) { + case 1: + return *p; + + case 2: + return *(Uint16 *)p; + + case 3: + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; + else + return p[0] | p[1] << 8 | p[2] << 16; + + case 4: + return *(Uint32 *)p; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } +} + + +void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) +{ + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to set */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch(bpp) { + case 1: + *p = pixel; + break; + + case 2: + *(Uint16 *)p = pixel; + break; + + case 3: + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (pixel >> 16) & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = pixel & 0xff; + } else { + p[0] = pixel & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = (pixel >> 16) & 0xff; + } + break; + + case 4: + *(Uint32 *)p = pixel; + break; + } +} + + +void scale (short int *dpattern, short int x, short int y) { + int a, dx, dy; + + if (x >= SCALE_MAXRES || y >= SCALE_MAXRES) { + for (x = 0; x < SCALE_MAXRES; x++) + dpattern[x] = 0; + return; + } + + if (x > y) { + dy = 2 * y; + dx = a = 2 * x - dy; + do { + if ( a <= 0) { + dpattern[(y--)-1] = x; + a = a + dx; + } + else + a = a - dy; + } while (x--); + } + else { + dy = 2 * x; + dx = a = 2 * y - dy; + do { + dpattern[y] = x; + if (a <= 0) { + x--; + a = a + dx; + } + else + a = a - dy; + } while (y--); + } +} + + +SDL_Surface * +scale_image (SDL_Surface * orginal, int newx, int newy) +{ + Uint32 rmask, + gmask, + bmask, + amask; + SDL_Surface *surface; + + int y, x; + short int xpattern[SCALE_MAXRES]; + short int ypattern[SCALE_MAXRES]; + +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; +#endif + + surface = SDL_CreateRGBSurface (SDL_SWSURFACE, newx, newy, 32, rmask, gmask, bmask, amask); + if (surface == NULL) { + fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); + return NULL; + } + + /* Lock the screen for direct access to the pixels */ + if ( SDL_MUSTLOCK(surface) ) + if ( SDL_LockSurface(surface) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + return NULL; + } + if ( SDL_MUSTLOCK(orginal) ) + if ( SDL_LockSurface(orginal) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + if ( SDL_MUSTLOCK(surface) ) { + SDL_UnlockSurface(surface); + } + return NULL; + } + + /* do the scaling work */ + scale (xpattern, orginal->w -1, newx); + scale (ypattern, orginal->h -1, newy); + + for (x = newx-1; x >= 0; x--) + for (y = newy - 1; y >= 0; y--) + putpixel (surface, x, y, getpixel (orginal, xpattern[x], ypattern[y])); + if ( SDL_MUSTLOCK(orginal) ) { + SDL_UnlockSurface(orginal); + } + + if ( SDL_MUSTLOCK(surface) ) { + SDL_UnlockSurface(surface); + } + + return surface; +}; + + +SDL_Surface *makegray_image (SDL_Surface *org) { + Uint32 rmask, + gmask, + bmask, + amask; + Uint32 pixel, transpixel = 0; + SDL_Surface *dest; + int y, x; + Uint8 r,g,b,gray; + +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; +#endif + + dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org->w, org->h, 32, rmask, gmask, bmask, amask); + if (dest == NULL) { + fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); + return NULL; + } + + /* Lock the screen for direct access to the pixels */ + if ( SDL_MUSTLOCK(dest) ) + if ( SDL_LockSurface(dest) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + return NULL; + } + + if ( SDL_MUSTLOCK(org) ) + if ( SDL_LockSurface(org) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + if ( SDL_MUSTLOCK(dest) ) { + SDL_UnlockSurface(dest); + } + return NULL; + } + + for (x = 0; x < org->w; x++) + for (y = 0; y < org->h; y++) { + pixel = getpixel (org, x, y); + if (x == 0 && y == 0) + transpixel = pixel; + + if (pixel != transpixel) { + SDL_GetRGB(pixel, org->format, &r, &g, &b); + gray = (r/3 + g/3 + b/3); + pixel = SDL_MapRGB(dest->format, gray, gray, gray); + } + + putpixel (dest, x, y, pixel); + } + + if ( SDL_MUSTLOCK(org) ) { + SDL_UnlockSurface(org); + } + + if ( SDL_MUSTLOCK(dest) ) { + SDL_UnlockSurface(dest); + } + + SDL_SetColorKey (dest, SDL_SRCCOLORKEY,transpixel); + + return dest; +}; + + + +#define __smalsizeX 12 +void gfx_load_players (int sx, int sy) { + float sfkt, ssfkt; + char filename[255]; + int i, + j, + r, + g, + b; + SDL_Surface *tmpimage, *tmpimage1; + + sfkt = ((float) sx) / ((float) GFX_IMGSIZE); + ssfkt = ((float) __smalsizeX) / ((float) GFX_IMGSIZE); + + /* loading the player images */ + for (j = i = 0; i < MAX_PLAYERS; i++) { + sprintf (filename, "%s/player%d.bmp", bman.datapath, j); + j++; + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + if (j == 0) { // try again with the first image, if this don't work give up. + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + i--; // load the this image again + j = 0; + } + else { + /* load the game player image */ + gfx.players[i].size.y = sy * 2; + gfx.players[i].size.x = (tmpimage->w / 4) * sfkt; + gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y; + tmpimage1 = scale_image (tmpimage, gfx.players[i].size.x * 4 , gfx.players[i].ani.frames * gfx.players[i].size.y); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage1); + /* calculate the numbers of images for the animation */ + gfx.players[i].offset.x = (sx - gfx.players[i].size.x) / 2; + gfx.players[i].offset.y = - sy; + + /* load the smal image */ + gfx.players[i].smal_size.y = __smalsizeX * 2; + gfx.players[i].smal_size.x = (tmpimage->w / 4) * ssfkt; + tmpimage1 = scale_image (tmpimage, gfx.players[i].smal_size.x * 4 , gfx.players[i].ani.frames * gfx.players[i].smal_size.y); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.players[i].smal_image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage1); + SDL_FreeSurface (tmpimage); + } + } +} + +/* load the images with teh right scaleing */ +void gfx_game_init () { + int i, + r, + g, + b; + + char filename[255]; + SDL_Surface *tmpimage, *tmpimage1; + float sfkt; + + d_printf ("GFX Init\n"); + + menu_displaytext ("Please Wait", "Loading GFX Data", 64, 64, 128); + + /* Calculate the Best Size of the Images */ + gfx.block.x = gfx.res.x / (bman.fieldsize.x+1); + gfx.block.y = (gfx.res.y - 80) / (bman.fieldsize.y+1); + + if (gfx.block.x < gfx.block.y) + gfx.block.y = gfx.block.x; + else + gfx.block.x = gfx.block.y; + + /* create Table of points */ + scale (gfx.postab, gfx.block.x, 256); + + sfkt = ((float) gfx.block.x) / ((float) GFX_IMGSIZE); + + /* calculating the best offset for the field on the screen */ + gfx.offset.x = (gfx.res.x - (gfx.block.x * bman.fieldsize.x)) / 2; + gfx.offset.y = gfx.res.y - (gfx.block.y * bman.fieldsize.y); + + /* load the fire */ + sprintf (filename, "%s/fire.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.fire.frames = tmpimage->h / GFX_IMGSIZE; + tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, gfx.fire.frames * gfx.block.y); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, + SDL_MapRGB (tmpimage1->format, 255, 0, 255)); + gfx.fire.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + + + /* load the bomb */ + sprintf (filename, "%s/bomb.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.bomb.frames = tmpimage->h / GFX_IMGSIZE; + tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, gfx.bomb.frames * gfx.block.y); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.bomb.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + + /* load the illnessthing */ + sprintf (filename, "%s/playersick.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.ill.frames = tmpimage->h / (2*GFX_IMGSIZE); + tmpimage1 = scale_image (tmpimage, (tmpimage->w / (2*GFX_IMGSIZE)) * (2 * gfx.block.x), gfx.ill.frames * (2*gfx.block.y)); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.ill.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + + /* loading the field images */ + for (i = 0; i < FT_max; i++) { + switch (i) { + case (FT_nothing): + sprintf (filename, "%s/background.bmp", bman.datapath); + break; + case (FT_stone): + sprintf (filename, "%s/stone.bmp", bman.datapath); + break; + case (FT_block): + sprintf (filename, "%s/block.bmp", bman.datapath); + break; + case (FT_death): + sprintf (filename, "%s/fielddeath.bmp", bman.datapath); + break; + case (FT_bomb): + sprintf (filename, "%s/fieldbomb.bmp", bman.datapath); + break; + case (FT_fire): + sprintf (filename, "%s/fieldfire.bmp", bman.datapath); + break; + case (FT_shoe): + sprintf (filename, "%s/fieldshoe.bmp", bman.datapath); + break; + } + + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; + tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, gfx.field[i].frames * gfx.block.y); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, 255, 255, 255)); + gfx.field[i].image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + } + + + /* loading the player images */ + gfx_load_players (gfx.block.x, gfx.block.y); + + UpdateRects_nr = 0; +} + +/* frees the player images */ +void gfx_free_players () { + int i; + + for (i = 0; i < MAX_PLAYERS; i++) { + if (gfx.players[i].ani.image != NULL) + SDL_FreeSurface (gfx.players[i].ani.image); + gfx.players[i].ani.image = NULL; + if (gfx.players[i].smal_image != NULL) + SDL_FreeSurface (gfx.players[i].smal_image); + gfx.players[i].smal_image = NULL; + } +} + + +void gfx_game_shutdown () { + int i; + + menu_displaytext ("Please Wait", "Freeing GFX Data", 64, 128, 64); + + for (i = 0; i < FT_max; i++) { + if (gfx.field[i].image != NULL) + SDL_FreeSurface (gfx.field[i].image); + gfx.field[i].image = NULL; + } + + gfx_free_players (); + + if (gfx.bomb.image != NULL) + SDL_FreeSurface (gfx.bomb.image); + + if (gfx.fire.image != NULL) + SDL_FreeSurface (gfx.fire.image); + + gfx.bomb.image = NULL; + gfx.fire.image = NULL; +}; + + + +/* init the whole GFX Part */ +void gfx_init () { + if (gfx.fullscreen) + gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, + SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN); + else + gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, + SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL); + + if (gfx.screen == NULL) { + d_printf ("Unable to set video mode: %s\n", SDL_GetError ()); + return; + } + + SDL_ShowCursor(SDL_DISABLE); + + gfx_loaddata (); +}; + + +void +gfx_loaddata () +{ + int r, + g, + b; + + char filename[255]; + SDL_Surface *tmpimage, *tmpimage1; + + /* load the font */ + sprintf (filename, "%s/font.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, + SDL_MapRGB (tmpimage->format, 0, 0, 0)); + gfx.font.image = SDL_DisplayFormat (tmpimage); + gfx.font.size.x = 16; + gfx.font.size.y = 16; + SDL_FreeSurface (tmpimage); + + /* load the font */ + sprintf (filename, "%s/font1.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, + SDL_MapRGB (tmpimage->format, 0, 0, 0)); + gfx.font1.image = SDL_DisplayFormat (tmpimage); + gfx.font1.size.x = 16; + gfx.font1.size.y = 16; + SDL_FreeSurface (tmpimage); + + /* load the logo */ + sprintf (filename, "%s/logo.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + tmpimage1 = scale_image (tmpimage, gfx.res.x, gfx.res.y); + SDL_FreeSurface (tmpimage); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, + SDL_MapRGB (tmpimage1->format, 255, 255, 0)); + gfx.logo = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage1); + + + /* load the menuselector */ + sprintf (filename, "%s/menuselect.bmp", bman.datapath); + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.menuselect.frames = tmpimage->h / GFX_IMGSIZE; + tmpimage1 = scale_image (tmpimage, gfx.font.size.x, gfx.menuselect.frames * gfx.font.size.y); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY,SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.menuselect.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); +}; + +void +gfx_shutdown () +{ + int i; + + for (i = 0; i < FT_max; i++) + SDL_FreeSurface (gfx.field[i].image); + + for (i = 0; i < MAX_PLAYERS; i++) + SDL_FreeSurface (gfx.players[i].ani.image); + + SDL_FreeSurface (gfx.font.image); + SDL_FreeSurface (gfx.font1.image); + SDL_FreeSurface (gfx.logo); + SDL_FreeSurface (gfx.bomb.image); + SDL_FreeSurface (gfx.fire.image); + SDL_FreeSurface (gfx.menuselect.image); + + gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, + SDL_HWSURFACE | SDL_DOUBLEBUF); + + SDL_FreeSurface (gfx.screen); +} + +void +gfx_AddUpdateRect (int x, int y, int w, int h) +{ + if (UpdateRects_nr >= MAX_UPDATERECTS) + return; + + UpdateRects[UpdateRects_nr].x = x; + UpdateRects[UpdateRects_nr].y = y; + UpdateRects[UpdateRects_nr].w = w; + UpdateRects[UpdateRects_nr].h = h; + + UpdateRects_nr++; +} + + +void +gfx_UpdateRects () +{ + if (UpdateRects_nr > 0) + SDL_UpdateRects (gfx.screen, UpdateRects_nr, UpdateRects); + UpdateRects_nr = 0; + +} + +void draw_logo () { + + SDL_BlitSurface (gfx.logo, NULL, gfx.screen, NULL); + + UpdateRects_nr = 0; + gfx_AddUpdateRect (0,0,gfx.screen->w, gfx.screen->h); +} + + +void redraw_logo_shaded (int x, int y, int w, int h, int c) { + + SDL_Rect dest; + + dest.w = w; + dest.h = h; + dest.x = x; + dest.y = y; + + redraw_logo (x, y, w+1, h+1); + + if (gfx_locksurface (gfx.screen)) + return; + + dest.h += dest.y; + dest.w += dest.x; + + draw_shadefield (gfx.screen, &dest, c); + + gfx_unlocksurface (gfx.screen); +}; + + +void redraw_logo (int x, int y, int w, int h) { + + SDL_Rect src, dest; + + dest.w = src.w = w; + dest.h = src.h = h; + + dest.x = x; + dest.y = y; + + src.x = x; + src.y = y; + + SDL_BlitSurface (gfx.logo, &src, gfx.screen, &dest); + +// gfx_AddUpdateRect (); +}; + +void +shade_pixel(SDL_Surface *s, int x, int y, int c) { + Uint32 p; + Uint8 r,g,b; + + p = getpixel(s,x,y); + + SDL_GetRGB(p, s->format, &r, &g, &b); + + if (c > 0) { + if (((Sint16) r) + c < 256) {r += c;} else r = 255; + if (((Sint16) g) + c < 256) {g += c;} else g = 255; + if (((Sint16) b) + c < 256) {b += c;} else b = 255; + } + else { + if (((Sint16) r) + c > 0) {r += c;} else r = 0; + if (((Sint16) g) + c > 0) {g += c;} else g = 0; + if (((Sint16) b) + c > 0) {b += c;} else b = 0; + } + + p = SDL_MapRGB(s->format, r, g, b); + + putpixel(s,x,y,p); +} + +int gfx_locksurface (SDL_Surface *surface) { + if ( SDL_MUSTLOCK(surface) ) + if ( SDL_LockSurface(surface) < 0 ) { + fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); + return -1; + } + return 0; +}; + + +void gfx_unlocksurface (SDL_Surface *surface) { + if ( SDL_MUSTLOCK(surface) ) { + SDL_UnlockSurface(surface); + } +}; + + +void +draw_shadefield (SDL_Surface *s, SDL_Rect *rec, int c) { + int x1, x, x2, y1, y; + + if (rec->x > rec->w) { + x1 = rec->w; + x2 = rec->x; + } + else { + x2 = rec->w; + x1 = rec->x; + } + + if (rec->y > rec->h) { + y = rec->h; + y1 = rec->y; + } + else { + y1 = rec->h; + y = rec->y; + } + + for (;y <= y1;y++) + for (x = x1 ;x <= x2;x++) + shade_pixel(s, x, y, c); +}; + + +SDL_Surface *gfx_copyscreen (SDL_Rect *wnd) { + SDL_Surface *res; + SDL_Rect dest; + + res = SDL_CreateRGBSurface(SDL_HWSURFACE, wnd->w, wnd->h, gfx.screen->format->BitsPerPixel, gfx.screen->format->Rmask, gfx.screen->format->Gmask, gfx.screen->format->Bmask, gfx.screen->format->Amask); + + dest.x = 0; + dest.y = 0; + dest.w = wnd->w; + dest.h = wnd->h; + + SDL_BlitSurface (gfx.screen, wnd, res, &dest); + return res; +}; diff --git a/src/gfx.h b/src/gfx.h new file mode 100644 index 0000000..c1402b0 --- /dev/null +++ b/src/gfx.h @@ -0,0 +1,89 @@ +#ifndef _GFX_H_ + +#define _GFX_H_ + +#define SCALE_MAXRES 10000 +#define GFX_IMGSIZE 64 +#define GFX_PLAYERIMGSIZE_Y 128 + +#include "basic.h" + +struct __gfxani { + SDL_Surface *image; + int frames; // how many single frames (image -> heigh / (1.5 * gamestyle.height)) +} typedef _gfxani; + + +struct __gfxplayer { + _gfxani ani; + _point offset; + _point size; // height of the image.. needed for faster access. + _point smal_size; // smal size of the image + SDL_Surface *smal_image; // smal size of the animation +} typedef _gfxplayer; + + +struct __gfxfont { + SDL_Surface *image; + _point size; +} typedef _gfxfont; + + +struct __gfx { + SDL_Surface *screen; + _point res; // resolution + _point block; // block size + + unsigned char fullscreen; + + _point offset; // where the game field starts + + _gfxfont font; + _gfxfont font1; + + _gfxplayer players[MAX_PLAYERS]; + short int postab[256]; // table of points where we need to go to. + + _gfxani field[FT_max]; // the field animations + _gfxani fire; // fire (explostion) + _gfxani bomb; // bomb animation + _gfxani ill; // sick animation above the player + + _gfxani menuselect; // The Menu Select GFX (the bomb ?) + + SDL_Surface *logo; +} typedef _gfx; + +extern _gfx gfx; + + +// everything what is in gfx.c +extern void gfx_loaddata (); +extern void gfx_UpdateRects (); +extern void gfx_AddUpdateRect (int x, int y, int w, int h); +extern void redraw_logo (int x, int y, int w, int h); +extern void draw_logo (); +extern void gfx_init (); // Load Base Image Data +extern void gfx_game_init (); // Load Game Data +extern void gfx_game_shutdown (); // Free Image Data +extern void gfx_shutdown (); // +extern void getRGBpixel (SDL_Surface *surface, int x, int y, int *R, int *G, int *B); +extern Uint32 getpixel(SDL_Surface *surface, int x, int y); +extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); +extern void scale (short int *dpattern, short int x, short int y); +extern SDL_Surface *scale_image (SDL_Surface * orginal, int newx, int newy); +extern void shade_pixel(SDL_Surface *s, int x, int y, int c); +extern void draw_shadefield (SDL_Surface *s, SDL_Rect *rec, int c); +extern int gfx_locksurface (SDL_Surface *surface); +extern void gfx_unlocksurface (SDL_Surface *surface); +extern void redraw_logo_shaded (int x, int y, int w, int h, int c); +extern void gfx_load_players (int sx, int sy); +extern void gfx_free_players (); +extern SDL_Surface *makegray_image (SDL_Surface *org); +extern SDL_Surface *gfx_copyscreen (SDL_Rect *wnd); + +// declared functions in font.c +extern void draw_text (int x, int y, char *text, int white); + +#endif + diff --git a/src/keybinput.c b/src/keybinput.c new file mode 100644 index 0000000..f01b5ea --- /dev/null +++ b/src/keybinput.c @@ -0,0 +1,54 @@ +/* keyborad handling for text fields */ + +#include +#include "keybinput.h" + +static int keybinput_oldkey = 0; + +void keybinput_new (_keybinput *ki) { + int i; + + for (i = 0; i < 255; i++) + ki->text[i] = 0; + ki->curpos = 0; + ki->len = 0; +} + + +int keybinput_loop (_keybinput *ki, SDL_Event *event) { + int key = 0; + + ki->changed = 0; + + if (event->type == SDL_KEYUP) + keybinput_oldkey = 0; + + if (event->type == SDL_KEYDOWN && keybinput_oldkey != event->key.keysym.sym) { + key = keybinput_oldkey = event->key.keysym.sym; + + if (key == 8) { // BACKSPACE + if (ki->curpos > 0) { + ki->curpos--; + ki->text[ki->curpos] = 0; + ki->changed = 1; + } + } + else if (key >= ' ' && key <= 'z') { + if (ki->curpos < 255) { + ki->text[ki->curpos++] = key; + ki->text[ki->curpos] = 0; + ki->changed = 1; + } + } + ki->len = strlen (ki->text); + } + + if (key == SDLK_RETURN) + return 1; + + if (key == SDLK_ESCAPE) + return -1; + + return 0; +} + diff --git a/src/keybinput.h b/src/keybinput.h new file mode 100644 index 0000000..c9358e3 --- /dev/null +++ b/src/keybinput.h @@ -0,0 +1,15 @@ + +#ifndef _KEYBINPUT_H_ +#define _KEYBINPUT_H_ + +struct __keybinput { + char text[255]; + short int curpos; + short int len; + char changed; +} typedef _keybinput; + +extern void keybinput_new (_keybinput *ki); +extern int keybinput_loop (_keybinput *ki, SDL_Event *event); + +#endif diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..c0414d2 --- /dev/null +++ b/src/main.c @@ -0,0 +1,68 @@ + +#include "bomberclone.h" +#include "network.h" +#include "gfx.h" +#include "../config.h" + +_bomberclone bman; // Holds GameData +Uint32 timestamp; // timestamp + +int +main (int argc, char **argv) +{ + int menuselect = 0; + _menu menu[] = { + {0, "Singleplayer"}, + {1, "Multiplayer"}, + {2, "Configuration"}, + {3, "Quit Game"}, + {-1, ""} + }; + char text[255]; + + if (SDL_Init (SDL_INIT_VIDEO) != 0) { + d_printf ("Unable to init SDL: %s\n", SDL_GetError ()); + return (1); + } + + game_init (argv); + d_printf ("\n\n ***** Bomberclone Version %s (%d)\n\n",VERSION,SUB_VERSION); + if (ReadConfig()) { + gfx_init (); + menu_get_text ("Please You Playername", bman.playername, LEN_PLAYERNAME-1); + bman.playername[LEN_PLAYERNAME-1] = 0; + } else { + gfx_init (); + if (bman.selectplayer) + menu_get_text ("Please You Playername", bman.playername, LEN_PLAYERNAME); + } + ReadPrgArgs (argc, argv); + + sprintf(text,"Welcome to BomberClone"); + while (menuselect != -1 && bman.state != GS_quit) { + + menuselect = menu_loop (text , menu, menuselect); + + switch (menuselect) { + case (0) : // Singleplayer + single_game_new (); + gfx_game_init (); + game_loop (); + gfx_game_shutdown (); + break; + case (1) : // Multiplayer + netmenu(); + break; + case (2) : // Options + configuration (); + break; + case (3) : // Quit + bman.state = GS_quit; + break; + } + } + + gfx_shutdown (); + + return 0; +}; diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 0000000..170ff40 --- /dev/null +++ b/src/menu.c @@ -0,0 +1,335 @@ +/* menu's for the game */ + +#include +#include "bomberclone.h" +#include "gfx.h" + +#define MENU_BG_SHADE_DARK -64 +#define MENU_BG_SHADE_BRIGHT 64 + + +void +draw_menubox (int x, int y) +{ + int x1, + x2, + y1, + y2, + i; + SDL_Rect src, + dest; + + x1 = gfx.res.x / 2 - x / 2; + x2 = gfx.res.x / 2 + x / 2; + y1 = gfx.res.y / 2 - y / 2; + y2 = gfx.res.y / 2 + y / 2; + + if (gfx_locksurface (gfx.screen)) + return; + + for (i = 0; i < 2; i++) { + src.x = x1 + i; + src.w = x2 + i; + src.y = y1 + i; + src.h = y2 + i; + draw_shadefield (gfx.screen, &src, MENU_BG_SHADE_BRIGHT); + } + + gfx_unlocksurface (gfx.screen); + + dest.w = src.w = x - 2; + dest.h = src.h = y - 2; + dest.x = src.x = x1 + 2; + dest.y = src.y = y1 + 2; + + redraw_logo_shaded (x1 + 2, y1 + 2, x - 2, y - 2, MENU_BG_SHADE_DARK); +} + +void +draw_menu (char *text, _menu menu[], int *x, int *y) +{ + int last, + maxlen, + x1, + y1, + i; + char vers[20]; + + // count the number of entrys + for (last = 0, maxlen = 0; menu[last].index != -1; last++) + if (strlen (menu[last].text) > maxlen) + maxlen = strlen (menu[last].text); + if (strlen (text) > maxlen) + maxlen = strlen (text); + *x = x1 = gfx.res.x / 2 - ((gfx.font.size.x + (maxlen * (gfx.font.size.x - 2))) / 2); + y1 = gfx.res.y / 2 - ((last + 2) * gfx.font.size.y / 2); + x1 = x1 + gfx.font.size.x; + draw_menubox (maxlen * gfx.font.size.x, (last + 3) * gfx.font.size.y); + draw_text (x1, y1, text, 1); + + *y = y1 = y1 + (gfx.font.size.y * 2); + + for (i = 0; i < last; i++) { + draw_text (x1, y1, menu[i].text, 1); + y1 = y1 + gfx.font.size.y; + } + sprintf (vers, "v%s.%d", VERSION, SUB_VERSION); + draw_text (gfx.res.x - gfx.font.size.x * strlen (vers), gfx.res.y - gfx.font.size.y, vers, 1); +}; + + +void +draw_select (int select, _menu menu[], int x, int y) +{ + SDL_Rect dest, + src; + int last; + + for (last = 0; menu[last].index != -1; last++) + redraw_logo_shaded (x, y + last * gfx.font.size.y, gfx.menuselect.image->w, gfx.menuselect.image->h , MENU_BG_SHADE_DARK); + + dest.x = x; + dest.y = y + select * gfx.font.size.y; + + src.x = 0; + src.y = 0; + src.w = gfx.font.size.x; + src.h = gfx.font.size.y; + + SDL_BlitSurface (gfx.menuselect.image, &src, gfx.screen, &dest); +}; + + +int +menu_loop (char *menutitle, _menu menu[], int lastselect) +{ + int menuselect = lastselect, + done = 0, + lastentry; + SDL_Event event; + Uint8 *keys; + int keypressed = 0; + + int bx, + by; + + draw_logo (); + + draw_menu (menutitle, menu, &bx, &by); + + SDL_Flip (gfx.screen); + + for (lastentry = 0; menu[lastentry].index != -1; lastentry++); + + while ((!done || keypressed == 1) && bman.state != GS_quit) { + draw_select (menuselect, menu, bx, by); + + SDL_Flip (gfx.screen); + + if (SDL_WaitEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + menuselect = -1; + bman.state = GS_quit; + done = 1; + } + + /* keyboard handling */ + keys = SDL_GetKeyState (NULL); + if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN) { + menuselect++; + if (menuselect >= lastentry) + menuselect = 0; + } + + if (keys[SDLK_UP] && event.type == SDL_KEYDOWN) { + menuselect--; + if (menuselect < 0) + menuselect = lastentry - 1; + } + + if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + return -1; + } + if (!keys[SDLK_ESCAPE] && event.type == SDL_KEYUP) + keypressed = 0; + + if (keys[SDLK_RETURN] && event.type == SDL_KEYDOWN) { + done = 1; + keypressed = 1; + } + if (!keys[SDLK_RETURN] && event.type == SDL_KEYUP) + keypressed = 0; + + }; + return menuselect; +}; + +void +menu_get_text (char *title, char *text, int len) +{ + char t[255]; + int done = 0, + keypressed = 0, + curpos, + x, + y, + i, + len_; + SDL_Event event; + Uint8 *keys; + + curpos = strlen (text); + strcpy (t, text); + if (len > strlen (title)) { + len_ = len; + } + else { + len_ = strlen (title); + } + draw_logo (); + y = (gfx.res.y - 2 * gfx.font.size.y) / 2; + x = (gfx.res.x - (gfx.font.size.x - 4) * len_) / 2; + draw_menubox ((gfx.font.size.x - 1) * len_, 4 * gfx.font.size.y); + draw_text (x, y, title, 1); + y = y + gfx.font.size.y; + x = (gfx.res.x - (gfx.font.size.x - 4) * len) / 2; + + if ((len - 1) * (gfx.font.size.x - 4) > gfx.res.x) + len_ = 40; + else + len_ = len; + + while (!done || keypressed == 1) { + + redraw_logo_shaded (x, y, (gfx.font.size.x - 4) * len_, gfx.font.size.y, MENU_BG_SHADE_DARK); + draw_text (x, y, t, 1); + + draw_text (x + (gfx.font.size.x - 4) * curpos, y, "_", 1); + + SDL_Flip (gfx.screen); + + if (SDL_WaitEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + bman.state = GS_quit; + done = 1; + } + + keys = SDL_GetKeyState (NULL); + if (!keypressed && keys[SDLK_LEFT] && event.type == SDL_KEYDOWN) { + if (curpos > 0) + curpos--; + keypressed = 1; + } + if (!keypressed && keys[SDLK_RIGHT] && event.type == SDL_KEYDOWN) { + if (curpos < strlen (text) && curpos < len - 1) + curpos++; + keypressed = 1; + } + + if (!keypressed && keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + done = 1; + keypressed = 1; + } + + if (!keypressed && keys[SDLK_RETURN] && event.type == SDL_KEYDOWN) { + done = 1; + keypressed = 1; + strcpy (text, t); + } + + if (!keypressed && keys[8] && event.type == SDL_KEYDOWN) + if (curpos > 0) { + curpos--; + t[curpos] = t[curpos + 1]; + t[curpos + 1] = t[curpos + 2]; + keypressed = 1; + } + + for (i = ' '; i <= 'z'; i++) + if (!keypressed && keys[i] && event.type == SDL_KEYDOWN) { + if (t[curpos] == 0) + t[curpos + 1] = 0; + t[curpos] = i; + if (curpos < strlen (t) && curpos < len - 1) + curpos++; + keypressed = 1; + } + + if (event.type == SDL_KEYUP) + keypressed = 0; + + } +}; + + +void +menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b) +{ + int x, + x1, + y, + y1, + len; + SDL_Rect dest; + + len = strlen (title); + if (len < strlen (text)) + len = strlen (text); + + y = (gfx.res.y - 2 * gfx.block.y) / 2; + x = (gfx.res.x - (gfx.font.size.x - 4) * len) / 2; + + y1 = gfx.font.size.y * 3; + x1 = ((gfx.font.size.x - 4) * len); + + dest.x = x; + dest.y = y - 4; + dest.h = y1; + dest.w = x1; + SDL_FillRect (gfx.screen, &dest, SDL_MapRGB (gfx.screen->format, r, g, b)); + + y = (gfx.res.y - 2 * gfx.block.y) / 2; + draw_text ((gfx.res.x - (gfx.font.size.x - 4) * strlen (title)) / 2, y, title, 1); + draw_text ((gfx.res.x - (gfx.font.size.x - 4) * strlen (text)) / 2, y + gfx.font.size.y, text, + 0); + + SDL_Flip (gfx.screen); +}; + + +void +menu_displaymessage (char *title, char *text) +{ + SDL_Event event; + Uint8 *keys; + int done = 0, + keypressed = 0; + + menu_displaytext (title, text, 64, 0, 0); + + while (done == 0 || (done == 1 && keypressed == 1)) { + if (SDL_WaitEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + done = 1; + bman.state = GS_quit; + } + keys = SDL_GetKeyState (NULL); + + if (!keypressed && keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + done = 1; + keypressed = 1; + } + + if (!keypressed && keys[SDLK_RETURN] && event.type == SDL_KEYDOWN) { + done = 1; + keypressed = 1; + } + + if (event.type == SDL_KEYUP) + keypressed = 0; + } + +}; diff --git a/src/multiwait.c b/src/multiwait.c new file mode 100644 index 0000000..800fc55 --- /dev/null +++ b/src/multiwait.c @@ -0,0 +1,361 @@ +/* + multiwait.c - this manages only the network screen where + everyone have to select it's players and where even the basic chat is inside +*/ + +#include "bomberclone.h" +#include "network.h" +#include "packets.h" +#include "gamesrv.h" +#include "gfx.h" +#include "chat.h" + +#define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (bman.players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--); + +extern int UpdateRects_nr; + +static int mw_y = 0, + mw_frame = 0, + mw_frameto = 0; +static SDL_Surface *mw_plgfx[MAX_PLAYERS]; + + +/* this will load some graphics and so other stuff */ +void +mw_init () +{ + int i; + SDL_Surface *tmp; + draw_logo (); + + menu_displaytext ("Please Wait", "Loading GFX Data", 64, 128, 64); + + gfx_load_players (32, 32); + network_loop (); + for (i = 0; i < MAX_PLAYERS; i++) { + network_loop (); + tmp = makegray_image (gfx.players[i].ani.image); + network_loop (); + mw_plgfx[i] = SDL_DisplayFormat (tmp); + network_loop (); + SDL_FreeSurface (tmp); + network_loop (); + } +}; + + +/* free all grafics */ +void +mw_shutdown () +{ + int i; + + chat_show (-1, -1, -1, -1); + + menu_displaytext ("Please Wait", "Freeing GFX Data", 64, 128, 64); + + gfx_free_players (); + for (i = 0; i < MAX_PLAYERS; i++) + SDL_FreeSurface (mw_plgfx[i]); +}; + + +void +mw_wait_for_connect () +{ + menu_displaytext ("Please Wait", "Wait For connection", 64, 128, 64); +}; + + +void +mw_draw_status () +{ + int pnr, + x, + x1, + y, + px; + char text[255]; + SDL_Rect src, + dest; + + /* Draw Player List */ + /* 1. the head */ + px = gfx.res.x / 320; + x = (gfx.res.x - px * 320) / 2; + + for (pnr = 0; pnr < px; pnr++) + draw_text (pnr * 320 + x, 24, " Wins Points", 1); + + /* 2. the names with points */ + for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) { + redraw_logo (x1 * 320, y - 4, 320, 32); + if (bman.players[pnr].gfx_nr != -1 && PS_IS_used (bman.players[pnr].state)) { + src.x = 3 * bman.players[pnr].gfx->smal_size.x; + src.y = 0; + src.w = dest.w = bman.players[pnr].gfx->smal_size.x; + src.h = dest.h = bman.players[pnr].gfx->smal_size.y; + + dest.x = x1 * 320; + dest.y = y - 4; + + SDL_BlitSurface (bman.players[pnr].gfx->smal_image, &src, gfx.screen, &dest); + } + + sprintf (text, " %10s %2d %2d", bman.players[pnr].name, bman.players[pnr].wins, + bman.players[pnr].points); + if (bman.lastwinner == pnr) + draw_text (x + x1 * 320, y, text, 1); + else + draw_text (x + x1 * 320, y, text, 0); + x1++; + if (x1 >= px) { + y += 32; + x1 = 0; + } + if (pnr == MAX_PLAYERS - 1 && x1 != 0) + y += 32; + } + + mw_y = y; +}; + + +void +mw_draw_gfxselect (int selgfx) +{ + int i, + select, + xstep; + SDL_Rect src, + dest; + + xstep = gfx.res.x / MAX_PLAYERS; + + if (bman.players[bman.p_nr].gfx_nr == -1) { + /* draw selection */ + for (i = 0; i < MAX_PLAYERS; i++) { + dest.w = src.w = gfx.players[i].size.x; + dest.h = src.h = gfx.players[i].size.y; + + dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); + dest.y = mw_y + 8; + + redraw_logo (dest.x, dest.y, dest.w, dest.h); + + src.x = 3 * gfx.players[i].size.x; + if (i == selgfx) + src.y = mw_frame * gfx.players[i].size.y; + else + src.y = 0; + + MW_IS_GFX_SELECT (i, select); + + if (select >= MAX_PLAYERS || select < 0) { + /* this player have not been selected */ + if (selgfx == i) { + mw_frameto--; + + if (mw_frameto <= 0 || mw_frameto > ANI_PLAYERTIMEOUT) { + mw_frameto = ANI_PLAYERTIMEOUT; + mw_frame++; + } + + if (mw_frame >= gfx.players[i].ani.frames || mw_frame < 0) { + mw_frameto = ANI_PLAYERTIMEOUT; + mw_frame = 0; + } + + SDL_BlitSurface (gfx.players[i].ani.image, &src, gfx.screen, &dest); + } + else + SDL_BlitSurface (mw_plgfx[i], &src, gfx.screen, &dest); + } + } + } + else { + /* draw selected players */ + for (i = 0; i < MAX_PLAYERS; i++) { + dest.w = src.w = gfx.players[i].size.x; + dest.h = src.h = gfx.players[i].size.y; + + dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); + dest.y = mw_y + 8; + + redraw_logo (dest.x, dest.y, dest.w, dest.h); + + src.x = 3 * gfx.players[i].size.x; + if (i == selgfx) + src.y = mw_frame * gfx.players[i].size.y; + else + src.y = 0; + + MW_IS_GFX_SELECT (i, select); + + if (select < MAX_PLAYERS && select >= 0) { + /* this player have been selected */ + if (bman.players[bman.p_nr].gfx_nr == i) + SDL_BlitSurface (gfx.players[i].ani.image, &src, gfx.screen, &dest); + else + SDL_BlitSurface (mw_plgfx[i], &src, gfx.screen, &dest); + } + } + } + + mw_y += 8 + gfx.players[0].size.y; +} + + +void +mw_draw_chat () +{ + if (chat.visible == 0) { + chat_show (16, mw_y + 16, gfx.res.x - 16, gfx.res.y - 32); + chat_addline ("Press [STRG] or [CTRL] - to select a player"); + if (GT_MP_PTPM) + chat_addline ("F4 - to start the game"); + } +}; + + +/* the loop itself */ +void +wait_for_players () +{ + SDL_Event event; + Uint8 *keys; + Uint32 timeloop1 = SDL_GetTicks (); + int done = 0, + ready = 0, + keypressed = 0, + i, + selgfx = 0; + + mw_init (); + draw_logo (); + + while (!done && bman.state == GS_wait) { + + i = bman.p_nr; + if (network_loop () < 0) { + done = 1; + bman.p_nr = -1; + } + if (i != bman.p_nr) /* clean the screen after we got our playernumber */ + draw_logo (); + + /* check if all players are ready, and more as one player is connected */ + if (GT_MP_PTPM) + for (ready = 0, i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_playing (bman.players[i].state)) + ready++; + if (ready > 1) + ready = 1; + else + ready = 0; + + /* draw the screeninformations */ + if (bman.p_nr == -1) /* we have no connect yet */ + mw_wait_for_connect (); + else { /* we have a connect so draw status */ + mw_draw_status (); + mw_draw_gfxselect (selgfx); + mw_draw_chat (); + } + + SDL_Flip (gfx.screen); + + /* do the keyboard handling */ + if (SDL_PollEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + bman.state = GS_quit; + bman.p_nr = -1; + done = 1; + } + + keys = SDL_GetKeyState (NULL); + + if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + /* we want to quit */ + done = 1; + bman.p_nr = -1; + keypressed = 1; + bman.state = GS_startup; + } + + if (bman.p_nr != -1) { + + if (keys[SDLK_DOWN] && (!keypressed)) { + } + + if (keys[SDLK_UP] && (!keypressed)) { + } + + if (keys[SDLK_LEFT] && (!keypressed) && bman.players[bman.p_nr].gfx_nr == -1) { + i = 0; + while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { + selgfx--; + if (selgfx < 0) + selgfx = MAX_PLAYERS - 1; + MW_IS_GFX_SELECT (selgfx, i); + } + } + + if (keys[SDLK_RIGHT] && (!keypressed) && bman.players[bman.p_nr].gfx_nr == -1) { + i = 0; + while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { + selgfx++; + if (selgfx >= MAX_PLAYERS) + selgfx = 0; + MW_IS_GFX_SELECT (selgfx, i); + } + } + + /* just make sure this player is not selected twice */ + if (bman.players[bman.p_nr].gfx_nr == -1) { + MW_IS_GFX_SELECT (selgfx, i); + while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { + selgfx++; + if (selgfx >= MAX_PLAYERS) + selgfx = 0; + MW_IS_GFX_SELECT (selgfx, i); + } + } + + if ((keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed)) { + if (bman.players[bman.p_nr].gfx_nr == -1) { + /* select player */ + bman.players[bman.p_nr].gfx_nr = selgfx; + } + else { + /* deselect player */ + bman.players[bman.p_nr].gfx_nr = -1; + } + net_change_playerid (bman.p_nr, 1); + } + + if ((GT_MP_PTPM) && ready && keys[SDLK_F4] && (!keypressed)) { + done = 1; + } + + chat_loop (&event); + } + + if (event.type == SDL_KEYUP) + keypressed = 0; + else if (event.type == SDL_KEYDOWN) + keypressed = 1; + + /* calculate time sync. */ + s_delay (1000); + timeloop1 = SDL_GetTicks (); + while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < 20) { + s_delay (timeloop1 - timestamp - 1); + timeloop1 = SDL_GetTicks (); + } + timestamp = timeloop1; + } + + mw_shutdown (); +}; diff --git a/src/netmenu.c b/src/netmenu.c new file mode 100644 index 0000000..54e929b --- /dev/null +++ b/src/netmenu.c @@ -0,0 +1,243 @@ +/* network menu */ + +#include "bomberclone.h" +#include "network.h" +#include "packets.h" +#include "gamesrv.h" +#include "gfx.h" + +extern int UpdateRects_nr; + + +void +networkmenu_joingame () +{ + int i; + gamesrv_getserver(); + for (i = 0; bman.servername[i] != 0; i++) + if (bman.servername[i] == ' ') + bman.servername[i] = ':'; + + + /* connect if we have an Servername */ +if (bman.servername[0] != 0) { + bman.sock = -1; + bman.gametype = GT_multi; + bman.multitype = MT_ptps; + join_multiplayer_game (); + bman.servername[0] = 0; +} +}; + +void +netmenu () +{ + int menuselect = 0; + _menu menu[] = { + {0, "Join A Netgame"}, + {1, "Create A New Netgame"}, + {2, "Options"}, + {3, "Return To Main Menu"}, + {-1, ""} + }; + + if (bman.gamename[0] == 0) + sprintf (bman.gamename, "%s's Game", bman.playername); + + while (menuselect != -1 && bman.state != GS_quit) { + menuselect = menu_loop ("Multiplayer", menu, menuselect); + switch (menuselect) { + case (0): // Join a Game + networkmenu_joingame (); + break; + case (1): // Create a new Game + bman.sock = -1; + bman.gametype = GT_multi; + bman.multitype = MT_ptpm; + host_multiplayer_game (); + break; + case (2): // Options + networkmenu_options (); + break; + case (3): + menuselect = -1; + break; + } + } +} + +void +networkmenu_options () +{ + int menuselect = 0; + char text[255]; + _menu menu[] = { + {0, "Game Name:"}, + {1, "Max Players:"}, + {2, "Network"}, + {3, "Notify Masterserver"}, + {4, "Masterserver"}, + {5, "Return To Multiplayer Menu"}, + {-1, ""} + }; + + + while (menuselect != -1 && bman.state != GS_quit) { + + sprintf (menu[0].text, "Gamename: %s", bman.gamename); + sprintf (menu[1].text, "Max Players: %d/%d", bman.maxplayer, MAX_PLAYERS); + + if (bman.net_ai_family == PF_INET) + sprintf (menu[2].text, "Network: IPv4"); + else + sprintf (menu[2].text, "Network: IPv6"); + + if (bman.notifygamemaster) + sprintf (menu[3].text, "Notify MasterServer: Yes"); + else + sprintf (menu[3].text, "Notify MasterServer: No"); + + sprintf (menu[4].text, "MasterServer %s", bman.gamemaster); + + menuselect = menu_loop ("Multiplayer Options", menu, menuselect); + + switch (menuselect) { + + case (0): // change the game name + menu_get_text ("Name of the Game:", bman.gamename, 32); + break; + + case (1): // Max Number of Players + sprintf (text, "%d", bman.maxplayer); + menu_get_text ("Max Players", text, 2); + bman.maxplayer = atoi (text); + if (bman.maxplayer > MAX_PLAYERS) + bman.maxplayer = MAX_PLAYERS; + if (bman.maxplayer < 2) + bman.maxplayer = 2; + break; + + case (2): +#ifndef _win32 + if (bman.net_ai_family == PF_INET) + bman.net_ai_family = PF_INET6; + else + bman.net_ai_family = PF_INET; +#endif + break; + + case (3): // Change the Notification + if (bman.notifygamemaster) + bman.notifygamemaster = 0; + else + bman.notifygamemaster = 1; + break; + + case (4): // Masterserver Address + menu_get_text ("Address of the MasterServer", bman.gamemaster, + LEN_SERVERNAME + LEN_PORT + 2); + break; + + case (5): + menuselect = -1; + break; + } + } +}; + + +void +multiplayer_firstrun () +{ + int i; + /* + reset some gamedata + */ + bman.p_nr = -1; + bman.state = GS_wait; + + for (i = 0; i < MAX_PLAYERS; i++) { + bman.players[i].name[0] = 0; + bman.players[i].gfx_nr = -1; + bman.players[i].gfx = NULL; + } + + /* + init the network + */ + if (network_init () < 0) { + d_printf ("network_init () FAILED\n"); + return; + } +}; + + +/* + We will host a network game +*/ +void +host_multiplayer_game () +{ + multiplayer_firstrun (); + + while (bman.state != GS_startup && bman.state != GS_quit) { + /* check players and in_pl lists */ + wait_for_players (); + + if (bman.p_nr != -1) { + bman.state = GS_update; + net_send_servermode (); + gfx_game_init (); + net_new_gamedata (); + + if (bman.state == GS_ready || bman.state == GS_running) { + net_send_servermode (); + + game_loop (); + if (bman.state == GS_running) + bman.state = GS_wait; + + bman.lastwinner = -1; + + game_end (); + + net_send_servermode (); + net_send_players (); + } + gfx_game_shutdown (); + } + } + + network_shutdown (); +}; + + + +/* + We will join a network game +*/ +void +join_multiplayer_game () +{ + multiplayer_firstrun (); + + while (bman.state != GS_startup && bman.state != GS_quit) { + wait_for_players (); + + if (bman.p_nr != -1 && (GS_WAITRUNNING || bman.state == GS_update)) { + gfx_game_init (); + + bman.state = GS_update; + net_new_gamedata (); + + if (bman.state == GS_ready || bman.state == GS_running) + game_loop (); + + gfx_game_shutdown (); + } + else + bman.state = GS_startup; + } + + network_shutdown (); +}; diff --git a/src/network.c b/src/network.c new file mode 100644 index 0000000..7c195ca --- /dev/null +++ b/src/network.c @@ -0,0 +1,710 @@ +/* + network routines. +*/ + +#include "bomberclone.h" +#include "network.h" +#include "gamesrv.h" +#include "packets.h" +#include "gfx.h" + +int _net_to_2sec = 0; +Uint32 _net_to_timestamp = 0; + +int +network_server_port (char *server, char *host, int hostlen, char *port, int portlen) +{ + char *pos, + *pos2; + + if (host == NULL) + return -1; + + pos2 = pos = strchr (server, ':'); + + if (pos != NULL) + while (pos2 != NULL) { + pos = pos2; + pos2 = strchr (pos + 1, ':'); + } + + if (pos != NULL) { + // : für Portangabe gefunden + if (pos - server < hostlen) { + strncpy (host, server, pos - server); + host[pos - server] = 0; + if (pos[1] == 0) + sprintf (port, "11000"); + else + strcpy (port, pos + 1); + } + else { + return -1; + } + } + else { + // Portangabe wurde nicht gefunden und wird auf 0 gesetzt + strncpy (host, server, hostlen); + sprintf (port, "11000"); + } + + return 0; +}; + + +/* + try to work better with the network packet option +*/ +void +net_dyn_pkgoption () +{ + if (_net_to_2sec > DYN_PKG_MAX_MISSING) { + if (bman.net_pkgsend_set < 10) { + bman.net_pkgsend_set++; + d_printf ("bman.netpkgsend is set to %d\n", bman.net_pkgsend_set); + } + else + d_printf ("WARNING: bman.netpkgsend is already at 10\n"); + _net_to_2sec = 0; + _net_to_timestamp = timestamp; + } + + if ((timestamp - _net_to_timestamp > 2000) && _net_to_2sec == 0) { + if (bman.net_pkgsend_set > 2) { + bman.net_pkgsend_set--; + d_printf ("bman.netpkgsend is set to %d\n", bman.net_pkgsend_set); + } + _net_to_2sec = 0; + _net_to_timestamp = timestamp; + } +}; + + + + +/* + setup everything for the network loop +*/ +int +network_init () +{ + int i; +/* + we need it for the windows winsock +*/ +#ifdef _WIN32 + WSADATA wsaData; + + if (WSAStartup (MAKEWORD (1, 1), &wsaData) != 0) { + d_printf ("WSAStartup failed.\n"); + exit (1); + } +#endif + + bman.sock = -1; + bman.p_nr = -1; + + timestamp = SDL_GetTicks (); + + // reset playernumber and number of connected players + for (i = 0; i < MAX_PLAYERS; i++) { + bman.players[i].net.addr.host[0] = 0; + bman.players[i].net.addr.port[0] = 0; + bman.players[i].name[0] = 0; + bman.players[i].gfx_nr = -1; + bman.players[i].net.timestamp = timestamp; + bman.players[i].points = 0; + bman.players[i].wins = 0; + bman.players[i].net.pingreq = 20; + bman.players[i].net.pingack = 22; + bman.players[i].state = 0; + } + + bman.lastwinner = -1; + bman.players_nr_s = 1; + + // start the udp server + bman.sock = udp_server (bman.port, bman.net_ai_family); + + if (bman.sock < 0) { +#ifdef _WIN32 + WSACleanup (); +#endif + return -1; + } + + // we have got out socket.. so now allocate the memory for the resend_cache + resend_cache.data = (char *) malloc (PKG_RESENDCACHE_SIZE); + resend_cache.fill = 0; + + // if we are the server set up my data + if (GT_MP_PTPM) { + strncpy (bman.players[0].name, bman.playername, LEN_PLAYERNAME); + bman.p_nr = 0; + bman.players[0].state = PSF_used; + if (bman.notifygamemaster) + gamesrv_sendmode (bman.maxplayer, 1); + } + + // if client send Data to the server + if (GT_MP_PTPS) { + network_server_port (bman.servername, bman.players[0].net.addr.host, + LEN_SERVERNAME, bman.players[0].net.addr.port, LEN_PORT); + + d_printf ("Connect To: %s[:%s]\n", bman.players[0].net.addr.host, + bman.players[0].net.addr.port); + + dns_filladdr (bman.players[0].net.addr.host, LEN_SERVERNAME, bman.players[0].net.addr.port, + LEN_PORT, bman.net_ai_family, &bman.players[0].net.addr.sAddr); + bman.players[0].net.addr.port[0] = bman.players[0].net.addr.host[0] = 0; + dns_filladdr (bman.players[0].net.addr.host, LEN_SERVERNAME, bman.players[0].net.addr.port, + LEN_PORT, bman.net_ai_family, &bman.players[0].net.addr.sAddr); + send_playerid (&bman.players[0].net.addr, bman.playername, NULL, NULL, -1, -1); + } + + return 0; +}; + + +/* +shutdown the network part +*/ +void +network_shutdown () +{ + int i; + + if (GT_MP_PTPM) { + for (i = 1; i < MAX_PLAYERS; i++) + if (bman.players[i].net.addr.host[0] != 0) + send_quit (&bman.players[i].net.addr, NULL, NULL); + if (bman.notifygamemaster) + gamesrv_quit (); + } + else if (bman.players[0].net.addr.host[0] != 0) + send_quit (&bman.players[0].net.addr, NULL, NULL); + + udp_close (bman.sock); + + if (resend_cache.data != NULL) + free (resend_cache.data); + + resend_cache.data = NULL; + resend_cache.fill = -1; + + bman.p_nr = -1; + +#ifdef _WIN32 + WSACleanup (); +#endif +}; + + +int +net_check_timeout (int pl_nr) +{ + int timeout = UDP_TIMEOUT; + + if ((bman.players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net) + && timestamp - bman.players[pl_nr].net.timestamp > timeout + && bman.players[pl_nr].net.pingreq != bman.players[pl_nr].net.pingack) { + d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr, + bman.players[pl_nr].net.pingack, bman.players[pl_nr].net.pingreq, + timestamp - bman.players[pl_nr].net.timestamp); + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingack = bman.players[pl_nr].net.pingreq; + send_ping (&bman.players[pl_nr].net.addr, bman.players[pl_nr].net.pingack + 100, + PKG_pingreq); + } + if ((bman.players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net) + && timestamp - bman.players[pl_nr].net.timestamp > timeout + && bman.players[pl_nr].net.pingreq == bman.players[pl_nr].net.pingack) { + d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr, + bman.players[pl_nr].net.pingack, bman.players[pl_nr].net.pingreq, + timestamp - bman.players[pl_nr].net.timestamp); + return 1; + } + return 0; +}; + + + +/* + Read data from the network and work with it +*/ +int +network_loop () +{ + char data[MAX_UDPDATA]; + struct pkg *packet = (struct pkg *) data; + int inlen, + i; + + _net_addr addr; + + if (bman.state != GS_running && bman.state != GS_ready) + timestamp = SDL_GetTicks (); + + /* + as long as we get any new data, work with them + */ + inlen = udp_get (bman.sock, data, MAX_UDPDATA, &addr.sAddr, bman.net_ai_family); + addr.port[0] = addr.host[0] = 0; + if (inlen > 0) + dns_filladdr (addr.host, LEN_SERVERNAME, addr.port, LEN_PORT, bman.net_ai_family, + &addr.sAddr); + + while (inlen > 0) { + + do_pkg (packet, &addr); + + // printf ("Network : inlen (%d) typ (%d) Size (%d)\n", inlen, packet->typ, pkglen); + inlen = udp_get (bman.sock, data, MAX_UDPDATA, &addr.sAddr, bman.net_ai_family); + addr.port[0] = addr.host[0] = 0; + if (inlen > 0) + dns_filladdr (addr.host, LEN_SERVERNAME, addr.port, LEN_PORT, bman.net_ai_family, + &addr.sAddr); + } + + /* + check here for old connections who aren't answering + */ + if (bman.state == GS_wait || bman.state == GS_ready || bman.state == GS_running) { + if (GT_MP_PTPS) { + if (net_check_timeout (0)) { + d_printf ("Server Timed Out\n"); + bman.state = GS_startup; + } + } + else if (GT_MP_PTPM) { + for (i = 1; i < MAX_PLAYERS; i++) + if (net_check_timeout (i)) { + d_printf ("Player %d Timed Out\n", i); + net_delplayer (i); + } + } + } + + /* + resend_cache.... + */ + rscache_loop (); + + /* + dynamic calibration of the network traffic option + */ + net_dyn_pkgoption (); + + /* what we need to do for the network packet send control */ + if (bman.net_pkgsend_to <= 0 || bman.net_pkgsend_to > bman.net_pkgsend_set) + bman.net_pkgsend_to = bman.net_pkgsend_set; + + bman.net_pkgsend_to--; + + return 0; +}; + + +/* + this is needed to draw the whole uppdate of everything +*/ +void +draw_netupdatestate () +{ + char text[255]; + int y = 0, + i; + SDL_Rect src, + dest; + + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state)) { + y += 48; + redraw_logo (0, y, gfx.res.x, y + 48); + + if (bman.players[i].gfx_nr != -1) { + dest.w = src.w = bman.players[i].gfx->smal_size.x; + dest.h = src.h = bman.players[i].gfx->smal_size.y; + src.x = bman.players[i].gfx->smal_size.x * down; + src.y = 0; + + dest.x = 50; + dest.y = y; + + SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest); + gfx_AddUpdateRect (dest.x, dest.y, gfx.res.x - dest.x, dest.h); + } + + if (bman.players[i].net.net_istep == 0) + sprintf (text, "%s - State : READY", bman.players[i].name); + else + sprintf (text, "%s - State : DOWNLOAD", bman.players[i].name); + draw_text (70, y, text, 1); + + text[0] = 0; + if (bman.players[i].net.net_istep == 2) + sprintf (text, "Getting Field Data %d of %d.", bman.players[i].net.net_status, + bman.fieldsize.x); + + if (bman.players[i].net.net_istep == 1) + sprintf (text, "Getting Player Data %d of %d.", bman.players[i].net.net_status, + MAX_PLAYERS); + + draw_text (70, y + 16, text, 1); + } + return; +} + +/* + used to update settings at startup +*/ +void +net_change_playerid (int pl_nr, unsigned char senddata) +{ + int i; + + if (GT_MP_PTPM) { + /* + Send to all connected clients the update + */ + for (i = 1; i < MAX_PLAYERS; i++) + if (bman.players[i].net.addr.host[0] != 0) + send_playerid (&bman.players[i].net.addr, bman.players[pl_nr].name, + bman.players[pl_nr].net.addr.host, bman.players[pl_nr].net.addr.port, + pl_nr, bman.players[pl_nr].gfx_nr); + } + else { + /* + Send only to the Server the update and only if in_nr == bman.in_nr + */ + if (pl_nr == bman.p_nr && senddata) + send_playerid (&bman.players[0].net.addr, bman.players[pl_nr].name, + bman.players[pl_nr].net.addr.host, bman.players[pl_nr].net.addr.port, + pl_nr, bman.players[pl_nr].gfx_nr); + } + + player_set_gfx (&bman.players[pl_nr], bman.players[pl_nr].gfx_nr); +}; + + +/* + sets up everything for the network game.. + on servers the game field will be created and the clients will wait for the game data + within the network loop +*/ +void +net_new_gamedata () +{ + int done = 0, + keypressed = 0, + x, + y, + p, + i, + net_istep; // network init step + SDL_Event event; + Uint8 *keys; + Uint32 downtimestamp = 0; + + multi_new_game (); // we do it to for the clients 'cause we need to reset the clients + draw_logo (); + + if (GT_MP_PTPM) + draw_text (100, 0, "Waiting for the Clients", 1); + else + draw_text (100, 0, "Downloading Data", 1); + + SDL_Flip (gfx.screen); + + /* + prepare everything for the loop + */ + for (x = 0; x < MAX_PLAYERS; x++) { + bman.players[x].net.timestamp = 0; + bman.players[x].net.net_status = -1; + bman.players[x].net.net_istep = 2; + } + + y = -1; + if (GT_MP_PTPM) + net_istep = 0; + else + net_istep = 2; + + while (!done && bman.state == GS_update) { + /* the network thing */ + + network_loop (); + + /* if PTPM check if all players are ready */ + if (GT_MP_PTPM) { + for (p = 1, i = 1; p < MAX_PLAYERS; p++) + if (PS_IS_playing (bman.players[p].state) && bman.players[p].net.net_istep != 0) + i = 0; + if (i == 1) { /* all players are ready */ + done = 1; + bman.state = GS_ready; + } + } + + /* if PTPS get all data */ + if (GT_MP_PTPS) { + if (net_istep == 2) { + if ((y < bman.fieldsize.y - 1 && y == bman.players[bman.p_nr].net.net_status) + || y == -1) { + /* send field data req */ + y++; + downtimestamp = timestamp; + send_getfield (&bman.players[0].net.addr, y); + } + else if (y < bman.fieldsize.y && y != bman.players[bman.p_nr].net.net_status + && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { + /* we have got no field data */ + y--; + } + else if (y == bman.fieldsize.y - 1 && bman.players[bman.p_nr].net.net_status == y) { + /* we have got all field data */ + y = -1; + bman.players[bman.p_nr].net.net_istep = --net_istep; + bman.players[bman.p_nr].net.net_status = -1; + } + } + + if (net_istep == 1) { + if ((y < MAX_PLAYERS - 1 && y == bman.players[bman.p_nr].net.net_status) || y == -1) { + /* send player date req */ + y++; + downtimestamp = timestamp; + send_getplayerdata (&bman.players[0].net.addr, y); + } + if (y < MAX_PLAYERS && y != bman.players[bman.p_nr].net.net_status && y >= 0 + && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { + /* we have got no player data */ + y--; + } + if (y == MAX_PLAYERS - 1 && bman.players[bman.p_nr].net.net_status == y) { + /* we have got all playerdata */ + y = -1; + bman.players[bman.p_nr].net.net_istep = --net_istep; + bman.players[bman.p_nr].net.net_status = -1; + downtimestamp = timestamp; + send_playerstatus (&bman.players[0].net.addr, bman.p_nr, 0, 0); + } + } + if (net_istep == 0 && bman.players[bman.p_nr].net.net_status == -1 + && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { + /* server did not send informations back */ + downtimestamp = timestamp; + send_playerstatus (&bman.players[0].net.addr, bman.p_nr, 0, 0); + } + } + + /* do the grafik work */ + draw_netupdatestate (); + SDL_Flip (gfx.screen); + + if (SDL_PollEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + bman.state = GS_quit; + bman.p_nr = -1; + done = 1; + } + + keys = SDL_GetKeyState (NULL); + + if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + done = 1; + bman.p_nr = -1; + keypressed = 1; + bman.state = GS_startup; + } + + if (event.type == SDL_KEYUP) + keypressed = 0; + + timestamp = SDL_GetTicks (); // needed for time sync. + SDL_Delay (1); // we don't need here anything better + + /* player is only watching so just go after we have got everything + go to show the field */ + if (bman.state == GS_update && net_istep == 0 && bman.players[bman.p_nr].gfx_nr == -1) { + done = 1; + bman.state = GS_running; + } + } +}; + + +void +net_game_send_player (int p_nr) +{ + int p; + + if (GT_MP_PTPM) { + for (p = 0; p < MAX_PLAYERS; p++) + if (PS_IS_used (bman.players[p].state) && p != bman.p_nr) + send_playerdata (&bman.players[p].net.addr, p_nr, &bman.players[p_nr]); + } + else if (p_nr == bman.p_nr) { + for (p = 0; p < MAX_PLAYERS; p++) + if (PS_IS_used (bman.players[p].state) && p != bman.p_nr) + send_playerdata (&bman.players[p].net.addr, p_nr, &bman.players[p_nr]); + } +}; + + +void +net_game_send_playermove (int p_nr) +{ + int p; + + for (p = 0; p < MAX_PLAYERS; p++) + if (PS_IS_used (bman.players[p].state) && p != bman.p_nr) + send_playermove (&bman.players[p].net.addr, p_nr, &bman.players[p_nr]); +}; + + +void +net_game_send_bomb (int p, int b) +{ + int pl; + + /* check if we are slave and send something else as dropping a bomb */ + if (GT_MP_PTPS && bman.players[p].bombs[b].state != BS_ticking) + return; + + d_printf ("Send BombData %d, %d\n", p, b); + + if (p < 0 || p >= MAX_PLAYERS || b < 0 || b >= MAX_BOMBS) + return; + + for (pl = 0; pl < MAX_PLAYERS; pl++) + if (PS_IS_used (bman.players[pl].state) && pl != bman.p_nr) + send_bombdata (&bman.players[pl].net.addr, p, b, &bman.players[p].bombs[b]); +}; + + +void +net_game_send_field (int x, int y) +{ + int pl; + + d_printf ("Send FieldData %d, %d\n", x, y); + + if (x < 0 || x >= MAX_FIELDSIZE_X || y < 0 || y >= MAX_FIELDSIZE_Y) + return; + + for (pl = 0; pl < MAX_PLAYERS; pl++) + if (PS_IS_used (bman.players[pl].state) && pl != bman.p_nr) + send_field (&bman.players[pl].net.addr, x, y, &bman.field[x][y]); +}; + + + +void +net_delplayer (int pl_nr) +{ + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + int i,j=1; + + d_printf ("net_delplayer (%d)\n", pl_nr); + + if (pl_nr == bman.p_nr) { + /* we're not wanted */ + network_shutdown (); + bman.state = GS_startup; + } + else { + strncpy (host, bman.players[pl_nr].net.addr.host, LEN_SERVERNAME); + strncpy (port, bman.players[pl_nr].net.addr.port, LEN_PORT); + + bman.players[pl_nr].state &= (0xFF - (PSF_used + PSF_alife)); // Delete the used flag + bman.players[pl_nr].net.net_istep = 0; // needed for disconnect during the update + bman.players_nr_s--; + bman.players[pl_nr].gfx_nr = -1; + + if (GT_MP_PTPM && (GS_WAITRUNNING || bman.state == GS_update)) + for (i = 1; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state)) { + send_quit (&bman.players[i].net.addr, host, port);j++;} + gamesrv_sendmode(bman.maxplayer,j); + } + + if (GT_MP_PTPM && bman.notifygamemaster) + gamesrv_sendmode (bman.maxplayer, bman.players_nr_s); +}; + + +void +net_game_fillsockaddr () +{ + /* Update all sockaddr before the game starts */ + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + if (bman.players[i].net.addr.host[0] != 0 && bman.players[i].net.addr.host[0] != 0) + dns_filladdr (bman.players[i].net.addr.host, LEN_SERVERNAME, + bman.players[i].net.addr.port, LEN_PORT, bman.net_ai_family, + &bman.players[i].net.addr.sAddr); +}; + + +void +net_send_servermode () +{ + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state) && i != bman.p_nr) + send_servermode (&bman.players[i].net.addr, i); + + if (GT_MP_PTPM && bman.notifygamemaster) /* send notification the the gamemaster */ + gamesrv_sendmode (bman.maxplayer, bman.players_nr_s); + +}; + + +/* sends to everyone an up to date playerlist*/ +void +net_send_players () +{ + int i, + j; + + for (j = 0; j < MAX_PLAYERS; j++) + if (PS_IS_used (bman.players[j].state) && j != bman.p_nr) + for (i = 0; i < MAX_PLAYERS; i++) + send_playerid (&bman.players[j].net.addr, bman.players[i].name, + bman.players[i].net.addr.host, bman.players[i].net.addr.port, i, + bman.players[i].gfx_nr); + +}; + + + +void +net_send_chat (char *text, signed char notigamesrv) +{ + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state) && i != bman.p_nr) + send_chat (&bman.players[i].net.addr, text); + + if (GT_MP_PTPM && bman.notifygamemaster && notigamesrv == 1) /* send notification the the gamemaster */ + gamesrv_sendchat (text); +}; + + +void net_game_send_ill (int p_nr) { + int i; + + d_printf ("net_game_send_ill (%d)\n", p_nr); + + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_used (bman.players[i].state) && i != bman.p_nr) + send_ill (&bman.players[i].net.addr, p_nr, &bman.players[p_nr]); +}; + diff --git a/src/network.h b/src/network.h new file mode 100644 index 0000000..bfdf2f5 --- /dev/null +++ b/src/network.h @@ -0,0 +1,91 @@ +/* +network.h file... for everything what have to do with the network stuff +*/ + +#ifndef _NETWORK_H_ +#define _NETWORK_H_ + +#define MAX_UDPDATA 1024 +#define DOWNLOAD_TIMEOUT 2000 +#define DYN_PKG_MAX_MISSING 4 + +#define GT_MP_PTPM (bman.multitype == MT_ptpm && bman.gametype == GT_multi) +#define GT_MP_PTPS (bman.multitype == MT_ptps && bman.gametype == GT_multi) +#define GT_MP_PTP ((bman.multitype == MT_ptps || bman.multitype == MT_ptpm) && bman.gametype == GT_multi) + +#define GS_WAITRUNNING (bman.state == GS_wait || bman.state == GS_ready || bman.state == GS_running) + +#ifdef _WIN32 +#define _sockaddr sockaddr +#else +#define _sockaddr sockaddr_in6 +#endif + +struct __net_addr { // this holds the network data + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + struct _sockaddr sAddr; +} typedef _net_addr; + + +struct __net_player { + _net_addr addr; // holds the address + int pingreq; // just to send a ping and to save the number in here + int pingack; // just to wait for an ping reply.. it will show up here + Uint32 timestamp; // time of the last incoming package + signed char net_istep; + signed char net_status; +} typedef _net_player; + + +extern int _net_to_2sec; +extern Uint32 _net_to_timestamp; + +// network menu +extern void netmenu(); +extern void networkmenu_joingame (); +extern void networkmenu_options (); +extern void join_multiplayer_game (); +extern void host_multiplayer_game (); +extern void multiplayer_firstrun (); + +// network.c +extern int network_server_port (char *server, char *host, int hostlen, char *port, int portlen); +extern void network_shutdown (); +extern int network_init (); +extern int network_loop (); +extern void net_change_playerid (int pl_nr, unsigned char senddata); +extern void net_new_gamedata (); +extern void net_game_send_player (int p_nr); +extern void net_game_send_playermove (int p_nr); +extern void net_game_send_bomb (int p, int b); +extern void net_game_send_field (int x, int y); +extern void net_game_fillsockaddr (); +extern void net_game_send_ill (int p_nr); +extern void net_delplayer (int pl_nr); +extern void draw_netupdatestate (); +extern void net_send_servermode (); +extern void net_send_players (); +extern int net_check_timeout (int pl_nr); +extern void net_dyn_pkgoption (); +extern void net_send_chat (char *text, signed char notigamesrv); + + +// multiwait.c +extern void wait_for_players (); +extern void mw_init (); +extern void mw_shutdown (); +extern void mw_draw_gfxselect (int selgfx); +extern void mw_draw_status (); +extern void mw_wait_for_connect (); +extern void mw_draw_chat (); + +// udp.c +extern char *dns_net_getip (char *host); +extern int dns_filladdr (char *host, int hostlen, char *port, int portlen, int ai_family, struct _sockaddr *sAddr); +extern int udp_get (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family); +extern int udp_server (char *port, int ai_family); +extern void udp_send (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family); +extern void udp_close (int sock); + +#endif diff --git a/src/packets.c b/src/packets.c new file mode 100644 index 0000000..0085072 --- /dev/null +++ b/src/packets.c @@ -0,0 +1,1096 @@ +/* network commands and data */ + +#include "basic.h" +#include "bomberclone.h" +#include "network.h" +#include "gamesrv.h" +#include "packets.h" +#include "chat.h" + +extern int condata[MAX_PLAYERS][MAX_PLAYERS]; +extern _point debug_field; +extern int debug_lastping; +extern void print_condata (); + +struct _resend_cache resend_cache; +struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM]; +int inpkg_index_pos = 0; + + +int +get_player_nr (char *host, char *port) +{ + int i, + res; + + for (i = 0, res = -1; (i < MAX_PLAYERS && res == -1); i++) { + if (bman.players[i].net.addr.host[0] != 0) + if ((strcmp (bman.players[i].net.addr.host, host) == 0) && + (strcmp (bman.players[i].net.addr.port, port) == 0)) + res = i; + } + return res; +} + + +void +send_error (_net_addr * addr, char *text) +{ + struct pkg_error p_err; + + d_printf ("Send Network Error : %s\n", text); + strncpy (p_err.text, text, 127); + p_err.h.typ = PKG_error; + p_err.h.flags = 0; + p_err.h.len = sizeof (struct pkg_error); + p_err.nr = 0; + + send_pkg ((struct pkg *) &p_err, addr); +}; + + +int +do_error (struct pkg_error *data, _net_addr * addr) +{ + d_printf ("Network Error : '%s'\n", data->text); + menu_displaymessage ("Network Error", data->text); + if (data->nr == 1) + return -1; + else + return 0; +}; + + +/* +update the playerinformations in the game +*/ +void +do_playerid (struct pkg_playerid *p_id, _net_addr * addr) +{ + _player *pl; + int i, + pl_nr, + j, + vma, + vmi; + char text[255]; + + sscanf (VERSION, "%d.%d", &vma, &vmi); + + pl_nr = get_player_nr (addr->host, addr->port); + if (p_id->ver_sub != SUB_VERSION || p_id->ver_major != vma || p_id->ver_minor != vmi) { + sprintf (text, "Version Error - Host/Server Version: %s.%d", VERSION, SUB_VERSION); + send_error (addr, text); + return; + } + d_printf ("do_playerid (From:%s:%s pl_nr=%d) Player(name:%s [%s:%s], pl_nr:%d)\n", addr->host, + addr->port, pl_nr, p_id->name, p_id->host, p_id->port, p_id->pl_nr); + + /* As Server/Master Only change settings, or do ignore them if we are not in GS_wait */ + if (((GT_MP_PTPM && (bman.state == GS_wait && pl_nr != -1)) || // PTPM change setting + (GT_MP_PTPS && pl_nr == 0)) && p_id->pl_nr >= 0 && p_id->pl_nr < MAX_PLAYERS) { // PTPS and information send by PTPM + + pl = &bman.players[p_id->pl_nr]; + + pl->state = p_id->state; + if (p_id->pl_nr != bman.p_nr && PS_IS_used (pl->state)) + pl->state |= PSF_net; + else + pl->state &= (0xff - PSF_net); + + player_set_gfx (pl, p_id->gfx_nr); + strncpy (pl->name, p_id->name, LEN_PLAYERNAME); + pl->net.timestamp = timestamp; + pl->net.pingreq = pl->net.pingack + 5; + + if (p_id->host[0] != 0) { + strncpy (pl->net.addr.host, p_id->host, LEN_SERVERNAME); + strncpy (pl->net.addr.port, p_id->port, LEN_PORT); + dns_filladdr (pl->net.addr.host, LEN_SERVERNAME, + pl->net.addr.port, LEN_PORT, bman.net_ai_family, &pl->net.addr.sAddr); + } + + if (GT_MP_PTPS) { + pl->points = p_id->points; + pl->wins = p_id->wins; + } + } + + /* add player into the list if there is something free */ + else if ((pl_nr == -1 || p_id->pl_nr == -1) && GS_WAITRUNNING && GT_MP_PTPM) { + + /* find free player slot */ + if (pl_nr == -1) + for (i = 0; (i < MAX_PLAYERS && PS_IS_used (bman.players[i].state)); i++); + else + i = pl_nr; + + if ((i < MAX_PLAYERS) && (i < bman.maxplayer)) { + /* free in_pl slot ... fill in data */ + pl = &bman.players[i]; + + pl->state = PSF_used + PSF_net; + if (strncmp (pl->name, p_id->name, LEN_PLAYERNAME) == 0) + d_printf ("***** Player ReJoined : Nr:[%d] Name:%10s\n", i, p_id->name); + else { + d_printf ("***** Player Added : Nr:[%d] Name:%10s\n", i, p_id->name); + pl->points = 0; + pl->wins = 0; + } + strncpy (pl->name, p_id->name, LEN_PLAYERNAME); + player_set_gfx (pl, p_id->gfx_nr); + pl->net.timestamp = timestamp; + strncpy (pl->net.addr.host, addr->host, LEN_SERVERNAME); + strncpy (pl->net.addr.port, addr->port, LEN_PORT); + dns_filladdr (pl->net.addr.host, LEN_SERVERNAME, pl->net.addr.port, LEN_PORT, + bman.net_ai_family, &pl->net.addr.sAddr); + bman.players_nr_s++; + + /* send to the new client the servermode and the complete playerlist */ + send_servermode (addr, i); + for (j = 0; j < MAX_PLAYERS; j++) + if (bman.players[j].net.addr.host[0] != 0 || bman.players[j].name[0] != 0) + send_playerid (addr, bman.players[j].name, bman.players[j].net.addr.host, + bman.players[j].net.addr.port, j, bman.players[j].gfx_nr); + + pl_nr = i; + for (j = 0, i = 0; i < bman.maxplayer; i++) + if (PS_IS_used (bman.players[i].state)) + j++; + gamesrv_sendmode (bman.maxplayer, j); + } + + else if (GS_WAITRUNNING) { + send_error (addr, "No Free Playerslot found\n"); + return; + } + + else if (!GS_WAITRUNNING) { + send_error (addr, "Game is in the wrong mode.\n"); + return; + } + } + + /* Send all connected players the new PlayerID */ + if (GS_WAITRUNNING && pl_nr >= 0 && pl_nr < MAX_PLAYERS) + net_change_playerid (pl_nr, (GT_MP_PTPM)); + + d_playerdetail ("*** PLAYER List ***"); +}; + + +void +send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport, int pl_nr, int gfx_nr) +{ + struct pkg_playerid p_id; + int vmi, + vma; + + d_printf ("send_playerid SendTo: %s:%s (Name:%16s p_nr:%d)\n", addr->host, addr->port, name, + pl_nr); + sscanf (VERSION, "%d.%d", &vma, &vmi); + + p_id.h.typ = PKG_playerid; + p_id.h.flags = PKGF_ackreq; + p_id.h.len = sizeof (struct pkg_playerid); + p_id.ver_sub = SUB_VERSION; + p_id.ver_major = vma; + p_id.ver_minor = vmi; + + strncpy (p_id.name, name, LEN_PLAYERNAME); + if (pladdr == NULL) + p_id.host[0] = 0; + else + strncpy (p_id.host, pladdr, LEN_SERVERNAME); + + if (plport == NULL) + p_id.port[0] = 0; + + else + strncpy (p_id.port, plport, LEN_PORT); + + p_id.pl_nr = pl_nr; + p_id.gfx_nr = gfx_nr; + if (pl_nr != -1) { + p_id.points = bman.players[pl_nr].points; + p_id.wins = bman.players[pl_nr].wins; + p_id.state = bman.players[pl_nr].state; + } + else { + p_id.points = 0; + p_id.wins = 0; + p_id.state = 0; + } + + send_pkg ((struct pkg *) &p_id, addr); +}; + + +void +do_servermode (struct pkg_servermode *s_mod, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + d_printf ("do_servermode (%s:%s) state = %d\n", addr->host, addr->port, s_mod->state); + + if (s_mod->pl_nr >= 0 && s_mod->pl_nr < MAX_PLAYERS) { + bman.p_nr = s_mod->pl_nr; + bman.players[bman.p_nr].state &= (0xFF - PSF_net); + strncpy (bman.players[s_mod->pl_nr].name, bman.playername, LEN_PLAYERNAME); + } + + if (s_mod->type == GT_multi) + bman.gametype = GT_multi; + else + bman.gametype = GT_single; + + bman.state = s_mod->state; + if (s_mod->multitype == MT_ptpm) + bman.multitype = MT_ptps; + + bman.players_nr_s = s_mod->players; + bman.lastwinner = s_mod->last_winner; + + if (GT_MP_PTPS) { + bman.fieldsize.x = s_mod->fieldsize_x; + bman.fieldsize.y = s_mod->fieldsize_y; + } +}; + + +void +send_servermode (_net_addr * addr, int pl_nr) +{ + struct pkg_servermode s_mod; + d_printf ("Send ServerMode\n"); + + s_mod.h.typ = PKG_servermode; + s_mod.h.len = sizeof (struct pkg_servermode); + s_mod.h.flags = PKGF_ackreq; + s_mod.type = bman.gametype; + s_mod.state = bman.state; + s_mod.multitype = bman.multitype; + s_mod.players = bman.players_nr_s; + s_mod.maxplayer = bman.maxplayer; + s_mod.pl_nr = pl_nr; + s_mod.last_winner = bman.lastwinner; + s_mod.fieldsize_x = bman.fieldsize.x; + s_mod.fieldsize_y = bman.fieldsize.y; + send_pkg ((struct pkg *) &s_mod, addr); +}; + + +void +send_field (_net_addr * addr, int x, int y, _field * field) +{ + struct pkg_field f_dat; + + d_printf ("send_field [%d,%d]\n", x, y); + + f_dat.h.typ = PKG_field; + f_dat.h.len = sizeof (struct pkg_field); + f_dat.h.flags = PKGF_ackreq; + + f_dat.x = x; + f_dat.y = y; + + if (x < 0 || x >= bman.fieldsize.x || y < 0 || y >= bman.fieldsize.y) + return; + memcpy (&f_dat.field, &bman.field[x][y], sizeof (_field)); + + send_pkg ((struct pkg *) &f_dat, addr); +}; + + +void +do_field (struct pkg_field *f_dat, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (f_dat->x < bman.fieldsize.x && f_dat->y < bman.fieldsize.y) { + memcpy (&bman.field[f_dat->x][f_dat->y], &f_dat->field, sizeof (_field)); + } + if (bman.state == GS_running) + draw_stone (f_dat->x, f_dat->y); + + if (f_dat->field.ex_nr > bman.last_ex_nr) + bman.last_ex_nr = f_dat->field.ex_nr; + + d_printf ("do_field (%d,%d) ex_nr = %d, special = %d, type = %d\n", f_dat->x, f_dat->y, + f_dat->field.ex_nr, f_dat->field.special, f_dat->field.type); +}; + + +void +do_ping (struct pkg_ping *p_dat, _net_addr * addr) +{ + int pl_nr; + pl_nr = get_player_nr (addr->host, addr->port); + + if (pl_nr == -1) /* Make sure we will never send to unknown players */ + return; + + if (p_dat->h.typ == PKG_pingack) + /* ping was an answer */ + bman.players[pl_nr].net.pingack = p_dat->data; + + else + /* send the answer */ + send_ping (addr, p_dat->data, PKG_pingack); + + d_printf ("do_ping pl_nr[%d] (%s:%s) req=%d, ack=%d, timediff=%d\n", pl_nr, addr->host, + addr->port, bman.players[pl_nr].net.pingreq, bman.players[pl_nr].net.pingack, + timestamp - bman.players[pl_nr].net.timestamp); + bman.players[pl_nr].net.timestamp = timestamp; +}; + + +void +send_ping (_net_addr * addr, int data, unsigned char typ) +{ + struct pkg_ping p_dat; + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + + if (pl_nr == -1) + return; + + p_dat.h.len = sizeof (struct pkg_ping); + p_dat.h.flags = 0; + + if (typ == PKG_pingack) { + p_dat.h.typ = typ; + p_dat.data = data; + send_pkg ((struct pkg *) &p_dat, addr); + } + + else if (typ == PKG_pingreq) { + p_dat.h.typ = typ; + p_dat.data = data; + send_pkg ((struct pkg *) &p_dat, addr); + } + + d_printf ("send_ping Player[%d] (%s:%s) req=%d, ack=%d\n", pl_nr, addr->host, addr->port, + bman.players[pl_nr].net.pingreq, bman.players[pl_nr].net.pingack); + bman.players[pl_nr].net.timestamp = timestamp; +}; + + +void +send_playerdata (_net_addr * addr, int p_nr, _player * pl) +{ + struct pkg_playerdata p_dat; + + p_dat.h.typ = PKG_playerdata; + p_dat.h.len = sizeof (struct pkg_playerdata); + + if (bman.state == GS_update) + p_dat.h.flags = 0; + else + p_dat.h.flags = PKGF_ackreq; + + p_dat.pos.x = pl->pos.x; + p_dat.pos.y = pl->pos.y; + p_dat.bombs_n = pl->bombs_n; + p_dat.d = pl->d; + p_dat.range = pl->range; + p_dat.gfx_nr = pl->gfx_nr; + p_dat.state = pl->state; + p_dat.wins = pl->wins; + p_dat.points = pl->points; + p_dat.dead_by = pl->dead_by; + p_dat.frame = pl->frame; + p_dat.p_nr = p_nr; + + send_pkg ((struct pkg *) &p_dat, addr); +}; + + +void +do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr) +{ + _player *pl; + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (p_dat->p_nr < 0 || p_dat->p_nr >= MAX_PLAYERS) + return; + + d_printf ("do_playerdata (From: %d) p_nr: %d\n", pl_nr, p_dat->p_nr); + + pl = &bman.players[p_dat->p_nr]; + player_set_gfx (pl, p_dat->gfx_nr); + + if (bman.state == GS_running && bman.p_nr != p_dat->p_nr) { + pl->points = p_dat->points; + pl->dead_by = p_dat->dead_by; + } + else if (bman.state != GS_running || bman.p_nr != p_dat->p_nr) { + pl->pos.x = p_dat->pos.x; + pl->pos.y = p_dat->pos.y; + pl->dead_by = p_dat->dead_by; + pl->points = p_dat->points; + pl->d = p_dat->d; + pl->bombs_n = p_dat->bombs_n; + pl->range = p_dat->range; + pl->frame = p_dat->frame; + pl->state = p_dat->state; + } + + if (p_dat->dead_by < 0 || p_dat->dead_by >= MAX_PLAYERS) /* set player state no matter what */ + pl->state = p_dat->state; + else { /* player died in the game */ + /* check if the player just died */ + if (PS_IS_alife (pl->state) && PS_IS_dead (p_dat->state)) { + /* player just died */ + if (p_dat->p_nr != p_dat->dead_by) { + bman.players[p_dat->dead_by].points++; + net_game_send_player (p_dat->dead_by); + } + } + pl->state = p_dat->state; + } + + /* set the state of the player */ + if (p_dat->p_nr != bman.p_nr && PS_IS_used (pl->state)) + pl->state |= PSF_net; + else + pl->state &= (0xff - PSF_net); + + if (p_dat->gfx_nr == -1) + pl->state &= (0xff - PSF_alife); + + if (bman.state == GS_update && PS_IS_used (p_dat->state)) + bman.players_nr_s++; + + if (bman.state == GS_update && bman.players[bman.p_nr].net.net_istep == 1) + bman.players[bman.p_nr].net.net_status = p_dat->p_nr; +} + + +void +send_playermove (_net_addr * addr, int p_nr, _player * pl) +{ + struct pkg_playermove p_dat; + + p_dat.h.typ = PKG_playermove; + p_dat.h.len = sizeof (struct pkg_playermove); + p_dat.h.flags = 0; + + p_dat.pos.x = pl->pos.x; + p_dat.pos.y = pl->pos.y; + p_dat.m = pl->m; + p_dat.d = pl->d; + p_dat.p_nr = p_nr; + p_dat.speed = pl->speed; + + send_pkg ((struct pkg *) &p_dat, addr); +}; + + +void +do_ill (struct pkg_ill *ill, _net_addr * addr) +{ + int pl_nr, + i; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + d_printf ("do_ill (From: %d) For Player %d\n", pl_nr, ill->pl_nr); + if (ill->pl_nr < 0 || ill->pl_nr >= MAX_PLAYERS || ill->pl_nr == bman.p_nr) + return; + + for (i = 0; i < PI_max; i++) + bman.players[ill->pl_nr].ill[i].to = ill->to[i]; +}; + + + +void +send_ill (_net_addr * addr, int p_nr, _player * pl) +{ + struct pkg_ill ill; + int i; + + ill.h.typ = PKG_ill; + ill.h.len = sizeof (struct pkg_ill); + ill.h.flags = PKGF_ackreq; + + ill.pl_nr = p_nr; + for (i = 0; i < PI_max; i++) + ill.to[i] = pl->ill[i].to; + + send_pkg ((struct pkg *) &ill, addr); +}; + + +void +do_playermove (struct pkg_playermove *p_dat, _net_addr * addr) +{ + _player *pl; + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (p_dat->p_nr == -1) + return; + + /* check if the right player is sending the information */ + pl = &bman.players[p_dat->p_nr]; + if (pl_nr != 0 && pl_nr != p_dat->p_nr) + return; + +// pl->old = pl->pos; + pl->m = p_dat->m; + pl->d = p_dat->d; + pl->speed = p_dat->speed; + pl->pos.x = p_dat->pos.x; + pl->pos.y = p_dat->pos.y; +} + + +void +do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) +{ + _bomb *bomb; + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (b_dat->p_nr >= MAX_PLAYERS || b_dat->b_nr >= MAX_BOMBS) { + d_printf ("Bomb Error\n"); + return; + } + + if (b_dat->state == BS_off) + return; // if there was a bomb let it explose don't delete the bomb + + d_printf ("do_bombdata [%d,%d] Player: %d Bomb: %d, ex_nr:%d\n", b_dat->x, b_dat->y, + b_dat->p_nr, b_dat->b_nr, b_dat->ex_nr); + + bomb = &bman.players[b_dat->p_nr].bombs[b_dat->b_nr]; + if (bomb->state == BS_exploding) { + d_printf ("do_bombdata ---> bomb is already exploding\n"); + return; + } + + if ((bomb->pos.x != b_dat->x || bomb->pos.y != b_dat->y) && bomb->state == BS_exploding + && b_dat->state != BS_exploding) + d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n"); + + bomb->pos.x = b_dat->x; + bomb->pos.y = b_dat->y; + if (bomb->state != BS_ticking) + bomb->to = b_dat->to; + bomb->r = b_dat->r; + bomb->ex_nr = b_dat->ex_nr; + bomb->state = b_dat->state; + if (bomb->state == BS_exploding) + bomb_explode (b_dat->p_nr, b_dat->b_nr); + + if (bomb->ex_nr > bman.last_ex_nr) + bman.last_ex_nr = bomb->ex_nr; +}; + + +void +send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb) +{ + struct pkg_bombdata b_dat; + + b_dat.h.typ = PKG_bombdata; + b_dat.h.len = sizeof (struct pkg_bombdata); + b_dat.x = bomb->pos.x; + b_dat.y = bomb->pos.y; + b_dat.to = bomb->to; + b_dat.r = bomb->r; + b_dat.ex_nr = bomb->ex_nr; + b_dat.state = bomb->state; + b_dat.b_nr = b; + b_dat.p_nr = p; + b_dat.h.flags = PKGF_ackreq; + + send_pkg ((struct pkg *) &b_dat, addr); +}; + + +void +send_quit (_net_addr * addr, char *plhost, char *plport) +{ + struct pkg_quit q_dat; + + d_printf ("send_quit (%s:%s) plhost (%s:%s)\n", addr->host, addr->port, plhost, plport); + + q_dat.h.typ = PKG_quit; + q_dat.h.flags = 0; + q_dat.h.len = sizeof (struct pkg_quit); + + if (plhost == NULL) { + q_dat.host[0] = 0; + q_dat.port[0] = 0; + } + + else { + strncpy (q_dat.host, plhost, LEN_SERVERNAME); + strncpy (q_dat.port, plport, LEN_PORT); + } + + send_pkg ((struct pkg *) &q_dat, addr); +}; + + +void +do_quit (struct pkg_quit *q_dat, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + d_printf ("do_quit (%s:%s) pl_nr = %d\n", addr->host, addr->port, pl_nr); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + + if (q_dat->host[0] == 0) { + /* the player who send this quit */ + net_delplayer (pl_nr); + } + + else { + pl_nr = get_player_nr (q_dat->host, q_dat->port); + if (pl_nr == -1) + return; + net_delplayer (pl_nr); + } +}; + + +void +send_getfield (_net_addr * addr, int line) +{ + struct pkg_getfield gf_dat; + + gf_dat.h.typ = PKG_getfield; + gf_dat.h.len = sizeof (struct pkg_getfield); + gf_dat.h.flags = 0; + gf_dat.line = line; + send_pkg ((struct pkg *) &gf_dat, addr); +}; + + +void +do_getfield (struct pkg_getfield *gf_dat, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (gf_dat->line < 0 || gf_dat->line >= MAX_FIELDSIZE_Y) + return; + + if (pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) { + if (pl_nr > 0 && pl_nr < MAX_PLAYERS) { + bman.players[pl_nr].net.net_status = gf_dat->line; + bman.players[pl_nr].net.net_istep = 2; + } + } + + send_fieldline (addr, gf_dat->line); +}; + + +void +send_fieldline (_net_addr * addr, int line) +{ + int i, + j; + struct pkg_fieldline f_dat; + + f_dat.h.typ = PKG_fieldline; + f_dat.h.len = sizeof (struct pkg_fieldline); + f_dat.h.flags = 0; + f_dat.line = line; + + if (line < 0 || line >= MAX_FIELDSIZE_Y) + return; + + for (i = 0; i < MAX_FIELDSIZE_X; i++) { + f_dat.type[i] = bman.field[i][line].type; + f_dat.special[i] = bman.field[i][line].special; + bman.field[i][line].frame = 0; + bman.field[i][line].frameto = 0; + bman.field[i][line].ex_nr = 0; + for (j = 0; j < 4; j++) + bman.field[i][line].ex[j] = 0; + + } + send_pkg ((struct pkg *) &f_dat, addr); +}; + + +void +do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr) +{ + int pl_nr, + i; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (pl_nr != 0) { + /* the data we have got are not from the server */ + d_printf ("do_fieldline: the data we have got are not from the server\n"); + return; + } + + if (f_dat->line < 0 || f_dat->line >= MAX_FIELDSIZE_Y) { + /* the line number is wrong */ + d_printf ("do_fieldline: the line number is not correct\n"); + return; + } + + if (bman.state == GS_update && bman.players[bman.p_nr].net.net_istep == 2) + bman.players[bman.p_nr].net.net_status = f_dat->line; + + for (i = 0; i < MAX_FIELDSIZE_X; i++) { + bman.field[i][f_dat->line].type = f_dat->type[i]; + bman.field[i][f_dat->line].special = f_dat->special[i]; + } +}; + + +void +send_getplayerdata (_net_addr * addr, int pl) +{ + struct pkg_getplayerdata gp_dat; + gp_dat.h.typ = PKG_getplayerdata; + gp_dat.h.len = sizeof (struct pkg_getplayerdata); + gp_dat.pl_nr = pl; + gp_dat.h.flags = 0; + send_pkg ((struct pkg *) &gp_dat, addr); +}; + + +void +do_getplayerdata (struct pkg_getplayerdata *gp_dat, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + if (pl_nr == -1) + return; + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + if (gp_dat->pl_nr < 0 || gp_dat->pl_nr >= MAX_PLAYERS) + return; + + if (pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) { + if (pl_nr > 0 && pl_nr < MAX_PLAYERS) { + bman.players[pl_nr].net.net_status = gp_dat->pl_nr; + bman.players[pl_nr].net.net_istep = 1; + } + } + send_playerdata (addr, gp_dat->pl_nr, &bman.players[gp_dat->pl_nr]); +}; + + +void +do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr) +{ + int pl_nr, + i; + + pl_nr = get_player_nr (addr->host, addr->port); + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + d_printf ("do_playerstatus (%s,%s)\n", addr->host, addr->port); + + if (pl_nr != 0 && !(GT_MP_PTPM)) { + /* the data we have got are not from the server */ + d_printf ("do_playerstatus: the data we have got are not from the server\n"); + return; + } + + if (stat->pl_nr < 0 || stat->pl_nr >= MAX_PLAYERS) { + /* the line number is wrong */ + d_printf ("do_playerstatus: playernumber not correct\n"); + return; + } + + bman.players[pl_nr].net.net_status = stat->status; + bman.players[pl_nr].net.net_istep = stat->net_istep; + if (GT_MP_PTPM) + for (i = 0; i < MAX_PLAYERS; i++) + if (bman.players[i].net.addr.host[0] != 0) + send_playerstatus (&bman.players[i].net.addr, stat->pl_nr, stat->net_istep, + stat->status); +}; + + +void +send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status) +{ + struct pkg_playerstatus stat; + + d_printf ("send_playerstatus (%s,%s) %d, %d, %d\n", addr->host, addr->port, pl_nr, net_istep, + status); + + stat.h.typ = PKG_playerstatus; + stat.h.flags = 0; + stat.h.len = sizeof (struct pkg_playerstatus); + stat.pl_nr = pl_nr; + stat.net_istep = net_istep; + stat.status = status; + + send_pkg ((struct pkg *) &stat, addr); +}; + + +void +do_chat (struct pkg_chat *chat_pkg, _net_addr * addr) +{ + int pl_nr; + + pl_nr = get_player_nr (addr->host, addr->port); + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + chat_addline (chat_pkg->text); + + if (GT_MP_PTPM && bman.notifygamemaster) /* send notification the the gamemaster */ + gamesrv_sendchat (chat_pkg->text); +}; + + +void +send_chat (_net_addr * addr, char *text) +{ + struct pkg_chat chat_pkg; + int i; + + chat_pkg.h.typ = PKG_chat; + chat_pkg.h.flags = 0; + chat_pkg.h.len = sizeof (struct pkg_chat); + + for (i = 0; i < sizeof (chat_pkg.text); i++) + chat_pkg.text[i] = 0; + strncpy (chat_pkg.text, text, sizeof (struct pkg_chat) - sizeof (struct pkg)); + + send_pkg ((struct pkg *) &chat_pkg, addr); +}; + + +void +send_pkgack (_net_addr * addr, unsigned char typ, short int id) +{ + struct pkg_pkgack p_ack; + + p_ack.h.typ = PKG_pkgack; + p_ack.h.flags = 0; + p_ack.h.len = sizeof (struct pkg_pkgack); + p_ack.id = id; + p_ack.typ = typ; + + send_pkg ((struct pkg *) &p_ack, addr); +}; + + +void +do_pkgack (struct pkg_pkgack *p_ack, _net_addr * addr) +{ + int pl_nr; + + d_printf ("do_pkgack (%s:%s)\n", addr->host, addr->port); + if (rscache_getpos (addr, p_ack->typ, p_ack->id) == -1) + return; + + pl_nr = get_player_nr (addr->host, addr->port); + bman.players[pl_nr].net.timestamp = timestamp; + bman.players[pl_nr].net.pingreq = bman.players[pl_nr].net.pingack + 5; + + rscache_del (); +}; + + +void +do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr) +{ + packet->data[127] = 0; + if (strstr (packet->data,"BC:BC:") == packet->data) + return; // ignore packet + chat_addline (packet->data); + net_send_chat (packet->data, 0); +}; + + +int +inpkg_check (unsigned char typ, short int id, _net_addr * addr) +{ + int i, + pos; + + /* find packet */ + for (i = 0, pos = -1; (i < PKG_IN_INDEX_NUM && pos == -1); i++) + if (strncmp (inpkg_index[i].addr.host, addr->host, LEN_SERVERNAME) == 0 && + strncmp (inpkg_index[i].addr.port, addr->port, LEN_PORT) == 0 && + inpkg_index[i].typ == typ && inpkg_index[i].id == id) + pos = i; + + if (pos == -1) { + /* packet unknown ... add to index */ + if (++inpkg_index_pos >= PKG_IN_INDEX_NUM) + inpkg_index_pos = 0; + memcpy (&inpkg_index[inpkg_index_pos].addr, addr, sizeof (_net_addr)); + inpkg_index[inpkg_index_pos].typ = typ; + inpkg_index[inpkg_index_pos].id = id; + } + + return pos; +}; + + + +void +send_pkg (struct pkg *packet, _net_addr * addr) +{ + packet->h.id = random (); + if (bman.net_ai_family != PF_INET) + packet->h.flags = packet->h.flags | PKGF_ipv6; + udp_send (bman.sock, (char *) packet, packet->h.len, &addr->sAddr, bman.net_ai_family); + + /* test if we have any important packet if so put it in the resend_cache */ + if (packet->h.flags & PKGF_ackreq) { + if (rscache_add (addr, packet) == -1) + d_printf ("resend_cache overrun.... packet throw away.\n"); + } +}; + + + +int +do_pkg (struct pkg *packet, _net_addr * addr) +{ + if ((((packet->h.flags & PKGF_ipv6) == 0 && bman.net_ai_family != PF_INET) || + ((packet->h.flags & PKGF_ipv6) != 0 && bman.net_ai_family == PF_INET)) && + packet->h.typ != PKG_bcmservchat) { + d_printf ("-----packet comes from the wrong network type\n"); + return 0; + } + + /* test if we have any important packet */ + if (packet->h.flags & PKGF_ackreq && packet->h.typ != PKG_bcmservchat) + send_pkgack (addr, packet->h.typ, packet->h.id); + + /* check the packet with the index */ + if (packet->h.typ != PKG_bcmservchat && inpkg_check (packet->h.typ, packet->h.id, addr) != -1) { + /* we have got this packet already */ + d_printf ("-----packet ignored\n"); + _net_to_2sec++; + return 0; + } + + switch (packet->h.typ) { + case (PKG_error): + if (do_error ((struct pkg_error *) packet, addr) < 0) + return -1; + break; + case (PKG_playerid): + do_playerid ((struct pkg_playerid *) packet, addr); + break; + case (PKG_servermode): + do_servermode ((struct pkg_servermode *) packet, addr); + break; + case (PKG_field): + do_field ((struct pkg_field *) packet, addr); + break; + case (PKG_pingreq): + do_ping ((struct pkg_ping *) packet, addr); + break; + case (PKG_pingack): + do_ping ((struct pkg_ping *) packet, addr); + break; + case (PKG_bombdata): + do_bombdata ((struct pkg_bombdata *) packet, addr); + break; + case (PKG_playerdata): + do_playerdata ((struct pkg_playerdata *) packet, addr); + break; + case (PKG_quit): + do_quit ((struct pkg_quit *) packet, addr); + break; + case (PKG_getfield): + do_getfield ((struct pkg_getfield *) packet, addr); + break; + case (PKG_getplayerdata): + do_getplayerdata ((struct pkg_getplayerdata *) packet, addr); + break; + case (PKG_fieldline): + do_fieldline ((struct pkg_fieldline *) packet, addr); + break; + case (PKG_playerstatus): + do_playerstatus ((struct pkg_playerstatus *) packet, addr); + break; + case (PKG_pkgack): + do_pkgack ((struct pkg_pkgack *) packet, addr); + break; + case (PKG_chat): + do_chat ((struct pkg_chat *) packet, addr); + break; + case (PKG_playermove): + do_playermove ((struct pkg_playermove *) packet, addr); + break; + case (PKG_bcmservchat): + do_bcmservchat ((struct pkg_bcmservchat *) packet, addr); + break; + case (PKG_ill): + do_ill ((struct pkg_ill *) packet, addr); + break; + default: + send_error (addr, "BomberClone: unknown data packet"); + break; + } + + return 0; +}; diff --git a/src/packets.h b/src/packets.h new file mode 100644 index 0000000..b08d769 --- /dev/null +++ b/src/packets.h @@ -0,0 +1,272 @@ +/* network packets.. */ + + +enum _network_data { + PKG_error = 0, + PKG_pingreq, + PKG_pingack, + PKG_playerid, + PKG_servermode, + PKG_quit, + PKG_field, + PKG_playerdata, + PKG_bombdata, + PKG_getfield, + PKG_getplayerdata, + PKG_fieldline, + PKG_playerstatus, + PKG_pkgack, + PKG_playermove, + PKG_chat, + PKG_ill, + + PKG_bcmservchat = 90 +}; + + +enum _pkgflags { + PKGF_ackreq = 1, + PKGF_ipv6 = 2 +}; + + +struct pkgheader { + unsigned char typ; + unsigned char flags; + short int id; + short int len; +}; + + +struct pkg { + struct pkgheader h; + char data[0]; +}; + + +struct pkg_bcmservchat { + char typ; + char data[128]; +}; + + +struct pkg_pkgack { + struct pkgheader h; + char typ; + short int id; +}; + + +struct pkg_ping { + struct pkgheader h; + int data; +}; + + +struct pkg_field { + struct pkgheader h; + unsigned char x; + unsigned char y; + _field field; +}; + + +struct pkg_error { + struct pkgheader h; + unsigned char nr; + char text[128]; +}; + + +struct pkg_servermode { + struct pkgheader h; + unsigned char type; + unsigned char state; + unsigned char multitype; + unsigned char players; + unsigned char maxplayer; + signed char last_winner; + signed char fieldsize_x; + signed char fieldsize_y; + signed char pl_nr; /* if the server sends this to a client... + it will be the clients in_nr number + (-1) for not set */ +}; + + +struct pkg_playerid { + struct pkgheader h; + char name[LEN_PLAYERNAME]; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; + signed char ver_major; // Version + signed char ver_minor; // Version + signed char ver_sub; // Version + signed char pl_nr; // Player Nummer + signed char gfx_nr; // number of the graphic + signed char state; + short int points; + short int wins; +}; + + +struct pkg_playerdata { + struct pkgheader h; + signed char p_nr; // Playernumber + short int points; // points + short int wins; // how many times we win + signed char gfx_nr; // the gfx number we want to use + _point pos; + unsigned char bombs_n; + unsigned char range; + unsigned char state; + unsigned char d; + unsigned char frame; + signed char dead_by; +}; + + +struct pkg_playermove { + struct pkgheader h; + signed char p_nr; + signed char m; + signed char d; + signed char speed; + _point pos; +}; + + +struct pkg_bombdata { + struct pkgheader h; + unsigned char p_nr; + unsigned char b_nr; + unsigned char x; + unsigned char y; + unsigned char state; + unsigned char r; + int ex_nr; + int to; +}; + + +struct pkg_quit { + struct pkgheader h; + char host[LEN_SERVERNAME]; + char port[LEN_PORT]; +}; + + +struct pkg_getfield { + struct pkgheader h; + signed char line; +}; + + +struct pkg_playerstatus { + struct pkgheader h; + signed char pl_nr; + signed char net_istep; + signed char status; +}; + + +struct pkg_fieldline { + struct pkgheader h; + signed char line; + unsigned char type[MAX_FIELDSIZE_X]; + unsigned char special[MAX_FIELDSIZE_X]; +}; + + +struct pkg_ill { + struct pkgheader h; + signed char pl_nr; + short int to[PI_max]; +}; + + +struct pkg_getplayerdata { + struct pkgheader h; + signed char pl_nr; +}; + + +struct pkg_chat { + struct pkgheader h; + char text[128]; +}; + + +struct _rscache_entry { + short int len; // size of the entry + Uint32 timestamp; // pointer to the timestamp + signed char retry; // retry's how many times we tryed this + _net_addr addr; // pointer to the address + struct pkg packet; // pointer to the packet +}; + + +struct _resend_cache { + char *data; // will hold the pointer to out cache + struct _rscache_entry *entry; // pointer to our data + int fill; // how much we have used +}; + + +struct _inpkg_index { + _net_addr addr; + unsigned char typ; + short int id; +}; + + +extern int do_error (struct pkg_error *data, _net_addr *addr); +extern void do_playerid (struct pkg_playerid *p_id, _net_addr *addr); +extern void do_servermode (struct pkg_servermode *s_mod, _net_addr *addr); +extern void do_field (struct pkg_field *f_dat, _net_addr *addr); +extern void do_ping (struct pkg_ping *p_dat, _net_addr *addr); +extern void do_playerdata (struct pkg_playerdata *p_dat, _net_addr *addr); +extern void do_playermove (struct pkg_playermove *p_dat, _net_addr *addr); +extern void do_bombdata (struct pkg_bombdata *b_dat, _net_addr *addr); +extern void do_quit (struct pkg_quit *q_dat, _net_addr *addr); +extern void do_getfield (struct pkg_getfield *gf_dat, _net_addr *addr); +extern void do_fieldline (struct pkg_fieldline *f_dat, _net_addr *addr); +extern void do_getplayerdata (struct pkg_getplayerdata *gp_dat, _net_addr *addr); +extern void do_playerstatus (struct pkg_playerstatus *gp_dat, _net_addr *addr); +extern void do_pkgack (struct pkg_pkgack *p_ack, _net_addr *addr); +extern void do_chat (struct pkg_chat *chat_pkg, _net_addr *addr); +extern int do_pkg (struct pkg *packet, _net_addr *addr); +extern void do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr *addr); +extern void do_ill (struct pkg_ill *ill_pkg, _net_addr *addr); + + +extern void send_pkg (struct pkg *packet, _net_addr *addr); +extern void send_playerid (_net_addr *addr, char *name, char *pladdr, char *plport, int p_nr, int gfx_nr); +extern void send_servermode (_net_addr *addr, int pl_nr); +extern void send_error (_net_addr *addr, char *text); +extern void send_field (_net_addr *addr, int x, int y, _field * field); +extern void send_ping (_net_addr *addr, int data, unsigned char typ); +extern void send_playerdata (_net_addr *addr, int p_nr, _player * pl); +extern void send_playermove (_net_addr *addr, int p_nr, _player * pl); +extern void send_bombdata (_net_addr *addr, int p, int b, _bomb * bomb); +extern void send_quit (_net_addr *addr, char *plhost, char *plport); +extern void send_getfield (_net_addr *addr, int line); +extern void send_fieldline (_net_addr *addr, int line); +extern void send_getplayerdata (_net_addr *addr, int pl); +extern void send_playerstatus (_net_addr *addr, int pl_nr, int net_istep, int status); +extern void send_pkgack (_net_addr *addr, unsigned char typ, short int id); +extern void send_chat (_net_addr *addr, char *text); +extern void send_ill (_net_addr *addr, int p_nr, _player *pl); + +extern int get_player_nr (char *host, char *port); +extern int inpkg_check (unsigned char typ, short int id, _net_addr *addr); + + +/* this functions will be defined in pkgcache.c */ +extern int rscache_add (_net_addr *addr, struct pkg *packet); +extern void rscache_del (); +extern int rscache_getpos (_net_addr *addr, unsigned char typ, short int id); +extern int rscache_getcurlen (); +extern void rscache_loop (); + +extern struct _resend_cache resend_cache; diff --git a/src/pkgcache.c b/src/pkgcache.c new file mode 100644 index 0000000..4f61a6d --- /dev/null +++ b/src/pkgcache.c @@ -0,0 +1,158 @@ +#include "bomberclone.h" +#include "network.h" +#include "packets.h" + +/* + set pointers at the giving pos +*/ +void +rscache_setpointer (int pos) +{ + resend_cache.entry = (struct _rscache_entry *) (((char *) resend_cache.data) + pos); +}; + + +/* + add a packet to the cache and sets the timestamp +*/ +int +rscache_add (_net_addr * addr, struct pkg *packet) +{ + int newlen; + + if (resend_cache.fill + sizeof (struct _rscache_entry) > PKG_RESENDCACHE_SIZE) + return -1; + + rscache_setpointer (resend_cache.fill); + resend_cache.entry->retry = 0; + resend_cache.entry->timestamp = timestamp; + memcpy (&resend_cache.entry->addr, addr, sizeof (_net_addr)); + memcpy (&resend_cache.entry->packet, packet, packet->h.len); + + newlen = resend_cache.fill + rscache_getcurlen (); + + resend_cache.fill = newlen; + + return 0; +}; + +/* + deletes the packet at current pointer in the cache +*/ +void +rscache_del () +{ + int len, + size; + char *pos1; + + /* check if we are able to delete */ + if ((char *) resend_cache.data > (char *) resend_cache.entry || + (char *) resend_cache.entry > (char *) resend_cache.data + resend_cache.fill || + resend_cache.fill == -1 || resend_cache.data == NULL) { + d_printf ("rscache_del: something wrong with the cache\n"); + exit (1); + return; + } + + /* newlen = size of the cacheentry we are going to delete */ + len = rscache_getcurlen (); + + if (resend_cache.fill <= len) /* something went wrong, fill is smaler as the cacheentry, delete the cache */ + resend_cache.fill = 0; + else { + pos1 = (char *) resend_cache.entry + len; + size = PKG_RESENDCACHE_SIZE - (pos1 - resend_cache.data); + + if (resend_cache.fill < PKG_RESENDCACHE_SIZE) { + memmove (resend_cache.entry, pos1, size); + resend_cache.fill = resend_cache.fill - len; + } + } +}; + +/* + get the position in the cache where our needed packet is +*/ +int +rscache_getpos (_net_addr * addr, unsigned char typ, short int id) +{ + int len, + pos, + done = 0; + + for (pos = 0; (pos < resend_cache.fill && done == 0);) { + + rscache_setpointer (pos); + + /* get size of the cacheentry */ + len = rscache_getcurlen (); + + if (strcmp (addr->host, resend_cache.entry->addr.host) == 0 && + strcmp (addr->port, resend_cache.entry->addr.port) == 0 && + typ == resend_cache.entry->packet.h.typ && id == resend_cache.entry->packet.h.id) + done = 1; /* we have found the old packet */ + else + pos = pos + len; + } + + if (done == 0) /* we have found nothing */ + return -1; + + return pos; +}; + +/* get the len of the current entry */ +int +rscache_getcurlen () +{ + int len; + + len = sizeof (struct _rscache_entry) - sizeof (struct pkg) + resend_cache.entry->packet.h.len; + + return len; +}; + + +/* + the loop for the cache.. to see what will have to be resend +*/ +void +rscache_loop () +{ + int len, + pos, + timeout = RESENDCACHE_TIMEOUT; + + for (pos = 0; pos < resend_cache.fill && pos < PKG_RESENDCACHE_SIZE && pos >= 0;) { + + rscache_setpointer (pos); + len = rscache_getcurlen (); + + if (timestamp - resend_cache.entry->timestamp >= timeout + && resend_cache.entry->retry < RESENDCACHE_RETRY) { + /* send it again */ + d_printf + ("Data Send Timeout (%s:%s) Resend now Package Fill %d, Pos %d\n", + resend_cache.entry->addr.host, resend_cache.entry->addr.port, resend_cache.fill, + pos); + udp_send (bman.sock, (char *) &resend_cache.entry->packet, + resend_cache.entry->packet.h.len, &resend_cache.entry->addr.sAddr, + bman.net_ai_family); + resend_cache.entry->timestamp = timestamp; + resend_cache.entry->retry++; + _net_to_2sec++; + } + + if (timestamp - resend_cache.entry->timestamp >= timeout + && resend_cache.entry->retry >= RESENDCACHE_RETRY) { + d_printf ("Data Send Timeout (%s:%s) Delete now Package Fill %d, Pos %d\n", + resend_cache.entry->addr.host, resend_cache.entry->addr.port, + resend_cache.fill, pos); + rscache_del (); + _net_to_2sec++; + } + else + pos = pos + len; + } +}; diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..246ae68 --- /dev/null +++ b/src/player.c @@ -0,0 +1,632 @@ +/* player.c - everything what have to do with the player */ + +#include +#include "bomberclone.h" +#include "network.h" + + +void +draw_player (_player * player) +{ + SDL_Rect src, + dest; + int i; + + dest.w = src.w = player->gfx->size.x; + dest.h = src.h = player->gfx->size.y; + + dest.x = + gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + + gfx.postab[player->pos.x & 255]; + dest.y = + gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + + gfx.postab[player->pos.y & 255]; + + src.x = player->d * player->gfx->size.x; + src.y = player->frame * player->gfx->size.y; + + SDL_BlitSurface (player->gfx->ani.image, &src, gfx.screen, &dest); + + /* if the player is ill, draw this image above him */ + if (PS_IS_alife (player->state)) { + for (i = PI_max - 1; (i >= 0) && (player->ill[i].to == 0); i--); + if (i >= 0) { + dest.w = src.w = gfx.block.x * 2; + dest.h = src.h = gfx.block.y * 2; + + src.x = 0; + src.y = (2 * gfx.block.y) * player->illframe; + + dest.x = + (-(gfx.block.x >> 1)) + gfx.offset.x + (player->pos.x >> 8) * gfx.block.x + + gfx.postab[player->pos.x & 255]; + dest.y = + gfx.offset.y + ((player->pos.y >> 8) - 1) * gfx.block.y + + gfx.postab[player->pos.y & 255]; + + SDL_BlitSurface (gfx.ill.image, &src, gfx.screen, &dest); + + } + } + gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); + player->old = player->pos; // save this position +}; + + +void +restore_players_screen () +{ + int i, + x, + xe, + y, + ys, + ye; + + for (i = 0; i < MAX_PLAYERS; i++) + if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) { + x = (bman.players[i].old.x >> 8) - 1; + xe = (bman.players[i].old.x >> 8) + 2; + if (x < 0) + x = 0; + if (xe >= bman.fieldsize.x) + xe = bman.fieldsize.x - 1; + + ys = (bman.players[i].old.y >> 8) - 1; + ye = (bman.players[i].old.y >> 8) + 1; + if (ys < 0) + ys = 0; + if (ye >= bman.fieldsize.y) + ye = bman.fieldsize.y - 1; + + for (; x <= xe; x++) + for (y = ys; y <= ye; y++) + draw_stone (x, y); + } +}; + + +void +player_check_powerup (_player * p) +{ + int fx = p->pos.x >> 8; + int fy = p->pos.y >> 8; + int _x = p->pos.x & 255; + int _y = p->pos.y & 255; + + /* Get the right field position */ + if (_x > 128) + fx = fx + 1; + + if (_y > 128) + fy = fy + 1; + + /* we found a bomb powerup */ + if (bman.field[fx][fy].type == FT_bomb) { + if (p->bombs_n < MAX_BOMBS) + p->bombs_n++; + bman.field[fx][fy].type = FT_nothing; + if (bman.gametype != GT_single) + net_game_send_field (fx, fy); + } + + /* we found a fire powerup */ + if (bman.field[fx][fy].type == FT_fire) { + if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) + p->range++; + bman.field[fx][fy].type = FT_nothing; + if (bman.gametype != GT_single) + net_game_send_field (fx, fy); + } + + /* we found a shoe powerup */ + if (bman.field[fx][fy].type == FT_shoe) { + if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) + p->speed *= SPEEDMUL; + bman.field[fx][fy].type = FT_nothing; + if (bman.gametype != GT_single) + net_game_send_field (fx, fy); + } + + /* we found a death ?powerup? */ + if (bman.field[fx][fy].type == FT_death) { + player_set_ilness (p, -1); + net_game_send_ill (bman.p_nr); + + bman.field[fx][fy].type = FT_nothing; + if (bman.gametype != GT_single) + net_game_send_field (fx, fy); + } +}; + + +/* + check the givin field. if we are able to move on it + fx,fy = position on the field +*/ +int +check_field (short int fx, short int fy, _player * p) +{ + _point bombs[MAX_PLAYERS * MAX_BOMBS]; + int res = 0; + + if (bman.field[fx][fy].type != FT_stone && bman.field[fx][fy].type != FT_block) + res = 1; + + get_bomb_on (fx, fy, bombs); + if (bombs[0].x != -1) + res = 0; + + return res; +} + + +int +stepmove_player () +{ + _player *p = &bman.players[bman.p_nr]; + int _x, + _y, + dx = 0, + dy = 0, + fx, + fy, + speed = 0; + + if (p->m == 1) { + + fx = p->pos.x >> 8; + fy = p->pos.y >> 8; + + _x = p->pos.x & 255; + _y = p->pos.y & 255; + + // do direction correction for going up/down + if (_x > 0 && _x <= 128 && (p->d == up || p->d == down)) + p->d = left; + if (_x > 128 && _x < 256 && (p->d == up || p->d == down)) + p->d = right; + + // do direction correction for left/right + if (_y > 0 && _y <= 128 && (p->d == left || p->d == right)) + p->d = up; + if (_y > 128 && _y < 256 && (p->d == left || p->d == right)) + p->d = down; + + /* get the pos to the next field */ + if (p->d == left) + speed = _x; + else if (p->d == right) + speed = 256 - _x; + else if (p->d == up) + speed = _y; + else + speed = 256 - _y; + + if (speed > p->speed || speed == 0) + speed = p->speed; + + // go left + if (p->d == left && _y == 0 && ((_x == 0 && check_field (fx - 1, fy, p)) || (_x > 0))) + dx = -speed; + + // go right + if (p->d == right && _y == 0 && ((_x == 0 && check_field (fx + 1, fy, p)) || (_x > 0))) + dx = speed; + + // go up + if (p->d == up && _x == 0 && ((_y == 0 && check_field (fx, fy - 1, p)) || (_y > 0))) + dy = -speed; + + // go down + if (p->d == down && _x == 0 && ((_y == 0 && check_field (fx, fy + 1, p)) || (_y > 0))) + dy = speed; + + p->pos.x = p->pos.x + dx; + p->pos.y = p->pos.y + dy; + + player_check_powerup (p); + } + + if (dx == 0 && dy == 0) + return 0; + return (p->speed - speed); +}; + + +void +move_player () +{ + int oldd, + stepsleft, + speed; + _player *p = &bman.players[bman.p_nr]; + + oldd = p->d; + if (p->m) { + player_animation (p); + + if ((stepsleft = stepmove_player ()) > 0) { + /* save the speed and go the rest of the step */ + p->d = oldd; + speed = p->speed; + p->speed = stepsleft; + stepmove_player (); + p->speed = speed; + } + + if (bman.gametype != GT_single && (bman.net_pkgsend_to == 0 || p->old_m == 0)) + net_game_send_playermove (bman.p_nr); + } + + /* the player stopt moving so send data */ + if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0) + net_game_send_playermove (bman.p_nr); + + p->old_m = p->m; // save the old state + p->m = 0; +}; + + +void +player_drop_bomb () +{ + _player *player = &bman.players[bman.p_nr]; + _bomb *bomb = NULL; + int i, + _x, + _y; + _point bombs[MAX_PLAYERS * MAX_BOMBS]; + + for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++); + + if (i < player->bombs_n) { // free bomb found + // get the best position for the bomb. + bomb = &player->bombs[i]; + + bomb->pos.x = player->pos.x >> 8; + bomb->pos.y = player->pos.y >> 8; + _x = player->pos.x & 255; + _y = player->pos.y & 255; + + if (_x > 0 && _x <= 128) + _x = 0; + else if (_x > 128) { + bomb->pos.x += 1; + _x = 0; + } + + if (_y > 0 && _y <= 128) + _y = 0; + else if (_y > 12) { + bomb->pos.y += 1; + _y = 0; + } + + get_bomb_on (bomb->pos.x, bomb->pos.y, bombs); + if (bombs[0].x != -1) // is there already a bomb + return; + + d_printf ("Player %d Dropped Bomb %d\n", bman.p_nr, i); + bomb->r = player->range; + bomb->state = BS_ticking; + bomb->ex_nr = -1; + + bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 + + if (bman.gametype != GT_single) { + net_game_send_bomb (bman.p_nr, i); + if (GT_MP_PTPS) + bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); + } + } +}; + + +/* +check the field - 4 pixels from every side.. so it's not anymore that tricky to get +away from bombs.. */ +void +get_player_on (short int x, short int y, int pl_nr[]) +{ + int i, + p; + + for (i = 0, p = 0; p < MAX_PLAYERS; p++) + if (PS_IS_alife (bman.players[p].state)) { + if (bman.players[p].pos.x - 42 > x - 256 + && bman.players[p].pos.x + 42 < x + 256 + && bman.players[p].pos.y - 42 > y - 256 && bman.players[p].pos.y + 42 < y + 256) { + pl_nr[i] = p; + i++; + } + } + pl_nr[i] = -1; +}; + + +void +player_died (_player * player, signed char dead_by) +{ + // player die ! + + d_printf ("player_died (%10s)\n", player->name); + + if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS) + if (bman.p_nr != dead_by) + bman.players[dead_by].points++; + + player->state &= (0xFF - PSF_alife); + player->dead_by = dead_by; + + net_game_send_player (bman.p_nr); +}; + + +void +draw_players () +{ + int p; + + for (p = 0; p < MAX_PLAYERS; p++) { + if (PS_IS_playing (bman.players[p].state)) + draw_player (&bman.players[p]); + } +}; + + +void +player_animation (_player * player) +{ + if (player->gfx == NULL) + return; + + if (player->frame < player->gfx->ani.frames + && (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT)) { + player->frameto = ANI_PLAYERTIMEOUT; + player->frame++; + } + + if (player->frame >= player->gfx->ani.frames && PS_IS_alife (player->state)) + player->frame = 0; + + if (player->frameto > 0) + player->frameto--; +}; + + +void +dead_playerani () +{ + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + if (PS_IS_dead (bman.players[i].state)) + player_animation (&bman.players[i]); +}; + + +void +player_calcstep (_player * pl) +{ + _point d; + int fx, + fy; + + player_animation (pl); + + fx = pl->pos.x >> 8; + fy = pl->pos.y >> 8; + + if (bman.field[fx][fy].type != FT_block && bman.field[fx][fy].type != FT_stone) { + d.x = 0; + d.y = 0; + if (pl->d == left) + d.x = -16; + else if (pl->d == right) + d.x = 16; + else if (pl->d == up) + d.y = -16; + else if (pl->d == down) + d.y = 16; + + pl->pos.x += d.x; + pl->pos.y += d.y; + } +}; + + +/* + calc the position on the screen for moving network players +*/ +void +player_calcpos () +{ + _player *pl; + int oldm, + oldd, + p; + + for (p = 0; p < MAX_PLAYERS; p++) { + pl = &bman.players[p]; + if (PS_IS_netplayer (pl->state) && pl->m != 0) { + + if (pl->speeddat == 0 || pl->speed == 1 || pl->speed == 3) + pl->speeddat = 1; + else + pl->speeddat = 0; + + oldm = pl->m; + oldd = pl->d; + + if (pl->speed > 1) + stepmove_player (); + + if (pl->speeddat) { + pl->m = oldm; + pl->d = oldd; + player_calcstep (pl); + } + } + } + +}; + + +void +player_ilness_loop () +{ + _player *p; + int type, + pnr, + i, + tmp, + send; + int pl[MAX_PLAYERS + 1]; + + /* do the illness for the network players */ + for (pnr = 0; pnr < MAX_PLAYERS; pnr++) + if (pnr != bman.p_nr && PS_IS_alife (bman.players[pnr].state)) { + p = &bman.players[pnr]; + for (type = 0; type < PI_max; type++) + if (p->ill[type].to > 0) { + p->ill[type].to--; + p->illframeto--; + if (p->illframeto <= 0 || p->illframeto > ANI_PLAYERILLTIMEOUT) { + p->illframeto = ANI_PLAYERILLTIMEOUT; + p->illframe++; + if (p->illframe < 0 || p->illframe >= gfx.ill.frames) + p->illframe = 0; + } + } + } + + /* check if we have contact with an other ill player */ + p = &bman.players[bman.p_nr]; + + get_player_on (p->pos.x, p->pos.y, pl); + for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++) + if (pl[i] != bman.p_nr) { + send = 0; + for (type = 0; type < PI_max; type++) { + if (bman.players[pl[i]].ill[type].to > p->ill[type].to) { + tmp = p->ill[type].to; + player_set_ilness (p, type); + p->ill[type].to = bman.players[pl[i]].ill[type].to; + if (tmp <= 0) + send = 1; + } + } + if (send != 0) + net_game_send_ill (bman.p_nr); + } + + /* do the illness for our own player */ + for (type = 0; type < PI_max; type++) + if (p->ill[type].to > 0) { + p->ill[type].to--; + if (p->ill[type].to == 0) + player_clear_ilness (p, type); + else { + p->illframeto--; + if (p->illframeto <= 0 || p->illframeto > ANI_PLAYERILLTIMEOUT) { + p->illframeto = ANI_PLAYERILLTIMEOUT; + p->illframe++; + if (p->illframe < 0 || p->illframe >= gfx.ill.frames) + p->illframe = 0; + } + + if (type == PI_keys) { + /* switch direction for player key illness */ + if (p->m > 0) + switch (p->d) { + case (left): + p->d = right; + break; + case (right): + p->d = left; + break; + case (up): + p->d = down; + break; + case (down): + p->d = up; + break; + } + } + else if (type == PI_bomb) { + /* player is dropping bombs */ + if (p->old.x != p->pos.x || p->old.y != p->pos.y) + player_drop_bomb (); + } + } + } +} + + +/* player picked up the death powerup, add timeout for +this illness to the maybe excisting timeout */ +void +player_set_ilness (_player * p, int t) +{ + int type; + + if (t == -1) + type = s_random (PI_max); + else + type = t; + + d_printf ("Ilness : %d\n", type); + + if (type == PI_slow) { + if (p->ill[type].to == 0) + p->ill[type].data = p->speed; + p->speed = 6; + } + + else if (type == PI_range) { + if (p->ill[type].to == 0) + p->ill[type].data = p->range; + p->range = 1; + } + + p->ill[type].to += TIME_FACTOR * IL_TIMEOUT; +}; + + +/* players ilness is over now */ +void +player_clear_ilness (_player * p, int type) +{ + if (type < 0 || type >= PI_max) + return; + + if (type == PI_slow) + p->speed = p->ill[type].data; + + if (type == PI_range) + p->range = p->ill[type].data; + + p->ill[type].to = 0; + + net_game_send_ill (bman.p_nr); +}; + + +void +player_set_gfx (_player * p, signed char gfx_nr) +{ + p->gfx_nr = gfx_nr; + + if (p->gfx_nr < 0 || p->gfx_nr >= MAX_PLAYERS) + p->gfx_nr = -1; + + if (p->gfx_nr == -1) { + p->gfx = NULL; + p->state &= (0xFF - (PSF_alife + PSF_playing)); + } + else { + p->gfx = &gfx.players[gfx_nr]; + p->state |= PSF_playing; + } +}; diff --git a/src/sysfunc.c b/src/sysfunc.c new file mode 100644 index 0000000..697d652 --- /dev/null +++ b/src/sysfunc.c @@ -0,0 +1,55 @@ +/* + sysfunc.c - this file hold some routines for the system functions.. + like d_delay +*/ + +#include "bomberclone.h" + + +void s_delay (int ms) { + fd_set selectset; + struct timeval tval; + + FD_ZERO (&selectset); + tval.tv_sec = 0; + tval.tv_usec = ms; + select (1, &selectset, NULL, NULL, &tval); +} + +int s_random (int maxnr) { +#ifdef _WIN32 + return ((rand () * maxnr)/RAND_MAX ); +#else + int i; + i = (((rand () >> 16) * (maxnr+1))/(RAND_MAX >> 16)); + if (i >= maxnr) + i = 0; + return i; +#endif +}; + +static char homedir[255]; + +char *s_gethomedir () { + + char *hd; + if ((hd = getenv ("HOME")) == NULL) { + /* Homedir konnte nicht ermittelt werden. */ + homedir[0] = 0; + d_printf ("Variable HOME could not be found\n"); + } + else { + strncpy (homedir, hd, 253); + homedir [strlen(homedir)+1] = 0; +#ifdef _WIN32 + if (homedir [strlen(homedir)-1] != '\\') + homedir [strlen(homedir)] = '\\'; +#else + if (homedir [strlen(homedir)-1] != '/') + homedir [strlen(homedir)] = '/'; +#endif + } + + return homedir; +}; + diff --git a/src/udp.c b/src/udp.c new file mode 100644 index 0000000..fa6d1aa --- /dev/null +++ b/src/udp.c @@ -0,0 +1,296 @@ +/* udp.c code for the network + File Version 0.2 +*/ + +#define UDP_LEN_HOSTNAME 128 +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#else +#include +#include +#include +#include +#endif + +#ifdef _WIN32 +#define _sockaddr sockaddr +#else +#define _sockaddr sockaddr_in6 +#endif + +extern char *dns_net_getip (char *host); +extern int dns_filladdr (char *host, int hostlen, char *port, int portlen, int ai_family, + struct _sockaddr *sAddr); +extern int udp_get (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family); +extern int udp_server (char *port, int ai_family); +extern void udp_send (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family); +extern void udp_close (int sock); + +char dnsip[UDP_LEN_HOSTNAME]; + +extern void d_printf (char *fmt,...); + + +/* closes an existing udp server */ +void +udp_close (int sock) +{ + if (sock != -1) + close (sock); + sock = -1; +}; + + +int +dns_filladdr (char *host, int hostlen, char *port, int portlen, int ai_family, + struct _sockaddr *sAddr) +{ +#ifdef _WIN32 + struct hostent *he; + char txt[255]; + + if (host[0] == 0 || port[0] == 0) { + /* we have to complete server and port from the sAddr */ + + strncpy (host, inet_ntoa (((struct sockaddr_in *) sAddr)->sin_addr), hostlen); + sprintf (txt, "%d", ntohs (((struct sockaddr_in *) sAddr)->sin_port)); + strncpy (port, txt, portlen); + } + else { + /* we have to complete the sAddr struct */ + + if ((he = gethostbyname (host)) == NULL) { // get the host info + perror ("dns_filladdr (gethostbyname)"); + return -1; + } + + ((struct sockaddr_in *) sAddr)->sin_family = ai_family; // host byte order + ((struct sockaddr_in *) sAddr)->sin_port = htons (atoi (port)); // short, network byte order + ((struct sockaddr_in *) sAddr)->sin_addr = *((struct in_addr *) he->h_addr); + memset (&(((struct sockaddr_in *) sAddr)->sin_zero), '\0', 8); // zero the rest of the struct + } + +#else + + struct addrinfo hints, + *res; + int err, i, + addrlen; + + if (host[0] == 0 || port[0] == 0) { + /* we have to complete server and port from the sAddr */ + + if (ai_family == PF_INET) + addrlen = sizeof (struct sockaddr_in); + else + addrlen = sizeof (struct sockaddr_in6); + + bzero (host, hostlen); + bzero (port, portlen); + + if ((err = + getnameinfo ((struct sockaddr *) sAddr, addrlen, host, hostlen, port, portlen, + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { + d_printf ("dns_filladdr (getnameinfo): %s\n", gai_strerror (err)); + return -1; + } + + if (strstr (host, "::ffff:") != NULL) { + for (i = 0; host[i + 7] != 0; i++) + host[i] = host[i+7]; + host[i] = 0; + } + } + else { + /* we have to complete the sAddr struct */ + + bzero (&hints, sizeof (struct addrinfo)); + hints.ai_family = ai_family; + hints.ai_socktype = SOCK_DGRAM; + + if ((err = getaddrinfo (host, port, &hints, &res)) < 0) { + d_printf ("dns_filladdr (getaddrinfo):%s\n", gai_strerror (err)); + return -1; + } + + // i hope it's enough to copy only sizeof (struct sockaddr) ? + memcpy (sAddr, res->ai_addr, res->ai_addrlen); + + freeaddrinfo (res); + } + +#endif + + return 0; +} + + +/* send text to someone */ +void +udp_send (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family) +{ + int addrlen; + + if (ai_family == PF_INET) + addrlen = sizeof (struct sockaddr_in); +#ifndef _WIN32 + else + addrlen = sizeof (struct sockaddr_in6); +#endif + + if (sendto (sock, text, len, 0, (struct sockaddr *) sAddr, addrlen) == -1) + perror ("udp_send :"); +}; + + +int +udp_server (char *port, int ai_family) +{ +#ifdef _WIN32 + + int sock; + struct sockaddr_in sAddr; // my address information + + if ((sock = socket (ai_family, SOCK_DGRAM, 0)) == -1) { + perror ("udp_server: socket"); + return -1; + } + + sAddr.sin_family = AF_INET; // host byte order + sAddr.sin_port = htons (atoi (port)); // short, network byte order + sAddr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP + + memset (&(sAddr.sin_zero), '\0', 8); // zero the rest of the struct + + if (bind (sock, (struct sockaddr *) &sAddr, sizeof (struct sockaddr)) == -1) { + perror ("udp_server: bind"); + return -1; + } + +#else + struct addrinfo hints, + *res, + *sres; + int err, + sock, + ai_family_; + + bzero (&hints, sizeof (struct addrinfo)); + + hints.ai_flags = AI_PASSIVE; + hints.ai_family = ai_family; + hints.ai_socktype = SOCK_DGRAM; + + ai_family_ = 0; + + if ((err = getaddrinfo (NULL, port, &hints, &res)) == 0) { + sres = res; + while ((ai_family_ == 0) && (sres)) { + if (sres->ai_family == ai_family || ai_family == PF_UNSPEC) + ai_family_ = sres->ai_family; + else + sres = sres->ai_next; + } + + if (sres == NULL) + sres = res; + + ai_family_ = sres->ai_family; + if (ai_family_ != ai_family && ai_family != PF_UNSPEC) { + // ai_family is not identic + freeaddrinfo (res); + return -1; + } + + if ((sock = socket (sres->ai_family, SOCK_DGRAM, 0)) < 0) { + perror ("UDP_Server (socket):"); + freeaddrinfo (res); + return -1; + } + + if ((err = bind (sock, sres->ai_addr, sres->ai_addrlen)) < 0) { + perror ("UDP_Server (bind):"); + close (sock); + freeaddrinfo (res); + return -1; + } + + freeaddrinfo (res); + } + else { + sock = -1; + d_printf ("UDP_Server (getaddrinfo):%s\n", gai_strerror (err)); + } +#endif + + return sock; +}; + +/* + gets some text + RESULT: 0 for nothing on there +*/ +int +udp_get (int sock, char *text, int len, struct _sockaddr *sAddr, int ai_family) +{ + int clen, + msglen; + fd_set sockset; + struct timeval tval; + + if (sock == -1) + return -1; + + /* what version of tcp/ip we're using */ + if (ai_family == AF_INET) + clen = sizeof (struct sockaddr_in); +#ifndef _WIN32 + else + clen = sizeof (struct sockaddr_in6); +#endif + + bzero (text, len); + + // check if we have got any data + FD_ZERO (&sockset); + FD_SET (sock, &sockset); + + tval.tv_sec = 0; + tval.tv_usec = 100; + + msglen = 0; + + if (select (sock + 1, &sockset, NULL, NULL, &tval)) { + + msglen = recvfrom (sock, text, len, 0, (struct sockaddr *) sAddr, &clen); + if (msglen < 0) + return 0; + + if ((msglen >= 0) && (msglen < len)) + text[msglen] = 0; + } + return msglen; +}; + + +char * +dns_net_getip (char *host) +{ + struct hostent *hAddr; + + hAddr = gethostbyname (host); + + if (hAddr == NULL) + return NULL; + + strncpy (dnsip, inet_ntoa (*((struct in_addr *) hAddr->h_addr)), UDP_LEN_HOSTNAME); + + return dnsip; +}; diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/tools/convert-bomb.sh b/tools/convert-bomb.sh new file mode 100755 index 0000000..ea0a67f --- /dev/null +++ b/tools/convert-bomb.sh @@ -0,0 +1,22 @@ +# CROP Files + +RES=415x415 +POS=+150+45 + +SRES=64x64 +SPOS=+0+0 + +ARES=64x640 +APOS=+0+0 + +rm -rf crop* +rm -rf bomb.bmp + +for i in `ls *.bmp`; do + echo "CROP & SCALE " $i + montage -crop $RES$POS $i -geometry $RES+0+0 bmp:crop-$i + mogrify -filter Point -antialias -resize $SRES crop-$i +done; + +echo "MONTAGE Bomb"; +montage -tile 1x20 -geometry $SRES crop-bomb*.bmp -crop $ARES bmp:bomb.bmp diff --git a/tools/convert-player.sh b/tools/convert-player.sh new file mode 100755 index 0000000..cc9a0ef --- /dev/null +++ b/tools/convert-player.sh @@ -0,0 +1,38 @@ +# CROP Files + +RES=214x295 +POS=+211+65 + +SRES=93x128 +SPOS=+0+0 + +ARES=93x2560 +APOS=+0+0 + +FRES=372x2560 +FPOS=+0+0 + +rm -rf crop* +rm -rf out* +rm -rf player.bmp + +for i in `ls *.bmp`; do + echo "CROP & SCALE " $i + montage -crop $RES$POS $i -geometry $RES+0+0 bmp:crop-$i + mogrify -filter Point -antialias -resize $SRES crop-$i +done; + +echo "MONTAGE back"; +montage -tile 1x20 -geometry $SRES crop-*back*.bmp -crop $ARES tiff:out03 + +echo "MONTAGE front"; +montage -tile 1x20 -geometry $SRES crop-*front*.bmp -crop $ARES tiff:out04 + +echo "MONTAGE left"; +montage -tile 1x20 -geometry $SRES crop-*left*.bmp -crop $ARES tiff:out02 + +echo "MONTAGE right"; +montage -tile 1x20 -geometry $SRES crop-*right*.bmp -crop $ARES tiff:out01 + +echo "MONTAGE all" +montage -tile 4x1 -geometry $ARES$APOS out01 out02 out03 out04 bmp:player.bmp diff --git a/tools/convert-sick.sh b/tools/convert-sick.sh new file mode 100755 index 0000000..a56ed27 --- /dev/null +++ b/tools/convert-sick.sh @@ -0,0 +1,17 @@ +# CROP Files + +SRES=128x128 +ARES=128x256 +SPOS=+0+0 + +rm -rf crop* +rm -rf bomb.bmp + +for i in `ls *.bmp`; do + echo "SCALE " $i + cp $i crop-$i + mogrify -filter Point -antialias -resize $SRES crop-$i +done; + +echo "MONTAGE Sick"; +montage -tile 1x2 -geometry $SRES crop-sick*.bmp -crop $ARES bmp:sick.bmp