Migrate vec to OFVector3D

FossilOrigin-Name: 2e931ae3e1bb8a3ac23d368cfacc7394d07f295bd0bc56a40e0c70190d019d8b
This commit is contained in:
Jonathan Schleifer 2025-03-04 00:14:25 +00:00
parent 4ce99636d3
commit 6f64252d65
15 changed files with 141 additions and 136 deletions

View file

@ -201,7 +201,7 @@ localservertoclient(
case SV_SHOT: {
int gun = getint(p);
vec s, e;
OFVector3D s, e;
s.x = getint(p) / DMF;
s.y = getint(p) / DMF;
s.z = getint(p) / DMF;
@ -274,8 +274,8 @@ localservertoclient(
setspawn(i, true);
if (i >= (uint)ents.length())
break;
vec v = {(float)ents[i].x, (float)ents[i].y,
(float)ents[i].z};
OFVector3D v =
OFMakeVector3D(ents[i].x, ents[i].y, ents[i].z);
playsound(S_ITEMSPAWN, &v);
break;
}

View file

@ -54,8 +54,8 @@ alias(OFString *name, OFString *action)
if (b.type == ID_ALIAS)
b.action = action;
else
conoutf(
@"cannot redefine builtin %s with an alias", name.UTF8String);
conoutf(@"cannot redefine builtin %s with an alias",
name.UTF8String);
}
}
COMMAND(alias, ARG_2STR)

View file

@ -102,9 +102,6 @@ struct header // map file format header
((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \
(y) >= ssize - MINBORD)
struct vec {
float x, y, z;
};
struct block {
int x, y, xs, ys;
};
@ -128,8 +125,8 @@ enum {
struct dynent // players & monsters
{
vec o, vel; // origin, velocity
float yaw, pitch, roll; // used as vec in one place
OFVector3D o, vel; // origin, velocity
float yaw, pitch, roll; // used as OFVector3D in one place
float maxspeed; // cubes per second, 24 for player
bool outsidemap; // from his eyes
bool inwater;
@ -154,7 +151,7 @@ struct dynent // players & monsters
bool blocked, moving; // used by physics to signal ai
int trigger; // millis at which transition to another monsterstate takes
// place
vec attacktarget; // delayed attacks
OFVector3D attacktarget; // delayed attacks
int anger; // how many times already hit by fellow monster
string name, team;
};
@ -295,7 +292,7 @@ extern dynent
extern dvector players; // all the other clients (in multiplayer)
extern bool editmode;
extern vector<entity> ents; // map entities
extern vec worldpos; // current target of the crosshair in the world
extern OFVector3D worldpos; // current target of the crosshair in the world
extern int lastmillis; // last time
extern int curtime; // current frame time
extern int gamemode, nextmode;
@ -341,7 +338,7 @@ extern bool demoplayback;
(u).z -= (v).z; \
};
#define vdist(d, v, e, s) \
vec v = s; \
OFVector3D v = s; \
vsub(v, e); \
float d = (float)sqrt(dotprod(v, v));
#define vreject(v, u, max) \

View file

@ -298,15 +298,15 @@ pickup(int n, dynent *d)
if (lastmillis - lastjumppad < 300)
break;
lastjumppad = lastmillis;
vec v = {(int)(char)ents[n].attr3 / 10.0f,
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f};
OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f,
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f);
player1->vel.z = 0;
vadd(player1->vel, v);
playsoundc(S_JUMPPAD);
break;
};
};
};
}
}
}
void
checkitems()
@ -322,13 +322,13 @@ checkitems()
continue;
if (OUTBORD(e.x, e.y))
continue;
vec v = {(float)e.x, (float)e.y,
(float)S(e.x, e.y)->floor + player1->eyeheight};
OFVector3D v = OFMakeVector3D(
e.x, e.y, (float)S(e.x, e.y)->floor + player1->eyeheight);
vdist(dist, t, player1->o, v);
if (dist < (e.type == TELEPORT ? 4 : 2.5))
pickup(i, player1);
};
};
}
}
void
checkquad(int time)

View file

