Improve clang-format

FossilOrigin-Name: 6f5dd506262655e5d3a6732794f955c8476b19a80fa03d5ebb6744ed8b18c963
This commit is contained in:
Jonathan Schleifer 2025-03-08 02:38:40 +00:00
parent f904d80214
commit dd08a1069e
41 changed files with 506 additions and 493 deletions

View file

@ -1,9 +1,26 @@
IndentWidth: 8
TabWidth: 8
UseTab: ForIndentation
BreakBeforeBraces: Linux
ColumnLimit: 80
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
AlwaysBreakAfterReturnType: AllDefinitions
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: Left
AlignOperands: DontAlign
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
@ -15,5 +32,11 @@ ObjCPropertyAttributeOrder: [
atomic, nonatomic,
getter, setter
]
SpaceBeforeInheritanceColon: false
QualifierAlignment: Left
#RemoveEmptyLinesInUnwrappedLines: true
RemoveSemicolon: true
CompactNamespaces: true
SortIncludes: CaseSensitive
IndentPPDirectives: AfterHash
PPIndentWidth: 1

View file

@ -7,7 +7,8 @@ OF_APPLICATION_DELEGATE(Cube)
VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);
@implementation Cube {
@implementation Cube
{
int _width, _height;
}

View file

@ -30,7 +30,8 @@ snap(int sn, float f)
return sn ? (float)(((int)(f + sn * 0.5f)) & (~(sn - 1))) : f;
}
@implementation MD2 {
@implementation MD2
{
int _numGlCommands;
int *_glCommands;
int _numTriangles;

View file

@ -295,8 +295,8 @@ c2sinfo(dynent *d) // send update to the server
} else {
putint(p, SV_POS);
putint(p, clientnum);
putint(
p, (int)(d->o.x *
putint(p,
(int)(d->o.x *
DMF)); // quantize coordinates to 1/16th
// of a cube, between 1 and 3 bytes
putint(p, (int)(d->o.y * DMF));
@ -311,8 +311,8 @@ c2sinfo(dynent *d) // send update to the server
putint(p, (int)(d->vel.z * DVF));
// pack rest in 1 byte: strafe:2, move:2, onfloor:1,
// state:3
putint(
p, (d->strafe & 3) | ((d->move & 3) << 2) |
putint(p,
(d->strafe & 3) | ((d->move & 3) << 2) |
(((int)d->onfloor) << 4) |
((editmode ? CS_EDITING : d->state) << 5));
@ -412,4 +412,4 @@ gets2c() // get updates from the server
server_err();
return;
}
};
}

View file

@ -78,9 +78,8 @@ renderclients()
{
dynent *d;
loopv(players) if ((d = players[i]) &&
(!demoplayback || i != democlientnum))
renderclient(d, isteam(player1->team, d->team), @"monster/ogro",
false, 1.0f);
(!demoplayback || i != democlientnum)) renderclient(d,
isteam(player1->team, d->team), @"monster/ogro", false, 1.0f);
}
// creation of scoreboard pseudo-menu

View file

@ -41,7 +41,7 @@ resetmovement(dynent *d)
d->jumpnext = false;
d->strafe = 0;
d->move = 0;
};
}
void
spawnstate(dynent *d) // reset player state not persistent accross spawns
@ -95,7 +95,7 @@ spawnstate(dynent *d) // reset player state not persistent accross spawns
} else {
d->ammo[GUN_SG] = 5;
};
};
}
dynent *
newdynent() // create a new blank player or monster
@ -125,14 +125,14 @@ newdynent() // create a new blank player or monster
d->state = CS_ALIVE;
spawnstate(d);
return d;
};
}
void
respawnself()
{
spawnplayer(player1);
showscores(false);
};
}
void
arenacount(dynent *d, int &alive, int &dead, char *&lastteam, bool &oneteam)
@ -145,7 +145,7 @@ arenacount(dynent *d, int &alive, int &dead, char *&lastteam, bool &oneteam)
} else {
dead++;
};
};
}
int arenarespawnwait = 0;
int arenadetectwait = 0;
@ -180,7 +180,7 @@ arenarespawn()
player1->roll = 0;
};
};
};
}
void
zapdynent(dynent *&d)
@ -188,7 +188,7 @@ zapdynent(dynent *&d)
if (d)
free(d);
d = NULL;
};
}
extern int democlientnum;
@ -207,8 +207,8 @@ otherplayers()
moveplayer(
players[i], 2, false); // use physics to extrapolate
// player position
};
};
}
}
void
respawn()
@ -268,8 +268,7 @@ updateworld(int millis) // main game update loop
player1->move = player1->strafe = 0;
moveplayer(player1, 10, false);
} else if (!m_arena && !m_sp &&
lastmillis - player1->lastaction >
10000)
lastmillis - player1->lastaction > 10000)
respawn();
} else if (!intermission) {
moveplayer(player1, 20, true);
@ -300,7 +299,7 @@ entinmap(dynent *
conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x,
(int)d->o.y);
// leave ent at original pos, possibly stuck
};
}
int spawncycle = -1;
int fixspawn = 2;
@ -324,7 +323,7 @@ spawnplayer(dynent *d) // place at random spawn. also used by monsters!
entinmap(d);
spawnstate(d);
d->state = CS_ALIVE;
};
}
// movement input code
@ -334,7 +333,7 @@ spawnplayer(dynent *d) // place at random spawn. also used by monsters!
player1->s = isdown; \
player1->v = isdown ? d : (player1->os ? -(d) : 0); \
player1->lastmove = lastmillis; \
};
}
dir(backward, move, -1, k_down, k_up);
dir(forward, move, 1, k_up, k_down);
@ -350,14 +349,14 @@ attack(bool on)
editdrag(on);
else if (player1->attacking = on)
respawn();
};
}
void
jumpn(bool on)
{
if (!intermission && (player1->jumpnext = on))
respawn();
};
}
COMMAND(backward, ARG_DOWN)
COMMAND(forward, ARG_DOWN)
@ -379,7 +378,7 @@ fixplayer1range()
player1->yaw += 360.0f;
while (player1->yaw >= 360.0f)
player1->yaw -= 360.0f;
};
}
void
mousemove(int dx, int dy)
@ -389,10 +388,9 @@ mousemove(int dx, int dy)
const float SENSF = 33.0f; // try match quake sens
player1->yaw += (dx / SENSF) * (sensitivity / (float)sensitivityscale);
player1->pitch -= (dy / SENSF) *
(sensitivity / (float)sensitivityscale) *
(invmouse ? -1 : 1);
(sensitivity / (float)sensitivityscale) * (invmouse ? -1 : 1);
fixplayer1range();
};
}
// damage arriving from the network, monsters, yourself, all ends up here.
@ -410,8 +408,7 @@ selfdamage(int damage, int actor, dynent *act)
player1->armour -= ad;
damage -= ad;
float droll = damage / 0.5f;
player1->roll +=
player1->roll > 0
player1->roll += player1->roll > 0
? droll
: (player1->roll < 0
? -droll

View file

@ -52,7 +52,7 @@ updatepos(dynent *d)
d->plag = (d->plag * 5 + lagtime) / 6;
d->lastupdate = lastmillis;
};
};
}
void
localservertoclient(

View file

@ -78,14 +78,15 @@ renderconsole() // render buffer taking into account time & scrolling
{
int nd = 0;
char *refs[ndraw];
loopv(conlines) if (conskip ? i >= conskip - 1 ||
i >= conlines.length() - ndraw
: lastmillis - conlines[i].outtime < 20000)
loopv(conlines)
{
if (conskip ? i >= conskip - 1 || i >= conlines.length() - ndraw
: lastmillis - conlines[i].outtime < 20000) {
refs[nd++] = conlines[i].cref;
if (nd == ndraw)
break;
}
}
@autoreleasepool {
loopj(nd)
{

View file

@ -33,7 +33,7 @@ bool selset = false;
{ \
sqr *s = S(sel.x + x, sel.y + y); \
b; \
}; \
} \
remip(sel); \
}
@ -86,7 +86,7 @@ correctsel() // ensures above invariant
sel.ys = bsize - sel.y;
if (sel.xs <= 0 || sel.ys <= 0)
selset = false;
};
}
bool
noteditmode()
@ -122,7 +122,7 @@ selectpos(int x, int y, int xs, int ys)
sel = s;
selh = 0;
correctsel();
};
}
void
makesel()
@ -134,7 +134,7 @@ makesel()
correctsel();
if (selset)
rtex = *S(sel.x, sel.y);
};
}
VAR(flrceil, 0, 0, 2);
@ -143,11 +143,9 @@ sheight(
sqr *s, sqr *t, float z) // finds out z height when cursor points at wall
{
return !flrceil // z-s->floor<s->ceil-z
? (s->type == FHF ? s->floor - t->vdelta / 4.0f
: (float)s->floor)
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f
: (float)s->ceil);
};
? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor)
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f : (float)s->ceil);
}
void
cursorupdate() // called every frame from hud
@ -235,7 +233,7 @@ cursorupdate() // called every frame from hud
linestyle(GRIDS, 0xFF, 0x40, 0x40);
box(sel, (float)selh, (float)selh, (float)selh, (float)selh);
};
};
}
vector<block *> undos; // unlimited undo
VARP(undomegs, 0, 1, 10); // bounded by n megs
@ -249,15 +247,15 @@ pruneundos(int maxremain) // bound memory
t += undos[i]->xs * undos[i]->ys * sizeof(sqr);
if (t > maxremain)
free(undos.remove(i));
};
};
}
}
void
makeundo()
{
undos.add(blockcopy(sel));
pruneundos(undomegs << 20);
};
}
void
editundo()
@ -281,7 +279,7 @@ copy()
if (copybuf)
free(copybuf);
copybuf = blockcopy(sel);
};
}
void
paste()
@ -319,8 +317,8 @@ tofronttex() // maintain most recently used of the texture lists when applying
p[0] = t;
curedittex[i] = -1;
};
};
};
}
}
void
editdrag(bool isdown)
@ -333,7 +331,7 @@ editdrag(bool isdown)
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
@ -352,7 +350,7 @@ editheightxy(bool isfloor, int amount, block &sel)
if (s->ceil <= s->floor)
s->ceil = s->floor + 1;
});
};
}
void
editheight(int flr, int amount)
@ -381,7 +379,7 @@ edittexxy(int type, int t, block &sel)
s->utex = t;
break;
});
};
}
void
edittex(int type, int dir)
@ -400,7 +398,7 @@ edittex(int type, int dir)
int t = lasttex = hdr.texlists[atype][i];
edittexxy(type, t, sel);
addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t);
};
}
void
replace()
@ -427,16 +425,16 @@ replace()
s->utex = lasttex;
break;
};
};
}
block b = {0, 0, ssize, ssize};
remip(b);
};
}
void
edittypexy(int type, block &sel)
{
loopselxy(s->type = type);
};
}
void
edittype(int type)
@ -491,7 +489,7 @@ editequalisexy(bool isfloor, block &sel)
if (s->floor >= s->ceil)
s->floor = s->ceil - 1;
});
};
}
void
equalize(int flr)
@ -508,7 +506,7 @@ setvdeltaxy(int delta, block &sel)
{
loopselxy(s->vdelta = max(s->vdelta + delta, 0));
remipmore(sel);
};
}
void
setvdelta(int delta)
@ -516,7 +514,7 @@ setvdelta(int delta)
EDITSEL;
setvdeltaxy(delta, sel);
addmsg(1, 6, SV_EDITD, sel.x, sel.y, sel.xs, sel.ys, delta);
};
}
const int MAXARCHVERT = 50;
int archverts[MAXARCHVERT][MAXARCHVERT];
@ -532,7 +530,7 @@ archvertex(int span, int vert, int delta)
if (span >= MAXARCHVERT || vert >= MAXARCHVERT || span < 0 || vert < 0)
return;
archverts[span][vert] = delta;
};
}
void
arch(int sidedelta, int _a)
@ -544,14 +542,13 @@ arch(int sidedelta, int _a)
sel.xs = MAXARCHVERT;
if (sel.ys > MAXARCHVERT)
sel.ys = MAXARCHVERT;
loopselxy(
s->vdelta = sel.xs > sel.ys
loopselxy(s->vdelta = sel.xs > sel.ys
? (archverts[sel.xs - 1][x] +
(y == 0 || y == sel.ys - 1 ? sidedelta : 0))
: (archverts[sel.ys - 1][y] +
(x == 0 || x == sel.xs - 1 ? sidedelta : 0)));
remipmore(sel);
};
}
void
slope(int xd, int yd)
@ -566,7 +563,7 @@ slope(int xd, int yd)
sel.ys++;
loopselxy(s->vdelta = xd * x + yd * y + off);
remipmore(sel);
};
}
void
perlin(int scale, int seed, int psize)
@ -583,7 +580,7 @@ perlin(int scale, int seed, int psize)
remipmore(sel);
sel.xs--;
sel.ys--;
};
}
VARF(
fullbright, 0, 0, 1, if (fullbright) {
@ -597,7 +594,7 @@ edittag(int tag)
{
EDITSELMP;
loopselxy(s->tag = tag);
};
}
void
newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4)

