Avoid pointless pointers

Passing OFVector3D by reference is annoying and is worse at passing via
registers.

FossilOrigin-Name: 304230c1e18fc15a2e66b01bbc1727d107b9d27be6949aad99419bc153bf6e66
This commit is contained in:
Jonathan Schleifer 2025-03-23 21:52:54 +00:00
parent d8f4f44468
commit 2f8d255946
9 changed files with 97 additions and 109 deletions

View file

@ -333,8 +333,7 @@ enemylos(Monster *m, OFVector3D *v)
if (self.trigger < lastmillis) { if (self.trigger < lastmillis) {
self.lastAction = 0; self.lastAction = 0;
self.attacking = true; self.attacking = true;
OFVector3D attackTarget = self.attackTarget; shoot(self, self.attackTarget);
shoot(self, &attackTarget);
[self transitionWithState:M_ATTACKING [self transitionWithState:M_ATTACKING
moving:0 moving:0
n:600 n:600

View file

@ -163,7 +163,7 @@ updateworld(int millis) // main game update loop
if (!demoplayback) { if (!demoplayback) {
if (getclientnum() >= 0) if (getclientnum() >= 0)
// only shoot when connected to server // only shoot when connected to server
shoot(player1, &worldpos); shoot(player1, worldpos);
// do this first, so we have most accurate information // do this first, so we have most accurate information
// when our player moves // when our player moves
gets2c(); gets2c();

View file

@ -221,8 +221,8 @@ localservertoclient(unsigned char *buf, int len)
e.y = getint(&p) / DMF; e.y = getint(&p) / DMF;
e.z = getint(&p) / DMF; e.z = getint(&p) / DMF;
if (gun == GUN_SG) if (gun == GUN_SG)
createrays(&s, &e); createrays(s, e);
shootv(gun, &s, &e, d, false); shootv(gun, s, e, d, false);
break; break;
} }

View file

@ -128,8 +128,8 @@ extern Entity *newentity(
// worldlight // worldlight
extern void calclight(); extern void calclight();
extern void dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, extern void dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength,
int strength, DynamicEntity *owner); DynamicEntity *owner);
extern void cleardlights(); extern void cleardlights();
extern struct block *blockcopy(const struct block *b); extern struct block *blockcopy(const struct block *b);
extern void blockpaste(const struct block *b); extern void blockpaste(const struct block *b);
@ -169,7 +169,7 @@ extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void box(const struct block *b, float z1, float z2, float z3, float z4); extern void box(const struct block *b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z); extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b); extern void linestyle(float width, int r, int g, int b);
extern void newsphere(const OFVector3D *o, float max, int type); extern void newsphere(OFVector3D o, float max, int type);
extern void renderspheres(int time); extern void renderspheres(int time);
extern void gl_drawhud( extern void gl_drawhud(
int w, int h, int curfps, int nquads, int curvert, bool underwater); int w, int h, int curfps, int nquads, int curvert, bool underwater);
@ -178,10 +178,9 @@ extern void blendbox(int x1, int y1, int x2, int y2, bool border);
extern void damageblend(int n); extern void damageblend(int n);
// renderparticles // renderparticles
extern void setorient(const OFVector3D *r, const OFVector3D *u); extern void setorient(OFVector3D r, OFVector3D u);
extern void particle_splash(int type, int num, int fade, const OFVector3D *p); extern void particle_splash(int type, int num, int fade, OFVector3D p);
extern void particle_trail( extern void particle_trail(int type, int fade, OFVector3D from, OFVector3D to);
int type, int fade, const OFVector3D *from, const OFVector3D *to);
extern void render_particles(int time); extern void render_particles(int time);
// worldio // worldio
@ -194,7 +193,7 @@ extern void incomingdemodata(unsigned char *buf, int len, bool extras);
extern void demoplaybackstep(); extern void demoplaybackstep();
extern void stop(); extern void stop();
extern void stopifrecording(); extern void stopifrecording();
extern void demodamage(int damage, const OFVector3D *o); extern void demodamage(int damage, OFVector3D o);
extern void demoblend(int damage); extern void demoblend(int damage);
// physics // physics
@ -241,10 +240,10 @@ extern ENetPacket *recvmap(int n);
// weapon // weapon
extern void selectgun(int a, int b, int c); extern void selectgun(int a, int b, int c);
extern void shoot(DynamicEntity *d, const OFVector3D *to); extern void shoot(DynamicEntity *d, OFVector3D to);
extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to, extern void shootv(
DynamicEntity *d, bool local); int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local);
extern void createrays(const OFVector3D *from, const OFVector3D *to); extern void createrays(OFVector3D from, OFVector3D to);
extern void moveprojectiles(float time); extern void moveprojectiles(float time);
extern void projreset(); extern void projreset();
extern OFString *playerincrosshair(); extern OFString *playerincrosshair();

View file

@ -93,7 +93,7 @@ static struct sphere spheres[MAXSPHERES], *slist = NULL, *sempty = NULL;
bool sinit = false; bool sinit = false;
void void
newsphere(const OFVector3D *o, float max, int type) newsphere(OFVector3D o, float max, int type)
{ {
if (!sinit) { if (!sinit) {
for (int i = 0; i < MAXSPHERES; i++) { for (int i = 0; i < MAXSPHERES; i++) {
@ -105,7 +105,7 @@ newsphere(const OFVector3D *o, float max, int type)
if (sempty) { if (sempty) {
struct sphere *p = sempty; struct sphere *p = sempty;
sempty = p->next; sempty = p->next;
p->o = *o; p->o = o;
p->max = max; p->max = max;
p->size = 1; p->size = 1;
p->type = type; p->type = type;
@ -189,8 +189,7 @@ renderents()
if (e.type == NOTUSED) if (e.type == NOTUSED)
continue; continue;
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z); particle_splash(2, 2, 40, OFMakeVector3D(e.x, e.y, e.z));
particle_splash(2, 2, 40, &v);
} }
int e = closestent(); int e = closestent();
@ -272,7 +271,7 @@ readdepth(int w, int h)
worldpos.z = (float)worldz; worldpos.z = (float)worldz;
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

View file

@ -18,7 +18,7 @@ bool parinit = false;
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500); VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
static void static void
newparticle(const OFVector3D *o, const OFVector3D *d, int fade, int type) newparticle(OFVector3D o, OFVector3D d, int fade, int type)
{ {
if (!parinit) { if (!parinit) {
for (int i = 0; i < MAXPARTICLES; i++) { for (int i = 0; i < MAXPARTICLES; i++) {
@ -30,8 +30,8 @@ newparticle(const OFVector3D *o, const OFVector3D *d, int fade, int type)
if (parempty) { if (parempty) {
struct particle *p = parempty; struct particle *p = parempty;
parempty = p->next; parempty = p->next;
p->o = *o; p->o = o;
p->d = *d; p->d = d;
p->fade = fade; p->fade = fade;
p->type = type; p->type = type;
p->millis = lastmillis; p->millis = lastmillis;
@ -46,20 +46,18 @@ VARP(particlesize, 20, 100, 500);
OFVector3D right, up; OFVector3D right, up;
void void
setorient(const OFVector3D *r, const OFVector3D *u) setorient(OFVector3D r, OFVector3D u)
{ {
right = *r; right = r;
up = *u; up = u;
} }
void void
render_particles(int time) render_particles(int time)
{ {
if (demoplayback && demotracking) { if (demoplayback && demotracking)
OFVector3D o = player1.origin; newparticle(
OFVector3D nom = OFMakeVector3D(0, 0, 0); player1.origin, OFMakeVector3D(0, 0, 0), 100000000, 8);
newparticle(&o, &nom, 100000000, 8);
}
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glEnable(GL_BLEND); glEnable(GL_BLEND);
@ -134,7 +132,7 @@ render_particles(int time)
} }
void void
particle_splash(int type, int num, int fade, const OFVector3D *p) particle_splash(int type, int num, int fade, OFVector3D p)
{ {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
const int radius = type == 5 ? 50 : 150; const int radius = type == 5 ? 50 : 150;
@ -145,21 +143,20 @@ particle_splash(int type, int num, int fade, const OFVector3D *p)
z = rnd(radius * 2) - radius; z = rnd(radius * 2) - radius;
} while (x * x + y * y + z * z > radius * radius); } while (x * x + y * y + z * z > radius * radius);
OFVector3D d = OFMakeVector3D(x, y, z); OFVector3D d = OFMakeVector3D(x, y, z);
newparticle(p, &d, rnd(fade * 3), type); newparticle(p, d, rnd(fade * 3), type);
} }
} }
void void
particle_trail(int type, int fade, const OFVector3D *s, const OFVector3D *e) particle_trail(int type, int fade, OFVector3D s, OFVector3D e)
{ {
float d = OFDistanceOfVectors3D(*s, *e); float d = OFDistanceOfVectors3D(s, e);
OFVector3D v = OFSubtractVectors3D(*s, *e); OFVector3D v = OFSubtractVectors3D(s, e);
v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f)); v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f));
OFVector3D p = *s;
for (int i = 0; i < ((int)d * 2); i++) { for (int i = 0; i < ((int)d * 2); i++) {
p = OFAddVectors3D(p, v); s = OFAddVectors3D(s, v);
OFVector3D d = OFVector3D d =
OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5); OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
newparticle(&p, &d, rnd(fade) + fade, type); newparticle(s, d, rnd(fade) + fade, type);
} }
} }

View file

@ -285,10 +285,10 @@ COMMAND(record, ARG_1STR, (^(OFString *name) {
})) }))
void void
demodamage(int damage, const OFVector3D *o) demodamage(int damage, OFVector3D o)
{ {
ddamage = damage; ddamage = damage;
dorig = *o; dorig = o;
} }
void void
@ -443,7 +443,7 @@ demoplaybackstep()
damageblend(bdamage); damageblend(bdamage);
if ((ddamage = gzgeti())) { if ((ddamage = gzgeti())) {
gzgetv(&dorig); gzgetv(&dorig);
particle_splash(3, ddamage, 1000, &dorig); particle_splash(3, ddamage, 1000, dorig);
} }
// FIXME: set more client state here // FIXME: set more client state here
} }