@ -126,7 +126,7 @@ monsterclear() // called after map start of when toggling edit mode to
bool
los(float lx, float ly, float lz, float bx, float by, float bz,
vec &v) // height-correct line of sight for monster shooting/seeing
OFVector3D &v) // height-correct line of sight for monster shooting/seeing
{
if (OUTBORD((int)lx, (int)ly) || OUTBORD((int)bx, (int)by))
return false;
@ -162,7 +162,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz,
};
bool
enemylos(dynent *m, vec &v)
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,
@ -253,7 +253,7 @@ monsteraction(
case M_SLEEP: // state classic sp monster start in, wait for visual
// contact
{
vec target;
OFVector3D target;
if (editmode || !enemylos(m, target))
return; // skip running physics
normalise(m, enemyyaw);
@ -283,7 +283,7 @@ monsteraction(
// and may want to shoot at any time
m->targetyaw = enemyyaw;
if (m->trigger < lastmillis) {
vec target;
OFVector3D target;
if (!enemylos(
m, target)) // no visual contact anymore, let
// monster get as close as possible
@ -380,7 +380,8 @@ monsterthink()
continue;
if (OUTBORD(e.x, e.y))
continue;
vec v = {(float)e.x, (float)e.y, (float)S(e.x, e.y)->floor};
OFVector3D v =
OFMakeVector3D(e.x, e.y, (float)S(e.x, e.y)->floor);
loopv(monsters) if (monsters[i]->state == CS_DEAD)
{
if (lastmillis - monsters[i]->lastaction < 2000) {

View file

@ -240,7 +240,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
const bool water = hdr.waterlevel > pl->o.z - 0.5f;
const bool floating = (editmode && local) || pl->state == CS_EDITING;
vec d; // vector of direction we ideally want to move in
OFVector3D d; // vector of direction we ideally want to move in
d.x = (float)(pl->move * cos(rad(pl->yaw - 90)));
d.y = (float)(pl->move * sin(rad(pl->yaw - 90)));

View file

@ -126,7 +126,7 @@ extern entity *newentity(
// worldlight
extern void calclight();
extern void dodynlight(
vec &vold, vec &v, int reach, int strength, dynent *owner);
OFVector3D &vold, OFVector3D &v, int reach, int strength, dynent *owner);
extern void cleardlights();
extern block *blockcopy(block &b);
extern void blockpaste(block &b);
@ -167,7 +167,7 @@ extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void box(block &b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b);
extern void newsphere(vec &o, float max, int type);
extern void newsphere(OFVector3D &o, float max, int type);
extern void renderspheres(int time);
extern void gl_drawhud(
int w, int h, int curfps, int nquads, int curvert, bool underwater);
@ -176,9 +176,10 @@ extern void blendbox(int x1, int y1, int x2, int y2, bool border);
extern void damageblend(int n);
// renderparticles
extern void setorient(vec &r, vec &u);
extern void particle_splash(int type, int num, int fade, vec &p);
extern void particle_trail(int type, int fade, vec &from, vec &to);
extern void setorient(OFVector3D &r, OFVector3D &u);
extern void particle_splash(int type, int num, int fade, OFVector3D &p);
extern void particle_trail(
int type, int fade, OFVector3D &from, OFVector3D &to);
extern void render_particles(int time);
// worldio
@ -191,7 +192,7 @@ extern void incomingdemodata(uchar *buf, int len, bool extras = false);
extern void demoplaybackstep();
extern void stop();
extern void stopifrecording();
extern void demodamage(int damage, vec &o);
extern void demodamage(int damage, OFVector3D &o);
extern void demoblend(int damage);
// physics
@ -202,7 +203,7 @@ extern void setentphysics(int mml, int mmr);
extern void physicsframe();
// sound
extern void playsound(int n, vec *loc = 0);
extern void playsound(int n, OFVector3D *loc = 0);
extern void playsoundc(int n);
extern void initsound();
extern void cleansound();
@ -236,10 +237,10 @@ extern ENetPacket *recvmap(int n);
// weapon
extern void selectgun(int a = -1, int b = -1, int c = -1);
extern void shoot(dynent *d, vec &to);
extern void shootv(
int gun, vec &from, vec &to, dynent *d = 0, bool local = false);
extern void createrays(vec &from, vec &to);
extern void shoot(dynent *d, OFVector3D &to);
extern void shootv(int gun, OFVector3D &from, OFVector3D &to, dynent *d = 0,
bool local = false);
extern void createrays(OFVector3D &from, OFVector3D &to);
extern void moveprojectiles(float time);
extern void projreset();
extern char *playerincrosshair();

View file

@ -80,7 +80,7 @@ blendbox(int x1, int y1, int x2, int y2, bool border)
const int MAXSPHERES = 50;
struct sphere {
vec o;
OFVector3D o;
float size, max;
int type;
sphere *next;
@ -89,7 +89,7 @@ sphere spheres[MAXSPHERES], *slist = NULL, *sempty = NULL;
bool sinit = false;
void
newsphere(vec &o, float max, int type)
newsphere(OFVector3D &o, float max, int type)
{
if (!sinit) {
loopi(MAXSPHERES)
@ -184,9 +184,9 @@ renderents() // show sparkly thingies for map entities in edit mode
entity &e = ents[i];
if (e.type == NOTUSED)
continue;
vec v = {(float)e.x, (float)e.y, (float)e.z};
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
particle_splash(2, 2, 40, v);
};
}
int e = closestent();
if (e >= 0) {
entity &c = ents[e];
@ -226,7 +226,7 @@ COMMAND(loadsky, ARG_1STR)
float cursordepth = 0.9f;
GLint viewport[4];
GLdouble mm[16], pm[16];
vec worldpos;
OFVector3D worldpos;
void
readmatrices()
@ -262,8 +262,8 @@ readdepth(int w, int h)
worldpos.x = (float)worldx;
worldpos.y = (float)worldy;
worldpos.z = (float)worldz;
vec r = {(float)mm[0], (float)mm[4], (float)mm[8]};
vec u = {(float)mm[1], (float)mm[5], (float)mm[9]};
OFVector3D r = OFMakeVector3D(mm[0], mm[4], mm[8]);
OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]);
setorient(r, u);
};

View file

@ -32,7 +32,7 @@ struct md2 {
int numFrames;
int numVerts;
char *frames;
vec **mverts;
OFVector3D **mverts;
int displaylist;
int displaylistverts;
@ -42,9 +42,9 @@ struct md2 {
bool loaded;
bool load(char *filename);
void render(vec &light, int numFrame, int range, float x, float y,
float z, float yaw, float pitch, float scale, float speed, int snap,
int basetime);
void render(OFVector3D &light, int numFrame, int range, float x,
float y, float z, float yaw, float pitch, float scale, float speed,
int snap, int basetime);
void scale(int frame, float scale, int sn);
md2()
@ -103,7 +103,7 @@ md2::load(char *filename)
fclose(file);
mverts = new vec *[numFrames];
mverts = new OFVector3D *[numFrames];
loopj(numFrames) mverts[j] = NULL;
return true;
@ -118,13 +118,13 @@ snap(int sn, float f)
void
md2::scale(int frame, float scale, int sn)
{
mverts[frame] = new vec[numVerts];
mverts[frame] = new OFVector3D[numVerts];
md2_frame *cf = (md2_frame *)((char *)frames + frameSize * frame);
float sc = 16.0f / scale;
loop(vi, numVerts)
{
uchar *cv = (uchar *)&cf->vertices[vi].vertex;
vec *v = &(mverts[frame])[vi];
OFVector3D *v = &(mverts[frame])[vi];
v->x = (snap(sn, cv[0] * cf->scale[0]) + cf->translate[0]) / sc;
v->y =
-(snap(sn, cv[1] * cf->scale[1]) + cf->translate[1]) / sc;
@ -133,7 +133,7 @@ md2::scale(int frame, float scale, int sn)
};
void
md2::render(vec &light, int frame, int range, float x, float y, float z,
md2::render(OFVector3D &light, int frame, int range, float x, float y, float z,
float yaw, float pitch, float sc, float speed, int snap, int basetime)
{
loopi(range) if (!mverts[frame + i]) scale(frame + i, sc, snap);
@ -163,8 +163,8 @@ md2::render(vec &light, int frame, int range, float x, float y, float z,
int fr2 = fr1 + 1;
if (fr2 >= frame + range)
fr2 = frame;
vec *verts1 = mverts[fr1];
vec *verts2 = mverts[fr2];
OFVector3D *verts1 = mverts[fr1];
OFVector3D *verts2 = mverts[fr2];
for (int *command = glCommands; (*command) != 0;) {
int numVertex = *command++;
@ -181,8 +181,8 @@ md2::render(vec &light, int frame, int range, float x, float y, float z,
float tv = *((float *)command++);
glTexCoord2f(tu, tv);
int vn = *command++;
vec &v1 = verts1[vn];
vec &v2 = verts2[vn];
OFVector3D &v1 = verts1[vn];
OFVector3D &v2 = verts2[vn];
#define ip(c) v1.c *frac2 + v2.c *frac1
glVertex3f(ip(x), ip(z), ip(y));
};
@ -283,7 +283,7 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad, float x,
int ix = (int)x;
int iy = (int)z;
vec light = {1.0f, 1.0f, 1.0f};
OFVector3D light = OFMakeVector3D(1, 1, 1);
if (!OUTBORD(ix, iy)) {
sqr *s = S(ix, iy);

View file

@ -5,7 +5,7 @@
const int MAXPARTICLES = 10500;
const int NUMPARTCUTOFF = 20;
struct particle {
vec o, d;
OFVector3D o, d;
int fade, type;
int millis;
particle *next;
@ -16,7 +16,7 @@ bool parinit = false;
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
void
newparticle(vec &o, vec &d, int fade, int type)
newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
{
if (!parinit) {
loopi(MAXPARTICLES)
@ -42,22 +42,22 @@ newparticle(vec &o, vec &d, int fade, int type)
VAR(demotracking, 0, 0, 1);
VARP(particlesize, 20, 100, 500);
vec right, up;
OFVector3D right, up;
void
setorient(vec &r, vec &u)
setorient(OFVector3D &r, OFVector3D &u)
{
right = r;
up = u;
};
}
void
render_particles(int time)
{
if (demoplayback && demotracking) {
vec nom = {0, 0, 0};
OFVector3D nom = OFMakeVector3D(0, 0, 0);
newparticle(player1->o, nom, 100000000, 8);
};
}
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
@ -118,13 +118,13 @@ render_particles(int time)
if (pt->gr)
p->o.z -= ((lastmillis - p->millis) / 3.0f) *
curtime / (pt->gr * 10000);
vec a = p->d;
OFVector3D a = p->d;
vmul(a, time);
vdiv(a, 20000.0f);
vadd(p->o, a);
pp = &p->next;
};
};
}
}
glEnable(GL_FOG);
glDisable(GL_BLEND);
@ -132,7 +132,7 @@ render_particles(int time)
};
void
particle_splash(int type, int num, int fade, vec &p)
particle_splash(int type, int num, int fade, OFVector3D &p)
{
loopi(num)
{
@ -143,22 +143,22 @@ particle_splash(int type, int num, int fade, vec &p)
y = rnd(radius * 2) - radius;
z = rnd(radius * 2) - radius;
} while (x * x + y * y + z * z > radius * radius);
vec d = {(float)x, (float)y, (float)z};
OFVector3D d = OFMakeVector3D(x, y, z);
newparticle(p, d, rnd(fade * 3), type);
};
};
}
}
void
particle_trail(int type, int fade, vec &s, vec &e)
particle_trail(int type, int fade, OFVector3D &s, OFVector3D &e)
{
vdist(d, v, s, e);
vdiv(v, d * 2 + 0.1f);
vec p = s;
OFVector3D p = s;
loopi((int)d * 2)
{
vadd(p, v);
vec d = {
float(rnd(11) - 5), float(rnd(11) - 5), float(rnd(11) - 5)};
OFVector3D d =
OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
newparticle(p, d, rnd(fade) + fade, type);
};
};
}
}

View file

@ -31,9 +31,9 @@ gzputi(int i)
}
void
gzputv(vec &v)
gzputv(OFVector3D &v)
{
gzwrite(f, &v, sizeof(vec));
gzwrite(f, &v, sizeof(OFVector3D));
}
void
@ -59,9 +59,9 @@ gzgeti()
}
void
gzgetv(vec &v)
gzgetv(OFVector3D &v)
{
gzcheck(gzread(f, &v, sizeof(vec)), sizeof(vec));
gzcheck(gzread(f, &v, sizeof(OFVector3D)), sizeof(OFVector3D));
}
void
@ -244,7 +244,7 @@ loadgamerest()
int starttime = 0;
int playbacktime = 0;
int ddamage, bdamage;
vec dorig;
OFVector3D dorig;
void
record(OFString *name)
@ -269,7 +269,7 @@ record(OFString *name)
COMMAND(record, ARG_1STR)
void
demodamage(int damage, vec &o)
demodamage(int damage, OFVector3D &o)
{
ddamage = damage;
dorig = o;
@ -363,11 +363,12 @@ startdemo()
VAR(demodelaymsec, 0, 120, 500);
// spline interpolation
void
catmulrom(
vec &z, vec &a, vec &b, vec &c, float s, vec &dest) // spline interpolation
catmulrom(OFVector3D &z, OFVector3D &a, OFVector3D &b, OFVector3D &c, float s,
OFVector3D &dest)
{
vec t1 = b, t2 = c;
OFVector3D t1 = b, t2 = c;
vsub(t1, z);
vmul(t1, 0.5f) vsub(t2, a);
@ -377,7 +378,7 @@ catmulrom(
float s3 = s * s2;
dest = a;
vec t = b;
OFVector3D t = b;
vmul(dest, 2 * s3 - 3 * s2 + 1);
vmul(t, -2 * s3 + 3 * s2);
@ -407,7 +408,7 @@ demoplaybackstep()
@"error: huge packet during demo play (%d)", len);
stopreset();
return;
};
}
uchar buf[MAXTRANS];
gzread(f, buf, len);
localservertoclient(buf, len); // update game state
@ -434,9 +435,9 @@ demoplaybackstep()
if (ddamage = gzgeti()) {
gzgetv(dorig);
particle_splash(3, ddamage, 1000, dorig);
};
}
// FIXME: set more client state here
};
}
// insert latest copy of player into history
if (extras &&
@ -449,11 +450,11 @@ demoplaybackstep()
if (playerhistory.length() > 20) {
zapdynent(playerhistory[0]);
playerhistory.remove(0);
};
};
}
}
readdemotime();
};
}
if (demoplayback) {
int itime = lastmillis - demodelaymsec;
@ -489,18 +490,19 @@ demoplaybackstep()
{
catmulrom(z->o, a->o, b->o, c->o, bf,
player1->o);
catmulrom(*(vec *)&z->yaw,
*(vec *)&a->yaw, *(vec *)&b->yaw,
*(vec *)&c->yaw, bf,
*(vec *)&player1->yaw);
};
catmulrom(*(OFVector3D *)&z->yaw,
*(OFVector3D *)&a->yaw,
*(OFVector3D *)&b->yaw,
*(OFVector3D *)&c->yaw, bf,
*(OFVector3D *)&player1->yaw);
}
fixplayer1range();
};
}
break;
};
}
// if(player1->state!=CS_DEAD) showscores(false);
};
};
}
}
void
stopn()

