From a28209edcfdf8fe649b913c2f2c8662d81fc357b Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 8 Mar 2025 03:05:16 +0000 Subject: [PATCH] More style cleanup FossilOrigin-Name: 753ff34122c906fdba43b8c382ac52cc9f0ac3ce585ec9f4db6b1dc1f21ef86a --- src/.clang-format | 3 + src/Cube.mm | 21 +++-- src/client.mm | 12 +-- src/clientextras.mm | 11 +-- src/clientgame.mm | 24 +++--- src/clients2c.mm | 6 +- src/editing.mm | 51 +++++------ src/entities.mm | 69 ++++++--------- src/monster.mm | 145 ++++++++++++++++--------------- src/physics.mm | 55 ++++++------ src/rendercubes.mm | 38 ++++----- src/renderextras.mm | 62 +++++++------- src/rendergl.mm | 25 +++--- src/renderparticles.mm | 23 ++--- src/rendertext.mm | 188 ++++++++++++++++++++--------------------- src/rndmap.mm | 5 +- src/savegamedemo.mm | 2 +- src/server.mm | 51 ++++++----- src/serverbrowser.mm | 12 +-- src/serverms.mm | 17 ++-- src/serverutil.mm | 53 ++++++------ src/sound.mm | 10 +-- src/weapon.mm | 20 ++--- src/world.mm | 40 ++++----- src/worldlight.mm | 18 ++-- src/worldocull.mm | 40 ++++----- src/worldrender.mm | 63 +++++++------- 27 files changed, 525 insertions(+), 539 deletions(-) diff --git a/src/.clang-format b/src/.clang-format index ae1c442..51abc50 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -21,6 +21,8 @@ AlwaysBreakAfterReturnType: AllDefinitions AlignAfterOpenBracket: DontAlign AlignEscapedNewlines: Left AlignOperands: DontAlign +Cpp11BracedListStyle: false +SpaceBeforeCpp11BracedList: true ObjCBlockIndentWidth: 8 ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true @@ -34,6 +36,7 @@ ObjCPropertyAttributeOrder: [ ] SpaceBeforeInheritanceColon: false QualifierAlignment: Left +MaxEmptyLinesToKeep: 1 #RemoveEmptyLinesInUnwrappedLines: true RemoveSemicolon: true CompactNamespaces: true diff --git a/src/Cube.mm b/src/Cube.mm index f6847b3..37a1635 100644 --- a/src/Cube.mm +++ b/src/Cube.mm @@ -29,15 +29,18 @@ VARP(minmillis, 0, 5, 1000); #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; diff --git a/src/client.mm b/src/client.mm index 411f2b9..eeb64de 100644 --- a/src/client.mm +++ b/src/client.mm @@ -90,7 +90,7 @@ connects(OFString *servername) 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) { @@ -120,14 +120,14 @@ disconnect(int onlyclean, int async) 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"); @@ -385,8 +385,8 @@ gets2c() // get updates from the server conoutf(@"could not connect to server"); disconnect(); return; - }; - }; + } + } while ( clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0) switch (event.type) { diff --git a/src/clientextras.mm b/src/clientextras.mm index d564dba..ac9dc01 100644 --- a/src/clientextras.mm +++ b/src/clientextras.mm @@ -8,9 +8,10 @@ // 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) @@ -37,8 +38,8 @@ renderclient(dynent *d, bool team, OFString *mdlname, bool hellpig, float scale) 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; diff --git a/src/clientgame.mm b/src/clientgame.mm index 0cdf866..d7ff44d 100644 --- a/src/clientgame.mm +++ b/src/clientgame.mm @@ -70,7 +70,7 @@ spawnstate(dynent *d) // reset player state not persistent accross spawns 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; @@ -80,8 +80,8 @@ spawnstate(dynent *d) // reset player state not persistent accross spawns if (gun1 != gun2) { baseammo(gun2); break; - }; - }; + } + } } else if (m_arena) // insta arena { d->ammo[GUN_RIFLE] = 100; @@ -89,12 +89,12 @@ spawnstate(dynent *d) // reset player state not persistent accross spawns { loopi(4) baseammo(i + 1); d->gunselect = GUN_CG; - }; + } d->ammo[GUN_CG] /= 2; - }; + } } else { d->ammo[GUN_SG] = 5; - }; + } } dynent * @@ -144,7 +144,7 @@ arenacount(dynent *d, int &alive, int &dead, char *&lastteam, bool &oneteam) lastteam = d->team; } else { dead++; - }; + } } int arenarespawnwait = 0; @@ -178,8 +178,8 @@ arenarespawn() arenarespawnwait = lastmillis + 5000; arenadetectwait = lastmillis + 10000; player1->roll = 0; - }; - }; + } + } } void @@ -201,7 +201,7 @@ otherplayers() 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( @@ -273,7 +273,7 @@ updateworld(int millis) // main game update loop } else if (!intermission) { moveplayer(player1, 20, true); checkitems(); - }; + } c2sinfo(player1); // do this last, to reduce the // effective frame lag } @@ -319,7 +319,7 @@ spawnplayer(dynent *d) // place at random spawn. also used by monsters! } else { d->o.x = d->o.y = (float)ssize / 2; d->o.z = 4; - }; + } entinmap(d); spawnstate(d); d->state = CS_ALIVE; diff --git a/src/clients2c.mm b/src/clients2c.mm index 5aba279..c62f485 100644 --- a/src/clients2c.mm +++ b/src/clients2c.mm @@ -46,12 +46,12 @@ updatepos(dynent *d) 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 @@ -301,7 +301,7 @@ localservertoclient( 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); diff --git a/src/editing.mm b/src/editing.mm index 60c5a27..7d0e2fe 100644 --- a/src/editing.mm +++ b/src/editing.mm @@ -14,11 +14,11 @@ 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), }; }); } @@ -39,7 +39,7 @@ bool selset = false; int cx, cy, ch; -int curedittex[] = {-1, -1, -1}; +int curedittex[] = { -1, -1, -1 }; bool dragging = false; int lastx, lasty, lasth; @@ -118,7 +118,7 @@ noselection() 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(); @@ -127,8 +127,8 @@ selectpos(int x, int y, int xs, int ys) 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(); @@ -164,8 +164,8 @@ cursorupdate() // called every frame from hud 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; @@ -174,7 +174,7 @@ cursorupdate() // called every frame from hud if (OUTBORD(cx, cy)) return; - }; + } if (dragging) makesel(); @@ -187,7 +187,7 @@ cursorupdate() // called every frame from hud // 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; @@ -204,7 +204,7 @@ cursorupdate() // called every frame from hud 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)) @@ -215,24 +215,25 @@ cursorupdate() // called every frame from hud 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 @@ -316,7 +317,7 @@ tofronttex() // maintain most recently used of the texture lists when applying p[a + 1] = p[a]; p[0] = t; curedittex[i] = -1; - }; + } } } @@ -329,7 +330,7 @@ editdrag(bool isdown) lasth = ch; selset = false; tofronttex(); - }; + } makesel(); } @@ -390,7 +391,7 @@ edittex(int type, int dir) if (type != lasttype) { tofronttex(); lasttype = type; - }; + } int atype = type == 3 ? 1 : type; int i = curedittex[atype]; i = i < 0 ? 0 : i + dir; @@ -424,9 +425,9 @@ replace() if (s->utex == rtex.utex) s->utex = lasttex; break; - }; + } } - block b = {0, 0, ssize, ssize}; + block b = { 0, 0, ssize, ssize }; remip(b); } @@ -526,7 +527,7 @@ 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; @@ -587,7 +588,7 @@ VARF( if (noteditmode()) return; loopi(mipsize) world[i].r = world[i].g = world[i].b = 176; - };); + }); void edittag(int tag) diff --git a/src/entities.mm b/src/entities.mm index e2971df..dcf0730 100644 --- a/src/entities.mm +++ b/src/entities.mm @@ -7,16 +7,16 @@ 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; @@ -63,7 +63,7 @@ renderentities() sin(lastmillis / 100.0 + e.x + e.y) / 20), lastmillis / 10.0f); - } else + } else { switch (e.attr2) { case 1: case 3: @@ -99,41 +99,24 @@ renderentities() : 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 @@ -233,8 +216,8 @@ teleport(int n, dynent *d) // also used by monsters entinmap(d); playsoundc(S_TELEPORT); break; - }; - }; + } + } } void @@ -294,7 +277,7 @@ pickup(int n, dynent *d) lastteleport = lastmillis; teleport(n, d); break; - }; + } case JUMPPAD: { static int lastjumppad = 0; diff --git a/src/monster.mm b/src/monster.mm index 58d4dd7..94152d1 100644 --- a/src/monster.mm +++ b/src/monster.mm @@ -31,22 +31,22 @@ struct monstertype // see docs for how these values modify behaviour } 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 * @@ -90,11 +90,12 @@ 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); } @@ -122,7 +123,7 @@ monsterclear() // called after map start of when toggling edit mode to entinmap(m); monstertotal++; } - }; + } } bool @@ -158,7 +159,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz, x += dx / (float)steps; y += dy / (float)steps; i++; - }; + } return i >= steps; } @@ -203,7 +204,7 @@ monsteraction( 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 { @@ -214,29 +215,25 @@ monsteraction( 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 * @@ -266,9 +263,9 @@ monsteraction( (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 @@ -277,7 +274,7 @@ monsteraction( 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 @@ -305,11 +302,11 @@ monsteraction( { transition(m, M_HOME, 1, monstertypes[m->mtype].rate, 0); - }; - }; - }; + } + } + } break; - }; + } moveplayer(m, 1, false); // use physics to move monster } @@ -317,24 +314,25 @@ monsteraction( 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; @@ -344,9 +342,8 @@ monsterpain(dynent *m, int damage, dynent *d) 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 @@ -368,7 +365,7 @@ monsterthink() conoutf(@"The invasion has begun!"); nextmonster = lastmillis + 1000; spawnmonster(); - }; + } if (monstertotal && !spawnremain && numkilled == monstertotal) endsp(true); @@ -383,20 +380,22 @@ monsterthink() continue; OFVector3D v = OFMakeVector3D(e.x, e.y, (float)S(e.x, e.y)->floor); - loopv(monsters) if (monsters[i]->state == CS_DEAD) + loopv(monsters) { - 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]); + 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]); + } } } diff --git a/src/physics.mm b/src/physics.mm index 83520a3..8845467 100644 --- a/src/physics.mm +++ b/src/physics.mm @@ -29,7 +29,7 @@ plcollide(dynent *d, dynent *o, float &headspace, float &hi, headspace = d->o.z - o->o.z - o->aboveeye - d->eyeheight; if (headspace < 0) headspace = 10; - }; + } return true; } @@ -49,7 +49,7 @@ cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by, by = y << mip; bs = 1 << mip; return cornertest(mip, x, y, dx, dy, bx, by, bs); - }; + } return stest; } @@ -132,7 +132,7 @@ collide(dynent *d, bool spawn, float drop, float rise) fx2 - bx + fy2 - by >= bs) return false; break; - }; + } case FHF: // FIXME: too simplistic collision with // slopes, makes it feels like tiny stairs @@ -147,14 +147,14 @@ collide(dynent *d, bool spawn, float drop, float rise) 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; @@ -194,7 +194,7 @@ collide(dynent *d, bool spawn, float drop, float rise) return false; } else { d->o.z -= min(min(drop, space), headspace); // gravity - }; + } const float space2 = hi - (d->o.z + d->aboveeye); if (space2 < 0) { @@ -202,10 +202,10 @@ collide(dynent *d, bool spawn, float drop, float rise) 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; } @@ -229,7 +229,7 @@ physicsframe() // optimally schedule physics frames inside the graphics frames physicsfraction = faketime - physicsrepeat * MINFRAMETIME; } else { physicsrepeat = 1; - }; + } } // main physics routine, moves a player/monster for a curtime step @@ -252,7 +252,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) 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))); @@ -287,37 +287,38 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) 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 / @@ -337,14 +338,14 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) 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; @@ -353,11 +354,11 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) 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 @@ -369,7 +370,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) 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 @@ -381,7 +382,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime) pl->roll = (float)maxroll; if (pl->roll < -maxroll) pl->roll = (float)-maxroll; - }; + } // play sounds on water transitions diff --git a/src/rendercubes.mm b/src/rendercubes.mm index 6b95868..60ed42d 100644 --- a/src/rendercubes.mm +++ b/src/rendercubes.mm @@ -47,7 +47,7 @@ reallocv() v.g = ls->g; \ v.b = ls->b; \ v.a = 255; \ - }; + } #define vert(v1, v2, v3, ls, t1, t2) \ { \ @@ -81,8 +81,8 @@ mipstats(int a, int b, int c) if (floorstrip || deltastrip) { \ addstrip(ogltex, firstindex, curvert - firstindex); \ floorstrip = deltastrip = false; \ - }; \ - }; + } \ + } void finishstrips() { @@ -100,7 +100,7 @@ render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); @@ -128,7 +128,7 @@ render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, } 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; @@ -157,8 +157,8 @@ render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, ol4r = p4[0]; ol4g = p4[1]; ol4b = p4[2]; - }; - }; + } + } if (isceil) { vert(x + size, h, y + size, l3, xo + xs, yo + ys); @@ -166,7 +166,7 @@ render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, } else { vert(x, h, y + size, l4, xo, yo + ys); vert(x + size, h, y + size, l3, xo + xs, yo + ys); - }; + } oy = y; nquads++; @@ -181,7 +181,7 @@ render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); @@ -207,14 +207,14 @@ render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, } 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( @@ -224,7 +224,7 @@ render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, 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++; @@ -276,7 +276,7 @@ render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s, if (h2) render_2tris(h2, s, x + size, y, x + size, y + size, x, y + size, t, u, v); - }; + } } void @@ -289,7 +289,7 @@ render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, if (showm) { l1 = &sbright; l2 = &sdark; - }; + } int sx, sy; int gltex = lookuptexture(wtex, &sx, &sy); @@ -308,7 +308,7 @@ render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, 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); @@ -375,17 +375,17 @@ renderwater(float hf) 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); @@ -412,7 +412,7 @@ addwaterquad(int x, int y, int size) // update bounding rect that contains water wx2 = x2; if (y2 > wy2) wy2 = y2; - }; + } } void diff --git a/src/renderextras.mm b/src/renderextras.mm index 78ea525..35881fd 100644 --- a/src/renderextras.mm +++ b/src/renderextras.mm @@ -98,7 +98,7 @@ newsphere(OFVector3D &o, float max, int type) sempty = &spheres[i]; } sinit = true; - }; + } if (sempty) { sphere *p = sempty; sempty = p->next; @@ -108,7 +108,7 @@ newsphere(OFVector3D &o, float max, int type) p->type = type; p->next = slist; slist = p; - }; + } } void @@ -139,8 +139,8 @@ renderspheres(int time) } else { p->size += time / 100.0f; pp = &p->next; - }; - }; + } + } glDisable(GL_BLEND); glDepthMask(GL_TRUE); @@ -148,29 +148,29 @@ renderspheres(int time) 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 @@ -210,8 +210,8 @@ loadsky(OFString *basename) 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) { @@ -336,7 +336,7 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); cursorupdate(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - }; + } glDisable(GL_DEPTH_TEST); invertperspective(); @@ -442,7 +442,7 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) if (g > 2) { g -= 3; r = 128; - }; + } drawicon((float)(g * 64), (float)r, 1220, 1650); glPopMatrix(); } diff --git a/src/rendergl.mm b/src/rendergl.mm index 5336a89..026ba5f 100644 --- a/src/rendergl.mm +++ b/src/rendergl.mm @@ -110,8 +110,13 @@ installtex(int tnum, OFIRI *IRI, int *xs, int *ys, bool clamp) } } - // 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, @@ -264,7 +269,7 @@ setupworld() glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - }; + } } int skyoglid; @@ -350,8 +355,8 @@ 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) @@ -382,7 +387,7 @@ drawhudgun(float fovy, float aspect, int farplane) drawhudmodel(7, 18, rtime / 18.0f, player1->lastaction); } else { drawhudmodel(6, 1, 100, 0); - }; + } glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -402,9 +407,9 @@ gl_drawframe(int w, int h, float curfps) 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); @@ -413,7 +418,7 @@ gl_drawframe(int w, int h, float curfps) 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); diff --git a/src/renderparticles.mm b/src/renderparticles.mm index 76ecdae..375c5af 100644 --- a/src/renderparticles.mm +++ b/src/renderparticles.mm @@ -25,7 +25,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type) parempty = &particles[i]; } parinit = true; - }; + } if (parempty) { particle *p = parempty; parempty = p->next; @@ -36,7 +36,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type) p->millis = lastmillis; p->next = parlist; parlist = p; - }; + } } VAR(demotracking, 0, 0, 1); @@ -69,15 +69,16 @@ render_particles(int time) 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; diff --git a/src/rendertext.mm b/src/rendertext.mm index 055ac51..d9b4a8f 100644 --- a/src/rendertext.mm +++ b/src/rendertext.mm @@ -3,100 +3,100 @@ #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 diff --git a/src/rndmap.mm b/src/rndmap.mm index 40638e7..481303c 100644 --- a/src/rndmap.mm +++ b/src/rndmap.mm @@ -73,7 +73,7 @@ perlinarea(block &b, int scale, int seed, int psize) 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) @@ -85,5 +85,6 @@ perlinarea(block &b, int scale, int seed, int psize) 25); if (s->vdelta > 128) s->vdelta = 0; - }; + } + } } diff --git a/src/savegamedemo.mm b/src/savegamedemo.mm index 4bbef55..e77487d 100644 --- a/src/savegamedemo.mm +++ b/src/savegamedemo.mm @@ -71,7 +71,7 @@ stop() if (demorecording) gzputi(-1); gzclose(f); - }; + } f = NULL; demorecording = false; demoplayback = false; diff --git a/src/server.mm b/src/server.mm index 1789264..17dbe58 100644 --- a/src/server.mm +++ b/src/server.mm @@ -20,8 +20,8 @@ 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; }; @@ -68,12 +68,12 @@ send(int n, ENetPacket *packet) enet_peer_send(clients[n].peer, 0, packet); bsend += packet->dataLength; break; - }; + } case ST_LOCAL: localservertoclient(packet->data, packet->dataLength); break; - }; + } } void @@ -137,7 +137,7 @@ pickup(uint i, int sec, int sender) // server side item pickup, acknowledge sents[i].spawned = false; sents[i].spawnsecs = sec; send2(true, sender, SV_ITEMACC, i); - }; + } } void @@ -190,7 +190,7 @@ process(ENetPacket *packet, int sender) // sender may be -1 packet->dataLength) { disconnect_client(sender, "packet length"); return; - }; + } uchar *end = packet->data + packet->dataLength; uchar *p = packet->data + 2; @@ -235,11 +235,11 @@ process(ENetPacket *packet, int sender) // sender may be -1 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; } @@ -260,7 +260,7 @@ process(ENetPacket *packet, int sender) // sender may be -1 clients[cn].type == ST_EMPTY) { disconnect_client(sender, "client num"); return; - }; + } int size = msgsizelookup(type); assert(size != -1); loopi(size - 2) getint(p); @@ -286,22 +286,22 @@ process(ENetPacket *packet, int sender) // sender may be -1 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); } @@ -365,7 +365,7 @@ checkintermission() if (!minremain) { interm = lastsec + 10; mapend = lastsec + 1000; - }; + } send2(true, -1, SV_TIMEUP, minremain--); } @@ -406,7 +406,7 @@ serverslice(int seconds, sents[i].spawnsecs = 0; sents[i].spawned = true; send2(true, -1, SV_ITEMSPAWN, i); - }; + } } lastsec = seconds; @@ -423,7 +423,7 @@ serverslice(int seconds, mapreload = true; break; } - }; + } resetserverifempty(); @@ -448,7 +448,7 @@ serverslice(int seconds, nonlocalclients, bsend / 60.0f / 1024, brec / 60.0f / 1024); bsend = brec = 0; - }; + } ENetEvent event; if (enet_host_service(serverhost, &event, timeout) > 0) { @@ -484,12 +484,11 @@ serverslice(int seconds, 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 @@ -528,7 +527,7 @@ initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip, 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) @@ -542,8 +541,8 @@ initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip, 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 @@ -553,5 +552,5 @@ initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip, atexit(enet_deinitialize); for (;;) serverslice(/*enet_time_get_sec()*/ time(NULL), 5); - }; + } } diff --git a/src/serverbrowser.mm b/src/serverbrowser.mm index 1862046..53cb6f6 100644 --- a/src/serverbrowser.mm +++ b/src/serverbrowser.mm @@ -36,7 +36,7 @@ resolverloop(void *data) 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(); @@ -45,7 +45,7 @@ resolverloop(void *data) rt->query = NULL; rt->starttime = 0; SDL_UnlockMutex(resolvermutex); - }; + } return 0; } @@ -125,8 +125,8 @@ resolvercheck(char **name, ENetAddress *address) *name = rt.query; SDL_UnlockMutex(resolvermutex); return true; - }; - }; + } + } } SDL_UnlockMutex(resolvermutex); return false; @@ -199,7 +199,7 @@ 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; @@ -305,7 +305,7 @@ 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(); diff --git a/src/serverms.mm b/src/serverms.mm index 9da7bb3..0d0e062 100644 --- a/src/serverms.mm +++ b/src/serverms.mm @@ -46,11 +46,11 @@ httpgetrecieve(ENetBuffer &buf) enet_socket_destroy(mssock); mssock = ENET_SOCKET_NULL; return; - }; + } buf.data = ((char *)buf.data) + len; ((char *)buf.data)[0] = 0; buf.dataLength -= len; - }; + } } uchar * @@ -62,7 +62,7 @@ stripheader(uchar *b) return s ? (uchar *)s : b; } -ENetAddress masterserver = {ENET_HOST_ANY, 80}; +ENetAddress masterserver = { ENET_HOST_ANY, 80 }; int updmaster = 0; string masterbase; string masterpath; @@ -72,9 +72,8 @@ 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"); @@ -82,7 +81,7 @@ updatemasterserver(int seconds) masterb.data = masterrep; masterb.dataLength = MAXTRANS - 1; updmaster = seconds + 60 * 60; - }; + } } void @@ -159,8 +158,8 @@ servermsinit(OFString *master_, OFString *sdesc, bool listen) 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) diff --git a/src/serverutil.mm b/src/serverutil.mm index 34ee73a..2b454ad 100644 --- a/src/serverutil.mm +++ b/src/serverutil.mm @@ -20,7 +20,7 @@ putint(uchar *&p, int n) *p++ = n >> 8; *p++ = n >> 16; *p++ = n >> 24; - }; + } } int @@ -54,20 +54,20 @@ sendstring(OFString *t_, uchar *&p) } 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 * @@ -75,16 +75,15 @@ 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) @@ -187,8 +186,8 @@ main(int argc, char *argv[]) break; default: printf("WARNING: unknown commandline option\n"); - }; - }; + } + } if (enet_initialize() < 0) fatal(@"Unable to initialise network module"); diff --git a/src/sound.mm b/src/sound.mm index dcc2e01..690bf03 100644 --- a/src/sound.mm +++ b/src/sound.mm @@ -45,13 +45,13 @@ stopsound() FMUSIC_FreeSong(mod); #endif mod = NULL; - }; + } if (stream) { #ifndef USE_MIXER FSOUND_Stream_Close(stream); #endif stream = NULL; - }; + } } VAR(soundbufferlen, 128, 1024, 4096); @@ -66,7 +66,7 @@ initsound() conoutf(@"sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); nosound = true; - }; + } Mix_AllocateChannels(MAXCHAN); #else if (FSOUND_GetVersion() < FMOD_VERSION) @@ -182,8 +182,8 @@ updatechanvol(int chan, OFVector3D *loc) 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); diff --git a/src/weapon.mm b/src/weapon.mm index e418406..a1f8cd6 100644 --- a/src/weapon.mm +++ b/src/weapon.mm @@ -13,15 +13,15 @@ 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 @@ -173,7 +173,7 @@ hit(int target, int damage, dynent *d, dynent *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); } diff --git a/src/world.mm b/src/world.mm index edcd6a6..8d97b7a 100644 --- a/src/world.mm +++ b/src/world.mm @@ -25,7 +25,7 @@ settag(int tag, int type) // set all cubes with "tag" to space, if tag is 0 then continue; } else { s->type = type ? SOLID : SPACE; - }; + } if (x > maxx) maxx = x; if (y > maxy) @@ -34,9 +34,9 @@ settag(int tag, int type) // set all cubes with "tag" to space, if tag is 0 then 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 } @@ -97,11 +97,11 @@ remip(block &b, int level) 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) @@ -144,7 +144,7 @@ remip(block &b, int level) // account middle // vertices on // higher mips - }; + } if (fh < floor) floor = fh; // take lowest floor and @@ -157,7 +157,7 @@ remip(block &b, int level) } r->floor = floor; r->ceil = ceil; - }; + } if (r->type == CORNER) goto mip; // special case: don't ever split even // if textures etc are different @@ -218,16 +218,16 @@ remip(block &b, int level) 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; @@ -267,7 +267,7 @@ closestent() // used for delent and edit mode ent display if (dist < bdist) { best = i; bdist = dist; - }; + } } return bdist == 99999 ? -1 : best; } @@ -291,7 +291,7 @@ entproperty(int prop, int amount) case 3: ents[e].attr4 += amount; break; - }; + } } void @@ -326,8 +326,8 @@ 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) @@ -347,7 +347,7 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4) 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! @@ -399,7 +399,7 @@ scalelights(int f, int intens) scalecomp(e.attr2, intens); scalecomp(e.attr3, intens); scalecomp(e.attr4, intens); - }; + } } calclight(); } @@ -445,7 +445,7 @@ empty_world( if (oldworld && factor < 0) { factor = sfactor + 1; copy = true; - }; + } if (factor < SMALLEST_FACTOR) factor = SMALLEST_FACTOR; if (factor > LARGEST_FACTOR) @@ -488,7 +488,7 @@ empty_world( 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); } diff --git a/src/worldlight.mm b/src/worldlight.mm index bebe3c3..f6818b1 100644 --- a/src/worldlight.mm +++ b/src/worldlight.mm @@ -99,7 +99,7 @@ lightray(float bx, float by, l -= stepl; stepl -= 25; } - }; + } } else // the old (white) light code, here for the few people with old // video cards that don't support overbright { @@ -115,7 +115,7 @@ lightray(float bx, float by, y += stepy; l -= stepl; } - }; + } } void @@ -134,11 +134,11 @@ calclightsource(persistent_entity &l) 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(); } @@ -180,7 +180,7 @@ calclight() calclightsource(e); } - block b = {1, 1, ssize - 2, ssize - 2}; + block b = { 1, 1, ssize - 2, ssize - 2 }; postlightarea(b); setvar(@"fullbright", 0); } @@ -213,8 +213,8 @@ dodynlight( 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; @@ -227,8 +227,8 @@ dodynlight( 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); } diff --git a/src/worldocull.mm b/src/worldocull.mm index 002c56a..52bf6b5 100644 --- a/src/worldocull.mm +++ b/src/worldocull.mm @@ -57,25 +57,22 @@ computeraytable(float vx, float vy) } 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; - }; } } @@ -152,9 +149,8 @@ isoccluded(float vx, float vy, float cx, float cy, } 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; @@ -167,8 +163,8 @@ isoccluded(float vx, float vy, float cx, float cy, } else { h = ma(cy - vy, -(cx + csize - vx)) + 2; l = ma(cy - vy, -(cx - vx)) + 2; - }; // G - }; + } // G + } } else // CEH { if (cy <= vy) // CE @@ -180,12 +176,12 @@ isoccluded(float vx, float vy, float cx, float cy, 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; @@ -194,10 +190,10 @@ isoccluded(float vx, float vy, float cx, float cy, 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 } diff --git a/src/worldrender.mm b/src/worldrender.mm index bc5856f..6b01f5c 100644 --- a/src/worldrender.mm +++ b/src/worldrender.mm @@ -14,18 +14,18 @@ render_wall(sqr *o, sqr *s, int x1, int y1, int x2, int y2, int mip, sqr *d1, 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; @@ -43,7 +43,7 @@ render_wall(sqr *o, sqr *s, int x1, int y1, int x2, int y2, int mip, sqr *d1, 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; @@ -60,7 +60,7 @@ skip: { 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 @@ -94,7 +94,7 @@ issemi(int mip, int x, int y, int x1, int y1, int x2, int y2) 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)) @@ -104,7 +104,7 @@ issemi(int mip, int x, int y, int x1, int y1, int x2, int y2) break; default: return true; - }; + } return false; } @@ -131,14 +131,14 @@ render_seg_new( 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; @@ -146,7 +146,7 @@ render_seg_new( // 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) @@ -195,7 +195,6 @@ render_seg_new( dc(t), dc(u), dc(v), s, t, u, v, true); } } -; LOOPH continue; // floors LOOPD @@ -204,16 +203,15 @@ if ((s->type == SPACE || s->type == CHF) && s->floor <= vh && render_floor) { 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 @@ -238,7 +236,7 @@ if (s->type == CORNER) { } 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, @@ -247,7 +245,7 @@ if (s->type == CORNER) { 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; @@ -259,7 +257,7 @@ if (s->type == CORNER) { } 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, @@ -268,9 +266,9 @@ if (s->type == CORNER) { 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); } @@ -294,12 +292,10 @@ if (normalwall) { (!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) @@ -325,14 +321,13 @@ render_world( 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) { @@ -348,7 +343,7 @@ render_world( 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;