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
|
14
src/Alias.h
14
src/Alias.h
|
@ -6,13 +6,13 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
@property (direct, copy, nonatomic) OFString *action;
|
||||
@property (readonly, nonatomic) bool persisted;
|
||||
|
||||
+ (instancetype)aliasWithName:(OFString *)name
|
||||
action:(OFString *)action
|
||||
persisted:(bool)persisted OF_DIRECT;
|
||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
action:(OFString *)action
|
||||
persisted:(bool)persisted OF_DESIGNATED_INITIALIZER
|
||||
+ (instancetype)aliasWithName: (OFString *)name
|
||||
action: (OFString *)action
|
||||
persisted: (bool)persisted OF_DIRECT;
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
action: (OFString *)action
|
||||
persisted: (bool)persisted OF_DESIGNATED_INITIALIZER
|
||||
OF_DIRECT;
|
||||
@end
|
||||
|
||||
|
|
20
src/Alias.m
20
src/Alias.m
|
@ -1,20 +1,20 @@
|
|||
#import "Alias.h"
|
||||
|
||||
@implementation Alias
|
||||
+ (instancetype)aliasWithName:(OFString *)name
|
||||
action:(OFString *)action
|
||||
persisted:(bool)persisted;
|
||||
+ (instancetype)aliasWithName: (OFString *)name
|
||||
action: (OFString *)action
|
||||
persisted: (bool)persisted;
|
||||
{
|
||||
return [[self alloc] initWithName:name
|
||||
action:action
|
||||
persisted:persisted];
|
||||
return [[self alloc] initWithName: name
|
||||
action: action
|
||||
persisted: persisted];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
action:(OFString *)action
|
||||
persisted:(bool)persisted
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
action: (OFString *)action
|
||||
persisted: (bool)persisted
|
||||
{
|
||||
self = [super initWithName:name];
|
||||
self = [super initWithName: name];
|
||||
|
||||
_action = [action copy];
|
||||
_persisted = persisted;
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define COMMAND(name, nargs, block_) \
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^{ \
|
||||
Identifier.identifiers[@ #name] = \
|
||||
[Command commandWithName:@ #name \
|
||||
argumentsTypes:nargs \
|
||||
block:block_]; \
|
||||
}); \
|
||||
#define COMMAND(name, nargs, block_) \
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^ { \
|
||||
Identifier.identifiers[@#name] = \
|
||||
[Command commandWithName: @#name \
|
||||
argumentsTypes: nargs \
|
||||
block: block_]; \
|
||||
}); \
|
||||
}
|
||||
|
||||
OF_DIRECT_MEMBERS
|
||||
@interface Command: Identifier
|
||||
@property (readonly, nonatomic) int argumentsTypes;
|
||||
|
||||
+ (instancetype)commandWithName:(OFString *)name
|
||||
argumentsTypes:(int)argumentsTypes
|
||||
block:(id)block;
|
||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
argumentsTypes:(int)argumentsTypes
|
||||
block:(id)block OF_DESIGNATED_INITIALIZER;
|
||||
- (int)callWithArguments:(OFArray<OFString *> *)arguments isDown:(bool)isDown;
|
||||
+ (instancetype)commandWithName: (OFString *)name
|
||||
argumentsTypes: (int)argumentsTypes
|
||||
block: (id)block;
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
argumentsTypes: (int)argumentsTypes
|
||||
block: (id)block OF_DESIGNATED_INITIALIZER;
|
||||
- (int)callWithArguments: (OFArray<OFString *> *)arguments isDown: (bool)isDown;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -13,7 +13,7 @@ padArguments(OFArray<OFString *> *arguments, size_t count)
|
|||
|
||||
copy = [arguments mutableCopy];
|
||||
while (copy.count < count)
|
||||
[copy addObject:@""];
|
||||
[copy addObject: @""];
|
||||
|
||||
[copy makeImmutable];
|
||||
return copy;
|
||||
|
@ -24,20 +24,20 @@ padArguments(OFArray<OFString *> *arguments, size_t count)
|
|||
id _block;
|
||||
}
|
||||
|
||||
+ (instancetype)commandWithName:(OFString *)name
|
||||
argumentsTypes:(int)argumentsTypes
|
||||
block:(id)block
|
||||
+ (instancetype)commandWithName: (OFString *)name
|
||||
argumentsTypes: (int)argumentsTypes
|
||||
block: (id)block
|
||||
{
|
||||
return [[self alloc] initWithName:name
|
||||
argumentsTypes:argumentsTypes
|
||||
block:block];
|
||||
return [[self alloc] initWithName: name
|
||||
argumentsTypes: argumentsTypes
|
||||
block: block];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
argumentsTypes:(int)argumentsTypes
|
||||
block:(id)block
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
argumentsTypes: (int)argumentsTypes
|
||||
block: (id)block
|
||||
{
|
||||
self = [super initWithName:name];
|
||||
self = [super initWithName: name];
|
||||
|
||||
_argumentsTypes = argumentsTypes;
|
||||
_block = block;
|
||||
|
@ -45,41 +45,41 @@ padArguments(OFArray<OFString *> *arguments, size_t count)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (int)callWithArguments:(OFArray<OFString *> *)arguments isDown:(bool)isDown
|
||||
- (int)callWithArguments: (OFArray<OFString *> *)arguments isDown: (bool)isDown
|
||||
{
|
||||
switch (_argumentsTypes) {
|
||||
case ARG_1INT:
|
||||
if (isDown) {
|
||||
arguments = padArguments(arguments, 2);
|
||||
((void (^)(int))_block)(
|
||||
[arguments[1] cube_intValueWithBase:0]);
|
||||
[arguments[1] cube_intValueWithBase: 0]);
|
||||
}
|
||||
break;
|
||||
case ARG_2INT:
|
||||
if (isDown) {
|
||||
arguments = padArguments(arguments, 3);
|
||||
((void (^)(int, int))_block)(
|
||||
[arguments[1] cube_intValueWithBase:0],
|
||||
[arguments[2] cube_intValueWithBase:0]);
|
||||
[arguments[1] cube_intValueWithBase: 0],
|
||||
[arguments[2] cube_intValueWithBase: 0]);
|
||||
}
|
||||
break;
|
||||
case ARG_3INT:
|
||||
if (isDown) {
|
||||
arguments = padArguments(arguments, 4);
|
||||
((void (^)(int, int, int))_block)(
|
||||
[arguments[1] cube_intValueWithBase:0],
|
||||
[arguments[2] cube_intValueWithBase:0],
|
||||
[arguments[3] cube_intValueWithBase:0]);
|
||||
[arguments[1] cube_intValueWithBase: 0],
|
||||
[arguments[2] cube_intValueWithBase: 0],
|
||||
[arguments[3] cube_intValueWithBase: 0]);
|
||||
}
|
||||
break;
|
||||
case ARG_4INT:
|
||||
if (isDown) {
|
||||
arguments = padArguments(arguments, 5);
|
||||
((void (^)(int, int, int, int))_block)(
|
||||
[arguments[1] cube_intValueWithBase:0],
|
||||
[arguments[2] cube_intValueWithBase:0],
|
||||
[arguments[3] cube_intValueWithBase:0],
|
||||
[arguments[4] cube_intValueWithBase:0]);
|
||||
[arguments[1] cube_intValueWithBase: 0],
|
||||
[arguments[2] cube_intValueWithBase: 0],
|
||||
[arguments[3] cube_intValueWithBase: 0],
|
||||
[arguments[4] cube_intValueWithBase: 0]);
|
||||
}
|
||||
break;
|
||||
case ARG_NONE:
|
||||
|
@ -154,8 +154,8 @@ padArguments(OFArray<OFString *> *arguments, size_t count)
|
|||
if (isDown)
|
||||
// limit, remove
|
||||
((void (^)(OFString *))_block)([[arguments
|
||||
objectsInRange:OFMakeRange(1, arguments.count - 1)]
|
||||
componentsJoinedByString:@" "]);
|
||||
objectsInRange: OFMakeRange(1, arguments.count - 1)]
|
||||
componentsJoinedByString: @" "]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@ OF_DIRECT_MEMBERS
|
|||
@property (readonly, copy) OFString *text;
|
||||
@property (readonly) int outtime;
|
||||
|
||||
+ (instancetype)lineWithText:(OFString *)text outtime:(int)outtime;
|
||||
- (instancetype)initWithText:(OFString *)text outtime:(int)outtime;
|
||||
+ (instancetype)lineWithText: (OFString *)text outtime: (int)outtime;
|
||||
- (instancetype)initWithText: (OFString *)text outtime: (int)outtime;
|
||||
@end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#import "ConsoleLine.h"
|
||||
|
||||
@implementation ConsoleLine
|
||||
+ (instancetype)lineWithText:(OFString *)text outtime:(int)outtime
|
||||
+ (instancetype)lineWithText: (OFString *)text outtime: (int)outtime
|
||||
{
|
||||
return [[self alloc] initWithText:text outtime:outtime];
|
||||
return [[self alloc] initWithText: text outtime: outtime];
|
||||
}
|
||||
|
||||
- (instancetype)initWithText:(OFString *)text outtime:(int)outtime
|
||||
- (instancetype)initWithText: (OFString *)text outtime: (int)outtime
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
107
src/Cube.m
107
src/Cube.m
|
@ -21,7 +21,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
return (Cube *)OFApplication.sharedApplication.delegate;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(OFNotification *)notification
|
||||
- (void)applicationDidFinishLaunching: (OFNotification *)notification
|
||||
{
|
||||
@autoreleasepool {
|
||||
bool dedicated, windowed;
|
||||
|
@ -48,7 +48,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
{ '\0', nil, 0, NULL, NULL }
|
||||
};
|
||||
OFOptionsParser *optionsParser =
|
||||
[OFOptionsParser parserWithOptions:options];
|
||||
[OFOptionsParser parserWithOptions: options];
|
||||
OFUnichar option;
|
||||
while ((option = [optionsParser nextOption]) != '\0') {
|
||||
switch (option) {
|
||||
|
@ -68,7 +68,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
case '=':
|
||||
case '?':
|
||||
conoutf(@"unknown commandline option");
|
||||
[OFApplication terminateWithStatus:1];
|
||||
[OFApplication terminateWithStatus: 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,11 @@ VARP(minmillis, 0, 5, 1000);
|
|||
[OFFileManager.defaultManager currentDirectoryIRI];
|
||||
|
||||
[OFFileManager.defaultManager createDirectoryAtIRI:
|
||||
[_userDataIRI IRIByAppendingPathComponent:@"demos"]
|
||||
createParents:true];
|
||||
[_userDataIRI IRIByAppendingPathComponent: @"demos"]
|
||||
createParents: true];
|
||||
[OFFileManager.defaultManager createDirectoryAtIRI:
|
||||
[_userDataIRI IRIByAppendingPathComponent:@"savegames"]
|
||||
createParents:true];
|
||||
[_userDataIRI IRIByAppendingPathComponent: @"savegames"]
|
||||
createParents: true];
|
||||
|
||||
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | par) < 0)
|
||||
fatal(@"Unable to initialize SDL");
|
||||
|
@ -145,44 +145,26 @@ VARP(minmillis, 0, 5, 1000);
|
|||
|
||||
log(@"basetex");
|
||||
int xs, ys;
|
||||
if (!installtex(2,
|
||||
[_gameDataIRI
|
||||
IRIByAppendingPathComponent:@"data/newchars.png"],
|
||||
&xs, &ys, false) ||
|
||||
!installtex(3,
|
||||
[_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/base.png"],
|
||||
&xs, &ys, false) ||
|
||||
!installtex(6,
|
||||
[_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/ball1.png"],
|
||||
&xs, &ys, false) ||
|
||||
!installtex(7,
|
||||
[_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/smoke.png"],
|
||||
&xs, &ys, false) ||
|
||||
!installtex(8,
|
||||
[_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"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))
|
||||
if (!installtex(2, [_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/newchars.png"], &xs, &ys, false) ||
|
||||
!installtex(3, [_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/base.png"], &xs, &ys, false) ||
|
||||
!installtex(6, [_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/ball1.png"], &xs, &ys, false) ||
|
||||
!installtex(7, [_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"data/martin/smoke.png"], &xs, &ys, false) ||
|
||||
!installtex(8, [_gameDataIRI IRIByAppendingPathComponent:
|
||||
@"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 "
|
||||
@"from the parent of the bin directory)");
|
||||
@"from the parent of the bin directory)");
|
||||
|
||||
log(@"sound");
|
||||
initsound();
|
||||
|
@ -196,9 +178,9 @@ VARP(minmillis, 0, 5, 1000);
|
|||
exec(@"data/sounds.cfg");
|
||||
exec(@"servers.cfg");
|
||||
if (!execfile([_userDataIRI
|
||||
IRIByAppendingPathComponent:@"config.cfg"]))
|
||||
IRIByAppendingPathComponent: @"config.cfg"]))
|
||||
execfile([_gameDataIRI
|
||||
IRIByAppendingPathComponent:@"data/defaults.cfg"]);
|
||||
IRIByAppendingPathComponent: @"data/defaults.cfg"]);
|
||||
exec(@"autoexec.cfg");
|
||||
|
||||
log(@"localconnect");
|
||||
|
@ -213,7 +195,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
int ignore = 5;
|
||||
for (;;) {
|
||||
@autoreleasepool {
|
||||
[OFRunLoop.mainRunLoop runUntilDate:past];
|
||||
[OFRunLoop.mainRunLoop runUntilDate: past];
|
||||
|
||||
Player *player1 = Player.player1;
|
||||
|
||||
|
@ -295,7 +277,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(OFNotification *)notification
|
||||
- (void)applicationWillTerminate: (OFNotification *)notification
|
||||
{
|
||||
stop();
|
||||
disconnect(true, false);
|
||||
|
@ -307,13 +289,13 @@ VARP(minmillis, 0, 5, 1000);
|
|||
SDL_Quit();
|
||||
}
|
||||
|
||||
- (void)showMessage:(OFString *)msg
|
||||
- (void)showMessage: (OFString *)msg
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MessageBoxW(
|
||||
NULL, msg.UTF16String, L"cube fatal error", MB_OK | MB_SYSTEMMODAL);
|
||||
#else
|
||||
[OFStdOut writeString:msg];
|
||||
[OFStdOut writeString: msg];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -339,12 +321,11 @@ VARP(minmillis, 0, 5, 1000);
|
|||
endianswap(dest, 3, _width);
|
||||
}
|
||||
|
||||
OFString *path = [OFString
|
||||
stringWithFormat:@"screenshots/screenshot_%d.bmp",
|
||||
lastmillis];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"screenshots/screenshot_%d.bmp", lastmillis];
|
||||
SDL_SaveBMP(temp,
|
||||
[_userDataIRI IRIByAppendingPathComponent:path]
|
||||
.fileSystemRepresentation.UTF8String);
|
||||
[_userDataIRI IRIByAppendingPathComponent: path]
|
||||
.fileSystemRepresentation.UTF8String);
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
|
||||
|
@ -355,7 +336,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
- (void)quit
|
||||
{
|
||||
writeservercfg();
|
||||
[OFApplication terminateWithStatus:0];
|
||||
[OFApplication terminateWithStatus: 0];
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -365,21 +346,21 @@ fatal(OFConstantString *s, ...)
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
OFMutableString *msg = [[OFMutableString alloc] initWithFormat:s
|
||||
arguments:args];
|
||||
OFMutableString *msg = [[OFMutableString alloc] initWithFormat: s
|
||||
arguments: args];
|
||||
va_end(args);
|
||||
|
||||
[msg appendFormat:@" (%s)\n", SDL_GetError()];
|
||||
[msg appendFormat: @" (%s)\n", SDL_GetError()];
|
||||
|
||||
[Cube.sharedInstance showMessage:msg];
|
||||
[OFApplication terminateWithStatus:1];
|
||||
[Cube.sharedInstance showMessage: msg];
|
||||
[OFApplication terminateWithStatus: 1];
|
||||
}
|
||||
|
||||
// normal exit
|
||||
COMMAND(quit, ARG_NONE, ^{
|
||||
COMMAND(quit, ARG_NONE, ^ {
|
||||
[Cube.sharedInstance quit];
|
||||
})
|
||||
|
||||
COMMAND(screenshot, ARG_NONE, ^{
|
||||
COMMAND(screenshot, ARG_NONE, ^ {
|
||||
[Cube.sharedInstance screenshot];
|
||||
})
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
@property (direct, copy, nonatomic) OFString *name;
|
||||
|
||||
- (OFData *)dataBySerializing;
|
||||
- (void)setFromSerializedData:(OFData *)data;
|
||||
- (void)setFromSerializedData: (OFData *)data;
|
||||
- (void)resetMovement;
|
||||
// reset player state not persistent accross spawns
|
||||
- (void)resetToSpawnState;
|
||||
|
|
|
@ -167,7 +167,7 @@ struct dynent {
|
|||
|
||||
memcpy(data.name, _name.UTF8String, min(_name.UTF8StringLength, 259));
|
||||
|
||||
if ([self isKindOfClass:Player.class]) {
|
||||
if ([self isKindOfClass: Player.class]) {
|
||||
Player *player = (Player *)self;
|
||||
data.lifeSequence = player.lifeSequence,
|
||||
data.frags = player.frags;
|
||||
|
@ -175,7 +175,7 @@ struct dynent {
|
|||
min(player.team.UTF8StringLength, 259));
|
||||
}
|
||||
|
||||
if ([self isKindOfClass:Monster.class]) {
|
||||
if ([self isKindOfClass: Monster.class]) {
|
||||
Monster *monster = (Monster *)self;
|
||||
data.monsterState = monster.monsterState;
|
||||
data.monsterType = monster.monsterType;
|
||||
|
@ -185,10 +185,10 @@ struct dynent {
|
|||
data.anger = monster.anger;
|
||||
}
|
||||
|
||||
return [OFData dataWithItems:&data count:sizeof(data)];
|
||||
return [OFData dataWithItems: &data count: sizeof(data)];
|
||||
}
|
||||
|
||||
- (void)setFromSerializedData:(OFData *)data
|
||||
- (void)setFromSerializedData: (OFData *)data
|
||||
{
|
||||
struct dynent d;
|
||||
|
||||
|
@ -239,16 +239,16 @@ struct dynent {
|
|||
_blocked = d.blocked;
|
||||
_moving = d.moving;
|
||||
|
||||
_name = [[OFString alloc] initWithUTF8String:d.name];
|
||||
_name = [[OFString alloc] initWithUTF8String: d.name];
|
||||
|
||||
if ([self isKindOfClass:Player.class]) {
|
||||
if ([self isKindOfClass: Player.class]) {
|
||||
Player *player = (Player *)self;
|
||||
player.lifeSequence = d.lifeSequence;
|
||||
player.frags = d.frags;
|
||||
player.team = @(d.team);
|
||||
}
|
||||
|
||||
if ([self isKindOfClass:Monster.class]) {
|
||||
if ([self isKindOfClass: Monster.class]) {
|
||||
Monster *monster = (Monster *)self;
|
||||
monster.monsterState = d.monsterState;
|
||||
monster.monsterType = d.monsterType;
|
||||
|
|
|
@ -8,7 +8,7 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
OFMutableDictionary<OFString *, __kindof Identifier *> *identifiers;
|
||||
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name;
|
||||
- (instancetype)initWithName: (OFString *)name;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -15,7 +15,7 @@ static OFMutableDictionary<OFString *, __kindof Identifier *> *identifiers;
|
|||
return identifiers;
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ OF_DIRECT_MEMBERS
|
|||
@property (readonly, nonatomic) OFString *name;
|
||||
@property (copy, nonatomic) OFString *action;
|
||||
|
||||
+ (instancetype)mappingWithCode:(int)code name:(OFString *)name;
|
||||
+ (instancetype)mappingWithCode: (int)code name: (OFString *)name;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithCode:(int)code name:(OFString *)name;
|
||||
- (instancetype)initWithCode: (int)code name: (OFString *)name;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#import "KeyMapping.h"
|
||||
|
||||
@implementation KeyMapping
|
||||
+ (instancetype)mappingWithCode:(int)code name:(OFString *)name
|
||||
+ (instancetype)mappingWithCode: (int)code name: (OFString *)name
|
||||
{
|
||||
return [[self alloc] initWithCode:code name:name];
|
||||
return [[self alloc] initWithCode: code name: name];
|
||||
}
|
||||
|
||||
- (instancetype)initWithCode:(int)code name:(OFString *)name
|
||||
- (instancetype)initWithCode: (int)code name: (OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
24
src/MD2.h
24
src/MD2.h
|
@ -12,18 +12,18 @@ OF_DIRECT_MEMBERS
|
|||
@property (nonatomic) bool loaded;
|
||||
|
||||
+ (instancetype)md2;
|
||||
- (bool)loadWithIRI:(OFIRI *)IRI;
|
||||
- (void)renderWithLight:(OFColor *)light
|
||||
frame:(int)frame
|
||||
range:(int)range
|
||||
position:(OFVector3D)position
|
||||
yaw:(float)yaw
|
||||
pitch:(float)pitch
|
||||
scale:(float)scale
|
||||
speed:(float)speed
|
||||
snap:(int)snap
|
||||
basetime:(int)basetime;
|
||||
- (void)scaleWithFrame:(int)frame scale:(float)scale snap:(int)snap;
|
||||
- (bool)loadWithIRI: (OFIRI *)IRI;
|
||||
- (void)renderWithLight: (OFColor *)light
|
||||
frame: (int)frame
|
||||
range: (int)range
|
||||
position: (OFVector3D)position
|
||||
yaw: (float)yaw
|
||||
pitch: (float)pitch
|
||||
scale: (float)scale
|
||||
speed: (float)speed
|
||||
snap: (int)snap
|
||||
basetime: (int)basetime;
|
||||
- (void)scaleWithFrame: (int)frame scale: (float)scale snap: (int)snap;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
48
src/MD2.m
48
src/MD2.m
|
@ -63,22 +63,22 @@ snap(int sn, float f)
|
|||
OFFreeMemory(_mverts);
|
||||
}
|
||||
|
||||
- (bool)loadWithIRI:(OFIRI *)IRI
|
||||
- (bool)loadWithIRI: (OFIRI *)IRI
|
||||
{
|
||||
OFSeekableStream *stream;
|
||||
@try {
|
||||
stream = (OFSeekableStream *)[[OFIRIHandler handlerForIRI:IRI]
|
||||
openItemAtIRI:IRI
|
||||
mode:@"r"];
|
||||
stream = (OFSeekableStream *)[[OFIRIHandler handlerForIRI: IRI]
|
||||
openItemAtIRI: IRI
|
||||
mode: @"r"];
|
||||
} @catch (id e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (![stream isKindOfClass:OFSeekableStream.class])
|
||||
if (![stream isKindOfClass: OFSeekableStream.class])
|
||||
return false;
|
||||
|
||||
struct md2_header header;
|
||||
[stream readIntoBuffer:&header exactLength:sizeof(header)];
|
||||
[stream readIntoBuffer: &header exactLength: sizeof(header)];
|
||||
endianswap(&header, sizeof(int), sizeof(header) / sizeof(int));
|
||||
|
||||
if (header.magic != 844121161 || header.version != 8)
|
||||
|
@ -90,9 +90,9 @@ snap(int sn, float f)
|
|||
return false;
|
||||
}
|
||||
|
||||
[stream seekToOffset:header.offsetFrames whence:OFSeekSet];
|
||||
[stream readIntoBuffer:_frames
|
||||
exactLength:header.frameSize * header.numFrames];
|
||||
[stream seekToOffset: header.offsetFrames whence: OFSeekSet];
|
||||
[stream readIntoBuffer: _frames
|
||||
exactLength: header.frameSize * header.numFrames];
|
||||
|
||||
for (int i = 0; i < header.numFrames; ++i)
|
||||
endianswap(_frames + i * header.frameSize, sizeof(float), 6);
|
||||
|
@ -103,9 +103,9 @@ snap(int sn, float f)
|
|||
return false;
|
||||
}
|
||||
|
||||
[stream seekToOffset:header.offsetGlCommands whence:OFSeekSet];
|
||||
[stream readIntoBuffer:_glCommands
|
||||
exactLength:header.numGlCommands * sizeof(int)];
|
||||
[stream seekToOffset: header.offsetGlCommands whence: OFSeekSet];
|
||||
[stream readIntoBuffer: _glCommands
|
||||
exactLength: header.numGlCommands * sizeof(int)];
|
||||
endianswap(_glCommands, sizeof(int), header.numGlCommands);
|
||||
|
||||
_numFrames = header.numFrames;
|
||||
|
@ -121,7 +121,7 @@ snap(int sn, float f)
|
|||
return true;
|
||||
}
|
||||
|
||||
- (void)scaleWithFrame:(int)frame scale:(float)scale snap:(int)sn
|
||||
- (void)scaleWithFrame: (int)frame scale: (float)scale snap: (int)sn
|
||||
{
|
||||
OFAssert(_mverts[frame] == NULL);
|
||||
|
||||
|
@ -139,20 +139,20 @@ snap(int sn, float f)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)renderWithLight:(OFColor *)light
|
||||
frame:(int)frame
|
||||
range:(int)range
|
||||
position:(OFVector3D)position
|
||||
yaw:(float)yaw
|
||||
pitch:(float)pitch
|
||||
scale:(float)sc
|
||||
speed:(float)speed
|
||||
snap:(int)sn
|
||||
basetime:(int)basetime
|
||||
- (void)renderWithLight: (OFColor *)light
|
||||
frame: (int)frame
|
||||
range: (int)range
|
||||
position: (OFVector3D)position
|
||||
yaw: (float)yaw
|
||||
pitch: (float)pitch
|
||||
scale: (float)sc
|
||||
speed: (float)speed
|
||||
snap: (int)sn
|
||||
basetime: (int)basetime
|
||||
{
|
||||
for (int i = 0; i < range; i++)
|
||||
if (!_mverts[frame + i])
|
||||
[self scaleWithFrame:frame + i scale:sc snap:sn];
|
||||
[self scaleWithFrame: frame + i scale: sc snap: sn];
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
|
|
|
@ -7,17 +7,17 @@ OF_DIRECT_MEMBERS
|
|||
@property (nonatomic) int rad, h, zoff, snap;
|
||||
@property (copy, nonatomic) OFString *name;
|
||||
|
||||
+ (instancetype)infoWithRad:(int)rad
|
||||
h:(int)h
|
||||
zoff:(int)zoff
|
||||
snap:(int)snap
|
||||
name:(OFString *)name;
|
||||
+ (instancetype)infoWithRad: (int)rad
|
||||
h: (int)h
|
||||
zoff: (int)zoff
|
||||
snap: (int)snap
|
||||
name: (OFString *)name;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithRad:(int)rad
|
||||
h:(int)h
|
||||
zoff:(int)zoff
|
||||
snap:(int)snap
|
||||
name:(OFString *)name;
|
||||
- (instancetype)initWithRad: (int)rad
|
||||
h: (int)h
|
||||
zoff: (int)zoff
|
||||
snap: (int)snap
|
||||
name: (OFString *)name;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
#import "MapModelInfo.h"
|
||||
|
||||
@implementation MapModelInfo
|
||||
+ (instancetype)infoWithRad:(int)rad
|
||||
h:(int)h
|
||||
zoff:(int)zoff
|
||||
snap:(int)snap
|
||||
name:(OFString *)name
|
||||
+ (instancetype)infoWithRad: (int)rad
|
||||
h: (int)h
|
||||
zoff: (int)zoff
|
||||
snap: (int)snap
|
||||
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
|
||||
h:(int)h
|
||||
zoff:(int)zoff
|
||||
snap:(int)snap
|
||||
name:(OFString *)name
|
||||
- (instancetype)initWithRad: (int)rad
|
||||
h: (int)h
|
||||
zoff: (int)zoff
|
||||
snap: (int)snap
|
||||
name: (OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ OF_DIRECT_MEMBERS
|
|||
@property (nonatomic) int mwidth;
|
||||
@property (nonatomic) int menusel;
|
||||
|
||||
+ (instancetype)menuWithName:(OFString *)name;
|
||||
+ (instancetype)menuWithName: (OFString *)name;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name;
|
||||
- (instancetype)initWithName: (OFString *)name;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#import "Menu.h"
|
||||
|
||||
@implementation Menu
|
||||
+ (instancetype)menuWithName:(OFString *)name
|
||||
+ (instancetype)menuWithName: (OFString *)name
|
||||
{
|
||||
return [[self alloc] initWithName:name];
|
||||
return [[self alloc] initWithName: name];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ OF_DIRECT_MEMBERS
|
|||
@interface MenuItem: OFObject
|
||||
@property (readonly, nonatomic) OFString *text, *action;
|
||||
|
||||
+ (instancetype)itemWithText:(OFString *)text action:(OFString *)action;
|
||||
+ (instancetype)itemWithText: (OFString *)text action: (OFString *)action;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithText:(OFString *)text action:(OFString *)action;
|
||||
- (instancetype)initWithText: (OFString *)text action: (OFString *)action;
|
||||
@end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#import "MenuItem.h"
|
||||
|
||||
@implementation MenuItem
|
||||
+ (instancetype)itemWithText:(OFString *)text action:(OFString *)action
|
||||
+ (instancetype)itemWithText: (OFString *)text action: (OFString *)action
|
||||
{
|
||||
return [[self alloc] initWithText:text action:action];
|
||||
return [[self alloc] initWithText: text action: action];
|
||||
}
|
||||
|
||||
- (instancetype)initWithText:(OFString *)text action:(OFString *)action
|
||||
- (instancetype)initWithText: (OFString *)text action: (OFString *)action
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (OFComparisonResult)compare:(id)otherObject
|
||||
- (OFComparisonResult)compare: (id)otherObject
|
||||
{
|
||||
MenuItem *otherItem;
|
||||
|
||||
if (![otherObject isKindOfClass:MenuItem.class])
|
||||
if (![otherObject isKindOfClass: MenuItem.class])
|
||||
@throw [OFInvalidArgumentException exception];
|
||||
|
||||
int x, y;
|
||||
|
|
|
@ -25,16 +25,16 @@ OF_DIRECT_MEMBERS
|
|||
+ (void)thinkAll;
|
||||
+ (void)renderAll;
|
||||
// TODO: Move this somewhere else
|
||||
+ (void)endSinglePlayerWithAllKilled:(bool)allKilled;
|
||||
+ (instancetype)monsterWithType:(int)type
|
||||
yaw:(int)yaw
|
||||
state:(int)state
|
||||
trigger:(int)trigger
|
||||
move:(int)move;
|
||||
- (instancetype)initWithType:(int)type
|
||||
yaw:(int)yaw
|
||||
state:(int)state
|
||||
trigger:(int)trigger
|
||||
move:(int)move;
|
||||
- (void)incurDamage:(int)damage fromEntity:(__kindof DynamicEntity *)d;
|
||||
+ (void)endSinglePlayerWithAllKilled: (bool)allKilled;
|
||||
+ (instancetype)monsterWithType: (int)type
|
||||
yaw: (int)yaw
|
||||
state: (int)state
|
||||
trigger: (int)trigger
|
||||
move: (int)move;
|
||||
- (instancetype)initWithType: (int)type
|
||||
yaw: (int)yaw
|
||||
state: (int)state
|
||||
trigger: (int)trigger
|
||||
move: (int)move;
|
||||
- (void)incurDamage: (int)damage fromEntity: (__kindof DynamicEntity *)d;
|
||||
@end
|
||||
|
|
128
src/Monster.m
128
src/Monster.m
|
@ -22,17 +22,17 @@ static int nextmonster, spawnremain, numkilled, monstertotal, mtimestart;
|
|||
return monsters;
|
||||
}
|
||||
|
||||
+ (instancetype)monsterWithType:(int)type
|
||||
yaw:(int)yaw
|
||||
state:(int)state
|
||||
trigger:(int)trigger
|
||||
move:(int)move
|
||||
+ (instancetype)monsterWithType: (int)type
|
||||
yaw: (int)yaw
|
||||
state: (int)state
|
||||
trigger: (int)trigger
|
||||
move: (int)move
|
||||
{
|
||||
return [[self alloc] initWithType:type
|
||||
yaw:yaw
|
||||
state:state
|
||||
trigger:trigger
|
||||
move:move];
|
||||
return [[self alloc] initWithType: type
|
||||
yaw: yaw
|
||||
state: state
|
||||
trigger: trigger
|
||||
move: move];
|
||||
}
|
||||
|
||||
VARF(skill, 1, 3, 10, conoutf(@"skill is now %d", skill));
|
||||
|
@ -75,11 +75,11 @@ monstertypes[NUMMONSTERTYPES] = {
|
|||
@"a goblin", @"monster/goblin" },
|
||||
};
|
||||
|
||||
- (instancetype)initWithType:(int)type
|
||||
yaw:(int)yaw
|
||||
state:(int)state
|
||||
trigger:(int)trigger
|
||||
move:(int)move
|
||||
- (instancetype)initWithType: (int)type
|
||||
yaw: (int)yaw
|
||||
state: (int)state
|
||||
trigger: (int)trigger
|
||||
move: (int)move
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
@ -146,11 +146,11 @@ spawnmonster() // spawn a random monster according to freq distribution in DMSP
|
|||
}
|
||||
}
|
||||
|
||||
[monsters addObject:[Monster monsterWithType:type
|
||||
yaw:rnd(360)
|
||||
state:M_SEARCH
|
||||
trigger:1000
|
||||
move:1]];
|
||||
[monsters addObject: [Monster monsterWithType: type
|
||||
yaw: rnd(360)
|
||||
state: M_SEARCH
|
||||
trigger: 1000
|
||||
move: 1]];
|
||||
}
|
||||
|
||||
+ (void)resetAll
|
||||
|
@ -171,13 +171,13 @@ spawnmonster() // spawn a random monster according to freq distribution in DMSP
|
|||
if (e.type != MONSTER)
|
||||
continue;
|
||||
|
||||
Monster *m = [Monster monsterWithType:e.attr2
|
||||
yaw:e.attr1
|
||||
state:M_SLEEP
|
||||
trigger:100
|
||||
move:0];
|
||||
Monster *m = [Monster monsterWithType: e.attr2
|
||||
yaw: e.attr1
|
||||
state: M_SLEEP
|
||||
trigger: 100
|
||||
move: 0];
|
||||
m.origin = OFMakeVector3D(e.x, e.y, e.z);
|
||||
[monsters addObject:m];
|
||||
[monsters addObject: m];
|
||||
entinmap(m);
|
||||
monstertotal++;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
// decision making means tougher AI.
|
||||
|
||||
// n = at skill 0, n/2 = at skill 10, r = added random factor
|
||||
- (void)transitionWithState:(int)state moving:(int)moving n:(int)n r:(int)r
|
||||
- (void)transitionWithState: (int)state moving: (int)moving n: (int)n r: (int)r
|
||||
{
|
||||
self.monsterState = state;
|
||||
self.move = moving;
|
||||
|
@ -245,7 +245,7 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
self.trigger = lastmillis + n - skill * (n / 16) + rnd(r + 1);
|
||||
}
|
||||
|
||||
- (void)normalizeWithAngle:(float)angle
|
||||
- (void)normalizeWithAngle: (float)angle
|
||||
{
|
||||
while (self.yaw < angle - 180.0f)
|
||||
self.yaw += 360.0f;
|
||||
|
@ -260,7 +260,7 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
self.enemy = Player.player1;
|
||||
self.anger = 0;
|
||||
}
|
||||
[self normalizeWithAngle:self.targetYaw];
|
||||
[self normalizeWithAngle: self.targetYaw];
|
||||
// slowly turn monster towards his target
|
||||
if (self.targetYaw > self.yaw) {
|
||||
self.yaw += curtime * 0.5f;
|
||||
|
@ -288,10 +288,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
(self.monsterState != M_HOME || !rnd(5))) {
|
||||
// patented "random walk" AI pathfinding (tm) ;)
|
||||
self.targetYaw += 180 + rnd(180);
|
||||
[self transitionWithState:M_SEARCH
|
||||
moving:1
|
||||
n:400
|
||||
r:1000];
|
||||
[self transitionWithState: M_SEARCH
|
||||
moving: 1
|
||||
n: 400
|
||||
r: 1000];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
case M_ATTACKING:
|
||||
case M_SEARCH:
|
||||
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;
|
||||
|
||||
case M_SLEEP: // state classic sp monster start in, wait for visual
|
||||
|
@ -314,14 +317,17 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
OFVector3D target;
|
||||
if (editmode || !enemylos(self, &target))
|
||||
return; // skip running physics
|
||||
[self normalizeWithAngle:enemyYaw];
|
||||
[self normalizeWithAngle: enemyYaw];
|
||||
float angle = (float)fabs(enemyYaw - self.yaw);
|
||||
if (disttoenemy < 8 // the better the angle to the player, the
|
||||
// further the monster can see/hear
|
||||
|| (disttoenemy < 16 && angle < 135) ||
|
||||
(disttoenemy < 32 && angle < 90) ||
|
||||
(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;
|
||||
playsound(S_GRUNT1 + rnd(2), &loc);
|
||||
}
|
||||
|
@ -335,10 +341,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
self.lastAction = 0;
|
||||
self.attacking = true;
|
||||
shoot(self, self.attackTarget);
|
||||
[self transitionWithState:M_ATTACKING
|
||||
moving:0
|
||||
n:600
|
||||
r:0];
|
||||
[self transitionWithState: M_ATTACKING
|
||||
moving: 0
|
||||
n: 600
|
||||
r: 0];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -351,10 +357,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
if (!enemylos(self, &target)) {
|
||||
// no visual contact anymore, let monster get
|
||||
// as close as possible then search for player
|
||||
[self transitionWithState:M_HOME
|
||||
moving:1
|
||||
n:800
|
||||
r:500];
|
||||
[self transitionWithState: M_HOME
|
||||
moving: 1
|
||||
n: 800
|
||||
r: 500];
|
||||
} else {
|
||||
// the closer the monster is the more likely he
|
||||
// wants to shoot
|
||||
|
@ -364,18 +370,18 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
self.attackTarget = target;
|
||||
int n =
|
||||
monstertypes[self.monsterType].lag;
|
||||
[self transitionWithState:M_AIMING
|
||||
moving:0
|
||||
n:n
|
||||
r:10];
|
||||
[self transitionWithState: M_AIMING
|
||||
moving: 0
|
||||
n: n
|
||||
r: 10];
|
||||
} else {
|
||||
// track player some more
|
||||
int n =
|
||||
monstertypes[self.monsterType].rate;
|
||||
[self transitionWithState:M_HOME
|
||||
moving:1
|
||||
n:n
|
||||
r:0];
|
||||
[self transitionWithState: M_HOME
|
||||
moving: 1
|
||||
n: n
|
||||
r: 0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -385,10 +391,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
moveplayer(self, 1, false); // use physics to move monster
|
||||
}
|
||||
|
||||
- (void)incurDamage:(int)damage fromEntity:(__kindof DynamicEntity *)d
|
||||
- (void)incurDamage: (int)damage fromEntity: (__kindof DynamicEntity *)d
|
||||
{
|
||||
// a monster hit us
|
||||
if ([d isKindOfClass:Monster.class]) {
|
||||
if ([d isKindOfClass: Monster.class]) {
|
||||
Monster *m = (Monster *)d;
|
||||
|
||||
// guard for RL guys shooting themselves :)
|
||||
|
@ -409,10 +415,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
}
|
||||
|
||||
// in this state monster won't attack
|
||||
[self transitionWithState:M_PAIN
|
||||
moving:0
|
||||
n:monstertypes[self.monsterType].pain
|
||||
r:200];
|
||||
[self transitionWithState: M_PAIN
|
||||
moving: 0
|
||||
n: monstertypes[self.monsterType].pain
|
||||
r: 200];
|
||||
|
||||
if ((self.health -= damage) <= 0) {
|
||||
self.state = CS_DEAD;
|
||||
|
@ -430,7 +436,7 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
}
|
||||
}
|
||||
|
||||
+ (void)endSinglePlayerWithAllKilled:(bool)allKilled
|
||||
+ (void)endSinglePlayerWithAllKilled: (bool)allKilled
|
||||
{
|
||||
conoutf(allKilled ? @"you have cleared the map!"
|
||||
: @"you reached the exit!");
|
||||
|
@ -450,10 +456,10 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
}
|
||||
|
||||
if (monstertotal && !spawnremain && numkilled == monstertotal)
|
||||
[self endSinglePlayerWithAllKilled:true];
|
||||
[self endSinglePlayerWithAllKilled: true];
|
||||
|
||||
// equivalent of player entity touch, but only teleports are used
|
||||
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
|
||||
[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
|
||||
if (e.type != TELEPORT)
|
||||
return;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
- (void)cube_setAsGLColor
|
||||
{
|
||||
float red, green, blue, alpha;
|
||||
[self getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||
[self getRed: &red green: &green blue: &blue alpha: &alpha];
|
||||
glColor4f(red, green, blue, alpha);
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
@interface OFString (Cube)
|
||||
@property (readonly, nonatomic) int cube_intValue;
|
||||
|
||||
- (int)cube_intValueWithBase:(unsigned char)base;
|
||||
- (int)cube_intValueWithBase: (unsigned char)base;
|
||||
@end
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (int)cube_intValueWithBase:(unsigned char)base
|
||||
- (int)cube_intValueWithBase: (unsigned char)base
|
||||
{
|
||||
@try {
|
||||
return [self intValueWithBase:base];
|
||||
return [self intValueWithBase: base];
|
||||
} @catch (OFInvalidFormatException *e) {
|
||||
conoutf(@"invalid value: %@", self);
|
||||
return 0;
|
||||
|
|
|
@ -14,7 +14,7 @@ static Player *player1;
|
|||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
+ (void)setPlayer1:(Player *)player1_
|
||||
+ (void)setPlayer1: (Player *)player1_
|
||||
{
|
||||
player1 = player1_;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ OF_DIRECT_MEMBERS
|
|||
@property (readonly, nonatomic) OFString *query;
|
||||
@property (readonly, nonatomic) ENetAddress address;
|
||||
|
||||
+ (instancetype)resultWithQuery:(OFString *)query address:(ENetAddress)address;
|
||||
+ (instancetype)resultWithQuery: (OFString *)query
|
||||
address: (ENetAddress)address;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithQuery:(OFString *)query address:(ENetAddress)address;
|
||||
- (instancetype)initWithQuery: (OFString *)query
|
||||
address: (ENetAddress)address OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#import "ResolverResult.h"
|
||||
|
||||
@implementation ResolverResult
|
||||
+ (instancetype)resultWithQuery:(OFString *)query address:(ENetAddress)address
|
||||
+ (instancetype)resultWithQuery: (OFString *)query address: (ENetAddress)address
|
||||
{
|
||||
return [[self alloc] initWithQuery:query address:address];
|
||||
return [[self alloc] initWithQuery: query address: address];
|
||||
}
|
||||
|
||||
- (instancetype)initWithQuery:(OFString *)query address:(ENetAddress)address
|
||||
- (instancetype)initWithQuery: (OFString *)query address: (ENetAddress)address
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ extern OFMutableArray<ResolverResult *> *resolverresults;
|
|||
enet_address_set_host(&address, _query.UTF8String);
|
||||
|
||||
@synchronized(ResolverThread.class) {
|
||||
[resolverresults
|
||||
addObject:[ResolverResult resultWithQuery:_query
|
||||
address:address]];
|
||||
[resolverresults addObject:
|
||||
[ResolverResult resultWithQuery: _query
|
||||
address: address]];
|
||||
|
||||
_query = NULL;
|
||||
_starttime = 0;
|
||||
|
|
|
@ -11,7 +11,7 @@ OF_DIRECT_MEMBERS
|
|||
@property (nonatomic) int mode, numplayers, ping, protocol, minremain;
|
||||
@property (nonatomic) ENetAddress address;
|
||||
|
||||
+ (instancetype)infoWithName:(OFString *)name;
|
||||
+ (instancetype)infoWithName: (OFString *)name;
|
||||
- (instancetype)init OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name;
|
||||
- (instancetype)initWithName: (OFString *)name;
|
||||
@end
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
#include "cube.h"
|
||||
|
||||
@implementation ServerInfo
|
||||
+ (instancetype)infoWithName:(OFString *)name;
|
||||
+ (instancetype)infoWithName: (OFString *)name;
|
||||
{
|
||||
return [[self alloc] initWithName:name];
|
||||
return [[self alloc] initWithName: name];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
@ -27,9 +27,9 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (OFComparisonResult)compare:(ServerInfo *)otherObject
|
||||
- (OFComparisonResult)compare: (ServerInfo *)otherObject
|
||||
{
|
||||
if (![otherObject isKindOfClass:ServerInfo.class])
|
||||
if (![otherObject isKindOfClass: ServerInfo.class])
|
||||
@throw [OFInvalidArgumentException exception];
|
||||
|
||||
if (_ping > otherObject.ping)
|
||||
|
@ -37,6 +37,6 @@
|
|||
if (_ping < otherObject.ping)
|
||||
return OFOrderedAscending;
|
||||
|
||||
return [_name compare:otherObject.name];
|
||||
return [_name compare: otherObject.name];
|
||||
}
|
||||
@end
|
||||
|
|
172
src/Variable.h
172
src/Variable.h
|
@ -2,76 +2,84 @@
|
|||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define VARP(name, min_, cur, max_) \
|
||||
int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^{ \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName:@ #name \
|
||||
min:min_ \
|
||||
max:max_ \
|
||||
storage:&name \
|
||||
function:NULL \
|
||||
persisted:true]; \
|
||||
Identifier.identifiers[@ #name] = variable; \
|
||||
}); \
|
||||
#define VARP(name, min_, cur, max_) \
|
||||
int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^ { \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName: @#name \
|
||||
min: min_ \
|
||||
max: max_ \
|
||||
storage: &name \
|
||||
function: NULL \
|
||||
persisted: true]; \
|
||||
Identifier.identifiers[@#name] = variable; \
|
||||
}); \
|
||||
}
|
||||
#define VAR(name, min_, cur, max_) \
|
||||
int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^{ \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName:@ #name \
|
||||
min:min_ \
|
||||
max:max_ \
|
||||
storage:&name \
|
||||
function:NULL \
|
||||
persisted:false]; \
|
||||
Identifier.identifiers[@ #name] = variable; \
|
||||
}); \
|
||||
#define VAR(name, min_, cur, max_) \
|
||||
int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^ { \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName: @#name \
|
||||
min: min_ \
|
||||
max: max_ \
|
||||
storage: &name \
|
||||
function: NULL \
|
||||
persisted: false]; \
|
||||
Identifier.identifiers[@#name] = variable; \
|
||||
}); \
|
||||
}
|
||||
#define VARF(name, min_, cur, max_, body) \
|
||||
static void var_##name(void); \
|
||||
static int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^ { \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName: @#name \
|
||||
min: min_ \
|
||||
max: max_ \
|
||||
storage: &name \
|
||||
function: var_##name \
|
||||
persisted: false]; \
|
||||
Identifier.identifiers[@#name] = variable; \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
var_##name(void) \
|
||||
{ \
|
||||
body; \
|
||||
}
|
||||
#define VARFP(name, min_, cur, max_, body) \
|
||||
static void var_##name(void); \
|
||||
static int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^ { \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName: @#name \
|
||||
min: min_ \
|
||||
max: max_ \
|
||||
storage: &name \
|
||||
function: var_##name \
|
||||
persisted: true]; \
|
||||
Identifier.identifiers[@#name] = variable; \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
var_##name(void) \
|
||||
{ \
|
||||
body; \
|
||||
}
|
||||
#define VARF(name, min_, cur, max_, body) \
|
||||
static void var_##name(); \
|
||||
static int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^{ \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName:@ #name \
|
||||
min:min_ \
|
||||
max:max_ \
|
||||
storage:&name \
|
||||
function:var_##name \
|
||||
persisted:false]; \
|
||||
Identifier.identifiers[@ #name] = variable; \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
static void var_##name() { body; }
|
||||
#define VARFP(name, min_, cur, max_, body) \
|
||||
static void var_##name(); \
|
||||
static int name = cur; \
|
||||
\
|
||||
OF_CONSTRUCTOR() \
|
||||
{ \
|
||||
enqueueInit(^{ \
|
||||
Variable *variable = \
|
||||
[Variable variableWithName:@ #name \
|
||||
min:min_ \
|
||||
max:max_ \
|
||||
storage:&name \
|
||||
function:var_##name \
|
||||
persisted:true]; \
|
||||
Identifier.identifiers[@ #name] = variable; \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
static void var_##name() { body; }
|
||||
|
||||
@interface Variable: Identifier
|
||||
@property (direct, readonly, nonatomic) int min, max;
|
||||
|
@ -79,22 +87,22 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
@property (direct, readonly, nullable, nonatomic) void (*function)();
|
||||
@property (readonly, nonatomic) bool persisted;
|
||||
|
||||
+ (instancetype)variableWithName:(OFString *)name
|
||||
min:(int)min
|
||||
max:(int)max
|
||||
storage:(int *)storage
|
||||
function:(void (*_Nullable)())function
|
||||
persisted:(bool)persisted OF_DIRECT;
|
||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
min:(int)min
|
||||
max:(int)max
|
||||
storage:(int *)storage
|
||||
function:(void (*_Nullable)())function
|
||||
persisted:(bool)persisted OF_DESIGNATED_INITIALIZER
|
||||
+ (instancetype)variableWithName: (OFString *)name
|
||||
min: (int)min
|
||||
max: (int)max
|
||||
storage: (int *)storage
|
||||
function: (void (*_Nullable)())function
|
||||
persisted: (bool)persisted OF_DIRECT;
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
min: (int)min
|
||||
max: (int)max
|
||||
storage: (int *)storage
|
||||
function: (void (*_Nullable)())function
|
||||
persisted: (bool)persisted OF_DESIGNATED_INITIALIZER
|
||||
OF_DIRECT;
|
||||
- (void)printValue OF_DIRECT;
|
||||
- (void)setValue:(int)value OF_DIRECT;
|
||||
- (void)setValue: (int)value OF_DIRECT;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -3,29 +3,29 @@
|
|||
#include "cube.h"
|
||||
|
||||
@implementation Variable
|
||||
+ (instancetype)variableWithName:(OFString *)name
|
||||
min:(int)min
|
||||
max:(int)max
|
||||
storage:(int *)storage
|
||||
function:(void (*__cdecl)())function
|
||||
persisted:(bool)persisted
|
||||
+ (instancetype)variableWithName: (OFString *)name
|
||||
min: (int)min
|
||||
max: (int)max
|
||||
storage: (int *)storage
|
||||
function: (void (*__cdecl)())function
|
||||
persisted: (bool)persisted
|
||||
{
|
||||
return [[self alloc] initWithName:name
|
||||
min:min
|
||||
max:max
|
||||
storage:storage
|
||||
function:function
|
||||
persisted:persisted];
|
||||
return [[self alloc] initWithName: name
|
||||
min: min
|
||||
max: max
|
||||
storage: storage
|
||||
function: function
|
||||
persisted: persisted];
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(OFString *)name
|
||||
min:(int)min
|
||||
max:(int)max
|
||||
storage:(int *)storage
|
||||
function:(void (*__cdecl)())function
|
||||
persisted:(bool)persisted
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
min: (int)min
|
||||
max: (int)max
|
||||
storage: (int *)storage
|
||||
function: (void (*__cdecl)())function
|
||||
persisted: (bool)persisted
|
||||
{
|
||||
self = [super initWithName:name];
|
||||
self = [super initWithName: name];
|
||||
|
||||
_min = min;
|
||||
_max = max;
|
||||
|
@ -41,7 +41,7 @@
|
|||
conoutf(@"%@ = %d", self.name, *_storage);
|
||||
}
|
||||
|
||||
- (void)setValue:(int)value
|
||||
- (void)setValue: (int)value
|
||||
{
|
||||
bool outOfRange = false;
|
||||
|
||||
|
|
|
@ -51,21 +51,21 @@ renderclient(
|
|||
// mdl = (((int)d>>6)&1)+1;
|
||||
// mz = d.o.z-d.eyeHeight+0.2f;
|
||||
// scale = 1.2f;
|
||||
} else if (d.state == CS_EDITING) {
|
||||
} else if (d.state == CS_EDITING)
|
||||
n = 16;
|
||||
} else if (d.state == CS_LAGGED) {
|
||||
else if (d.state == CS_LAGGED)
|
||||
n = 17;
|
||||
} else if ([d isKindOfClass:Monster.class] &&
|
||||
((Monster *)d).monsterState == M_ATTACKING) {
|
||||
else if ([d isKindOfClass: Monster.class] &&
|
||||
((Monster *)d).monsterState == M_ATTACKING)
|
||||
n = 8;
|
||||
} else if ([d isKindOfClass:Monster.class] &&
|
||||
((Monster *)d).monsterState == M_PAIN) {
|
||||
else if ([d isKindOfClass: Monster.class] &&
|
||||
((Monster *)d).monsterState == M_PAIN)
|
||||
n = 10;
|
||||
} else if ((!d.move && !d.strafe) || !d.moving) {
|
||||
else if ((!d.move && !d.strafe) || !d.moving)
|
||||
n = 12;
|
||||
} else if (!d.onFloor && d.timeInAir > 100) {
|
||||
else if (!d.onFloor && d.timeInAir > 100)
|
||||
n = 18;
|
||||
} else {
|
||||
else {
|
||||
n = 14;
|
||||
speed = 1200 / d.maxSpeed * scale;
|
||||
if (hellpig)
|
||||
|
@ -86,14 +86,13 @@ extern int democlientnum;
|
|||
void
|
||||
renderclients()
|
||||
{
|
||||
[players
|
||||
enumerateObjectsUsingBlock:^(Player *player, size_t i, bool *stop) {
|
||||
if ([player isKindOfClass:Player.class] &&
|
||||
(!demoplayback || i != democlientnum))
|
||||
renderclient(player,
|
||||
isteam(Player.player1.team, [player team]),
|
||||
@"monster/ogro", false, 1.0f);
|
||||
}];
|
||||
[players enumerateObjectsUsingBlock: ^ (Player *player, size_t i,
|
||||
bool *stop) {
|
||||
if ([player isKindOfClass: Player.class] &&
|
||||
(!demoplayback || i != democlientnum))
|
||||
renderclient(player, isteam(Player.player1.team,
|
||||
[player team]), @"monster/ogro", false, 1.0f);
|
||||
}];
|
||||
}
|
||||
|
||||
// creation of scoreboard pseudo-menu
|
||||
|
@ -112,16 +111,16 @@ static OFMutableArray<OFString *> *scoreLines;
|
|||
static void
|
||||
renderscore(Player *d)
|
||||
{
|
||||
OFString *lag = [OFString stringWithFormat:@"%d", d.lag];
|
||||
OFString *name = [OFString stringWithFormat:@"(%@)", d.name];
|
||||
OFString *line = [OFString stringWithFormat:@"%d\t%@\t%d\t%@\t%@",
|
||||
OFString *lag = [OFString stringWithFormat: @"%d", d.lag];
|
||||
OFString *name = [OFString stringWithFormat: @"(%@)", d.name];
|
||||
OFString *line = [OFString stringWithFormat: @"%d\t%@\t%d\t%@\t%@",
|
||||
d.frags, (d.state == CS_LAGGED ? @"LAG" : lag), d.ping, d.team,
|
||||
(d.state == CS_DEAD ? name : d.name)];
|
||||
|
||||
if (scoreLines == nil)
|
||||
scoreLines = [[OFMutableArray alloc] init];
|
||||
|
||||
[scoreLines addObject:line];
|
||||
[scoreLines addObject: line];
|
||||
|
||||
menumanual(0, scoreLines.count - 1, line);
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ static void
|
|||
addteamscore(Player *d)
|
||||
{
|
||||
for (size_t i = 0; i < teamsUsed; i++) {
|
||||
if ([teamName[i] isEqual:d.team]) {
|
||||
if ([teamName[i] isEqual: d.team]) {
|
||||
teamScore[i] += d.frags;
|
||||
return;
|
||||
}
|
||||
|
@ -157,20 +156,20 @@ renderscores()
|
|||
if (!demoplayback)
|
||||
renderscore(Player.player1);
|
||||
for (Player *player in players)
|
||||
if ([player isKindOfClass:Player.class])
|
||||
if ([player isKindOfClass: Player.class])
|
||||
renderscore(player);
|
||||
sortmenu();
|
||||
if (m_teammode) {
|
||||
teamsUsed = 0;
|
||||
for (Player *player in players)
|
||||
if ([player isKindOfClass:Player.class])
|
||||
if ([player isKindOfClass: Player.class])
|
||||
addteamscore(player);
|
||||
if (!demoplayback)
|
||||
addteamscore(Player.player1);
|
||||
OFMutableString *teamScores = [OFMutableString string];
|
||||
for (size_t j = 0; j < teamsUsed; j++)
|
||||
[teamScores appendFormat:@"[ %@: %d ]", teamName[j],
|
||||
teamScore[j]];
|
||||
[teamScores appendFormat:
|
||||
@"[ %@: %d ]", teamName[j], teamScore[j]];
|
||||
menumanual(0, scoreLines.count, @"");
|
||||
menumanual(0, scoreLines.count + 1, teamScores);
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ renderscores()
|
|||
|
||||
// sendmap/getmap commands, should be replaced by more intuitive map downloading
|
||||
|
||||
COMMAND(sendmap, ARG_1STR, (^(OFString *mapname) {
|
||||
COMMAND(sendmap, ARG_1STR, (^ (OFString *mapname) {
|
||||
if (mapname.length > 0)
|
||||
save_world(mapname);
|
||||
changemap(mapname);
|
||||
|
@ -204,14 +203,12 @@ COMMAND(sendmap, ARG_1STR, (^(OFString *mapname) {
|
|||
enet_packet_resize(packet, p - start);
|
||||
sendpackettoserv(packet);
|
||||
conoutf(@"sending map %@ to server...", mapname);
|
||||
OFString *msg =
|
||||
[OFString stringWithFormat:@"[map %@ uploaded to server, "
|
||||
@"\"getmap\" to receive it]",
|
||||
mapname];
|
||||
OFString *msg = [OFString stringWithFormat:
|
||||
@"[map %@ uploaded to server, \"getmap\" to receive it]", mapname];
|
||||
toserver(msg);
|
||||
}))
|
||||
|
||||
COMMAND(getmap, ARG_NONE, ^{
|
||||
COMMAND(getmap, ARG_NONE, ^ {
|
||||
ENetPacket *packet =
|
||||
enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
|
||||
unsigned char *start = packet->data;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
int nextmode = 0; // nextmode becomes gamemode after next map load
|
||||
VAR(gamemode, 1, 0, 0);
|
||||
|
||||
COMMAND(mode, ARG_1INT, ^(int n) {
|
||||
COMMAND(mode, ARG_1INT, ^ (int n) {
|
||||
addmsg(1, 2, SV_GAMEMODE, nextmode = n);
|
||||
})
|
||||
|
||||
|
@ -53,7 +53,7 @@ arenacount(Player *d, int *alive, int *dead, OFString **lastteam, bool *oneteam)
|
|||
{
|
||||
if (d.state != CS_DEAD) {
|
||||
(*alive)++;
|
||||
if (![*lastteam isEqual:d.team])
|
||||
if (![*lastteam isEqual: d.team])
|
||||
*oneteam = false;
|
||||
*lastteam = d.team;
|
||||
} else
|
||||
|
@ -102,22 +102,22 @@ extern int democlientnum;
|
|||
void
|
||||
otherplayers()
|
||||
{
|
||||
[players
|
||||
enumerateObjectsUsingBlock:^(Player *player, size_t i, bool *stop) {
|
||||
if ([player isKindOfClass:Player.class])
|
||||
return;
|
||||
[players enumerateObjectsUsingBlock: ^ (Player *player, size_t i,
|
||||
bool *stop) {
|
||||
if ([player isKindOfClass: Player.class])
|
||||
return;
|
||||
|
||||
const int lagtime = lastmillis - player.lastUpdate;
|
||||
if (lagtime > 1000 && player.state == CS_ALIVE) {
|
||||
player.state = CS_LAGGED;
|
||||
return;
|
||||
}
|
||||
const int lagtime = lastmillis - player.lastUpdate;
|
||||
if (lagtime > 1000 && player.state == CS_ALIVE) {
|
||||
player.state = CS_LAGGED;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lagtime && player.state != CS_DEAD &&
|
||||
(!demoplayback || i != democlientnum))
|
||||
// use physics to extrapolate player position
|
||||
moveplayer(player, 2, false);
|
||||
}];
|
||||
if (lagtime && player.state != CS_DEAD &&
|
||||
(!demoplayback || i != democlientnum))
|
||||
// use physics to extrapolate player position
|
||||
moveplayer(player, 2, false);
|
||||
}];
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -140,7 +140,7 @@ respawn()
|
|||
|
||||
int sleepwait = 0;
|
||||
static OFString *sleepcmd = nil;
|
||||
COMMAND(sleep, ARG_2STR, ^(OFString *msec, OFString *cmd) {
|
||||
COMMAND(sleep, ARG_2STR, ^ (OFString *msec, OFString *cmd) {
|
||||
sleepwait = msec.cube_intValue + lastmillis;
|
||||
sleepcmd = cmd;
|
||||
})
|
||||
|
@ -237,12 +237,12 @@ spawnplayer(Player *d)
|
|||
|
||||
// movement input code
|
||||
|
||||
#define dir(name, v, d, s, os) \
|
||||
COMMAND(name, ARG_DOWN, ^(bool isDown) { \
|
||||
Player *player1 = Player.player1; \
|
||||
player1.s = isDown; \
|
||||
player1.v = isDown ? d : (player1.os ? -(d) : 0); \
|
||||
player1.lastMove = lastmillis; \
|
||||
#define dir(name, v, d, s, os) \
|
||||
COMMAND(name, ARG_DOWN, ^ (bool isDown) { \
|
||||
Player *player1 = Player.player1; \
|
||||
player1.s = isDown; \
|
||||
player1.v = isDown ? d : (player1.os ? -(d) : 0); \
|
||||
player1.lastMove = lastmillis; \
|
||||
})
|
||||
|
||||
dir(backward, move, -1, k_down, k_up);
|
||||
|
@ -250,7 +250,7 @@ dir(forward, move, 1, k_up, k_down);
|
|||
dir(left, strafe, 1, k_left, k_right);
|
||||
dir(right, strafe, -1, k_right, k_left);
|
||||
|
||||
COMMAND(attack, ARG_DOWN, ^(bool on) {
|
||||
COMMAND(attack, ARG_DOWN, ^ (bool on) {
|
||||
if (intermission)
|
||||
return;
|
||||
if (editmode)
|
||||
|
@ -259,12 +259,12 @@ COMMAND(attack, ARG_DOWN, ^(bool on) {
|
|||
respawn();
|
||||
})
|
||||
|
||||
COMMAND(jump, ARG_DOWN, ^(bool on) {
|
||||
COMMAND(jump, ARG_DOWN, ^ (bool on) {
|
||||
if (!intermission && (Player.player1.jumpNext = on))
|
||||
respawn();
|
||||
})
|
||||
|
||||
COMMAND(showscores, ARG_DOWN, ^(bool isDown) {
|
||||
COMMAND(showscores, ARG_DOWN, ^ (bool isDown) {
|
||||
showscores(isDown);
|
||||
})
|
||||
|
||||
|
@ -376,7 +376,7 @@ getclient(int cn) // ensure valid entity
|
|||
}
|
||||
|
||||
while (cn >= players.count)
|
||||
[players addObject:[OFNull null]];
|
||||
[players addObject: [OFNull null]];
|
||||
|
||||
id player = players[cn];
|
||||
if (player == [OFNull null]) {
|
||||
|
@ -393,7 +393,7 @@ setclient(int cn, id client)
|
|||
if (cn < 0 || cn >= MAXCLIENTS)
|
||||
neterr(@"clientnum");
|
||||
while (cn >= players.count)
|
||||
[players addObject:[OFNull null]];
|
||||
[players addObject: [OFNull null]];
|
||||
players[cn] = client;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ startmap(OFString *name) // called just after a map load
|
|||
spawnplayer(Player.player1);
|
||||
Player.player1.frags = 0;
|
||||
for (Player *player in players)
|
||||
if ([player isKindOfClass:Player.class])
|
||||
if ([player isKindOfClass: Player.class])
|
||||
player.frags = 0;
|
||||
resetspawns();
|
||||
clientmap = name;
|
||||
|
@ -433,6 +433,6 @@ startmap(OFString *name) // called just after a map load
|
|||
conoutf(@"game mode is %@", modestr(gamemode));
|
||||
}
|
||||
|
||||
COMMAND(map, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(map, ARG_1STR, ^ (OFString *name) {
|
||||
changemap(name);
|
||||
})
|
||||
|
|
|
@ -68,12 +68,12 @@ newname(OFString *name)
|
|||
c2sinit = false;
|
||||
|
||||
if (name.length > 16)
|
||||
name = [name substringToIndex:16];
|
||||
name = [name substringToIndex: 16];
|
||||
|
||||
Player.player1.name = name;
|
||||
}
|
||||
|
||||
COMMAND(name, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(name, ARG_1STR, ^ (OFString *name) {
|
||||
newname(name);
|
||||
})
|
||||
|
||||
|
@ -83,20 +83,20 @@ newteam(OFString *name)
|
|||
c2sinit = false;
|
||||
|
||||
if (name.length > 5)
|
||||
name = [name substringToIndex:5];
|
||||
name = [name substringToIndex: 5];
|
||||
|
||||
Player.player1.team = name;
|
||||
}
|
||||
|
||||
COMMAND(team, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(team, ARG_1STR, ^ (OFString *name) {
|
||||
newteam(name);
|
||||
})
|
||||
|
||||
void
|
||||
writeclientinfo(OFStream *stream)
|
||||
{
|
||||
[stream writeFormat:@"name \"%@\"\nteam \"%@\"\n", Player.player1.name,
|
||||
Player.player1.team];
|
||||
[stream writeFormat: @"name \"%@\"\nteam \"%@\"\n",
|
||||
Player.player1.name, Player.player1.team];
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -185,16 +185,16 @@ toserver(OFString *text)
|
|||
ctext = text;
|
||||
}
|
||||
|
||||
COMMAND(echo, ARG_VARI, ^(OFString *text) {
|
||||
COMMAND(echo, ARG_VARI, ^ (OFString *text) {
|
||||
conoutf(@"%@", text);
|
||||
})
|
||||
COMMAND(say, ARG_VARI, ^(OFString *text) {
|
||||
COMMAND(say, ARG_VARI, ^ (OFString *text) {
|
||||
toserver(text);
|
||||
})
|
||||
COMMAND(connect, ARG_1STR, ^(OFString *servername) {
|
||||
COMMAND(connect, ARG_1STR, ^ (OFString *servername) {
|
||||
connects(servername);
|
||||
})
|
||||
COMMAND(disconnect, ARG_NONE, ^{
|
||||
COMMAND(disconnect, ARG_NONE, ^ {
|
||||
trydisconnect();
|
||||
})
|
||||
|
||||
|
@ -215,17 +215,17 @@ addmsg(int rel, int num, int type, ...)
|
|||
return;
|
||||
}
|
||||
|
||||
OFMutableData *msg = [OFMutableData dataWithItemSize:sizeof(int)
|
||||
capacity:num + 2];
|
||||
[msg addItem:&num];
|
||||
[msg addItem:&rel];
|
||||
[msg addItem:&type];
|
||||
OFMutableData *msg = [OFMutableData dataWithItemSize: sizeof(int)
|
||||
capacity: num + 2];
|
||||
[msg addItem: &num];
|
||||
[msg addItem: &rel];
|
||||
[msg addItem: &type];
|
||||
|
||||
va_list marker;
|
||||
va_start(marker, type);
|
||||
for (int i = 0; i < num - 1; i++) {
|
||||
int tmp = va_arg(marker, int);
|
||||
[msg addItem:&tmp];
|
||||
[msg addItem: &tmp];
|
||||
}
|
||||
va_end(marker);
|
||||
[msg makeImmutable];
|
||||
|
@ -233,7 +233,7 @@ addmsg(int rel, int num, int type, ...)
|
|||
if (messages == nil)
|
||||
messages = [[OFMutableArray alloc] init];
|
||||
|
||||
[messages addObject:msg];
|
||||
[messages addObject: msg];
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -249,7 +249,7 @@ bool senditemstoserver =
|
|||
false; // after a map change, since server doesn't have map data
|
||||
|
||||
OFString *clientpassword;
|
||||
COMMAND(password, ARG_1STR, ^(OFString *p) {
|
||||
COMMAND(password, ARG_1STR, ^ (OFString *p) {
|
||||
clientpassword = p;
|
||||
})
|
||||
|
||||
|
@ -317,10 +317,9 @@ c2sinfo(Player *d)
|
|||
putint(&p, (int)(d.velocity.y * DVF));
|
||||
putint(&p, (int)(d.velocity.z * DVF));
|
||||
// pack rest in 1 byte: strafe:2, move:2, onFloor:1, state:3
|
||||
putint(&p,
|
||||
(d.strafe & 3) | ((d.move & 3) << 2) |
|
||||
(((int)d.onFloor) << 4) |
|
||||
((editmode ? CS_EDITING : d.state) << 5));
|
||||
putint(&p, (d.strafe & 3) | ((d.move & 3) << 2) |
|
||||
(((int)d.onFloor) << 4) |
|
||||
((editmode ? CS_EDITING : d.state) << 5));
|
||||
|
||||
if (senditemstoserver) {
|
||||
packet->flags = ENET_PACKET_FLAG_RELIABLE;
|
||||
|
@ -349,10 +348,10 @@ c2sinfo(Player *d)
|
|||
}
|
||||
for (OFData *msg in messages) {
|
||||
// send messages collected during the previous frames
|
||||
if (*(int *)[msg itemAtIndex:1])
|
||||
if (*(int *)[msg itemAtIndex: 1])
|
||||
packet->flags = ENET_PACKET_FLAG_RELIABLE;
|
||||
for (int i = 0; i < *(int *)[msg itemAtIndex:0]; i++)
|
||||
putint(&p, *(int *)[msg itemAtIndex:i + 2]);
|
||||
for (int i = 0; i < *(int *)[msg itemAtIndex: 0]; i++)
|
||||
putint(&p, *(int *)[msg itemAtIndex: i + 2]);
|
||||
}
|
||||
[messages removeAllObjects];
|
||||
if (lastmillis - lastping > 250) {
|
||||
|
|
|
@ -174,10 +174,10 @@ localservertoclient(unsigned char *buf, int len)
|
|||
// server requests next map
|
||||
case SV_MAPRELOAD: {
|
||||
getint(&p);
|
||||
OFString *nextmapalias = [OFString
|
||||
stringWithFormat:@"nextmap_%@", getclientmap()];
|
||||
OFString *map =
|
||||
getalias(nextmapalias); // look up map in the cycle
|
||||
OFString *nextmapalias = [OFString stringWithFormat:
|
||||
@"nextmap_%@", getclientmap()];
|
||||
// look up map in the cycle
|
||||
OFString *map = getalias(nextmapalias);
|
||||
changemap(map != nil ? map : getclientmap());
|
||||
break;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ localservertoclient(unsigned char *buf, int len)
|
|||
sgetstr();
|
||||
if (d_.name.length > 0) {
|
||||
// already connected
|
||||
if (![d_.name isEqual:@(text)])
|
||||
if (![d_.name isEqual: @(text)])
|
||||
conoutf(@"%@ is now known as %s",
|
||||
d_.name, text);
|
||||
} else {
|
||||
|
@ -279,7 +279,7 @@ localservertoclient(unsigned char *buf, int len)
|
|||
}
|
||||
|
||||
case SV_FRAGS:
|
||||
OFAssert([players[cn] isKindOfClass:Player.class]);
|
||||
OFAssert([players[cn] isKindOfClass: Player.class]);
|
||||
((Player *)players[cn]).frags = getint(&p);
|
||||
break;
|
||||
|
||||
|
@ -342,7 +342,7 @@ localservertoclient(unsigned char *buf, int len)
|
|||
while (ents.count <= i) {
|
||||
Entity *e = [Entity entity];
|
||||
e.type = NOTUSED;
|
||||
[ents addObject:e];
|
||||
[ents addObject: e];
|
||||
}
|
||||
|
||||
int to = ents[i].type;
|
||||
|
@ -372,7 +372,7 @@ localservertoclient(unsigned char *buf, int len)
|
|||
break;
|
||||
|
||||
case SV_CLIENTPING:
|
||||
OFAssert([players[cn] isKindOfClass:Player.class]);
|
||||
OFAssert([players[cn] isKindOfClass: Player.class]);
|
||||
((Player *)players[cn]).ping = getint(&p);
|
||||
break;
|
||||
|
||||
|
|
173
src/commands.m
173
src/commands.m
|
@ -21,11 +21,11 @@ alias(OFString *name, OFString *action)
|
|||
Alias *alias = Identifier.identifiers[name];
|
||||
|
||||
if (alias == nil)
|
||||
Identifier.identifiers[name] = [Alias aliasWithName:name
|
||||
action:action
|
||||
persisted:true];
|
||||
Identifier.identifiers[name] = [Alias aliasWithName: name
|
||||
action: action
|
||||
persisted: true];
|
||||
else {
|
||||
if ([alias isKindOfClass:Alias.class])
|
||||
if ([alias isKindOfClass: Alias.class])
|
||||
alias.action = action;
|
||||
else
|
||||
conoutf(
|
||||
|
@ -33,7 +33,7 @@ alias(OFString *name, OFString *action)
|
|||
}
|
||||
}
|
||||
|
||||
COMMAND(alias, ARG_2STR, ^(OFString *name, OFString *action) {
|
||||
COMMAND(alias, ARG_2STR, ^ (OFString *name, OFString *action) {
|
||||
alias(name, action);
|
||||
})
|
||||
|
||||
|
@ -42,7 +42,7 @@ setvar(OFString *name, int i)
|
|||
{
|
||||
Variable *variable = Identifier.identifiers[name];
|
||||
|
||||
if ([variable isKindOfClass:Variable.class])
|
||||
if ([variable isKindOfClass: Variable.class])
|
||||
*variable.storage = i;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ getvar(OFString *name)
|
|||
{
|
||||
Variable *variable = Identifier.identifiers[name];
|
||||
|
||||
if ([variable isKindOfClass:Variable.class])
|
||||
if ([variable isKindOfClass: Variable.class])
|
||||
return *variable.storage;
|
||||
|
||||
return 0;
|
||||
|
@ -68,7 +68,7 @@ getalias(OFString *name)
|
|||
{
|
||||
Alias *alias = Identifier.identifiers[name];
|
||||
|
||||
if ([alias isKindOfClass:Alias.class])
|
||||
if ([alias isKindOfClass: Alias.class])
|
||||
return alias.action;
|
||||
|
||||
return nil;
|
||||
|
@ -98,8 +98,8 @@ parseexp(char **p, int right)
|
|||
if (left == '(') {
|
||||
OFString *t;
|
||||
@try {
|
||||
t = [OFString
|
||||
stringWithFormat:@"%d", execute(@(s), true)];
|
||||
t = [OFString stringWithFormat:
|
||||
@"%d", execute(@(s), true)];
|
||||
} @finally {
|
||||
free(s);
|
||||
}
|
||||
|
@ -140,14 +140,15 @@ OFString *
|
|||
lookup(OFString *n)
|
||||
{
|
||||
__kindof Identifier *identifier =
|
||||
Identifier.identifiers[[n substringFromIndex:1]];
|
||||
Identifier.identifiers[[n substringFromIndex: 1]];
|
||||
|
||||
if ([identifier isKindOfClass:Variable.class]) {
|
||||
return [OFString stringWithFormat:@"%d", *[identifier storage]];
|
||||
} else if ([identifier isKindOfClass:Alias.class])
|
||||
if ([identifier isKindOfClass: Variable.class]) {
|
||||
return [OFString stringWithFormat:
|
||||
@"%d", *[identifier storage]];
|
||||
} else if ([identifier isKindOfClass: Alias.class])
|
||||
return [identifier action];
|
||||
|
||||
conoutf(@"unknown alias lookup: %@", [n substringFromIndex:1]);
|
||||
conoutf(@"unknown alias lookup: %@", [n substringFromIndex: 1]);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ executeIdentifier(__kindof Identifier *identifier,
|
|||
{
|
||||
if (identifier == nil) {
|
||||
@try {
|
||||
return [arguments[0] intValueWithBase:0];
|
||||
return [arguments[0] intValueWithBase: 0];
|
||||
} @catch (OFInvalidFormatException *e) {
|
||||
conoutf(@"unknown command: %@", arguments[0]);
|
||||
return 0;
|
||||
|
@ -167,12 +168,12 @@ executeIdentifier(__kindof Identifier *identifier,
|
|||
}
|
||||
}
|
||||
|
||||
if ([identifier isKindOfClass:Command.class])
|
||||
if ([identifier isKindOfClass: Command.class])
|
||||
// game defined commands use very ad-hoc function signature,
|
||||
// and just call it
|
||||
return [identifier callWithArguments:arguments isDown:isDown];
|
||||
return [identifier callWithArguments: arguments isDown: isDown];
|
||||
|
||||
if ([identifier isKindOfClass:Variable.class]) {
|
||||
if ([identifier isKindOfClass: Variable.class]) {
|
||||
if (!isDown)
|
||||
return 0;
|
||||
|
||||
|
@ -180,16 +181,16 @@ executeIdentifier(__kindof Identifier *identifier,
|
|||
if (arguments.count < 2 || arguments[1].length == 0)
|
||||
[identifier printValue];
|
||||
else
|
||||
[identifier
|
||||
setValue:[arguments[1] cube_intValueWithBase:0]];
|
||||
[identifier setValue:
|
||||
[arguments[1] cube_intValueWithBase: 0]];
|
||||
}
|
||||
|
||||
if ([identifier isKindOfClass:Alias.class]) {
|
||||
if ([identifier isKindOfClass: Alias.class]) {
|
||||
// alias, also used as functions and (global) variables
|
||||
for (int i = 1; i < arguments.count; i++) {
|
||||
// set any arguments as (global) arg values so
|
||||
// functions can access them
|
||||
OFString *t = [OFString stringWithFormat:@"arg%d", i];
|
||||
OFString *t = [OFString stringWithFormat: @"arg%d", i];
|
||||
alias(t, arguments[i]);
|
||||
}
|
||||
|
||||
|
@ -239,8 +240,8 @@ execute(OFString *string, bool isDown)
|
|||
cont = *p++ != 0;
|
||||
OFString *c = w[0];
|
||||
// strip irc-style command prefix
|
||||
if ([c hasPrefix:@"/"]) {
|
||||
c = [c substringFromIndex:1];
|
||||
if ([c hasPrefix: @"/"]) {
|
||||
c = [c substringFromIndex: 1];
|
||||
w[0] = c;
|
||||
}
|
||||
// empty statement
|
||||
|
@ -248,7 +249,7 @@ execute(OFString *string, bool isDown)
|
|||
continue;
|
||||
|
||||
val = executeIdentifier(Identifier.identifiers[c],
|
||||
[OFArray arrayWithObjects:w count:numargs], isDown);
|
||||
[OFArray arrayWithObjects: w count: numargs], isDown);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
@ -267,8 +268,8 @@ resetcomplete()
|
|||
void
|
||||
complete(OFMutableString *s)
|
||||
{
|
||||
if (![s hasPrefix:@"/"])
|
||||
[s insertString:@"/" atIndex:0];
|
||||
if (![s hasPrefix: @"/"])
|
||||
[s insertString: @"/" atIndex: 0];
|
||||
|
||||
if (s.length == 1)
|
||||
return;
|
||||
|
@ -279,13 +280,13 @@ complete(OFMutableString *s)
|
|||
}
|
||||
|
||||
__block int idx = 0;
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||
^ (OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||
if (strncmp(identifier.name.UTF8String, s.UTF8String + 1,
|
||||
completesize) == 0 &&
|
||||
idx++ == completeidx)
|
||||
[s replaceCharactersInRange:OFMakeRange(1, s.length - 1)
|
||||
withString:identifier.name];
|
||||
completesize) == 0 && idx++ == completeidx)
|
||||
[s replaceCharactersInRange: OFMakeRange(
|
||||
1, s.length - 1)
|
||||
withString: identifier.name];
|
||||
}];
|
||||
|
||||
completeidx++;
|
||||
|
@ -299,7 +300,7 @@ execfile(OFIRI *cfgfile)
|
|||
{
|
||||
OFString *command;
|
||||
@try {
|
||||
command = [OFString stringWithContentsOfIRI:cfgfile];
|
||||
command = [OFString stringWithContentsOfIRI: cfgfile];
|
||||
} @catch (OFOpenItemFailedException *e) {
|
||||
return false;
|
||||
} @catch (OFReadFailedException *e) {
|
||||
|
@ -314,13 +315,13 @@ void
|
|||
exec(OFString *cfgfile)
|
||||
{
|
||||
if (!execfile([Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent:cfgfile]) &&
|
||||
IRIByAppendingPathComponent: cfgfile]) &&
|
||||
!execfile([Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:cfgfile]))
|
||||
IRIByAppendingPathComponent: cfgfile]))
|
||||
conoutf(@"could not read \"%@\"", cfgfile);
|
||||
}
|
||||
|
||||
COMMAND(exec, ARG_1STR, ^(OFString *cfgfile) {
|
||||
COMMAND(exec, ARG_1STR, ^ (OFString *cfgfile) {
|
||||
exec(cfgfile);
|
||||
})
|
||||
|
||||
|
@ -330,50 +331,52 @@ writecfg()
|
|||
OFStream *stream;
|
||||
@try {
|
||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent:@"config.cfg"];
|
||||
stream = [[OFIRIHandler handlerForIRI:IRI] openItemAtIRI:IRI
|
||||
mode:@"w"];
|
||||
IRIByAppendingPathComponent: @"config.cfg"];
|
||||
stream = [[OFIRIHandler handlerForIRI: IRI]
|
||||
openItemAtIRI: IRI
|
||||
mode: @"w"];
|
||||
} @catch (id e) {
|
||||
return;
|
||||
}
|
||||
|
||||
[stream writeString:@"// automatically written on exit, do not modify\n"
|
||||
@"// delete this file to have defaults.cfg "
|
||||
@"overwrite these settings\n"
|
||||
@"// modify settings in game, or put settings in "
|
||||
@"autoexec.cfg to override anything\n"
|
||||
@"\n"];
|
||||
[stream writeString:
|
||||
@"// automatically written on exit, do not modify\n"
|
||||
@"// delete this file to have defaults.cfg overwrite these "
|
||||
@"settings\n"
|
||||
@"// modify settings in game, or put settings in autoexec.cfg to "
|
||||
@"override anything\n"
|
||||
@"\n"];
|
||||
writeclientinfo(stream);
|
||||
[stream writeString:@"\n"];
|
||||
[stream writeString: @"\n"];
|
||||
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||
if (![identifier isKindOfClass:Variable.class] ||
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||
^ (OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||
if (![identifier isKindOfClass: Variable.class] ||
|
||||
![identifier persisted])
|
||||
return;
|
||||
|
||||
[stream writeFormat:@"%@ %d\n", identifier.name,
|
||||
*[identifier storage]];
|
||||
[stream writeFormat:
|
||||
@"%@ %d\n", identifier.name, *[identifier storage]];
|
||||
}];
|
||||
[stream writeString:@"\n"];
|
||||
[stream writeString: @"\n"];
|
||||
|
||||
writebinds(stream);
|
||||
[stream writeString:@"\n"];
|
||||
[stream writeString: @"\n"];
|
||||
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:^(
|
||||
OFString *name, __kindof Identifier *identifier, bool *stop) {
|
||||
if (![identifier isKindOfClass:Alias.class] ||
|
||||
[identifier.name hasPrefix:@"nextmap_"])
|
||||
[Identifier.identifiers enumerateKeysAndObjectsUsingBlock:
|
||||
^ (OFString *name, Alias *alias, bool *stop) {
|
||||
if (![alias isKindOfClass: Alias.class] ||
|
||||
[alias.name hasPrefix: @"nextmap_"])
|
||||
return;
|
||||
|
||||
[stream writeFormat:@"alias \"%@\" [%@]\n", identifier.name,
|
||||
[identifier action]];
|
||||
[stream writeFormat: @"alias \"%@\" [%@]\n",
|
||||
alias.name, alias.action];
|
||||
}];
|
||||
|
||||
[stream close];
|
||||
}
|
||||
|
||||
COMMAND(writecfg, ARG_NONE, ^{
|
||||
COMMAND(writecfg, ARG_NONE, ^ {
|
||||
writecfg();
|
||||
})
|
||||
|
||||
|
@ -384,14 +387,14 @@ COMMAND(writecfg, ARG_NONE, ^{
|
|||
void
|
||||
intset(OFString *name, int v)
|
||||
{
|
||||
alias(name, [OFString stringWithFormat:@"%d", v]);
|
||||
alias(name, [OFString stringWithFormat: @"%d", v]);
|
||||
}
|
||||
|
||||
COMMAND(if, ARG_3STR, ^(OFString *cond, OFString *thenp, OFString *elsep) {
|
||||
execute((![cond hasPrefix:@"0"] ? thenp : elsep), true);
|
||||
COMMAND(if, ARG_3STR, ^ (OFString *cond, OFString *thenp, OFString *elsep) {
|
||||
execute((![cond hasPrefix: @"0"] ? thenp : elsep), true);
|
||||
})
|
||||
|
||||
COMMAND(loop, ARG_2STR, ^(OFString *times, OFString *body) {
|
||||
COMMAND(loop, ARG_2STR, ^ (OFString *times, OFString *body) {
|
||||
int t = times.cube_intValue;
|
||||
|
||||
for (int i = 0; i < t; i++) {
|
||||
|
@ -400,12 +403,12 @@ COMMAND(loop, ARG_2STR, ^(OFString *times, OFString *body) {
|
|||
}
|
||||
})
|
||||
|
||||
COMMAND(while, ARG_2STR, ^(OFString *cond, OFString *body) {
|
||||
COMMAND(while, ARG_2STR, ^ (OFString *cond, OFString *body) {
|
||||
while (execute(cond, true))
|
||||
execute(body, true);
|
||||
})
|
||||
|
||||
COMMAND(onrelease, ARG_DWN1, ^(bool on, OFString *body) {
|
||||
COMMAND(onrelease, ARG_DWN1, ^ (bool on, OFString *body) {
|
||||
if (!on)
|
||||
execute(body, true);
|
||||
})
|
||||
|
@ -416,15 +419,15 @@ concat(OFString *s)
|
|||
alias(@"s", s);
|
||||
}
|
||||
|
||||
COMMAND(concat, ARG_VARI, ^(OFString *s) {
|
||||
COMMAND(concat, ARG_VARI, ^ (OFString *s) {
|
||||
concat(s);
|
||||
})
|
||||
|
||||
COMMAND(concatword, ARG_VARI, ^(OFString *s) {
|
||||
concat([s stringByReplacingOccurrencesOfString:@" " withString:@""]);
|
||||
COMMAND(concatword, ARG_VARI, ^ (OFString *s) {
|
||||
concat([s stringByReplacingOccurrencesOfString: @" " withString: @""]);
|
||||
})
|
||||
|
||||
COMMAND(listlen, ARG_1EST, ^(OFString *a_) {
|
||||
COMMAND(listlen, ARG_1EST, ^ (OFString *a_) {
|
||||
const char *a = a_.UTF8String;
|
||||
|
||||
if (!*a)
|
||||
|
@ -438,7 +441,7 @@ COMMAND(listlen, ARG_1EST, ^(OFString *a_) {
|
|||
return n + 1;
|
||||
})
|
||||
|
||||
COMMAND(at, ARG_2STR, ^(OFString *s_, OFString *pos) {
|
||||
COMMAND(at, ARG_2STR, ^ (OFString *s_, OFString *pos) {
|
||||
int n = pos.cube_intValue;
|
||||
char *copy __attribute__((__cleanup__(cleanup))) =
|
||||
strdup(s_.UTF8String);
|
||||
|
@ -451,46 +454,46 @@ COMMAND(at, ARG_2STR, ^(OFString *s_, OFString *pos) {
|
|||
concat(@(s));
|
||||
})
|
||||
|
||||
COMMAND(+, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(+, ARG_2EXP, ^ (int a, int b) {
|
||||
return a + b;
|
||||
})
|
||||
|
||||
COMMAND(*, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(*, ARG_2EXP, ^ (int a, int b) {
|
||||
return a * b;
|
||||
})
|
||||
|
||||
COMMAND(-, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(-, ARG_2EXP, ^ (int a, int b) {
|
||||
return a - b;
|
||||
})
|
||||
|
||||
COMMAND(div, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(div, ARG_2EXP, ^ (int a, int b) {
|
||||
return b ? a / b : 0;
|
||||
})
|
||||
|
||||
COMMAND(mod, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(mod, ARG_2EXP, ^ (int a, int b) {
|
||||
return b ? a % b : 0;
|
||||
})
|
||||
|
||||
COMMAND(=, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(=, ARG_2EXP, ^ (int a, int b) {
|
||||
return (int)(a == b);
|
||||
})
|
||||
|
||||
COMMAND(<, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(<, ARG_2EXP, ^ (int a, int b) {
|
||||
return (int)(a < b);
|
||||
})
|
||||
|
||||
COMMAND(>, ARG_2EXP, ^(int a, int b) {
|
||||
COMMAND(>, ARG_2EXP, ^ (int a, int b) {
|
||||
return (int)(a > b);
|
||||
})
|
||||
|
||||
COMMAND(strcmp, ARG_2EST, ^(OFString *a, OFString *b) {
|
||||
return [a isEqual:b];
|
||||
COMMAND(strcmp, ARG_2EST, ^ (OFString *a, OFString *b) {
|
||||
return [a isEqual: b];
|
||||
})
|
||||
|
||||
COMMAND(rnd, ARG_1EXP, ^(int a) {
|
||||
COMMAND(rnd, ARG_1EXP, ^ (int a) {
|
||||
return (a > 0 ? rnd(a) : 0);
|
||||
})
|
||||
|
||||
COMMAND(millis, ARG_1EXP, ^(int unused) {
|
||||
COMMAND(millis, ARG_1EXP, ^ (int unused) {
|
||||
return lastmillis;
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@ int conskip = 0;
|
|||
bool saycommandon = false;
|
||||
static OFMutableString *commandbuf;
|
||||
|
||||
COMMAND(conskip, ARG_1INT, ^(int n) {
|
||||
COMMAND(conskip, ARG_1INT, ^ (int n) {
|
||||
conskip += n;
|
||||
if (conskip < 0)
|
||||
conskip = 0;
|
||||
|
@ -38,16 +38,16 @@ conline(OFString *sf, bool highlight) // add a line to the console buffer
|
|||
|
||||
if (highlight)
|
||||
// show line in a different colour, for chat etc.
|
||||
[text appendString:@"\f"];
|
||||
[text appendString: @"\f"];
|
||||
|
||||
[text appendString:sf];
|
||||
[text appendString: sf];
|
||||
|
||||
if (conlines == nil)
|
||||
conlines = [[OFMutableArray alloc] init];
|
||||
|
||||
[conlines insertObject:[ConsoleLine lineWithText:text
|
||||
outtime:lastmillis]
|
||||
atIndex:0];
|
||||
[conlines insertObject: [ConsoleLine lineWithText: text
|
||||
outtime: lastmillis]
|
||||
atIndex: 0];
|
||||
|
||||
puts(text.UTF8String);
|
||||
#ifndef OF_WINDOWS
|
||||
|
@ -61,15 +61,15 @@ conoutf(OFConstantString *format, ...)
|
|||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
|
||||
OFString *string = [[OFString alloc] initWithFormat:format
|
||||
arguments:arguments];
|
||||
OFString *string = [[OFString alloc] initWithFormat: format
|
||||
arguments: arguments];
|
||||
|
||||
va_end(arguments);
|
||||
|
||||
int n = 0;
|
||||
while (string.length > WORDWRAP) {
|
||||
conline([string substringToIndex:WORDWRAP], n++ != 0);
|
||||
string = [string substringFromIndex:WORDWRAP];
|
||||
conline([string substringToIndex: WORDWRAP], n++ != 0);
|
||||
string = [string substringFromIndex: WORDWRAP];
|
||||
}
|
||||
conline(string, n != 0);
|
||||
}
|
||||
|
@ -102,19 +102,19 @@ renderconsole()
|
|||
|
||||
static OFMutableArray<KeyMapping *> *keyMappings = nil;
|
||||
|
||||
COMMAND(keymap, ARG_3STR, ^(OFString *code, OFString *key, OFString *action) {
|
||||
COMMAND(keymap, ARG_3STR, ^ (OFString *code, OFString *key, OFString *action) {
|
||||
if (keyMappings == nil)
|
||||
keyMappings = [[OFMutableArray alloc] init];
|
||||
|
||||
KeyMapping *mapping = [KeyMapping mappingWithCode:code.cube_intValue
|
||||
name:key];
|
||||
KeyMapping *mapping = [KeyMapping mappingWithCode: code.cube_intValue
|
||||
name: key];
|
||||
mapping.action = action;
|
||||
[keyMappings addObject:mapping];
|
||||
[keyMappings addObject: mapping];
|
||||
})
|
||||
|
||||
COMMAND(bind, ARG_2STR, ^(OFString *key, OFString *action) {
|
||||
COMMAND(bind, ARG_2STR, ^ (OFString *key, OFString *action) {
|
||||
for (KeyMapping *mapping in keyMappings) {
|
||||
if ([mapping.name caseInsensitiveCompare:key] ==
|
||||
if ([mapping.name caseInsensitiveCompare: key] ==
|
||||
OFOrderedSame) {
|
||||
mapping.action = action;
|
||||
return;
|
||||
|
@ -143,11 +143,11 @@ saycommand(OFString *init)
|
|||
commandbuf = [init mutableCopy];
|
||||
}
|
||||
|
||||
COMMAND(saycommand, ARG_VARI, ^(OFString *init) {
|
||||
COMMAND(saycommand, ARG_VARI, ^ (OFString *init) {
|
||||
saycommand(init);
|
||||
})
|
||||
|
||||
COMMAND(mapmsg, ARG_1STR, ^(OFString *s) {
|
||||
COMMAND(mapmsg, ARG_1STR, ^ (OFString *s) {
|
||||
memset(hdr.maptitle, '\0', sizeof(hdr.maptitle));
|
||||
strncpy(hdr.maptitle, s.UTF8String, 127);
|
||||
})
|
||||
|
@ -155,13 +155,13 @@ COMMAND(mapmsg, ARG_1STR, ^(OFString *s) {
|
|||
void
|
||||
pasteconsole()
|
||||
{
|
||||
[commandbuf appendString:@(SDL_GetClipboardText())];
|
||||
[commandbuf appendString: @(SDL_GetClipboardText())];
|
||||
}
|
||||
|
||||
static OFMutableArray<OFString *> *vhistory;
|
||||
static int histpos = 0;
|
||||
|
||||
COMMAND(history, ARG_1INT, ^(int n) {
|
||||
COMMAND(history, ARG_1INT, ^ (int n) {
|
||||
static bool rec = false;
|
||||
|
||||
if (!rec && n >= 0 && n < vhistory.count) {
|
||||
|
@ -226,14 +226,14 @@ keypress(int code, bool isDown)
|
|||
init];
|
||||
|
||||
if (vhistory.count == 0 ||
|
||||
![vhistory.lastObject
|
||||
isEqual:commandbuf]) {
|
||||
![vhistory.lastObject isEqual:
|
||||
commandbuf]) {
|
||||
// cap this?
|
||||
[vhistory addObject:[commandbuf
|
||||
copy]];
|
||||
[vhistory addObject:
|
||||
[commandbuf copy]];
|
||||
}
|
||||
histpos = vhistory.count;
|
||||
if ([commandbuf hasPrefix:@"/"])
|
||||
if ([commandbuf hasPrefix: @"/"])
|
||||
execute(commandbuf, true);
|
||||
else
|
||||
toserver(commandbuf);
|
||||
|
@ -261,7 +261,7 @@ void
|
|||
input(OFString *text)
|
||||
{
|
||||
if (saycommandon)
|
||||
[commandbuf appendString:text];
|
||||
[commandbuf appendString: text];
|
||||
}
|
||||
|
||||
OFString *
|
||||
|
@ -275,6 +275,6 @@ writebinds(OFStream *stream)
|
|||
{
|
||||
for (KeyMapping *mapping in keyMappings)
|
||||
if (mapping.action.length > 0)
|
||||
[stream writeFormat:@"bind \"%@\" [%@]\n", mapping.name,
|
||||
mapping.action];
|
||||
[stream writeFormat: @"bind \"%@\" [%@]\n",
|
||||
mapping.name, mapping.action];
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ extern bool demoplayback;
|
|||
#define m_sp (gamemode < 0)
|
||||
#define m_dmsp (gamemode == -1)
|
||||
#define m_classicsp (gamemode == -2)
|
||||
#define isteam(a, b) (m_teammode && [a isEqual:b])
|
||||
#define isteam(a, b) (m_teammode && [a isEqual: b])
|
||||
|
||||
// function signatures for script functions, see command.mm
|
||||
enum {
|
||||
|
|
104
src/editing.m
104
src/editing.m
|
@ -20,7 +20,7 @@ struct block sel = { 0, 0, 0, 0 };
|
|||
|
||||
OF_CONSTRUCTOR()
|
||||
{
|
||||
enqueueInit(^{
|
||||
enqueueInit(^ {
|
||||
static const struct {
|
||||
OFString *name;
|
||||
int *storage;
|
||||
|
@ -28,13 +28,13 @@ OF_CONSTRUCTOR()
|
|||
{ @"selxs", &sel.xs }, { @"selys", &sel.ys } };
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
Variable *variable =
|
||||
[Variable variableWithName:vars[i].name
|
||||
min:0
|
||||
max:4096
|
||||
storage:vars[i].storage
|
||||
function:NULL
|
||||
persisted:false];
|
||||
Variable *variable = [Variable
|
||||
variableWithName: vars[i].name
|
||||
min: 0
|
||||
max: 4096
|
||||
storage: vars[i].storage
|
||||
function: NULL
|
||||
persisted: false];
|
||||
Identifier.identifiers[vars[i].name] = variable;
|
||||
}
|
||||
});
|
||||
|
@ -93,7 +93,7 @@ toggleedit()
|
|||
editing = editmode;
|
||||
}
|
||||
|
||||
COMMAND(edittoggle, ARG_NONE, ^{
|
||||
COMMAND(edittoggle, ARG_NONE, ^ {
|
||||
toggleedit();
|
||||
})
|
||||
|
||||
|
@ -137,7 +137,7 @@ noselection()
|
|||
if (noteditmode() || multiplayer()) \
|
||||
return;
|
||||
|
||||
COMMAND(select, ARG_4INT, (^(int x, int y, int xs, int ys) {
|
||||
COMMAND(select, ARG_4INT, (^ (int x, int y, int xs, int ys) {
|
||||
struct block s = { x, y, xs, ys };
|
||||
sel = s;
|
||||
selh = 0;
|
||||
|
@ -221,23 +221,23 @@ cursorupdate() // called every frame from hud
|
|||
float h3 = sheight(s, SWS(s, 1, 1, ssize), z);
|
||||
float h4 = sheight(s, SWS(s, 0, 1, ssize), z);
|
||||
if (s->tag)
|
||||
linestyle(GRIDW, [OFColor colorWithRed:1.0f
|
||||
green:0.25f
|
||||
blue:0.25f
|
||||
alpha:1.0f]);
|
||||
linestyle(GRIDW, [OFColor colorWithRed: 1.0f
|
||||
green: 0.25f
|
||||
blue: 0.25f
|
||||
alpha: 1.0f]);
|
||||
else if (s->type == FHF || s->type == CHF)
|
||||
linestyle(GRIDW, [OFColor colorWithRed:0.5f
|
||||
green:1.0f
|
||||
blue:0.5f
|
||||
alpha:1.0f]);
|
||||
linestyle(GRIDW, [OFColor colorWithRed: 0.5f
|
||||
green: 1.0f
|
||||
blue: 0.5f
|
||||
alpha: 1.0f]);
|
||||
else
|
||||
linestyle(GRIDW, OFColor.gray);
|
||||
struct block b = { ix, iy, 1, 1 };
|
||||
box(&b, h1, h2, h3, h4);
|
||||
linestyle(GRID8, [OFColor colorWithRed:0.25f
|
||||
green:0.25f
|
||||
blue:1.0f
|
||||
alpha:1.0f]);
|
||||
linestyle(GRID8, [OFColor colorWithRed: 0.25f
|
||||
green: 0.25f
|
||||
blue: 1.0f
|
||||
alpha: 1.0f]);
|
||||
if (!(ix & GRIDM))
|
||||
line(ix, iy, h1, ix, iy + 1, h4);
|
||||
if (!(ix + 1 & GRIDM))
|
||||
|
@ -262,10 +262,10 @@ cursorupdate() // called every frame from hud
|
|||
}
|
||||
|
||||
if (selset) {
|
||||
linestyle(GRIDS, [OFColor colorWithRed:1.0f
|
||||
green:0.25f
|
||||
blue:0.25f
|
||||
alpha:1.0f]);
|
||||
linestyle(GRIDS, [OFColor colorWithRed: 1.0f
|
||||
green: 0.25f
|
||||
blue: 0.25f
|
||||
alpha: 1.0f]);
|
||||
box(&sel, (float)selh, (float)selh, (float)selh, (float)selh);
|
||||
}
|
||||
}
|
||||
|
@ -278,12 +278,12 @@ pruneundos(int maxremain) // bound memory
|
|||
{
|
||||
int t = 0;
|
||||
for (ssize_t i = (ssize_t)undos.count - 1; i >= 0; i--) {
|
||||
struct block *undo = [undos mutableItemAtIndex:i];
|
||||
struct block *undo = [undos mutableItemAtIndex: i];
|
||||
|
||||
t += undo->xs * undo->ys * sizeof(struct sqr);
|
||||
if (t > maxremain) {
|
||||
OFFreeMemory(undo);
|
||||
[undos removeItemAtIndex:i];
|
||||
[undos removeItemAtIndex: i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,14 +293,14 @@ makeundo()
|
|||
{
|
||||
if (undos == nil)
|
||||
undos = [[OFMutableData alloc]
|
||||
initWithItemSize:sizeof(struct block *)];
|
||||
initWithItemSize: sizeof(struct block *)];
|
||||
|
||||
struct block *copy = blockcopy(&sel);
|
||||
[undos addItem:©];
|
||||
[undos addItem: ©];
|
||||
pruneundos(undomegs << 20);
|
||||
}
|
||||
|
||||
COMMAND(undo, ARG_NONE, ^{
|
||||
COMMAND(undo, ARG_NONE, ^ {
|
||||
EDITMP;
|
||||
if (undos.count == 0) {
|
||||
conoutf(@"nothing more to undo");
|
||||
|
@ -314,7 +314,7 @@ COMMAND(undo, ARG_NONE, ^{
|
|||
|
||||
static struct block *copybuf = NULL;
|
||||
|
||||
COMMAND(copy, ARG_NONE, ^{
|
||||
COMMAND(copy, ARG_NONE, ^ {
|
||||
EDITSELMP;
|
||||
|
||||
if (copybuf)
|
||||
|
@ -323,7 +323,7 @@ COMMAND(copy, ARG_NONE, ^{
|
|||
copybuf = blockcopy(&sel);
|
||||
})
|
||||
|
||||
COMMAND(paste, ARG_NONE, ^{
|
||||
COMMAND(paste, ARG_NONE, ^ {
|
||||
EDITMP;
|
||||
if (!copybuf) {
|
||||
conoutf(@"nothing to paste");
|
||||
|
@ -401,7 +401,7 @@ editheight(int flr, int amount)
|
|||
addmsg(1, 7, SV_EDITH, sel.x, sel.y, sel.xs, sel.ys, isfloor, amount);
|
||||
}
|
||||
|
||||
COMMAND(editheight, ARG_2INT, ^(int flr, int amount) {
|
||||
COMMAND(editheight, ARG_2INT, ^ (int flr, int amount) {
|
||||
editheight(flr, amount);
|
||||
})
|
||||
|
||||
|
@ -424,7 +424,7 @@ edittexxy(int type, int t, const struct block *sel)
|
|||
});
|
||||
}
|
||||
|
||||
COMMAND(edittex, ARG_2INT, ^(int type, int dir) {
|
||||
COMMAND(edittex, ARG_2INT, ^ (int type, int dir) {
|
||||
EDITSEL;
|
||||
|
||||
if (type < 0 || type > 3)
|
||||
|
@ -444,7 +444,7 @@ COMMAND(edittex, ARG_2INT, ^(int type, int dir) {
|
|||
addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t);
|
||||
})
|
||||
|
||||
COMMAND(replace, ARG_NONE, (^{
|
||||
COMMAND(replace, ARG_NONE, (^ {
|
||||
EDITSELMP;
|
||||
|
||||
for (int x = 0; x < ssize; x++) {
|
||||
|
@ -497,15 +497,15 @@ edittype(int type)
|
|||
addmsg(1, 6, SV_EDITS, sel.x, sel.y, sel.xs, sel.ys, type);
|
||||
}
|
||||
|
||||
COMMAND(heightfield, ARG_1INT, ^(int t) {
|
||||
COMMAND(heightfield, ARG_1INT, ^ (int t) {
|
||||
edittype(t == 0 ? FHF : CHF);
|
||||
})
|
||||
|
||||
COMMAND(solid, ARG_1INT, ^(int t) {
|
||||
COMMAND(solid, ARG_1INT, ^ (int t) {
|
||||
edittype(t == 0 ? SPACE : SOLID);
|
||||
})
|
||||
|
||||
COMMAND(corner, ARG_NONE, ^{
|
||||
COMMAND(corner, ARG_NONE, ^ {
|
||||
edittype(CORNER);
|
||||
})
|
||||
|
||||
|
@ -529,7 +529,7 @@ editequalisexy(bool isfloor, const struct block *sel)
|
|||
});
|
||||
}
|
||||
|
||||
COMMAND(equalize, ARG_1INT, ^(int flr) {
|
||||
COMMAND(equalize, ARG_1INT, ^ (int flr) {
|
||||
bool isfloor = (flr == 0);
|
||||
|
||||
EDITSEL;
|
||||
|
@ -545,7 +545,7 @@ setvdeltaxy(int delta, const struct block *sel)
|
|||
remipmore(sel, 0);
|
||||
}
|
||||
|
||||
COMMAND(vdelta, ARG_1INT, ^(int delta) {
|
||||
COMMAND(vdelta, ARG_1INT, ^ (int delta) {
|
||||
EDITSEL;
|
||||
|
||||
setvdeltaxy(delta, &sel);
|
||||
|
@ -556,7 +556,7 @@ COMMAND(vdelta, ARG_1INT, ^(int delta) {
|
|||
int archverts[MAXARCHVERT][MAXARCHVERT];
|
||||
bool archvinit = false;
|
||||
|
||||
COMMAND(archvertex, ARG_3INT, ^(int span, int vert, int delta) {
|
||||
COMMAND(archvertex, ARG_3INT, ^ (int span, int vert, int delta) {
|
||||
if (!archvinit) {
|
||||
archvinit = true;
|
||||
for (int s = 0; s < MAXARCHVERT; s++)
|
||||
|
@ -568,7 +568,7 @@ COMMAND(archvertex, ARG_3INT, ^(int span, int vert, int delta) {
|
|||
archverts[span][vert] = delta;
|
||||
})
|
||||
|
||||
COMMAND(arch, ARG_2INT, ^(int sidedelta, int _a) {
|
||||
COMMAND(arch, ARG_2INT, ^ (int sidedelta, int _a) {
|
||||
EDITSELMP;
|
||||
|
||||
sel.xs++;
|
||||
|
@ -590,7 +590,7 @@ COMMAND(arch, ARG_2INT, ^(int sidedelta, int _a) {
|
|||
remipmore(sel, 0);
|
||||
})
|
||||
|
||||
COMMAND(slope, ARG_2INT, ^(int xd, int yd) {
|
||||
COMMAND(slope, ARG_2INT, ^ (int xd, int yd) {
|
||||
EDITSELMP;
|
||||
|
||||
int off = 0;
|
||||
|
@ -609,7 +609,7 @@ COMMAND(slope, ARG_2INT, ^(int xd, int yd) {
|
|||
remipmore(sel, 0);
|
||||
})
|
||||
|
||||
COMMAND(perlin, ARG_3INT, ^(int scale, int seed, int psize) {
|
||||
COMMAND(perlin, ARG_3INT, ^ (int scale, int seed, int psize) {
|
||||
EDITSELMP;
|
||||
|
||||
sel.xs++;
|
||||
|
@ -639,7 +639,7 @@ VARF(
|
|||
world[i].r = world[i].g = world[i].b = 176;
|
||||
});
|
||||
|
||||
COMMAND(edittag, ARG_1INT, ^(int tag) {
|
||||
COMMAND(edittag, ARG_1INT, ^ (int tag) {
|
||||
EDITSELMP;
|
||||
|
||||
struct block *sel_ = &sel;
|
||||
|
@ -649,10 +649,10 @@ COMMAND(edittag, ARG_1INT, ^(int tag) {
|
|||
})
|
||||
|
||||
COMMAND(newent, ARG_5STR,
|
||||
^(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4) {
|
||||
EDITSEL;
|
||||
^ (OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4) {
|
||||
EDITSEL;
|
||||
|
||||
newentity(sel.x, sel.y, (int)Player.player1.origin.z, what,
|
||||
[a1 cube_intValueWithBase:0], [a2 cube_intValueWithBase:0],
|
||||
[a3 cube_intValueWithBase:0], [a4 cube_intValueWithBase:0]);
|
||||
})
|
||||
newentity(sel.x, sel.y, (int)Player.player1.origin.z, what,
|
||||
[a1 cube_intValueWithBase: 0], [a2 cube_intValueWithBase: 0],
|
||||
[a3 cube_intValueWithBase: 0], [a4 cube_intValueWithBase: 0]);
|
||||
})
|
||||
|
|
|
@ -313,7 +313,7 @@ checkitems()
|
|||
if (editmode)
|
||||
return;
|
||||
|
||||
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
|
||||
[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
|
||||
if (e.type == NOTUSED)
|
||||
return;
|
||||
|
||||
|
@ -348,7 +348,7 @@ checkquad(int time)
|
|||
void
|
||||
putitems(unsigned char **p)
|
||||
{
|
||||
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
|
||||
[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
|
||||
if ((e.type >= I_SHELLS && e.type <= I_QUAD) ||
|
||||
e.type == CARROT) {
|
||||
putint(p, i);
|
||||
|
|
26
src/menus.m
26
src/menus.m
|
@ -21,10 +21,10 @@ menuset(int menu)
|
|||
menus[1].menusel = 0;
|
||||
}
|
||||
|
||||
COMMAND(showmenu, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(showmenu, ARG_1STR, ^ (OFString *name) {
|
||||
int i = 0;
|
||||
for (Menu *menu in menus) {
|
||||
if (i > 1 && [menu.name isEqual:name]) {
|
||||
if (i > 1 && [menu.name isEqual: name]) {
|
||||
menuset(i);
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ rendermenu()
|
|||
Menu *m = menus[vmenu];
|
||||
OFString *title;
|
||||
if (vmenu > 1)
|
||||
title = [OFString stringWithFormat:@"[ %@ menu ]", m.name];
|
||||
title = [OFString stringWithFormat: @"[ %@ menu ]", m.name];
|
||||
else
|
||||
title = m.name;
|
||||
int mdisp = m.items.count;
|
||||
|
@ -93,10 +93,10 @@ newmenu(OFString *name)
|
|||
if (menus == nil)
|
||||
menus = [[OFMutableArray alloc] init];
|
||||
|
||||
[menus addObject:[Menu menuWithName:name]];
|
||||
[menus addObject: [Menu menuWithName: name]];
|
||||
}
|
||||
|
||||
COMMAND(newmenu, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(newmenu, ARG_1STR, ^ (OFString *name) {
|
||||
newmenu(name);
|
||||
})
|
||||
|
||||
|
@ -106,17 +106,17 @@ menumanual(int m, int n, OFString *text)
|
|||
if (n == 0)
|
||||
[menus[m].items removeAllObjects];
|
||||
|
||||
MenuItem *item = [MenuItem itemWithText:text action:@""];
|
||||
[menus[m].items addObject:item];
|
||||
MenuItem *item = [MenuItem itemWithText: text action: @""];
|
||||
[menus[m].items addObject: item];
|
||||
}
|
||||
|
||||
COMMAND(menuitem, ARG_2STR, ^(OFString *text, OFString *action) {
|
||||
COMMAND(menuitem, ARG_2STR, ^ (OFString *text, OFString *action) {
|
||||
Menu *menu = menus.lastObject;
|
||||
|
||||
MenuItem *item =
|
||||
[MenuItem itemWithText:text
|
||||
action:(action.length > 0 ? action : text)];
|
||||
[menu.items addObject:item];
|
||||
MenuItem *item = [MenuItem
|
||||
itemWithText: text
|
||||
action: (action.length > 0 ? action : text)];
|
||||
[menu.items addObject: item];
|
||||
})
|
||||
|
||||
bool
|
||||
|
@ -155,7 +155,7 @@ menukey(int code, bool isdown)
|
|||
if (menuStack == nil)
|
||||
menuStack = [[OFMutableArray alloc] init];
|
||||
|
||||
[menuStack addObject:@(vmenu)];
|
||||
[menuStack addObject: @(vmenu)];
|
||||
menuset(-1);
|
||||
|
||||
execute(action, true);
|
||||
|
|
|
@ -32,7 +32,7 @@ plcollide(
|
|||
|
||||
if (fabs(o.origin.z - d.origin.z) < o.aboveEye + d.eyeHeight)
|
||||
return false;
|
||||
if ([d isKindOfClass:Monster.class])
|
||||
if ([d isKindOfClass: Monster.class])
|
||||
return false; // hack
|
||||
|
||||
*headspace = d.origin.z - o.origin.z - o.aboveEye - d.eyeHeight;
|
||||
|
@ -108,10 +108,8 @@ collide(DynamicEntity *d, bool spawn, float drop, float rise)
|
|||
const int y2 = fy2;
|
||||
float hi = 127, lo = -128;
|
||||
// big monsters are afraid of heights, unless angry :)
|
||||
float minfloor =
|
||||
([d isKindOfClass:Monster.class] && !spawn && d.health > 100
|
||||
? d.origin.z - d.eyeHeight - 4.5f
|
||||
: -1000.0f);
|
||||
float minfloor = ([d isKindOfClass: Monster.class] && !spawn &&
|
||||
d.health > 100 ? d.origin.z - d.eyeHeight - 4.5f : -1000.0f);
|
||||
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
|
@ -328,7 +326,7 @@ moveplayer4(DynamicEntity *pl, int moveres, bool local, int curtime)
|
|||
pl.velocity.y / 8, pl.velocity.z);
|
||||
if (local)
|
||||
playsoundc(S_JUMP);
|
||||
else if ([pl isKindOfClass:Monster.class]) {
|
||||
else if ([pl isKindOfClass: Monster.class]) {
|
||||
OFVector3D loc = pl.origin;
|
||||
playsound(S_JUMP, &loc);
|
||||
}
|
||||
|
@ -337,7 +335,7 @@ moveplayer4(DynamicEntity *pl, int moveres, bool local, int curtime)
|
|||
// high jump, make thud sound
|
||||
if (local)
|
||||
playsoundc(S_LAND);
|
||||
else if ([pl isKindOfClass:Monster.class]) {
|
||||
else if ([pl isKindOfClass: Monster.class]) {
|
||||
OFVector3D loc = pl.origin;
|
||||
playsound(S_LAND, &loc);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ int ol3r, ol3g, ol3b, ol4r, ol4g, ol4b;
|
|||
int firstindex;
|
||||
bool showm = false;
|
||||
|
||||
COMMAND(showmip, ARG_NONE, ^{
|
||||
COMMAND(showmip, ARG_NONE, ^ {
|
||||
showm = !showm;
|
||||
})
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ blendbox(int x1, int y1, int x2, int y2, bool border)
|
|||
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
glBegin(GL_QUADS);
|
||||
if (border)
|
||||
[[OFColor colorWithRed:0.5f
|
||||
green:0.3f
|
||||
blue:0.4f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 0.5f
|
||||
green: 0.3f
|
||||
blue: 0.4f
|
||||
alpha: 1.0f] cube_setAsGLColor];
|
||||
else
|
||||
[OFColor.white cube_setAsGLColor];
|
||||
glVertex2i(x1, y1);
|
||||
|
@ -74,10 +74,10 @@ blendbox(int x1, int y1, int x2, int y2, bool border)
|
|||
glDisable(GL_BLEND);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glBegin(GL_POLYGON);
|
||||
[[OFColor colorWithRed:0.2f
|
||||
green:0.7f
|
||||
blue:0.4f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 0.2f
|
||||
green: 0.7f
|
||||
blue: 0.4f
|
||||
alpha: 1.0f] cube_setAsGLColor];
|
||||
glVertex2i(x1, y1);
|
||||
glVertex2i(x2, y1);
|
||||
glVertex2i(x2, y2);
|
||||
|
@ -133,10 +133,10 @@ renderspheres(int time)
|
|||
for (struct sphere *p, **pp = &slist; (p = *pp) != NULL;) {
|
||||
glPushMatrix();
|
||||
float size = p->size / p->max;
|
||||
[[OFColor colorWithRed:1.0f
|
||||
green:1.0f
|
||||
blue:1.0f
|
||||
alpha:1.0f - size] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 1.0f
|
||||
green: 1.0f
|
||||
blue: 1.0f
|
||||
alpha: 1.0f - size] cube_setAsGLColor];
|
||||
glTranslatef(p->o.x, p->o.z, p->o.y);
|
||||
glRotatef(lastmillis / 5.0f, 1, 1, 1);
|
||||
glScalef(p->size, p->size, p->size);
|
||||
|
@ -207,34 +207,33 @@ renderents()
|
|||
if (e >= 0) {
|
||||
Entity *c = ents[e];
|
||||
closeent =
|
||||
[OFString stringWithFormat:@"closest entity = %@ (%d, %d, "
|
||||
@"%d, %d), selection = (%d, %d)",
|
||||
[OFString stringWithFormat:
|
||||
@"closest entity = %@ (%d, %d, %d, %d), "
|
||||
@"selection = (%d, %d)",
|
||||
entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4,
|
||||
getvar(@"selxs"), getvar(@"selys")];
|
||||
}
|
||||
}
|
||||
|
||||
COMMAND(loadsky, ARG_1STR, (^(OFString *basename) {
|
||||
COMMAND(loadsky, ARG_1STR, (^ (OFString *basename) {
|
||||
static OFString *lastsky = @"";
|
||||
|
||||
basename = [basename stringByReplacingOccurrencesOfString:@"\\"
|
||||
withString:@"/"];
|
||||
basename = [basename stringByReplacingOccurrencesOfString: @"\\"
|
||||
withString: @"/"];
|
||||
|
||||
if ([lastsky isEqual:basename])
|
||||
if ([lastsky isEqual: basename])
|
||||
return;
|
||||
|
||||
static const OFString *side[] = { @"ft", @"bk", @"lf", @"rt", @"dn",
|
||||
@"up" };
|
||||
int texnum = 14;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
OFString *path = [OFString
|
||||
stringWithFormat:@"packages/%@_%@.jpg", basename, side[i]];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"packages/%@_%@.jpg", basename, side[i]];
|
||||
|
||||
int xs, ys;
|
||||
if (!installtex(texnum + i,
|
||||
[Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:path],
|
||||
&xs, &ys, true))
|
||||
if (!installtex(texnum + i, [Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent: path], &xs, &ys, true))
|
||||
conoutf(@"could not load sky textures");
|
||||
}
|
||||
|
||||
|
@ -361,15 +360,15 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
|
|||
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
glBegin(GL_QUADS);
|
||||
if (dblend)
|
||||
[[OFColor colorWithRed:0.0f
|
||||
green:0.9f
|
||||
blue:0.9f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 0.0f
|
||||
green: 0.9f
|
||||
blue: 0.9f
|
||||
alpha: 1.0f] cube_setAsGLColor];
|
||||
else
|
||||
[[OFColor colorWithRed:0.9f
|
||||
green:0.5f
|
||||
blue:0.0f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 0.9f
|
||||
green: 0.5f
|
||||
blue: 0.0f
|
||||
alpha: 1.0f] cube_setAsGLColor];
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(VIRTW, 0);
|
||||
glVertex2i(VIRTW, VIRTH);
|
||||
|
@ -404,10 +403,11 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
|
|||
else if (player1.health <= 25)
|
||||
[OFColor.red cube_setAsGLColor];
|
||||
else if (player1.health <= 50)
|
||||
[[OFColor colorWithRed:1.0f
|
||||
green:0.5f
|
||||
blue:0.0f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 1.0f
|
||||
green: 0.5f
|
||||
blue: 0.0f
|
||||
alpha: 1.0f]
|
||||
cube_setAsGLColor];
|
||||
}
|
||||
float chsize = (float)crosshairsize;
|
||||
glTexCoord2d(0.0, 0.0);
|
||||
|
|
|
@ -190,19 +190,19 @@ purgetextures()
|
|||
|
||||
int curtexnum = 0;
|
||||
|
||||
COMMAND(texturereset, ARG_NONE, ^{
|
||||
COMMAND(texturereset, ARG_NONE, ^ {
|
||||
curtexnum = 0;
|
||||
})
|
||||
|
||||
COMMAND(texture, ARG_2STR, (^(OFString *aframe, OFString *name) {
|
||||
COMMAND(texture, ARG_2STR, (^ (OFString *aframe, OFString *name) {
|
||||
int num = curtexnum++, frame = aframe.cube_intValue;
|
||||
|
||||
if (num < 0 || num >= 256 || frame < 0 || frame >= MAXFRAMES)
|
||||
return;
|
||||
|
||||
mapping[num][frame] = 1;
|
||||
mapname[num][frame] = [name stringByReplacingOccurrencesOfString:@"\\"
|
||||
withString:@"/"];
|
||||
mapname[num][frame] = [name stringByReplacingOccurrencesOfString: @"\\"
|
||||
withString: @"/"];
|
||||
}))
|
||||
|
||||
int
|
||||
|
@ -223,7 +223,7 @@ lookuptexture(int tex, int *xs, int *ys)
|
|||
|
||||
// lazily happens once per "texture" command, basically
|
||||
for (int i = 0; i < curtex; i++) {
|
||||
if ([mapname[tex][frame] isEqual:texname[i]]) {
|
||||
if ([mapname[tex][frame] isEqual: texname[i]]) {
|
||||
mapping[tex][frame] = tid = i + FIRSTTEX;
|
||||
*xs = texx[i];
|
||||
*ys = texy[i];
|
||||
|
@ -237,13 +237,11 @@ lookuptexture(int tex, int *xs, int *ys)
|
|||
int tnum = curtex + FIRSTTEX;
|
||||
texname[curtex] = mapname[tex][frame];
|
||||
|
||||
OFString *path =
|
||||
[OFString stringWithFormat:@"packages/%@", texname[curtex]];
|
||||
OFString *path = [OFString stringWithFormat: @"packages/%@",
|
||||
texname[curtex]];
|
||||
|
||||
if (installtex(tnum,
|
||||
[Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:path],
|
||||
xs, ys, false)) {
|
||||
if (installtex(tnum, [Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent: path], xs, ys, false)) {
|
||||
mapping[tex][frame] = tnum;
|
||||
texx[curtex] = *xs;
|
||||
texy[curtex] = *ys;
|
||||
|
@ -322,10 +320,10 @@ addstrip(int tex, int start, int n)
|
|||
{
|
||||
if (strips == nil)
|
||||
strips = [[OFMutableData alloc]
|
||||
initWithItemSize:sizeof(struct strip)];
|
||||
initWithItemSize: sizeof(struct strip)];
|
||||
|
||||
struct strip s = { .tex = tex, .start = start, .num = n };
|
||||
[strips addItem:&s];
|
||||
[strips addItem: &s];
|
||||
}
|
||||
|
||||
#undef gamma
|
||||
|
|
|
@ -17,16 +17,18 @@ void
|
|||
delayedload(MD2 *m)
|
||||
{
|
||||
if (!m.loaded) {
|
||||
OFString *path = [OFString
|
||||
stringWithFormat:@"packages/models/%@", m.loadname];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"packages/models/%@", m.loadname];
|
||||
OFIRI *baseIRI = [Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:path];
|
||||
IRIByAppendingPathComponent: path];
|
||||
|
||||
OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"];
|
||||
if (![m loadWithIRI:IRI1])
|
||||
OFIRI *IRI1 = [baseIRI
|
||||
IRIByAppendingPathComponent: @"tris.md2"];
|
||||
if (![m loadWithIRI: IRI1])
|
||||
fatal(@"loadmodel: %@", IRI1.string);
|
||||
|
||||
OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"];
|
||||
OFIRI *IRI2 = [baseIRI
|
||||
IRIByAppendingPathComponent: @"skin.jpg"];
|
||||
int xs, ys;
|
||||
installtex(FIRSTMDL + m.mdlnum, IRI2, &xs, &ys, false);
|
||||
m.loaded = true;
|
||||
|
@ -44,7 +46,7 @@ loadmodel(OFString *name)
|
|||
|
||||
m = [MD2 md2];
|
||||
m.mdlnum = modelnum++;
|
||||
m.mmi = [MapModelInfo infoWithRad:2 h:2 zoff:0 snap:0 name:@""];
|
||||
m.mmi = [MapModelInfo infoWithRad: 2 h: 2 zoff: 0 snap: 0 name: @""];
|
||||
m.loadname = name;
|
||||
|
||||
if (mdllookup == nil)
|
||||
|
@ -55,25 +57,23 @@ loadmodel(OFString *name)
|
|||
return m;
|
||||
}
|
||||
|
||||
COMMAND(mapmodel, ARG_5STR,
|
||||
^(OFString *rad, OFString *h, OFString *zoff, OFString *snap,
|
||||
OFString *name) {
|
||||
MD2 *m =
|
||||
loadmodel([name stringByReplacingOccurrencesOfString:@"\\"
|
||||
withString:@"/"]);
|
||||
m.mmi = [MapModelInfo infoWithRad:rad.cube_intValue
|
||||
h:h.cube_intValue
|
||||
zoff:zoff.cube_intValue
|
||||
snap:snap.cube_intValue
|
||||
name:m.loadname];
|
||||
COMMAND(mapmodel, ARG_5STR, ^ (OFString *rad, OFString *h, OFString *zoff,
|
||||
OFString *snap, OFString *name) {
|
||||
MD2 *m = loadmodel([name stringByReplacingOccurrencesOfString: @"\\"
|
||||
withString: @"/"]);
|
||||
m.mmi = [MapModelInfo infoWithRad: rad.cube_intValue
|
||||
h: h.cube_intValue
|
||||
zoff: zoff.cube_intValue
|
||||
snap: snap.cube_intValue
|
||||
name: m.loadname];
|
||||
|
||||
if (mapmodels == nil)
|
||||
mapmodels = [[OFMutableArray alloc] init];
|
||||
if (mapmodels == nil)
|
||||
mapmodels = [[OFMutableArray alloc] init];
|
||||
|
||||
[mapmodels addObject:m];
|
||||
})
|
||||
[mapmodels addObject: m];
|
||||
})
|
||||
|
||||
COMMAND(mapmodelreset, ARG_NONE, ^{
|
||||
COMMAND(mapmodelreset, ARG_NONE, ^ {
|
||||
[mapmodels removeAllObjects];
|
||||
})
|
||||
|
||||
|
@ -102,35 +102,35 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
|
|||
|
||||
int ix = (int)position.x;
|
||||
int iy = (int)position.z;
|
||||
OFColor *light = [OFColor colorWithRed:1 green:1 blue:1 alpha:1];
|
||||
OFColor *light = OFColor.white;
|
||||
|
||||
if (!OUTBORD(ix, iy)) {
|
||||
struct sqr *s = S(ix, iy);
|
||||
float ll = 256.0f; // 0.96f;
|
||||
float of = 0.0f; // 0.1f;
|
||||
light = [OFColor colorWithRed:s->r / ll + of
|
||||
green:s->g / ll + of
|
||||
blue:s->b / ll + of
|
||||
alpha:1];
|
||||
light = [OFColor colorWithRed: s->r / ll + of
|
||||
green: s->g / ll + of
|
||||
blue: s->b / ll + of
|
||||
alpha: 1];
|
||||
}
|
||||
|
||||
if (teammate) {
|
||||
float red, green, blue;
|
||||
[light getRed:&red green:&green blue:&blue alpha:NULL];
|
||||
light = [OFColor colorWithRed:red * 0.6f
|
||||
green:green * 0.7f
|
||||
blue:blue * 1.2f
|
||||
alpha:1];
|
||||
[light getRed: &red green: &green blue: &blue alpha: NULL];
|
||||
light = [OFColor colorWithRed: red * 0.6f
|
||||
green: green * 0.7f
|
||||
blue: blue * 1.2f
|
||||
alpha: 1];
|
||||
}
|
||||
|
||||
[m renderWithLight:light
|
||||
frame:frame
|
||||
range:range
|
||||
position:position
|
||||
yaw:yaw
|
||||
pitch:pitch
|
||||
scale:scale
|
||||
speed:speed
|
||||
snap:snap
|
||||
basetime:basetime];
|
||||
[m renderWithLight: light
|
||||
frame: frame
|
||||
range: range
|
||||
position: position
|
||||
yaw: yaw
|
||||
pitch: pitch
|
||||
scale: scale
|
||||
speed: speed
|
||||
snap: snap
|
||||
basetime: basetime];
|
||||
}
|
||||
|
|
|
@ -139,8 +139,8 @@ draw_textf(OFConstantString *format, int left, int top, int gl_num, ...)
|
|||
{
|
||||
va_list arguments;
|
||||
va_start(arguments, gl_num);
|
||||
OFString *str = [[OFString alloc] initWithFormat:format
|
||||
arguments:arguments];
|
||||
OFString *str = [[OFString alloc] initWithFormat: format
|
||||
arguments: arguments];
|
||||
va_end(arguments);
|
||||
draw_text(str, left, top, gl_num);
|
||||
}
|
||||
|
@ -170,10 +170,10 @@ draw_text(OFString *string, int left, int top, int gl_num)
|
|||
}
|
||||
|
||||
if (c == '\f') {
|
||||
[[OFColor colorWithRed:0.25f
|
||||
green:1.0f
|
||||
blue:0.5f
|
||||
alpha:1.0f] cube_setAsGLColor];
|
||||
[[OFColor colorWithRed: 0.25f
|
||||
green: 1.0f
|
||||
blue: 0.5f
|
||||
alpha: 1.0f] cube_setAsGLColor];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,8 +97,7 @@ savestate(OFIRI *IRI)
|
|||
{
|
||||
stop();
|
||||
f = gzopen([IRI.fileSystemRepresentation
|
||||
cStringWithEncoding:OFLocale.encoding],
|
||||
"wb9");
|
||||
cStringWithEncoding: OFLocale.encoding], "wb9");
|
||||
if (!f) {
|
||||
conoutf(@"could not write %@", IRI.string);
|
||||
return;
|
||||
|
@ -131,15 +130,16 @@ savestate(OFIRI *IRI)
|
|||
}
|
||||
}
|
||||
|
||||
COMMAND(savegame, ARG_1STR, (^(OFString *name) {
|
||||
COMMAND(savegame, ARG_1STR, (^ (OFString *name) {
|
||||
if (!m_classicsp) {
|
||||
conoutf(@"can only save classic sp games");
|
||||
return;
|
||||
}
|
||||
|
||||
OFString *path = [OFString stringWithFormat:@"savegames/%@.csgz", name];
|
||||
OFIRI *IRI =
|
||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"savegames/%@.csgz", name];
|
||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent: path];
|
||||
savestate(IRI);
|
||||
stop();
|
||||
conoutf(@"wrote %@", IRI.string);
|
||||
|
@ -152,8 +152,7 @@ loadstate(OFIRI *IRI)
|
|||
if (multiplayer())
|
||||
return;
|
||||
f = gzopen([IRI.fileSystemRepresentation
|
||||
cStringWithEncoding:OFLocale.encoding],
|
||||
"rb9");
|
||||
cStringWithEncoding: OFLocale.encoding], "rb9");
|
||||
if (!f) {
|
||||
conoutf(@"could not open %@", IRI.string);
|
||||
return;
|
||||
|
@ -183,10 +182,11 @@ out:
|
|||
stop();
|
||||
}
|
||||
|
||||
COMMAND(loadgame, ARG_1STR, (^(OFString *name) {
|
||||
OFString *path = [OFString stringWithFormat:@"savegames/%@.csgz", name];
|
||||
OFIRI *IRI =
|
||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
||||
COMMAND(loadgame, ARG_1STR, (^ (OFString *name) {
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"savegames/%@.csgz", name];
|
||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent: path];
|
||||
loadstate(IRI);
|
||||
}))
|
||||
|
||||
|
@ -217,10 +217,10 @@ loadgamerest()
|
|||
restoreserverstate(ents);
|
||||
|
||||
OFMutableData *data =
|
||||
[OFMutableData dataWithCapacity:DynamicEntity.serializedSize];
|
||||
[data increaseCountBy:DynamicEntity.serializedSize];
|
||||
[OFMutableData dataWithCapacity: DynamicEntity.serializedSize];
|
||||
[data increaseCountBy: DynamicEntity.serializedSize];
|
||||
gzread(f, data.mutableItems, data.count);
|
||||
[Player.player1 setFromSerializedData:data];
|
||||
[Player.player1 setFromSerializedData: data];
|
||||
Player.player1.lastAction = lastmillis;
|
||||
|
||||
int nmonsters = gzgeti();
|
||||
|
@ -230,7 +230,7 @@ loadgamerest()
|
|||
|
||||
for (Monster *monster in monsters) {
|
||||
gzread(f, data.mutableItems, data.count);
|
||||
[monster setFromSerializedData:data];
|
||||
[monster setFromSerializedData: data];
|
||||
// lazy, could save id of enemy instead
|
||||
monster.enemy = Player.player1;
|
||||
// also lazy, but no real noticable effect on game
|
||||
|
@ -246,7 +246,7 @@ loadgamerest()
|
|||
Player *d = getclient(i);
|
||||
assert(d);
|
||||
gzread(f, data.mutableItems, data.count);
|
||||
[d setFromSerializedData:data];
|
||||
[d setFromSerializedData: data];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ int playbacktime = 0;
|
|||
int ddamage, bdamage;
|
||||
OFVector3D dorig;
|
||||
|
||||
COMMAND(record, ARG_1STR, (^(OFString *name) {
|
||||
COMMAND(record, ARG_1STR, (^ (OFString *name) {
|
||||
if (m_sp) {
|
||||
conoutf(@"cannot record singleplayer games");
|
||||
return;
|
||||
|
@ -274,9 +274,9 @@ COMMAND(record, ARG_1STR, (^(OFString *name) {
|
|||
if (cn < 0)
|
||||
return;
|
||||
|
||||
OFString *path = [OFString stringWithFormat:@"demos/%@.cdgz", name];
|
||||
OFIRI *IRI =
|
||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
||||
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent: path];
|
||||
savestate(IRI);
|
||||
gzputi(cn);
|
||||
conoutf(@"started recording demo to %@", IRI.string);
|
||||
|
@ -333,10 +333,10 @@ incomingdemodata(unsigned char *buf, int len, bool extras)
|
|||
}
|
||||
}
|
||||
|
||||
COMMAND(demo, ARG_1STR, (^(OFString *name) {
|
||||
OFString *path = [OFString stringWithFormat:@"demos/%@.cdgz", name];
|
||||
OFIRI *IRI =
|
||||
[Cube.sharedInstance.userDataIRI IRIByAppendingPathComponent:path];
|
||||
COMMAND(demo, ARG_1STR, (^ (OFString *name) {
|
||||
OFString *path = [OFString stringWithFormat: @"demos/%@.cdgz", name];
|
||||
OFIRI *IRI = [Cube.sharedInstance.userDataIRI
|
||||
IRIByAppendingPathComponent: path];
|
||||
loadstate(IRI);
|
||||
demoloading = true;
|
||||
}))
|
||||
|
@ -462,10 +462,10 @@ demoplaybackstep()
|
|||
if (playerhistory == nil)
|
||||
playerhistory = [[OFMutableArray alloc] init];
|
||||
|
||||
[playerhistory addObject:d];
|
||||
[playerhistory addObject: d];
|
||||
|
||||
if (playerhistory.count > 20)
|
||||
[playerhistory removeObjectAtIndex:0];
|
||||
[playerhistory removeObjectAtIndex: 0];
|
||||
}
|
||||
|
||||
readdemotime();
|
||||
|
@ -542,7 +542,7 @@ demoplaybackstep()
|
|||
// if(player1->state!=CS_DEAD) showscores(false);
|
||||
}
|
||||
|
||||
COMMAND(stop, ARG_NONE, ^{
|
||||
COMMAND(stop, ARG_NONE, ^ {
|
||||
if (demoplayback)
|
||||
stopreset();
|
||||
else
|
||||
|
|
39
src/server.m
39
src/server.m
|
@ -24,8 +24,8 @@ int mode = 0;
|
|||
void
|
||||
restoreserverstate(OFArray<Entity *> *ents)
|
||||
{
|
||||
[sents enumerateObjectsUsingBlock:^(
|
||||
ServerEntity *e, size_t i, bool *stop) {
|
||||
[sents enumerateObjectsUsingBlock:
|
||||
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||
e.spawned = ents[i].spawned;
|
||||
e.spawnsecs = 0;
|
||||
}];
|
||||
|
@ -101,8 +101,8 @@ sendservmsg(OFString *msg)
|
|||
void
|
||||
disconnect_client(int n, OFString *reason)
|
||||
{
|
||||
[OFStdOut writeFormat:@"disconnecting client (%@) [%@]\n",
|
||||
clients[n].hostname, reason];
|
||||
[OFStdOut writeFormat: @"disconnecting client (%@) [%@]\n",
|
||||
clients[n].hostname, reason];
|
||||
enet_peer_disconnect(clients[n].peer);
|
||||
clients[n].type = ST_EMPTY;
|
||||
send2(true, -1, SV_CDIS, n);
|
||||
|
@ -146,7 +146,7 @@ vote(OFString *map, int reqmode, int sender)
|
|||
for (Client *client in clients) {
|
||||
if (client.type != ST_EMPTY) {
|
||||
if (client.mapvote.length > 0) {
|
||||
if ([client.mapvote isEqual:map] &&
|
||||
if ([client.mapvote isEqual: map] &&
|
||||
client.modevote == reqmode)
|
||||
yes++;
|
||||
else
|
||||
|
@ -159,8 +159,8 @@ vote(OFString *map, int reqmode, int sender)
|
|||
if (yes == 1 && no == 0)
|
||||
return true; // single player
|
||||
|
||||
OFString *msg = [OFString
|
||||
stringWithFormat:@"%@ suggests %@ on map %@ (set map to vote)",
|
||||
OFString *msg = [OFString stringWithFormat:
|
||||
@"%@ suggests %@ on map %@ (set map to vote)",
|
||||
clients[sender].name, modestr(reqmode), map];
|
||||
sendservmsg(msg);
|
||||
|
||||
|
@ -227,8 +227,8 @@ process(ENetPacket *packet, int sender) // sender may be -1
|
|||
while ((n = getint(&p)) != -1)
|
||||
if (notgotitems) {
|
||||
while (sents.count <= n)
|
||||
[sents addObject:[ServerEntity
|
||||
entity]];
|
||||
[sents addObject:
|
||||
[ServerEntity entity]];
|
||||
sents[n].spawned = true;
|
||||
}
|
||||
notgotitems = false;
|
||||
|
@ -314,8 +314,8 @@ send_welcome(int n)
|
|||
sendstring(smapname, &p);
|
||||
putint(&p, mode);
|
||||
putint(&p, SV_ITEMLIST);
|
||||
[sents enumerateObjectsUsingBlock:^(
|
||||
ServerEntity *e, size_t i, bool *stop) {
|
||||
[sents enumerateObjectsUsingBlock:
|
||||
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||
if (e.spawned)
|
||||
putint(&p, i);
|
||||
}];
|
||||
|
@ -356,7 +356,7 @@ addclient()
|
|||
if (clients == nil)
|
||||
clients = [[OFMutableArray alloc] init];
|
||||
|
||||
[clients addObject:client];
|
||||
[clients addObject: client];
|
||||
|
||||
return client;
|
||||
}
|
||||
|
@ -405,8 +405,8 @@ serverslice(int seconds,
|
|||
// sp, or dedicated server loop
|
||||
{
|
||||
// spawn entities when timer reached
|
||||
[sents enumerateObjectsUsingBlock:^(
|
||||
ServerEntity *e, size_t i, bool *stop) {
|
||||
[sents enumerateObjectsUsingBlock:
|
||||
^ (ServerEntity *e, size_t i, bool *stop) {
|
||||
if (e.spawnsecs && (e.spawnsecs -= seconds - lastsec) <= 0) {
|
||||
e.spawnsecs = 0;
|
||||
e.spawned = true;
|
||||
|
@ -421,8 +421,8 @@ serverslice(int seconds,
|
|||
checkintermission();
|
||||
if (interm && seconds > interm) {
|
||||
interm = 0;
|
||||
[clients enumerateObjectsUsingBlock:^(
|
||||
Client *client, size_t i, bool *stop) {
|
||||
[clients enumerateObjectsUsingBlock:
|
||||
^ (Client *client, size_t i, bool *stop) {
|
||||
if (client.type != ST_EMPTY) {
|
||||
// ask a client to trigger map reload
|
||||
send2(true, i, SV_MAPRELOAD, 0);
|
||||
|
@ -475,8 +475,8 @@ serverslice(int seconds,
|
|||
&c.peer->address, hn, sizeof(hn)) == 0
|
||||
? @(hn)
|
||||
: @"localhost");
|
||||
[OFStdOut
|
||||
writeFormat:@"client connected (%@)\n", c.hostname];
|
||||
[OFStdOut writeFormat: @"client connected (%@)\n",
|
||||
c.hostname];
|
||||
send_welcome(lastconnect = clients.count - 1);
|
||||
break;
|
||||
}
|
||||
|
@ -489,7 +489,8 @@ serverslice(int seconds,
|
|||
case ENET_EVENT_TYPE_DISCONNECT:
|
||||
if ((intptr_t)event.peer->data < 0)
|
||||
break;
|
||||
[OFStdOut writeFormat:@"disconnected client (%@)\n",
|
||||
[OFStdOut writeFormat:
|
||||
@"disconnected client (%@)\n",
|
||||
clients[(size_t)event.peer->data].hostname];
|
||||
clients[(size_t)event.peer->data].type = ST_EMPTY;
|
||||
send2(true, -1, SV_CDIS, (intptr_t)event.peer->data);
|
||||
|
|
|
@ -27,7 +27,7 @@ resolverinit(int threads, int limit)
|
|||
while (threads > 0) {
|
||||
ResolverThread *rt = [ResolverThread thread];
|
||||
rt.name = @"resolverthread";
|
||||
[resolverthreads addObject:rt];
|
||||
[resolverthreads addObject: rt];
|
||||
[rt start];
|
||||
--threads;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ resolverstop(size_t i, bool restart)
|
|||
|
||||
[rt start];
|
||||
} else
|
||||
[resolverthreads removeObjectAtIndex:i];
|
||||
[resolverthreads removeObjectAtIndex: i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void
|
|||
resolverquery(OFString *name)
|
||||
{
|
||||
@synchronized(ResolverThread.class) {
|
||||
[resolverqueries addObject:name];
|
||||
[resolverqueries addObject: name];
|
||||
SDL_SemPost(resolversem);
|
||||
}
|
||||
}
|
||||
|
@ -118,16 +118,16 @@ void
|
|||
addserver(OFString *servername)
|
||||
{
|
||||
for (ServerInfo *si in servers)
|
||||
if ([si.name isEqual:servername])
|
||||
if ([si.name isEqual: servername])
|
||||
return;
|
||||
|
||||
if (servers == nil)
|
||||
servers = [[OFMutableArray alloc] init];
|
||||
|
||||
[servers addObject:[ServerInfo infoWithName:servername]];
|
||||
[servers addObject: [ServerInfo infoWithName: servername]];
|
||||
}
|
||||
|
||||
COMMAND(addserver, ARG_1STR, ^(OFString *servername) {
|
||||
COMMAND(addserver, ARG_1STR, ^ (OFString *servername) {
|
||||
addserver(servername);
|
||||
})
|
||||
|
||||
|
@ -163,7 +163,7 @@ checkresolver()
|
|||
continue;
|
||||
|
||||
for (ServerInfo *si in servers) {
|
||||
if ([name isEqual:si.name]) {
|
||||
if ([name isEqual: si.name]) {
|
||||
si.address = addr;
|
||||
addr.host = ENET_HOST_ANY;
|
||||
break;
|
||||
|
@ -217,29 +217,28 @@ refreshservers()
|
|||
[servers sort];
|
||||
|
||||
__block int maxmenu = 16;
|
||||
[servers enumerateObjectsUsingBlock:^(
|
||||
ServerInfo *si, size_t i, bool *stop) {
|
||||
[servers enumerateObjectsUsingBlock:
|
||||
^ (ServerInfo *si, size_t i, bool *stop) {
|
||||
if (si.address.host != ENET_HOST_ANY && si.ping != 9999) {
|
||||
if (si.protocol != PROTOCOL_VERSION)
|
||||
si.full = [OFString stringWithFormat:
|
||||
@"%@ [different cube protocol]",
|
||||
si.name];
|
||||
@"%@ [different cube protocol]", si.name];
|
||||
else
|
||||
si.full = [OFString
|
||||
stringWithFormat:@"%d\t%d\t%@, %@: %@ %@",
|
||||
si.full = [OFString stringWithFormat:
|
||||
@"%d\t%d\t%@, %@: %@ %@",
|
||||
si.ping, si.numplayers,
|
||||
si.map.length > 0 ? si.map : @"[unknown]",
|
||||
modestr(si.mode), si.name, si.sdesc];
|
||||
} else
|
||||
si.full = [OFString stringWithFormat:
|
||||
(si.address.host != ENET_HOST_ANY
|
||||
? @"%@ [waiting for server response]"
|
||||
: @"%@ [unknown host]\t"),
|
||||
(si.address.host != ENET_HOST_ANY
|
||||
? @"%@ [waiting for server response]"
|
||||
: @"%@ [unknown host]\t"),
|
||||
si.name];
|
||||
|
||||
// cut off too long server descriptions
|
||||
if (si.full.length > 50)
|
||||
si.full = [si.full substringToIndex:50];
|
||||
si.full = [si.full substringToIndex: 50];
|
||||
|
||||
menumanual(1, i, si.full);
|
||||
|
||||
|
@ -265,11 +264,11 @@ servermenu()
|
|||
menuset(1);
|
||||
}
|
||||
|
||||
COMMAND(servermenu, ARG_NONE, ^{
|
||||
COMMAND(servermenu, ARG_NONE, ^ {
|
||||
servermenu();
|
||||
})
|
||||
|
||||
COMMAND(updatefrommaster, ARG_NONE, ^{
|
||||
COMMAND(updatefrommaster, ARG_NONE, ^ {
|
||||
const int MAXUPD = 32000;
|
||||
unsigned char buf[MAXUPD];
|
||||
unsigned char *reply = retrieveservers(buf, MAXUPD);
|
||||
|
|
|
@ -9,7 +9,7 @@ httpgetsend(ENetAddress *ad, OFString *hostname, OFString *req, OFString *ref,
|
|||
OFString *agent)
|
||||
{
|
||||
if (ad->host == ENET_HOST_ANY) {
|
||||
[OFStdOut writeFormat:@"looking up %@...\n", hostname];
|
||||
[OFStdOut writeFormat: @"looking up %@...\n", hostname];
|
||||
enet_address_set_host(ad, hostname.UTF8String);
|
||||
if (ad->host == ENET_HOST_ANY)
|
||||
return;
|
||||
|
@ -26,14 +26,15 @@ httpgetsend(ENetAddress *ad, OFString *hostname, OFString *req, OFString *ref,
|
|||
return;
|
||||
}
|
||||
ENetBuffer buf;
|
||||
OFString *httpget = [OFString stringWithFormat:@"GET %@ HTTP/1.0\n"
|
||||
@"Host: %@\n"
|
||||
@"Referer: %@\n"
|
||||
@"User-Agent: %@\n\n",
|
||||
OFString *httpget = [OFString stringWithFormat:
|
||||
@"GET %@ HTTP/1.0\n"
|
||||
@"Host: %@\n"
|
||||
@"Referer: %@\n"
|
||||
@"User-Agent: %@\n\n",
|
||||
req, hostname, ref, agent];
|
||||
buf.data = (void *)httpget.UTF8String;
|
||||
buf.dataLength = httpget.UTF8StringLength;
|
||||
[OFStdOut writeFormat:@"sending request to %@...\n", hostname];
|
||||
[OFStdOut writeFormat: @"sending request to %@...\n", hostname];
|
||||
enet_socket_send(mssock, NULL, &buf, 1);
|
||||
}
|
||||
|
||||
|
@ -77,8 +78,8 @@ updatemasterserver(int seconds)
|
|||
{
|
||||
// send alive signal to masterserver every hour of uptime
|
||||
if (seconds > updmaster) {
|
||||
OFString *path = [OFString
|
||||
stringWithFormat:@"%@register.do?action=add", masterpath];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"%@register.do?action=add", masterpath];
|
||||
httpgetsend(&masterserver, masterbase, path, @"cubeserver",
|
||||
@"Cube Server");
|
||||
masterrep[0] = 0;
|
||||
|
@ -100,8 +101,8 @@ checkmasterreply()
|
|||
unsigned char *
|
||||
retrieveservers(unsigned char *buf, int buflen)
|
||||
{
|
||||
OFString *path =
|
||||
[OFString stringWithFormat:@"%@retrieve.do?item=list", masterpath];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"%@retrieve.do?item=list", masterpath];
|
||||
httpgetsend(
|
||||
&masterserver, masterbase, path, @"cubeserver", @"Cube Server");
|
||||
ENetBuffer eb;
|
||||
|
@ -140,8 +141,8 @@ serverms(int mode, int numplayers, int minremain, OFString *smapname,
|
|||
putint(&p, mode);
|
||||
putint(&p, numplayers);
|
||||
putint(&p, minremain);
|
||||
OFString *mname = [OFString stringWithFormat:@"%@%@",
|
||||
(isfull ? @"[FULL] " : @""), smapname];
|
||||
OFString *mname = [OFString stringWithFormat:
|
||||
@"%@%@", (isfull ? @"[FULL] " : @""), smapname];
|
||||
sendstring(mname, &p);
|
||||
sendstring(serverdesc, &p);
|
||||
buf.dataLength = p - pong;
|
||||
|
@ -157,7 +158,8 @@ servermsinit(OFString *master_, OFString *sdesc, bool listen)
|
|||
if (!mid)
|
||||
mid = master;
|
||||
masterpath = @(mid);
|
||||
masterbase = [OFString stringWithUTF8String:master length:mid - master];
|
||||
masterbase = [OFString stringWithUTF8String: master
|
||||
length: mid - master];
|
||||
serverdesc = sdesc;
|
||||
|
||||
if (listen) {
|
||||
|
|
|
@ -146,10 +146,10 @@ fatal(OFConstantString *s, ...)
|
|||
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
OFString *msg = [[OFString alloc] initWithFormat:s arguments:args];
|
||||
OFString *msg = [[OFString alloc] initWithFormat: s arguments: args];
|
||||
va_end(args);
|
||||
|
||||
[OFStdOut writeFormat:@"servererror: %@\n", msg];
|
||||
[OFStdOut writeFormat: @"servererror: %@\n", msg];
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
|
32
src/sound.m
32
src/sound.m
|
@ -49,19 +49,19 @@ initsound()
|
|||
Mix_AllocateChannels(MAXCHAN);
|
||||
}
|
||||
|
||||
COMMAND(music, ARG_1STR, (^(OFString *name) {
|
||||
COMMAND(music, ARG_1STR, (^ (OFString *name) {
|
||||
if (nosound)
|
||||
return;
|
||||
|
||||
stopsound();
|
||||
|
||||
if (soundvol && musicvol) {
|
||||
name = [name stringByReplacingOccurrencesOfString:@"\\"
|
||||
withString:@"/"];
|
||||
OFString *path =
|
||||
[OFString stringWithFormat:@"packages/%@", name];
|
||||
name = [name stringByReplacingOccurrencesOfString: @"\\"
|
||||
withString: @"/"];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"packages/%@", name];
|
||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:path];
|
||||
IRIByAppendingPathComponent: path];
|
||||
|
||||
if ((mod = Mix_LoadMUS(
|
||||
IRI.fileSystemRepresentation.UTF8String)) != NULL) {
|
||||
|
@ -77,7 +77,7 @@ static OFMutableArray<OFString *> *snames;
|
|||
COMMAND(registersound, ARG_1EST, ^int(OFString *name) {
|
||||
int i = 0;
|
||||
for (OFString *iter in snames) {
|
||||
if ([iter isEqual:name])
|
||||
if ([iter isEqual: name])
|
||||
return i;
|
||||
|
||||
i++;
|
||||
|
@ -87,12 +87,12 @@ COMMAND(registersound, ARG_1EST, ^int(OFString *name) {
|
|||
snames = [[OFMutableArray alloc] init];
|
||||
if (samples == nil)
|
||||
samples = [[OFMutableData alloc]
|
||||
initWithItemSize:sizeof(Mix_Chunk *)];
|
||||
initWithItemSize: sizeof(Mix_Chunk *)];
|
||||
|
||||
[snames addObject:[name stringByReplacingOccurrencesOfString:@"\\"
|
||||
withString:@"/"]];
|
||||
[snames addObject: [name stringByReplacingOccurrencesOfString: @"\\"
|
||||
withString: @"/"]];
|
||||
Mix_Chunk *sample = NULL;
|
||||
[samples addItem:&sample];
|
||||
[samples addItem: &sample];
|
||||
|
||||
return samples.count - 1;
|
||||
})
|
||||
|
@ -193,12 +193,12 @@ playsound(int n, const OFVector3D *loc)
|
|||
return;
|
||||
}
|
||||
|
||||
Mix_Chunk **sample = (Mix_Chunk **)[samples mutableItemAtIndex:n];
|
||||
Mix_Chunk **sample = (Mix_Chunk **)[samples mutableItemAtIndex: n];
|
||||
if (*sample == NULL) {
|
||||
OFString *path = [OFString
|
||||
stringWithFormat:@"packages/sounds/%@.wav", snames[n]];
|
||||
OFString *path = [OFString stringWithFormat:
|
||||
@"packages/sounds/%@.wav", snames[n]];
|
||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||
IRIByAppendingPathComponent:path];
|
||||
IRIByAppendingPathComponent: path];
|
||||
|
||||
*sample = Mix_LoadWAV(IRI.fileSystemRepresentation.UTF8String);
|
||||
|
||||
|
@ -218,6 +218,6 @@ playsound(int n, const OFVector3D *loc)
|
|||
updatechanvol(chan, loc);
|
||||
}
|
||||
|
||||
COMMAND(sound, ARG_1INT, ^(int n) {
|
||||
COMMAND(sound, ARG_1INT, ^ (int n) {
|
||||
playsound(n, NULL);
|
||||
})
|
||||
|
|
31
src/weapon.m
31
src/weapon.m
|
@ -66,7 +66,7 @@ reloadtime(int gun)
|
|||
return guns[gun].attackdelay;
|
||||
}
|
||||
|
||||
COMMAND(weapon, ARG_3STR, ^(OFString *a1, OFString *a2, OFString *a3) {
|
||||
COMMAND(weapon, ARG_3STR, ^ (OFString *a1, OFString *a2, OFString *a3) {
|
||||
selectgun((a1.length > 0 ? a1.cube_intValue : -1),
|
||||
(a2.length > 0 ? a2.cube_intValue : -1),
|
||||
(a3.length > 0 ? a3.cube_intValue : -1));
|
||||
|
@ -117,7 +117,7 @@ playerincrosshair()
|
|||
|
||||
OFVector3D o = Player.player1.origin;
|
||||
for (Player *player in players) {
|
||||
if (![Player isKindOfClass:Player.class])
|
||||
if (![Player isKindOfClass: Player.class])
|
||||
continue;
|
||||
|
||||
if (intersect(player, o, worldpos))
|
||||
|
@ -167,9 +167,9 @@ hit(int target, int damage, __kindof DynamicEntity *d, DynamicEntity *at)
|
|||
OFVector3D o = d.origin;
|
||||
if (d == Player.player1)
|
||||
selfdamage(damage, (at == Player.player1) ? -1 : -2, at);
|
||||
else if ([d isKindOfClass:Monster.class])
|
||||
[d incurDamage:damage fromEntity:at];
|
||||
else if ([d isKindOfClass:Player.class]) {
|
||||
else if ([d isKindOfClass: Monster.class])
|
||||
[d incurDamage: damage fromEntity: at];
|
||||
else if ([d isKindOfClass: Player.class]) {
|
||||
addmsg(1, 4, SV_DAMAGE, target, damage,
|
||||
((Player *)d).lifeSequence);
|
||||
playsound(S_PAIN1 + rnd(5), &o);
|
||||
|
@ -225,8 +225,8 @@ splash(Projectile *p, OFVector3D v, OFVector3D vold, int notthisplayer,
|
|||
|
||||
radialeffect(Player.player1, v, -1, qdam, p.owner);
|
||||
|
||||
[players enumerateObjectsUsingBlock:^(
|
||||
id player, size_t i, bool *stop) {
|
||||
[players enumerateObjectsUsingBlock:
|
||||
^ (id player, size_t i, bool *stop) {
|
||||
if (i == notthisplayer)
|
||||
return;
|
||||
|
||||
|
@ -236,8 +236,8 @@ splash(Projectile *p, OFVector3D v, OFVector3D vold, int notthisplayer,
|
|||
radialeffect(player, v, i, qdam, p.owner);
|
||||
}];
|
||||
|
||||
[Monster.monsters enumerateObjectsUsingBlock:^(
|
||||
Monster *monster, size_t i, bool *stop) {
|
||||
[Monster.monsters enumerateObjectsUsingBlock:
|
||||
^ (Monster *monster, size_t i, bool *stop) {
|
||||
if (i != notthismonster)
|
||||
radialeffect(monster, v, i, qdam, p.owner);
|
||||
}];
|
||||
|
@ -268,7 +268,7 @@ moveprojectiles(float time)
|
|||
continue;
|
||||
|
||||
int qdam = guns[p.gun].damage * (p.owner.quadMillis ? 4 : 1);
|
||||
if ([p.owner isKindOfClass:Monster.class])
|
||||
if ([p.owner isKindOfClass: Monster.class])
|
||||
qdam /= MONSTERDAMAGEFACTOR;
|
||||
OFVector3D po = p.o, pto = p.to;
|
||||
float dist = OFDistanceOfVectors3D(pto, po);
|
||||
|
@ -336,7 +336,7 @@ shootv(int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local)
|
|||
case GUN_ICEBALL:
|
||||
case GUN_SLIMEBALL:
|
||||
pspeed = guns[gun].projspeed;
|
||||
if ([d isKindOfClass:Monster.class])
|
||||
if ([d isKindOfClass: Monster.class])
|
||||
pspeed /= 2;
|
||||
newprojectile(from, to, (float)pspeed, local, d, gun);
|
||||
break;
|
||||
|
@ -368,7 +368,7 @@ raydamage(
|
|||
int qdam = guns[d.gunSelect].damage;
|
||||
if (d.quadMillis)
|
||||
qdam *= 4;
|
||||
if ([d isKindOfClass:Monster.class])
|
||||
if ([d isKindOfClass: Monster.class])
|
||||
qdam /= MONSTERDAMAGEFACTOR;
|
||||
if (d.gunSelect == GUN_SG) {
|
||||
int damage = 0;
|
||||
|
@ -423,7 +423,7 @@ shoot(DynamicEntity *d, OFVector3D targ)
|
|||
if (d.quadMillis && attacktime > 200)
|
||||
playsoundc(S_ITEMPUP);
|
||||
shootv(d.gunSelect, from, to, d, true);
|
||||
if (![d isKindOfClass:Monster.class])
|
||||
if (![d isKindOfClass: Monster.class])
|
||||
addmsg(1, 8, SV_SHOT, d.gunSelect, (int)(from.x * DMF),
|
||||
(int)(from.y * DMF), (int)(from.z * DMF), (int)(to.x * DMF),
|
||||
(int)(to.y * DMF), (int)(to.z * DMF));
|
||||
|
@ -432,7 +432,8 @@ shoot(DynamicEntity *d, OFVector3D targ)
|
|||
if (guns[d.gunSelect].projspeed)
|
||||
return;
|
||||
|
||||
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
||||
[players enumerateObjectsUsingBlock:
|
||||
^ (id player, size_t i, bool *stop) {
|
||||
if (player != [OFNull null])
|
||||
raydamage(player, from, to, d, i);
|
||||
}];
|
||||
|
@ -441,6 +442,6 @@ shoot(DynamicEntity *d, OFVector3D targ)
|
|||
if (monster != d)
|
||||
raydamage(monster, from, to, d, -2);
|
||||
|
||||
if ([d isKindOfClass:Monster.class])
|
||||
if ([d isKindOfClass: Monster.class])
|
||||
raydamage(Player.player1, from, to, d, -1);
|
||||
}
|
||||
|
|
30
src/world.m
30
src/world.m
|
@ -66,7 +66,7 @@ settagareas()
|
|||
{
|
||||
settag(0, 1);
|
||||
|
||||
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
|
||||
[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
|
||||
if (ents[i].type == CARROT)
|
||||
setspawn(i, true);
|
||||
}];
|
||||
|
@ -83,17 +83,17 @@ trigger(int tag, int type, bool savegame)
|
|||
if (!savegame && type != 3)
|
||||
playsound(S_RUMBLE, NULL);
|
||||
|
||||
OFString *aliasname =
|
||||
[OFString stringWithFormat:@"level_trigger_%d", tag];
|
||||
OFString *aliasname = [OFString stringWithFormat:
|
||||
@"level_trigger_%d", tag];
|
||||
|
||||
if (identexists(aliasname))
|
||||
execute(aliasname, true);
|
||||
|
||||
if (type == 2)
|
||||
[Monster endSinglePlayerWithAllKilled:false];
|
||||
[Monster endSinglePlayerWithAllKilled: false];
|
||||
}
|
||||
|
||||
COMMAND(trigger, ARG_2INT, ^(int tag, int type, bool savegame) {
|
||||
COMMAND(trigger, ARG_2INT, ^ (int tag, int type, bool savegame) {
|
||||
trigger(tag, type, savegame);
|
||||
})
|
||||
|
||||
|
@ -293,7 +293,7 @@ closestent() // used for delent and edit mode ent display
|
|||
|
||||
__block int best;
|
||||
__block float bdist = 99999;
|
||||
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
|
||||
[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
|
||||
if (e.type == NOTUSED)
|
||||
return;
|
||||
|
||||
|
@ -308,7 +308,7 @@ closestent() // used for delent and edit mode ent display
|
|||
return (bdist == 99999 ? -1 : best);
|
||||
}
|
||||
|
||||
COMMAND(entproperty, ARG_2INT, ^(int prop, int amount) {
|
||||
COMMAND(entproperty, ARG_2INT, ^ (int prop, int amount) {
|
||||
int e = closestent();
|
||||
if (e < 0)
|
||||
return;
|
||||
|
@ -328,7 +328,7 @@ COMMAND(entproperty, ARG_2INT, ^(int prop, int amount) {
|
|||
}
|
||||
})
|
||||
|
||||
COMMAND(delent, ARG_NONE, ^{
|
||||
COMMAND(delent, ARG_NONE, ^ {
|
||||
int e = closestent();
|
||||
if (e < 0) {
|
||||
conoutf(@"no more entities");
|
||||
|
@ -346,7 +346,7 @@ int
|
|||
findtype(OFString *what)
|
||||
{
|
||||
for (int i = 0; i < MAXENTTYPES; i++)
|
||||
if ([what isEqual:entnames[i]])
|
||||
if ([what isEqual: entnames[i]])
|
||||
return i;
|
||||
conoutf(@"unknown entity type \"%@\"", what);
|
||||
return NOTUSED;
|
||||
|
@ -389,7 +389,7 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
|
|||
addmsg(1, 10, SV_EDITENT, ents.count, type, e.x, e.y, e.z, e.attr1,
|
||||
e.attr2, e.attr3, e.attr4);
|
||||
|
||||
[ents addObject:e];
|
||||
[ents addObject: e];
|
||||
|
||||
if (type == LIGHT)
|
||||
calclight();
|
||||
|
@ -397,7 +397,7 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
|
|||
return e;
|
||||
}
|
||||
|
||||
COMMAND(clearents, ARG_1STR, ^(OFString *name) {
|
||||
COMMAND(clearents, ARG_1STR, ^ (OFString *name) {
|
||||
int type = findtype(name);
|
||||
|
||||
if (noteditmode() || multiplayer())
|
||||
|
@ -420,7 +420,7 @@ scalecomp(unsigned char c, int intens)
|
|||
return n;
|
||||
}
|
||||
|
||||
COMMAND(scalelights, ARG_2INT, ^(int f, int intens) {
|
||||
COMMAND(scalelights, ARG_2INT, ^ (int f, int intens) {
|
||||
for (Entity *e in ents) {
|
||||
if (e.type != LIGHT)
|
||||
continue;
|
||||
|
@ -545,14 +545,14 @@ empty_world(int factor, bool force)
|
|||
}
|
||||
}
|
||||
|
||||
COMMAND(mapenlarge, ARG_NONE, ^{
|
||||
COMMAND(mapenlarge, ARG_NONE, ^ {
|
||||
empty_world(-1, false);
|
||||
})
|
||||
|
||||
COMMAND(newmap, ARG_1INT, ^(int i) {
|
||||
COMMAND(newmap, ARG_1INT, ^ (int i) {
|
||||
empty_world(i, false);
|
||||
})
|
||||
|
||||
COMMAND(recalc, ARG_NONE, ^{
|
||||
COMMAND(recalc, ARG_NONE, ^ {
|
||||
calclight();
|
||||
})
|
||||
|
|
|
@ -15,8 +15,8 @@ struct persistent_entity {
|
|||
void
|
||||
backup(OFString *name, OFString *backupname)
|
||||
{
|
||||
[OFFileManager.defaultManager removeItemAtPath:backupname];
|
||||
[OFFileManager.defaultManager moveItemAtPath:name toPath:backupname];
|
||||
[OFFileManager.defaultManager removeItemAtPath: backupname];
|
||||
[OFFileManager.defaultManager moveItemAtPath: name toPath: backupname];
|
||||
}
|
||||
|
||||
static OFString *cgzname, *bakname, *pcfname, *mcfname;
|
||||
|
@ -25,26 +25,26 @@ static void
|
|||
setnames(OFString *name)
|
||||
{
|
||||
OFCharacterSet *cs =
|
||||
[OFCharacterSet characterSetWithCharactersInString:@"/\\"];
|
||||
OFRange range = [name rangeOfCharacterFromSet:cs];
|
||||
[OFCharacterSet characterSetWithCharactersInString: @"/\\"];
|
||||
OFRange range = [name rangeOfCharacterFromSet: cs];
|
||||
OFString *pakname, *mapname;
|
||||
|
||||
if (range.location != OFNotFound) {
|
||||
pakname = [name substringToIndex:range.location];
|
||||
mapname = [name substringFromIndex:range.location + 1];
|
||||
pakname = [name substringToIndex: range.location];
|
||||
mapname = [name substringFromIndex: range.location + 1];
|
||||
} else {
|
||||
pakname = @"base";
|
||||
mapname = name;
|
||||
}
|
||||
|
||||
cgzname = [[OFString alloc]
|
||||
initWithFormat:@"packages/%@/%@.cgz", pakname, mapname];
|
||||
bakname = [[OFString alloc] initWithFormat:@"packages/%@/%@_%d.BAK",
|
||||
pakname, mapname, lastmillis];
|
||||
pcfname = [[OFString alloc]
|
||||
initWithFormat:@"packages/%@/package.cfg", pakname];
|
||||
mcfname = [[OFString alloc]
|
||||
initWithFormat:@"packages/%@/%@.cfg", pakname, mapname];
|
||||
cgzname = [[OFString alloc] initWithFormat:
|
||||
@"packages/%@/%@.cgz", pakname, mapname];
|
||||
bakname = [[OFString alloc] initWithFormat:
|
||||
@"packages/%@/%@_%d.BAK", pakname, mapname, lastmillis];
|
||||
pcfname = [[OFString alloc] initWithFormat:
|
||||
@"packages/%@/package.cfg", pakname];
|
||||
mcfname = [[OFString alloc] initWithFormat:
|
||||
@"packages/%@/%@.cfg", pakname, mapname];
|
||||
}
|
||||
|
||||
// the optimize routines below are here to reduce the detrimental effects of
|
||||
|
@ -145,7 +145,7 @@ writemap(OFString *mname, int msize, unsigned char *mdata)
|
|||
setnames(mname);
|
||||
backup(cgzname, bakname);
|
||||
|
||||
FILE *f = fopen([cgzname cStringWithEncoding:OFLocale.encoding], "wb");
|
||||
FILE *f = fopen([cgzname cStringWithEncoding: OFLocale.encoding], "wb");
|
||||
if (!f) {
|
||||
conoutf(@"could not write map to %@", cgzname);
|
||||
return;
|
||||
|
@ -159,7 +159,7 @@ OFData *
|
|||
readmap(OFString *mname)
|
||||
{
|
||||
setnames(mname);
|
||||
return [OFData dataWithContentsOfFile:mname];
|
||||
return [OFData dataWithContentsOfFile: mname];
|
||||
}
|
||||
|
||||
// save map as .cgz file. uses 2 layers of compression: first does simple
|
||||
|
@ -178,8 +178,8 @@ save_world(OFString *mname)
|
|||
mname = getclientmap();
|
||||
setnames(mname);
|
||||
backup(cgzname, bakname);
|
||||
gzFile f =
|
||||
gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "wb9");
|
||||
gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
|
||||
"wb9");
|
||||
if (!f) {
|
||||
conoutf(@"could not write map to %@", cgzname);
|
||||
return;
|
||||
|
@ -258,7 +258,7 @@ save_world(OFString *mname)
|
|||
settagareas();
|
||||
}
|
||||
|
||||
COMMAND(savemap, ARG_1STR, ^(OFString *mname) {
|
||||
COMMAND(savemap, ARG_1STR, ^ (OFString *mname) {
|
||||
save_world(mname);
|
||||
})
|
||||
|
||||
|
@ -270,8 +270,8 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
|||
cleardlights();
|
||||
pruneundos(0);
|
||||
setnames(mname);
|
||||
gzFile f =
|
||||
gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "rb9");
|
||||
gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
|
||||
"rb9");
|
||||
if (!f) {
|
||||
conoutf(@"could not read map %@", cgzname);
|
||||
return;
|
||||
|
@ -305,7 +305,7 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
|||
e.attr2 = tmp.attr2;
|
||||
e.attr3 = tmp.attr3;
|
||||
e.attr4 = tmp.attr4;
|
||||
[ents addObject:e];
|
||||
[ents addObject: e];
|
||||
|
||||
if (e.type == LIGHT) {
|
||||
if (!e.attr2)
|
||||
|
@ -396,14 +396,14 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
|||
startmap(mname);
|
||||
for (int l = 0; l < 256; l++) {
|
||||
// can this be done smarter?
|
||||
OFString *aliasname =
|
||||
[OFString stringWithFormat:@"level_trigger_%d", l];
|
||||
OFString *aliasname = [OFString stringWithFormat:
|
||||
@"level_trigger_%d", l];
|
||||
if (identexists(aliasname))
|
||||
alias(aliasname, @"");
|
||||
}
|
||||
OFIRI *gameDataIRI = Cube.sharedInstance.gameDataIRI;
|
||||
execfile([gameDataIRI
|
||||
IRIByAppendingPathComponent:@"data/default_map_settings.cfg"]);
|
||||
execfile([gameDataIRI IRIByAppendingPathComponent:pcfname]);
|
||||
execfile([gameDataIRI IRIByAppendingPathComponent:mcfname]);
|
||||
IRIByAppendingPathComponent: @"data/default_map_settings.cfg"]);
|
||||
execfile([gameDataIRI IRIByAppendingPathComponent: pcfname]);
|
||||
execfile([gameDataIRI IRIByAppendingPathComponent: mcfname]);
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength,
|
|||
{
|
||||
if (!reach)
|
||||
reach = dynlight;
|
||||
if ([owner isKindOfClass:Monster.class])
|
||||
if ([owner isKindOfClass: Monster.class])
|
||||
reach = reach / 2;
|
||||
if (!reach)
|
||||
return;
|
||||
|
@ -227,11 +227,11 @@ dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength,
|
|||
|
||||
if (dlights == nil)
|
||||
dlights = [[OFMutableData alloc]
|
||||
initWithItemSize:sizeof(struct block *)];
|
||||
initWithItemSize: sizeof(struct block *)];
|
||||
|
||||
// backup area before rendering in dynlight
|
||||
struct block *copy = blockcopy(&b);
|
||||
[dlights addItem:©];
|
||||
[dlights addItem: ©];
|
||||
|
||||
Entity *l = [Entity entity];
|
||||
l.x = v.x;
|
||||
|
|
|
@ -11,7 +11,7 @@ float rdist[NUMRAYS];
|
|||
bool ocull = true;
|
||||
float odist = 256;
|
||||
|
||||
COMMAND(toggleocull, ARG_NONE, ^{
|
||||
COMMAND(toggleocull, ARG_NONE, ^ {
|
||||
ocull = !ocull;
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue