Convert several files to pure Objective-C
FossilOrigin-Name: eac9e3d9480c641e752bce15f24de48bbb77705cd44ef2bb9a04603ca04c67e1
This commit is contained in:
parent
2085a651bd
commit
565a845aaf
13 changed files with 84 additions and 55 deletions
42
src/ServerInfo.m
Normal file
42
src/ServerInfo.m
Normal file
|
@ -0,0 +1,42 @@
|
|||
#import "ServerInfo.h"
|
||||
|
||||
#include "cube.h"
|
||||
|
||||
@implementation ServerInfo
|
||||
+ (instancetype)infoWithName:(OFString *)name;
|
||||
{
|
||||
return [[self alloc] initWithName:name];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
_name = [name copy];
|
||||
_full = @"";
|
||||
_mode = 0;
|
||||
_numplayers = 0;
|
||||
_ping = 9999;
|
||||
_protocol = 0;
|
||||
_minremain = 0;
|
||||
_map = @"";
|
||||
_sdesc = @"";
|
||||
_address.host = ENET_HOST_ANY;
|
||||
_address.port = CUBE_SERVINFO_PORT;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (OFComparisonResult)compare:(id)otherObject
|
||||
{
|
||||
if (![otherObject isKindOfClass:ServerInfo.class])
|
||||
@throw [OFInvalidArgumentException exception];
|
||||
|
||||
if (_ping > [otherObject ping])
|
||||
return OFOrderedDescending;
|
||||
if (_ping < [otherObject ping])
|
||||
return OFOrderedAscending;
|
||||
|
||||
return [_name compare:[otherObject name]];
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue