diff options
author | Simon Howard | 2006-10-05 17:18:14 +0000 |
---|---|---|
committer | Simon Howard | 2006-10-05 17:18:14 +0000 |
commit | 14a26c3d0825a67eedffa37af5fb463776c4a7bb (patch) | |
tree | 5320a3ef6b86f881b5063bdd5d3845178f587713 | |
parent | 433a6e9e411fb188991d5d78df4b04dd81b2baac (diff) | |
download | chocolate-doom-14a26c3d0825a67eedffa37af5fb463776c4a7bb.tar.gz chocolate-doom-14a26c3d0825a67eedffa37af5fb463776c4a7bb.tar.bz2 chocolate-doom-14a26c3d0825a67eedffa37af5fb463776c4a7bb.zip |
Packet loss simulation code for test.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 684
-rw-r--r-- | src/net_sdl.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/net_sdl.c b/src/net_sdl.c index 820c9ca9..56ab0c59 100644 --- a/src/net_sdl.c +++ b/src/net_sdl.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_sdl.c 611 2006-09-17 18:01:16Z fraggle $ +// $Id: net_sdl.c 684 2006-10-05 17:18:14Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -189,6 +189,10 @@ static boolean NET_SDL_InitClient(void) recvpacket = SDLNet_AllocPacket(1500); +#ifdef DROP_PACKETS + srand(time(NULL)); +#endif + return true; } @@ -210,6 +214,9 @@ static boolean NET_SDL_InitServer(void) } recvpacket = SDLNet_AllocPacket(1500); +#ifdef DROP_PACKETS + srand(time(NULL)); +#endif return true; } @@ -245,6 +252,11 @@ static void NET_SDL_SendPacket(net_addr_t *addr, net_packet_t *packet) } #endif +#ifdef DROP_PACKETS + if ((rand() % 4) == 0) + return; +#endif + sdl_packet.channel = 0; sdl_packet.data = packet->data; sdl_packet.len = packet->len; |