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