View file

@ -27,7 +27,7 @@ renderent(entity &e, OFString *mdlname, float z, float yaw, int frame = 0,
{
rendermodel(mdlname, frame, numf, 0, 1.1f, e.x, z + S(e.x, e.y)->floor,
e.y, yaw, 0, false, 1.0f, speed, 0, basetime);
};
}
void
renderentities()
@ -59,8 +59,8 @@ renderentities()
if (e.type < I_SHELLS || e.type > TELEPORT)
continue;
renderent(e, entmdlnames[e.type - I_SHELLS],
(float)(1 + sin(lastmillis / 100.0 + e.x +
e.y) /
(float)(1 +
sin(lastmillis / 100.0 + e.x + e.y) /
20),
lastmillis / 10.0f);
} else
@ -74,8 +74,9 @@ renderentities()
if (!e.spawned)
continue;
renderent(e, @"carrot",
(float)(1 + sin(lastmillis / 100.0 +
e.x + e.y) /
(float)(1 +
sin(lastmillis / 100.0 + e.x +
e.y) /
20),
lastmillis /
(e.attr2 ? 1.0f : 10.0f));
@ -100,8 +101,8 @@ renderentities()
break;
};
};
};
};
}
}
struct itemstat {
int add, max, sound;
@ -139,7 +140,7 @@ void
baseammo(int gun)
{
player1->ammo[gun] = itemstats[gun - 1].add * 2;
};
}
// these two functions are called when the server acknowledges that you really
// picked up the item (in multiplayer someone may grab it before you).
@ -153,7 +154,7 @@ radditem(int i, int &v)
if (v > is.max)
v = is.max;
playsoundc(is.sound);
};
}
void
realpickup(int n, dynent *d)
@ -234,7 +235,7 @@ teleport(int n, dynent *d) // also used by monsters
break;
};
};
};
}
void
pickup(int n, dynent *d)
@ -357,10 +358,10 @@ void
resetspawns()
{
loopv(ents) ents[i].spawned = false;
};
}
void
setspawn(uint i, bool on)
{
if (i < (uint)ents.length())
ents[i].spawned = on;
};
}

