Cube  Artifact [4b142ee758]

Artifact 4b142ee75847c5f294d579f7b9bd921e3554cfd11ac4dc9b3fa27d2281c292f7:


#import "ServerInfo.h"

#include "cube.h"

@implementation ServerInfo
- (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