30 |
#include <Foundation/NSString.h> |
#include <Foundation/NSString.h> |
31 |
#include <Foundation/NSURL.h> |
#include <Foundation/NSURL.h> |
32 |
#include <Foundation/NSValue.h> |
#include <Foundation/NSValue.h> |
33 |
|
#include <Foundation/NSData.h> |
34 |
|
|
35 |
#include "Network/NetProtocol.h" |
#include "Network/NetProtocol.h" |
36 |
#include "Network/NetGameList.h" |
#include "Network/NetGameList.h" |
41 |
#include "GameEngine/HgPlayerState.h" |
#include "GameEngine/HgPlayerState.h" |
42 |
#include "GameEngine/HgGame.h" |
#include "GameEngine/HgGame.h" |
43 |
|
|
44 |
|
@interface NSData (Hack) |
45 |
|
+ (id) dataWithContentsOfURL: (NSURL*)url; |
46 |
|
@end |
47 |
|
|
48 |
|
@implementation NSData (Hack) |
49 |
|
/** |
50 |
|
* This method is redefined to not use the cache. |
51 |
|
*/ |
52 |
|
+ (id) dataWithContentsOfURL: (NSURL*)url |
53 |
|
{ |
54 |
|
NSData *d; |
55 |
|
|
56 |
|
d = [url resourceDataUsingCache: NO]; |
57 |
|
return d; |
58 |
|
} |
59 |
|
@end |
60 |
|
|
61 |
@interface NetGameList (Private) |
@interface NetGameList (Private) |
62 |
NSString * const _gameListURL = @"http://meta.hegemonie.org/html_game_list"; |
NSString * const _gameListURL = @"http://meta.hegemonie.org/html_game_list"; |
63 |
|
|
161 |
[self _clearGameList]; |
[self _clearGameList]; |
162 |
|
|
163 |
url = [NSURL URLWithString: _gameListURL]; |
url = [NSURL URLWithString: _gameListURL]; |
164 |
|
|
165 |
gamesArray = [NSArray arrayWithContentsOfURL: url]; |
gamesArray = [NSArray arrayWithContentsOfURL: url]; |
166 |
|
|
167 |
NSEnumerator *enumerator = [gamesArray objectEnumerator]; |
NSEnumerator *enumerator = [gamesArray objectEnumerator]; |
168 |
NSDictionary *infosServer; |
NSDictionary *infosServer; |
169 |
|
|
170 |
while ( (infosServer = [enumerator nextObject]) ) { |
while ( (infosServer = [enumerator nextObject]) ) { |
|
printf(" numplayers = %d\n", [[infosServer objectForKey: @"num_players"] |
|
|
intValue]); |
|
|
|
|
171 |
[self _addGameIDWithHost: [NSHost hostWithAddress: |
[self _addGameIDWithHost: [NSHost hostWithAddress: |
172 |
[infosServer objectForKey: @"address"]] |
[infosServer objectForKey: @"address"]] |
173 |
gameName: [infosServer objectForKey: @"game_name"] |
gameName: [infosServer objectForKey: @"game_name"] |
264 |
NSParameterAssert (master); |
NSParameterAssert (master); |
265 |
NSParameterAssert (mapName); |
NSParameterAssert (mapName); |
266 |
|
|
|
printf ("AddGameID\n"); |
|
|
printf ("numPlayers = %d\n", numPlayers); |
|
|
|
|
|
|
|
267 |
NetGameID *game = [[NetGameID alloc] initWithHost: host |
NetGameID *game = [[NetGameID alloc] initWithHost: host |
268 |
gameName: gameName |
gameName: gameName |
269 |
numPlayers: numPlayers |
numPlayers: numPlayers |