/[hegemonie]/hegemonie/Network/NetGameList.m
ViewVC logotype

Diff of /hegemonie/Network/NetGameList.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by nicov, Tue Jul 22 10:08:40 2003 UTC revision 1.13 by nicov, Fri Jul 25 13:34:47 2003 UTC
# Line 30  Line 30 
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"
# Line 40  Line 41 
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    
# Line 143  NSString * const _gameListURL = @"http:/ Line 161  NSString * const _gameListURL = @"http:/
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"]
# Line 249  NSString * const _gameListURL = @"http:/ Line 264  NSString * const _gameListURL = @"http:/
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

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26