View file

@ -84,7 +84,7 @@ basicmonster(int type, int yaw, int state, int trigger, int move)
}
monsters.add(m);
return m;
};
}
void
spawnmonster() // spawn a random monster according to freq distribution in DMSP
@ -96,7 +96,7 @@ spawnmonster() // spawn a random monster according to freq distribution in DMSP
break;
};
basicmonster(type, rnd(360), M_SEARCH, 1000, 1);
};
}
void
monsterclear() // called after map start of when toggling edit mode to
@ -121,9 +121,9 @@ monsterclear() // called after map start of when toggling edit mode to
m->o.z = ents[i].z;
entinmap(m);
monstertotal++;
}
};
};
};
}
bool
los(float lx, float ly, float lz, float bx, float by, float bz,
@ -160,7 +160,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz,
i++;
};
return i >= steps;
};
}
bool
enemylos(dynent *m, OFVector3D &v)
@ -168,7 +168,7 @@ enemylos(dynent *m, OFVector3D &v)
v = m->o;
return los(m->o.x, m->o.y, m->o.z, m->enemy->o.x, m->enemy->o.y,
m->enemy->o.z, v);
};
}
// monster AI is sequenced using transitions: they are in a particular state
// where they execute a particular behaviour until the trigger time is hit, and
@ -185,7 +185,7 @@ transition(dynent *m, int state, int moving, int n,
m->move = moving;
n = n * 130 / 100;
m->trigger = lastmillis + n - skill * (n / 16) + rnd(r + 1);
};
}
void
normalise(dynent *m, float angle)
@ -194,7 +194,7 @@ normalise(dynent *m, float angle)
m->yaw += 360.0f;
while (m->yaw > angle + 180.0f)
m->yaw -= 360.0f;
};
}
void
monsteraction(
@ -312,7 +312,7 @@ monsteraction(
};
moveplayer(m, 1, false); // use physics to move monster
};
}
void
monsterpain(dynent *m, int damage, dynent *d)
@ -347,7 +347,7 @@ monsterpain(dynent *m, int damage, dynent *d)
} else {
playsound(monstertypes[m->mtype].painsound, &m->o);
}
};
}
void
endsp(bool allkilled)
@ -397,8 +397,8 @@ monsterthink()
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]);