View file

@ -71,24 +71,23 @@ COMMAND(weapon, ARG_3STR, ^(OFString *a1, OFString *a2, OFString *a3) {
// create random spread of rays for the shotgun // create random spread of rays for the shotgun
void void
createrays(const OFVector3D *from, const OFVector3D *to) createrays(OFVector3D from, OFVector3D to)
{ {
float dist = OFDistanceOfVectors3D(*from, *to); float dist = OFDistanceOfVectors3D(from, to);
float f = dist * SGSPREAD / 1000; float f = dist * SGSPREAD / 1000;
for (int i = 0; i < SGRAYS; i++) for (int i = 0; i < SGRAYS; i++)
#define RNDD (rnd(101) - 50) * f #define RNDD (rnd(101) - 50) * f
sg[i] = OFAddVectors3D(*to, OFMakeVector3D(RNDD, RNDD, RNDD)); sg[i] = OFAddVectors3D(to, OFMakeVector3D(RNDD, RNDD, RNDD));
} }
// if lineseg hits entity bounding box // if lineseg hits entity bounding box
static bool static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to) intersect(DynamicEntity *d, OFVector3D from, OFVector3D to)
{ {
OFVector3D v = *to, w = d.origin; OFVector3D v = OFSubtractVectors3D(to, from);
const OFVector3D *p; OFVector3D w = OFSubtractVectors3D(d.origin, from);
v = OFSubtractVectors3D(v, *from);
w = OFSubtractVectors3D(w, *from);
float c1 = OFDotProductOfVectors3D(w, v); float c1 = OFDotProductOfVectors3D(w, v);
OFVector3D p;
if (c1 <= 0) if (c1 <= 0)
p = from; p = from;
@ -98,15 +97,13 @@ intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
p = to; p = to;
else { else {
v = OFMultiplyVector3D(v, c1 / c2); v = OFMultiplyVector3D(v, c1 / c2);
v = OFAddVectors3D(v, *from); p = OFAddVectors3D(v, from);
p = &v;
} }
} }
return (p->x <= d.origin.x + d.radius && return (p.x <= d.origin.x + d.radius && p.x >= d.origin.x - d.radius &&
p->x >= d.origin.x - d.radius && p->y <= d.origin.y + d.radius && p.y <= d.origin.y + d.radius && p.y >= d.origin.y - d.radius &&
p->y >= d.origin.y - d.radius && p->z <= d.origin.z + d.aboveEye && p.z <= d.origin.z + d.aboveEye && p.z >= d.origin.z - d.eyeHeight);
p->z >= d.origin.z - d.eyeHeight);
} }
OFString * OFString *
@ -120,7 +117,7 @@ playerincrosshair()
continue; continue;
OFVector3D o = player1.origin; OFVector3D o = player1.origin;
if (intersect(player, &o, &worldpos)) if (intersect(player, o, worldpos))
return [player name]; return [player name];
} }
@ -138,8 +135,8 @@ projreset()
} }
void void
newprojectile(const OFVector3D *from, const OFVector3D *to, float speed, newprojectile(OFVector3D from, OFVector3D to, float speed, bool local,
bool local, DynamicEntity *owner, int gun) DynamicEntity *owner, int gun)
{ {
for (size_t i = 0; i < MAXPROJ; i++) { for (size_t i = 0; i < MAXPROJ; i++) {
Projectile *p = projs[i]; Projectile *p = projs[i];
@ -151,8 +148,8 @@ newprojectile(const OFVector3D *from, const OFVector3D *to, float speed,
continue; continue;
p.inuse = true; p.inuse = true;
p.o = *from; p.o = from;
p.to = *to; p.to = to;
p.speed = speed; p.speed = speed;
p.local = local; p.local = local;
p.owner = owner; p.owner = owner;
@ -173,8 +170,8 @@ hit(int target, int damage, __kindof DynamicEntity *d, DynamicEntity *at)
addmsg(1, 4, SV_DAMAGE, target, damage, d.lifeSequence); addmsg(1, 4, SV_DAMAGE, target, damage, d.lifeSequence);
playsound(S_PAIN1 + rnd(5), &o); playsound(S_PAIN1 + rnd(5), &o);
} }
particle_splash(3, damage, 1000, &o); particle_splash(3, damage, 1000, o);
demodamage(damage, &o); demodamage(damage, o);
} }
const float RL_RADIUS = 5; const float RL_RADIUS = 5;
@ -182,14 +179,14 @@ const float RL_DAMRAD = 7; // hack
static void static void
radialeffect( radialeffect(
DynamicEntity *o, const OFVector3D *v, int cn, int qdam, DynamicEntity *at) DynamicEntity *o, OFVector3D v, int cn, int qdam, DynamicEntity *at)
{ {
if (o.state != CS_ALIVE) if (o.state != CS_ALIVE)
return; return;
OFVector3D origin = o.origin; OFVector3D origin = o.origin;
float dist = OFDistanceOfVectors3D(*v, origin); float dist = OFDistanceOfVectors3D(v, origin);
OFVector3D temp = OFSubtractVectors3D(*v, origin); OFVector3D temp = OFSubtractVectors3D(v, origin);
dist -= 2; // account for eye distance imprecision dist -= 2; // account for eye distance imprecision
if (dist < RL_DAMRAD) { if (dist < RL_DAMRAD) {
@ -206,17 +203,17 @@ radialeffect(
} }
static void static void
splash(Projectile *p, const OFVector3D *v, const OFVector3D *vold, splash(Projectile *p, OFVector3D v, OFVector3D vold, int notthisplayer,
int notthisplayer, int notthismonster, int qdam) int notthismonster, int qdam)
{ {
particle_splash(0, 50, 300, v); particle_splash(0, 50, 300, v);
p.inuse = false; p.inuse = false;
if (p.gun != GUN_RL) { if (p.gun != GUN_RL) {
playsound(S_FEXPLODE, v); playsound(S_FEXPLODE, &v);
// no push? // no push?
} else { } else {
playsound(S_RLHIT, v); playsound(S_RLHIT, &v);
newsphere(v, RL_RADIUS, 0); newsphere(v, RL_RADIUS, 0);
dodynlight(vold, v, 0, 0, p.owner); dodynlight(vold, v, 0, 0, p.owner);
@ -245,15 +242,15 @@ splash(Projectile *p, const OFVector3D *v, const OFVector3D *vold,
} }
static inline void static inline void
projdamage(DynamicEntity *o, Projectile *p, const OFVector3D *v, int i, int im, projdamage(
int qdam) DynamicEntity *o, Projectile *p, OFVector3D v, int i, int im, int qdam)
{ {
if (o.state != CS_ALIVE) if (o.state != CS_ALIVE)
return; return;
OFVector3D po = p.o; OFVector3D po = p.o;
if (intersect(o, &po, v)) { if (intersect(o, po, v)) {
splash(p, v, &po, i, im, qdam); splash(p, v, po, i, im, qdam);
hit(i, qdam, o, p.owner); hit(i, qdam, o, p.owner);
} }
} }
@ -281,29 +278,27 @@ moveprojectiles(float time)
if (p.local) { if (p.local) {
for (id player in players) for (id player in players)
if (player != [OFNull null]) if (player != [OFNull null])
projdamage(player, p, &v, i, -1, qdam); projdamage(player, p, v, i, -1, qdam);
if (p.owner != player1) if (p.owner != player1)
projdamage(player1, p, &v, -1, -1, qdam); projdamage(player1, p, v, -1, -1, qdam);
for (Monster *monster in Monster.monsters) for (Monster *monster in Monster.monsters)
if (!vreject(monster.origin, v, 10.0f) && if (!vreject(monster.origin, v, 10.0f) &&
monster != p.owner) monster != p.owner)
projdamage(monster, p, &v, -1, i, qdam); projdamage(monster, p, v, -1, i, qdam);
} }
if (p.inuse) { if (p.inuse) {
OFVector3D po = p.o;
if (time == dtime) if (time == dtime)
splash(p, &v, &po, -1, -1, qdam); splash(p, v, p.o, -1, -1, qdam);
else { else {
if (p.gun == GUN_RL) { if (p.gun == GUN_RL) {
dodynlight(&po, &v, 0, 255, p.owner); dodynlight(p.o, v, 0, 255, p.owner);
particle_splash(5, 2, 200, &v); particle_splash(5, 2, 200, v);
} else { } else {
particle_splash(1, 1, 200, &v); particle_splash(1, 1, 200, v);
particle_splash( particle_splash(
guns[p.gun].part, 1, 1, &v); guns[p.gun].part, 1, 1, v);
} }
} }
} }
@ -313,8 +308,7 @@ moveprojectiles(float time)
// create visual effect from a shot // create visual effect from a shot
void void
shootv(int gun, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d, shootv(int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local)
bool local)
{ {
OFVector3D loc = d.origin; OFVector3D loc = d.origin;
playsound(guns[gun].sound, d == player1 ? NULL : &loc); playsound(guns[gun].sound, d == player1 ? NULL : &loc);
@ -325,7 +319,7 @@ shootv(int gun, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d,
case GUN_SG: { case GUN_SG: {
for (int i = 0; i < SGRAYS; i++) for (int i = 0; i < SGRAYS; i++)
particle_splash(0, 5, 200, &sg[i]); particle_splash(0, 5, 200, sg[i]);
break; break;
} }
@ -353,18 +347,18 @@ shootv(int gun, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d,
void void
hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at, hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
const OFVector3D *from, const OFVector3D *to) OFVector3D from, OFVector3D to)
{ {
hit(target, damage, d, at); hit(target, damage, d, at);
float dist = OFDistanceOfVectors3D(*from, *to); float dist = OFDistanceOfVectors3D(from, to);
OFVector3D v = OFSubtractVectors3D(*from, *to); OFVector3D v = OFSubtractVectors3D(from, to);
v = OFMultiplyVector3D(v, damage / dist / 50); v = OFMultiplyVector3D(v, damage / dist / 50);
d.velocity = OFAddVectors3D(d.velocity, v); d.velocity = OFAddVectors3D(d.velocity, v);
} }
void void
raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to, raydamage(
DynamicEntity *d, int i) DynamicEntity *o, OFVector3D from, OFVector3D to, DynamicEntity *d, int i)
{ {
if (o.state != CS_ALIVE) if (o.state != CS_ALIVE)
return; return;
@ -376,7 +370,7 @@ raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to,
if (d.gunSelect == GUN_SG) { if (d.gunSelect == GUN_SG) {
int damage = 0; int damage = 0;
for (int r = 0; r < SGRAYS; r++) for (int r = 0; r < SGRAYS; r++)
if (intersect(o, from, &sg[r])) if (intersect(o, from, sg[r]))
damage += qdam; damage += qdam;
if (damage) if (damage)
hitpush(i, damage, o, d, from, to); hitpush(i, damage, o, d, from, to);
@ -385,7 +379,7 @@ raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to,
} }
void void
shoot(DynamicEntity *d, const OFVector3D *targ) shoot(DynamicEntity *d, OFVector3D targ)
{ {
int attacktime = lastmillis - d.lastAction; int attacktime = lastmillis - d.lastAction;
if (attacktime < d.gunWait) if (attacktime < d.gunWait)
@ -404,7 +398,7 @@ shoot(DynamicEntity *d, const OFVector3D *targ)
if (d.gunSelect) if (d.gunSelect)
d.ammo[d.gunSelect]--; d.ammo[d.gunSelect]--;
OFVector3D from = d.origin; OFVector3D from = d.origin;
OFVector3D to = *targ; OFVector3D to = targ;
from.z -= 0.2f; // below eye from.z -= 0.2f; // below eye
float dist = OFDistanceOfVectors3D(from, to); float dist = OFDistanceOfVectors3D(from, to);
@ -421,11 +415,11 @@ shoot(DynamicEntity *d, const OFVector3D *targ)
to = OFAddVectors3D(from, unitv); to = OFAddVectors3D(from, unitv);
} }
if (d.gunSelect == GUN_SG) if (d.gunSelect == GUN_SG)
createrays(&from, &to); createrays(from, to);
if (d.quadMillis && attacktime > 200) if (d.quadMillis && attacktime > 200)
playsoundc(S_ITEMPUP); playsoundc(S_ITEMPUP);
shootv(d.gunSelect, &from, &to, d, true); shootv(d.gunSelect, from, to, d, true);
if (![d isKindOfClass:Monster.class]) if (![d isKindOfClass:Monster.class])
addmsg(1, 8, SV_SHOT, d.gunSelect, (int)(from.x * DMF), addmsg(1, 8, SV_SHOT, d.gunSelect, (int)(from.x * DMF),
(int)(from.y * DMF), (int)(from.z * DMF), (int)(to.x * DMF), (int)(from.y * DMF), (int)(from.z * DMF), (int)(to.x * DMF),
@ -437,13 +431,13 @@ shoot(DynamicEntity *d, const OFVector3D *targ)
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) { [players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
if (player != [OFNull null]) if (player != [OFNull null])
raydamage(player, &from, &to, d, i); raydamage(player, from, to, d, i);
}]; }];
for (Monster *monster in Monster.monsters) for (Monster *monster in Monster.monsters)
if (monster != d) if (monster != d)
raydamage(monster, &from, &to, d, -2); raydamage(monster, from, to, d, -2);
if ([d isKindOfClass:Monster.class]) if ([d isKindOfClass:Monster.class])
raydamage(player1, &from, &to, d, -1); raydamage(player1, from, to, d, -1);
} }

View file

@ -199,7 +199,7 @@ cleardlights()
} }
void void
dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength, dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength,
DynamicEntity *owner) DynamicEntity *owner)
{ {
if (!reach) if (!reach)
@ -208,12 +208,12 @@ dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength,
reach = reach / 2; reach = reach / 2;
if (!reach) if (!reach)
return; return;
if (v->x < 0 || v->y < 0 || v->x > ssize || v->y > ssize) if (v.x < 0 || v.y < 0 || v.x > ssize || v.y > ssize)
return; return;
int creach = reach + 16; // dependant on lightray random offsets! int creach = reach + 16; // dependant on lightray random offsets!
struct block b = { (int)v->x - creach, (int)v->y - creach, struct block b = { (int)v.x - creach, (int)v.y - creach, creach * 2 + 1,
creach * 2 + 1, creach * 2 + 1 }; creach * 2 + 1 };
if (b.x < 1) if (b.x < 1)
b.x = 1; b.x = 1;
@ -233,9 +233,9 @@ dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength,
[dlights addItem:&copy]; [dlights addItem:&copy];
Entity *l = [Entity entity]; Entity *l = [Entity entity];
l.x = v->x; l.x = v.x;
l.y = v->y; l.y = v.y;
l.z = v->z; l.z = v.z;
l.attr1 = reach; l.attr1 = reach;
l.type = LIGHT; l.type = LIGHT;
l.attr2 = strength; l.attr2 = strength;