Improve clang-format
FossilOrigin-Name: 6f5dd506262655e5d3a6732794f955c8476b19a80fa03d5ebb6744ed8b18c963
This commit is contained in:
parent
f904d80214
commit
dd08a1069e
41 changed files with 506 additions and 493 deletions
|
@ -1,9 +1,26 @@
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: ForIndentation
|
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
|
AlwaysBreakAfterReturnType: AllDefinitions
|
||||||
AlignAfterOpenBracket: DontAlign
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: DontAlign
|
||||||
ObjCBlockIndentWidth: 8
|
ObjCBlockIndentWidth: 8
|
||||||
ObjCSpaceAfterProperty: true
|
ObjCSpaceAfterProperty: true
|
||||||
ObjCSpaceBeforeProtocolList: true
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
@ -15,5 +32,11 @@ ObjCPropertyAttributeOrder: [
|
||||||
atomic, nonatomic,
|
atomic, nonatomic,
|
||||||
getter, setter
|
getter, setter
|
||||||
]
|
]
|
||||||
|
SpaceBeforeInheritanceColon: false
|
||||||
|
QualifierAlignment: Left
|
||||||
|
#RemoveEmptyLinesInUnwrappedLines: true
|
||||||
|
RemoveSemicolon: true
|
||||||
|
CompactNamespaces: true
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
IndentPPDirectives: AfterHash
|
IndentPPDirectives: AfterHash
|
||||||
PPIndentWidth: 1
|
PPIndentWidth: 1
|
||||||
|
|
|
@ -7,7 +7,8 @@ OF_APPLICATION_DELEGATE(Cube)
|
||||||
VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
|
VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
|
||||||
VARP(minmillis, 0, 5, 1000);
|
VARP(minmillis, 0, 5, 1000);
|
||||||
|
|
||||||
@implementation Cube {
|
@implementation Cube
|
||||||
|
{
|
||||||
int _width, _height;
|
int _width, _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ snap(int sn, float f)
|
||||||
return sn ? (float)(((int)(f + sn * 0.5f)) & (~(sn - 1))) : f;
|
return sn ? (float)(((int)(f + sn * 0.5f)) & (~(sn - 1))) : f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation MD2 {
|
@implementation MD2
|
||||||
|
{
|
||||||
int _numGlCommands;
|
int _numGlCommands;
|
||||||
int *_glCommands;
|
int *_glCommands;
|
||||||
int _numTriangles;
|
int _numTriangles;
|
||||||
|
|
|
@ -295,8 +295,8 @@ c2sinfo(dynent *d) // send update to the server
|
||||||
} else {
|
} else {
|
||||||
putint(p, SV_POS);
|
putint(p, SV_POS);
|
||||||
putint(p, clientnum);
|
putint(p, clientnum);
|
||||||
putint(
|
putint(p,
|
||||||
p, (int)(d->o.x *
|
(int)(d->o.x *
|
||||||
DMF)); // quantize coordinates to 1/16th
|
DMF)); // quantize coordinates to 1/16th
|
||||||
// of a cube, between 1 and 3 bytes
|
// of a cube, between 1 and 3 bytes
|
||||||
putint(p, (int)(d->o.y * DMF));
|
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));
|
putint(p, (int)(d->vel.z * DVF));
|
||||||
// pack rest in 1 byte: strafe:2, move:2, onfloor:1,
|
// pack rest in 1 byte: strafe:2, move:2, onfloor:1,
|
||||||
// state:3
|
// state:3
|
||||||
putint(
|
putint(p,
|
||||||
p, (d->strafe & 3) | ((d->move & 3) << 2) |
|
(d->strafe & 3) | ((d->move & 3) << 2) |
|
||||||
(((int)d->onfloor) << 4) |
|
(((int)d->onfloor) << 4) |
|
||||||
((editmode ? CS_EDITING : d->state) << 5));
|
((editmode ? CS_EDITING : d->state) << 5));
|
||||||
|
|
||||||
|
@ -412,4 +412,4 @@ gets2c() // get updates from the server
|
||||||
server_err();
|
server_err();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -78,9 +78,8 @@ renderclients()
|
||||||
{
|
{
|
||||||
dynent *d;
|
dynent *d;
|
||||||
loopv(players) if ((d = players[i]) &&
|
loopv(players) if ((d = players[i]) &&
|
||||||
(!demoplayback || i != democlientnum))
|
(!demoplayback || i != democlientnum)) renderclient(d,
|
||||||
renderclient(d, isteam(player1->team, d->team), @"monster/ogro",
|
isteam(player1->team, d->team), @"monster/ogro", false, 1.0f);
|
||||||
false, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// creation of scoreboard pseudo-menu
|
// creation of scoreboard pseudo-menu
|
||||||
|
|
|
@ -41,7 +41,7 @@ resetmovement(dynent *d)
|
||||||
d->jumpnext = false;
|
d->jumpnext = false;
|
||||||
d->strafe = 0;
|
d->strafe = 0;
|
||||||
d->move = 0;
|
d->move = 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawnstate(dynent *d) // reset player state not persistent accross spawns
|
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 {
|
} else {
|
||||||
d->ammo[GUN_SG] = 5;
|
d->ammo[GUN_SG] = 5;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
dynent *
|
dynent *
|
||||||
newdynent() // create a new blank player or monster
|
newdynent() // create a new blank player or monster
|
||||||
|
@ -125,14 +125,14 @@ newdynent() // create a new blank player or monster
|
||||||
d->state = CS_ALIVE;
|
d->state = CS_ALIVE;
|
||||||
spawnstate(d);
|
spawnstate(d);
|
||||||
return d;
|
return d;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
respawnself()
|
respawnself()
|
||||||
{
|
{
|
||||||
spawnplayer(player1);
|
spawnplayer(player1);
|
||||||
showscores(false);
|
showscores(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arenacount(dynent *d, int &alive, int &dead, char *&lastteam, bool &oneteam)
|
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 {
|
} else {
|
||||||
dead++;
|
dead++;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
int arenarespawnwait = 0;
|
int arenarespawnwait = 0;
|
||||||
int arenadetectwait = 0;
|
int arenadetectwait = 0;
|
||||||
|
@ -180,7 +180,7 @@ arenarespawn()
|
||||||
player1->roll = 0;
|
player1->roll = 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zapdynent(dynent *&d)
|
zapdynent(dynent *&d)
|
||||||
|
@ -188,7 +188,7 @@ zapdynent(dynent *&d)
|
||||||
if (d)
|
if (d)
|
||||||
free(d);
|
free(d);
|
||||||
d = NULL;
|
d = NULL;
|
||||||
};
|
}
|
||||||
|
|
||||||
extern int democlientnum;
|
extern int democlientnum;
|
||||||
|
|
||||||
|
@ -207,8 +207,8 @@ otherplayers()
|
||||||
moveplayer(
|
moveplayer(
|
||||||
players[i], 2, false); // use physics to extrapolate
|
players[i], 2, false); // use physics to extrapolate
|
||||||
// player position
|
// player position
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
respawn()
|
respawn()
|
||||||
|
@ -268,8 +268,7 @@ updateworld(int millis) // main game update loop
|
||||||
player1->move = player1->strafe = 0;
|
player1->move = player1->strafe = 0;
|
||||||
moveplayer(player1, 10, false);
|
moveplayer(player1, 10, false);
|
||||||
} else if (!m_arena && !m_sp &&
|
} else if (!m_arena && !m_sp &&
|
||||||
lastmillis - player1->lastaction >
|
lastmillis - player1->lastaction > 10000)
|
||||||
10000)
|
|
||||||
respawn();
|
respawn();
|
||||||
} else if (!intermission) {
|
} else if (!intermission) {
|
||||||
moveplayer(player1, 20, true);
|
moveplayer(player1, 20, true);
|
||||||
|
@ -300,7 +299,7 @@ entinmap(dynent *
|
||||||
conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x,
|
conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x,
|
||||||
(int)d->o.y);
|
(int)d->o.y);
|
||||||
// leave ent at original pos, possibly stuck
|
// leave ent at original pos, possibly stuck
|
||||||
};
|
}
|
||||||
|
|
||||||
int spawncycle = -1;
|
int spawncycle = -1;
|
||||||
int fixspawn = 2;
|
int fixspawn = 2;
|
||||||
|
@ -324,7 +323,7 @@ spawnplayer(dynent *d) // place at random spawn. also used by monsters!
|
||||||
entinmap(d);
|
entinmap(d);
|
||||||
spawnstate(d);
|
spawnstate(d);
|
||||||
d->state = CS_ALIVE;
|
d->state = CS_ALIVE;
|
||||||
};
|
}
|
||||||
|
|
||||||
// movement input code
|
// movement input code
|
||||||
|
|
||||||
|
@ -334,7 +333,7 @@ spawnplayer(dynent *d) // place at random spawn. also used by monsters!
|
||||||
player1->s = isdown; \
|
player1->s = isdown; \
|
||||||
player1->v = isdown ? d : (player1->os ? -(d) : 0); \
|
player1->v = isdown ? d : (player1->os ? -(d) : 0); \
|
||||||
player1->lastmove = lastmillis; \
|
player1->lastmove = lastmillis; \
|
||||||
};
|
}
|
||||||
|
|
||||||
dir(backward, move, -1, k_down, k_up);
|
dir(backward, move, -1, k_down, k_up);
|
||||||
dir(forward, move, 1, k_up, k_down);
|
dir(forward, move, 1, k_up, k_down);
|
||||||
|
@ -350,14 +349,14 @@ attack(bool on)
|
||||||
editdrag(on);
|
editdrag(on);
|
||||||
else if (player1->attacking = on)
|
else if (player1->attacking = on)
|
||||||
respawn();
|
respawn();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
jumpn(bool on)
|
jumpn(bool on)
|
||||||
{
|
{
|
||||||
if (!intermission && (player1->jumpnext = on))
|
if (!intermission && (player1->jumpnext = on))
|
||||||
respawn();
|
respawn();
|
||||||
};
|
}
|
||||||
|
|
||||||
COMMAND(backward, ARG_DOWN)
|
COMMAND(backward, ARG_DOWN)
|
||||||
COMMAND(forward, ARG_DOWN)
|
COMMAND(forward, ARG_DOWN)
|
||||||
|
@ -379,7 +378,7 @@ fixplayer1range()
|
||||||
player1->yaw += 360.0f;
|
player1->yaw += 360.0f;
|
||||||
while (player1->yaw >= 360.0f)
|
while (player1->yaw >= 360.0f)
|
||||||
player1->yaw -= 360.0f;
|
player1->yaw -= 360.0f;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mousemove(int dx, int dy)
|
mousemove(int dx, int dy)
|
||||||
|
@ -389,10 +388,9 @@ mousemove(int dx, int dy)
|
||||||
const float SENSF = 33.0f; // try match quake sens
|
const float SENSF = 33.0f; // try match quake sens
|
||||||
player1->yaw += (dx / SENSF) * (sensitivity / (float)sensitivityscale);
|
player1->yaw += (dx / SENSF) * (sensitivity / (float)sensitivityscale);
|
||||||
player1->pitch -= (dy / SENSF) *
|
player1->pitch -= (dy / SENSF) *
|
||||||
(sensitivity / (float)sensitivityscale) *
|
(sensitivity / (float)sensitivityscale) * (invmouse ? -1 : 1);
|
||||||
(invmouse ? -1 : 1);
|
|
||||||
fixplayer1range();
|
fixplayer1range();
|
||||||
};
|
}
|
||||||
|
|
||||||
// damage arriving from the network, monsters, yourself, all ends up here.
|
// 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;
|
player1->armour -= ad;
|
||||||
damage -= ad;
|
damage -= ad;
|
||||||
float droll = damage / 0.5f;
|
float droll = damage / 0.5f;
|
||||||
player1->roll +=
|
player1->roll += player1->roll > 0
|
||||||
player1->roll > 0
|
|
||||||
? droll
|
? droll
|
||||||
: (player1->roll < 0
|
: (player1->roll < 0
|
||||||
? -droll
|
? -droll
|
||||||
|
|
|
@ -52,7 +52,7 @@ updatepos(dynent *d)
|
||||||
d->plag = (d->plag * 5 + lagtime) / 6;
|
d->plag = (d->plag * 5 + lagtime) / 6;
|
||||||
d->lastupdate = lastmillis;
|
d->lastupdate = lastmillis;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
localservertoclient(
|
localservertoclient(
|
||||||
|
|
|
@ -78,14 +78,15 @@ renderconsole() // render buffer taking into account time & scrolling
|
||||||
{
|
{
|
||||||
int nd = 0;
|
int nd = 0;
|
||||||
char *refs[ndraw];
|
char *refs[ndraw];
|
||||||
loopv(conlines) if (conskip ? i >= conskip - 1 ||
|
loopv(conlines)
|
||||||
i >= conlines.length() - ndraw
|
|
||||||
: lastmillis - conlines[i].outtime < 20000)
|
|
||||||
{
|
{
|
||||||
|
if (conskip ? i >= conskip - 1 || i >= conlines.length() - ndraw
|
||||||
|
: lastmillis - conlines[i].outtime < 20000) {
|
||||||
refs[nd++] = conlines[i].cref;
|
refs[nd++] = conlines[i].cref;
|
||||||
if (nd == ndraw)
|
if (nd == ndraw)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
loopj(nd)
|
loopj(nd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ bool selset = false;
|
||||||
{ \
|
{ \
|
||||||
sqr *s = S(sel.x + x, sel.y + y); \
|
sqr *s = S(sel.x + x, sel.y + y); \
|
||||||
b; \
|
b; \
|
||||||
}; \
|
} \
|
||||||
remip(sel); \
|
remip(sel); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ correctsel() // ensures above invariant
|
||||||
sel.ys = bsize - sel.y;
|
sel.ys = bsize - sel.y;
|
||||||
if (sel.xs <= 0 || sel.ys <= 0)
|
if (sel.xs <= 0 || sel.ys <= 0)
|
||||||
selset = false;
|
selset = false;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
noteditmode()
|
noteditmode()
|
||||||
|
@ -122,7 +122,7 @@ selectpos(int x, int y, int xs, int ys)
|
||||||
sel = s;
|
sel = s;
|
||||||
selh = 0;
|
selh = 0;
|
||||||
correctsel();
|
correctsel();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
makesel()
|
makesel()
|
||||||
|
@ -134,7 +134,7 @@ makesel()
|
||||||
correctsel();
|
correctsel();
|
||||||
if (selset)
|
if (selset)
|
||||||
rtex = *S(sel.x, sel.y);
|
rtex = *S(sel.x, sel.y);
|
||||||
};
|
}
|
||||||
|
|
||||||
VAR(flrceil, 0, 0, 2);
|
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
|
sqr *s, sqr *t, float z) // finds out z height when cursor points at wall
|
||||||
{
|
{
|
||||||
return !flrceil // z-s->floor<s->ceil-z
|
return !flrceil // z-s->floor<s->ceil-z
|
||||||
? (s->type == FHF ? s->floor - t->vdelta / 4.0f
|
? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor)
|
||||||
: (float)s->floor)
|
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f : (float)s->ceil);
|
||||||
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f
|
}
|
||||||
: (float)s->ceil);
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cursorupdate() // called every frame from hud
|
cursorupdate() // called every frame from hud
|
||||||
|
@ -235,7 +233,7 @@ cursorupdate() // called every frame from hud
|
||||||
linestyle(GRIDS, 0xFF, 0x40, 0x40);
|
linestyle(GRIDS, 0xFF, 0x40, 0x40);
|
||||||
box(sel, (float)selh, (float)selh, (float)selh, (float)selh);
|
box(sel, (float)selh, (float)selh, (float)selh, (float)selh);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
vector<block *> undos; // unlimited undo
|
vector<block *> undos; // unlimited undo
|
||||||
VARP(undomegs, 0, 1, 10); // bounded by n megs
|
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);
|
t += undos[i]->xs * undos[i]->ys * sizeof(sqr);
|
||||||
if (t > maxremain)
|
if (t > maxremain)
|
||||||
free(undos.remove(i));
|
free(undos.remove(i));
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
makeundo()
|
makeundo()
|
||||||
{
|
{
|
||||||
undos.add(blockcopy(sel));
|
undos.add(blockcopy(sel));
|
||||||
pruneundos(undomegs << 20);
|
pruneundos(undomegs << 20);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
editundo()
|
editundo()
|
||||||
|
@ -281,7 +279,7 @@ copy()
|
||||||
if (copybuf)
|
if (copybuf)
|
||||||
free(copybuf);
|
free(copybuf);
|
||||||
copybuf = blockcopy(sel);
|
copybuf = blockcopy(sel);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
paste()
|
paste()
|
||||||
|
@ -319,8 +317,8 @@ tofronttex() // maintain most recently used of the texture lists when applying
|
||||||
p[0] = t;
|
p[0] = t;
|
||||||
curedittex[i] = -1;
|
curedittex[i] = -1;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
editdrag(bool isdown)
|
editdrag(bool isdown)
|
||||||
|
@ -333,7 +331,7 @@ editdrag(bool isdown)
|
||||||
tofronttex();
|
tofronttex();
|
||||||
};
|
};
|
||||||
makesel();
|
makesel();
|
||||||
};
|
}
|
||||||
|
|
||||||
// the core editing function. all the *xy functions perform the core operations
|
// 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
|
// 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)
|
if (s->ceil <= s->floor)
|
||||||
s->ceil = s->floor + 1;
|
s->ceil = s->floor + 1;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
editheight(int flr, int amount)
|
editheight(int flr, int amount)
|
||||||
|
@ -381,7 +379,7 @@ edittexxy(int type, int t, block &sel)
|
||||||
s->utex = t;
|
s->utex = t;
|
||||||
break;
|
break;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edittex(int type, int dir)
|
edittex(int type, int dir)
|
||||||
|
@ -400,7 +398,7 @@ edittex(int type, int dir)
|
||||||
int t = lasttex = hdr.texlists[atype][i];
|
int t = lasttex = hdr.texlists[atype][i];
|
||||||
edittexxy(type, t, sel);
|
edittexxy(type, t, sel);
|
||||||
addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t);
|
addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
replace()
|
replace()
|
||||||
|
@ -427,16 +425,16 @@ replace()
|
||||||
s->utex = lasttex;
|
s->utex = lasttex;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
block b = {0, 0, ssize, ssize};
|
block b = {0, 0, ssize, ssize};
|
||||||
remip(b);
|
remip(b);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edittypexy(int type, block &sel)
|
edittypexy(int type, block &sel)
|
||||||
{
|
{
|
||||||
loopselxy(s->type = type);
|
loopselxy(s->type = type);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edittype(int type)
|
edittype(int type)
|
||||||
|
@ -491,7 +489,7 @@ editequalisexy(bool isfloor, block &sel)
|
||||||
if (s->floor >= s->ceil)
|
if (s->floor >= s->ceil)
|
||||||
s->floor = s->ceil - 1;
|
s->floor = s->ceil - 1;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
equalize(int flr)
|
equalize(int flr)
|
||||||
|
@ -508,7 +506,7 @@ setvdeltaxy(int delta, block &sel)
|
||||||
{
|
{
|
||||||
loopselxy(s->vdelta = max(s->vdelta + delta, 0));
|
loopselxy(s->vdelta = max(s->vdelta + delta, 0));
|
||||||
remipmore(sel);
|
remipmore(sel);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setvdelta(int delta)
|
setvdelta(int delta)
|
||||||
|
@ -516,7 +514,7 @@ setvdelta(int delta)
|
||||||
EDITSEL;
|
EDITSEL;
|
||||||
setvdeltaxy(delta, sel);
|
setvdeltaxy(delta, sel);
|
||||||
addmsg(1, 6, SV_EDITD, sel.x, sel.y, sel.xs, sel.ys, delta);
|
addmsg(1, 6, SV_EDITD, sel.x, sel.y, sel.xs, sel.ys, delta);
|
||||||
};
|
}
|
||||||
|
|
||||||
const int MAXARCHVERT = 50;
|
const int MAXARCHVERT = 50;
|
||||||
int archverts[MAXARCHVERT][MAXARCHVERT];
|
int archverts[MAXARCHVERT][MAXARCHVERT];
|
||||||
|
@ -532,7 +530,7 @@ archvertex(int span, int vert, int delta)
|
||||||
if (span >= MAXARCHVERT || vert >= MAXARCHVERT || span < 0 || vert < 0)
|
if (span >= MAXARCHVERT || vert >= MAXARCHVERT || span < 0 || vert < 0)
|
||||||
return;
|
return;
|
||||||
archverts[span][vert] = delta;
|
archverts[span][vert] = delta;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arch(int sidedelta, int _a)
|
arch(int sidedelta, int _a)
|
||||||
|
@ -544,14 +542,13 @@ arch(int sidedelta, int _a)
|
||||||
sel.xs = MAXARCHVERT;
|
sel.xs = MAXARCHVERT;
|
||||||
if (sel.ys > MAXARCHVERT)
|
if (sel.ys > MAXARCHVERT)
|
||||||
sel.ys = MAXARCHVERT;
|
sel.ys = MAXARCHVERT;
|
||||||
loopselxy(
|
loopselxy(s->vdelta = sel.xs > sel.ys
|
||||||
s->vdelta = sel.xs > sel.ys
|
|
||||||
? (archverts[sel.xs - 1][x] +
|
? (archverts[sel.xs - 1][x] +
|
||||||
(y == 0 || y == sel.ys - 1 ? sidedelta : 0))
|
(y == 0 || y == sel.ys - 1 ? sidedelta : 0))
|
||||||
: (archverts[sel.ys - 1][y] +
|
: (archverts[sel.ys - 1][y] +
|
||||||
(x == 0 || x == sel.xs - 1 ? sidedelta : 0)));
|
(x == 0 || x == sel.xs - 1 ? sidedelta : 0)));
|
||||||
remipmore(sel);
|
remipmore(sel);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
slope(int xd, int yd)
|
slope(int xd, int yd)
|
||||||
|
@ -566,7 +563,7 @@ slope(int xd, int yd)
|
||||||
sel.ys++;
|
sel.ys++;
|
||||||
loopselxy(s->vdelta = xd * x + yd * y + off);
|
loopselxy(s->vdelta = xd * x + yd * y + off);
|
||||||
remipmore(sel);
|
remipmore(sel);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
perlin(int scale, int seed, int psize)
|
perlin(int scale, int seed, int psize)
|
||||||
|
@ -583,7 +580,7 @@ perlin(int scale, int seed, int psize)
|
||||||
remipmore(sel);
|
remipmore(sel);
|
||||||
sel.xs--;
|
sel.xs--;
|
||||||
sel.ys--;
|
sel.ys--;
|
||||||
};
|
}
|
||||||
|
|
||||||
VARF(
|
VARF(
|
||||||
fullbright, 0, 0, 1, if (fullbright) {
|
fullbright, 0, 0, 1, if (fullbright) {
|
||||||
|
@ -597,7 +594,7 @@ edittag(int tag)
|
||||||
{
|
{
|
||||||
EDITSELMP;
|
EDITSELMP;
|
||||||
loopselxy(s->tag = tag);
|
loopselxy(s->tag = tag);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4)
|
newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4)
|
||||||
|
|
|
@ -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,
|
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);
|
e.y, yaw, 0, false, 1.0f, speed, 0, basetime);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
renderentities()
|
renderentities()
|
||||||
|
@ -59,8 +59,8 @@ renderentities()
|
||||||
if (e.type < I_SHELLS || e.type > TELEPORT)
|
if (e.type < I_SHELLS || e.type > TELEPORT)
|
||||||
continue;
|
continue;
|
||||||
renderent(e, entmdlnames[e.type - I_SHELLS],
|
renderent(e, entmdlnames[e.type - I_SHELLS],
|
||||||
(float)(1 + sin(lastmillis / 100.0 + e.x +
|
(float)(1 +
|
||||||
e.y) /
|
sin(lastmillis / 100.0 + e.x + e.y) /
|
||||||
20),
|
20),
|
||||||
lastmillis / 10.0f);
|
lastmillis / 10.0f);
|
||||||
} else
|
} else
|
||||||
|
@ -74,8 +74,9 @@ renderentities()
|
||||||
if (!e.spawned)
|
if (!e.spawned)
|
||||||
continue;
|
continue;
|
||||||
renderent(e, @"carrot",
|
renderent(e, @"carrot",
|
||||||
(float)(1 + sin(lastmillis / 100.0 +
|
(float)(1 +
|
||||||
e.x + e.y) /
|
sin(lastmillis / 100.0 + e.x +
|
||||||
|
e.y) /
|
||||||
20),
|
20),
|
||||||
lastmillis /
|
lastmillis /
|
||||||
(e.attr2 ? 1.0f : 10.0f));
|
(e.attr2 ? 1.0f : 10.0f));
|
||||||
|
@ -100,8 +101,8 @@ renderentities()
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
struct itemstat {
|
struct itemstat {
|
||||||
int add, max, sound;
|
int add, max, sound;
|
||||||
|
@ -139,7 +140,7 @@ void
|
||||||
baseammo(int gun)
|
baseammo(int gun)
|
||||||
{
|
{
|
||||||
player1->ammo[gun] = itemstats[gun - 1].add * 2;
|
player1->ammo[gun] = itemstats[gun - 1].add * 2;
|
||||||
};
|
}
|
||||||
|
|
||||||
// these two functions are called when the server acknowledges that you really
|
// these two functions are called when the server acknowledges that you really
|
||||||
// picked up the item (in multiplayer someone may grab it before you).
|
// 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)
|
if (v > is.max)
|
||||||
v = is.max;
|
v = is.max;
|
||||||
playsoundc(is.sound);
|
playsoundc(is.sound);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
realpickup(int n, dynent *d)
|
realpickup(int n, dynent *d)
|
||||||
|
@ -234,7 +235,7 @@ teleport(int n, dynent *d) // also used by monsters
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pickup(int n, dynent *d)
|
pickup(int n, dynent *d)
|
||||||
|
@ -357,10 +358,10 @@ void
|
||||||
resetspawns()
|
resetspawns()
|
||||||
{
|
{
|
||||||
loopv(ents) ents[i].spawned = false;
|
loopv(ents) ents[i].spawned = false;
|
||||||
};
|
}
|
||||||
void
|
void
|
||||||
setspawn(uint i, bool on)
|
setspawn(uint i, bool on)
|
||||||
{
|
{
|
||||||
if (i < (uint)ents.length())
|
if (i < (uint)ents.length())
|
||||||
ents[i].spawned = on;
|
ents[i].spawned = on;
|
||||||
};
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ basicmonster(int type, int yaw, int state, int trigger, int move)
|
||||||
}
|
}
|
||||||
monsters.add(m);
|
monsters.add(m);
|
||||||
return m;
|
return m;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawnmonster() // spawn a random monster according to freq distribution in DMSP
|
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;
|
break;
|
||||||
};
|
};
|
||||||
basicmonster(type, rnd(360), M_SEARCH, 1000, 1);
|
basicmonster(type, rnd(360), M_SEARCH, 1000, 1);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
monsterclear() // called after map start of when toggling edit mode to
|
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;
|
m->o.z = ents[i].z;
|
||||||
entinmap(m);
|
entinmap(m);
|
||||||
monstertotal++;
|
monstertotal++;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
los(float lx, float ly, float lz, float bx, float by, float bz,
|
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++;
|
i++;
|
||||||
};
|
};
|
||||||
return i >= steps;
|
return i >= steps;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
enemylos(dynent *m, OFVector3D &v)
|
enemylos(dynent *m, OFVector3D &v)
|
||||||
|
@ -168,7 +168,7 @@ enemylos(dynent *m, OFVector3D &v)
|
||||||
v = m->o;
|
v = m->o;
|
||||||
return los(m->o.x, m->o.y, m->o.z, m->enemy->o.x, m->enemy->o.y,
|
return los(m->o.x, m->o.y, m->o.z, m->enemy->o.x, m->enemy->o.y,
|
||||||
m->enemy->o.z, v);
|
m->enemy->o.z, v);
|
||||||
};
|
}
|
||||||
|
|
||||||
// monster AI is sequenced using transitions: they are in a particular state
|
// 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
|
// 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;
|
m->move = moving;
|
||||||
n = n * 130 / 100;
|
n = n * 130 / 100;
|
||||||
m->trigger = lastmillis + n - skill * (n / 16) + rnd(r + 1);
|
m->trigger = lastmillis + n - skill * (n / 16) + rnd(r + 1);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
normalise(dynent *m, float angle)
|
normalise(dynent *m, float angle)
|
||||||
|
@ -194,7 +194,7 @@ normalise(dynent *m, float angle)
|
||||||
m->yaw += 360.0f;
|
m->yaw += 360.0f;
|
||||||
while (m->yaw > angle + 180.0f)
|
while (m->yaw > angle + 180.0f)
|
||||||
m->yaw -= 360.0f;
|
m->yaw -= 360.0f;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
monsteraction(
|
monsteraction(
|
||||||
|
@ -312,7 +312,7 @@ monsteraction(
|
||||||
};
|
};
|
||||||
|
|
||||||
moveplayer(m, 1, false); // use physics to move monster
|
moveplayer(m, 1, false); // use physics to move monster
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
monsterpain(dynent *m, int damage, dynent *d)
|
monsterpain(dynent *m, int damage, dynent *d)
|
||||||
|
@ -347,7 +347,7 @@ monsterpain(dynent *m, int damage, dynent *d)
|
||||||
} else {
|
} else {
|
||||||
playsound(monstertypes[m->mtype].painsound, &m->o);
|
playsound(monstertypes[m->mtype].painsound, &m->o);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
endsp(bool allkilled)
|
endsp(bool allkilled)
|
||||||
|
@ -397,8 +397,8 @@ monsterthink()
|
||||||
v.z -= monsters[i]->eyeheight;
|
v.z -= monsters[i]->eyeheight;
|
||||||
if (dist < 4)
|
if (dist < 4)
|
||||||
teleport((int)(&e - &ents[0]), monsters[i]);
|
teleport((int)(&e - &ents[0]), monsters[i]);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
loopv(monsters) if (monsters[i]->state == CS_ALIVE)
|
loopv(monsters) if (monsters[i]->state == CS_ALIVE)
|
||||||
monsteraction(monsters[i]);
|
monsteraction(monsters[i]);
|
||||||
|
|
|
@ -31,7 +31,7 @@ plcollide(dynent *d, dynent *o, float &headspace, float &hi,
|
||||||
headspace = 10;
|
headspace = 10;
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by,
|
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 cornertest(mip, x, y, dx, dy, bx, by, bs);
|
||||||
};
|
};
|
||||||
return stest;
|
return stest;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mmcollide(dynent *d, float &hi, float &lo) // collide with a mapmodel
|
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;
|
continue;
|
||||||
if (!plcollide(d, o, headspace, hi, lo))
|
if (!plcollide(d, o, headspace, hi, lo))
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
if (d != player1)
|
if (d != player1)
|
||||||
if (!plcollide(d, player1, headspace, hi, lo))
|
if (!plcollide(d, player1, headspace, hi, lo))
|
||||||
return false;
|
return false;
|
||||||
|
@ -213,7 +213,7 @@ float
|
||||||
rad(float x)
|
rad(float x)
|
||||||
{
|
{
|
||||||
return x * 3.14159f / 180;
|
return x * 3.14159f / 180;
|
||||||
};
|
}
|
||||||
|
|
||||||
VARP(maxroll, 0, 3, 20);
|
VARP(maxroll, 0, 3, 20);
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ physicsframe() // optimally schedule physics frames inside the graphics frames
|
||||||
} else {
|
} else {
|
||||||
physicsrepeat = 1;
|
physicsrepeat = 1;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
// main physics routine, moves a player/monster for a curtime step
|
// main physics routine, moves a player/monster for a curtime step
|
||||||
// moveres indicated the physics precision (which is lower for monsters and
|
// 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 gravity = 20;
|
||||||
const float f = 1.0f / moveres;
|
const float f = 1.0f / moveres;
|
||||||
float dropf =
|
float dropf = ((gravity - 1) +
|
||||||
((gravity - 1) +
|
|
||||||
pl->timeinair / 15.0f); // incorrect, but works fine
|
pl->timeinair / 15.0f); // incorrect, but works fine
|
||||||
if (water) {
|
if (water) {
|
||||||
dropf = 5;
|
dropf = 5;
|
||||||
pl->timeinair = 0;
|
pl->timeinair = 0;
|
||||||
}; // float slowly down in water
|
}; // float slowly down in water
|
||||||
const float drop =
|
const float drop = dropf * curtime / gravity / 100 /
|
||||||
dropf * curtime / gravity / 100 /
|
|
||||||
moveres; // at high fps, gravity kicks in too fast
|
moveres; // at high fps, gravity kicks in too fast
|
||||||
const float rise =
|
const float rise = speed / moveres /
|
||||||
speed / moveres /
|
|
||||||
1.2f; // extra smoothness when lifting up stairs
|
1.2f; // extra smoothness when lifting up stairs
|
||||||
|
|
||||||
loopi(moveres) // discrete steps collision detection & sliding
|
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;
|
pl->o.z -= f * d.z;
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// detect wether player is outside map, used for skipping zbuffer clear
|
// 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;
|
pl->outsidemap = true;
|
||||||
} else {
|
} else {
|
||||||
sqr *s = S((int)pl->o.x, (int)pl->o.y);
|
sqr *s = S((int)pl->o.x, (int)pl->o.y);
|
||||||
pl->outsidemap =
|
pl->outsidemap = SOLID(s) ||
|
||||||
SOLID(s) ||
|
|
||||||
pl->o.z < s->floor - (s->type == FHF ? s->vdelta / 4 : 0) ||
|
pl->o.z < s->floor - (s->type == FHF ? s->vdelta / 4 : 0) ||
|
||||||
pl->o.z > s->ceil + (s->type == CHF ? 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)
|
} else if (pl->inwater && !water)
|
||||||
playsound(S_SPLASH1, &pl->o);
|
playsound(S_SPLASH1, &pl->o);
|
||||||
pl->inwater = water;
|
pl->inwater = water;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
moveplayer(dynent *pl, int moveres, bool local)
|
moveplayer(dynent *pl, int moveres, bool local)
|
||||||
|
@ -403,4 +399,4 @@ moveplayer(dynent *pl, int moveres, bool local)
|
||||||
loopi(physicsrepeat) moveplayer(pl, moveres, local,
|
loopi(physicsrepeat) moveplayer(pl, moveres, local,
|
||||||
i ? curtime / physicsrepeat
|
i ? curtime / physicsrepeat
|
||||||
: curtime - curtime / physicsrepeat * (physicsrepeat - 1));
|
: curtime - curtime / physicsrepeat * (physicsrepeat - 1));
|
||||||
};
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ void
|
||||||
finishstrips()
|
finishstrips()
|
||||||
{
|
{
|
||||||
stripend();
|
stripend();
|
||||||
};
|
}
|
||||||
|
|
||||||
sqr sbright, sdark;
|
sqr sbright, sdark;
|
||||||
VAR(lighterror, 1, 8, 100);
|
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;
|
oy = y;
|
||||||
nquads++;
|
nquads++;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3,
|
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;
|
oy = y;
|
||||||
nquads++;
|
nquads++;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3,
|
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);
|
vertf((float)x1, h->ceil, (float)y1, l1, xf * x1, yf * y1);
|
||||||
addstrip(gltex, curvert - 3, 3);
|
addstrip(gltex, curvert - 3, 3);
|
||||||
nquads++;
|
nquads++;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s,
|
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,
|
render_2tris(h2, s, x + size, y, x + size, y + size, x,
|
||||||
y + size, t, u, v);
|
y + size, t, u, v);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2,
|
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++;
|
nquads++;
|
||||||
addstrip(gltex, curvert - 4, 4);
|
addstrip(gltex, curvert - 4, 4);
|
||||||
};
|
}
|
||||||
|
|
||||||
int wx1, wy1, wx2, wy2;
|
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();
|
vertcheck();
|
||||||
vertf((float)v1, v2 - (float)sin(v1 * v3 * 0.1 + t) * 0.2f, (float)v3,
|
vertf((float)v1, v2 - (float)sin(v1 * v3 * 0.1 + t) * 0.2f, (float)v3,
|
||||||
c, t1, t2);
|
c, t1, t2);
|
||||||
};
|
}
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
dx(float x)
|
dx(float x)
|
||||||
{
|
{
|
||||||
return x + (float)sin(x * 2 + lastmillis / 1000.0f) * 0.04f;
|
return x + (float)sin(x * 2 + lastmillis / 1000.0f) * 0.04f;
|
||||||
};
|
}
|
||||||
inline float
|
inline float
|
||||||
dy(float x)
|
dy(float x)
|
||||||
{
|
{
|
||||||
return x + (float)sin(x * 2 + lastmillis / 900.0f + PI / 5) * 0.05f;
|
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
|
// renders water for bounding rect area that contains water... simple but very
|
||||||
// inefficient
|
// inefficient
|
||||||
|
@ -391,7 +391,7 @@ renderwater(float hf)
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
return nquads;
|
return nquads;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
addwaterquad(int x, int y, int size) // update bounding rect that contains water
|
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)
|
if (y2 > wy2)
|
||||||
wy2 = y2;
|
wy2 = y2;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resetcubes()
|
resetcubes()
|
||||||
|
@ -425,4 +425,4 @@ resetcubes()
|
||||||
nquads = 0;
|
nquads = 0;
|
||||||
sbright.r = sbright.g = sbright.b = 255;
|
sbright.r = sbright.g = sbright.b = 255;
|
||||||
sdark.r = sdark.g = sdark.b = 0;
|
sdark.r = sdark.g = sdark.b = 0;
|
||||||
};
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@ line(int x1, int y1, float z1, int x2, int y2, float z2)
|
||||||
glVertex3f((float)x2, z2, (float)y2);
|
glVertex3f((float)x2, z2, (float)y2);
|
||||||
glEnd();
|
glEnd();
|
||||||
xtraverts += 4;
|
xtraverts += 4;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
linestyle(float width, int r, int g, int b)
|
linestyle(float width, int r, int g, int b)
|
||||||
{
|
{
|
||||||
glLineWidth(width);
|
glLineWidth(width);
|
||||||
glColor3ub(r, g, b);
|
glColor3ub(r, g, b);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
box(block &b, float z1, float z2, float z3, float z4)
|
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);
|
glVertex3f((float)b.x, z4, (float)b.y + b.ys);
|
||||||
glEnd();
|
glEnd();
|
||||||
xtraverts += 4;
|
xtraverts += 4;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dot(int x, int y, float z)
|
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);
|
glVertex3f(x - DOF, (float)z, y + DOF);
|
||||||
glEnd();
|
glEnd();
|
||||||
xtraverts += 4;
|
xtraverts += 4;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
blendbox(int x1, int y1, int x2, int y2, bool border)
|
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_BLEND);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
};
|
}
|
||||||
|
|
||||||
const int MAXSPHERES = 50;
|
const int MAXSPHERES = 50;
|
||||||
struct sphere {
|
struct sphere {
|
||||||
|
@ -96,7 +96,7 @@ newsphere(OFVector3D &o, float max, int type)
|
||||||
{
|
{
|
||||||
spheres[i].next = sempty;
|
spheres[i].next = sempty;
|
||||||
sempty = &spheres[i];
|
sempty = &spheres[i];
|
||||||
};
|
}
|
||||||
sinit = true;
|
sinit = true;
|
||||||
};
|
};
|
||||||
if (sempty) {
|
if (sempty) {
|
||||||
|
@ -109,7 +109,7 @@ newsphere(OFVector3D &o, float max, int type)
|
||||||
p->next = slist;
|
p->next = slist;
|
||||||
slist = p;
|
slist = p;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
renderspheres(int time)
|
renderspheres(int time)
|
||||||
|
@ -144,7 +144,7 @@ renderspheres(int time)
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
};
|
}
|
||||||
|
|
||||||
string closeent;
|
string closeent;
|
||||||
OFString *entnames[] = {
|
OFString *entnames[] = {
|
||||||
|
@ -243,7 +243,7 @@ readmatrices()
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
glGetDoublev(GL_MODELVIEW_MATRIX, mm);
|
glGetDoublev(GL_MODELVIEW_MATRIX, mm);
|
||||||
glGetDoublev(GL_PROJECTION_MATRIX, pm);
|
glGetDoublev(GL_PROJECTION_MATRIX, pm);
|
||||||
};
|
}
|
||||||
|
|
||||||
// stupid function to cater for stupid ATI linux drivers that return incorrect
|
// stupid function to cater for stupid ATI linux drivers that return incorrect
|
||||||
// depth values
|
// depth values
|
||||||
|
@ -252,7 +252,7 @@ float
|
||||||
depthcorrect(float d)
|
depthcorrect(float d)
|
||||||
{
|
{
|
||||||
return (d <= 1 / 256.0f) ? d * 256 : d;
|
return (d <= 1 / 256.0f) ? d * 256 : d;
|
||||||
};
|
}
|
||||||
|
|
||||||
// find out the 3d target of the crosshair in the world easily and very
|
// 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
|
// 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 r = OFMakeVector3D(mm[0], mm[4], mm[8]);
|
||||||
OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]);
|
OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]);
|
||||||
setorient(r, u);
|
setorient(r, u);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawicon(float tx, float ty, int x, int y)
|
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);
|
glVertex2i(x, y + s);
|
||||||
glEnd();
|
glEnd();
|
||||||
xtraverts += 4;
|
xtraverts += 4;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
invertperspective()
|
invertperspective()
|
||||||
|
@ -312,7 +312,7 @@ invertperspective()
|
||||||
inv[3 * 4 + 3] = pm[2 * 4 + 2] / pm[3 * 4 + 2];
|
inv[3 * 4 + 3] = pm[2 * 4 + 2] / pm[3 * 4 + 2];
|
||||||
|
|
||||||
glLoadMatrixd(inv);
|
glLoadMatrixd(inv);
|
||||||
};
|
}
|
||||||
|
|
||||||
VARP(crosshairsize, 0, 15, 50);
|
VARP(crosshairsize, 0, 15, 50);
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ void
|
||||||
damageblend(int n)
|
damageblend(int n)
|
||||||
{
|
{
|
||||||
dblend += n;
|
dblend += n;
|
||||||
};
|
}
|
||||||
|
|
||||||
VAR(hidestats, 0, 0, 1);
|
VAR(hidestats, 0, 0, 1);
|
||||||
VARP(crosshairfx, 0, 1, 1);
|
VARP(crosshairfx, 0, 1, 1);
|
||||||
|
|
|
@ -63,7 +63,7 @@ gl_init(int w, int h)
|
||||||
glNewList(1, GL_COMPILE);
|
glNewList(1, GL_COMPILE);
|
||||||
gluSphere(qsphere, 1, 12, 6);
|
gluSphere(qsphere, 1, 12, 6);
|
||||||
glEndList();
|
glEndList();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleangl()
|
cleangl()
|
||||||
|
@ -174,7 +174,7 @@ void
|
||||||
purgetextures()
|
purgetextures()
|
||||||
{
|
{
|
||||||
loopi(256) loop(j, MAXFRAMES) mapping[i][j] = 0;
|
loopi(256) loop(j, MAXFRAMES) mapping[i][j] = 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
int curtexnum = 0;
|
int curtexnum = 0;
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ setupworld()
|
||||||
glTexEnvi(
|
glTexEnvi(
|
||||||
GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
|
GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
int skyoglid;
|
int skyoglid;
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ transplayer()
|
||||||
(player1->state == CS_DEAD ? player1->eyeheight - 0.2f : 0) -
|
(player1->state == CS_DEAD ? player1->eyeheight - 0.2f : 0) -
|
||||||
player1->o.z,
|
player1->o.z,
|
||||||
-player1->o.y);
|
-player1->o.y);
|
||||||
};
|
}
|
||||||
|
|
||||||
VARP(fov, 10, 105, 120);
|
VARP(fov, 10, 105, 120);
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ drawhudgun(float fovy, float aspect, int farplane)
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gl_drawframe(int w, int h, float curfps)
|
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_CULL_FACE);
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
};
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
|
||||||
{
|
{
|
||||||
particles[i].next = parempty;
|
particles[i].next = parempty;
|
||||||
parempty = &particles[i];
|
parempty = &particles[i];
|
||||||
};
|
}
|
||||||
parinit = true;
|
parinit = true;
|
||||||
};
|
};
|
||||||
if (parempty) {
|
if (parempty) {
|
||||||
|
@ -37,7 +37,7 @@ newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
|
||||||
p->next = parlist;
|
p->next = parlist;
|
||||||
parlist = p;
|
parlist = p;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
VAR(demotracking, 0, 0, 1);
|
VAR(demotracking, 0, 0, 1);
|
||||||
VARP(particlesize, 20, 100, 500);
|
VARP(particlesize, 20, 100, 500);
|
||||||
|
@ -129,7 +129,7 @@ render_particles(int time)
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
particle_splash(int type, int num, int fade, OFVector3D &p)
|
particle_splash(int type, int num, int fade, OFVector3D &p)
|
||||||
|
|
|
@ -86,4 +86,4 @@ perlinarea(block &b, int scale, int seed, int psize)
|
||||||
if (s->vdelta > 128)
|
if (s->vdelta > 128)
|
||||||
s->vdelta = 0;
|
s->vdelta = 0;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ loadgamerest()
|
||||||
ents[i].spawned = gzgetc(f) != 0;
|
ents[i].spawned = gzgetc(f) != 0;
|
||||||
if (ents[i].type == CARROT && !ents[i].spawned)
|
if (ents[i].type == CARROT && !ents[i].spawned)
|
||||||
trigger(ents[i].attr1, ents[i].attr2, true);
|
trigger(ents[i].attr1, ents[i].attr2, true);
|
||||||
};
|
}
|
||||||
restoreserverstate(ents);
|
restoreserverstate(ents);
|
||||||
|
|
||||||
gzread(f, player1, sizeof(dynent));
|
gzread(f, player1, sizeof(dynent));
|
||||||
|
@ -230,12 +230,11 @@ loadgamerest()
|
||||||
gzread(f, monsters[i], sizeof(dynent));
|
gzread(f, monsters[i], sizeof(dynent));
|
||||||
monsters[i]->enemy =
|
monsters[i]->enemy =
|
||||||
player1; // lazy, could save id of enemy instead
|
player1; // lazy, could save id of enemy instead
|
||||||
monsters[i]->lastaction = monsters[i]->trigger =
|
monsters[i]->lastaction = monsters[i]->trigger = lastmillis +
|
||||||
lastmillis +
|
|
||||||
500; // also lazy, but no real noticable effect on game
|
500; // also lazy, but no real noticable effect on game
|
||||||
if (monsters[i]->state == CS_DEAD)
|
if (monsters[i]->state == CS_DEAD)
|
||||||
monsters[i]->lastaction = 0;
|
monsters[i]->lastaction = 0;
|
||||||
};
|
}
|
||||||
restoremonsterstate();
|
restoremonsterstate();
|
||||||
|
|
||||||
int nplayers = gzgeti();
|
int nplayers = gzgeti();
|
||||||
|
@ -244,7 +243,7 @@ loadgamerest()
|
||||||
dynent *d = getclient(i);
|
dynent *d = getclient(i);
|
||||||
assert(d);
|
assert(d);
|
||||||
gzread(f, d, sizeof(dynent));
|
gzread(f, d, sizeof(dynent));
|
||||||
};
|
}
|
||||||
|
|
||||||
conoutf(@"savegame restored");
|
conoutf(@"savegame restored");
|
||||||
if (demoloading)
|
if (demoloading)
|
||||||
|
@ -292,12 +291,12 @@ demodamage(int damage, OFVector3D &o)
|
||||||
{
|
{
|
||||||
ddamage = damage;
|
ddamage = damage;
|
||||||
dorig = o;
|
dorig = o;
|
||||||
};
|
}
|
||||||
void
|
void
|
||||||
demoblend(int damage)
|
demoblend(int damage)
|
||||||
{
|
{
|
||||||
bdamage = damage;
|
bdamage = damage;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incomingdemodata(uchar *buf, int len, bool extras)
|
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);
|
vadd(dest, t1);
|
||||||
vmul(t2, s3 - s2);
|
vmul(t2, s3 - s2);
|
||||||
vadd(dest, t2);
|
vadd(dest, t2);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fixwrap(dynent *a, dynent *b)
|
fixwrap(dynent *a, dynent *b)
|
||||||
|
@ -418,7 +417,7 @@ fixwrap(dynent *a, dynent *b)
|
||||||
a->yaw += 360;
|
a->yaw += 360;
|
||||||
while (b->yaw - a->yaw < -180)
|
while (b->yaw - a->yaw < -180)
|
||||||
a->yaw -= 360;
|
a->yaw -= 360;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
demoplaybackstep()
|
demoplaybackstep()
|
||||||
|
@ -500,8 +499,7 @@ demoplaybackstep()
|
||||||
z = playerhistory[i - 1];
|
z = playerhistory[i - 1];
|
||||||
// if(a==z || b==c) printf("* %d\n",
|
// if(a==z || b==c) printf("* %d\n",
|
||||||
// lastmillis);
|
// lastmillis);
|
||||||
float bf =
|
float bf = (itime - a->lastupdate) /
|
||||||
(itime - a->lastupdate) /
|
|
||||||
(float)(b->lastupdate - a->lastupdate);
|
(float)(b->lastupdate - a->lastupdate);
|
||||||
fixwrap(a, player1);
|
fixwrap(a, player1);
|
||||||
fixwrap(c, player1);
|
fixwrap(c, player1);
|
||||||
|
|
|
@ -40,8 +40,8 @@ restoreserverstate(
|
||||||
{
|
{
|
||||||
sents[i].spawned = ents[i].spawned;
|
sents[i].spawned = ents[i].spawned;
|
||||||
sents[i].spawnsecs = 0;
|
sents[i].spawnsecs = 0;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
int interm = 0, minremain = 0, mapend = 0;
|
int interm = 0, minremain = 0, mapend = 0;
|
||||||
bool mapreload = false;
|
bool mapreload = false;
|
||||||
|
@ -74,7 +74,7 @@ send(int n, ENetPacket *packet)
|
||||||
localservertoclient(packet->data, packet->dataLength);
|
localservertoclient(packet->data, packet->dataLength);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
send2(bool rel, int cn, int a, int b)
|
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);
|
send(cn, packet);
|
||||||
if (packet->referenceCount == 0)
|
if (packet->referenceCount == 0)
|
||||||
enet_packet_destroy(packet);
|
enet_packet_destroy(packet);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sendservmsg(OFString *msg)
|
sendservmsg(OFString *msg)
|
||||||
|
@ -118,14 +118,14 @@ disconnect_client(int n, char *reason)
|
||||||
enet_peer_disconnect(clients[n].peer);
|
enet_peer_disconnect(clients[n].peer);
|
||||||
clients[n].type = ST_EMPTY;
|
clients[n].type = ST_EMPTY;
|
||||||
send2(true, -1, SV_CDIS, n);
|
send2(true, -1, SV_CDIS, n);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resetitems()
|
resetitems()
|
||||||
{
|
{
|
||||||
sents.setsize(0);
|
sents.setsize(0);
|
||||||
notgotitems = true;
|
notgotitems = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pickup(uint i, int sec, int sender) // server side item pickup, acknowledge
|
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;
|
sents[i].spawnsecs = sec;
|
||||||
send2(true, sender, SV_ITEMACC, i);
|
send2(true, sender, SV_ITEMACC, i);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resetvotes()
|
resetvotes()
|
||||||
{
|
{
|
||||||
loopv(clients) clients[i].mapvote[0] = 0;
|
loopv(clients) clients[i].mapvote[0] = 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
vote(char *map, int reqmode, int sender)
|
vote(char *map, int reqmode, int sender)
|
||||||
|
@ -162,7 +162,7 @@ vote(char *map, int reqmode, int sender)
|
||||||
no++;
|
no++;
|
||||||
} else
|
} else
|
||||||
no++;
|
no++;
|
||||||
};
|
}
|
||||||
if (yes == 1 && no == 0)
|
if (yes == 1 && no == 0)
|
||||||
return true; // single player
|
return true; // single player
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
@ -177,7 +177,7 @@ vote(char *map, int reqmode, int sender)
|
||||||
sendservmsg(@"vote passed");
|
sendservmsg(@"vote passed");
|
||||||
resetvotes();
|
resetvotes();
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
// server side processing of updates: does very little and most state is tracked
|
// 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
|
// 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;
|
return;
|
||||||
};
|
};
|
||||||
multicast(packet, sender);
|
multicast(packet, sender);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
send_welcome(int n)
|
send_welcome(int n)
|
||||||
|
@ -341,8 +341,8 @@ multicast(ENetPacket *packet, int sender)
|
||||||
if (i == sender)
|
if (i == sender)
|
||||||
continue;
|
continue;
|
||||||
send(i, packet);
|
send(i, packet);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
localclienttoserver(ENetPacket *packet)
|
localclienttoserver(ENetPacket *packet)
|
||||||
|
@ -350,14 +350,14 @@ localclienttoserver(ENetPacket *packet)
|
||||||
process(packet, 0);
|
process(packet, 0);
|
||||||
if (!packet->referenceCount)
|
if (!packet->referenceCount)
|
||||||
enet_packet_destroy(packet);
|
enet_packet_destroy(packet);
|
||||||
};
|
}
|
||||||
|
|
||||||
client &
|
client &
|
||||||
addclient()
|
addclient()
|
||||||
{
|
{
|
||||||
loopv(clients) if (clients[i].type == ST_EMPTY) return clients[i];
|
loopv(clients) if (clients[i].type == ST_EMPTY) return clients[i];
|
||||||
return clients.add();
|
return clients.add();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkintermission()
|
checkintermission()
|
||||||
|
@ -367,14 +367,14 @@ checkintermission()
|
||||||
mapend = lastsec + 1000;
|
mapend = lastsec + 1000;
|
||||||
};
|
};
|
||||||
send2(true, -1, SV_TIMEUP, minremain--);
|
send2(true, -1, SV_TIMEUP, minremain--);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
startintermission()
|
startintermission()
|
||||||
{
|
{
|
||||||
minremain = 0;
|
minremain = 0;
|
||||||
checkintermission();
|
checkintermission();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resetserverifempty()
|
resetserverifempty()
|
||||||
|
@ -407,7 +407,7 @@ serverslice(int seconds,
|
||||||
sents[i].spawned = true;
|
sents[i].spawned = true;
|
||||||
send2(true, -1, SV_ITEMSPAWN, i);
|
send2(true, -1, SV_ITEMSPAWN, i);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
lastsec = seconds;
|
lastsec = seconds;
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ serverslice(int seconds,
|
||||||
0); // ask a client to trigger map reload
|
0); // ask a client to trigger map reload
|
||||||
mapreload = true;
|
mapreload = true;
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resetserverifempty();
|
resetserverifempty();
|
||||||
|
@ -459,9 +459,9 @@ serverslice(int seconds,
|
||||||
c.peer = event.peer;
|
c.peer = event.peer;
|
||||||
c.peer->data = (void *)(&c - &clients[0]);
|
c.peer->data = (void *)(&c - &clients[0]);
|
||||||
char hn[1024];
|
char hn[1024];
|
||||||
strcpy_s(
|
strcpy_s(c.hostname,
|
||||||
c.hostname, (enet_address_get_host(&c.peer->address,
|
(enet_address_get_host(
|
||||||
hn, sizeof(hn)) == 0)
|
&c.peer->address, hn, sizeof(hn)) == 0)
|
||||||
? hn
|
? hn
|
||||||
: "localhost");
|
: "localhost");
|
||||||
printf("client connected (%s)\n", c.hostname);
|
printf("client connected (%s)\n", c.hostname);
|
||||||
|
@ -493,21 +493,21 @@ serverslice(int seconds,
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanupserver()
|
cleanupserver()
|
||||||
{
|
{
|
||||||
if (serverhost)
|
if (serverhost)
|
||||||
enet_host_destroy(serverhost);
|
enet_host_destroy(serverhost);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
localdisconnect()
|
localdisconnect()
|
||||||
{
|
{
|
||||||
loopv(clients) if (clients[i].type == ST_LOCAL) clients[i].type =
|
loopv(clients) if (clients[i].type == ST_LOCAL) clients[i].type =
|
||||||
ST_EMPTY;
|
ST_EMPTY;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
localconnect()
|
localconnect()
|
||||||
|
@ -516,7 +516,7 @@ localconnect()
|
||||||
c.type = ST_LOCAL;
|
c.type = ST_LOCAL;
|
||||||
strcpy_s(c.hostname, "local");
|
strcpy_s(c.hostname, "local");
|
||||||
send_welcome(&c - &clients[0]);
|
send_welcome(&c - &clients[0]);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip,
|
initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip,
|
||||||
|
@ -554,4 +554,4 @@ initserver(bool dedicated, int uprate, OFString *sdesc, OFString *ip,
|
||||||
for (;;)
|
for (;;)
|
||||||
serverslice(/*enet_time_get_sec()*/ time(NULL), 5);
|
serverslice(/*enet_time_get_sec()*/ time(NULL), 5);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ resolverloop(void *data)
|
||||||
SDL_UnlockMutex(resolvermutex);
|
SDL_UnlockMutex(resolvermutex);
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resolverinit(int threads, int limit)
|
resolverinit(int threads, int limit)
|
||||||
|
@ -92,9 +92,9 @@ resolverclear()
|
||||||
{
|
{
|
||||||
resolverthread &rt = resolverthreads[i];
|
resolverthread &rt = resolverthreads[i];
|
||||||
resolverstop(rt, true);
|
resolverstop(rt, true);
|
||||||
};
|
}
|
||||||
SDL_UnlockMutex(resolvermutex);
|
SDL_UnlockMutex(resolvermutex);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resolverquery(char *name)
|
resolverquery(char *name)
|
||||||
|
@ -103,7 +103,7 @@ resolverquery(char *name)
|
||||||
resolverqueries.add(name);
|
resolverqueries.add(name);
|
||||||
SDL_SemPost(resolversem);
|
SDL_SemPost(resolversem);
|
||||||
SDL_UnlockMutex(resolvermutex);
|
SDL_UnlockMutex(resolvermutex);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
resolvercheck(char **name, ENetAddress *address)
|
resolvercheck(char **name, ENetAddress *address)
|
||||||
|
@ -127,10 +127,10 @@ resolvercheck(char **name, ENetAddress *address)
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
SDL_UnlockMutex(resolvermutex);
|
SDL_UnlockMutex(resolvermutex);
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
struct serverinfo {
|
struct serverinfo {
|
||||||
string name;
|
string name;
|
||||||
|
@ -191,9 +191,9 @@ pingservers()
|
||||||
buf.data = ping;
|
buf.data = ping;
|
||||||
buf.dataLength = p - ping;
|
buf.dataLength = p - ping;
|
||||||
enet_socket_send(pingsock, &si.address, &buf, 1);
|
enet_socket_send(pingsock, &si.address, &buf, 1);
|
||||||
};
|
}
|
||||||
lastinfo = lastmillis;
|
lastinfo = lastmillis;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkresolver()
|
checkresolver()
|
||||||
|
@ -285,8 +285,7 @@ refreshservers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf_s(si.full)(
|
sprintf_s(si.full)(si.address.host != ENET_HOST_ANY
|
||||||
si.address.host != ENET_HOST_ANY
|
|
||||||
? "%s [waiting for server response]"
|
? "%s [waiting for server response]"
|
||||||
: "%s [unknown host]\t",
|
: "%s [unknown host]\t",
|
||||||
si.name);
|
si.name);
|
||||||
|
@ -311,7 +310,7 @@ servermenu()
|
||||||
loopv(servers) resolverquery(servers[i].name);
|
loopv(servers) resolverquery(servers[i].name);
|
||||||
refreshservers();
|
refreshservers();
|
||||||
menuset(1);
|
menuset(1);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatefrommaster()
|
updatefrommaster()
|
||||||
|
|
|
@ -51,7 +51,7 @@ httpgetrecieve(ENetBuffer &buf)
|
||||||
((char *)buf.data)[0] = 0;
|
((char *)buf.data)[0] = 0;
|
||||||
buf.dataLength -= len;
|
buf.dataLength -= len;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
uchar *
|
uchar *
|
||||||
stripheader(uchar *b)
|
stripheader(uchar *b)
|
||||||
|
@ -60,7 +60,7 @@ stripheader(uchar *b)
|
||||||
if (!s)
|
if (!s)
|
||||||
s = strstr((char *)b, "\n\n");
|
s = strstr((char *)b, "\n\n");
|
||||||
return s ? (uchar *)s : b;
|
return s ? (uchar *)s : b;
|
||||||
};
|
}
|
||||||
|
|
||||||
ENetAddress masterserver = {ENET_HOST_ANY, 80};
|
ENetAddress masterserver = {ENET_HOST_ANY, 80};
|
||||||
int updmaster = 0;
|
int updmaster = 0;
|
||||||
|
@ -83,7 +83,7 @@ updatemasterserver(int seconds)
|
||||||
masterb.dataLength = MAXTRANS - 1;
|
masterb.dataLength = MAXTRANS - 1;
|
||||||
updmaster = seconds + 60 * 60;
|
updmaster = seconds + 60 * 60;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkmasterreply()
|
checkmasterreply()
|
||||||
|
@ -92,7 +92,7 @@ checkmasterreply()
|
||||||
httpgetrecieve(masterb);
|
httpgetrecieve(masterb);
|
||||||
if (busy && mssock == ENET_SOCKET_NULL)
|
if (busy && mssock == ENET_SOCKET_NULL)
|
||||||
printf("masterserver reply: %s\n", stripheader(masterrep));
|
printf("masterserver reply: %s\n", stripheader(masterrep));
|
||||||
};
|
}
|
||||||
|
|
||||||
uchar *
|
uchar *
|
||||||
retrieveservers(uchar *buf, int buflen)
|
retrieveservers(uchar *buf, int buflen)
|
||||||
|
@ -107,7 +107,7 @@ retrieveservers(uchar *buf, int buflen)
|
||||||
while (mssock != ENET_SOCKET_NULL)
|
while (mssock != ENET_SOCKET_NULL)
|
||||||
httpgetrecieve(eb);
|
httpgetrecieve(eb);
|
||||||
return stripheader(buf);
|
return stripheader(buf);
|
||||||
};
|
}
|
||||||
|
|
||||||
ENetSocket pongsock = ENET_SOCKET_NULL;
|
ENetSocket pongsock = ENET_SOCKET_NULL;
|
||||||
static OFString *serverdesc;
|
static OFString *serverdesc;
|
||||||
|
|
|
@ -21,7 +21,7 @@ putint(uchar *&p, int n)
|
||||||
*p++ = n >> 16;
|
*p++ = n >> 16;
|
||||||
*p++ = n >> 24;
|
*p++ = n >> 24;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
getint(uchar *&p)
|
getint(uchar *&p)
|
||||||
|
@ -93,7 +93,7 @@ msgsizelookup(int msg)
|
||||||
if (*p == msg)
|
if (*p == msg)
|
||||||
return p[1];
|
return p[1];
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
|
|
||||||
// sending of maps between clients
|
// sending of maps between clients
|
||||||
|
|
||||||
|
|
18
src/sound.mm
18
src/sound.mm
|
@ -52,7 +52,7 @@ stopsound()
|
||||||
#endif
|
#endif
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
VAR(soundbufferlen, 128, 1024, 4096);
|
VAR(soundbufferlen, 128, 1024, 4096);
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ cleansound()
|
||||||
#else
|
#else
|
||||||
FSOUND_Close();
|
FSOUND_Close();
|
||||||
#endif
|
#endif
|
||||||
};
|
}
|
||||||
|
|
||||||
VAR(stereo, 0, 1, 1);
|
VAR(stereo, 0, 1, 1);
|
||||||
|
|
||||||
|
@ -179,8 +179,8 @@ updatechanvol(int chan, OFVector3D *loc)
|
||||||
player1->yaw *
|
player1->yaw *
|
||||||
(PI / 180.0f); // relative angle of
|
(PI / 180.0f); // relative angle of
|
||||||
// sound along X-Y axis
|
// sound along X-Y axis
|
||||||
pan = int(255.9f * (0.5 * sin(yaw) +
|
pan = int(255.9f *
|
||||||
0.5f)); // range is from 0 (left)
|
(0.5 * sin(yaw) + 0.5f)); // range is from 0 (left)
|
||||||
// to 255 (right)
|
// to 255 (right)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ updatechanvol(int chan, OFVector3D *loc)
|
||||||
FSOUND_SetVolume(chan, vol);
|
FSOUND_SetVolume(chan, vol);
|
||||||
FSOUND_SetPan(chan, pan);
|
FSOUND_SetPan(chan, pan);
|
||||||
#endif
|
#endif
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
newsoundloc(int chan, OFVector3D *loc)
|
newsoundloc(int chan, OFVector3D *loc)
|
||||||
|
@ -200,7 +200,7 @@ newsoundloc(int chan, OFVector3D *loc)
|
||||||
assert(chan >= 0 && chan < MAXCHAN);
|
assert(chan >= 0 && chan < MAXCHAN);
|
||||||
soundlocs[chan].loc = *loc;
|
soundlocs[chan].loc = *loc;
|
||||||
soundlocs[chan].inuse = true;
|
soundlocs[chan].inuse = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatevol()
|
updatevol()
|
||||||
|
@ -217,15 +217,15 @@ updatevol()
|
||||||
updatechanvol(i, &soundlocs[i].loc);
|
updatechanvol(i, &soundlocs[i].loc);
|
||||||
else
|
else
|
||||||
soundlocs[i].inuse = false;
|
soundlocs[i].inuse = false;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
playsoundc(int n)
|
playsoundc(int n)
|
||||||
{
|
{
|
||||||
addmsg(0, 2, SV_SOUND, n);
|
addmsg(0, 2, SV_SOUND, n);
|
||||||
playsound(n);
|
playsound(n);
|
||||||
};
|
}
|
||||||
|
|
||||||
int soundsatonce = 0, lastsoundmillis = 0;
|
int soundsatonce = 0, lastsoundmillis = 0;
|
||||||
|
|
||||||
|
|
|
@ -17,5 +17,5 @@ endianswap(
|
||||||
uchar t = p[i];
|
uchar t = p[i];
|
||||||
p[i] = p[stride - i - 1];
|
p[i] = p[stride - i - 1];
|
||||||
p[stride - i - 1] = t;
|
p[stride - i - 1] = t;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
41
src/world.mm
41
src/world.mm
|
@ -35,23 +35,23 @@ settag(int tag, int type) // set all cubes with "tag" to space, if tag is 0 then
|
||||||
if (y < miny)
|
if (y < miny)
|
||||||
miny = y;
|
miny = y;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
block b = {minx, miny, maxx - minx + 1, maxy - miny + 1};
|
block b = {minx, miny, maxx - minx + 1, maxy - miny + 1};
|
||||||
if (maxx)
|
if (maxx)
|
||||||
remip(b); // remip minimal area of changed geometry
|
remip(b); // remip minimal area of changed geometry
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resettagareas()
|
resettagareas()
|
||||||
{
|
{
|
||||||
settag(0, 0);
|
settag(0, 0);
|
||||||
}; // reset for editing or map saving
|
} // reset for editing or map saving
|
||||||
void
|
void
|
||||||
settagareas()
|
settagareas()
|
||||||
{
|
{
|
||||||
settag(0, 1);
|
settag(0, 1);
|
||||||
loopv(ents) if (ents[i].type == CARROT) setspawn(i, true);
|
loopv(ents) if (ents[i].type == CARROT) setspawn(i, true);
|
||||||
}; // set for playing
|
} // set for playing
|
||||||
|
|
||||||
void
|
void
|
||||||
trigger(int tag, int type, bool savegame)
|
trigger(int tag, int type, bool savegame)
|
||||||
|
@ -137,8 +137,7 @@ remip(block &b, int level)
|
||||||
// large mips
|
// large mips
|
||||||
// next to hfs
|
// next to hfs
|
||||||
if (o[i]->type == CHF)
|
if (o[i]->type == CHF)
|
||||||
ch +=
|
ch += o[i]->vdelta / 4 +
|
||||||
o[i]->vdelta / 4 +
|
|
||||||
2; // FIXME: needs
|
2; // FIXME: needs
|
||||||
// to somehow
|
// to somehow
|
||||||
// take into
|
// take into
|
||||||
|
@ -155,7 +154,7 @@ remip(block &b, int level)
|
||||||
// from the side
|
// from the side
|
||||||
if (ch > ceil)
|
if (ch > ceil)
|
||||||
ceil = ch;
|
ceil = ch;
|
||||||
};
|
}
|
||||||
r->floor = floor;
|
r->floor = floor;
|
||||||
r->ceil = ceil;
|
r->ceil = ceil;
|
||||||
};
|
};
|
||||||
|
@ -172,7 +171,7 @@ remip(block &b, int level)
|
||||||
// to be equal for a
|
// to be equal for a
|
||||||
// perfect mip is the
|
// perfect mip is the
|
||||||
// wall texture
|
// wall texture
|
||||||
};
|
}
|
||||||
} else {
|
} else {
|
||||||
loopi(3)
|
loopi(3)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +191,7 @@ remip(block &b, int level)
|
||||||
o[i]->utex != o[3]->utex ||
|
o[i]->utex != o[3]->utex ||
|
||||||
o[i]->wtex != o[3]->wtex)
|
o[i]->wtex != o[3]->wtex)
|
||||||
goto c;
|
goto c;
|
||||||
};
|
}
|
||||||
if (r->type == CHF ||
|
if (r->type == CHF ||
|
||||||
r->type ==
|
r->type ==
|
||||||
FHF) // can make a perfect mip out of a
|
FHF) // can make a perfect mip out of a
|
||||||
|
@ -234,7 +233,7 @@ remip(block &b, int level)
|
||||||
s.xs /= 2;
|
s.xs /= 2;
|
||||||
s.ys /= 2;
|
s.ys /= 2;
|
||||||
remip(s, level + 1);
|
remip(s, level + 1);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
remipmore(block &b, int level)
|
remipmore(block &b, int level)
|
||||||
|
@ -249,7 +248,7 @@ remipmore(block &b, int level)
|
||||||
if (bb.ys < ssize - 3)
|
if (bb.ys < ssize - 3)
|
||||||
bb.ys++;
|
bb.ys++;
|
||||||
remip(bb, level);
|
remip(bb, level);
|
||||||
};
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
closestent() // used for delent and edit mode ent display
|
closestent() // used for delent and edit mode ent display
|
||||||
|
@ -269,9 +268,9 @@ closestent() // used for delent and edit mode ent display
|
||||||
best = i;
|
best = i;
|
||||||
bdist = dist;
|
bdist = dist;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
return bdist == 99999 ? -1 : best;
|
return bdist == 99999 ? -1 : best;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
entproperty(int prop, int amount)
|
entproperty(int prop, int amount)
|
||||||
|
@ -293,7 +292,7 @@ entproperty(int prop, int amount)
|
||||||
ents[e].attr4 += amount;
|
ents[e].attr4 += amount;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
delent()
|
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)
|
if (type == LIGHT)
|
||||||
calclight();
|
calclight();
|
||||||
return &ents.last();
|
return &ents.last();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clearents(OFString *name)
|
clearents(OFString *name)
|
||||||
|
@ -368,7 +367,7 @@ clearents(OFString *name)
|
||||||
entity &e = ents[i];
|
entity &e = ents[i];
|
||||||
if (e.type == type)
|
if (e.type == type)
|
||||||
e.type = NOTUSED;
|
e.type = NOTUSED;
|
||||||
};
|
}
|
||||||
if (type == LIGHT)
|
if (type == LIGHT)
|
||||||
calclight();
|
calclight();
|
||||||
}
|
}
|
||||||
|
@ -381,7 +380,7 @@ scalecomp(uchar &c, int intens)
|
||||||
if (n > 255)
|
if (n > 255)
|
||||||
n = 255;
|
n = 255;
|
||||||
c = n;
|
c = n;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scalelights(int f, int intens)
|
scalelights(int f, int intens)
|
||||||
|
@ -401,7 +400,7 @@ scalelights(int f, int intens)
|
||||||
scalecomp(e.attr3, intens);
|
scalecomp(e.attr3, intens);
|
||||||
scalecomp(e.attr4, intens);
|
scalecomp(e.attr4, intens);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
calclight();
|
calclight();
|
||||||
}
|
}
|
||||||
COMMAND(scalelights, ARG_2INT)
|
COMMAND(scalelights, ARG_2INT)
|
||||||
|
@ -414,7 +413,7 @@ findentity(int type, int index)
|
||||||
return i;
|
return i;
|
||||||
loopj(index) if (ents[j].type == type) return j;
|
loopj(index) if (ents[j].type == type) return j;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
|
|
||||||
sqr *wmip[LARGEST_FACTOR * 2];
|
sqr *wmip[LARGEST_FACTOR * 2];
|
||||||
|
|
||||||
|
@ -429,8 +428,8 @@ setupworld(int factor)
|
||||||
{
|
{
|
||||||
wmip[i] = w;
|
wmip[i] = w;
|
||||||
w += cubicsize >> (i * 2);
|
w += cubicsize >> (i * 2);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
empty_world(
|
empty_world(
|
||||||
|
|
|
@ -77,7 +77,7 @@ lightray(float bx, float by,
|
||||||
stepl -= 25;
|
stepl -= 25;
|
||||||
stepg -= 25;
|
stepg -= 25;
|
||||||
stepb -= 25;
|
stepb -= 25;
|
||||||
};
|
}
|
||||||
} else // white light, special optimized version
|
} else // white light, special optimized version
|
||||||
{
|
{
|
||||||
int dimness = rnd((255 - light.attr2) / 16 + 1);
|
int dimness = rnd((255 - light.attr2) / 16 + 1);
|
||||||
|
@ -98,7 +98,7 @@ lightray(float bx, float by,
|
||||||
y += stepy;
|
y += stepy;
|
||||||
l -= stepl;
|
l -= stepl;
|
||||||
stepl -= 25;
|
stepl -= 25;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
} else // the old (white) light code, here for the few people with old
|
} else // the old (white) light code, here for the few people with old
|
||||||
// video cards that don't support overbright
|
// video cards that don't support overbright
|
||||||
|
@ -114,9 +114,9 @@ lightray(float bx, float by,
|
||||||
x += stepx;
|
x += stepx;
|
||||||
y += stepy;
|
y += stepy;
|
||||||
l -= stepl;
|
l -= stepl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
calclightsource(persistent_entity &l)
|
calclightsource(persistent_entity &l)
|
||||||
|
@ -141,7 +141,7 @@ calclightsource(persistent_entity &l)
|
||||||
};
|
};
|
||||||
|
|
||||||
rndtime();
|
rndtime();
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
postlightarea(block &a) // median filter, smooths out random noise in light and
|
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(r);
|
||||||
median(g);
|
median(g);
|
||||||
median(b);
|
median(b);
|
||||||
};
|
}
|
||||||
|
|
||||||
remip(a);
|
remip(a);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
calclight()
|
calclight()
|
||||||
|
|
|
@ -76,8 +76,8 @@ computeraytable(float vx, float vy)
|
||||||
} else {
|
} else {
|
||||||
rdist[i] = 2;
|
rdist[i] = 2;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// test occlusion for a cube... one of the most computationally expensive
|
// 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
|
// 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)
|
ca(float x, float y)
|
||||||
{
|
{
|
||||||
return x > y ? y / x : 2 - x / y;
|
return x > y ? y / x : 2 - x / y;
|
||||||
};
|
}
|
||||||
inline float
|
inline float
|
||||||
ma(float x, float y)
|
ma(float x, float y)
|
||||||
{
|
{
|
||||||
return x == 0 ? (y > 0 ? 2 : -2) : y / x;
|
return x == 0 ? (y > 0 ? 2 : -2) : y / x;
|
||||||
};
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
isoccluded(float vx, float vy, float cx, float cy,
|
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
|
return 1; // cube is entirely occluded
|
||||||
};
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ skip: {
|
||||||
render_square(o->utex, f1, f2, c1, c2, x1 << mip, y1 << mip, x2 << mip,
|
render_square(o->utex, f1, f2, c1, c2, x1 << mip, y1 << mip, x2 << mip,
|
||||||
y2 << mip, 1 << mip, d1, d2, topleft);
|
y2 << mip, 1 << mip, d1, d2, topleft);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
const int MAX_MIP = 5; // 32x32 unit blocks
|
const int MAX_MIP = 5; // 32x32 unit blocks
|
||||||
const int MIN_LOD = 2;
|
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 true;
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool render_floor, render_ceil;
|
bool render_floor, render_ceil;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ render_seg_new(
|
||||||
render_seg_new(vx, vy, vh, mip - 1, xx * 2, start * 2,
|
render_seg_new(vx, vy, vh, mip - 1, xx * 2, start * 2,
|
||||||
xx * 2 + 2, yy * 2 + 2);
|
xx * 2 + 2, yy * 2 + 2);
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
stats[mip]++;
|
stats[mip]++;
|
||||||
LOOPD
|
LOOPD
|
||||||
if ((s->type == SPACE || s->type == FHF) && s->ceil >= vh &&
|
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;
|
low = min_lod;
|
||||||
if (high < min_lod)
|
if (high < min_lod)
|
||||||
high = min_lod;
|
high = min_lod;
|
||||||
};
|
}
|
||||||
|
|
||||||
// does some out of date view frustrum optimisation that doesn't contribute much
|
// does some out of date view frustrum optimisation that doesn't contribute much
|
||||||
// anymore
|
// anymore
|
||||||
|
@ -328,7 +328,8 @@ render_world(
|
||||||
if (cdist < 7) // hack to avoid popup at high fovs at 45 yaw
|
if (cdist < 7) // hack to avoid popup at high fovs at 45 yaw
|
||||||
{
|
{
|
||||||
min_lod = max(min_lod,
|
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)); // less if lod worked better
|
||||||
widef = 1.0f;
|
widef = 1.0f;
|
||||||
};
|
};
|
||||||
|
@ -355,4 +356,4 @@ render_world(
|
||||||
render_seg_new(
|
render_seg_new(
|
||||||
vx, vy, vh, MAX_MIP, 0, 0, ssize >> MAX_MIP, ssize >> MAX_MIP);
|
vx, vy, vh, MAX_MIP, 0, 0, ssize >> MAX_MIP, ssize >> MAX_MIP);
|
||||||
mipstats(stats[0], stats[1], stats[2]);
|
mipstats(stats[0], stats[1], stats[2]);
|
||||||
};
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue