Fix all warnings
FossilOrigin-Name: 0e7605d101d4079a75f8b62b072f342cb5ce5ff95090cf2068318193de907e2c
This commit is contained in:
parent
fd09d38b8c
commit
ff6912e3ff
12 changed files with 51 additions and 58 deletions
13
src/Entity.h
13
src/Entity.h
|
@ -1,5 +1,12 @@
|
|||
#import "PersistentEntity.h"
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
@interface Entity: PersistentEntity
|
||||
@property (nonatomic) bool spawned; // the only dynamic state of a map entity
|
||||
// map entity
|
||||
@interface Entity: OFObject
|
||||
@property (nonatomic) short x, y, z; // cube aligned position
|
||||
@property (nonatomic) short attr1;
|
||||
@property (nonatomic) unsigned char type; // type is one of the above
|
||||
@property (nonatomic) unsigned char attr2, attr3, attr4;
|
||||
@property (nonatomic) bool spawned;
|
||||
|
||||
+ (instancetype)entity;
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#import "Entity.h"
|
||||
|
||||
@implementation Entity
|
||||
+ (instancetype)entity
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
// map entity
|
||||
@interface PersistentEntity: OFObject
|
||||
@property (nonatomic) short x, y, z; // cube aligned position
|
||||
@property (nonatomic) short attr1;
|
||||
@property (nonatomic) unsigned char type; // type is one of the above
|
||||
@property (nonatomic) unsigned char attr2, attr3, attr4;
|
||||
|
||||
+ (instancetype)entity;
|
||||
@end
|
|
@ -1,8 +0,0 @@
|
|||
#import "PersistentEntity.h"
|
||||
|
||||
@implementation PersistentEntity
|
||||
+ (instancetype)entity
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
@end
|
|
@ -22,7 +22,8 @@ renderclient(
|
|||
int n = 3;
|
||||
float speed = 100.0f;
|
||||
float mz = d.o.z - d.eyeheight + 1.55f * scale;
|
||||
int basetime = -((intptr_t)d & 0xFFF);
|
||||
intptr_t tmp = (intptr_t)d;
|
||||
int basetime = -(tmp & 0xFFF);
|
||||
if (d.state == CS_DEAD) {
|
||||
int r;
|
||||
if (hellpig) {
|
||||
|
|
|
@ -372,27 +372,29 @@ void
|
|||
gets2c() // get updates from the server
|
||||
{
|
||||
ENetEvent event;
|
||||
|
||||
if (!clienthost)
|
||||
return;
|
||||
|
||||
if (connecting && lastmillis / 3000 > connecting / 3000) {
|
||||
conoutf(@"attempting to connect...");
|
||||
connecting = lastmillis;
|
||||
++connattempts;
|
||||
if (connattempts > 3) {
|
||||
|
||||
if (++connattempts > 3) {
|
||||
conoutf(@"could not connect to server");
|
||||
disconnect(false, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (
|
||||
clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
|
||||
|
||||
while (clienthost != NULL &&
|
||||
enet_host_service(clienthost, &event, 0) > 0) {
|
||||
switch (event.type) {
|
||||
case ENET_EVENT_TYPE_CONNECT:
|
||||
conoutf(@"connected to server");
|
||||
connecting = 0;
|
||||
throttle();
|
||||
break;
|
||||
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
if (disconnecting)
|
||||
conoutf(@"attempting to disconnect...");
|
||||
|
@ -401,12 +403,14 @@ gets2c() // get updates from the server
|
|||
event.packet->dataLength);
|
||||
enet_packet_destroy(event.packet);
|
||||
break;
|
||||
|
||||
case ENET_EVENT_TYPE_DISCONNECT:
|
||||
if (disconnecting)
|
||||
disconnect(false, false);
|
||||
else
|
||||
server_err();
|
||||
return;
|
||||
case ENET_EVENT_TYPE_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ edittype(int type)
|
|||
{
|
||||
EDITSEL;
|
||||
if (type == CORNER &&
|
||||
(sel.xs != sel.ys || sel.xs == 3 || sel.xs > 4 && sel.xs != 8 ||
|
||||
(sel.xs != sel.ys || sel.xs == 3 || (sel.xs > 4 && sel.xs != 8) ||
|
||||
sel.x & ~-sel.xs || sel.y & ~-sel.ys)) {
|
||||
conoutf(@"corner selection must be power of 2 aligned");
|
||||
return;
|
||||
|
|
|
@ -14,7 +14,6 @@ executable('client',
|
|||
'Menu.m',
|
||||
'MenuItem.m',
|
||||
'OFString+Cube.m',
|
||||
'PersistentEntity.m',
|
||||
'Projectile.m',
|
||||
'ResolverResult.m',
|
||||
'ResolverThread.m',
|
||||
|
|
|
@ -113,46 +113,46 @@ collide(DynamicEntity *d, bool spawn, float drop, float rise)
|
|||
struct sqr *s = S(x, y);
|
||||
float ceil = s->ceil;
|
||||
float floor = s->floor;
|
||||
|
||||
switch (s->type) {
|
||||
case SOLID:
|
||||
return false;
|
||||
|
||||
case CORNER: {
|
||||
int bx = x, by = y, bs = 1;
|
||||
if (x == x1 && y == y1 &&
|
||||
if ((x == x1 && y == y1 &&
|
||||
cornertest(
|
||||
0, x, y, -1, -1, &bx, &by, &bs) &&
|
||||
fx1 - bx + fy1 - by <= bs ||
|
||||
x == x2 && y == y1 &&
|
||||
fx1 - bx + fy1 - by <= bs) ||
|
||||
(x == x2 && y == y1 &&
|
||||
cornertest(
|
||||
0, x, y, 1, -1, &bx, &by, &bs) &&
|
||||
fx2 - bx >= fy1 - by ||
|
||||
x == x1 && y == y2 &&
|
||||
fx2 - bx >= fy1 - by) ||
|
||||
(x == x1 && y == y2 &&
|
||||
cornertest(
|
||||
0, x, y, -1, 1, &bx, &by, &bs) &&
|
||||
fx1 - bx <= fy2 - by ||
|
||||
x == x2 && y == y2 &&
|
||||
fx1 - bx <= fy2 - by) ||
|
||||
(x == x2 && y == y2 &&
|
||||
cornertest(
|
||||
0, x, y, 1, 1, &bx, &by, &bs) &&
|
||||
fx2 - bx + fy2 - by >= bs)
|
||||
fx2 - bx + fy2 - by >= bs))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
case FHF: // FIXME: too simplistic collision with
|
||||
// slopes, makes it feels like tiny stairs
|
||||
// FIXME: too simplistic collision with slopes, makes
|
||||
// it feels like tiny stairs
|
||||
case FHF:
|
||||
floor -= (s->vdelta + S(x + 1, y)->vdelta +
|
||||
S(x, y + 1)->vdelta +
|
||||
S(x + 1, y + 1)->vdelta) /
|
||||
16.0f;
|
||||
break;
|
||||
|
||||
case CHF:
|
||||
ceil += (s->vdelta + S(x + 1, y)->vdelta +
|
||||
S(x, y + 1)->vdelta +
|
||||
S(x + 1, y + 1)->vdelta) /
|
||||
16.0f;
|
||||
}
|
||||
|
||||
if (ceil < hi)
|
||||
hi = ceil;
|
||||
if (floor > lo)
|
||||
|
|
|
@ -483,7 +483,6 @@ serverslice(int seconds,
|
|||
if (event.packet->referenceCount == 0)
|
||||
enet_packet_destroy(event.packet);
|
||||
break;
|
||||
|
||||
case ENET_EVENT_TYPE_DISCONNECT:
|
||||
if ((intptr_t)event.peer->data < 0)
|
||||
break;
|
||||
|
@ -493,6 +492,8 @@ serverslice(int seconds,
|
|||
send2(true, -1, SV_CDIS, (intptr_t)event.peer->data);
|
||||
event.peer->data = (void *)-1;
|
||||
break;
|
||||
case ENET_EVENT_TYPE_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
if (numplayers > maxclients)
|
||||
|
|
|
@ -129,10 +129,9 @@ remip(const struct block *b, int level)
|
|||
r->type = SEMISOLID;
|
||||
loopk(MAXTYPE) if (nums[k] == 4) r->type = k;
|
||||
if (!SOLID(r)) {
|
||||
int floor = 127, ceil = -128, num = 0;
|
||||
int floor = 127, ceil = -128;
|
||||
loopi(4) if (!SOLID(o[i]))
|
||||
{
|
||||
num++;
|
||||
int fh = o[i]->floor;
|
||||
int ch = o[i]->ceil;
|
||||
if (r->type == SEMISOLID) {
|
||||
|
@ -332,7 +331,7 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
|
|||
{
|
||||
int type = findtype(what);
|
||||
|
||||
PersistentEntity *e = [PersistentEntity entity];
|
||||
Entity *e = [Entity entity];
|
||||
e.x = x;
|
||||
e.y = y;
|
||||
e.z = z;
|
||||
|
@ -351,7 +350,6 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
|
|||
if (!v2 && !v3 && !v4)
|
||||
e.attr2 = 255;
|
||||
break;
|
||||
|
||||
case MAPMODEL:
|
||||
e.attr4 = e.attr3;
|
||||
e.attr3 = e.attr2;
|
||||
|
@ -365,7 +363,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]; // unsafe!
|
||||
[ents addObject:e];
|
||||
|
||||
if (type == LIGHT)
|
||||
calclight();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#import "DynamicEntity.h"
|
||||
#import "Entity.h"
|
||||
#import "PersistentEntity.h"
|
||||
|
||||
extern bool hasoverbright;
|
||||
|
||||
|
@ -12,7 +11,7 @@ VAR(lightscale, 1, 4, 100);
|
|||
|
||||
// done in realtime, needs to be fast
|
||||
void
|
||||
lightray(float bx, float by, PersistentEntity *light)
|
||||
lightray(float bx, float by, Entity *light)
|
||||
{
|
||||
float lx = light.x + (rnd(21) - 10) * 0.1f;
|
||||
float ly = light.y + (rnd(21) - 10) * 0.1f;
|
||||
|
@ -39,10 +38,9 @@ lightray(float bx, float by, PersistentEntity *light)
|
|||
l /= lightscale;
|
||||
stepl /= lightscale;
|
||||
|
||||
if (light.attr3 ||
|
||||
light.attr4) // coloured light version, special case because
|
||||
// most lights are white
|
||||
{
|
||||
// coloured light version, special case because most lights are
|
||||
// white
|
||||
if (light.attr3 || light.attr4) {
|
||||
int dimness = rnd(
|
||||
(255 -
|
||||
(light.attr2 + light.attr3 + light.attr4) / 3) /
|
||||
|
@ -123,7 +121,7 @@ lightray(float bx, float by, PersistentEntity *light)
|
|||
}
|
||||
|
||||
void
|
||||
calclightsource(PersistentEntity *l)
|
||||
calclightsource(Entity *l)
|
||||
{
|
||||
int reach = l.attr1;
|
||||
int sx = l.x - reach;
|
||||
|
@ -235,7 +233,7 @@ dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength,
|
|||
struct block *copy = blockcopy(&b);
|
||||
[dlights addItem:©];
|
||||
|
||||
PersistentEntity *l = [Entity entity];
|
||||
Entity *l = [Entity entity];
|
||||
l.x = v->x;
|
||||
l.y = v->y;
|
||||
l.z = v->z;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue