diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-16 13:45:40 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-16 13:45:40 +0000 |
| commit | 2c160370499826609371fa9621b8c31aa8a8566a (patch) | |
| tree | 6941e47adc9915c03709f450450e02fda524f288 /src/net_multiplayer.c | |
| parent | b84b59153c587248ca8a6a94a6d93977e851233f (diff) | |
- siete boli prepisane do SDL_net
git-svn-id: http://opensvn.csie.org/tuxanci_ng@19 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/net_multiplayer.c')
| -rw-r--r-- | src/net_multiplayer.c | 171 |
1 files changed, 92 insertions, 79 deletions
diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c index 410ee99..84cb28d 100644 --- a/src/net_multiplayer.c +++ b/src/net_multiplayer.c @@ -15,6 +15,7 @@ #include "server.h" #include "tcp.h" #include "udp.h" +#include "sdl_udp.h" #ifndef BUBLIC_SERVER #include "screen.h" @@ -41,49 +42,58 @@ int initNetMuliplayer(int type, char *ip, int port) break; case NET_GAME_TYPE_SERVER : - switch( netProtoType ) +#ifdef SUPPORT_NET_UNIX_TCP + if( initTcpServer(port) != 0 ) { - case NET_PROTOCOL_TYPE_TCP : - if( initTcpServer(port) != 0 ) - { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); - netGameType = NET_GAME_TYPE_NONE; - return -1; - } - break; - case NET_PROTOCOL_TYPE_UDP : - if( initUdpServer(port) != 0 ) - { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); - netGameType = NET_GAME_TYPE_NONE; - return -1; - } - break; + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; } - +#endif +#ifdef SUPPORT_NET_UNIX_UDP + if( initUdpServer(port) != 0 ) + { + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; + } +#endif +#ifdef SUPPORT_NET_SDL_UDP + if( initSdlUdpServer(port) != 0 ) + { + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; + } +#endif break; #ifndef BUBLIC_SERVER case NET_GAME_TYPE_CLIENT : - switch( netProtoType ) +#ifdef SUPPORT_NET_UNIX_TCP + if( initTcpClient(ip, port) != 0 ) + { + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; + } +#endif +#ifdef SUPPORT_NET_UNIX_UDP + if( initUdpClient(ip, port) != 0 ) { - case NET_PROTOCOL_TYPE_TCP : - if( initTcpClient(ip, port) != 0 ) - { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); - netGameType = NET_GAME_TYPE_NONE; - return -1; - } - break; - case NET_PROTOCOL_TYPE_UDP : - if( initUdpClient(ip, port) != 0 ) - { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); - netGameType = NET_GAME_TYPE_NONE; - return -1; - } - break; + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; } +#endif +#ifdef SUPPORT_NET_SDL_UDP + if( initSdlUdpClient(ip, port) != 0 ) + { + fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); + netGameType = NET_GAME_TYPE_NONE; + return -1; + } +#endif break; #endif default : @@ -102,37 +112,40 @@ void eventNetMultiplayer() break; case NET_GAME_TYPE_SERVER : - switch( netProtoType ) - { - case NET_PROTOCOL_TYPE_TCP : - selectServerTcpSocket(); - eventClientListBuffer(); - eventPeriodicSyncClient(); - break; - case NET_PROTOCOL_TYPE_UDP : - selectServerUdpSocket(); - eventClientListBuffer(); - eventPeriodicSyncClient(); - break; - } +#ifdef SUPPORT_NET_UNIX_TCP + selectServerTcpSocket(); + eventClientListBuffer(); +#endif +#ifdef SUPPORT_NET_UNIX_UDP + selectServerUdpSocket(); + eventClientListBuffer(); + eventPeriodicSyncClient(); +#endif +#ifdef SUPPORT_NET_SDL_UDP + selectServerSdlUdpSocket(); + eventClientListBuffer(); + eventPeriodicSyncClient(); +#endif break; #ifndef BUBLIC_SERVER case NET_GAME_TYPE_CLIENT : - switch( netProtoType ) - { - case NET_PROTOCOL_TYPE_TCP : - selectClientTcpSocket(); - eventServerBuffer(); - break; - case NET_PROTOCOL_TYPE_UDP : - eventPingServer(); - selectClientUdpSocket(); - eventServerBuffer(); - break; - } - break; +#ifdef SUPPORT_NET_UNIX_TCP + selectClientTcpSocket(); + eventServerBuffer(); +#endif +#ifdef SUPPORT_NET_UNIX_UDP + eventPingServer(); + selectClientUdpSocket(); + eventServerBuffer(); +#endif +#ifdef SUPPORT_NET_SDL_UDP + eventPingServer(); + selectClientSdlUdpSocket(); + eventServerBuffer(); #endif +#endif + break; default : assert( ! "Premenna netGameType ma zlu hodnotu !" ); break; @@ -147,28 +160,28 @@ void quitNetMultiplayer() break; case NET_GAME_TYPE_SERVER : - switch( netProtoType ) - { - case NET_PROTOCOL_TYPE_TCP : - quitTcpServer(); - break; - case NET_PROTOCOL_TYPE_UDP : - quitUdpServer(); - break; - } +#ifdef SUPPORT_NET_UNIX_TCP + quitTcpServer(); +#endif +#ifdef SUPPORT_NET_UNIX_UDP + quitUdpServer(); +#endif +#ifdef SUPPORT_NET_SDL_UDP + quitSdlUdpServer(); +#endif break; #ifndef BUBLIC_SERVER case NET_GAME_TYPE_CLIENT : - switch( netProtoType ) - { - case NET_PROTOCOL_TYPE_TCP : - quitTcpClient(); - break; - case NET_PROTOCOL_TYPE_UDP : - quitUdpClient(); - break; - } +#ifdef SUPPORT_NET_UNIX_TCP + quitTcpClient(); +#endif +#ifdef SUPPORT_NET_UNIX_UDP + quitUdpClient(); +#endif +#ifdef SUPPORT_NET_SDL_UDP + quitSdlUdpClient(); +#endif break; #endif |