View file

@ -31,7 +31,7 @@ plcollide(dynent *d, dynent *o, float &headspace, float &hi,
headspace = 10;
};
return true;
};
}
bool
cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by,
@ -51,7 +51,7 @@ cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by,
return cornertest(mip, x, y, dx, dy, bx, by, bs);
};
return stest;
};
}
void
mmcollide(dynent *d, float &hi, float &lo) // collide with a mapmodel
@ -167,7 +167,7 @@ collide(dynent *d, bool spawn, float drop, float rise)
continue;
if (!plcollide(d, o, headspace, hi, lo))
return false;
};
}
if (d != player1)
if (!plcollide(d, player1, headspace, hi, lo))
return false;
@ -213,7 +213,7 @@ float
rad(float x)
{
return x * 3.14159f / 180;
};
}
VARP(maxroll, 0, 3, 20);
@ -230,7 +230,7 @@ physicsframe() // optimally schedule physics frames inside the graphics frames
} 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
@ -312,18 +312,15 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
const float gravity = 20;
const float f = 1.0f / moveres;
float dropf =
((gravity - 1) +
float dropf = ((gravity - 1) +
pl->timeinair / 15.0f); // incorrect, but works fine
if (water) {
dropf = 5;
pl->timeinair = 0;
}; // float slowly down in water
const float drop =
dropf * curtime / gravity / 100 /
const float drop = dropf * curtime / gravity / 100 /
moveres; // at high fps, gravity kicks in too fast
const float rise =
speed / moveres /
const float rise = speed / moveres /
1.2f; // extra smoothness when lifting up stairs
loopi(moveres) // discrete steps collision detection & sliding
@ -359,7 +356,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
};
pl->o.z -= f * d.z;
break;
};
}
};
// detect wether player is outside map, used for skipping zbuffer clear
@ -369,8 +366,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
pl->outsidemap = true;
} else {
sqr *s = S((int)pl->o.x, (int)pl->o.y);
pl->outsidemap =
SOLID(s) ||
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);
};
@ -395,7 +391,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
} else if (pl->inwater && !water)
playsound(S_SPLASH1, &pl->o);
pl->inwater = water;
};
}
void
moveplayer(dynent *pl, int moveres, bool local)
@ -403,4 +399,4 @@ moveplayer(dynent *pl, int moveres, bool local)
loopi(physicsrepeat) moveplayer(pl, moveres, local,
i ? curtime / physicsrepeat
: curtime - curtime / physicsrepeat * (physicsrepeat - 1));
};
}

View file

@ -87,7 +87,7 @@ void
finishstrips()
{
stripend();
};
}
sqr sbright, sdark;
VAR(lighterror, 1, 8, 100);
@ -170,7 +170,7 @@ render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3,
oy = y;
nquads++;
};
}
void
render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3,
@ -228,7 +228,7 @@ render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3,
oy = y;
nquads++;
};
}
void
render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3,
@ -256,7 +256,7 @@ render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3,
vertf((float)x1, h->ceil, (float)y1, l1, xf * x1, yf * y1);
addstrip(gltex, curvert - 3, 3);
nquads++;
};
}
void
render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s,
@ -277,7 +277,7 @@ render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s,
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,
@ -312,7 +312,7 @@ render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2,
nquads++;
addstrip(gltex, curvert - 4, 4);
};
}
int wx1, wy1, wx2, wy2;
@ -326,18 +326,18 @@ vertw(int v1, float v2, int v3, sqr *c, float t1, float t2, float t)
vertcheck();
vertf((float)v1, v2 - (float)sin(v1 * v3 * 0.1 + t) * 0.2f, (float)v3,
c, t1, t2);
};
}
inline float
dx(float x)
{
return x + (float)sin(x * 2 + lastmillis / 1000.0f) * 0.04f;
};
}
inline float
dy(float x)
{
return x + (float)sin(x * 2 + lastmillis / 900.0f + PI / 5) * 0.05f;
};
}
// renders water for bounding rect area that contains water... simple but very
// inefficient
@ -391,7 +391,7 @@ renderwater(float hf)
glDepthMask(GL_TRUE);
return nquads;
};
}
void
addwaterquad(int x, int y, int size) // update bounding rect that contains water
@ -413,7 +413,7 @@ addwaterquad(int x, int y, int size) // update bounding rect that contains water
if (y2 > wy2)
wy2 = y2;
};
};
}
void
resetcubes()
@ -425,4 +425,4 @@ resetcubes()
nquads = 0;
sbright.r = sbright.g = sbright.b = 255;
sdark.r = sdark.g = sdark.b = 0;
};
}

View file

