equal
deleted
inserted
replaced
25 ipcPort = 51342; |
25 ipcPort = 51342; |
26 return self; |
26 return self; |
27 } |
27 } |
28 |
28 |
29 -(void) dealloc { |
29 -(void) dealloc { |
30 [self.systemSettings release]; |
30 if (systemSettings) [self.systemSettings release]; |
31 [self.localeString autorelease]; |
31 [self.localeString autorelease]; |
32 [super dealloc]; |
32 [super dealloc]; |
33 } |
33 } |
34 |
34 |
35 #pragma mark - |
35 #pragma mark - |
82 serverQuit = NO; |
82 serverQuit = NO; |
83 while (!serverQuit) { |
83 while (!serverQuit) { |
84 |
84 |
85 /* This check the sd if there is a pending connection. |
85 /* This check the sd if there is a pending connection. |
86 * If there is one, accept that, and open a new socket for communicating */ |
86 * If there is one, accept that, and open a new socket for communicating */ |
87 if ((csd = SDLNet_TCP_Accept(sd))) { |
87 csd = SDLNet_TCP_Accept(sd); |
|
88 if (NULL != csd) { |
88 |
89 |
89 NSLog(@"engineProtocol - Client found"); |
90 NSLog(@"engineProtocol - Client found"); |
90 |
91 |
91 //first byte of the command alwayas contain the size of the command |
92 //first byte of the command alwayas contain the size of the command |
92 SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8)); |
93 SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8)); |
173 // team 2 ammostore |
174 // team 2 ammostore |
174 [self sendToEngine:@"eammstore 93919294221991210322351110012010000002110404000441400444645644444774776112211144"]; |
175 [self sendToEngine:@"eammstore 93919294221991210322351110012010000002110404000441400444645644444774776112211144"]; |
175 |
176 |
176 clientQuit = NO; |
177 clientQuit = NO; |
177 } else { |
178 } else { |
178 NSLog(@"engineProtocolThread - wrong message, closing connection"); |
179 NSLog(@"engineProtocolThread - wrong message or client closed connection"); |
179 clientQuit = YES; |
180 clientQuit = YES; |
180 } |
181 } |
181 |
182 |
182 while (!clientQuit){ |
183 while (!clientQuit){ |
183 /* Now we can communicate with the client using csd socket |
184 /* Now we can communicate with the client using csd socket |
224 break; |
225 break; |
225 default: |
226 default: |
226 // empty packet or just statistics |
227 // empty packet or just statistics |
227 break; |
228 break; |
228 // missing case for exiting right away |
229 // missing case for exiting right away |
229 } |
230 } |
230 } |
231 } |
|
232 NSLog(@"Client Exited"); |
|
233 // wait a little to let the client close cleanly |
|
234 sleep(5); |
|
235 // Close the client socket |
|
236 SDLNet_TCP_Close(csd); |
231 } |
237 } |
232 |
238 |
233 /* Close the client socket */ |
|
234 SDLNet_TCP_Close(csd); |
|
235 } |
239 } |
236 |
240 |
237 SDLNet_TCP_Close(sd); |
241 SDLNet_TCP_Close(sd); |
238 SDLNet_Quit(); |
242 SDLNet_Quit(); |
239 |
243 |
256 } |
260 } |
257 |
261 |
258 } |
262 } |
259 |
263 |
260 -(void) unloadSettings { |
264 -(void) unloadSettings { |
261 for (id obj in self) |
265 [systemSettings dealloc]; |
262 if ([obj isKindOfClass:[NSDictionary class]]) { |
|
263 [obj release]; |
|
264 } |
|
265 } |
266 } |
266 |
267 |
267 -(void) setArgsForLocalPlay { |
268 -(void) setArgsForLocalPlay { |
268 NSString *portNumber = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
269 NSString *portNumber = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
269 //NSString *username = [[NSString alloc] initWithString:[systemSettings objectForKey:@"username"]]; |
270 //NSString *username = [[NSString alloc] initWithString:[systemSettings objectForKey:@"username"]]; |