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
8e57c65386
Use "struct timeval" from winsock2.h instead of our own
...
On Windows <sys/time.h> doesn't exist (MinGW being an exception) and
"struct timeval" is thus defined in winsock2.h.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7285 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel
c48e302bcb
Lets use Winsock 2!
...
Even Windows 98 provides Winsock 2 (95 in an add on package). So we can
safely upgrade.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7284 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:35 +02:00
Giel van Schijndel
8f7322f717
Improve buildsystem for cross compiling
...
* Make sure to pass CXXFLAGS to ./configure as well
* Allow for overriding of CFLAGS and CXXFLAGS when building for the building system
- CFLAGS_FOR_BUILD
- CXXFLAGS_FOR_BUILD
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7283 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +02:00
Per Inge Mathisen
0a599f9818
Attempt to fix ticket:449 - Warzone crashed when destroyed repair facility. Reviewed by Zarel.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7281 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +02:00
Per Inge Mathisen
83cb5626e4
Stylistic cleanup of bridge code
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7280 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +02:00
Guangcong Luo
43f184fa22
Fix target prediction broken by Rhamphoryncus's patch.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7278 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +02:00
Giel van Schijndel
e0adf0d0e8
Revert r7276's accidental change to wzmasterserver.py
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7277 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +02:00
Giel van Schijndel
9943cf6b01
Lets not mark utility modules as executable
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7276 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:34 +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
8b7f17e2e5
Fix _swap_endianness() to return it's argument endian-swapped, not a tuple containing that result
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7273 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel
f8a70ebf2b
Lets not use an intermediate buffer for the MOTD before adding it to the console (as a message)
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7271 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
7e7ba74801
Move exception handling to the location where RequestHandler.handle(self) is being invoked from
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7269 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel
36dc3d8c6c
Use the RequestHandler's finish() method for cleaning up any open games instead of a try-finally block
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7268 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel
6618674111
Fix a syntax error from r7266 (and a disconnected spelling error while we're at it)
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7267 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:33 +02:00
Giel van Schijndel
0c7f44ee70
Make gamedblock intrinsic to GameDB itself (i.e. let it contain its own lock)
...
* Return generators instead of entire lists and have the generator keep the lock intact while it's being iterated over
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7266 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Giel van Schijndel
3153a9f63d
Make sure to reset the "requests" counter when checkInterval is reached
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7265 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Giel van Schijndel
563ff537a1
Lobbyserver: Use separate sockets to listen on IPv4 and IPv6 (instead of a single socket which uses IPv4 to IPv6 mapping)
...
* Use select(2) to wait for a connection on both sockets and accept(2)ing them in a separate thread
* This prevents IPv4 addresses from becoming IPv6 mapped, which might not be properly supported on all platforms
- The IPv6 mapped addresses where transferred back to clients
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7264 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Freddie Witherden
d0fec57acf
Minor indentation/spelling fixes in patternManager.[ch].
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7263 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Per Inge Mathisen
7bea80efd3
Please use setDroidActionTarget() whenever you change psActionTarget. This helps set dangling pointer debugging information.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7262 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Guangcong Luo
d18d80f979
More order/action bugfixes, and some miscellaneous bugfixes, namely:
...
* Make sure all turrets shoot at things they're ordered to shoot at
* Make sure all turrets shoot at things they're supposed to shoot at (this fixes all the multiturret behavior bugs)
* Stop an assert relating to auto-repair
* Internationalize "Hydra"
* Stop repair facility from trying to repair dead units
* Comment the update stage of DACTION_ATTACK and Repair Facility very well.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7260 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:32 +02:00
Guangcong Luo
d2c8a1ccad
Misc. multiplayer bugfixes.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7258 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +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
Per Inge Mathisen
73ea6f197e
Remove unused functions from text drawing code.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7253 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Per Inge Mathisen
b8d3c62005
Remove last of the useless statics from text drawing code.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7252 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Per Inge Mathisen
e5006affb7
Remove useless and unused statics from text drawing code.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7251 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:31 +02:00
Buginator
1f9e48ba86
Fixes compile issue that was broken in r7237.
...
In this case, 'Remove unnecessary SDL includes.' Removed the #include for C99 types that we use on non C99 compilers.
In case your wondering, using SDL_stdinc.h, since SDL_types.h is Deprecated.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7250 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +02:00
Giel van Schijndel
fb4c443dd8
Update the lobby server to still be in sync with the 2.2 lobby protocol which was changed in r7239
...
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@7249 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +02:00
Giel van Schijndel
b665aa67ba
Update the lobby server to still be in sync with the 2.2 lobby protocol which was changed in r7246
...
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@7248 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +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
Per Inge Mathisen
a9b8a20aa5
Make focusState a static to main.c, instead of a global from frame.c
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7240 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
Per Inge Mathisen
29a2b2fe35
Change SDL types to stdint.h defined types. Do not depend on SDL.h included system headers.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7238 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:30 +02:00
Per Inge Mathisen
8a0a0af7c0
Remove unnecessary SDL includes.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7237 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:29 +02:00
Guangcong Luo
f3281e7d89
Fix compiler error on a "suggestion".
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7235 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:29 +02:00
Guangcong Luo
c4d38188d3
Commit patch #413 : A minor fix to the order/action code, and a partial rewrite of the repair facility code. It fixes a few bugs, including:
...
Droids with Hold Position and Fire-At-Will will fire upon anything that comes within range.
Droids waiting for repair with Fire-At-Will will fire upon anything that comes within range.
Droids waiting for repair will "snap out of" whatever they're doing and get repaired when it's their turn at a repair facility (fixes bug #92 ).
Droids returning for repair that lose sight of their target will try again (might fix bug #360 ).
Trucks will not help enemies build structures (generally only happened if two trucks were going for the same oil resource).
Repair facilities with nothing better to do will repair nearby units.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7233 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:29 +02:00
Christian Ohm
b04a4a7412
Change some defaults:
...
- Use DejaVu Sans
- Don't pause on focus loss
- Use the whole window for videos
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7232 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 22:29:29 +02:00
Guangcong Luo
663321709e
Don't count cheated games as wins/losses in multiplayer stats.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7227 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 20:52:20 +02:00
Guangcong Luo
b8772dd066
Singleplayer crashfix.
...
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7226 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 20:52:19 +02:00
Giel van Schijndel
ebd93276a6
Make the lobby server listen and operate on IPv6
...
* Also disable IPV6_V6ONLY to make sure that (on systems that support the option) IPv4 is still supported, using the same socket
- This option works on Linux from 2.4.21 and 2.6 (according to "man ipv6")
- On FreeBSD this works from version 6 onward (lower versions might work, I only tested on 6 and 7 and didn't find any note in the manual)
- Furthermore, according to
http://en.wikipedia.org/wiki/IPv4_mapped_address :
* This works on Windows from Vista onward
* This works on NetBSD (version unspecified)
* This doesn't work on OpenBSD (as a design decision for security)
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7225 4a71c877-e1ca-e34f-864e-861f7616d084
2009-05-06 20:52:19 +02:00