@ -12,14 +12,14 @@ line(int x1, int y1, float z1, int x2, int y2, float z2)
glVertex3f((float)x2, z2, (float)y2);
glEnd();
xtraverts += 4;
};
}
void
linestyle(float width, int r, int g, int b)
{
glLineWidth(width);
glColor3ub(r, g, b);
};
}
void
box(block &b, float z1, float z2, float z3, float z4)
@ -31,7 +31,7 @@ box(block &b, float z1, float z2, float z3, float z4)
glVertex3f((float)b.x, z4, (float)b.y + b.ys);
glEnd();
xtraverts += 4;
};
}
void
dot(int x, int y, float z)
@ -44,7 +44,7 @@ dot(int x, int y, float z)
glVertex3f(x - DOF, (float)z, y + DOF);
glEnd();
xtraverts += 4;
};
}
void
blendbox(int x1, int y1, int x2, int y2, bool border)
@ -76,7 +76,7 @@ blendbox(int x1, int y1, int x2, int y2, bool border)
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glDepthMask(GL_TRUE);
};
}
const int MAXSPHERES = 50;
struct sphere {
@ -96,7 +96,7 @@ newsphere(OFVector3D &o, float max, int type)
{
spheres[i].next = sempty;
sempty = &spheres[i];
};
}
sinit = true;
};
if (sempty) {
@ -109,7 +109,7 @@ newsphere(OFVector3D &o, float max, int type)
p->next = slist;
slist = p;
};
};
}
void
renderspheres(int time)
@ -144,7 +144,7 @@ renderspheres(int time)
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
};
}
string closeent;
OFString *entnames[] = {
@ -243,7 +243,7 @@ readmatrices()
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, mm);
glGetDoublev(GL_PROJECTION_MATRIX, pm);
};
}
// stupid function to cater for stupid ATI linux drivers that return incorrect
// depth values
@ -252,7 +252,7 @@ float
depthcorrect(float d)
{
return (d <= 1 / 256.0f) ? d * 256 : d;
};
}
// find out the 3d target of the crosshair in the world easily and very
// acurately. sadly many very old cards and drivers appear to fuck up on
@ -274,7 +274,7 @@ readdepth(int w, int h)
OFVector3D r = OFMakeVector3D(mm[0], mm[4], mm[8]);
OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]);
setorient(r, u);
};
}
void
drawicon(float tx, float ty, int x, int y)
@ -295,7 +295,7 @@ drawicon(float tx, float ty, int x, int y)
glVertex2i(x, y + s);
glEnd();
xtraverts += 4;
};
}
void
invertperspective()
@ -312,7 +312,7 @@ invertperspective()
inv[3 * 4 + 3] = pm[2 * 4 + 2] / pm[3 * 4 + 2];
glLoadMatrixd(inv);
};
}
VARP(crosshairsize, 0, 15, 50);
@ -321,7 +321,7 @@ void
damageblend(int n)
{
dblend += n;
};
}
VAR(hidestats, 0, 0, 1);
VARP(crosshairfx, 0, 1, 1);

View file

@ -63,7 +63,7 @@ gl_init(int w, int h)
glNewList(1, GL_COMPILE);
gluSphere(qsphere, 1, 12, 6);
glEndList();
};
}
void
cleangl()
@ -174,7 +174,7 @@ void
purgetextures()
{
loopi(256) loop(j, MAXFRAMES) mapping[i][j] = 0;
};
}
int curtexnum = 0;
@ -265,7 +265,7 @@ setupworld()
glTexEnvi(
GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
};
};
}
int skyoglid;
@ -339,7 +339,7 @@ transplayer()
(player1->state == CS_DEAD ? player1->eyeheight - 0.2f : 0) -
player1->o.z,
-player1->o.y);
};
}
VARP(fov, 10, 105, 120);
@ -390,7 +390,7 @@ drawhudgun(float fovy, float aspect, int farplane)
glMatrixMode(GL_MODELVIEW);
glDisable(GL_CULL_FACE);
};
}
void
gl_drawframe(int w, int h, float curfps)
@ -490,4 +490,4 @@ gl_drawframe(int w, int h, float curfps)
glEnable(GL_CULL_FACE);
glEnable(GL_FOG);
};
}

View file

@ -23,7 +23,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
{
particles[i].next = parempty;
parempty = &particles[i];
};
}
parinit = true;
};
if (parempty) {
@ -37,7 +37,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
p->next = parlist;
parlist = p;
};
};
}
VAR(demotracking, 0, 0, 1);
VARP(particlesize, 20, 100, 500);
@ -129,7 +129,7 @@ render_particles(int time)
glEnable(GL_FOG);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
};
}
void
particle_splash(int type, int num, int fade, OFVector3D &p)

View file

@ -86,4 +86,4 @@ perlinarea(block &b, int scale, int seed, int psize)
if (s->vdelta > 128)
s->vdelta = 0;
};
};
}

View file