View file

@ -16,7 +16,7 @@ bool nosound = false;
#define SOUNDFREQ 22050
struct soundloc {
vec loc;
OFVector3D loc;
bool inuse;
} soundlocs[MAXCHAN];
@ -150,7 +150,7 @@ cleansound()
VAR(stereo, 0, 1, 1);
void
updatechanvol(int chan, vec *loc)
updatechanvol(int chan, OFVector3D *loc)
{
int vol = soundvol, pan = 255 / 2;
if (loc) {
@ -178,7 +178,7 @@ updatechanvol(int chan, vec *loc)
};
void
newsoundloc(int chan, vec *loc)
newsoundloc(int chan, OFVector3D *loc)
{
assert(chan >= 0 && chan < MAXCHAN);
soundlocs[chan].loc = *loc;
@ -213,7 +213,7 @@ playsoundc(int n)
int soundsatonce = 0, lastsoundmillis = 0;
void
playsound(int n, vec *loc)
playsound(int n, OFVector3D *loc)
{
if (nosound)
return;

View file

@ -10,7 +10,7 @@ struct guninfo {
const int MONSTERDAMAGEFACTOR = 4;
const int SGRAYS = 20;
const float SGSPREAD = 2;
vec sg[SGRAYS];
OFVector3D sg[SGRAYS];
guninfo guns[NUMGUNS] = {
{S_PUNCH1, 250, 50, 0, 0, 1, "fist"},
@ -71,23 +71,25 @@ weapon(OFString *a1, OFString *a2, OFString *a3)
COMMAND(weapon, ARG_3STR)
void
createrays(vec &from, vec &to) // create random spread of rays for the shotgun
createrays(OFVector3D &from,
OFVector3D &to) // create random spread of rays for the shotgun
{
vdist(dist, dvec, from, to);
float f = dist * SGSPREAD / 1000;
loopi(SGRAYS)
{
#define RNDD (rnd(101) - 50) * f
vec r = {RNDD, RNDD, RNDD};
OFVector3D r = OFMakeVector3D(RNDD, RNDD, RNDD);
sg[i] = to;
vadd(sg[i], r);
};
};
bool
intersect(dynent *d, vec &from, vec &to) // if lineseg hits entity bounding box
intersect(dynent *d, OFVector3D &from,
OFVector3D &to) // if lineseg hits entity bounding box
{
vec v = to, w = d->o, *p;
OFVector3D v = to, w = d->o, *p;
vsub(v, from);
vsub(w, from);
float c1 = dotprod(w, v);
@ -129,7 +131,7 @@ playerincrosshair()
const int MAXPROJ = 100;
struct projectile {
vec o, to;
OFVector3D o, to;
float speed;
dynent *owner;
int gun;
@ -144,8 +146,8 @@ projreset()
};
void
newprojectile(
vec &from, vec &to, float speed, bool local, dynent *owner, int gun)
newprojectile(OFVector3D &from, OFVector3D &to, float speed, bool local,
dynent *owner, int gun)
{
loopi(MAXPROJ)
{
@ -182,7 +184,7 @@ const float RL_RADIUS = 5;
const float RL_DAMRAD = 7; // hack
void
radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
radialeffect(dynent *o, OFVector3D &v, int cn, int qdam, dynent *at)
{
if (o->state != CS_ALIVE)
return;
@ -199,8 +201,8 @@ radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
};
void
splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster,
int qdam)
splash(projectile *p, OFVector3D &v, OFVector3D &vold, int notthisplayer,
int notthismonster, int qdam)
{
particle_splash(0, 50, 300, v);
p->inuse = false;
@ -230,7 +232,7 @@ splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster,
};
inline void
projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam)
projdamage(dynent *o, projectile *p, OFVector3D &v, int i, int im, int qdam)
{
if (o->state != CS_ALIVE)
return;
@ -264,14 +266,14 @@ moveprojectiles(float time)
if (!o)
continue;
projdamage(o, p, v, i, -1, qdam);
};
}
if (p->owner != player1)
projdamage(player1, p, v, -1, -1, qdam);
dvector &mv = getmonsters();
loopv(mv) if (!vreject(mv[i]->o, v, 10.0f) &&
mv[i] != p->owner)
projdamage(mv[i], p, v, -1, i, qdam);
};
}
if (p->inuse) {
if (time == dtime)
splash(p, v, p->o, -1, -1, qdam);
@ -283,15 +285,15 @@ moveprojectiles(float time)
particle_splash(1, 1, 200, v);
particle_splash(
guns[p->gun].part, 1, 1, v);
};
};
};
}
}
}
p->o = v;
};
};
void
shootv(int gun, vec &from, vec &to, dynent *d,
shootv(int gun, OFVector3D &from, OFVector3D &to, dynent *d,
bool local) // create visual effect from a shot
{
playsound(guns[gun].sound, d == player1 ? NULL : &d->o);
@ -328,16 +330,17 @@ shootv(int gun, vec &from, vec &to, dynent *d,
};
void
hitpush(int target, int damage, dynent *d, dynent *at, vec &from, vec &to)
hitpush(int target, int damage, dynent *d, dynent *at, OFVector3D &from,
OFVector3D &to)
{
hit(target, damage, d, at);
vdist(dist, v, from, to);
vmul(v, damage / dist / 50);
vadd(d->vel, v);
};
}
void
raydamage(dynent *o, vec &from, vec &to, dynent *d, int i)
raydamage(dynent *o, OFVector3D &from, OFVector3D &to, dynent *d, int i)
{
if (o->state != CS_ALIVE)
return;
@ -356,7 +359,7 @@ raydamage(dynent *o, vec &from, vec &to, dynent *d, int i)
};
void
shoot(dynent *d, vec &targ)
shoot(dynent *d, OFVector3D &targ)
{
int attacktime = lastmillis - d->lastaction;
if (attacktime < d->gunwait)
@ -374,13 +377,13 @@ shoot(dynent *d, vec &targ)
};
if (d->gunselect)
d->ammo[d->gunselect]--;
vec from = d->o;
vec to = targ;
OFVector3D from = d->o;
OFVector3D to = targ;
from.z -= 0.2f; // below eye
vdist(dist, unitv, from, to);
vdiv(unitv, dist);
vec kickback = unitv;
OFVector3D kickback = unitv;
vmul(kickback, guns[d->gunselect].kickamount * -0.01f);
vadd(d->vel, kickback);
if (d->pitch < 80.0f)

View file

@ -267,7 +267,7 @@ closestent() // used for delent and edit mode ent display
entity &e = ents[i];
if (e.type == NOTUSED)
continue;
vec v = {(float)e.x, (float)e.y, (float)e.z};
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
vdist(dist, t, player1->o, v);
if (dist < bdist) {
best = i;

View file

@ -200,7 +200,8 @@ cleardlights()
}
void
dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner)
dodynlight(
OFVector3D &vold, OFVector3D &v, int reach, int strength, dynent *owner)
{
if (!reach)
reach = dynlight;