22 #import "ServerSetup.h" |
22 #import "ServerSetup.h" |
23 #import "PascalImports.h" |
23 #import "PascalImports.h" |
24 #import "CommodityFunctions.h" |
24 #import "CommodityFunctions.h" |
25 #import <SystemConfiguration/SCNetworkReachability.h> |
25 #import <SystemConfiguration/SCNetworkReachability.h> |
26 #import <netinet/in.h> |
26 #import <netinet/in.h> |
|
27 #import "hwconsts.h" |
27 |
28 |
28 #define BUFFER_SIZE 256 |
29 #define BUFFER_SIZE 256 |
29 |
30 |
30 @implementation ServerSetup |
31 @implementation ServerSetup |
31 @synthesize systemSettings; |
32 @synthesize systemSettings; |
103 DLog(@"SDLNet_Init: %s", SDLNet_GetError()); |
104 DLog(@"SDLNet_Init: %s", SDLNet_GetError()); |
104 clientQuit = YES; |
105 clientQuit = YES; |
105 } |
106 } |
106 |
107 |
107 // Resolving the host using NULL make network interface to listen |
108 // Resolving the host using NULL make network interface to listen |
108 if (SDLNet_ResolveHost(&ip, "netserver.hedgewars.org", DEFAULT_NETGAME_PORT) < 0 && !clientQuit) { |
109 if (SDLNet_ResolveHost(&ip, "netserver.hedgewars.org", NETGAME_DEFAULT_PORT) < 0 && !clientQuit) { |
109 DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError()); |
110 DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError()); |
110 clientQuit = YES; |
111 clientQuit = YES; |
111 } |
112 } |
112 |
113 |
113 // Open a connection with the IP provided (listen on the host's port) |
114 // Open a connection with the IP provided (listen on the host's port) |
114 if (!(sd = SDLNet_TCP_Open(&ip)) && !clientQuit) { |
115 if (!(sd = SDLNet_TCP_Open(&ip)) && !clientQuit) { |
115 DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), DEFAULT_NETGAME_PORT); |
116 DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), NETGAME_DEFAULT_PORT); |
116 clientQuit = YES; |
117 clientQuit = YES; |
117 } |
118 } |
118 |
119 |
119 DLog(@"Found server on port %d", DEFAULT_NETGAME_PORT); |
120 DLog(@"Found server on port %d", NETGAME_DEFAULT_PORT); |
120 while (!clientQuit) { |
121 while (!clientQuit) { |
121 int index = 0; |
122 int index = 0; |
122 BOOL exitBufferLoop = NO; |
123 BOOL exitBufferLoop = NO; |
123 memset(buffer, '\0', dim); |
124 memset(buffer, '\0', dim); |
124 |
125 |