@ -215,7 +215,7 @@ loadgamerest()
ents[i].spawned = gzgetc(f) != 0;
if (ents[i].type == CARROT && !ents[i].spawned)
trigger(ents[i].attr1, ents[i].attr2, true);
};
}
restoreserverstate(ents);
gzread(f, player1, sizeof(dynent));
@ -230,12 +230,11 @@ loadgamerest()
gzread(f, monsters[i], sizeof(dynent));
monsters[i]->enemy =
player1; // lazy, could save id of enemy instead
monsters[i]->lastaction = monsters[i]->trigger =
lastmillis +
monsters[i]->lastaction = monsters[i]->trigger = lastmillis +
500; // also lazy, but no real noticable effect on game
if (monsters[i]->state == CS_DEAD)
monsters[i]->lastaction = 0;
};
}
restoremonsterstate();
int nplayers = gzgeti();
@ -244,7 +243,7 @@ loadgamerest()
dynent *d = getclient(i);
assert(d);
gzread(f, d, sizeof(dynent));
};
}
conoutf(@"savegame restored");
if (demoloading)
@ -292,12 +291,12 @@ demodamage(int damage, OFVector3D &o)
{
ddamage = damage;
dorig = o;
};
}
void
demoblend(int damage)
{
bdamage = damage;
};
}
void
incomingdemodata(uchar *buf, int len, bool extras)
@ -409,7 +408,7 @@ catmulrom(OFVector3D &z, OFVector3D &a, OFVector3D &b, OFVector3D &c, float s,
vadd(dest, t1);
vmul(t2, s3 - s2);
vadd(dest, t2);
};
}
void
fixwrap(dynent *a, dynent *b)
@ -418,7 +417,7 @@ fixwrap(dynent *a, dynent *b)
a->yaw += 360;
while (b->yaw - a->yaw < -180)
a->yaw -= 360;
};
}
void
demoplaybackstep()
@ -500,8 +499,7 @@ demoplaybackstep()
z = playerhistory[i - 1];
// if(a==z || b==c) printf("* %d\n",
// lastmillis);
float bf =
(itime - a->lastupdate) /
float bf = (itime - a->lastupdate) /
(float)(b->lastupdate - a->lastupdate);
fixwrap(a, player1);
fixwrap(c, player1);

View file

@ -40,8 +40,8 @@ restoreserverstate(
{
sents[i].spawned = ents[i].spawned;
sents[i].spawnsecs = 0;
};
};
}
}
int interm = 0, minremain = 0, mapend = 0;
bool mapreload = false;
@ -74,7 +74,7 @@ send(int n, ENetPacket *packet)
localservertoclient(packet->data, packet->dataLength);
break;
};
};
}
void
send2(bool rel, int cn, int a, int b)
@ -93,7 +93,7 @@ send2(bool rel, int cn, int a, int b)
send(cn, packet);
if (packet->referenceCount == 0)
enet_packet_destroy(packet);
};
}
void
sendservmsg(OFString *msg)
@ -118,14 +118,14 @@ disconnect_client(int n, char *reason)
enet_peer_disconnect(clients[n].peer);
clients[n].type = ST_EMPTY;
send2(true, -1, SV_CDIS, n);
};
}
void
resetitems()
{
sents.setsize(0);
notgotitems = true;
};
}
void
pickup(uint i, int sec, int sender) // server side item pickup, acknowledge
@ -138,13 +138,13 @@ pickup(uint i, int sec, int sender) // server side item pickup, acknowledge
sents[i].spawnsecs = sec;
send2(true, sender, SV_ITEMACC, i);
};
};
}
void
resetvotes()
{
loopv(clients) clients[i].mapvote[0] = 0;
};
}
bool
vote(char *map, int reqmode, int sender)
@ -162,7 +162,7 @@ vote(char *map, int reqmode, int sender)
no++;
} else
no++;
};
}
if (yes == 1 && no == 0)
return true; // single player
@autoreleasepool {
@ -177,7 +177,7 @@ vote(char *map, int reqmode, int sender)
sendservmsg(@"vote passed");
resetvotes();
return true;
};
}
// server side processing of updates: does very little and most state is tracked
// client only could be extended to move more gameplay to server (at expense of
@ -303,7 +303,7 @@ process(ENetPacket *packet, int sender) // sender may be -1
return;
};
multicast(packet, sender);
};
}
void
send_welcome(int n)
@ -341,8 +341,8 @@ multicast(ENetPacket *packet, int sender)
if (i == sender)
continue;
send(i, packet);
};
};
}
}
void
localclienttoserver(ENetPacket *packet)
@ -350,14 +350,14 @@ localclienttoserver(ENetPacket *packet)
process(packet, 0);
if (!packet->referenceCount)
enet_packet_destroy(packet);
};
}
client &
addclient()
{
loopv(clients) if (clients[i].type == ST_EMPTY) return clients[i];
return clients.add();
};
}
void
checkintermission()
@ -367,14 +367,14 @@ checkintermission()
mapend = lastsec + 1000;
};
send2(true, -1, SV_TIMEUP, minremain--);
};
}
void
startintermission()
{
minremain = 0;
checkintermission();
};
}
void
resetserverifempty()
@ -407,7 +407,7 @@ serverslice(int seconds,
sents[i].spawned = true;
send2(true, -1, SV_ITEMSPAWN, i);
};
};
}
lastsec = seconds;
@ -422,7 +422,7 @@ serverslice(int seconds,
0); // ask a client to trigger map reload
mapreload = true;
break;
};
}
};
resetserverifempty();
@ -459,9 +459,9 @@ serverslice(int seconds,
c.peer = event.peer;
c.peer->data = (void *)(&c - &clients[0]);
char hn[1024];
strcpy_s(
c.hostname, (enet_address_get_host(&c.peer->address,
hn, sizeof(hn)) == 0)
strcpy_s(c.hostname,
(enet_address_get_host(
&c.peer->address, hn, sizeof(hn)) == 0)
? hn
: "localhost");
printf("client connected (%s)\n", c.hostname);
@ -493,21 +493,21 @@ serverslice(int seconds,
#ifndef _WIN32
fflush(stdout);
#endif
};
}
void
cleanupserver()
{
if (serverhost)
enet_host_destroy(serverhost);
};
}
void
localdisconnect()
{
loopv(clients) if (clients[i].type == ST_LOCAL) clients[i].type =
ST_EMPTY;
};
}
void
localconnect()
@ -516,7 +516,7 @@ localconnect()
c.type = ST_LOCAL;
strcpy_s(c.hostname, "local");
send_welcome(&c - &clients[0]);
};
}
void
initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip,
@ -554,4 +554,4 @@ initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip,
for (;;)
serverslice(/*enet_time_get_sec()*/ time(NULL), 5);
};
};
}

