Make use of OF_DIRECT
FossilOrigin-Name: 7a98b92af94db34093428fc95da00435311c270d74135e69aa94bca16871a023
This commit is contained in:
parent
fb8a872695
commit
cc5cc21aca
27 changed files with 73 additions and 50 deletions
|
@ -3,16 +3,17 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface Alias: Identifier
|
@interface Alias: Identifier
|
||||||
@property (copy, nonatomic) OFString *action;
|
@property (direct, copy, nonatomic) OFString *action;
|
||||||
@property (readonly, nonatomic) bool persisted;
|
@property (readonly, nonatomic) bool persisted;
|
||||||
|
|
||||||
+ (instancetype)aliasWithName:(OFString *)name
|
+ (instancetype)aliasWithName:(OFString *)name
|
||||||
action:(OFString *)action
|
action:(OFString *)action
|
||||||
persisted:(bool)persisted;
|
persisted:(bool)persisted OF_DIRECT;
|
||||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||||
- (instancetype)initWithName:(OFString *)name
|
- (instancetype)initWithName:(OFString *)name
|
||||||
action:(OFString *)action
|
action:(OFString *)action
|
||||||
persisted:(bool)persisted;
|
persisted:(bool)persisted OF_DESIGNATED_INITIALIZER
|
||||||
|
OF_DIRECT;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#import "cube.h"
|
#import "cube.h"
|
||||||
|
|
||||||
// server side version of "dynent" type
|
// server side version of "dynent" type
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Client: OFObject
|
@interface Client: OFObject
|
||||||
@property (nonatomic) int type;
|
@property (nonatomic) int type;
|
||||||
@property (nonatomic) ENetPeer *peer;
|
@property (nonatomic) ENetPeer *peer;
|
||||||
|
|
|
@ -13,6 +13,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
}); \
|
}); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Command: Identifier
|
@interface Command: Identifier
|
||||||
@property (readonly, nonatomic) int argumentsTypes;
|
@property (readonly, nonatomic) int argumentsTypes;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||||
- (instancetype)initWithName:(OFString *)name
|
- (instancetype)initWithName:(OFString *)name
|
||||||
argumentsTypes:(int)argumentsTypes
|
argumentsTypes:(int)argumentsTypes
|
||||||
block:(id)block;
|
block:(id)block OF_DESIGNATED_INITIALIZER;
|
||||||
- (int)callWithArguments:(OFArray<OFString *> *)arguments isDown:(bool)isDown;
|
- (int)callWithArguments:(OFArray<OFString *> *)arguments isDown:(bool)isDown;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface ConsoleLine: OFObject
|
@interface ConsoleLine: OFObject
|
||||||
@property (readonly, copy) OFString *text;
|
@property (readonly, copy) OFString *text;
|
||||||
@property (readonly) int outtime;
|
@property (readonly) int outtime;
|
||||||
|
|
|
@ -2,37 +2,36 @@
|
||||||
|
|
||||||
// players & monsters
|
// players & monsters
|
||||||
@interface DynamicEntity: OFObject <OFCopying>
|
@interface DynamicEntity: OFObject <OFCopying>
|
||||||
@property (class, readonly, nonatomic) size_t serializedSize;
|
@property (class, direct, readonly, nonatomic) size_t serializedSize;
|
||||||
|
|
||||||
@property (nonatomic) OFVector3D origin, velocity;
|
@property (direct, nonatomic) OFVector3D origin, velocity;
|
||||||
// used as OFVector3D in one place
|
// used as OFVector3D in one place
|
||||||
@property (nonatomic) float yaw, pitch, roll;
|
@property (direct, nonatomic) float yaw, pitch, roll;
|
||||||
// cubes per second, 24 for player
|
// cubes per second, 24 for player
|
||||||
@property (nonatomic) float maxSpeed;
|
@property (direct, nonatomic) float maxSpeed;
|
||||||
// from his eyes
|
// from his eyes
|
||||||
@property (nonatomic) bool outsideMap;
|
@property (direct, nonatomic) bool outsideMap;
|
||||||
@property (nonatomic) bool inWater;
|
@property (direct, nonatomic) bool inWater;
|
||||||
@property (nonatomic) bool onFloor, jumpNext;
|
@property (direct, nonatomic) bool onFloor, jumpNext;
|
||||||
@property (nonatomic) int move, strafe;
|
@property (direct, nonatomic) int move, strafe;
|
||||||
// see input code
|
// see input code
|
||||||
@property (nonatomic) bool k_left, k_right, k_up, k_down;
|
@property (direct, nonatomic) bool k_left, k_right, k_up, k_down;
|
||||||
// used for fake gravity
|
// used for fake gravity
|
||||||
@property (nonatomic) int timeInAir;
|
@property (direct, nonatomic) int timeInAir;
|
||||||
// bounding box size
|
// bounding box size
|
||||||
@property (nonatomic) float radius, eyeHeight, aboveEye;
|
@property (direct, nonatomic) float radius, eyeHeight, aboveEye;
|
||||||
@property (nonatomic) int lastUpdate, lag, ping;
|
@property (direct, nonatomic) int lastUpdate, lag, ping;
|
||||||
// one of CS_* below
|
// one of CS_* below
|
||||||
@property (nonatomic) int state;
|
@property (direct, nonatomic) int state;
|
||||||
@property (nonatomic) int health, armour, armourType, quadMillis;
|
@property (direct, nonatomic) int health, armour, armourType, quadMillis;
|
||||||
@property (nonatomic) int gunSelect, gunWait;
|
@property (direct, nonatomic) int gunSelect, gunWait;
|
||||||
@property (nonatomic) int lastAction, lastAttackGun, lastMove;
|
@property (direct, nonatomic) int lastAction, lastAttackGun, lastMove;
|
||||||
@property (readonly, nonatomic) int *ammo;
|
@property (direct, readonly, nonatomic) int *ammo;
|
||||||
@property (nonatomic) bool attacking;
|
@property (direct, nonatomic) bool attacking;
|
||||||
// used by physics to signal ai
|
// used by physics to signal ai
|
||||||
@property (nonatomic) bool blocked, moving;
|
@property (direct, nonatomic) bool blocked, moving;
|
||||||
@property (copy, nonatomic) OFString *name;
|
@property (direct, copy, nonatomic) OFString *name;
|
||||||
|
|
||||||
+ (instancetype)entity;
|
|
||||||
- (OFData *)dataBySerializing;
|
- (OFData *)dataBySerializing;
|
||||||
- (void)setFromSerializedData:(OFData *)data;
|
- (void)setFromSerializedData:(OFData *)data;
|
||||||
- (void)resetMovement;
|
- (void)resetMovement;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
// map entity
|
// map entity
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Entity: OFObject
|
@interface Entity: OFObject
|
||||||
@property (nonatomic) short x, y, z; // cube aligned position
|
@property (nonatomic) short x, y, z; // cube aligned position
|
||||||
@property (nonatomic) short attr1;
|
@property (nonatomic) short attr1;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface Identifier: OFObject
|
@interface Identifier: OFObject
|
||||||
@property (readonly, copy, nonatomic) OFString *name;
|
@property (direct, readonly, copy, nonatomic) OFString *name;
|
||||||
@property (class, readonly, nonatomic)
|
@property (class, direct, readonly, nonatomic)
|
||||||
OFMutableDictionary<OFString *, __kindof Identifier *> *identifiers;
|
OFMutableDictionary<OFString *, __kindof Identifier *> *identifiers;
|
||||||
|
|
||||||
- (instancetype)init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface KeyMapping: OFObject
|
@interface KeyMapping: OFObject
|
||||||
@property (readonly) int code;
|
@property (readonly) int code;
|
||||||
@property (readonly, nonatomic) OFString *name;
|
@property (readonly, nonatomic) OFString *name;
|
||||||
|
|
|
@ -4,6 +4,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class MapModelInfo;
|
@class MapModelInfo;
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface MD2: OFObject
|
@interface MD2: OFObject
|
||||||
@property (nonatomic) MapModelInfo *mmi;
|
@property (nonatomic) MapModelInfo *mmi;
|
||||||
@property (copy, nonatomic) OFString *loadname;
|
@property (copy, nonatomic) OFString *loadname;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface MapModelInfo: OFObject
|
@interface MapModelInfo: OFObject
|
||||||
@property (nonatomic) int rad, h, zoff, snap;
|
@property (nonatomic) int rad, h, zoff, snap;
|
||||||
@property (copy, nonatomic) OFString *name;
|
@property (copy, nonatomic) OFString *name;
|
||||||
|
|
|
@ -4,6 +4,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class MenuItem;
|
@class MenuItem;
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Menu: OFObject
|
@interface Menu: OFObject
|
||||||
@property (readonly, nonatomic) OFString *name;
|
@property (readonly, nonatomic) OFString *name;
|
||||||
@property (readonly) OFMutableArray<MenuItem *> *items;
|
@property (readonly) OFMutableArray<MenuItem *> *items;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface MenuItem: OFObject
|
@interface MenuItem: OFObject
|
||||||
@property (readonly, nonatomic) OFString *text, *action;
|
@property (readonly, nonatomic) OFString *text, *action;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import "DynamicEntity.h"
|
#import "DynamicEntity.h"
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Monster: DynamicEntity
|
@interface Monster: DynamicEntity
|
||||||
@property (class, readonly, nonatomic) OFMutableArray<Monster *> *monsters;
|
@property (class, readonly, nonatomic) OFMutableArray<Monster *> *monsters;
|
||||||
// one of M_*
|
// one of M_*
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface
|
@interface
|
||||||
OFString (Cube)
|
OFString (Cube)
|
||||||
@property (readonly, nonatomic) int cube_intValue;
|
@property (readonly, nonatomic) int cube_intValue;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import "DynamicEntity.h"
|
#import "DynamicEntity.h"
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Player: DynamicEntity
|
@interface Player: DynamicEntity
|
||||||
// special client ent that receives input and acts as camera
|
// special client ent that receives input and acts as camera
|
||||||
@property (class, nonatomic) Player *player1;
|
@property (class, nonatomic) Player *player1;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
@class DynamicEntity;
|
@class DynamicEntity;
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Projectile: OFObject
|
@interface Projectile: OFObject
|
||||||
@property (nonatomic) OFVector3D o, to;
|
@property (nonatomic) OFVector3D o, to;
|
||||||
@property (nonatomic) float speed;
|
@property (nonatomic) float speed;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#import "cube.h"
|
#import "cube.h"
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface ResolverResult: OFObject
|
@interface ResolverResult: OFObject
|
||||||
@property (readonly, nonatomic) OFString *query;
|
@property (readonly, nonatomic) OFString *query;
|
||||||
@property (readonly, nonatomic) ENetAddress address;
|
@property (readonly, nonatomic) ENetAddress address;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface ResolverThread: OFThread
|
@interface ResolverThread: OFThread
|
||||||
{
|
{
|
||||||
volatile bool _stop;
|
volatile bool _stop;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
// server side version of "entity" type
|
// server side version of "entity" type
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface ServerEntity: OFObject
|
@interface ServerEntity: OFObject
|
||||||
@property (nonatomic) bool spawned;
|
@property (nonatomic) bool spawned;
|
||||||
@property (nonatomic) int spawnsecs;
|
@property (nonatomic) int spawnsecs;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <enet/enet.h>
|
#include <enet/enet.h>
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface ServerInfo: OFObject <OFComparing>
|
@interface ServerInfo: OFObject <OFComparing>
|
||||||
@property (readonly, nonatomic) OFString *name;
|
@property (readonly, nonatomic) OFString *name;
|
||||||
@property (copy, nonatomic) OFString *full;
|
@property (copy, nonatomic) OFString *full;
|
||||||
|
|
|
@ -27,16 +27,16 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFComparisonResult)compare:(id)otherObject
|
- (OFComparisonResult)compare:(ServerInfo *)otherObject
|
||||||
{
|
{
|
||||||
if (![otherObject isKindOfClass:ServerInfo.class])
|
if (![otherObject isKindOfClass:ServerInfo.class])
|
||||||
@throw [OFInvalidArgumentException exception];
|
@throw [OFInvalidArgumentException exception];
|
||||||
|
|
||||||
if (_ping > [otherObject ping])
|
if (_ping > otherObject.ping)
|
||||||
return OFOrderedDescending;
|
return OFOrderedDescending;
|
||||||
if (_ping < [otherObject ping])
|
if (_ping < otherObject.ping)
|
||||||
return OFOrderedAscending;
|
return OFOrderedAscending;
|
||||||
|
|
||||||
return [_name compare:[otherObject name]];
|
return [_name compare:otherObject.name];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -74,9 +74,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
static void var_##name() { body; }
|
static void var_##name() { body; }
|
||||||
|
|
||||||
@interface Variable: Identifier
|
@interface Variable: Identifier
|
||||||
@property (readonly, nonatomic) int min, max;
|
@property (direct, readonly, nonatomic) int min, max;
|
||||||
@property (readonly, nonatomic) int *storage;
|
@property (direct, readonly, nonatomic) int *storage;
|
||||||
@property (readonly, nullable, nonatomic) void (*function)();
|
@property (direct, readonly, nullable, nonatomic) void (*function)();
|
||||||
@property (readonly, nonatomic) bool persisted;
|
@property (readonly, nonatomic) bool persisted;
|
||||||
|
|
||||||
+ (instancetype)variableWithName:(OFString *)name
|
+ (instancetype)variableWithName:(OFString *)name
|
||||||
|
@ -84,16 +84,17 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
max:(int)max
|
max:(int)max
|
||||||
storage:(int *)storage
|
storage:(int *)storage
|
||||||
function:(void (*_Nullable)())function
|
function:(void (*_Nullable)())function
|
||||||
persisted:(bool)persisted;
|
persisted:(bool)persisted OF_DIRECT;
|
||||||
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
- (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE;
|
||||||
- (instancetype)initWithName:(OFString *)name
|
- (instancetype)initWithName:(OFString *)name
|
||||||
min:(int)min
|
min:(int)min
|
||||||
max:(int)max
|
max:(int)max
|
||||||
storage:(int *)storage
|
storage:(int *)storage
|
||||||
function:(void (*_Nullable)())function
|
function:(void (*_Nullable)())function
|
||||||
persisted:(bool)persisted;
|
persisted:(bool)persisted OF_DESIGNATED_INITIALIZER
|
||||||
- (void)printValue;
|
OF_DIRECT;
|
||||||
- (void)setValue:(int)value;
|
- (void)printValue OF_DIRECT;
|
||||||
|
- (void)setValue:(int)value OF_DIRECT;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -86,13 +86,14 @@ extern int democlientnum;
|
||||||
void
|
void
|
||||||
renderclients()
|
renderclients()
|
||||||
{
|
{
|
||||||
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
[players
|
||||||
if (player != [OFNull null] &&
|
enumerateObjectsUsingBlock:^(Player *player, size_t i, bool *stop) {
|
||||||
(!demoplayback || i != democlientnum))
|
if ([player isKindOfClass:Player.class] &&
|
||||||
renderclient(player,
|
(!demoplayback || i != democlientnum))
|
||||||
isteam(Player.player1.team, [player team]),
|
renderclient(player,
|
||||||
@"monster/ogro", false, 1.0f);
|
isteam(Player.player1.team, [player team]),
|
||||||
}];
|
@"monster/ogro", false, 1.0f);
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
// creation of scoreboard pseudo-menu
|
// creation of scoreboard pseudo-menu
|
||||||
|
|
|
@ -417,9 +417,9 @@ startmap(OFString *name) // called just after a map load
|
||||||
spawncycle = -1;
|
spawncycle = -1;
|
||||||
spawnplayer(Player.player1);
|
spawnplayer(Player.player1);
|
||||||
Player.player1.frags = 0;
|
Player.player1.frags = 0;
|
||||||
for (id player in players)
|
for (Player *player in players)
|
||||||
if (player != [OFNull null])
|
if ([player isKindOfClass:Player.class])
|
||||||
[player setFrags:0];
|
player.frags = 0;
|
||||||
resetspawns();
|
resetspawns();
|
||||||
clientmap = name;
|
clientmap = name;
|
||||||
if (editmode)
|
if (editmode)
|
||||||
|
|
|
@ -279,7 +279,8 @@ localservertoclient(unsigned char *buf, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
case SV_FRAGS:
|
case SV_FRAGS:
|
||||||
[players[cn] setFrags:getint(&p)];
|
OFAssert([players[cn] isKindOfClass:Player.class]);
|
||||||
|
((Player *)players[cn]).frags = getint(&p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SV_ITEMPICKUP:
|
case SV_ITEMPICKUP:
|
||||||
|
@ -371,7 +372,8 @@ localservertoclient(unsigned char *buf, int len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SV_CLIENTPING:
|
case SV_CLIENTPING:
|
||||||
[players[cn] setPing:getint(&p)];
|
OFAssert([players[cn] isKindOfClass:Player.class]);
|
||||||
|
((Player *)players[cn]).ping = getint(&p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SV_GAMEMODE:
|
case SV_GAMEMODE:
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
@class Entity;
|
@class Entity;
|
||||||
@class Player;
|
@class Player;
|
||||||
|
|
||||||
|
OF_DIRECT_MEMBERS
|
||||||
@interface Cube: OFObject <OFApplicationDelegate>
|
@interface Cube: OFObject <OFApplicationDelegate>
|
||||||
@property (class, readonly, nonatomic) Cube *sharedInstance;
|
@property (class, readonly, nonatomic) Cube *sharedInstance;
|
||||||
@property (readonly, nonatomic) SDL_Window *window;
|
@property (readonly, nonatomic) SDL_Window *window;
|
||||||
|
|
|
@ -70,6 +70,7 @@ executable('client',
|
||||||
executable('server',
|
executable('server',
|
||||||
[
|
[
|
||||||
'Client.m',
|
'Client.m',
|
||||||
|
'Entity.m',
|
||||||
'ServerEntity.m',
|
'ServerEntity.m',
|
||||||
'server.m',
|
'server.m',
|
||||||
'serverms.m',
|
'serverms.m',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue