/[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.8 by thunder, Wed Jul 16 13:18:43 2003 UTC revision 1.9 by thunder, Thu Jul 17 16:11:47 2003 UTC
# Line 59  Line 59 
59   */   */
60  - (id) init  - (id) init
61  {  {
62    self = [super init];    self = [super init];  
     
63    if (self != nil)    if (self != nil)
64      {      {
65        _gameList = AUTORELEASE ([NSMutableArray array]);        _gameList = [[NSMutableArray init] alloc];
66      }      }
67        
68    return self;    return self;
# Line 84  Line 83 
83   * Research games on the local network to actualise the list and returns   * Research games on the local network to actualise the list and returns
84   * this NetGameID list.   * this NetGameID list.
85   */   */
86  - (NSArray *) searchGames  - (void) searchGames
87  {  {
88    NSDistantObject<NetServer> *server;    NSDistantObject<NetServer> *server;
89    unsigned int num = 1;    unsigned num = 1;
   unsigned int i;  
90    NSString *name;    NSString *name;
91    NSHost   *host;    NSHost   *host;
92        
# Line 108  Line 106 
106          NSString *nameRegisteredForParty;          NSString *nameRegisteredForParty;
107          NSDistantObject<NetParty> * party;                NSDistantObject<NetParty> * party;      
108                    
109            int i;
110          for (i = 1; i <= [partyNameList count]; i++)          for (i = 1; i <= [partyNameList count]; i++)
111            {            {
112              nameRegisteredForParty =  [NSString stringWithFormat: @"%@Party%d",              nameRegisteredForParty =  [NSString stringWithFormat: @"%@Party%d",
# Line 116  Line 115 
115              party = [NetConnection rootProxyForConnectionWithRegisteredName:              party = [NetConnection rootProxyForConnectionWithRegisteredName:
116                                       nameRegisteredForParty                                       nameRegisteredForParty
117                                     host: @"*"];                                     host: @"*"];
118              [self _addGameIDWithParty: party              [self _addGameIDWithParty: party
119                 withHost: host];                 withHost: host];
120            }            }
121        }        }
122    } while (server != nil);    } while (server != nil);
123      }
124    
125    - (NSArray *) gameList
126    {
127    return _gameList;    return _gameList;
128  }  }
129    
# Line 130  Line 132 
132   * On success, returns the NetClient created.   * On success, returns the NetClient created.
133   * Else, if this player's name is already use by an other player, returns nil.   * Else, if this player's name is already use by an other player, returns nil.
134   */   */
135  - (NetClient *) connectToGame: (NetGameID *)gameID  + (NetClient *) connectToGame: (NetGameID *)gameID
136                       withName: (NSString *)playerName                       withName: (NSString *)playerName
137  {  {
138    NSParameterAssert (gameID);    NSParameterAssert (gameID);
139    NSParameterAssert (playerName);    NSParameterAssert (playerName);
140    
141    HgGame *game;    HgGame *game;
   game = [[HgGame alloc] init];  
142    
143    NSPort *receivePort = [NSPort port];    NSPort *receivePort = [NSPort port];
144    
   printf("    - attente port\n");  
145    NSPort *sendPort = [[gameID party] connectWithName: playerName    NSPort *sendPort = [[gameID party] connectWithName: playerName
146                                              withPort: receivePort                                              withPort: receivePort
147                                              initGame: &game];                                              initGame: &game];
   printf("    - port renvoye\n");  
148    
149    RETAIN(game);    RETAIN(game);
150    
# Line 162  Line 161 
161                                   withGame: game];                                   withGame: game];
162    
163        [cnx setRootObject: client];        [cnx setRootObject: client];
164        [serverInfosClient createProxy];        [serverInfosClient registerClient];
       [serverInfosClient delegateClient];  
   
       //RELEASE(game);  
165    
166        return client;        return client;
167      }      }
168    else  
169      {    return nil;
       //RELEASE(game);  
       return nil;  
     }  
170  }  }
171    
172  @end  // End of NetGameList class implementation  @end  // End of NetGameList class implementation

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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