View file

@ -47,7 +47,7 @@ resolverloop(void *data)
SDL_UnlockMutex(resolvermutex);
};
return 0;
};
}
void
resolverinit(int threads, int limit)
@ -92,9 +92,9 @@ resolverclear()
{
resolverthread &rt = resolverthreads[i];
resolverstop(rt, true);
};
}
SDL_UnlockMutex(resolvermutex);
};
}
void
resolverquery(char *name)
@ -103,7 +103,7 @@ resolverquery(char *name)
resolverqueries.add(name);
SDL_SemPost(resolversem);
SDL_UnlockMutex(resolvermutex);
};
}
bool
resolvercheck(char **name, ENetAddress *address)
@ -127,10 +127,10 @@ resolvercheck(char **name, ENetAddress *address)
return true;
};
};
};
}
SDL_UnlockMutex(resolvermutex);
return false;
};
}
struct serverinfo {
string name;
@ -191,9 +191,9 @@ pingservers()
buf.data = ping;
buf.dataLength = p - ping;
enet_socket_send(pingsock, &si.address, &buf, 1);
};
}
lastinfo = lastmillis;
};
}
void
checkresolver()
@ -285,8 +285,7 @@ refreshservers()
}
}
} else {
sprintf_s(si.full)(
si.address.host != ENET_HOST_ANY
sprintf_s(si.full)(si.address.host != ENET_HOST_ANY
? "%s [waiting for server response]"
: "%s [unknown host]\t",
si.name);
@ -311,7 +310,7 @@ servermenu()
loopv(servers) resolverquery(servers[i].name);
refreshservers();
menuset(1);
};
}
void
updatefrommaster()

View file

@ -51,7 +51,7 @@ httpgetrecieve(ENetBuffer &buf)
((char *)buf.data)[0] = 0;
buf.dataLength -= len;
};
};
}
uchar *
stripheader(uchar *b)
@ -60,7 +60,7 @@ stripheader(uchar *b)
if (!s)
s = strstr((char *)b, "\n\n");
return s ? (uchar *)s : b;
};
}
ENetAddress masterserver = {ENET_HOST_ANY, 80};
int updmaster = 0;
@ -83,7 +83,7 @@ updatemasterserver(int seconds)
masterb.dataLength = MAXTRANS - 1;
updmaster = seconds + 60 * 60;
};
};
}
void
checkmasterreply()
@ -92,7 +92,7 @@ checkmasterreply()
httpgetrecieve(masterb);
if (busy && mssock == ENET_SOCKET_NULL)
printf("masterserver reply: %s\n", stripheader(masterrep));
};
}
uchar *
retrieveservers(uchar *buf, int buflen)
@ -107,7 +107,7 @@ retrieveservers(uchar *buf, int buflen)
while (mssock != ENET_SOCKET_NULL)
httpgetrecieve(eb);
return stripheader(buf);
};
}
ENetSocket pongsock = ENET_SOCKET_NULL;
static OFString *serverdesc;

View file

@ -21,7 +21,7 @@ putint(uchar *&p, int n)
*p++ = n >> 16;
*p++ = n >> 24;
};
};
}
int
getint(uchar *&p)
@ -93,7 +93,7 @@ msgsizelookup(int msg)
if (*p == msg)
return p[1];
return -1;
};
}
// sending of maps between clients

View file

@ -52,7 +52,7 @@ stopsound()
#endif
stream = NULL;
};
};
}
VAR(soundbufferlen, 128, 1024, 4096);
@ -162,7 +162,7 @@ cleansound()
#else
FSOUND_Close();
#endif
};
}
VAR(stereo, 0, 1, 1);
@ -179,8 +179,8 @@ updatechanvol(int chan, OFVector3D *loc)
player1->yaw *
(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)
pan = int(255.9f *
(0.5 * sin(yaw) + 0.5f)); // range is from 0 (left)
// to 255 (right)
};
};
@ -192,7 +192,7 @@ updatechanvol(int chan, OFVector3D *loc)
FSOUND_SetVolume(chan, vol);
FSOUND_SetPan(chan, pan);
#endif
};
}
void
newsoundloc(int chan, OFVector3D *loc)
@ -200,7 +200,7 @@ newsoundloc(int chan, OFVector3D *loc)
assert(chan >= 0 && chan < MAXCHAN);
soundlocs[chan].loc = *loc;
soundlocs[chan].inuse = true;
};
}
void
updatevol()
@ -217,15 +217,15 @@ updatevol()
updatechanvol(i, &soundlocs[i].loc);
else
soundlocs[i].inuse = false;
};
};
}
}
void
playsoundc(int n)
{
addmsg(0, 2, SV_SOUND, n);
playsound(n);
};
}
int soundsatonce = 0, lastsoundmillis = 0;

View file

@ -17,5 +17,5 @@ endianswap(
uchar t = p[i];
p[i] = p[stride - i - 1];
p[stride - i - 1] = t;
};
}
}

View file

