Switch from clang-format to manual formatting
clang-format does too many weird things. FossilOrigin-Name: 75e920ae307d96d6ce0141652617959f609c21b542e930cb537789298856c480
This commit is contained in:
parent
3a081f18e5
commit
d3dc40de33
62 changed files with 945 additions and 991 deletions
|
@ -1,45 +0,0 @@
|
||||||
IndentWidth: 8
|
|
||||||
TabWidth: 8
|
|
||||||
UseTab: ForIndentation
|
|
||||||
ColumnLimit: 80
|
|
||||||
BreakBeforeBinaryOperators: None
|
|
||||||
BreakBeforeBraces: Custom
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BraceWrapping:
|
|
||||||
AfterClass: false
|
|
||||||
AfterControlStatement: false
|
|
||||||
AfterEnum: false
|
|
||||||
AfterFunction: true
|
|
||||||
AfterNamespace: false
|
|
||||||
AfterObjCDeclaration: true
|
|
||||||
AfterStruct: false
|
|
||||||
AfterUnion: false
|
|
||||||
AfterExternBlock: false
|
|
||||||
BeforeCatch: false
|
|
||||||
BeforeElse: false
|
|
||||||
AlwaysBreakAfterReturnType: AllDefinitions
|
|
||||||
AlignAfterOpenBracket: DontAlign
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AlignOperands: DontAlign
|
|
||||||
Cpp11BracedListStyle: false
|
|
||||||
SpaceBeforeCpp11BracedList: true
|
|
||||||
ObjCBlockIndentWidth: 8
|
|
||||||
ObjCSpaceAfterProperty: true
|
|
||||||
ObjCSpaceBeforeProtocolList: true
|
|
||||||
ObjCPropertyAttributeOrder: [
|
|
||||||
class, direct,
|
|
||||||
readonly, readwrite,
|
|
||||||
nullable, nonnull, null_resettable, null_unspecified,
|
|
||||||
assign, retain, strong, copy, weak, unsafe_unretained,
|
|
||||||
atomic, nonatomic,
|
|
||||||
getter, setter
|
|
||||||
]
|
|
||||||
SpaceBeforeInheritanceColon: false
|
|
||||||
QualifierAlignment: Left
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
#RemoveEmptyLinesInUnwrappedLines: true
|
|
||||||
RemoveSemicolon: true
|
|
||||||
CompactNamespaces: true
|
|
||||||
SortIncludes: CaseSensitive
|
|
||||||
IndentPPDirectives: AfterHash
|
|
||||||
PPIndentWidth: 1
|
|
59
src/Cube.m
59
src/Cube.m
|
@ -145,42 +145,24 @@ VARP(minmillis, 0, 5, 1000);
|
||||||
|
|
||||||
log(@"basetex");
|
log(@"basetex");
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
if (!installtex(2,
|
if (!installtex(2, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
[_gameDataIRI
|
@"data/newchars.png"], &xs, &ys, false) ||
|
||||||
IRIByAppendingPathComponent:@"data/newchars.png"],
|
!installtex(3, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
&xs, &ys, false) ||
|
@"data/martin/base.png"], &xs, &ys, false) ||
|
||||||
!installtex(3,
|
!installtex(6, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
[_gameDataIRI IRIByAppendingPathComponent:
|
@"data/martin/ball1.png"], &xs, &ys, false) ||
|
||||||
@"data/martin/base.png"],
|
!installtex(7, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
&xs, &ys, false) ||
|
@"data/martin/smoke.png"], &xs, &ys, false) ||
|
||||||
!installtex(6,
|
!installtex(8, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
[_gameDataIRI IRIByAppendingPathComponent:
|
@"data/martin/ball2.png"], &xs, &ys, false) ||
|
||||||
@"data/martin/ball1.png"],
|
!installtex(9, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
&xs, &ys, false) ||
|
@"data/martin/ball3.png"], &xs, &ys, false) ||
|
||||||
!installtex(7,
|
!installtex(4, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
[_gameDataIRI IRIByAppendingPathComponent:
|
@"data/explosion.jpg"], &xs, &ys, false) ||
|
||||||
@"data/martin/smoke.png"],
|
!installtex(5, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
&xs, &ys, false) ||
|
@"data/items.png"], &xs, &ys, false) ||
|
||||||
!installtex(8,
|
!installtex(1, [_gameDataIRI IRIByAppendingPathComponent:
|
||||||
[_gameDataIRI IRIByAppendingPathComponent:
|
@"data/crosshair.png"], &xs, &ys, false))
|
||||||
@"data/martin/ball2.png"],
|
|
||||||
&xs, &ys, false) ||
|
|
||||||
!installtex(9,
|
|
||||||
[_gameDataIRI IRIByAppendingPathComponent:
|
|
||||||
@"data/martin/ball3.png"],
|
|
||||||
&xs, &ys, false) ||
|
|
||||||
!installtex(4,
|
|
||||||
[_gameDataIRI
|
|
||||||
IRIByAppendingPathComponent:@"data/explosion.jpg"],
|
|
||||||
&xs, &ys, false) ||
|
|
||||||
!installtex(5,
|
|
||||||
[_gameDataIRI
|
|
||||||
IRIByAppendingPathComponent:@"data/items.png"],
|
|
||||||
&xs, &ys, false) ||
|
|
||||||
!installtex(1,
|
|
||||||
[_gameDataIRI
|
|
||||||
IRIByAppendingPathComponent:@"data/crosshair.png"],
|
|
||||||
&xs, &ys, false))
|
|
||||||
fatal(@"could not find core textures (hint: run cube "
|
fatal(@"could not find core textures (hint: run cube "
|
||||||
@"from the parent of the bin directory)");
|
@"from the parent of the bin directory)");
|
||||||
|
|
||||||
|
@ -339,9 +321,8 @@ VARP(minmillis, 0, 5, 1000);
|
||||||
endianswap(dest, 3, _width);
|
endianswap(dest, 3, _width);
|
||||||
}
|
}
|
||||||
|
|
||||||
OFString *path = [OFString
|
OFString *path = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"screenshots/screenshot_%d.bmp",
|
@"screenshots/screenshot_%d.bmp", lastmillis];
|
||||||
lastmillis];
|
|
||||||
SDL_SaveBMP(temp,
|
SDL_SaveBMP(temp,
|
||||||
[_userDataIRI IRIByAppendingPathComponent: path]
|
[_userDataIRI IRIByAppendingPathComponent: path]
|
||||||
.fileSystemRepresentation.UTF8String);
|
.fileSystemRepresentation.UTF8String);
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
snap: (int)snap
|
snap: (int)snap
|
||||||
name: (OFString *)name
|
name: (OFString *)name
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithRad:rad h:h zoff:zoff snap:snap name:name];
|
return [[self alloc] initWithRad: rad
|
||||||
|
h: h
|
||||||
|
zoff: zoff
|
||||||
|
snap: snap
|
||||||
|
name: name];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithRad: (int)rad
|
- (instancetype)initWithRad: (int)rad
|
||||||
|
|
|
@ -305,7 +305,10 @@ enemylos(Monster *m, OFVector3D *v)
|
||||||
case M_ATTACKING:
|
case M_ATTACKING:
|
||||||
case M_SEARCH:
|
case M_SEARCH:
|
||||||
if (self.trigger < lastmillis)
|
if (self.trigger < lastmillis)
|
||||||
[self transitionWithState:M_HOME moving:1 n:100 r:200];
|
[self transitionWithState: M_HOME
|
||||||
|
moving: 1
|
||||||
|
n: 100
|
||||||
|
r: 200];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_SLEEP: // state classic sp monster start in, wait for visual
|
case M_SLEEP: // state classic sp monster start in, wait for visual
|
||||||
|
@ -321,7 +324,10 @@ enemylos(Monster *m, OFVector3D *v)
|
||||||
|| (disttoenemy < 16 && angle < 135) ||
|
|| (disttoenemy < 16 && angle < 135) ||
|
||||||
(disttoenemy < 32 && angle < 90) ||
|
(disttoenemy < 32 && angle < 90) ||
|
||||||
(disttoenemy < 64 && angle < 45) || angle < 10) {
|
(disttoenemy < 64 && angle < 45) || angle < 10) {
|
||||||
[self transitionWithState:M_HOME moving:1 n:500 r:200];
|
[self transitionWithState: M_HOME
|
||||||
|
moving: 1
|
||||||
|
n: 500
|
||||||
|
r: 200];
|
||||||
OFVector3D loc = self.origin;
|
OFVector3D loc = self.origin;
|
||||||
playsound(S_GRUNT1 + rnd(2), &loc);
|
playsound(S_GRUNT1 + rnd(2), &loc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@ OF_DIRECT_MEMBERS
|
||||||
@property (readonly, nonatomic) OFString *query;
|
@property (readonly, nonatomic) OFString *query;
|
||||||
@property (readonly, nonatomic) ENetAddress address;
|
@property (readonly, nonatomic) ENetAddress address;
|
||||||
|
|
||||||
+ (instancetype)resultWithQuery:(OFString *)query address:(ENetAddress)address;
|
+ (instancetype)resultWithQuery: (OFString *)query
|
||||||
|
address: (ENetAddress)address;
|
||||||
- (instancetype)init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
- (instancetype)initWithQuery:(OFString *)query address:(ENetAddress)address;
|
- (instancetype)initWithQuery: (OFString *)query
|
||||||
|
address: (ENetAddress)address OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -25,8 +25,8 @@ extern OFMutableArray<ResolverResult *> *resolverresults;
|
||||||
enet_address_set_host(&address, _query.UTF8String);
|
enet_address_set_host(&address, _query.UTF8String);
|
||||||
|
|
||||||
@synchronized(ResolverThread.class) {
|
@synchronized(ResolverThread.class) {
|
||||||
[resolverresults
|
[resolverresults addObject:
|
||||||
addObject:[ResolverResult resultWithQuery:_query
|
[ResolverResult resultWithQuery: _query
|
||||||
address: address]];
|
address: address]];
|
||||||
|
|
||||||
_query = NULL;
|
_query = NULL;
|
||||||
|
|
|
@ -35,7 +35,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
}); \
|
}); \
|
||||||
}
|
}
|
||||||
#define VARF(name, min_, cur, max_, body) \
|
#define VARF(name, min_, cur, max_, body) \
|
||||||
static void var_##name(); \
|
static void var_##name(void); \
|
||||||
static int name = cur; \
|
static int name = cur; \
|
||||||
\
|
\
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
|
@ -52,9 +52,13 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
}); \
|
}); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void var_##name() { body; }
|
static void \
|
||||||
|
var_##name(void) \
|
||||||
|
{ \
|
||||||
|
body; \
|
||||||
|
}
|
||||||
#define VARFP(name, min_, cur, max_, body) \
|
#define VARFP(name, min_, cur, max_, body) \
|
||||||
static void var_##name(); \
|
static void var_##name(void); \
|
||||||
static int name = cur; \
|
static int name = cur; \
|
||||||
\
|
\
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
|
@ -71,7 +75,11 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
}); \
|
}); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void var_##name() { body; }
|
static void \
|
||||||
|
var_##name(void) \
|
||||||
|
{ \
|
||||||
|
body; \
|
||||||
|
}
|
||||||
|
|
||||||
@interface Variable: Identifier
|
@interface Variable: Identifier
|
||||||
@property (direct, readonly, nonatomic) int min, max;
|
@property (direct, readonly, nonatomic) int min, max;
|
||||||
|
|
|
@ -51,21 +51,21 @@ renderclient(
|
||||||
// mdl = (((int)d>>6)&1)+1;
|
// mdl = (((int)d>>6)&1)+1;
|
||||||
// mz = d.o.z-d.eyeHeight+0.2f;
|
// mz = d.o.z-d.eyeHeight+0.2f;
|
||||||
// scale = 1.2f;
|
// scale = 1.2f;
|
||||||
} else if (d.state == CS_EDITING) {
|
} else if (d.state == CS_EDITING)
|
||||||
n = 16;
|
n = 16;
|
||||||
} else if (d.state == CS_LAGGED) {
|
else if (d.state == CS_LAGGED)
|
||||||
n = 17;
|
n = 17;
|
||||||
} else if ([d isKindOfClass:Monster.class] &&
|
else if ([d isKindOfClass: Monster.class] &&
|
||||||
((Monster *)d).monsterState == M_ATTACKING) {
|
((Monster *)d).monsterState == M_ATTACKING)
|
||||||
n = 8;
|
n = 8;
|
||||||
} else if ([d isKindOfClass:Monster.class] &&
|
else if ([d isKindOfClass: Monster.class] &&
|
||||||
((Monster *)d).monsterState == M_PAIN) {
|
((Monster *)d).monsterState == M_PAIN)
|
||||||
n = 10;
|
n = 10;
|
||||||
} else if ((!d.move && !d.strafe) || !d.moving) {
|
else if ((!d.move && !d.strafe) || !d.moving)
|
||||||
n = 12;
|
n = 12;
|
||||||
} else if (!d.onFloor && d.timeInAir > 100) {
|
else if (!d.onFloor && d.timeInAir > 100)
|
||||||
n = 18;
|
n = 18;
|
||||||
} else {
|
else {
|
||||||
n = 14;
|
n = 14;
|
||||||
speed = 1200 / d.maxSpeed * scale;
|
speed = 1200 / d.maxSpeed * scale;
|
||||||
if (hellpig)
|
if (hellpig)
|
||||||
|
@ -86,13 +86,12 @@ extern int democlientnum;
|
||||||
void
|
void
|
||||||
renderclients()
|
renderclients()
|
||||||
{
|
{
|
||||||
[players
|
[players enumerateObjectsUsingBlock: ^ (Player *player, size_t i,
|
||||||
enumerateObjectsUsingBlock:^(Player *player, size_t i, bool *stop) {
|
bool *stop) {
|
||||||
if ([player isKindOfClass: Player.class] &&
|
if ([player isKindOfClass: Player.class] &&
|
||||||
(!demoplayback || i != democlientnum))
|
(!demoplayback || i != democlientnum))
|
||||||
renderclient(player,
|
renderclient(player, isteam(Player.player1.team,
|
||||||
isteam(Player.player1.team, [player team]),
|
[player team]), @"monster/ogro", false, 1.0f);
|
||||||
@"monster/ogro", false, 1.0f);
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +168,8 @@ renderscores()
|
||||||
addteamscore(Player.player1);
|
addteamscore(Player.player1);
|
||||||
OFMutableString *teamScores = [OFMutableString string];
|
OFMutableString *teamScores = [OFMutableString string];
|
||||||
for (size_t j = 0; j < teamsUsed; j++)
|
for (size_t j = 0; j < teamsUsed; j++)
|
||||||
[teamScores appendFormat:@"[ %@: %d ]", teamName[j],
|
[teamScores appendFormat:
|
||||||
teamScore[j]];
|
@"[ %@: %d ]", teamName[j], teamScore[j]];
|
||||||
menumanual(0, scoreLines.count, @"");
|
menumanual(0, scoreLines.count, @"");
|
||||||
menumanual(0, scoreLines.count + 1, teamScores);
|
menumanual(0, scoreLines.count + 1, teamScores);
|
||||||
}
|
}
|
||||||
|
@ -204,10 +203,8 @@ COMMAND(sendmap, ARG_1STR, (^(OFString *mapname) {
|
||||||
enet_packet_resize(packet, p - start);
|
enet_packet_resize(packet, p - start);
|
||||||
sendpackettoserv(packet);
|
sendpackettoserv(packet);
|
||||||
conoutf(@"sending map %@ to server...", mapname);
|
conoutf(@"sending map %@ to server...", mapname);
|
||||||
OFString *msg =
|
OFString *msg = [OFString stringWithFormat:
|
||||||
[OFString stringWithFormat:@"[map %@ uploaded to server, "
|
@"[map %@ uploaded to server, \"getmap\" to receive it]", mapname];
|
||||||
@"\"getmap\" to receive it]",
|
|
||||||
mapname];
|
|
||||||
toserver(msg);
|
toserver(msg);
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@ extern int democlientnum;
|
||||||
void
|
void
|
||||||
otherplayers()
|
otherplayers()
|
||||||
{
|
{
|
||||||
[players
|
[players enumerateObjectsUsingBlock: ^ (Player *player, size_t i,
|
||||||
enumerateObjectsUsingBlock:^(Player *player, size_t i, bool *stop) {
|
bool *stop) {
|
||||||
if ([player isKindOfClass: Player.class])
|
if ([player isKindOfClass: Player.class])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ COMMAND(team, ARG_1STR, ^(OFString *name) {
|
||||||
void
|
void
|
||||||
writeclientinfo(OFStream *stream)
|
writeclientinfo(OFStream *stream)
|
||||||
{
|
{
|
||||||
[stream writeFormat:@"name \"%@\"\nteam \"%@\"\n", Player.player1.name,
|
[stream writeFormat: @"name \"%@\"\nteam \"%@\"\n",
|
||||||
Player.player1.team];
|
Player.player1.name, Player.player1.team];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -317,8 +317,7 @@ c2sinfo(Player *d)
|
||||||
putint(&p, (int)(d.velocity.y * DVF));
|
putint(&p, (int)(d.velocity.y * DVF));
|
||||||
putint(&p, (int)(d.velocity.z * DVF));
|
putint(&p, (int)(d.velocity.z * DVF));
|
||||||
// pack rest in 1 byte: strafe:2, move:2, onFloor:1, state:3
|
// pack rest in 1 byte: strafe:2, move:2, onFloor:1, state:3
|
||||||
putint(&p,
|
putint(&p, (d.strafe & 3) | ((d.move & 3) << 2) |
|
||||||
(d.strafe & 3) | ((d.move & 3) << 2) |
|
|
||||||
(((int)d.onFloor) << 4) |
|
(((int)d.onFloor) << 4) |
|
||||||
((editmode ? CS_EDITING : d.state) << 5));
|
((editmode ? CS_EDITING : d.state) << 5));
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,10 @@ localservertoclient(unsigned char *buf, int len)
|
||||||
// server requests next map
|
// server requests next map
|
||||||
case SV_MAPRELOAD: {
|
case SV_MAPRELOAD: {
|
||||||
getint(&p);
|
getint(&p);
|
||||||
OFString *nextmapalias = [OFString
|
OFString *nextmapalias = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"nextmap_%@", getclientmap()];
|
@"nextmap_%@", getclientmap()];
|
||||||
OFString *map =
|
// look up map in the cycle
|
||||||
getalias(nextmapalias); // look up map in the cycle
|
OFString *map = getalias(nextmapalias);
|
||||||
changemap(map != nil ? map : getclientmap());
|
changemap(map != nil ? map : getclientmap());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ parseexp(char **p, int right)
|
||||||
if (left == '(') {
|
if (left == '(') {
|
||||||
OFString *t;
|
OFString *t;
|
||||||
@try {
|
@try {
|
||||||
t = [OFString
|
t = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"%d", execute(@(s), true)];
|
@"%d", execute(@(s), true)];
|
||||||
} @finally {
|
} @finally {
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,8 @@ lookup(OFString *n)
|
||||||
Identifier.identifiers[[n substringFromIndex: 1]];
|
Identifier.identifiers[[n substringFromIndex: 1]];
|
||||||
|
|
||||||
if ([identifier isKindOfClass: Variable.class]) {
|
if ([identifier isKindOfClass: Variable.class]) {
|
||||||
return [OFString stringWithFormat:@"%d", *[identifier storage]];
|
return [OFString stringWithFormat:
|
||||||
|
@"%d", *[identifier storage]];
|
||||||
} else if ([identifier isKindOfClass: Alias.class])
|
} else if ([identifier isKindOfClass: Alias.class])
|
||||||
return [identifier action];
|
return [identifier action];
|
||||||
|
|
||||||
|
@ -180,8 +181,8 @@ executeIdentifier(__kindof Identifier *identifier,
|
||||||
if (arguments.count < 2 || arguments[1].length == 0)
|
if (arguments.count < 2 || arguments[1].length == 0)
|
||||||
[identifier printValue];
|
[identifier printValue];
|
||||||
else
|
else
|
||||||
[identifier
|
[identifier setValue:
|
||||||
setValue:[arguments[1] cube_intValueWithBase:0]];
|
[arguments[1] cube_intValueWithBase: 0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([identifier isKindOfClass: Alias.class]) {
|
if ([identifier isKindOfClass: Alias.class]) {
|
||||||
|
@ -279,12 +280,12 @@ complete(OFMutableString *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
__block int idx = 0;
|
__block int idx = 0;
|
||||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
^ (OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||||
if (strncmp(identifier.name.UTF8String, s.UTF8String + 1,
|
if (strncmp(identifier.name.UTF8String, s.UTF8String + 1,
|
||||||
completesize) == 0 &&
|
completesize) == 0 && idx++ == completeidx)
|
||||||
idx++ == completeidx)
|
[s replaceCharactersInRange: OFMakeRange(
|
||||||
[s replaceCharactersInRange:OFMakeRange(1, s.length - 1)
|
1, s.length - 1)
|
||||||
withString: identifier.name];
|
withString: identifier.name];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -331,43 +332,45 @@ writecfg()
|
||||||
@try {
|
@try {
|
||||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||||
IRIByAppendingPathComponent: @"config.cfg"];
|
IRIByAppendingPathComponent: @"config.cfg"];
|
||||||
stream = [[OFIRIHandler handlerForIRI:IRI] openItemAtIRI:IRI
|
stream = [[OFIRIHandler handlerForIRI: IRI]
|
||||||
|
openItemAtIRI: IRI
|
||||||
mode: @"w"];
|
mode: @"w"];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[stream writeString:@"// automatically written on exit, do not modify\n"
|
[stream writeString:
|
||||||
@"// delete this file to have defaults.cfg "
|
@"// automatically written on exit, do not modify\n"
|
||||||
@"overwrite these settings\n"
|
@"// delete this file to have defaults.cfg overwrite these "
|
||||||
@"// modify settings in game, or put settings in "
|
@"settings\n"
|
||||||
@"autoexec.cfg to override anything\n"
|
@"// modify settings in game, or put settings in autoexec.cfg to "
|
||||||
|
@"override anything\n"
|
||||||
@"\n"];
|
@"\n"];
|
||||||
writeclientinfo(stream);
|
writeclientinfo(stream);
|
||||||
[stream writeString: @"\n"];
|
[stream writeString: @"\n"];
|
||||||
|
|
||||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
^ (OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||||
if (![identifier isKindOfClass: Variable.class] ||
|
if (![identifier isKindOfClass: Variable.class] ||
|
||||||
![identifier persisted])
|
![identifier persisted])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[stream writeFormat:@"%@ %d\n", identifier.name,
|
[stream writeFormat:
|
||||||
*[identifier storage]];
|
@"%@ %d\n", identifier.name, *[identifier storage]];
|
||||||
}];
|
}];
|
||||||
[stream writeString: @"\n"];
|
[stream writeString: @"\n"];
|
||||||
|
|
||||||
writebinds(stream);
|
writebinds(stream);
|
||||||
[stream writeString: @"\n"];
|
[stream writeString: @"\n"];
|
||||||
|
|
||||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
^ (OFString *name, Alias *alias, bool *stop) {
|
||||||
if (![identifier isKindOfClass:Alias.class] ||
|
if (![alias isKindOfClass: Alias.class] ||
|
||||||
[identifier.name hasPrefix:@"nextmap_"])
|
[alias.name hasPrefix: @"nextmap_"])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[stream writeFormat:@"alias \"%@\" [%@]\n", identifier.name,
|
[stream writeFormat: @"alias \"%@\" [%@]\n",
|
||||||
[identifier action]];
|
alias.name, alias.action];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[stream close];
|
[stream close];
|
||||||
|
|
|
@ -226,11 +226,11 @@ keypress(int code, bool isDown)
|
||||||
init];
|
init];
|
||||||
|
|
||||||
if (vhistory.count == 0 ||
|
if (vhistory.count == 0 ||
|
||||||
![vhistory.lastObject
|
![vhistory.lastObject isEqual:
|
||||||
isEqual:commandbuf]) {
|
commandbuf]) {
|
||||||
// cap this?
|
// cap this?
|
||||||
[vhistory addObject:[commandbuf
|
[vhistory addObject:
|
||||||
copy]];
|
[commandbuf copy]];
|
||||||
}
|
}
|
||||||
histpos = vhistory.count;
|
histpos = vhistory.count;
|
||||||
if ([commandbuf hasPrefix: @"/"])
|
if ([commandbuf hasPrefix: @"/"])
|
||||||
|
@ -275,6 +275,6 @@ writebinds(OFStream *stream)
|
||||||
{
|
{
|
||||||
for (KeyMapping *mapping in keyMappings)
|
for (KeyMapping *mapping in keyMappings)
|
||||||
if (mapping.action.length > 0)
|
if (mapping.action.length > 0)
|
||||||
[stream writeFormat:@"bind \"%@\" [%@]\n", mapping.name,
|
[stream writeFormat: @"bind \"%@\" [%@]\n",
|
||||||
mapping.action];
|
mapping.name, mapping.action];
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ OF_CONSTRUCTOR()
|
||||||
{ @"selxs", &sel.xs }, { @"selys", &sel.ys } };
|
{ @"selxs", &sel.xs }, { @"selys", &sel.ys } };
|
||||||
|
|
||||||
for (size_t i = 0; i < 4; i++) {
|
for (size_t i = 0; i < 4; i++) {
|
||||||
Variable *variable =
|
Variable *variable = [Variable
|
||||||
[Variable variableWithName:vars[i].name
|
variableWithName: vars[i].name
|
||||||
min: 0
|
min: 0
|
||||||
max: 4096
|
max: 4096
|
||||||
storage: vars[i].storage
|
storage: vars[i].storage
|
||||||
|
|
|
@ -113,8 +113,8 @@ menumanual(int m, int n, OFString *text)
|
||||||
COMMAND(menuitem, ARG_2STR, ^ (OFString *text, OFString *action) {
|
COMMAND(menuitem, ARG_2STR, ^ (OFString *text, OFString *action) {
|
||||||
Menu *menu = menus.lastObject;
|
Menu *menu = menus.lastObject;
|
||||||
|
|
||||||
MenuItem *item =
|
MenuItem *item = [MenuItem
|
||||||
[MenuItem itemWithText:text
|
itemWithText: text
|
||||||
action: (action.length > 0 ? action : text)];
|
action: (action.length > 0 ? action : text)];
|
||||||
[menu.items addObject: item];
|
[menu.items addObject: item];
|
||||||
})
|
})
|
||||||
|
|
|
@ -108,10 +108,8 @@ collide(DynamicEntity *d, bool spawn, float drop, float rise)
|
||||||
const int y2 = fy2;
|
const int y2 = fy2;
|
||||||
float hi = 127, lo = -128;
|
float hi = 127, lo = -128;
|
||||||
// big monsters are afraid of heights, unless angry :)
|
// big monsters are afraid of heights, unless angry :)
|
||||||
float minfloor =
|
float minfloor = ([d isKindOfClass: Monster.class] && !spawn &&
|
||||||
([d isKindOfClass:Monster.class] && !spawn && d.health > 100
|
d.health > 100 ? d.origin.z - d.eyeHeight - 4.5f : -1000.0f);
|
||||||
? d.origin.z - d.eyeHeight - 4.5f
|
|
||||||
: -1000.0f);
|
|
||||||
|
|
||||||
for (int x = x1; x <= x2; x++) {
|
for (int x = x1; x <= x2; x++) {
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
|
|
|
@ -207,8 +207,9 @@ renderents()
|
||||||
if (e >= 0) {
|
if (e >= 0) {
|
||||||
Entity *c = ents[e];
|
Entity *c = ents[e];
|
||||||
closeent =
|
closeent =
|
||||||
[OFString stringWithFormat:@"closest entity = %@ (%d, %d, "
|
[OFString stringWithFormat:
|
||||||
@"%d, %d), selection = (%d, %d)",
|
@"closest entity = %@ (%d, %d, %d, %d), "
|
||||||
|
@"selection = (%d, %d)",
|
||||||
entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4,
|
entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4,
|
||||||
getvar(@"selxs"), getvar(@"selys")];
|
getvar(@"selxs"), getvar(@"selys")];
|
||||||
}
|
}
|
||||||
|
@ -227,14 +228,12 @@ COMMAND(loadsky, ARG_1STR, (^(OFString *basename) {
|
||||||
@"up" };
|
@"up" };
|
||||||
int texnum = 14;
|
int texnum = 14;
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
OFString *path = [OFString
|
OFString *path = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"packages/%@_%@.jpg", basename, side[i]];
|
@"packages/%@_%@.jpg", basename, side[i]];
|
||||||
|
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
if (!installtex(texnum + i,
|
if (!installtex(texnum + i, [Cube.sharedInstance.gameDataIRI
|
||||||
[Cube.sharedInstance.gameDataIRI
|
IRIByAppendingPathComponent: path], &xs, &ys, true))
|
||||||
IRIByAppendingPathComponent:path],
|
|
||||||
&xs, &ys, true))
|
|
||||||
conoutf(@"could not load sky textures");
|
conoutf(@"could not load sky textures");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +406,8 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
|
||||||
[[OFColor colorWithRed: 1.0f
|
[[OFColor colorWithRed: 1.0f
|
||||||
green: 0.5f
|
green: 0.5f
|
||||||
blue: 0.0f
|
blue: 0.0f
|
||||||
alpha:1.0f] cube_setAsGLColor];
|
alpha: 1.0f]
|
||||||
|
cube_setAsGLColor];
|
||||||
}
|
}
|
||||||
float chsize = (float)crosshairsize;
|
float chsize = (float)crosshairsize;
|
||||||
glTexCoord2d(0.0, 0.0);
|
glTexCoord2d(0.0, 0.0);
|
||||||
|
|
|
@ -237,13 +237,11 @@ lookuptexture(int tex, int *xs, int *ys)
|
||||||
int tnum = curtex + FIRSTTEX;
|
int tnum = curtex + FIRSTTEX;
|
||||||
texname[curtex] = mapname[tex][frame];
|
texname[curtex] = mapname[tex][frame];
|
||||||
|
|
||||||
OFString *path =
|
OFString *path = [OFString stringWithFormat: @"packages/%@",
|
||||||
[OFString stringWithFormat:@"packages/%@", texname[curtex]];
|
texname[curtex]];
|
||||||
|
|
||||||
if (installtex(tnum,
|
if (installtex(tnum, [Cube.sharedInstance.gameDataIRI
|
||||||
[Cube.sharedInstance.gameDataIRI
|
IRIByAppendingPathComponent: path], xs, ys, false)) {
|
||||||
IRIByAppendingPathComponent:path],
|
|
||||||
xs, ys, false)) {
|
|
||||||
mapping[tex][frame] = tnum;
|
mapping[tex][frame] = tnum;
|
||||||
texx[curtex] = *xs;
|
texx[curtex] = *xs;
|
||||||
texy[curtex] = *ys;
|
texy[curtex] = *ys;
|
||||||
|
|
|
@ -17,16 +17,18 @@ void
|
||||||
delayedload(MD2 *m)
|
delayedload(MD2 *m)
|
||||||
{
|
{
|
||||||
if (!m.loaded) {
|
if (!m.loaded) {
|
||||||
OFString *path = [OFString
|
OFString *path = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"packages/models/%@", m.loadname];
|
@"packages/models/%@", m.loadname];
|
||||||
OFIRI *baseIRI = [Cube.sharedInstance.gameDataIRI
|
OFIRI *baseIRI = [Cube.sharedInstance.gameDataIRI
|
||||||
IRIByAppendingPathComponent: path];
|
IRIByAppendingPathComponent: path];
|
||||||
|
|
||||||
OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"];
|
OFIRI *IRI1 = [baseIRI
|
||||||
|
IRIByAppendingPathComponent: @"tris.md2"];
|
||||||
if (![m loadWithIRI: IRI1])
|
if (![m loadWithIRI: IRI1])
|
||||||
fatal(@"loadmodel: %@", IRI1.string);
|
fatal(@"loadmodel: %@", IRI1.string);
|
||||||
|
|
||||||
OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"];
|
OFIRI *IRI2 = [baseIRI
|
||||||
|
IRIByAppendingPathComponent: @"skin.jpg"];
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
installtex(FIRSTMDL + m.mdlnum, IRI2, &xs, &ys, false);
|
installtex(FIRSTMDL + m.mdlnum, IRI2, &xs, &ys, false);
|
||||||
m.loaded = true;
|
m.loaded = true;
|
||||||
|
@ -55,11 +57,9 @@ loadmodel(OFString *name)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND(mapmodel, ARG_5STR,
|
COMMAND(mapmodel, ARG_5STR, ^ (OFString *rad, OFString *h, OFString *zoff,
|
||||||
^(OFString *rad, OFString *h, OFString *zoff, OFString *snap,
|
OFString *snap, OFString *name) {
|
||||||
OFString *name) {
|
MD2 *m = loadmodel([name stringByReplacingOccurrencesOfString: @"\\"
|
||||||
MD2 *m =
|
|
||||||
loadmodel([name stringByReplacingOccurrencesOfString:@"\\"
|
|
||||||
withString: @"/"]);
|
withString: @"/"]);
|
||||||
m.mmi = [MapModelInfo infoWithRad: rad.cube_intValue
|
m.mmi = [MapModelInfo infoWithRad: rad.cube_intValue
|
||||||
h: h.cube_intValue
|
h: h.cube_intValue
|
||||||
|
@ -102,7 +102,7 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
|
||||||
|
|
||||||
int ix = (int)position.x;
|
int ix = (int)position.x;
|
||||||
int iy = (int)position.z;
|
int iy = (int)position.z;
|
||||||
OFColor *light = [OFColor colorWithRed:1 green:1 blue:1 alpha:1];
|
OFColor *light = OFColor.white;
|
||||||
|
|
||||||
if (!OUTBORD(ix, iy)) {
|
if (!OUTBORD(ix, iy)) {
|
||||||
struct sqr *s = S(ix, iy);
|
struct sqr *s = S(ix, iy);
|
||||||
|
|
|
@ -97,8 +97,7 @@ savestate(OFIRI *IRI)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
f = gzopen([IRI.fileSystemRepresentation
|
f = gzopen([IRI.fileSystemRepresentation
|
||||||
cStringWithEncoding:OFLocale.encoding],
|
cStringWithEncoding: OFLocale.encoding], "wb9");
|
||||||
"wb9");
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
conoutf(@"could not write %@", IRI.string);
|
conoutf(@"could not write %@", IRI.string);
|
||||||
return;
|
return;
|
||||||
|
@ -137,9 +136,10 @@ COMMAND(savegame, ARG_1STR, (^(OFString *name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFString *path = [OFString stringWithFormat:@"savegames/%@.csgz", name];
|
OFString *path = [OFString stringWithFormat:
|
||||||
OFIRI *IRI =
|
@"savegames/%@.csgz", name];
|
||||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||||
|
IRIByAppendingPathComponent: path];
|
||||||
savestate(IRI);
|
savestate(IRI);
|
||||||
stop();
|
stop();
|
||||||
conoutf(@"wrote %@", IRI.string);
|
conoutf(@"wrote %@", IRI.string);
|
||||||
|
@ -152,8 +152,7 @@ loadstate(OFIRI *IRI)
|
||||||
if (multiplayer())
|
if (multiplayer())
|
||||||
return;
|
return;
|
||||||
f = gzopen([IRI.fileSystemRepresentation
|
f = gzopen([IRI.fileSystemRepresentation
|
||||||
cStringWithEncoding:OFLocale.encoding],
|
cStringWithEncoding: OFLocale.encoding], "rb9");
|
||||||
"rb9");
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
conoutf(@"could not open %@", IRI.string);
|
conoutf(@"could not open %@", IRI.string);
|
||||||
return;
|
return;
|
||||||
|
@ -184,9 +183,10 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND(loadgame, ARG_1STR, (^ (OFString *name) {
|
COMMAND(loadgame, ARG_1STR, (^ (OFString *name) {
|
||||||
OFString *path = [OFString stringWithFormat:@"savegames/%@.csgz", name];
|
OFString *path = [OFString stringWithFormat:
|
||||||
OFIRI *IRI =
|
@"savegames/%@.csgz", name];
|
||||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||||
|
IRIByAppendingPathComponent: path];
|
||||||
loadstate(IRI);
|
loadstate(IRI);
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -275,8 +275,8 @@ COMMAND(record, ARG_1STR, (^(OFString *name) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
||||||
OFIRI *IRI =
|
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
IRIByAppendingPathComponent: path];
|
||||||
savestate(IRI);
|
savestate(IRI);
|
||||||
gzputi(cn);
|
gzputi(cn);
|
||||||
conoutf(@"started recording demo to %@", IRI.string);
|
conoutf(@"started recording demo to %@", IRI.string);
|
||||||
|
@ -335,8 +335,8 @@ incomingdemodata(unsigned char *buf, int len, bool extras)
|
||||||
|
|
||||||
COMMAND(demo, ARG_1STR, (^ (OFString *name) {
|
COMMAND(demo, ARG_1STR, (^ (OFString *name) {
|
||||||
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
||||||
OFIRI *IRI =
|
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
IRIByAppendingPathComponent: path];
|
||||||
loadstate(IRI);
|
loadstate(IRI);
|
||||||
demoloading = true;
|
demoloading = true;
|
||||||
}))
|
}))
|
||||||
|
|
31
src/server.m
31
src/server.m
|
@ -24,8 +24,8 @@ int mode = 0;
|
||||||
void
|
void
|
||||||
restoreserverstate(OFArray<Entity *> *ents)
|
restoreserverstate(OFArray<Entity *> *ents)
|
||||||
{
|
{
|
||||||
[sents enumerateObjectsUsingBlock:^(
|
[sents enumerateObjectsUsingBlock:
|
||||||
ServerEntity *e, size_t i, bool *stop) {
|
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||||
e.spawned = ents[i].spawned;
|
e.spawned = ents[i].spawned;
|
||||||
e.spawnsecs = 0;
|
e.spawnsecs = 0;
|
||||||
}];
|
}];
|
||||||
|
@ -159,8 +159,8 @@ vote(OFString *map, int reqmode, int sender)
|
||||||
if (yes == 1 && no == 0)
|
if (yes == 1 && no == 0)
|
||||||
return true; // single player
|
return true; // single player
|
||||||
|
|
||||||
OFString *msg = [OFString
|
OFString *msg = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"%@ suggests %@ on map %@ (set map to vote)",
|
@"%@ suggests %@ on map %@ (set map to vote)",
|
||||||
clients[sender].name, modestr(reqmode), map];
|
clients[sender].name, modestr(reqmode), map];
|
||||||
sendservmsg(msg);
|
sendservmsg(msg);
|
||||||
|
|
||||||
|
@ -227,8 +227,8 @@ process(ENetPacket *packet, int sender) // sender may be -1
|
||||||
while ((n = getint(&p)) != -1)
|
while ((n = getint(&p)) != -1)
|
||||||
if (notgotitems) {
|
if (notgotitems) {
|
||||||
while (sents.count <= n)
|
while (sents.count <= n)
|
||||||
[sents addObject:[ServerEntity
|
[sents addObject:
|
||||||
entity]];
|
[ServerEntity entity]];
|
||||||
sents[n].spawned = true;
|
sents[n].spawned = true;
|
||||||
}
|
}
|
||||||
notgotitems = false;
|
notgotitems = false;
|
||||||
|
@ -314,8 +314,8 @@ send_welcome(int n)
|
||||||
sendstring(smapname, &p);
|
sendstring(smapname, &p);
|
||||||
putint(&p, mode);
|
putint(&p, mode);
|
||||||
putint(&p, SV_ITEMLIST);
|
putint(&p, SV_ITEMLIST);
|
||||||
[sents enumerateObjectsUsingBlock:^(
|
[sents enumerateObjectsUsingBlock:
|
||||||
ServerEntity *e, size_t i, bool *stop) {
|
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||||
if (e.spawned)
|
if (e.spawned)
|
||||||
putint(&p, i);
|
putint(&p, i);
|
||||||
}];
|
}];
|
||||||
|
@ -405,8 +405,8 @@ serverslice(int seconds,
|
||||||
// sp, or dedicated server loop
|
// sp, or dedicated server loop
|
||||||
{
|
{
|
||||||
// spawn entities when timer reached
|
// spawn entities when timer reached
|
||||||
[sents enumerateObjectsUsingBlock:^(
|
[sents enumerateObjectsUsingBlock:
|
||||||
ServerEntity *e, size_t i, bool *stop) {
|
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||||
if (e.spawnsecs && (e.spawnsecs -= seconds - lastsec) <= 0) {
|
if (e.spawnsecs && (e.spawnsecs -= seconds - lastsec) <= 0) {
|
||||||
e.spawnsecs = 0;
|
e.spawnsecs = 0;
|
||||||
e.spawned = true;
|
e.spawned = true;
|
||||||
|
@ -421,8 +421,8 @@ serverslice(int seconds,
|
||||||
checkintermission();
|
checkintermission();
|
||||||
if (interm && seconds > interm) {
|
if (interm && seconds > interm) {
|
||||||
interm = 0;
|
interm = 0;
|
||||||
[clients enumerateObjectsUsingBlock:^(
|
[clients enumerateObjectsUsingBlock:
|
||||||
Client *client, size_t i, bool *stop) {
|
^ (Client *client, size_t i, bool *stop) {
|
||||||
if (client.type != ST_EMPTY) {
|
if (client.type != ST_EMPTY) {
|
||||||
// ask a client to trigger map reload
|
// ask a client to trigger map reload
|
||||||
send2(true, i, SV_MAPRELOAD, 0);
|
send2(true, i, SV_MAPRELOAD, 0);
|
||||||
|
@ -475,8 +475,8 @@ serverslice(int seconds,
|
||||||
&c.peer->address, hn, sizeof(hn)) == 0
|
&c.peer->address, hn, sizeof(hn)) == 0
|
||||||
? @(hn)
|
? @(hn)
|
||||||
: @"localhost");
|
: @"localhost");
|
||||||
[OFStdOut
|
[OFStdOut writeFormat: @"client connected (%@)\n",
|
||||||
writeFormat:@"client connected (%@)\n", c.hostname];
|
c.hostname];
|
||||||
send_welcome(lastconnect = clients.count - 1);
|
send_welcome(lastconnect = clients.count - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,8 @@ serverslice(int seconds,
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
if ((intptr_t)event.peer->data < 0)
|
if ((intptr_t)event.peer->data < 0)
|
||||||
break;
|
break;
|
||||||
[OFStdOut writeFormat:@"disconnected client (%@)\n",
|
[OFStdOut writeFormat:
|
||||||
|
@"disconnected client (%@)\n",
|
||||||
clients[(size_t)event.peer->data].hostname];
|
clients[(size_t)event.peer->data].hostname];
|
||||||
clients[(size_t)event.peer->data].type = ST_EMPTY;
|
clients[(size_t)event.peer->data].type = ST_EMPTY;
|
||||||
send2(true, -1, SV_CDIS, (intptr_t)event.peer->data);
|
send2(true, -1, SV_CDIS, (intptr_t)event.peer->data);
|
||||||
|
|
|
@ -217,16 +217,15 @@ refreshservers()
|
||||||
[servers sort];
|
[servers sort];
|
||||||
|
|
||||||
__block int maxmenu = 16;
|
__block int maxmenu = 16;
|
||||||
[servers enumerateObjectsUsingBlock:^(
|
[servers enumerateObjectsUsingBlock:
|
||||||
ServerInfo *si, size_t i, bool *stop) {
|
^ (ServerInfo *si, size_t i, bool *stop) {
|
||||||
if (si.address.host != ENET_HOST_ANY && si.ping != 9999) {
|
if (si.address.host != ENET_HOST_ANY && si.ping != 9999) {
|
||||||
if (si.protocol != PROTOCOL_VERSION)
|
if (si.protocol != PROTOCOL_VERSION)
|
||||||
si.full = [OFString stringWithFormat:
|
si.full = [OFString stringWithFormat:
|
||||||
@"%@ [different cube protocol]",
|
@"%@ [different cube protocol]", si.name];
|
||||||
si.name];
|
|
||||||
else
|
else
|
||||||
si.full = [OFString
|
si.full = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"%d\t%d\t%@, %@: %@ %@",
|
@"%d\t%d\t%@, %@: %@ %@",
|
||||||
si.ping, si.numplayers,
|
si.ping, si.numplayers,
|
||||||
si.map.length > 0 ? si.map : @"[unknown]",
|
si.map.length > 0 ? si.map : @"[unknown]",
|
||||||
modestr(si.mode), si.name, si.sdesc];
|
modestr(si.mode), si.name, si.sdesc];
|
||||||
|
|
|
@ -26,7 +26,8 @@ httpgetsend(ENetAddress *ad, OFString *hostname, OFString *req, OFString *ref,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ENetBuffer buf;
|
ENetBuffer buf;
|
||||||
OFString *httpget = [OFString stringWithFormat:@"GET %@ HTTP/1.0\n"
|
OFString *httpget = [OFString stringWithFormat:
|
||||||
|
@"GET %@ HTTP/1.0\n"
|
||||||
@"Host: %@\n"
|
@"Host: %@\n"
|
||||||
@"Referer: %@\n"
|
@"Referer: %@\n"
|
||||||
@"User-Agent: %@\n\n",
|
@"User-Agent: %@\n\n",
|
||||||
|
@ -77,8 +78,8 @@ updatemasterserver(int seconds)
|
||||||
{
|
{
|
||||||
// send alive signal to masterserver every hour of uptime
|
// send alive signal to masterserver every hour of uptime
|
||||||
if (seconds > updmaster) {
|
if (seconds > updmaster) {
|
||||||
OFString *path = [OFString
|
OFString *path = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"%@register.do?action=add", masterpath];
|
@"%@register.do?action=add", masterpath];
|
||||||
httpgetsend(&masterserver, masterbase, path, @"cubeserver",
|
httpgetsend(&masterserver, masterbase, path, @"cubeserver",
|
||||||
@"Cube Server");
|
@"Cube Server");
|
||||||
masterrep[0] = 0;
|
masterrep[0] = 0;
|
||||||
|
@ -100,8 +101,8 @@ checkmasterreply()
|
||||||
unsigned char *
|
unsigned char *
|
||||||
retrieveservers(unsigned char *buf, int buflen)
|
retrieveservers(unsigned char *buf, int buflen)
|
||||||
{
|
{
|
||||||
OFString *path =
|
OFString *path = [OFString stringWithFormat:
|
||||||
[OFString stringWithFormat:@"%@retrieve.do?item=list", masterpath];
|
@"%@retrieve.do?item=list", masterpath];
|
||||||
httpgetsend(
|
httpgetsend(
|
||||||
&masterserver, masterbase, path, @"cubeserver", @"Cube Server");
|
&masterserver, masterbase, path, @"cubeserver", @"Cube Server");
|
||||||
ENetBuffer eb;
|
ENetBuffer eb;
|
||||||
|
@ -140,8 +141,8 @@ serverms(int mode, int numplayers, int minremain, OFString *smapname,
|
||||||
putint(&p, mode);
|
putint(&p, mode);
|
||||||
putint(&p, numplayers);
|
putint(&p, numplayers);
|
||||||
putint(&p, minremain);
|
putint(&p, minremain);
|
||||||
OFString *mname = [OFString stringWithFormat:@"%@%@",
|
OFString *mname = [OFString stringWithFormat:
|
||||||
(isfull ? @"[FULL] " : @""), smapname];
|
@"%@%@", (isfull ? @"[FULL] " : @""), smapname];
|
||||||
sendstring(mname, &p);
|
sendstring(mname, &p);
|
||||||
sendstring(serverdesc, &p);
|
sendstring(serverdesc, &p);
|
||||||
buf.dataLength = p - pong;
|
buf.dataLength = p - pong;
|
||||||
|
@ -157,7 +158,8 @@ servermsinit(OFString *master_, OFString *sdesc, bool listen)
|
||||||
if (!mid)
|
if (!mid)
|
||||||
mid = master;
|
mid = master;
|
||||||
masterpath = @(mid);
|
masterpath = @(mid);
|
||||||
masterbase = [OFString stringWithUTF8String:master length:mid - master];
|
masterbase = [OFString stringWithUTF8String: master
|
||||||
|
length: mid - master];
|
||||||
serverdesc = sdesc;
|
serverdesc = sdesc;
|
||||||
|
|
||||||
if (listen) {
|
if (listen) {
|
||||||
|
|
|
@ -58,8 +58,8 @@ COMMAND(music, ARG_1STR, (^(OFString *name) {
|
||||||
if (soundvol && musicvol) {
|
if (soundvol && musicvol) {
|
||||||
name = [name stringByReplacingOccurrencesOfString: @"\\"
|
name = [name stringByReplacingOccurrencesOfString: @"\\"
|
||||||
withString: @"/"];
|
withString: @"/"];
|
||||||
OFString *path =
|
OFString *path = [OFString stringWithFormat:
|
||||||
[OFString stringWithFormat:@"packages/%@", name];
|
@"packages/%@", name];
|
||||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||||
IRIByAppendingPathComponent: path];
|
IRIByAppendingPathComponent: path];
|
||||||
|
|
||||||
|
@ -195,8 +195,8 @@ playsound(int n, const OFVector3D *loc)
|
||||||
|
|
||||||
Mix_Chunk **sample = (Mix_Chunk **)[samples mutableItemAtIndex: n];
|
Mix_Chunk **sample = (Mix_Chunk **)[samples mutableItemAtIndex: n];
|
||||||
if (*sample == NULL) {
|
if (*sample == NULL) {
|
||||||
OFString *path = [OFString
|
OFString *path = [OFString stringWithFormat:
|
||||||
stringWithFormat:@"packages/sounds/%@.wav", snames[n]];
|
@"packages/sounds/%@.wav", snames[n]];
|
||||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||||
IRIByAppendingPathComponent: path];
|
IRIByAppendingPathComponent: path];
|
||||||
|
|
||||||
|
|
11
src/weapon.m
11
src/weapon.m
|
@ -225,8 +225,8 @@ splash(Projectile *p, OFVector3D v, OFVector3D vold, int notthisplayer,
|
||||||
|
|
||||||
radialeffect(Player.player1, v, -1, qdam, p.owner);
|
radialeffect(Player.player1, v, -1, qdam, p.owner);
|
||||||
|
|
||||||
[players enumerateObjectsUsingBlock:^(
|
[players enumerateObjectsUsingBlock:
|
||||||
id player, size_t i, bool *stop) {
|
^ (id player, size_t i, bool *stop) {
|
||||||
if (i == notthisplayer)
|
if (i == notthisplayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -236,8 +236,8 @@ splash(Projectile *p, OFVector3D v, OFVector3D vold, int notthisplayer,
|
||||||
radialeffect(player, v, i, qdam, p.owner);
|
radialeffect(player, v, i, qdam, p.owner);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[Monster.monsters enumerateObjectsUsingBlock:^(
|
[Monster.monsters enumerateObjectsUsingBlock:
|
||||||
Monster *monster, size_t i, bool *stop) {
|
^ (Monster *monster, size_t i, bool *stop) {
|
||||||
if (i != notthismonster)
|
if (i != notthismonster)
|
||||||
radialeffect(monster, v, i, qdam, p.owner);
|
radialeffect(monster, v, i, qdam, p.owner);
|
||||||
}];
|
}];
|
||||||
|
@ -432,7 +432,8 @@ shoot(DynamicEntity *d, OFVector3D targ)
|
||||||
if (guns[d.gunSelect].projspeed)
|
if (guns[d.gunSelect].projspeed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
[players enumerateObjectsUsingBlock:
|
||||||
|
^ (id player, size_t i, bool *stop) {
|
||||||
if (player != [OFNull null])
|
if (player != [OFNull null])
|
||||||
raydamage(player, from, to, d, i);
|
raydamage(player, from, to, d, i);
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -83,8 +83,8 @@ trigger(int tag, int type, bool savegame)
|
||||||
if (!savegame && type != 3)
|
if (!savegame && type != 3)
|
||||||
playsound(S_RUMBLE, NULL);
|
playsound(S_RUMBLE, NULL);
|
||||||
|
|
||||||
OFString *aliasname =
|
OFString *aliasname = [OFString stringWithFormat:
|
||||||
[OFString stringWithFormat:@"level_trigger_%d", tag];
|
@"level_trigger_%d", tag];
|
||||||
|
|
||||||
if (identexists(aliasname))
|
if (identexists(aliasname))
|
||||||
execute(aliasname, true);
|
execute(aliasname, true);
|
||||||
|
|
|
@ -37,14 +37,14 @@ setnames(OFString *name)
|
||||||
mapname = name;
|
mapname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
cgzname = [[OFString alloc]
|
cgzname = [[OFString alloc] initWithFormat:
|
||||||
initWithFormat:@"packages/%@/%@.cgz", pakname, mapname];
|
@"packages/%@/%@.cgz", pakname, mapname];
|
||||||
bakname = [[OFString alloc] initWithFormat:@"packages/%@/%@_%d.BAK",
|
bakname = [[OFString alloc] initWithFormat:
|
||||||
pakname, mapname, lastmillis];
|
@"packages/%@/%@_%d.BAK", pakname, mapname, lastmillis];
|
||||||
pcfname = [[OFString alloc]
|
pcfname = [[OFString alloc] initWithFormat:
|
||||||
initWithFormat:@"packages/%@/package.cfg", pakname];
|
@"packages/%@/package.cfg", pakname];
|
||||||
mcfname = [[OFString alloc]
|
mcfname = [[OFString alloc] initWithFormat:
|
||||||
initWithFormat:@"packages/%@/%@.cfg", pakname, mapname];
|
@"packages/%@/%@.cfg", pakname, mapname];
|
||||||
}
|
}
|
||||||
|
|
||||||
// the optimize routines below are here to reduce the detrimental effects of
|
// the optimize routines below are here to reduce the detrimental effects of
|
||||||
|
@ -178,8 +178,8 @@ save_world(OFString *mname)
|
||||||
mname = getclientmap();
|
mname = getclientmap();
|
||||||
setnames(mname);
|
setnames(mname);
|
||||||
backup(cgzname, bakname);
|
backup(cgzname, bakname);
|
||||||
gzFile f =
|
gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
|
||||||
gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "wb9");
|
"wb9");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
conoutf(@"could not write map to %@", cgzname);
|
conoutf(@"could not write map to %@", cgzname);
|
||||||
return;
|
return;
|
||||||
|
@ -270,8 +270,8 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
||||||
cleardlights();
|
cleardlights();
|
||||||
pruneundos(0);
|
pruneundos(0);
|
||||||
setnames(mname);
|
setnames(mname);
|
||||||
gzFile f =
|
gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
|
||||||
gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "rb9");
|
"rb9");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
conoutf(@"could not read map %@", cgzname);
|
conoutf(@"could not read map %@", cgzname);
|
||||||
return;
|
return;
|
||||||
|
@ -396,8 +396,8 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
||||||
startmap(mname);
|
startmap(mname);
|
||||||
for (int l = 0; l < 256; l++) {
|
for (int l = 0; l < 256; l++) {
|
||||||
// can this be done smarter?
|
// can this be done smarter?
|
||||||
OFString *aliasname =
|
OFString *aliasname = [OFString stringWithFormat:
|
||||||
[OFString stringWithFormat:@"level_trigger_%d", l];
|
@"level_trigger_%d", l];
|
||||||
if (identexists(aliasname))
|
if (identexists(aliasname))
|
||||||
alias(aliasname, @"");
|
alias(aliasname, @"");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue