Index: src/.clang-format ================================================================== --- src/.clang-format +++ src/.clang-format @@ -19,10 +19,12 @@ BeforeElse: false AlwaysBreakAfterReturnType: AllDefinitions AlignAfterOpenBracket: DontAlign AlignEscapedNewlines: Left AlignOperands: DontAlign +Cpp11BracedListStyle: false +SpaceBeforeCpp11BracedList: true ObjCBlockIndentWidth: 8 ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true ObjCPropertyAttributeOrder: [ class, direct, @@ -32,11 +34,12 @@ atomic, nonatomic, getter, setter ] SpaceBeforeInheritanceColon: false QualifierAlignment: Left +MaxEmptyLinesToKeep: 1 #RemoveEmptyLinesInUnwrappedLines: true RemoveSemicolon: true CompactNamespaces: true SortIncludes: CaseSensitive IndentPPDirectives: AfterHash PPIndentWidth: 1 Index: src/Cube.mm ================================================================== --- src/Cube.mm +++ src/Cube.mm @@ -27,19 +27,22 @@ processInitQueue(); #define log(s) conoutf(@"init: %@", s) log(@"sdl"); - const OFOptionsParserOption options[] = { - {'d', @"dedicated", 0, &dedicated, NULL}, - {'t', @"window", 0, &windowed, NULL}, - {'w', @"width", 1, NULL, NULL}, {'h', @"height", 1, NULL, NULL}, - {'u', @"upload-rate", 1, NULL, NULL}, - {'n', @"server-desc", 1, NULL, &sdesc}, {'i', @"ip", 1, NULL, &ip}, - {'m', @"master", 1, NULL, &master}, - {'p', @"password", 1, NULL, &passwd}, - {'c', @"max-clients", 1, NULL, NULL}, {'\0', nil, 0, NULL, NULL}}; + const OFOptionsParserOption options[] = { { 'd', @"dedicated", 0, + &dedicated, NULL }, + { 't', @"window", 0, &windowed, NULL }, + { 'w', @"width", 1, NULL, NULL }, + { 'h', @"height", 1, NULL, NULL }, + { 'u', @"upload-rate", 1, NULL, NULL }, + { 'n', @"server-desc", 1, NULL, &sdesc }, + { 'i', @"ip", 1, NULL, &ip }, + { 'm', @"master", 1, NULL, &master }, + { 'p', @"password", 1, NULL, &passwd }, + { 'c', @"max-clients", 1, NULL, NULL }, + { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions:options]; OFUnichar option; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { Index: src/client.mm ================================================================== --- src/client.mm +++ src/client.mm @@ -88,11 +88,11 @@ { disconnect(1); // reset state addserver(servername); conoutf(@"attempting to connect to %@", servername); - ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT}; + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT }; @autoreleasepool { if (enet_address_set_host(&address, servername.UTF8String) < 0) { conoutf(@"could not resolve server %@", servername); return; @@ -118,18 +118,18 @@ if (clienthost) { if (!connecting && !disconnecting) { enet_peer_disconnect(clienthost->peers); enet_host_flush(clienthost); disconnecting = lastmillis; - }; + } if (clienthost->peers->state != ENET_PEER_STATE_DISCONNECTED) { if (async) return; enet_peer_reset(clienthost->peers); - }; + } enet_host_destroy(clienthost); - }; + } if (clienthost && !connecting) conoutf(@"disconnected"); clienthost = NULL; connecting = 0; @@ -383,12 +383,12 @@ ++connattempts; if (connattempts > 3) { conoutf(@"could not connect to server"); disconnect(); return; - }; - }; + } + } while ( clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0) switch (event.type) { case ENET_EVENT_TYPE_CONNECT: conoutf(@"connected to server"); Index: src/clientextras.mm ================================================================== --- src/clientextras.mm +++ src/clientextras.mm @@ -6,13 +6,14 @@ // very messy ad-hoc handling of animation frames, should be made more // configurable // D D D D' D D D D' A A' P P' I I' // R, R' E L J J' -int frame[] = {178, 184, 190, 137, 183, 189, 197, 164, 46, 51, 54, 32, 0, 0, 40, - 1, 162, 162, 67, 168}; -int range[] = {6, 6, 8, 28, 1, 1, 1, 1, 8, 19, 4, 18, 40, 1, 6, 15, 1, 1, 1, 1}; +int frame[] = { 178, 184, 190, 137, 183, 189, 197, 164, 46, 51, 54, 32, 0, 0, + 40, 1, 162, 162, 67, 168 }; +int range[] = { 6, 6, 8, 28, 1, 1, 1, 1, 8, 19, 4, 18, 40, 1, 6, 15, 1, 1, 1, + 1 }; void renderclient(dynent *d, bool team, OFString *mdlname, bool hellpig, float scale) { int n = 3; @@ -35,12 +36,12 @@ if (t > (r - 1) * 100) { n += 4; if (t > (r + 10) * 100) { t -= (r + 10) * 100; mz -= t * t / 10000000000.0f * t; - }; - }; + } + } if (mz < -1000) return; // mdl = (((int)d>>6)&1)+1; // mz = d->o.z-d->eyeheight+0.2f; // scale = 1.2f; Index: src/clientgame.mm ================================================================== --- src/clientgame.mm +++ src/clientgame.mm @@ -68,35 +68,35 @@ d->ammo[GUN_RIFLE] = 100; } else { if (gamemode == 12) { d->gunselect = GUN_FIST; return; - }; // eihrul's secret "instafist" mode + } // eihrul's secret "instafist" mode d->health = 256; if (m_tarena) { int gun1 = rnd(4) + 1; baseammo(d->gunselect = gun1); for (;;) { int gun2 = rnd(4) + 1; if (gun1 != gun2) { baseammo(gun2); break; - }; - }; + } + } } else if (m_arena) // insta arena { d->ammo[GUN_RIFLE] = 100; } else // efficiency { loopi(4) baseammo(i + 1); d->gunselect = GUN_CG; - }; + } d->ammo[GUN_CG] /= 2; - }; + } } else { d->ammo[GUN_SG] = 5; - }; + } } dynent * newdynent() // create a new blank player or monster { @@ -142,11 +142,11 @@ if (lastteam && strcmp(lastteam, d->team)) oneteam = false; lastteam = d->team; } else { dead++; - }; + } } int arenarespawnwait = 0; int arenadetectwait = 0; @@ -176,12 +176,12 @@ else conoutf(@"everyone died!"); arenarespawnwait = lastmillis + 5000; arenadetectwait = lastmillis + 10000; player1->roll = 0; - }; - }; + } + } } void zapdynent(dynent *&d) { @@ -199,11 +199,11 @@ { const int lagtime = lastmillis - players[i]->lastupdate; if (lagtime > 1000 && players[i]->state == CS_ALIVE) { players[i]->state = CS_LAGGED; continue; - }; + } if (lagtime && players[i]->state != CS_DEAD && (!demoplayback || i != democlientnum)) moveplayer( players[i], 2, false); // use physics to extrapolate // player position @@ -271,11 +271,11 @@ lastmillis - player1->lastaction > 10000) respawn(); } else if (!intermission) { moveplayer(player1, 20, true); checkitems(); - }; + } c2sinfo(player1); // do this last, to reduce the // effective frame lag } } lastmillis = millis; @@ -317,11 +317,11 @@ d->pitch = 0; d->roll = 0; } else { d->o.x = d->o.y = (float)ssize / 2; d->o.z = 4; - }; + } entinmap(d); spawnstate(d); d->state = CS_ALIVE; } Index: src/clients2c.mm ================================================================== --- src/clients2c.mm +++ src/clients2c.mm @@ -44,16 +44,16 @@ if (fx < r && fy < r && fz < rz && d->state != CS_DEAD) { if (fx < fy) d->o.y += dy < 0 ? r - fy : -(r - fy); // push aside else d->o.x += dx < 0 ? r - fx : -(r - fx); - }; + } int lagtime = lastmillis - d->lastupdate; if (lagtime) { d->plag = (d->plag * 5 + lagtime) / 6; d->lastupdate = lastmillis; - }; + } } void localservertoclient( uchar *buf, int len) // processes any updates from the server @@ -299,11 +299,11 @@ int x = getint(p); int y = getint(p); int xs = getint(p); int ys = getint(p); int v = getint(p); - block b = {x, y, xs, ys}; + block b = { x, y, xs, ys }; switch (type) { case SV_EDITH: editheightxy(v != 0, getint(p), b); break; case SV_EDITT: Index: src/editing.mm ================================================================== --- src/editing.mm +++ src/editing.mm @@ -12,15 +12,15 @@ block sel; OF_CONSTRUCTOR() { enqueueInit(^{ - sel = (block){ - variable(@"selx", 0, 0, 4096, &sel.x, NULL, false), - variable(@"sely", 0, 0, 4096, &sel.y, NULL, false), - variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false), - variable(@"selys", 0, 0, 4096, &sel.ys, NULL, false), + sel = (block) { + variable(@"selx", 0, 0, 4096, &sel.x, NULL, false), + variable(@"sely", 0, 0, 4096, &sel.y, NULL, false), + variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false), + variable(@"selys", 0, 0, 4096, &sel.ys, NULL, false), }; }); } int selh = 0; @@ -37,11 +37,11 @@ remip(sel); \ } int cx, cy, ch; -int curedittex[] = {-1, -1, -1}; +int curedittex[] = { -1, -1, -1 }; bool dragging = false; int lastx, lasty, lasth; int lasttype = 0, lasttex = 0; @@ -116,21 +116,21 @@ return; void selectpos(int x, int y, int xs, int ys) { - block s = {x, y, xs, ys}; + block s = { x, y, xs, ys }; sel = s; selh = 0; correctsel(); } void makesel() { - block s = {min(lastx, cx), min(lasty, cy), abs(lastx - cx) + 1, - abs(lasty - cy) + 1}; + block s = { min(lastx, cx), min(lasty, cy), abs(lastx - cx) + 1, + abs(lasty - cy) + 1 }; sel = s; selh = max(lasth, ch); correctsel(); if (selset) rtex = *S(sel.x, sel.y); @@ -162,21 +162,21 @@ if (OUTBORD(cx, cy)) return; sqr *s = S(cx, cy); - if (fabs(sheight(s, s, z) - z) > 1) // selected wall - { + // selected wall + if (fabs(sheight(s, s, z) - z) > 1) { x += x > player1->o.x ? 0.5f : -0.5f; // find right wall cube y += y > player1->o.y ? 0.5f : -0.5f; cx = (int)x; cy = (int)y; if (OUTBORD(cx, cy)) return; - }; + } if (dragging) makesel(); const int GRIDSIZE = 5; @@ -185,11 +185,11 @@ const float GRIDS = 2.0f; const int GRIDM = 0x7; // render editing grid - for (int ix = cx - GRIDSIZE; ix <= cx + GRIDSIZE; ix++) + for (int ix = cx - GRIDSIZE; ix <= cx + GRIDSIZE; ix++) { for (int iy = cy - GRIDSIZE; iy <= cy + GRIDSIZE; iy++) { if (OUTBORD(ix, iy)) continue; sqr *s = S(ix, iy); if (SOLID(s)) @@ -202,11 +202,11 @@ linestyle(GRIDW, 0xFF, 0x40, 0x40); else if (s->type == FHF || s->type == CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80); else linestyle(GRIDW, 0x80, 0x80, 0x80); - block b = {ix, iy, 1, 1}; + block b = { ix, iy, 1, 1 }; box(b, h1, h2, h3, h4); linestyle(GRID8, 0x40, 0x40, 0xFF); if (!(ix & GRIDM)) line(ix, iy, h1, ix, iy + 1, h4); if (!(ix + 1 & GRIDM)) @@ -213,28 +213,29 @@ line(ix + 1, iy, h2, ix + 1, iy + 1, h3); if (!(iy & GRIDM)) line(ix, iy, h1, ix + 1, iy, h2); if (!(iy + 1 & GRIDM)) line(ix, iy + 1, h4, ix + 1, iy + 1, h3); - }; + } + } if (!SOLID(s)) { float ih = sheight(s, s, z); linestyle(GRIDS, 0xFF, 0xFF, 0xFF); - block b = {cx, cy, 1, 1}; + block b = { cx, cy, 1, 1 }; box(b, ih, sheight(s, SWS(s, 1, 0, ssize), z), sheight(s, SWS(s, 1, 1, ssize), z), sheight(s, SWS(s, 0, 1, ssize), z)); linestyle(GRIDS, 0xFF, 0x00, 0x00); dot(cx, cy, ih); ch = (int)ih; - }; + } if (selset) { linestyle(GRIDS, 0xFF, 0x40, 0x40); box(sel, (float)selh, (float)selh, (float)selh, (float)selh); - }; + } } vector undos; // unlimited undo VARP(undomegs, 0, 1, 10); // bounded by n megs @@ -314,11 +315,11 @@ int t = p[c]; for (int a = c - 1; a >= 0; a--) p[a + 1] = p[a]; p[0] = t; curedittex[i] = -1; - }; + } } } void editdrag(bool isdown) @@ -327,11 +328,11 @@ lastx = cx; lasty = cy; lasth = ch; selset = false; tofronttex(); - }; + } makesel(); } // the core editing function. all the *xy functions perform the core operations // and are also called directly from the network, the function below it is @@ -388,11 +389,11 @@ if (type < 0 || type > 3) return; if (type != lasttype) { tofronttex(); lasttype = type; - }; + } int atype = type == 3 ? 1 : type; int i = curedittex[atype]; i = i < 0 ? 0 : i + dir; curedittex[atype] = i = min(max(i, 0), 255); int t = lasttex = hdr.texlists[atype][i]; @@ -422,13 +423,13 @@ break; case 3: if (s->utex == rtex.utex) s->utex = lasttex; break; - }; + } } - block b = {0, 0, ssize, ssize}; + block b = { 0, 0, ssize, ssize }; remip(b); } void edittypexy(int type, block &sel) @@ -524,11 +525,11 @@ archvertex(int span, int vert, int delta) { if (!archvinit) { archvinit = true; loop(s, MAXARCHVERT) loop(v, MAXARCHVERT) archverts[s][v] = 0; - }; + } if (span >= MAXARCHVERT || vert >= MAXARCHVERT || span < 0 || vert < 0) return; archverts[span][vert] = delta; } @@ -585,11 +586,11 @@ VARF( fullbright, 0, 0, 1, if (fullbright) { if (noteditmode()) return; loopi(mipsize) world[i].r = world[i].g = world[i].b = 176; - };); + }); void edittag(int tag) { EDITSELMP; Index: src/entities.mm ================================================================== --- src/entities.mm +++ src/entities.mm @@ -5,20 +5,20 @@ #import "MapModelInfo.h" vector ents; static OFString *entmdlnames[] = { - @"shells", - @"bullets", - @"rockets", - @"rrounds", - @"health", - @"boost", - @"g_armour", - @"y_armour", - @"quad", - @"teleporter", + @"shells", + @"bullets", + @"rockets", + @"rrounds", + @"health", + @"boost", + @"g_armour", + @"y_armour", + @"quad", + @"teleporter", }; int triggertime = 0; void @@ -61,11 +61,11 @@ renderent(e, entmdlnames[e.type - I_SHELLS], (float)(1 + sin(lastmillis / 100.0 + e.x + e.y) / 20), lastmillis / 10.0f); - } else + } else { switch (e.attr2) { case 1: case 3: continue; @@ -97,45 +97,28 @@ : 0, (e.spawned || !triggertime) ? 1 : 30, triggertime, 35.0f); break; - }; - }; + } + } + } } } struct itemstat { int add, max, sound; } itemstats[] = { - 10, - 50, - S_ITEMAMMO, - 20, - 100, - S_ITEMAMMO, - 5, - 25, - S_ITEMAMMO, - 5, - 25, - S_ITEMAMMO, - 25, - 100, - S_ITEMHEALTH, - 50, - 200, - S_ITEMHEALTH, - 100, - 100, - S_ITEMARMOUR, - 150, - 150, - S_ITEMARMOUR, - 20000, - 30000, - S_ITEMPUP, + { 10, 50, S_ITEMAMMO }, + { 20, 100, S_ITEMAMMO }, + { 5, 25, S_ITEMAMMO }, + { 5, 25, S_ITEMAMMO }, + { 25, 100, S_ITEMHEALTH }, + { 50, 200, S_ITEMHEALTH }, + { 100, 100, S_ITEMARMOUR }, + { 150, 150, S_ITEMARMOUR }, + { 20000, 30000, S_ITEMPUP }, }; void baseammo(int gun) { @@ -231,12 +214,12 @@ d->pitch = 0; d->vel.x = d->vel.y = d->vel.z = 0; entinmap(d); playsoundc(S_TELEPORT); break; - }; - }; + } + } } void pickup(int n, dynent *d) { @@ -292,11 +275,11 @@ if (lastmillis - lastteleport < 500) break; lastteleport = lastmillis; teleport(n, d); break; - }; + } case JUMPPAD: { static int lastjumppad = 0; if (lastmillis - lastjumppad < 300) break; Index: src/monster.mm ================================================================== --- src/monster.mm +++ src/monster.mm @@ -29,26 +29,26 @@ short painsound, diesound; OFConstantString *name, *mdlname; } monstertypes[NUMMONSTERTYPES] = { - {GUN_FIREBALL, 15, 100, 3, 0, 100, 800, 1, 10, 10, S_PAINO, S_DIE1, - @"an ogre", @"monster/ogro"}, - {GUN_CG, 18, 70, 2, 70, 10, 400, 2, 8, 9, S_PAINR, S_DEATHR, @"a rhino", - @"monster/rhino"}, - {GUN_SG, 14, 120, 1, 100, 300, 400, 4, 14, 14, S_PAINE, S_DEATHE, - @"ratamahatta", @"monster/rat"}, - {GUN_RIFLE, 15, 200, 1, 80, 300, 300, 4, 18, 18, S_PAINS, S_DEATHS, - @"a slith", @"monster/slith"}, - {GUN_RL, 13, 500, 1, 0, 100, 200, 6, 24, 24, S_PAINB, S_DEATHB, @"bauul", - @"monster/bauul"}, - {GUN_BITE, 22, 50, 3, 0, 100, 400, 1, 12, 15, S_PAINP, S_PIGGR2, - @"a hellpig", @"monster/hellpig"}, - {GUN_ICEBALL, 12, 250, 1, 0, 10, 400, 6, 18, 18, S_PAINH, S_DEATHH, - @"a knight", @"monster/knight"}, - {GUN_SLIMEBALL, 15, 100, 1, 0, 200, 400, 2, 13, 10, S_PAIND, S_DEATHD, - @"a goblin", @"monster/goblin"}, + { GUN_FIREBALL, 15, 100, 3, 0, 100, 800, 1, 10, 10, S_PAINO, S_DIE1, + @"an ogre", @"monster/ogro" }, + { GUN_CG, 18, 70, 2, 70, 10, 400, 2, 8, 9, S_PAINR, S_DEATHR, + @"a rhino", @"monster/rhino" }, + { GUN_SG, 14, 120, 1, 100, 300, 400, 4, 14, 14, S_PAINE, S_DEATHE, + @"ratamahatta", @"monster/rat" }, + { GUN_RIFLE, 15, 200, 1, 80, 300, 300, 4, 18, 18, S_PAINS, S_DEATHS, + @"a slith", @"monster/slith" }, + { GUN_RL, 13, 500, 1, 0, 100, 200, 6, 24, 24, S_PAINB, S_DEATHB, + @"bauul", @"monster/bauul" }, + { GUN_BITE, 22, 50, 3, 0, 100, 400, 1, 12, 15, S_PAINP, S_PIGGR2, + @"a hellpig", @"monster/hellpig" }, + { GUN_ICEBALL, 12, 250, 1, 0, 10, 400, 6, 18, 18, S_PAINH, S_DEATHH, + @"a knight", @"monster/knight" }, + { GUN_SLIMEBALL, 15, 100, 1, 0, 200, 400, 2, 13, 10, S_PAIND, S_DEATHD, + @"a goblin", @"monster/goblin" }, }; dynent * basicmonster(int type, int yaw, int state, int trigger, int move) { @@ -88,15 +88,16 @@ void spawnmonster() // spawn a random monster according to freq distribution in DMSP { int n = rnd(TOTMFREQ), type; - for (int i = 0;; i++) + for (int i = 0;; i++) { if ((n -= monstertypes[i].freq) < 0) { type = i; break; - }; + } + } basicmonster(type, rnd(360), M_SEARCH, 1000, 1); } void monsterclear() // called after map start of when toggling edit mode to @@ -120,11 +121,11 @@ m->o.y = ents[i].y; m->o.z = ents[i].z; entinmap(m); monstertotal++; } - }; + } } bool los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D &v) // height-correct line of sight for monster shooting/seeing @@ -156,11 +157,11 @@ v.y = y; v.z = rz; x += dx / (float)steps; y += dy / (float)steps; i++; - }; + } return i >= steps; } bool enemylos(dynent *m, OFVector3D &v) @@ -201,11 +202,11 @@ dynent *m) // main AI thinking routine, called every frame for every monster { if (m->enemy->state == CS_DEAD) { m->enemy = player1; m->anger = 0; - }; + } normalise(m, m->targetyaw); if (m->targetyaw > m->yaw) // slowly turn monster towards his target { m->yaw += curtime * 0.5f; if (m->targetyaw < m->yaw) @@ -212,33 +213,29 @@ m->yaw = m->targetyaw; } else { m->yaw -= curtime * 0.5f; if (m->targetyaw > m->yaw) m->yaw = m->targetyaw; - }; + } vdist(disttoenemy, vectoenemy, m->o, m->enemy->o); m->pitch = atan2(m->enemy->o.z - m->o.z, disttoenemy) * 180 / PI; - if (m->blocked) // special case: if we run into scenery - { + // special case: if we run into scenery + if (m->blocked) { m->blocked = false; - if (!rnd(20000 / - monstertypes[m->mtype] - .speed)) // try to jump over obstackle (rare) - { + // try to jump over obstackle (rare) + if (!rnd(20000 / monstertypes[m->mtype].speed)) m->jumpnext = true; - } else if (m->trigger < lastmillis && - (m->monsterstate != M_HOME || - !rnd(5))) // search for a way around (common) - { - m->targetyaw += - 180 + rnd(180); // patented "random walk" AI - // pathfinding (tm) ;) + // search for a way around (common) + else if (m->trigger < lastmillis && + (m->monsterstate != M_HOME || !rnd(5))) { + // patented "random walk" AI pathfinding (tm) ;) + m->targetyaw += 180 + rnd(180); transition(m, M_SEARCH, 1, 400, 1000); - }; - }; + } + } float enemyyaw = -(float)atan2(m->enemy->o.x - m->o.x, m->enemy->o.y - m->o.y) / PI * 180 + 180; @@ -264,22 +261,22 @@ || (disttoenemy < 16 && angle < 135) || (disttoenemy < 32 && angle < 90) || (disttoenemy < 64 && angle < 45) || angle < 10) { transition(m, M_HOME, 1, 500, 200); playsound(S_GRUNT1 + rnd(2), &m->o); - }; + } break; - }; + } case M_AIMING: // this state is the delay between wanting to shoot and // actually firing if (m->trigger < lastmillis) { m->lastaction = 0; m->attacking = true; shoot(m, m->attacktarget); transition(m, M_ATTACKING, 0, 600, 0); - }; + } break; case M_HOME: // monster has visual contact, heads straight for player // and may want to shoot at any time m->targetyaw = enemyyaw; @@ -303,52 +300,52 @@ monstertypes[m->mtype].lag, 10); } else // track player some more { transition(m, M_HOME, 1, monstertypes[m->mtype].rate, 0); - }; - }; - }; + } + } + } break; - }; + } moveplayer(m, 1, false); // use physics to move monster } void monsterpain(dynent *m, int damage, dynent *d) { - if (d->monsterstate) // a monster hit us - { - if (m != d) // guard for RL guys shooting themselves :) - { - m->anger++; // don't attack straight away, first get - // angry + // a monster hit us + if (d->monsterstate) { + // guard for RL guys shooting themselves :) + if (m != d) { + // don't attack straight away, first get angry + m->anger++; int anger = m->mtype == d->mtype ? m->anger / 2 : m->anger; if (anger >= monstertypes[m->mtype].loyalty) - m->enemy = d; // monster infight if very angry - }; - } else // player hit us - { + // monster infight if very angry + m->enemy = d; + } + } else { + // player hit us m->anger = 0; m->enemy = d; - }; - transition(m, M_PAIN, 0, monstertypes[m->mtype].pain, - 200); // in this state monster won't attack + } + // in this state monster won't attack + transition(m, M_PAIN, 0, monstertypes[m->mtype].pain, 200); if ((m->health -= damage) <= 0) { m->state = CS_DEAD; m->lastaction = lastmillis; numkilled++; player1->frags = numkilled; playsound(monstertypes[m->mtype].diesound, &m->o); int remain = monstertotal - numkilled; if (remain > 0 && remain <= 5) conoutf(@"only %d monster(s) remaining", remain); - } else { + } else playsound(monstertypes[m->mtype].painsound, &m->o); - } } void endsp(bool allkilled) { @@ -366,11 +363,11 @@ if (m_dmsp && spawnremain && lastmillis > nextmonster) { if (spawnremain-- == monstertotal) conoutf(@"The invasion has begun!"); nextmonster = lastmillis + 1000; spawnmonster(); - }; + } if (monstertotal && !spawnremain && numkilled == monstertotal) endsp(true); loopv(ents) // equivalent of player entity touch, but only teleports are @@ -381,24 +378,26 @@ continue; if (OUTBORD(e.x, e.y)) continue; OFVector3D v = OFMakeVector3D(e.x, e.y, (float)S(e.x, e.y)->floor); - loopv(monsters) if (monsters[i]->state == CS_DEAD) - { - if (lastmillis - monsters[i]->lastaction < 2000) { - monsters[i]->move = 0; - moveplayer(monsters[i], 1, false); - }; - } - else - { - v.z += monsters[i]->eyeheight; - vdist(dist, t, monsters[i]->o, v); - v.z -= monsters[i]->eyeheight; - if (dist < 4) - teleport((int)(&e - &ents[0]), monsters[i]); + loopv(monsters) + { + if (monsters[i]->state == CS_DEAD) { + if (lastmillis - monsters[i]->lastaction < + 2000) { + monsters[i]->move = 0; + moveplayer(monsters[i], 1, false); + } + } else { + v.z += monsters[i]->eyeheight; + vdist(dist, t, monsters[i]->o, v); + v.z -= monsters[i]->eyeheight; + if (dist < 4) + teleport( + (int)(&e - &ents[0]), monsters[i]); + } } } loopv(monsters) if (monsters[i]->state == CS_ALIVE) monsteraction(monsters[i]); Index: src/physics.mm ================================================================== --- src/physics.mm +++ src/physics.mm @@ -27,11 +27,11 @@ if (d->monsterstate) return false; // hack headspace = d->o.z - o->o.z - o->aboveeye - d->eyeheight; if (headspace < 0) headspace = 10; - }; + } return true; } bool cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by, @@ -47,11 +47,11 @@ if (SWS(wmip[mip], x, y, ssize >> mip)->type == CORNER) { bx = x << mip; by = y << mip; bs = 1 << mip; return cornertest(mip, x, y, dx, dy, bx, by, bs); - }; + } return stest; } void mmcollide(dynent *d, float &hi, float &lo) // collide with a mapmodel @@ -130,11 +130,11 @@ x == x2 && y == y2 && cornertest(0, x, y, 1, 1, bx, by, bs) && fx2 - bx + fy2 - by >= bs) return false; break; - }; + } case FHF: // FIXME: too simplistic collision with // slopes, makes it feels like tiny stairs floor -= (s->vdelta + S(x + 1, y)->vdelta + S(x, y + 1)->vdelta + @@ -145,18 +145,18 @@ 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) return false; - }; + } if (hi - lo < d->eyeheight + d->aboveeye) return false; float headspace = 10; @@ -192,22 +192,22 @@ d->o.z += rise; // rise thru stair else return false; } else { d->o.z -= min(min(drop, space), headspace); // gravity - }; + } const float space2 = hi - (d->o.z + d->aboveeye); if (space2 < 0) { if (space2 < -0.1) return false; // hack alert! d->o.z = hi - d->aboveeye; // glue to ceiling d->vel.z = 0; // cancel out jumping velocity - }; + } d->onfloor = d->o.z - d->eyeheight - lo < 0.001f; - }; + } return true; } float rad(float x) @@ -227,11 +227,11 @@ int faketime = curtime + physicsfraction; physicsrepeat = faketime / MINFRAMETIME; physicsfraction = faketime - physicsrepeat * MINFRAMETIME; } else { physicsrepeat = 1; - }; + } } // main physics routine, moves a player/monster for a curtime step // moveres indicated the physics precision (which is lower for monsters and // multiplayer prediction) local is false for multiplayer prediction @@ -250,11 +250,11 @@ if (floating || water) { d.x *= (float)cos(rad(pl->pitch)); d.y *= (float)cos(rad(pl->pitch)); d.z = (float)(pl->move * sin(rad(pl->pitch))); - }; + } d.x += (float)(pl->strafe * cos(rad(pl->yaw - 180))); d.y += (float)(pl->strafe * sin(rad(pl->yaw - 180))); const float speed = @@ -285,41 +285,42 @@ { if (pl->onfloor || water) { if (pl->jumpnext) { pl->jumpnext = false; pl->vel.z = 1.7f; // physics impulse upwards + // dampen velocity change even harder, gives + // correct water feel if (water) { pl->vel.x /= 8; pl->vel.y /= 8; - }; // dampen velocity change even harder, gives - // correct water feel + } if (local) playsoundc(S_JUMP); else if (pl->monsterstate) playsound(S_JUMP, &pl->o); - } else if (pl->timeinair > - 800) // if we land after long time must have - // been a high jump, make thud sound - { + } else if (pl->timeinair > 800) { + // if we land after long time must have been a + // high jump, make thud sound if (local) playsoundc(S_LAND); else if (pl->monsterstate) playsound(S_LAND, &pl->o); - }; + } pl->timeinair = 0; } else { pl->timeinair += curtime; - }; + } const float gravity = 20; const float f = 1.0f / moveres; - float dropf = ((gravity - 1) + - pl->timeinair / 15.0f); // incorrect, but works fine + // incorrect, but works fine + float dropf = ((gravity - 1) + pl->timeinair / 15.0f); + // float slowly down in water if (water) { dropf = 5; pl->timeinair = 0; - }; // float slowly down in water + } const float drop = dropf * curtime / gravity / 100 / moveres; // at high fps, gravity kicks in too fast const float rise = speed / moveres / 1.2f; // extra smoothness when lifting up stairs @@ -335,31 +336,31 @@ pl->blocked = true; pl->o.x -= f * d.x; if (collide(pl, false, drop, rise)) { d.x = 0; continue; - }; + } pl->o.x += f * d.x; // still stuck, try x axis pl->o.y -= f * d.y; if (collide(pl, false, drop, rise)) { d.y = 0; continue; - }; + } pl->o.y += f * d.y; // try just dropping down pl->moving = false; pl->o.x -= f * d.x; pl->o.y -= f * d.y; if (collide(pl, false, drop, rise)) { d.y = d.x = 0; continue; - }; + } pl->o.z -= f * d.z; break; } - }; + } // detect wether player is outside map, used for skipping zbuffer clear // mostly if (pl->o.x < 0 || pl->o.x >= ssize || pl->o.y < 0 || pl->o.y > ssize) { @@ -367,11 +368,11 @@ } else { sqr *s = S((int)pl->o.x, (int)pl->o.y); pl->outsidemap = SOLID(s) || pl->o.z < s->floor - (s->type == FHF ? s->vdelta / 4 : 0) || pl->o.z > s->ceil + (s->type == CHF ? s->vdelta / 4 : 0); - }; + } // automatically apply smooth roll when strafing if (pl->strafe == 0) { pl->roll = pl->roll / (1 + (float)sqrt((float)curtime) / 25); @@ -379,11 +380,11 @@ pl->roll += pl->strafe * curtime / -30.0f; if (pl->roll > maxroll) pl->roll = (float)maxroll; if (pl->roll < -maxroll) pl->roll = (float)-maxroll; - }; + } // play sounds on water transitions if (!pl->inwater && water) { playsound(S_SPLASH2, &pl->o); Index: src/rendercubes.mm ================================================================== --- src/rendercubes.mm +++ src/rendercubes.mm @@ -45,11 +45,11 @@ v.z = v3; \ v.r = ls->r; \ v.g = ls->g; \ v.b = ls->b; \ v.a = 255; \ - }; + } #define vert(v1, v2, v3, ls, t1, t2) \ { \ vertf((float)(v1), (float)(v2), (float)(v3), ls, t1, t2); \ } @@ -79,12 +79,12 @@ #define stripend() \ { \ if (floorstrip || deltastrip) { \ addstrip(ogltex, firstindex, curvert - firstindex); \ floorstrip = deltastrip = false; \ - }; \ - }; + } \ + } void finishstrips() { stripend(); } @@ -98,11 +98,11 @@ { vertcheck(); if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); float xf = TEXTURESCALE / sx; float yf = TEXTURESCALE / sy; @@ -126,11 +126,11 @@ vert(x + size, h, y, l2, xo + xs, yo); vert(x, h, y, l1, xo, yo); } else { vert(x, h, y, l1, xo, yo); vert(x + size, h, y, l2, xo + xs, yo); - }; + } ol3r = l1->r; ol3g = l1->g; ol3b = l1->b; ol4r = l2->r; ol4g = l2->g; @@ -155,20 +155,20 @@ ol3b = p3[2]; uchar *p4 = (uchar *)(&verts[curvert - 2].r); ol4r = p4[0]; ol4g = p4[1]; ol4b = p4[2]; - }; - }; + } + } if (isceil) { vert(x + size, h, y + size, l3, xo + xs, yo + ys); vert(x, h, y + size, l4, xo, yo + ys); } else { vert(x, h, y + size, l4, xo, yo + ys); vert(x + size, h, y + size, l3, xo + xs, yo + ys); - }; + } oy = y; nquads++; } @@ -179,11 +179,11 @@ { vertcheck(); if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); float xf = TEXTURESCALE / sx; float yf = TEXTURESCALE / sy; @@ -205,28 +205,28 @@ vertf((float)x + size, h2, (float)y, l2, xo + xs, yo); vertf((float)x, h1, (float)y, l1, xo, yo); } else { vertf((float)x, h1, (float)y, l1, xo, yo); vertf((float)x + size, h2, (float)y, l2, xo + xs, yo); - }; + } ol3r = l1->r; ol3g = l1->g; ol3b = l1->b; ol4r = l2->r; ol4g = l2->g; ol4b = l2->b; - }; + } if (isceil) { vertf( (float)x + size, h3, (float)y + size, l3, xo + xs, yo + ys); vertf((float)x, h4, (float)y + size, l4, xo, yo + ys); } else { vertf((float)x, h4, (float)y + size, l4, xo, yo + ys); vertf( (float)x + size, h3, (float)y + size, l3, xo + xs, yo + ys); - }; + } oy = y; nquads++; } @@ -274,11 +274,11 @@ render_2tris( h1, s, x, y, x + size, y, x, y + size, s, t, u); if (h2) render_2tris(h2, s, x + size, y, x + size, y + size, x, y + size, t, u, v); - }; + } } void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, @@ -287,11 +287,11 @@ stripend(); vertcheck(); if (showm) { l1 = &sbright; l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); float xf = TEXTURESCALE / sx; float yf = TEXTURESCALE / sy; @@ -306,11 +306,11 @@ } else { vertf((float)x1, ceil1, (float)y1, l1, xo, -yf * ceil1); vertf((float)x2, ceil2, (float)y2, l2, xo + xs, -yf * ceil2); vertf((float)x1, floor1, (float)y1, l1, xo, -floor1 * yf); vertf((float)x2, floor2, (float)y2, l2, xo + xs, -floor2 * yf); - }; + } nquads++; addstrip(gltex, curvert - 4, 4); } @@ -373,21 +373,21 @@ float yo = yf * (yy + t2); if (yy == wy1) { vertw(xx, hf, yy, &dl, dx(xo), dy(yo), t1); vertw(xx + watersubdiv, hf, yy, &dl, dx(xo + xs), dy(yo), t1); - }; + } vertw(xx, hf, yy + watersubdiv, &dl, dx(xo), dy(yo + ys), t1); vertw(xx + watersubdiv, hf, yy + watersubdiv, &dl, dx(xo + xs), dy(yo + ys), t1); - }; + } int n = (wy2 - wy1 - 1) / watersubdiv; nquads += n; n = (n + 2) * 2; glDrawArrays(GL_TRIANGLE_STRIP, curvert -= n, n); - }; + } glDisable(GL_BLEND); glDepthMask(GL_TRUE); return nquads; @@ -410,11 +410,11 @@ wy1 = y; if (x2 > wx2) wx2 = x2; if (y2 > wy2) wy2 = y2; - }; + } } void resetcubes() { Index: src/renderextras.mm ================================================================== --- src/renderextras.mm +++ src/renderextras.mm @@ -96,21 +96,21 @@ { spheres[i].next = sempty; sempty = &spheres[i]; } sinit = true; - }; + } if (sempty) { sphere *p = sempty; sempty = p->next; p->o = o; p->max = max; p->size = 1; p->type = type; p->next = slist; slist = p; - }; + } } void renderspheres(int time) { @@ -137,42 +137,42 @@ p->next = sempty; sempty = p; } else { p->size += time / 100.0f; pp = &p->next; - }; - }; + } + } glDisable(GL_BLEND); glDepthMask(GL_TRUE); } string closeent; OFString *entnames[] = { - @"none?", - @"light", - @"playerstart", - @"shells", - @"bullets", - @"rockets", - @"riflerounds", - @"health", - @"healthboost", - @"greenarmour", - @"yellowarmour", - @"quaddamage", - @"teleport", - @"teledest", - @"mapmodel", - @"monster", - @"trigger", - @"jumppad", - @"?", - @"?", - @"?", - @"?", - @"?", + @"none?", + @"light", + @"playerstart", + @"shells", + @"bullets", + @"rockets", + @"riflerounds", + @"health", + @"healthboost", + @"greenarmour", + @"yellowarmour", + @"quaddamage", + @"teleport", + @"teledest", + @"mapmodel", + @"monster", + @"trigger", + @"jumppad", + @"?", + @"?", + @"?", + @"?", + @"?", }; void renderents() // show sparkly thingies for map entities in edit mode { @@ -208,12 +208,12 @@ static OFString *lastsky = @""; if ([lastsky isEqual:basename]) return; - static const OFString *side[] = { - @"ft", @"bk", @"lf", @"rt", @"dn", @"up"}; + static const OFString *side[] = { @"ft", @"bk", @"lf", @"rt", + @"dn", @"up" }; int texnum = 14; loopi(6) { OFString *path = [OFString stringWithFormat:@"packages/%@_%@.jpg", @@ -334,11 +334,11 @@ if (cursordepth == 1.0f) worldpos = player1->o; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); cursorupdate(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - }; + } glDisable(GL_DEPTH_TEST); invertperspective(); glPushMatrix(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); @@ -440,15 +440,15 @@ int g = player1->gunselect; int r = 64; if (g > 2) { g -= 3; r = 128; - }; + } drawicon((float)(g * 64), (float)r, 1220, 1650); glPopMatrix(); } glDepthMask(GL_TRUE); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); } Index: src/rendergl.mm ================================================================== --- src/rendergl.mm +++ src/rendergl.mm @@ -108,12 +108,17 @@ } @finally { SDL_FreeFormat(format); } } - // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = - // 255-*p; }; +#if 0 + loopi(s->w * s->h * 3) + { + uchar *p = (uchar *)s->pixels + i; + *p = 255 - *p; + } +#endif glBindTexture(GL_TEXTURE_2D, tnum); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, @@ -262,11 +267,11 @@ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - }; + } } int skyoglid; struct strip { @@ -348,12 +353,12 @@ VAR(fog, 64, 180, 1024); VAR(fogcolour, 0, 0x8099B3, 0xFFFFFF); VARP(hudgun, 0, 1, 1); -OFString *hudgunnames[] = {@"hudguns/fist", @"hudguns/shotg", @"hudguns/chaing", - @"hudguns/rocket", @"hudguns/rifle"}; +OFString *hudgunnames[] = { @"hudguns/fist", @"hudguns/shotg", + @"hudguns/chaing", @"hudguns/rocket", @"hudguns/rifle" }; void drawhudmodel(int start, int end, float speed, int base) { rendermodel(hudgunnames[player1->gunselect], start, end, 0, 1.0f, @@ -380,11 +385,11 @@ player1->lastattackgun == player1->gunselect && lastmillis - player1->lastaction < rtime) { drawhudmodel(7, 18, rtime / 18.0f, player1->lastaction); } else { drawhudmodel(6, 1, 100, 0); - }; + } glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fovy, aspect, 0.15f, farplane); glMatrixMode(GL_MODELVIEW); @@ -400,22 +405,22 @@ float aspect = w / (float)h; bool underwater = player1->o.z < hf; glFogi(GL_FOG_START, (fog + 64) / 8); glFogi(GL_FOG_END, fog); - float fogc[4] = {(fogcolour >> 16) / 256.0f, - ((fogcolour >> 8) & 255) / 256.0f, (fogcolour & 255) / 256.0f, - 1.0f}; + float fogc[4] = { (fogcolour >> 16) / 256.0f, + ((fogcolour >> 8) & 255) / 256.0f, (fogcolour & 255) / 256.0f, + 1.0f }; glFogfv(GL_FOG_COLOR, fogc); glClearColor(fogc[0], fogc[1], fogc[2], 1.0f); if (underwater) { fovy += (float)sin(lastmillis / 1000.0) * 2.0f; aspect += (float)sin(lastmillis / 1000.0 + PI) * 0.1f; glFogi(GL_FOG_START, 0); glFogi(GL_FOG_END, (fog + 96) / 8); - }; + } glClear((player1->outsidemap ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); Index: src/renderparticles.mm ================================================================== --- src/renderparticles.mm +++ src/renderparticles.mm @@ -23,11 +23,11 @@ { particles[i].next = parempty; parempty = &particles[i]; } parinit = true; - }; + } if (parempty) { particle *p = parempty; parempty = p->next; p->o = o; p->d = d; @@ -34,11 +34,11 @@ p->fade = fade; p->type = type; p->millis = lastmillis; p->next = parlist; parlist = p; - }; + } } VAR(demotracking, 0, 0, 1); VARP(particlesize, 20, 100, 500); @@ -67,19 +67,20 @@ struct parttype { float r, g, b; int gr, tex; float sz; } parttypes[] = { - {0.7f, 0.6f, 0.3f, 2, 3, 0.06f}, // yellow: sparks - {0.5f, 0.5f, 0.5f, 20, 7, 0.15f}, // grey: small smoke - {0.2f, 0.2f, 1.0f, 20, 3, 0.08f}, // blue: edit mode entities - {1.0f, 0.1f, 0.1f, 1, 7, 0.06f}, // red: blood spats - {1.0f, 0.8f, 0.8f, 20, 6, 1.2f}, // yellow: fireball1 - {0.5f, 0.5f, 0.5f, 20, 7, 0.6f}, // grey: big smoke - {1.0f, 1.0f, 1.0f, 20, 8, 1.2f}, // blue: fireball2 - {1.0f, 1.0f, 1.0f, 20, 9, 1.2f}, // green: fireball3 - {1.0f, 0.1f, 0.1f, 0, 7, 0.2f}, // red: demotrack + { 0.7f, 0.6f, 0.3f, 2, 3, 0.06f }, // yellow: sparks + { 0.5f, 0.5f, 0.5f, 20, 7, 0.15f }, // grey: small smoke + { 0.2f, 0.2f, 1.0f, 20, 3, + 0.08f }, // blue: edit mode entities + { 1.0f, 0.1f, 0.1f, 1, 7, 0.06f }, // red: blood spats + { 1.0f, 0.8f, 0.8f, 20, 6, 1.2f }, // yellow: fireball1 + { 0.5f, 0.5f, 0.5f, 20, 7, 0.6f }, // grey: big smoke + { 1.0f, 1.0f, 1.0f, 20, 8, 1.2f }, // blue: fireball2 + { 1.0f, 1.0f, 1.0f, 20, 9, 1.2f }, // green: fireball3 + { 1.0f, 0.1f, 0.1f, 0, 7, 0.2f }, // red: demotrack }; int numrender = 0; for (particle *p, **pp = &parlist; p = *pp;) { Index: src/rendertext.mm ================================================================== --- src/rendertext.mm +++ src/rendertext.mm @@ -1,104 +1,104 @@ // rendertext.cpp: based on Don's gl_text.cpp #include "cube.h" short char_coords[96][4] = { - {0, 0, 25, 64}, //! - {25, 0, 54, 64}, //" - {54, 0, 107, 64}, // # - {107, 0, 148, 64}, //$ - {148, 0, 217, 64}, //% - {217, 0, 263, 64}, //& - {263, 0, 280, 64}, //' - {280, 0, 309, 64}, //( - {309, 0, 338, 64}, //) - {338, 0, 379, 64}, //* - {379, 0, 432, 64}, //+ - {432, 0, 455, 64}, //, - {455, 0, 484, 64}, //- - {0, 64, 21, 128}, //. - {23, 64, 52, 128}, /// - {52, 64, 93, 128}, // 0 - {93, 64, 133, 128}, // 1 - {133, 64, 174, 128}, // 2 - {174, 64, 215, 128}, // 3 - {215, 64, 256, 128}, // 4 - {256, 64, 296, 128}, // 5 - {296, 64, 337, 128}, // 6 - {337, 64, 378, 128}, // 7 - {378, 64, 419, 128}, // 8 - {419, 64, 459, 128}, // 9 - {459, 64, 488, 128}, //: - {0, 128, 29, 192}, //; - {29, 128, 81, 192}, //< - {81, 128, 134, 192}, //= - {134, 128, 186, 192}, //> - {186, 128, 221, 192}, //? - {221, 128, 285, 192}, //@ - {285, 128, 329, 192}, // A - {329, 128, 373, 192}, // B - {373, 128, 418, 192}, // C - {418, 128, 467, 192}, // D - {0, 192, 40, 256}, // E - {40, 192, 77, 256}, // F - {77, 192, 127, 256}, // G - {127, 192, 175, 256}, // H - {175, 192, 202, 256}, // I - {202, 192, 231, 256}, // J - {231, 192, 275, 256}, // K - {275, 192, 311, 256}, // L - {311, 192, 365, 256}, // M - {365, 192, 413, 256}, // N - {413, 192, 463, 256}, // O - {1, 256, 38, 320}, // P - {38, 256, 89, 320}, // Q - {89, 256, 133, 320}, // R - {133, 256, 176, 320}, // S - {177, 256, 216, 320}, // T - {217, 256, 263, 320}, // U - {263, 256, 307, 320}, // V - {307, 256, 370, 320}, // W - {370, 256, 414, 320}, // X - {414, 256, 453, 320}, // Y - {453, 256, 497, 320}, // Z - {0, 320, 29, 384}, //[ - {29, 320, 58, 384}, //"\" - {59, 320, 87, 384}, //] - {87, 320, 139, 384}, //^ - {139, 320, 180, 384}, //_ - {180, 320, 221, 384}, //` - {221, 320, 259, 384}, // a - {259, 320, 299, 384}, // b - {299, 320, 332, 384}, // c - {332, 320, 372, 384}, // d - {372, 320, 411, 384}, // e - {411, 320, 433, 384}, // f - {435, 320, 473, 384}, // g - {0, 384, 40, 448}, // h - {40, 384, 56, 448}, // i - {58, 384, 80, 448}, // j - {80, 384, 118, 448}, // k - {118, 384, 135, 448}, // l - {135, 384, 197, 448}, // m - {197, 384, 238, 448}, // n - {238, 384, 277, 448}, // o - {277, 384, 317, 448}, // p - {317, 384, 356, 448}, // q - {357, 384, 384, 448}, // r - {385, 384, 417, 448}, // s - {417, 384, 442, 448}, // t - {443, 384, 483, 448}, // u - {0, 448, 38, 512}, // v - {38, 448, 90, 512}, // w - {90, 448, 128, 512}, // x - {128, 448, 166, 512}, // y - {166, 448, 200, 512}, // z - {200, 448, 241, 512}, //{ - {241, 448, 270, 512}, //| - {270, 448, 310, 512}, //} - {310, 448, 363, 512}, //~ + { 0, 0, 25, 64 }, //! + { 25, 0, 54, 64 }, //" + { 54, 0, 107, 64 }, // # + { 107, 0, 148, 64 }, //$ + { 148, 0, 217, 64 }, //% + { 217, 0, 263, 64 }, //& + { 263, 0, 280, 64 }, //' + { 280, 0, 309, 64 }, //( + { 309, 0, 338, 64 }, //) + { 338, 0, 379, 64 }, //* + { 379, 0, 432, 64 }, //+ + { 432, 0, 455, 64 }, //, + { 455, 0, 484, 64 }, //- + { 0, 64, 21, 128 }, //. + { 23, 64, 52, 128 }, /// + { 52, 64, 93, 128 }, // 0 + { 93, 64, 133, 128 }, // 1 + { 133, 64, 174, 128 }, // 2 + { 174, 64, 215, 128 }, // 3 + { 215, 64, 256, 128 }, // 4 + { 256, 64, 296, 128 }, // 5 + { 296, 64, 337, 128 }, // 6 + { 337, 64, 378, 128 }, // 7 + { 378, 64, 419, 128 }, // 8 + { 419, 64, 459, 128 }, // 9 + { 459, 64, 488, 128 }, //: + { 0, 128, 29, 192 }, //; + { 29, 128, 81, 192 }, //< + { 81, 128, 134, 192 }, //= + { 134, 128, 186, 192 }, //> + { 186, 128, 221, 192 }, //? + { 221, 128, 285, 192 }, //@ + { 285, 128, 329, 192 }, // A + { 329, 128, 373, 192 }, // B + { 373, 128, 418, 192 }, // C + { 418, 128, 467, 192 }, // D + { 0, 192, 40, 256 }, // E + { 40, 192, 77, 256 }, // F + { 77, 192, 127, 256 }, // G + { 127, 192, 175, 256 }, // H + { 175, 192, 202, 256 }, // I + { 202, 192, 231, 256 }, // J + { 231, 192, 275, 256 }, // K + { 275, 192, 311, 256 }, // L + { 311, 192, 365, 256 }, // M + { 365, 192, 413, 256 }, // N + { 413, 192, 463, 256 }, // O + { 1, 256, 38, 320 }, // P + { 38, 256, 89, 320 }, // Q + { 89, 256, 133, 320 }, // R + { 133, 256, 176, 320 }, // S + { 177, 256, 216, 320 }, // T + { 217, 256, 263, 320 }, // U + { 263, 256, 307, 320 }, // V + { 307, 256, 370, 320 }, // W + { 370, 256, 414, 320 }, // X + { 414, 256, 453, 320 }, // Y + { 453, 256, 497, 320 }, // Z + { 0, 320, 29, 384 }, //[ + { 29, 320, 58, 384 }, //"\" + { 59, 320, 87, 384 }, //] + { 87, 320, 139, 384 }, //^ + { 139, 320, 180, 384 }, //_ + { 180, 320, 221, 384 }, //` + { 221, 320, 259, 384 }, // a + { 259, 320, 299, 384 }, // b + { 299, 320, 332, 384 }, // c + { 332, 320, 372, 384 }, // d + { 372, 320, 411, 384 }, // e + { 411, 320, 433, 384 }, // f + { 435, 320, 473, 384 }, // g + { 0, 384, 40, 448 }, // h + { 40, 384, 56, 448 }, // i + { 58, 384, 80, 448 }, // j + { 80, 384, 118, 448 }, // k + { 118, 384, 135, 448 }, // l + { 135, 384, 197, 448 }, // m + { 197, 384, 238, 448 }, // n + { 238, 384, 277, 448 }, // o + { 277, 384, 317, 448 }, // p + { 317, 384, 356, 448 }, // q + { 357, 384, 384, 448 }, // r + { 385, 384, 417, 448 }, // s + { 417, 384, 442, 448 }, // t + { 443, 384, 483, 448 }, // u + { 0, 448, 38, 512 }, // v + { 38, 448, 90, 512 }, // w + { 90, 448, 128, 512 }, // x + { 128, 448, 166, 512 }, // y + { 166, 448, 200, 512 }, // z + { 200, 448, 241, 512 }, //{ + { 241, 448, 270, 512 }, //| + { 270, 448, 310, 512 }, //} + { 310, 448, 363, 512 }, //~ }; int text_width(OFString *string) { Index: src/rndmap.mm ================================================================== --- src/rndmap.mm +++ src/rndmap.mm @@ -71,11 +71,11 @@ { srand(seed); seed = rnd(10000); if (!scale) scale = 10; - for (int x = b.x; x <= b.x + b.xs; x++) + for (int x = b.x; x <= b.x + b.xs; x++) { for (int y = b.y; y <= b.y + b.ys; y++) { sqr *s = S(x, y); if (!SOLID(s) && x != b.x + b.xs && y != b.y + b.ys) s->type = FHF; s->vdelta = @@ -83,7 +83,8 @@ y / ((float)scale) + seed, 1000, 0.01f) * 50 + 25); if (s->vdelta > 128) s->vdelta = 0; - }; + } + } } Index: src/savegamedemo.mm ================================================================== --- src/savegamedemo.mm +++ src/savegamedemo.mm @@ -69,11 +69,11 @@ { if (f) { if (demorecording) gzputi(-1); gzclose(f); - }; + } f = NULL; demorecording = false; demoplayback = false; demoloading = false; loopv(playerhistory) zapdynent(playerhistory[i]); Index: src/server.mm ================================================================== --- src/server.mm +++ src/server.mm @@ -18,12 +18,12 @@ vector clients; int maxclients = 8; static OFString *smapname; -struct server_entity // server side version of "entity" type -{ +// server side version of "entity" type +struct server_entity { bool spawned; int spawnsecs; }; vector sents; @@ -66,16 +66,16 @@ switch (clients[n].type) { case ST_TCPIP: { enet_peer_send(clients[n].peer, 0, packet); bsend += packet->dataLength; break; - }; + } case ST_LOCAL: localservertoclient(packet->data, packet->dataLength); break; - }; + } } void send2(bool rel, int cn, int a, int b) { @@ -135,11 +135,11 @@ return; if (sents[i].spawned) { sents[i].spawned = false; sents[i].spawnsecs = sec; send2(true, sender, SV_ITEMACC, i); - }; + } } void resetvotes() { @@ -188,11 +188,11 @@ { if (ENET_NET_TO_HOST_16(*(ushort *)packet->data) != packet->dataLength) { disconnect_client(sender, "packet length"); return; - }; + } uchar *end = packet->data + packet->dataLength; uchar *p = packet->data + 2; char text[MAXTRANS]; int cn = -1, type; @@ -233,15 +233,15 @@ case SV_ITEMLIST: { int n; while ((n = getint(p)) != -1) if (notgotitems) { - server_entity se = {false, 0}; + server_entity se = { false, 0 }; while (sents.length() <= n) sents.add(se); sents[n].spawned = true; - }; + } notgotitems = false; break; } case SV_ITEMPICKUP: { @@ -258,11 +258,11 @@ cn = getint(p); if (cn < 0 || cn >= clients.length() || clients[cn].type == ST_EMPTY) { disconnect_client(sender, "client num"); return; - }; + } int size = msgsizelookup(type); assert(size != -1); loopi(size - 2) getint(p); break; } @@ -284,26 +284,26 @@ // updates { for (int n = getint(p); n; n--) getint(p); break; - }; + } default: { int size = msgsizelookup(type); if (size == -1) { disconnect_client(sender, "tag type"); return; - }; + } loopi(size - 1) getint(p); - }; - }; + } + } if (p > end) { disconnect_client(sender, "end of packet"); return; - }; + } multicast(packet, sender); } void send_welcome(int n) @@ -363,11 +363,11 @@ checkintermission() { if (!minremain) { interm = lastsec + 10; mapend = lastsec + 1000; - }; + } send2(true, -1, SV_TIMEUP, minremain--); } void startintermission() @@ -404,11 +404,11 @@ if (sents[i].spawnsecs && (sents[i].spawnsecs -= seconds - lastsec) <= 0) { sents[i].spawnsecs = 0; sents[i].spawned = true; send2(true, -1, SV_ITEMSPAWN, i); - }; + } } lastsec = seconds; if ((mode > 1 || (mode == 0 && nonlocalclients)) && @@ -421,11 +421,11 @@ send2(true, i, SV_MAPRELOAD, 0); // ask a client to trigger map reload mapreload = true; break; } - }; + } resetserverifempty(); if (!isdedicated) return; // below is network only @@ -446,11 +446,11 @@ printf("status: %d remote clients, %.1f send, %.1f rec " "(K/sec)\n", nonlocalclients, bsend / 60.0f / 1024, brec / 60.0f / 1024); bsend = brec = 0; - }; + } ENetEvent event; if (enet_host_service(serverhost, &event, timeout) > 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: { @@ -482,16 +482,15 @@ clients[(intptr_t)event.peer->data].hostname); clients[(intptr_t)event.peer->data].type = ST_EMPTY; send2(true, -1, SV_CDIS, (intptr_t)event.peer->data); event.peer->data = (void *)-1; break; - }; + } - if (numplayers > maxclients) { + if (numplayers > maxclients) disconnect_client(lastconnect, "maxclients reached"); - }; - }; + } #ifndef _WIN32 fflush(stdout); #endif } @@ -526,11 +525,11 @@ maxclients = maxcl; servermsinit(master ? master : @"wouter.fov120.com/cube/masterserver/", sdesc, dedicated); if (isdedicated = dedicated) { - ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT}; + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT }; @autoreleasepool { if (ip.length > 0 && enet_address_set_host(&address, ip.UTF8String) < 0) printf("WARNING: server ip not resolved"); } @@ -540,18 +539,18 @@ loopi(MAXCLIENTS) serverhost->peers[i].data = (void *)-1; } resetserverifempty(); - if (isdedicated) // do not return, this becomes main loop - { + // do not return, this becomes main loop + if (isdedicated) { #ifdef _WIN32 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); #endif printf("dedicated server started, waiting for " "clients...\nCtrl-C to exit\n\n"); atexit(cleanupserver); atexit(enet_deinitialize); for (;;) serverslice(/*enet_time_get_sec()*/ time(NULL), 5); - }; + } } Index: src/serverbrowser.mm ================================================================== --- src/serverbrowser.mm +++ src/serverbrowser.mm @@ -34,20 +34,20 @@ continue; } rt->query = resolverqueries.pop(); rt->starttime = lastmillis; SDL_UnlockMutex(resolvermutex); - ENetAddress address = {ENET_HOST_ANY, CUBE_SERVINFO_PORT}; + ENetAddress address = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; enet_address_set_host(&address, rt->query); SDL_LockMutex(resolvermutex); resolverresult &rr = resolverresults.add(); rr.query = rt->query; rr.address = address; rt->query = NULL; rt->starttime = 0; SDL_UnlockMutex(resolvermutex); - }; + } return 0; } void resolverinit(int threads, int limit) @@ -123,12 +123,12 @@ if (lastmillis - rt.starttime > resolverlimit) { resolverstop(rt, true); *name = rt.query; SDL_UnlockMutex(resolvermutex); return true; - }; - }; + } + } } SDL_UnlockMutex(resolvermutex); return false; } @@ -197,11 +197,11 @@ void checkresolver() { char *name = NULL; - ENetAddress addr = {ENET_HOST_ANY, CUBE_SERVINFO_PORT}; + ENetAddress addr = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; while (resolvercheck(&name, &addr)) { if (addr.host == ENET_HOST_ANY) continue; loopv(servers) { @@ -303,11 +303,11 @@ servermenu() { if (pingsock == ENET_SOCKET_NULL) { pingsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM, NULL); resolverinit(1, 1000); - }; + } resolverclear(); loopv(servers) resolverquery(servers[i].name); refreshservers(); menuset(1); } Index: src/serverms.mm ================================================================== --- src/serverms.mm +++ src/serverms.mm @@ -44,15 +44,15 @@ int len = enet_socket_receive(mssock, NULL, &buf, 1); if (len <= 0) { enet_socket_destroy(mssock); mssock = ENET_SOCKET_NULL; return; - }; + } buf.data = ((char *)buf.data) + len; ((char *)buf.data)[0] = 0; buf.dataLength -= len; - }; + } } uchar * stripheader(uchar *b) { @@ -60,31 +60,30 @@ if (!s) s = strstr((char *)b, "\n\n"); return s ? (uchar *)s : b; } -ENetAddress masterserver = {ENET_HOST_ANY, 80}; +ENetAddress masterserver = { ENET_HOST_ANY, 80 }; int updmaster = 0; string masterbase; string masterpath; uchar masterrep[MAXTRANS]; ENetBuffer masterb; void updatemasterserver(int seconds) { - if (seconds > - updmaster) // send alive signal to masterserver every hour of uptime - { + // send alive signal to masterserver every hour of uptime + if (seconds > updmaster) { sprintf_sd(path)("%sregister.do?action=add", masterpath); httpgetsend(masterserver, masterbase, path, "cubeserver", "Cube Server"); masterrep[0] = 0; masterb.data = masterrep; masterb.dataLength = MAXTRANS - 1; updmaster = seconds + 60 * 60; - }; + } } void checkmasterreply() { @@ -157,14 +156,14 @@ strcpy_s(masterpath, mid); strn0cpy(masterbase, master, mid - master + 1); serverdesc = sdesc; if (listen) { - ENetAddress address = { - ENET_HOST_ANY, CUBE_SERVINFO_PORT}; + ENetAddress address = { ENET_HOST_ANY, + CUBE_SERVINFO_PORT }; pongsock = enet_socket_create( ENET_SOCKET_TYPE_DATAGRAM, &address); if (pongsock == ENET_SOCKET_NULL) fatal(@"could not create server info socket\n"); } } } Index: src/serverutil.mm ================================================================== --- src/serverutil.mm +++ src/serverutil.mm @@ -18,11 +18,11 @@ *p++ = 0x81; *p++ = n; *p++ = n >> 8; *p++ = n >> 16; *p++ = n >> 24; - }; + } } int getint(uchar *&p) { @@ -52,41 +52,40 @@ putint(p, 0); } } static const OFString *modenames[] = { - @"SP", - @"DMSP", - @"ffa/default", - @"coopedit", - @"ffa/duel", - @"teamplay", - @"instagib", - @"instagib team", - @"efficiency", - @"efficiency team", - @"insta arena", - @"insta clan arena", - @"tactics arena", - @"tactics clan arena", + @"SP", + @"DMSP", + @"ffa/default", + @"coopedit", + @"ffa/duel", + @"teamplay", + @"instagib", + @"instagib team", + @"efficiency", + @"efficiency team", + @"insta arena", + @"insta clan arena", + @"tactics arena", + @"tactics clan arena", }; OFString * modestr(int n) { return (n >= -2 && n < 12) ? modenames[n + 2] : @"unknown"; } - -char msgsizesl[] = // size inclusive message token, 0 for variable or - // not-checked sizes - {SV_INITS2C, 4, SV_INITC2S, 0, SV_POS, 12, SV_TEXT, 0, SV_SOUND, 2, SV_CDIS, - 2, SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6, - SV_DIED, 2, SV_DAMAGE, 4, SV_SHOT, 8, SV_FRAGS, 2, SV_MAPCHANGE, 0, - SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 3, SV_DENIED, 2, SV_PING, 2, SV_PONG, 2, - SV_CLIENTPING, 2, SV_GAMEMODE, 2, SV_TIMEUP, 2, SV_EDITENT, 10, - SV_MAPRELOAD, 2, SV_ITEMACC, 2, SV_SENDMAP, 0, SV_RECVMAP, 1, - SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_EXT, 0, -1}; +// size inclusive message token, 0 for variable or not-checked sizes +char msgsizesl[] = { SV_INITS2C, 4, SV_INITC2S, 0, SV_POS, 12, SV_TEXT, 0, + SV_SOUND, 2, SV_CDIS, 2, SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, + SV_EDITD, 6, SV_EDITE, 6, SV_DIED, 2, SV_DAMAGE, 4, SV_SHOT, 8, + SV_FRAGS, 2, SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 3, + SV_DENIED, 2, SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2, + SV_TIMEUP, 2, SV_EDITENT, 10, SV_MAPRELOAD, 2, SV_ITEMACC, 2, + SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_EXT, 0, + -1 }; char msgsizelookup(int msg) { for (char *p = msgsizesl; *p >= 0; p += 2) @@ -185,14 +184,14 @@ case 'c': maxcl = atoi(a); break; default: printf("WARNING: unknown commandline option\n"); - }; - }; + } + } if (enet_initialize() < 0) fatal(@"Unable to initialise network module"); initserver(true, uprate, @(sdesc), @(ip), @(master), @(passwd), maxcl); return 0; } #endif Index: src/sound.mm ================================================================== --- src/sound.mm +++ src/sound.mm @@ -43,17 +43,17 @@ Mix_FreeMusic(mod); #else FMUSIC_FreeSong(mod); #endif mod = NULL; - }; + } if (stream) { #ifndef USE_MIXER FSOUND_Stream_Close(stream); #endif stream = NULL; - }; + } } VAR(soundbufferlen, 128, 1024, 4096); void @@ -64,11 +64,11 @@ if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) < 0) { conoutf(@"sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); nosound = true; - }; + } Mix_AllocateChannels(MAXCHAN); #else if (FSOUND_GetVersion() < FMOD_VERSION) fatal(@"old FMOD dll"); if (!FSOUND_Init(SOUNDFREQ, MAXCHAN, FSOUND_INIT_GLOBALFOCUS)) { @@ -180,12 +180,12 @@ (PI / 180.0f); // relative angle of // sound along X-Y axis pan = int(255.9f * (0.5 * sin(yaw) + 0.5f)); // range is from 0 (left) // to 255 (right) - }; - }; + } + } vol = (vol * MAXVOL) / 255; #ifdef USE_MIXER Mix_Volume(chan, vol); Mix_SetPanning(chan, 255 - pan, pan); #else Index: src/weapon.mm ================================================================== --- src/weapon.mm +++ src/weapon.mm @@ -11,19 +11,19 @@ static const int SGRAYS = 20; static const float SGSPREAD = 2; static OFVector3D sg[SGRAYS]; static const guninfo guns[NUMGUNS] = { - {S_PUNCH1, 250, 50, 0, 0, 1, @"fist"}, - {S_SG, 1400, 10, 0, 0, 20, @"shotgun"}, // *SGRAYS - {S_CG, 100, 30, 0, 0, 7, @"chaingun"}, - {S_RLFIRE, 800, 120, 80, 0, 10, @"rocketlauncher"}, - {S_RIFLE, 1500, 100, 0, 0, 30, @"rifle"}, - {S_FLAUNCH, 200, 20, 50, 4, 1, @"fireball"}, - {S_ICEBALL, 200, 40, 30, 6, 1, @"iceball"}, - {S_SLIMEBALL, 200, 30, 160, 7, 1, @"slimeball"}, - {S_PIGR1, 250, 50, 0, 0, 1, @"bite"}, + { S_PUNCH1, 250, 50, 0, 0, 1, @"fist" }, + { S_SG, 1400, 10, 0, 0, 20, @"shotgun" }, // *SGRAYS + { S_CG, 100, 30, 0, 0, 7, @"chaingun" }, + { S_RLFIRE, 800, 120, 80, 0, 10, @"rocketlauncher" }, + { S_RIFLE, 1500, 100, 0, 0, 30, @"rifle" }, + { S_FLAUNCH, 200, 20, 50, 4, 1, @"fireball" }, + { S_ICEBALL, 200, 40, 30, 6, 1, @"iceball" }, + { S_SLIMEBALL, 200, 30, 160, 7, 1, @"slimeball" }, + { S_PIGR1, 250, 50, 0, 0, 1, @"bite" }, }; void selectgun(int a, int b, int c) { @@ -171,11 +171,11 @@ else if (d->monsterstate) monsterpain(d, damage, at); else { addmsg(1, 4, SV_DAMAGE, target, damage, d->lifesequence); playsound(S_PAIN1 + rnd(5), &d->o); - }; + } particle_splash(3, damage, 1000, d->o); demodamage(damage, d->o); } const float RL_RADIUS = 5; Index: src/world.mm ================================================================== --- src/world.mm +++ src/world.mm @@ -23,22 +23,22 @@ s->type = SPACE; else continue; } else { s->type = type ? SOLID : SPACE; - }; + } if (x > maxx) maxx = x; if (y > maxy) maxy = y; if (x < minx) minx = x; if (y < miny) miny = y; - }; + } } - block b = {minx, miny, maxx - minx + 1, maxy - miny + 1}; + block b = { minx, miny, maxx - minx + 1, maxy - miny + 1 }; if (maxx) remip(b); // remip minimal area of changed geometry } void @@ -95,15 +95,15 @@ int vs = ssize >> (level + 1); block s = b; if (s.x & 1) { s.x--; s.xs++; - }; + } if (s.y & 1) { s.y--; s.ys++; - }; + } s.xs = (s.xs + 1) & ~1; s.ys = (s.ys + 1) & ~1; for (int x = s.x; x < s.x + s.xs; x += 2) for (int y = s.y; y < s.y + s.ys; y += 2) { sqr *o[4]; @@ -142,11 +142,11 @@ // to somehow // take into // account middle // vertices on // higher mips - }; + } if (fh < floor) floor = fh; // take lowest floor and // highest ceil, so we // never have to see @@ -155,11 +155,11 @@ if (ch > ceil) ceil = ch; } r->floor = floor; r->ceil = ceil; - }; + } if (r->type == CORNER) goto mip; // special case: don't ever split even // if textures etc are different r->defer = 1; if (SOLID(r)) { @@ -216,20 +216,20 @@ o[1]->vdelta - o[2]->vdelta != o[2]->vdelta - SWS(w, x + 1, y + 2, ws) ->vdelta) goto c; - }; - }; + } + } { loopi(4) if (o[i]->defer) goto c; - }; // if any of the constituents is not perfect, then - // this one isn't either + } // if any of the constituents is not perfect, then + // this one isn't either mip: r->defer = 0; c:; - }; + } s.x /= 2; s.y /= 2; s.xs /= 2; s.ys /= 2; remip(s, level + 1); @@ -265,11 +265,11 @@ OFVector3D v = OFMakeVector3D(e.x, e.y, e.z); vdist(dist, t, player1->o, v); if (dist < bdist) { best = i; bdist = dist; - }; + } } return bdist == 99999 ? -1 : best; } void @@ -289,11 +289,11 @@ ents[e].attr3 += amount; break; case 3: ents[e].attr4 += amount; break; - }; + } } void delent() { @@ -324,12 +324,12 @@ entity * newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4) { int type = findtype(what); - persistent_entity e = {(short)x, (short)y, (short)z, (short)v1, - (uchar)type, (uchar)v2, (uchar)v3, (uchar)v4}; + persistent_entity e = { (short)x, (short)y, (short)z, (short)v1, + (uchar)type, (uchar)v2, (uchar)v3, (uchar)v4 }; switch (type) { case LIGHT: if (v1 > 32) v1 = 32; if (!v1) @@ -345,11 +345,11 @@ case TELEDEST: e.attr2 = (uchar)e.attr1; case PLAYERSTART: e.attr1 = (int)player1->yaw; break; - }; + } addmsg(1, 10, SV_EDITENT, ents.length(), type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4); ents.add(*((entity *)&e)); // unsafe! if (type == LIGHT) calclight(); @@ -397,11 +397,11 @@ e.attr1 = 32; if (intens) { scalecomp(e.attr2, intens); scalecomp(e.attr3, intens); scalecomp(e.attr4, intens); - }; + } } calclight(); } COMMAND(scalelights, ARG_2INT) @@ -443,11 +443,11 @@ sqr *oldworld = world; bool copy = false; if (oldworld && factor < 0) { factor = sfactor + 1; copy = true; - }; + } if (factor < SMALLEST_FACTOR) factor = SMALLEST_FACTOR; if (factor > LARGEST_FACTOR) factor = LARGEST_FACTOR; setupworld(factor); @@ -486,11 +486,11 @@ strn0cpy(hdr.maptitle, "Untitled Map by Unknown", 128); hdr.waterlevel = -100000; loopi(15) hdr.reserved[i] = 0; loopk(3) loopi(256) hdr.texlists[k][i] = i; ents.setsize(0); - block b = {8, 8, ssize - 16, ssize - 16}; + block b = { 8, 8, ssize - 16, ssize - 16 }; edittypexy(SPACE, b); } calclight(); startmap(@"base/unnamed"); Index: src/worldlight.mm ================================================================== --- src/worldlight.mm +++ src/worldlight.mm @@ -97,11 +97,11 @@ x += stepx; y += stepy; l -= stepl; stepl -= 25; } - }; + } } else // the old (white) light code, here for the few people with old // video cards that don't support overbright { loopi(steps) { @@ -113,11 +113,11 @@ return; x += stepx; y += stepy; l -= stepl; } - }; + } } void calclightsource(persistent_entity &l) { @@ -132,15 +132,15 @@ const float s = 0.8f; for (float sx2 = (float)sx; sx2 <= ex; sx2 += s * 2) { lightray(sx2, (float)sy, l); lightray(sx2, (float)ey, l); - }; + } for (float sy2 = sy + s; sy2 <= ey - s; sy2 += s * 2) { lightray((float)sx, sy2, l); lightray((float)ex, sy2, l); - }; + } rndtime(); } void @@ -178,11 +178,11 @@ entity &e = ents[i]; if (e.type == LIGHT) calclightsource(e); } - block b = {1, 1, ssize - 2, ssize - 2}; + block b = { 1, 1, ssize - 2, ssize - 2 }; postlightarea(b); setvar(@"fullbright", 0); } VARP(dynlight, 0, 16, 32); @@ -211,12 +211,12 @@ return; if (v.x < 0 || v.y < 0 || v.x > ssize || v.y > ssize) return; int creach = reach + 16; // dependant on lightray random offsets! - block b = {(int)v.x - creach, (int)v.y - creach, creach * 2 + 1, - creach * 2 + 1}; + block b = { (int)v.x - creach, (int)v.y - creach, creach * 2 + 1, + creach * 2 + 1 }; if (b.x < 1) b.x = 1; if (b.y < 1) b.y = 1; @@ -225,12 +225,12 @@ if (b.ys + b.y > ssize - 2) b.ys = ssize - 2 - b.y; dlights.add(blockcopy(b)); // backup area before rendering in dynlight - persistent_entity l = {(short)v.x, (short)v.y, (short)v.z, (short)reach, - LIGHT, (uchar)strength, 0, 0}; + persistent_entity l = { (short)v.x, (short)v.y, (short)v.z, + (short)reach, LIGHT, (uchar)strength, 0, 0 }; calclightsource(l); postlightarea(b); } // utility functions also used by editing code Index: src/worldocull.mm ================================================================== --- src/worldocull.mm +++ src/worldocull.mm @@ -55,29 +55,26 @@ dx = ray - 6; dy = -1; } else { dx = 1; dy = ray > 4 ? ray - 8 : ray; - }; + } float sx = vx; float sy = vy; for (;;) { sx += dx; sy += dy; - if (SOLID(S(fast_f2nat(sx), - fast_f2nat( - sy)))) // 90% of time spend in this - // function is on this line - { + // 90% of time spend in this function is on this + // line + if (SOLID(S(fast_f2nat(sx), fast_f2nat(sy)))) { rdist[i] = (float)(fabs(sx - vx) + fabs(sy - vy)); break; - }; - }; - } else { + } + } + } else rdist[i] = 2; - }; } } // test occlusion for a cube... one of the most computationally expensive // functions in the engine as its done for every cube and entity, but its effect @@ -150,13 +147,12 @@ 4; } // D } else { h = ca(cy + csize - vy, -(cx + csize - vx)) + 2; l = ca(cy - vy, -(cx - vx)) + 2; - }; // F - } else // BG - { + } // F + } else { // BG if (cy <= vy) { if (cy + csize < vy) { h = ma(-(cy + csize - vy), cx - vx) + 6; l = ma(-(cy + csize - vy), cx + csize - vx) + @@ -165,12 +161,12 @@ else return 0; } else { h = ma(cy - vy, -(cx + csize - vx)) + 2; l = ma(cy - vy, -(cx - vx)) + 2; - }; // G - }; + } // G + } } else // CEH { if (cy <= vy) // CE { if (cy + csize < vy) { @@ -178,26 +174,26 @@ l = ca(-(cy + csize - vy), cx + csize - vx) + 6; } // C else { h = ma(cx - vx, cy - vy); l = ma(cx - vx, cy + csize - vy); - }; // E + } // E } else { h = ca(cx + csize - vx, cy - vy); l = ca(cx - vx, cy + csize - vy); - }; // H - }; + } // H + } int si = fast_f2nat(h * (NUMRAYS / 8)) + NUMRAYS; // get indexes into occlusion map from angles int ei = fast_f2nat(l * (NUMRAYS / 8)) + NUMRAYS + 1; if (ei <= si) ei += NUMRAYS; for (int i = si; i <= ei; i++) { if (dist < rdist[i & (NUMRAYS - 1)]) - return 0; // if any value in this segment of the - // occlusion map is further away then cube is - // not occluded - }; + // if any value in this segment of the occlusion map is + // further away then cube is not occluded + return 0; + } return 1; // cube is entirely occluded } Index: src/worldrender.mm ================================================================== --- src/worldrender.mm +++ src/worldrender.mm @@ -12,22 +12,22 @@ float c1 = s->floor; float c2 = s->floor; if (s->type == FHF) { c1 -= d1->vdelta / 4.0f; c2 -= d2->vdelta / 4.0f; - }; + } float f1 = s->ceil; float f2 = s->ceil; if (s->type == CHF) { f1 += d1->vdelta / 4.0f; f2 += d2->vdelta / 4.0f; - }; + } // if(f1-c1<=0 && f2-c2<=0) return; render_square(o->wtex, c1, c2, f1, f2, x1 << mip, y1 << mip, x2 << mip, y2 << mip, 1 << mip, d1, d2, topleft); return; - }; + } { float f1 = s->floor; float f2 = s->floor; float c1 = o->floor; float c2 = o->floor; @@ -41,11 +41,11 @@ } if (f1 >= c1 && f2 >= c2) goto skip; render_square(o->wtex, f1, f2, c1, c2, x1 << mip, y1 << mip, x2 << mip, y2 << mip, 1 << mip, d1, d2, topleft); - }; + } skip: { float f1 = o->ceil; float f2 = o->ceil; float c1 = s->ceil; float c2 = s->ceil; @@ -58,11 +58,11 @@ } if (c1 <= f1 && c2 <= f2) return; render_square(o->utex, f1, f2, c1, c2, x1 << mip, y1 << mip, x2 << mip, y2 << mip, 1 << mip, d1, d2, topleft); -}; +} } const int MAX_MIP = 5; // 32x32 unit blocks const int MIN_LOD = 2; const int LOW_LOD = 25; @@ -92,21 +92,21 @@ case CORNER: case SOLID: break; default: return true; - }; + } switch (SWS(w, x + x2, y + y2, msize)->type) { case SEMISOLID: if (issemi(mip, x + x2, y + y2, x1, y1, x2, y2)) return true; case CORNER: case SOLID: break; default: return true; - }; + } return false; } bool render_floor, render_ceil; @@ -129,26 +129,26 @@ int ly = vyy - lodtop; int rx = vxx + lodright; int ry = vyy + lodbot; float fsize = (float)(1 << mip); - for (int ox = x; ox < xs; ox++) - for (int oy = y; oy < ys; - oy++) // first collect occlusion information for this block - { + for (int ox = x; ox < xs; ox++) { + // first collect occlusion information for this block + for (int oy = y; oy < ys; oy++) { SWS(w, ox, oy, sz)->occluded = isoccluded(player1->o.x, player1->o.y, (float)(ox << mip), (float)(oy << mip), fsize); - }; + } + } int pvx = (int)vx >> mip; int pvy = (int)vy >> mip; if (pvx >= 0 && pvy >= 0 && pvx < sz && pvy < sz) { // SWS(w,vxx,vyy,sz)->occluded = 0; SWS(w, pvx, pvy, sz)->occluded = 0; // player cell never occluded - }; + } #define df(x) s->floor - (x->vdelta / 4.0f) #define dc(x) s->ceil + (x->vdelta / 4.0f) // loop through the rect 3 times (for floor/ceil/walls seperately, to @@ -193,29 +193,27 @@ if (s->type == CHF) // if(s->ceil>=vh) render_flatdelta(s->ctex, xx << mip, yy << mip, 1 << mip, dc(s), dc(t), dc(u), dc(v), s, t, u, v, true); } } -; LOOPH continue; // floors LOOPD if ((s->type == SPACE || s->type == CHF) && s->floor <= vh && render_floor) { render_flat(s->ftex, xx << mip, yy << mip, 1 << mip, s->floor, s, t, u, v, false); if (s->floor < hdr.waterlevel && !SOLID(s)) addwaterquad(xx << mip, yy << mip, 1 << mip); -}; +} if (s->type == FHF) { render_flatdelta(s->ftex, xx << mip, yy << mip, 1 << mip, df(s), df(t), df(u), df(v), s, t, u, v, false); if (s->floor - s->vdelta / 4.0f < hdr.waterlevel && !SOLID(s)) addwaterquad(xx << mip, yy << mip, 1 << mip); -}; +} } } -; LOOPH continue; // walls LOOPD // w // zSt @@ -236,20 +234,20 @@ v, false); topleft = false; } else if (SOLID(v)) { render_wall(v, h2 = s, xx, yy, xx + 1, yy + 1, mip, s, u, false); - }; + } } else if (SOLID(t)) { if (SOLID(w)) { render_wall(w, h1 = s, xx + 1, yy + 1, xx, yy, mip, u, s, false); } else if (SOLID(v)) { render_wall(v, h1 = s, xx, yy + 1, xx + 1, yy, mip, v, t, false); topleft = false; - }; + } } else { normalwall = false; bool wv = w->ceil - w->floor < v->ceil - v->floor; if (z->ceil - z->floor < t->ceil - t->floor) { if (wv) { @@ -257,22 +255,22 @@ yy + 1, mip, t, v, false); topleft = false; } else { render_wall(h1 = s, h2 = w, xx, yy, xx + 1, yy + 1, mip, s, u, false); - }; + } } else { if (wv) { render_wall(h2 = s, h1 = v, xx + 1, yy + 1, xx, yy, mip, u, s, false); } else { render_wall(h2 = s, h1 = w, xx, yy + 1, xx + 1, yy, mip, v, t, false); topleft = false; - }; - }; - }; + } + } + } render_tris( xx << mip, yy << mip, 1 << mip, topleft, h1, h2, s, t, u, v); } if (normalwall) { @@ -292,16 +290,14 @@ render_wall(s, w, xx, yy, xx + 1, yy, mip, s, t, false); if (yy <= vyy && inner && !SOLID(v) && (!SOLID(s) || v->type != CORNER) && (v->type != SEMISOLID || issemi(mip, xx, yy + 1, 0, 0, 1, 0))) render_wall(s, v, xx, yy + 1, xx + 1, yy + 1, mip, v, u, true); -}; +} +} } } -; -} -; void distlod(int &low, int &high, int angle, float widef) { float f = 90.0f / lod / widef; @@ -323,18 +319,17 @@ loopi(LARGEST_FACTOR) stats[i] = 0; min_lod = MIN_LOD + abs(pitch) / 12; yaw = 360 - yaw; float widef = fov / 75.0f; int cdist = abs(yaw % 90 - 45); - if (cdist < 7) // hack to avoid popup at high fovs at 45 yaw - { - min_lod = max(min_lod, - (int)(MIN_LOD + - (10 - cdist) / 1.0f * - widef)); // less if lod worked better + // hack to avoid popup at high fovs at 45 yaw + if (cdist < 7) { + // less if lod worked better + min_lod = + max(min_lod, (int)(MIN_LOD + (10 - cdist) / 1.0f * widef)); widef = 1.0f; - }; + } lod = MAX_LOD; lodtop = lodbot = lodleft = lodright = min_lod; if (yaw > 45 && yaw <= 135) { lodleft = lod; distlod(lodtop, lodbot, yaw - 45, widef); @@ -346,14 +341,14 @@ distlod(lodbot, lodtop, yaw - 225, widef); } else { lodtop = lod; distlod( lodright, lodleft, yaw <= 45 ? yaw + 45 : yaw - 315, widef); - }; + } float hyfov = fov * h / w / 2; render_floor = pitch < hyfov; render_ceil = -pitch < hyfov; render_seg_new( vx, vy, vh, MAX_MIP, 0, 0, ssize >> MAX_MIP, ssize >> MAX_MIP); mipstats(stats[0], stats[1], stats[2]); }