@ -35,23 +35,23 @@ settag(int tag, int type) // set all cubes with "tag" to space, if tag is 0 then
if (y < miny)
miny = y;
};
};
}
block b = {minx, miny, maxx - minx + 1, maxy - miny + 1};
if (maxx)
remip(b); // remip minimal area of changed geometry
};
}
void
resettagareas()
{
settag(0, 0);
}; // reset for editing or map saving
} // reset for editing or map saving
void
settagareas()
{
settag(0, 1);
loopv(ents) if (ents[i].type == CARROT) setspawn(i, true);
}; // set for playing
} // set for playing
void
trigger(int tag, int type, bool savegame)
@ -137,8 +137,7 @@ remip(block &b, int level)
// large mips
// next to hfs
if (o[i]->type == CHF)
ch +=
o[i]->vdelta / 4 +
ch += o[i]->vdelta / 4 +
2; // FIXME: needs
// to somehow
// take into
@ -155,7 +154,7 @@ remip(block &b, int level)
// from the side
if (ch > ceil)
ceil = ch;
};
}
r->floor = floor;
r->ceil = ceil;
};
@ -172,7 +171,7 @@ remip(block &b, int level)
// to be equal for a
// perfect mip is the
// wall texture
};
}
} else {
loopi(3)
{
@ -192,7 +191,7 @@ remip(block &b, int level)
o[i]->utex != o[3]->utex ||
o[i]->wtex != o[3]->wtex)
goto c;
};
}
if (r->type == CHF ||
r->type ==
FHF) // can make a perfect mip out of a
@ -234,7 +233,7 @@ remip(block &b, int level)
s.xs /= 2;
s.ys /= 2;
remip(s, level + 1);
};
}
void
remipmore(block &b, int level)
@ -249,7 +248,7 @@ remipmore(block &b, int level)
if (bb.ys < ssize - 3)
bb.ys++;
remip(bb, level);
};
}
int
closestent() // used for delent and edit mode ent display
@ -269,9 +268,9 @@ closestent() // used for delent and edit mode ent display
best = i;
bdist = dist;
};
};
}
return bdist == 99999 ? -1 : best;
};
}
void
entproperty(int prop, int amount)
@ -293,7 +292,7 @@ entproperty(int prop, int amount)
ents[e].attr4 += amount;
break;
};
};
}
void
delent()
@ -355,7 +354,7 @@ newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
if (type == LIGHT)
calclight();
return &ents.last();
};
}
void
clearents(OFString *name)
@ -368,7 +367,7 @@ clearents(OFString *name)
entity &e = ents[i];
if (e.type == type)
e.type = NOTUSED;
};
}
if (type == LIGHT)
calclight();
}
@ -381,7 +380,7 @@ scalecomp(uchar &c, int intens)
if (n > 255)
n = 255;
c = n;
};
}
void
scalelights(int f, int intens)
@ -401,7 +400,7 @@ scalelights(int f, int intens)
scalecomp(e.attr3, intens);
scalecomp(e.attr4, intens);
};
};
}
calclight();
}
COMMAND(scalelights, ARG_2INT)
@ -414,7 +413,7 @@ findentity(int type, int index)
return i;
loopj(index) if (ents[j].type == type) return j;
return -1;
};
}
sqr *wmip[LARGEST_FACTOR * 2];
@ -429,8 +428,8 @@ setupworld(int factor)
{
wmip[i] = w;
w += cubicsize >> (i * 2);
};
};
}
}
void
empty_world(

View file

@ -77,7 +77,7 @@ lightray(float bx, float by,
stepl -= 25;
stepg -= 25;
stepb -= 25;
};
}
} else // white light, special optimized version
{
int dimness = rnd((255 - light.attr2) / 16 + 1);
@ -98,7 +98,7 @@ lightray(float bx, float by,
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
@ -114,9 +114,9 @@ lightray(float bx, float by,
x += stepx;
y += stepy;
l -= stepl;
}
};
};
};
}
void
calclightsource(persistent_entity &l)
@ -141,7 +141,7 @@ calclightsource(persistent_entity &l)
};
rndtime();
};
}
void
postlightarea(block &a) // median filter, smooths out random noise in light and
@ -159,10 +159,10 @@ postlightarea(block &a) // median filter, smooths out random noise in light and
median(r);
median(g);
median(b);
};
}
remip(a);
};
}
void
calclight()

View file

@ -76,8 +76,8 @@ computeraytable(float vx, float vy)
} 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
@ -87,12 +87,12 @@ inline float
ca(float x, float y)
{
return x > y ? y / x : 2 - x / y;
};
}
inline float
ma(float x, float y)
{
return x == 0 ? (y > 0 ? 2 : -2) : y / x;
};
}
int
isoccluded(float vx, float vy, float cx, float cy,
@ -200,4 +200,4 @@ isoccluded(float vx, float vy, float cx, float cy,
};
return 1; // cube is entirely occluded
};
}

View file

@ -61,7 +61,7 @@ skip: {
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;
@ -106,7 +106,7 @@ issemi(int mip, int x, int y, int x1, int y1, int x2, int y2)
return true;
};
return false;
};
}
bool render_floor, render_ceil;
@ -183,7 +183,7 @@ render_seg_new(
render_seg_new(vx, vy, vh, mip - 1, xx * 2, start * 2,
xx * 2 + 2, yy * 2 + 2);
continue;
};
}
stats[mip]++;
LOOPD
if ((s->type == SPACE || s->type == FHF) && s->ceil >= vh &&
@ -311,7 +311,7 @@ distlod(int &low, int &high, int angle, float widef)
low = min_lod;
if (high < min_lod)
high = min_lod;
};
}
// does some out of date view frustrum optimisation that doesn't contribute much
// anymore
@ -328,7 +328,8 @@ render_world(
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 *
(int)(MIN_LOD +
(10 - cdist) / 1.0f *
widef)); // less if lod worked better
widef = 1.0f;
};
@ -355,4 +356,4 @@ render_world(
render_seg_new(
vx, vy, vh, MAX_MIP, 0, 0, ssize >> MAX_MIP, ssize >> MAX_MIP);
mipstats(stats[0], stats[1], stats[2]);
};
}