Commit Graph

370 Commits (1ed72f87abf0793051dea02837c10db91b64add7)

Author SHA1 Message Date
Guangcong Luo bbba6f6ff8 Only delSocket if it actually exists (fix assert).
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8794 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:52 +01:00
Giel van Schijndel 34b50b4219 Fix the doxygen documentation for `addSocket` and `delSocket`
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8792 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:52 +01:00
Giel van Schijndel 64d8e39b38 Check for socket errors and handle them:
* Close a socket when an error occurs on it
 * Store the return values of send() and recv() in `ssize_t` instead of `int`
  - Prevents truncation of values as ssize_t is the return type specified by POSIX to use

This should prevent us from ever getting hit with SIGPIPE again.

SIGPIPE is transmitted when we try to write to a connection we've previously been told has closed.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8772 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:50 +01:00
Giel van Schijndel 46aa89779e Be more resiliant in the case of dangling pointers to a Socket
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8769 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:50 +01:00
Buginator 5b2eabf0b5 Fix bad indentation on a merge that went astray
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8749 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:48 +01:00
Buginator 79037573f0 frontport r8717
"Add new flag to keep track of when Host is alive.

Add a popup window notification for when the Host drops, and also notify the host when *they* quit, that the game will be over for everyone else (because of the network model)

Fix heap corruption when the host's connection was severed in the NET_fillBuffer() function.

Fix a socket error when we tried to write to a NULL socket.

Note: added two strings that need translating"


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8743 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:47 +01:00
Buginator 15413718c8 frontport r8672
"Update packet names for new packet types in log.


refs ticket:1185"


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8737 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:46 +01:00
Buginator d26716553b frontport r8671
"Reset flags for new people joining."

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8736 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:46 +01:00
Buginator 38f66c5f9e frontport r8667
"Rewrite the stupid file transfer routines.
* It will now only send the file to the person that needs it.

* Adds abort code to the file routines as well, and also tries to detect when the Host is using a malformed filename to host a map.

* Make sure user can't hit the 'ready' button when the map transfer is ongoing.

* Get rid of the silly delays (Much faster transfers)

