summaryrefslogtreecommitdiff
path: root/src/base/net_multiplayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/net_multiplayer.c')
-rw-r--r--src/base/net_multiplayer.c169
1 files changed, 82 insertions, 87 deletions
diff --git a/src/base/net_multiplayer.c b/src/base/net_multiplayer.c
index bfd4f94..d967413 100644
--- a/src/base/net_multiplayer.c
+++ b/src/base/net_multiplayer.c
@@ -15,125 +15,120 @@
#include "udp.h"
#ifndef PUBLIC_SERVER
-#include "screen_setting.h"
-#include "screen_choiceArena.h"
+# include "screen_setting.h"
+# include "screen_choiceArena.h"
-#include "screen.h"
-#include "client.h"
+# include "screen.h"
+# include "client.h"
#endif
static int netGameType;
-int
-getNetTypeGame()
+int getNetTypeGame()
{
- return netGameType;
+ return netGameType;
}
-int
-initNetMuliplayerForGameServer(char *ip4, int port4, char *ip6, int port6)
+int initNetMuliplayerForGameServer(char *ip4, int port4, char *ip6, int port6)
{
- int ret;
+ int ret;
- ret = initServer(ip4, port4, ip6, port6);
+ ret = initServer(ip4, port4, ip6, port6);
- if (ret > 0) {
- netGameType = NET_GAME_TYPE_SERVER;
- }
+ if (ret > 0) {
+ netGameType = NET_GAME_TYPE_SERVER;
+ }
- return ret;
+ return ret;
}
-int
-initNetMuliplayer(int type, char *ip, int port, int proto)
+int initNetMuliplayer(int type, char *ip, int port, int proto)
{
- netGameType = type;
-
- switch (netGameType) {
- case NET_GAME_TYPE_NONE:
- break;
-
- case NET_GAME_TYPE_SERVER:
- switch (proto) {
- case PROTO_UDPv4:
- if (initServer(ip, port, NULL, 0) != 1) {
- fprintf(stderr,
- _("Unable to inicialize network game as server!\n"));
- netGameType = NET_GAME_TYPE_NONE;
- return -1;
- }
- break;
- case PROTO_UDPv6:
- if (initServer(NULL, 0, ip, port) != 1) {
- fprintf(stderr,
- _("Unable to inicialize network game as server!\n"));
- netGameType = NET_GAME_TYPE_NONE;
- return -1;
- }
- break;
- }
- break;
+ netGameType = type;
+
+ switch (netGameType) {
+ case NET_GAME_TYPE_NONE:
+ break;
+
+ case NET_GAME_TYPE_SERVER:
+ switch (proto) {
+ case PROTO_UDPv4:
+ if (initServer(ip, port, NULL, 0) != 1) {
+ fprintf(stderr,
+ _("Unable to inicialize network game as server!\n"));
+ netGameType = NET_GAME_TYPE_NONE;
+ return -1;
+ }
+ break;
+ case PROTO_UDPv6:
+ if (initServer(NULL, 0, ip, port) != 1) {
+ fprintf(stderr,
+ _("Unable to inicialize network game as server!\n"));
+ netGameType = NET_GAME_TYPE_NONE;
+ return -1;
+ }
+ break;
+ }
+ break;
#ifndef PUBLIC_SERVER
- case NET_GAME_TYPE_CLIENT:
- if (initClient(ip, port, proto) != 0) {
- fprintf(stderr,
- _("Unable to inicialize network game as client!\n"));
- netGameType = NET_GAME_TYPE_NONE;
- return -1;
- }
- break;
+ case NET_GAME_TYPE_CLIENT:
+ if (initClient(ip, port, proto) != 0) {
+ fprintf(stderr,
+ _("Unable to inicialize network game as client!\n"));
+ netGameType = NET_GAME_TYPE_NONE;
+ return -1;
+ }
+ break;
#endif
- default:
- assert(!_("Variable netGameType has a really weird value!"));
- break;
- }
+ default:
+ assert(!_("Variable netGameType has a really weird value!"));
+ break;
+ }
- return 0;
+ return 0;
}
-void
-eventNetMultiplayer()
+void eventNetMultiplayer()
{
- switch (netGameType) {
- case NET_GAME_TYPE_NONE:
- break;
+ switch (netGameType) {
+ case NET_GAME_TYPE_NONE:
+ break;
- case NET_GAME_TYPE_SERVER:
- eventServer();
- break;
+ case NET_GAME_TYPE_SERVER:
+ eventServer();
+ break;
#ifndef PUBLIC_SERVER
- case NET_GAME_TYPE_CLIENT:
- eventClient();
- break;
+ case NET_GAME_TYPE_CLIENT:
+ eventClient();
+ break;
#endif
- default:
- assert(!_("Variable netGameType has a really weird value!"));
- break;
- }
+ default:
+ assert(!_("Variable netGameType has a really weird value!"));
+ break;
+ }
}
-void
-quitNetMultiplayer()
+void quitNetMultiplayer()
{
- switch (netGameType) {
- case NET_GAME_TYPE_NONE:
- break;
+ switch (netGameType) {
+ case NET_GAME_TYPE_NONE:
+ break;
- case NET_GAME_TYPE_SERVER:
- quitServer();
- break;
+ case NET_GAME_TYPE_SERVER:
+ quitServer();
+ break;
#ifndef PUBLIC_SERVER
- case NET_GAME_TYPE_CLIENT:
- quitClient();
- break;
+ case NET_GAME_TYPE_CLIENT:
+ quitClient();
+ break;
#endif
- default:
- assert(!_("Variable netGameType has a really weird value!"));
- break;
- }
+ default:
+ assert(!_("Variable netGameType has a really weird value!"));
+ break;
+ }
- netGameType = NET_GAME_TYPE_NONE;
+ netGameType = NET_GAME_TYPE_NONE;
}