Index: src/Entity.h ================================================================== --- src/Entity.h +++ src/Entity.h @@ -1,5 +1,12 @@ -#import "PersistentEntity.h" +#import + +// 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; -@interface Entity: PersistentEntity -@property (nonatomic) bool spawned; // the only dynamic state of a map entity ++ (instancetype)entity; @end Index: src/Entity.m ================================================================== --- src/Entity.m +++ src/Entity.m @@ -1,4 +1,8 @@ #import "Entity.h" @implementation Entity ++ (instancetype)entity +{ + return [[self alloc] init]; +} @end DELETED src/PersistentEntity.h Index: src/PersistentEntity.h ================================================================== --- src/PersistentEntity.h +++ /dev/null @@ -1,11 +0,0 @@ -#import - -// 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 DELETED src/PersistentEntity.m Index: src/PersistentEntity.m ================================================================== --- src/PersistentEntity.m +++ /dev/null @@ -1,8 +0,0 @@ -#import "PersistentEntity.h" - -@implementation PersistentEntity -+ (instancetype)entity -{ - return [[self alloc] init]; -} -@end Index: src/clientextras.m ================================================================== --- src/clientextras.m +++ src/clientextras.m @@ -20,11 +20,12 @@ DynamicEntity *d, bool team, OFString *mdlname, bool hellpig, float scale) { 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) { n = 2; r = range[3]; Index: src/clients.m ================================================================== --- src/clients.m +++ src/clients.m @@ -370,43 +370,47 @@ 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..."); else localservertoclient(event.packet->data, 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; } + } } Index: src/editing.m ================================================================== --- src/editing.m +++ src/editing.m @@ -452,11 +452,11 @@ void 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; } edittypexy(type, &sel); Index: src/meson.build ================================================================== --- src/meson.build +++ src/meson.build @@ -12,11 +12,10 @@ 'MD2.m', 'MapModelInfo.m', 'Menu.m', 'MenuItem.m', 'OFString+Cube.m', - 'PersistentEntity.m', 'Projectile.m', 'ResolverResult.m', 'ResolverThread.m', 'ServerEntity.m', 'ServerInfo.m', Index: src/physics.m ================================================================== --- src/physics.m +++ src/physics.m @@ -111,50 +111,50 @@ if (OUTBORD(x, y)) return false; 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) lo = floor; if (floor < minfloor) Index: src/server.m ================================================================== --- src/server.m +++ src/server.m @@ -481,19 +481,20 @@ brec += event.packet->dataLength; process(event.packet, (intptr_t)event.peer->data); if (event.packet->referenceCount == 0) enet_packet_destroy(event.packet); break; - case ENET_EVENT_TYPE_DISCONNECT: if ((intptr_t)event.peer->data < 0) break; [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); event.peer->data = (void *)-1; + break; + case ENET_EVENT_TYPE_NONE: break; } if (numplayers > maxclients) disconnect_client(lastconnect, @"maxclients reached"); Index: src/world.m ================================================================== --- src/world.m +++ src/world.m @@ -127,14 +127,13 @@ // cube contains both solid and space, treated // specially in the renderer 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) { if (o[i]->type == FHF) // crap hack, needed @@ -330,11 +329,11 @@ Entity * 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; e.attr1 = v1; e.type = type; @@ -349,11 +348,10 @@ if (!v1) e.attr1 = 16; if (!v2 && !v3 && !v4) e.attr2 = 255; break; - case MAPMODEL: e.attr4 = e.attr3; e.attr3 = e.attr2; case MONSTER: case TELEDEST: @@ -363,11 +361,11 @@ break; } 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(); return e; Index: src/worldlight.m ================================================================== --- src/worldlight.m +++ src/worldlight.m @@ -2,19 +2,18 @@ #include "cube.h" #import "DynamicEntity.h" #import "Entity.h" -#import "PersistentEntity.h" extern bool hasoverbright; 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; float dx = bx - lx; float dy = by - ly; @@ -37,14 +36,13 @@ if (hasoverbright) { 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) / 16 + 1); @@ -121,11 +119,11 @@ } } } void -calclightsource(PersistentEntity *l) +calclightsource(Entity *l) { int reach = l.attr1; int sx = l.x - reach; int ex = l.x + reach; int sy = l.y - reach; @@ -233,11 +231,11 @@ // backup area before rendering in dynlight 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; l.attr1 = reach; l.type = LIGHT;