NOTE: we are still capped by fps. 
fixes ticket:1128
fixes ticket:1127
refs ticket:215 (still can't transfer 'map packs')"

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8734 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:45 +01:00
Buginator 5a2509a26d frontport r8651
"Add config variable 'UPnP' to enable/disable UPnP detection / routines.  1=on, 0=off, default is ON.
"

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8732 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:45 +01:00
Buginator 098a1ea117 frontport r8650
"To prevent some confusion rename 'game' structure in netplay.c to gamestruct.

'game' is used as MULTIPLAYERGAME structure everywhere else, and it used GAMESTRUCT in netplay.c"


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8731 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:45 +01:00
Christian Ohm cd36584441 Don't access UPnP device info after freeing it.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8676 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:41 +01:00
Per Inge Mathisen 5e16640ba3 Build fixes for netplay.c on OpenBSD, closes ticket:1180
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8675 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 20:26:41 +01:00
Christian Ohm d808f72d8e Don't add UPnP redirects in single player skirmish.
Closes #1174.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8647 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:53 +01:00
Christian Ohm cd3ce412a3 Fix typos, reported by Paul Wise.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8646 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:53 +01:00
Guangcong Luo 9dc3cac6d6 [Having problems committing, so I'm seeing if I can commit this one file at a time] Continue fixing bug #1170: compile warning.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8643 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:53 +01:00
Guangcong Luo f6992d5719 sendTextMessage improvements - uses the position numbers again, and sends "(private to Player) message" instead of "0message". Also adds a shortcut for alliance chat: Use ".message" to send "(allies) message" to allies only.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8639 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:53 +01:00
Guangcong Luo aabbca68d8 Move map download progress to players list, so you can still chat while it happens. Also update players list instantly, instead of every 2 seconds (except slider changes, which are updated every 0.5 seconds). Also fix taken position detection (fixes bug #1137).
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8602 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:48 +01:00
Christian Ohm 5a5e5d6510 Threaded UPnP device detection.
Increases the timeout to 2 seconds. Closes #1073.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8564 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:45 +01:00
Buginator e8d4d378a8 Add UPnP detection results to the Crash dump.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8557 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:45 +01:00
Buginator 25b9dc9ba6 Add more documentation about the Map issues and note in logs about map transfers (if exists / file size mismatch)
(r8548/r8549)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8555 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:45 +01:00
Buginator a1ec0bd358 Clarify variables by prefix of _64 for 64bit and _32 for 32bit...
(r8546)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8553 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:44 +01:00
Buginator 8018d99190 Add new message of NET_HOST_DROPPED to deal with when host quits game, we should quit as well (lobby)
Add more debug lines when we drop/leave players
(r8538)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8550 4a71c877-e1ca-e34f-864e-861f7616d084
2010-01-30 17:12:44 +01:00
Buginator b307503d56 Slightly rework when we should and shouldn't chop strings based on if the tech level is present or not.
Also add more debug lines to see if this issue crops up again.

Fixes ticket:1104
(r8533)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8534 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:15 +01:00
Buginator f76f352bd0 Add error checking to socketClose()
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8532 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:15 +01:00
Buginator cc76454b69 Fix the missing header file for the setPlayerColour() function.
(r8411)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8525 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:14 +01:00
Buginator a72cb7295a Transmit and set local color array. Fixes picking of team color bug.
Transmit player map position & handle picking of players correctly. fixes ticket:1075

Enable/disable AIs on maps. fixes ticket:1065

(r8410)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8524 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:14 +01:00
Buginator 06e0716a14 *Change* MaxMsgSize is now 16K
*Change* MAX_BYTESPERSEC is now 14K (was hitting limit in 4p games old limit was 6K)
*Change* relax timings of ping & scoreboard to alleviate the bandwidth strain a bit
(r8381)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8520 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:13 +01:00
Per Inge Mathisen 5e7c746001 Remove obsolete references to SDL_net, which is now long gone.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8509 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-28 19:34:12 +01:00
Guangcong Luo 193c8d142b Fix a segfault from a null pointer dereference in netplay.c upnp_init(). (Fixes bug #1099)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8497 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-23 18:13:26 +01:00
Guangcong Luo ae16bb2aa0 Make Warzone compile and run successfully on Mac OS X again.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8482 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:20:06 +01:00
i-nod c5e16d59ce libminiupnpc has been integrated into MinGW build process.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8470 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:20:03 +01:00
Christian Ohm a7ae06572d Integrate miniupnpc.
This should bring it up to about the state of the patches and comments in
ticket #1073, without the threaded device detection. Timeout is 500ms, that
should be enough to detect a LAN device, and doesn't delay startup too much.

Port r8447 plus the fixes for it in r8449, r8453, r8455 and r8456 to trunk.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8460 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:20:02 +01:00
Christian Ohm 03607b0fb8 Rename miniupnp Makefile to prepare for automake.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8459 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:20:02 +01:00
Christian Ohm 1f1a95e85e Include MiniUPnPc.
lib/netplay/miniupnpc now contains a completely unmodified copy of
miniupnpc-1.4.tar.gz from http://miniupnp.free.fr/, integration with Warzone
will follow.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8458 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:20:02 +01:00
Guangcong Luo c41b9da86a More informative version string error messages.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8418 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:19:58 +01:00
Guangcong Luo a279c154af Fix a typo from r7840 that caused the game to be unable to display all the games on the lobby sometimes.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8341 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:19:54 +01:00
Buginator 0aff0b46cf Add a new debug flag type, LOG_FATAL.
This is used to differentiate LOG_ERROR (which is a *non* fatal error, but a error none the less) and fatal errors which result in program termination with no *visible* output (on windows/macs) on our end because of the crappy GUI functions so we usually dump it to stderr.txt and there is no clue that the program had to exit for whatever reason.

Hopefully, this will be helpful to windows people so they can differentiate between *our* exit/abort routines, and crashes that occur in drivers which look exactly the same since they get dumped back to the desktop with no visible clue why.

LOG_FATAL is *always* on in both debug & release builds.

On LOG_FATAL debug lines, on windows, we now throw up a modal dialog box with the current error message.  At this time, this only happens when we have a error, and we use abort() right after the error, which makes it fatal.

That explains why this touches ~60 files :)


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8320 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-22 16:19:51 +01:00
Buginator 2ea2c754eb Up map packet size to 1K from 256 bytes
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8244 4a71c877-e1ca-e34f-864e-861f7616d084
2009-10-10 14:49:25 +02:00
Buginator 0ec13ebdf5 Data Integrity is reimplemented. Version string has been updated, so the new data checks can work correctly.
If all players do not run the same mods or have the same data as the HOST, then they will be kicked.  This is done to prevent crashes to the game.

Closes ticket:961

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8213 4a71c877-e1ca-e34f-864e-861f7616d084
2009-10-06 22:09:59 +02:00
Giel van Schijndel 7952b39be8 netplay address printing:
* Don't cast if we can safely alter the format specifiers
 * Fix a spelling error: 'address famliy' -> 'address family'

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7897 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:52 +02:00
Guangcong Luo 6e52b9a01d Fix bug reported by Beau - NetPlay.playercount could be decremented in situations where it should not, and underflow.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7855 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:32 +02:00
Christian Ohm bd85f32ba5 Prevent possible out-of-bounds access when out of sockets in NETallowJoining.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7854 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:32 +02:00
Guangcong Luo 924ef17242 Fix bug #713: Can't compile.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7848 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:31 +02:00
Guangcong Luo 76ee950a03 Fix bug #711 - didn't compile
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7843 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:30 +02:00
Guangcong Luo d5dfdc17e0 Fix bug #691: Cannot display more than one game from lobby. Also fix a lobby display issue that I thought I already fixed.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7840 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:30 +02:00
Per Inge Mathisen b86f0f85cc Improve documentation of PLAYER.allocated field. Improve asserts for indexing into some player methods.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7826 4a71c877-e1ca-e34f-864e-861f7616d084
2009-09-27 19:06:27 +02:00
Buginator 79a8dbf4f4 Add #define NET_TIMEOUT_DELAY 2500 to allow for easier changing of the constant.
No real code changes.

closes ticket:613

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7719 4a71c877-e1ca-e34f-864e-861f7616d084
2009-06-16 22:28:32 +02:00
Buginator 5a8cab42d9 Bump up timeout period to 2500ms from 1000ms for dial-up modem users.
Fixes ticket:543

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7687 4a71c877-e1ca-e34f-864e-861f7616d084
2009-06-09 23:44:24 +02:00
Buginator 70ebec41b0 Fix compile issue
Thanks to stiv for the report.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7679 4a71c877-e1ca-e34f-864e-861f7616d084
2009-06-09 23:44:18 +02:00
Buginator cdbe56c1c5 Merge netplay (anti-dpid) branch to trunk.
netplay branch ceases to exists anymore.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7678 4a71c877-e1ca-e34f-864e-861f7616d084
2009-06-09 23:44:17 +02:00
Guangcong Luo d6e036a25d Fix compile error.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7651 4a71c877-e1ca-e34f-864e-861f7616d084
2009-06-05 16:21:05 +02:00
Giel van Schijndel 452c507de1 Networking:
* Only clean up the IPv4 socket if we are able to enable IPv4 mapping of IPv6 addresses ''and'' are able to create an IPv6 socket
 * Add some more debug messages to be able to see what sockets could be created
 * Close sockets when they've become useless/invalid

This should fix #534 for real (unlike r7541, which fixed it and then reintroduced another bug causing the same symptom).


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7543 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-28 09:59:31 +02:00
Giel van Schijndel c2f8273762 Make setting up of the IPv4 and IPv6 sockets indepent:
* Allow failure for setting up of one of the sockets
  - More accurately: require only one socket to succeed
 * Try to use the IPv4 to IPv6 mapping feature if the host OS provides it
  - This allows us to use only a single socket on those systems for both listening to IPv4 and IPv6

This should fix #534.



git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7541 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-28 09:59:30 +02:00
Giel van Schijndel 7e6afc09cb #include all required headers (<netinet/in.h> for sockaddr_in and sockaddr_in6)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7540 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-28 09:59:30 +02:00
Giel van Schijndel 3e5254af26 Only (attempt to) disable IPV6_V6ONLY on systems where it's #defined
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7378 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-10 19:18:11 +02:00
Giel van Schijndel 3dfb215c8b Add IPv6 support to the lobby protocol
* Add a new field: secondaryHosts, an array of two fallback hosts
  - Canibalize the entire "misc" field and part of the "extra" field for this
  - When connecting, first try the primary "host" field, then fall back to the hosts in secondaryHosts (in order)
 * Add a new field: gameId, used on the lobby server to link multiple lobby connections to a single game entry
  - First (attempt to) connect to the lobby with all available address families (currently IPv4 and IPv6)
  - Then ask for a gameId from the lobby server using the first established lobby connection
  - Set the gameId field in the GAMESTRUCT to the one retrieved
  - Transmit the GAMESTRUCT using a "addg" command to the lobby over each lobby connection
  - The lobby then compares all incoming ID numbers with ID numbers already present
  - If there's a match it will use the GAMESTRUCT already present and only add a new hostname to the list

This is the last change, part of, and closes #452

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7364 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-09 23:29:55 +02:00
Giel van Schijndel 3b80e3a63c Add client side IPv6 support
* Properly format IPv6 addresses (so that parsing later on will work again)
 * Resolve names to all address families, not just IPv4

Addresses #452

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7363 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-09 23:29:54 +02:00
Giel van Schijndel 4a90601536 Add partial server side IPv6 support
Implement a "dual stack", i.e. listen on both IPv4 and IPv6 addresses.
This change doesn't affect the socket API itself.

Addresses #452

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7362 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-09 23:29:54 +02:00
Giel van Schijndel 6fdc07b3f9 For the purpose of error messages set the error to ECONNRESET when we got disconnected while doing a readAll()
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7345 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:42 +02:00
Buginator b9aea91c74 Move 'server_not_there' to a more correct location.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7333 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:40 +02:00
Buginator e26ca45678 When we get a error in readLobbyResponse(), we need to put a stop to hitting the server, since this will cause massive slowdowns.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7330 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:40 +02:00
Giel van Schijndel d02f591709 Lobby protocol; change the way the "addg" command works:
* Make the "addg" command return a status code (ranging 200-299 on success) and message (MOTD on succes)
 * Don't use the "motd" command anymore to check the lobby status, instead use the returned status code for that purpose.
 * Allow MOTD strings of arbitrary length (by sending along the length)

This modification ensures that ''proper'' connectivity checking is being performed on the game server (and reported to the user accurately).

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7323 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:40 +02:00
Buginator 967b1bcb74 Reset version string back to "trunk", accidentally changed in r7079.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7315 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:39 +02:00
Giel van Schijndel 38cfef4e6d Make sure to #undef the errno Exxxx symbols on Windows to prevent collision with the predefined ones by MinGW
Also lets :sort the Exxxx #define list

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7308 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:38 +02:00
Buginator 7e1a1d714c Slight fixes for the BSD socket overhaul to make it compile OK on MSVC again.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7307 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:38 +02:00
Giel van Schijndel 9fa9402919 Work around MSVC's weak & stinky preprocessor:
* Duplicate the entire ASSERT() call instead of conditionally expanding its parameter
  - Depending on whether we are or are not compiling on Windows

Thanks go to Buginator for reporting this.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7306 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:38 +02:00
Giel van Schijndel fcf40c7eb2 For incoming connections print the address from which the connection originates.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7303 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:38 +02:00
Giel van Schijndel a3cbe4c0c3 Use a single function for address to text translation (instead of duplicating code)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7302 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:37 +02:00
Giel van Schijndel dc70524cd2 Take advantage of SocketAccept's non-blocking nature
Just go ahead and try to accept incoming connections without waiting for
a notification that connections are pending.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7301 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:37 +02:00
Giel van Schijndel 63b6d37a94 Make SocketAccept non-blocking
This way it is no longer required to first explicitly check whether
connections are pending (through checkSockets, which select(2)s) and
only then accept(2) it. Now you can attempt to accept the connection,
and if one is available it'll get returned, NULL otherwise.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7300 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:37 +02:00
Giel van Schijndel 36f536fcdb Check for EAGAIN as well to confirm connect(2) has started
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7299 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:37 +02:00
Giel van Schijndel 73a29daefd * Use camelCase instead of CamelCase and under_squores (as requested by Per, see #435)
* Rename read_all to readNoInt because that function is a read(2) variant that doesn't get interrupted by signals (EINTR)
 * Add Doxygen comments to readNoInt and writeAll

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7298 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:37 +02:00
Giel van Schijndel a8f8357904 Mark the server socket as not-ready when we've just accept(2)ed on it
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7296 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel 99c1ed95e8 Always use SocketClose to clean up sockets
Additionally make SocketClose work properly on Windows as well.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7295 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel 0bc6be39b1 Fix logic in handling return value of addSocket
When a socket set is full (in addSocket) print a debug message

This is the last change, part of, and closes #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7294 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel ba9d49acd5 Get rid of duplicated code
Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7293 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel ab6b694420 Bugfix: set SOCKET_ERROR to -1 to *correctly* check for errors
Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7292 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel a9070e60a9 For non-blocking sockets lets not block on read_all()
Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7291 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel 37d3b9535f Replace -1 for socket API errors with SOCKET_ERROR
Additionaly, on Unix systems define constants SOCKET_ERROR and INVALID_SOCKET to -1

Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7290 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:36 +02:00
Giel van Schijndel f412eb5a6f Port NetPlay's BSD socket usage to Windows
* Use the "SOCKET" typedef to represent socket descriptors (instead of "int")
 * Add wrapper functions for getting & setting the last socket error ("errno" on Unix)
 * Add a wrapper function for strerror, strsockerror, that works on Windows
 * Use recv(2) and send(2) instead of read(2) and write(2) respectively
 * Use INVALID_SOCKET and SOCKET_ERROR instead of -1 to find errors
 * Move setting of sockets to blocking/non-blocking to a separate function
 * Add Windows-specific wrapper functions for getaddrinfo() and freeaddrinfo()
  - Currently work only from 2000 *or* XP upwards, documentation is fuzzy.

Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7289 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel ae878a7880 Change write_all such that it will always return "size" or -1 (error)
* Check for write_all() == -1 (error) instead of "< 0" and "!= size" to
   see whether sending has failed.
 * Don't just mark sockets as "invalid" on error (by setting them to
   NULL), close them as well.
 * Give decent error messages on write failure (most likely a disconnect)

Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7288 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel 61e0a18a6a Pass the Socket* structure to read_all and write_all instead of a plain file descriptor
This way it becomes possible to modify a socket's state when
reading/writing.

Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7287 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel 939f4902ad Replace SDL-net by using BSD sockets instead
NOTE: Still needs some checking and work for Windoze compatibility.

Addresses #435

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7286 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel 7297008ed5 Fix spelling error: rename "ERROR_WRONGVESION" to "ERROR_WRONGVERSION"
Thanks to Kreuvf for noting the mistake.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7275 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel 47bbacc7bb Bugfix: NUL terminate the MOTD string buffer
If registering with the lobby server failed once, we don't want part of
the failure message to be kept at the end of the MOTD string.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7270 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel e4f82dc1e5 Disconnect immediately when we've handled the client's request (or concluded it to be invalid)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7256 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Giel van Schijndel dd66b9fe33 Fix a bug where we would check the wrong socket for readiness
- Would occur when processing a "list" command on the game server

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7255 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Giel van Schijndel 4a3b92bd4b Document the purpose of the different sets of sockets
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7254 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Giel van Schijndel f6b3c04c8c Backport r7244 into trunk from the 2.2 branch
Move GAMESTRUCT_VERSION to the top of GAMESTRUCT, thus allowing versioning to work properly at all times

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7246 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +02:00
Giel van Schijndel e16e034ec7 Use 40 bytes for the "host" (IP address) in GAMESTRUCT, this allows for using IPv6 without breaking protocol combatility again
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7239 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +02:00
Giel van Schijndel 7db243a59e Lets correctly indicate in our error message which TCP ports should be open (instead of hardcoding the message and getting it wrong)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7222 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 20:52:19 +02:00
Buginator 2dc8626d75 whoops! :o I applied the wrong patch.
Reverting.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7204 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-27 21:30:41 +02:00
Buginator 8a11947b31 Let's only send the map to the person that needs the map.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7178 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-27 12:46:39 +02:00
Buginator 7ef71df9cb Fixes ticket:419
Add check to make sure logfile is available.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7169 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-27 12:46:38 +02:00
Buginator b095418a42 Fixes ticket: 369
Don't always assume that the (lobby) server will not be available, and give up on all future attempts.
We now reset the flag on NETclose().



git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7159 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-24 14:16:08 +02:00
Giel van Schijndel acd07fc7b4 * Add functions for retrieving the masterserver's hostname and port and game hosting port
* Use these functions to save configuration values (instead of duplicating them)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7091 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-20 15:31:23 +02:00
Buginator e9446f60b4 Backport r7084 to trunk also.
"remove dead code left in accidentally
Move a enum to netplay.h, and fix #include files so netplay.h comes before multiint.h"




git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7085 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-19 23:45:25 +02:00
Buginator c2e5d2462f Adds password support to warzone.
Adds feedback from the lobby server.

Notes: You have to enter a password *first*, and then either host the game, or join a game.

Thanks to elio for the new icons!


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7079 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-19 23:45:25 +02:00
Giel van Schijndel 1852caeff9 Get the size of a variable using "sizeof", not using the array size that was used for that variable (as the connection between the two is only obvious in the variable's declaration)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7066 4a71c877-e1ca-e34f-864e-861f7616d084
2009-04-18 22:39:51 +02:00