00001
00002
00003
00004
00005
00006
00007
00008
00009 #import "MetaServerEntry.h"
00010
00011 @implementation MetaServerEntry : NSObject
00012
00013 - (id) init {
00014 self = [super init];
00015 if (self != nil) {
00016 statusStrings = [[NSArray alloc] initWithObjects:
00017 @"OPEN:",
00018 @"Wait queue:",
00019 @"Nobody",
00020 @"Timed out",
00021 @"No connection",
00022 @"Active",
00023 @"CANNOT CONNECT",
00024 @"DEFAULT SERVER",
00025 nil];
00026
00027 }
00028 return self;
00029 }
00030
00031
00032 - (void) setAddress:(NSString*) newAddress {
00033 [address release];
00034 address = newAddress;
00035 [address retain];
00036 }
00037
00038 - (void) setPort:(int)newPort {
00039 port = newPort;
00040 }
00041
00042 - (void) setTime:(int)newTime {
00043 time = newTime;
00044 }
00045
00046 - (void) setPlayers:(int)newPlayers {
00047 players = newPlayers;
00048 }
00049
00050 - (void) setStatus:(enum ServerStatusType)newStatus {
00051 status = newStatus;
00052 }
00053
00054 - (enum ServerGameType) setGameTypeWithString:(NSString *) line {
00055
00056 if ([line isEqualToString:@"P"]) {
00057 [self setGameType: PARADISE];
00058 } else if ([line isEqualToString:@"B"]) {
00059 [self setGameType: BRONCO];
00060 } else if ([line isEqualToString:@"H"]) {
00061 [self setGameType: HOCKEY];
00062 } else {
00063 [self setGameType: UNKNOWN];
00064 }
00065
00066 return [self gameType];
00067 }
00068
00069 - (enum ServerStatusType) setStatusWithString:(NSString *) line {
00070 for (int i = 0; i < [statusStrings count]; ++i) {
00071 if ([line compare:[statusStrings objectAtIndex:i]] != -1) {
00072 [self setStatus: i];
00073 return [self status];
00074 }
00075 }
00076 return ERROR;
00077 }
00078
00079 - (void) setGameType:(enum ServerGameType)newType {
00080 type = newType;
00081 }
00082
00083 - (void) setHasRSA:(bool)newRsa {
00084 rsa = newRsa;
00085 }
00086
00087
00088 - (NSString*) address {
00089 return address;
00090 }
00091
00092 - (int) port {
00093 return port;
00094 }
00095
00096 - (int) time {
00097 return time;
00098 }
00099
00100 - (int) players {
00101 return players;
00102 }
00103
00104 - (enum ServerStatusType) status {
00105 return status;
00106 }
00107
00108 - (NSString*) statusString {
00109
00110 switch (status) {
00111 case OPEN:
00112 return @"Open";
00113 break;
00114 case WAIT:
00115 return @"Wait";
00116 break;
00117 case NOBODY:
00118 return @"Nobody";
00119 break;
00120 case TIME_OUT:
00121 return @"Time Out";
00122 break;
00123 case NO_CONNECT:
00124 return @"No Connection";
00125 break;
00126 case NO_VALUE:
00127 return @"No Value";
00128 break;
00129 case DEFAULT:
00130 return @"DEFAULT";
00131 break;
00132 case CANNOT_CONNECT:
00133 return @"Cannot Connect";
00134 break;
00135 default:
00136 return @"ERROR";
00137 break;
00138 }
00139 }
00140
00141 - (NSString*) gameTypeString {
00142
00143 switch (type) {
00144 case BRONCO:
00145 return @"Bronco";
00146 break;
00147 case PARADISE:
00148 return @"Paradise";
00149 break;
00150 case HOCKEY:
00151 return @"Hockey";
00152 break;
00153 default:
00154 return @"Unknown";
00155 break;
00156 }
00157 }
00158
00159 - (enum ServerGameType) gameType {
00160 return type;
00161 }
00162
00163 - (bool) hasRSA {
00164 return rsa;
00165 }
00166
00167 @end