diff --git a/src/Monster.m b/src/Monster.m index cce0543..37719ec 100644 --- a/src/Monster.m +++ b/src/Monster.m @@ -333,8 +333,7 @@ enemylos(Monster *m, OFVector3D *v) if (self.trigger < lastmillis) { self.lastAction = 0; self.attacking = true; - OFVector3D attackTarget = self.attackTarget; - shoot(self, &attackTarget); + shoot(self, self.attackTarget); [self transitionWithState:M_ATTACKING moving:0 n:600 diff --git a/src/clientgame.m b/src/clientgame.m index aad16cf..99ee8c5 100644 --- a/src/clientgame.m +++ b/src/clientgame.m @@ -163,7 +163,7 @@ updateworld(int millis) // main game update loop if (!demoplayback) { if (getclientnum() >= 0) // only shoot when connected to server - shoot(player1, &worldpos); + shoot(player1, worldpos); // do this first, so we have most accurate information // when our player moves gets2c(); diff --git a/src/clients2c.m b/src/clients2c.m index 1a3b1e7..5671d7b 100644 --- a/src/clients2c.m +++ b/src/clients2c.m @@ -221,8 +221,8 @@ localservertoclient(unsigned char *buf, int len) e.y = getint(&p) / DMF; e.z = getint(&p) / DMF; if (gun == GUN_SG) - createrays(&s, &e); - shootv(gun, &s, &e, d, false); + createrays(s, e); + shootv(gun, s, e, d, false); break; } diff --git a/src/protos.h b/src/protos.h index c2bfdc1..872098e 100644 --- a/src/protos.h +++ b/src/protos.h @@ -128,8 +128,8 @@ extern Entity *newentity( // worldlight extern void calclight(); -extern void dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, - int strength, DynamicEntity *owner); +extern void dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength, + DynamicEntity *owner); extern void cleardlights(); extern struct block *blockcopy(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 dot(int x, int y, float z); 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 gl_drawhud( 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); // renderparticles -extern void setorient(const OFVector3D *r, const OFVector3D *u); -extern void particle_splash(int type, int num, int fade, const OFVector3D *p); -extern void particle_trail( - int type, int fade, const OFVector3D *from, const OFVector3D *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 @@ -194,7 +193,7 @@ extern void incomingdemodata(unsigned char *buf, int len, bool extras); extern void demoplaybackstep(); extern void stop(); extern void stopifrecording(); -extern void demodamage(int damage, const OFVector3D *o); +extern void demodamage(int damage, OFVector3D o); extern void demoblend(int damage); // physics @@ -241,10 +240,10 @@ extern ENetPacket *recvmap(int n); // weapon extern void selectgun(int a, int b, int c); -extern void shoot(DynamicEntity *d, const OFVector3D *to); -extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to, - DynamicEntity *d, bool local); -extern void createrays(const OFVector3D *from, const OFVector3D *to); +extern void shoot(DynamicEntity *d, OFVector3D to); +extern void shootv( + int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local); +extern void createrays(OFVector3D from, OFVector3D to); extern void moveprojectiles(float time); extern void projreset(); extern OFString *playerincrosshair(); diff --git a/src/renderextras.m b/src/renderextras.m index 698a604..25cf542 100644 --- a/src/renderextras.m +++ b/src/renderextras.m @@ -93,7 +93,7 @@ static struct sphere spheres[MAXSPHERES], *slist = NULL, *sempty = NULL; bool sinit = false; void -newsphere(const OFVector3D *o, float max, int type) +newsphere(OFVector3D o, float max, int type) { if (!sinit) { for (int i = 0; i < MAXSPHERES; i++) { @@ -105,7 +105,7 @@ newsphere(const OFVector3D *o, float max, int type) if (sempty) { struct sphere *p = sempty; sempty = p->next; - p->o = *o; + p->o = o; p->max = max; p->size = 1; p->type = type; @@ -189,8 +189,7 @@ renderents() if (e.type == NOTUSED) continue; - OFVector3D v = OFMakeVector3D(e.x, e.y, e.z); - particle_splash(2, 2, 40, &v); + particle_splash(2, 2, 40, OFMakeVector3D(e.x, e.y, e.z)); } int e = closestent(); @@ -272,7 +271,7 @@ readdepth(int w, int h) worldpos.z = (float)worldz; OFVector3D r = OFMakeVector3D(mm[0], mm[4], mm[8]); OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]); - setorient(&r, &u); + setorient(r, u); } void diff --git a/src/renderparticles.m b/src/renderparticles.m index ab57497..6a48f48 100644 --- a/src/renderparticles.m +++ b/src/renderparticles.m @@ -18,7 +18,7 @@ bool parinit = false; VARP(maxparticles, 100, 2000, MAXPARTICLES - 500); static void -newparticle(const OFVector3D *o, const OFVector3D *d, int fade, int type) +newparticle(OFVector3D o, OFVector3D d, int fade, int type) { if (!parinit) { for (int i = 0; i < MAXPARTICLES; i++) { @@ -30,8 +30,8 @@ newparticle(const OFVector3D *o, const OFVector3D *d, int fade, int type) if (parempty) { struct particle *p = parempty; parempty = p->next; - p->o = *o; - p->d = *d; + p->o = o; + p->d = d; p->fade = fade; p->type = type; p->millis = lastmillis; @@ -46,20 +46,18 @@ VARP(particlesize, 20, 100, 500); OFVector3D right, up; void -setorient(const OFVector3D *r, const OFVector3D *u) +setorient(OFVector3D r, OFVector3D u) { - right = *r; - up = *u; + right = r; + up = u; } void render_particles(int time) { - if (demoplayback && demotracking) { - OFVector3D o = player1.origin; - OFVector3D nom = OFMakeVector3D(0, 0, 0); - newparticle(&o, &nom, 100000000, 8); - } + if (demoplayback && demotracking) + newparticle( + player1.origin, OFMakeVector3D(0, 0, 0), 100000000, 8); glDepthMask(GL_FALSE); glEnable(GL_BLEND); @@ -134,7 +132,7 @@ render_particles(int time) } 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++) { 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; } while (x * x + y * y + z * z > radius * radius); OFVector3D d = OFMakeVector3D(x, y, z); - newparticle(p, &d, rnd(fade * 3), type); + newparticle(p, d, rnd(fade * 3), type); } } 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); - OFVector3D v = OFSubtractVectors3D(*s, *e); + float d = OFDistanceOfVectors3D(s, e); + OFVector3D v = OFSubtractVectors3D(s, e); v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f)); - OFVector3D p = *s; for (int i = 0; i < ((int)d * 2); i++) { - p = OFAddVectors3D(p, v); + s = OFAddVectors3D(s, v); OFVector3D d = OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5); - newparticle(&p, &d, rnd(fade) + fade, type); + newparticle(s, d, rnd(fade) + fade, type); } } diff --git a/src/savegamedemo.m b/src/savegamedemo.m index c88fb68..d68158c 100644 --- a/src/savegamedemo.m +++ b/src/savegamedemo.m @@ -285,10 +285,10 @@ COMMAND(record, ARG_1STR, (^(OFString *name) { })) void -demodamage(int damage, const OFVector3D *o) +demodamage(int damage, OFVector3D o) { ddamage = damage; - dorig = *o; + dorig = o; } void @@ -443,7 +443,7 @@ demoplaybackstep() damageblend(bdamage); if ((ddamage = gzgeti())) { gzgetv(&dorig); - particle_splash(3, ddamage, 1000, &dorig); + particle_splash(3, ddamage, 1000, dorig); } // FIXME: set more client state here } diff --git a/src/weapon.m b/src/weapon.m index 7ec674b..e85b79f 100644 --- a/src/weapon.m +++ b/src/weapon.m @@ -71,24 +71,23 @@ COMMAND(weapon, ARG_3STR, ^(OFString *a1, OFString *a2, OFString *a3) { // create random spread of rays for the shotgun 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; for (int i = 0; i < SGRAYS; i++) #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 static bool -intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to) +intersect(DynamicEntity *d, OFVector3D from, OFVector3D to) { - OFVector3D v = *to, w = d.origin; - const OFVector3D *p; - v = OFSubtractVectors3D(v, *from); - w = OFSubtractVectors3D(w, *from); + OFVector3D v = OFSubtractVectors3D(to, from); + OFVector3D w = OFSubtractVectors3D(d.origin, from); float c1 = OFDotProductOfVectors3D(w, v); + OFVector3D p; if (c1 <= 0) p = from; @@ -98,15 +97,13 @@ intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to) p = to; else { v = OFMultiplyVector3D(v, c1 / c2); - v = OFAddVectors3D(v, *from); - p = &v; + p = OFAddVectors3D(v, from); } } - return (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->z <= d.origin.z + d.aboveEye && - p->z >= d.origin.z - d.eyeHeight); + return (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.z <= d.origin.z + d.aboveEye && p.z >= d.origin.z - d.eyeHeight); } OFString * @@ -120,7 +117,7 @@ playerincrosshair() continue; OFVector3D o = player1.origin; - if (intersect(player, &o, &worldpos)) + if (intersect(player, o, worldpos)) return [player name]; } @@ -138,8 +135,8 @@ projreset() } void -newprojectile(const OFVector3D *from, const OFVector3D *to, float speed, - bool local, DynamicEntity *owner, int gun) +newprojectile(OFVector3D from, OFVector3D to, float speed, bool local, + DynamicEntity *owner, int gun) { for (size_t i = 0; i < MAXPROJ; i++) { Projectile *p = projs[i]; @@ -151,8 +148,8 @@ newprojectile(const OFVector3D *from, const OFVector3D *to, float speed, continue; p.inuse = true; - p.o = *from; - p.to = *to; + p.o = from; + p.to = to; p.speed = speed; p.local = local; 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); playsound(S_PAIN1 + rnd(5), &o); } - particle_splash(3, damage, 1000, &o); - demodamage(damage, &o); + particle_splash(3, damage, 1000, o); + demodamage(damage, o); } const float RL_RADIUS = 5; @@ -182,14 +179,14 @@ const float RL_DAMRAD = 7; // hack static void 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) return; OFVector3D origin = o.origin; - float dist = OFDistanceOfVectors3D(*v, origin); - OFVector3D temp = OFSubtractVectors3D(*v, origin); + float dist = OFDistanceOfVectors3D(v, origin); + OFVector3D temp = OFSubtractVectors3D(v, origin); dist -= 2; // account for eye distance imprecision if (dist < RL_DAMRAD) { @@ -206,17 +203,17 @@ radialeffect( } static void -splash(Projectile *p, const OFVector3D *v, const OFVector3D *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; if (p.gun != GUN_RL) { - playsound(S_FEXPLODE, v); + playsound(S_FEXPLODE, &v); // no push? } else { - playsound(S_RLHIT, v); + playsound(S_RLHIT, &v); newsphere(v, RL_RADIUS, 0); dodynlight(vold, v, 0, 0, p.owner); @@ -245,15 +242,15 @@ splash(Projectile *p, const OFVector3D *v, const OFVector3D *vold, } static inline void -projdamage(DynamicEntity *o, Projectile *p, const OFVector3D *v, int i, int im, - int qdam) +projdamage( + DynamicEntity *o, Projectile *p, OFVector3D v, int i, int im, int qdam) { if (o.state != CS_ALIVE) return; OFVector3D po = p.o; - if (intersect(o, &po, v)) { - splash(p, v, &po, i, im, qdam); + if (intersect(o, po, v)) { + splash(p, v, po, i, im, qdam); hit(i, qdam, o, p.owner); } } @@ -281,29 +278,27 @@ moveprojectiles(float time) if (p.local) { for (id player in players) if (player != [OFNull null]) - projdamage(player, p, &v, i, -1, qdam); + projdamage(player, p, v, i, -1, qdam); if (p.owner != player1) - projdamage(player1, p, &v, -1, -1, qdam); + projdamage(player1, p, v, -1, -1, qdam); for (Monster *monster in Monster.monsters) if (!vreject(monster.origin, v, 10.0f) && monster != p.owner) - projdamage(monster, p, &v, -1, i, qdam); + projdamage(monster, p, v, -1, i, qdam); } if (p.inuse) { - OFVector3D po = p.o; - if (time == dtime) - splash(p, &v, &po, -1, -1, qdam); + splash(p, v, p.o, -1, -1, qdam); else { if (p.gun == GUN_RL) { - dodynlight(&po, &v, 0, 255, p.owner); - particle_splash(5, 2, 200, &v); + dodynlight(p.o, v, 0, 255, p.owner); + particle_splash(5, 2, 200, v); } else { - particle_splash(1, 1, 200, &v); + particle_splash(1, 1, 200, v); 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 void -shootv(int gun, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d, - bool local) +shootv(int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local) { OFVector3D loc = d.origin; 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: { for (int i = 0; i < SGRAYS; i++) - particle_splash(0, 5, 200, &sg[i]); + particle_splash(0, 5, 200, sg[i]); break; } @@ -353,18 +347,18 @@ shootv(int gun, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d, void hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at, - const OFVector3D *from, const OFVector3D *to) + OFVector3D from, OFVector3D to) { hit(target, damage, d, at); - float dist = OFDistanceOfVectors3D(*from, *to); - OFVector3D v = OFSubtractVectors3D(*from, *to); + float dist = OFDistanceOfVectors3D(from, to); + OFVector3D v = OFSubtractVectors3D(from, to); v = OFMultiplyVector3D(v, damage / dist / 50); d.velocity = OFAddVectors3D(d.velocity, v); } void -raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to, - DynamicEntity *d, int i) +raydamage( + DynamicEntity *o, OFVector3D from, OFVector3D to, DynamicEntity *d, int i) { if (o.state != CS_ALIVE) return; @@ -376,7 +370,7 @@ raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to, if (d.gunSelect == GUN_SG) { int damage = 0; for (int r = 0; r < SGRAYS; r++) - if (intersect(o, from, &sg[r])) + if (intersect(o, from, sg[r])) damage += qdam; if (damage) hitpush(i, damage, o, d, from, to); @@ -385,7 +379,7 @@ raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to, } void -shoot(DynamicEntity *d, const OFVector3D *targ) +shoot(DynamicEntity *d, OFVector3D targ) { int attacktime = lastmillis - d.lastAction; if (attacktime < d.gunWait) @@ -404,7 +398,7 @@ shoot(DynamicEntity *d, const OFVector3D *targ) if (d.gunSelect) d.ammo[d.gunSelect]--; OFVector3D from = d.origin; - OFVector3D to = *targ; + OFVector3D to = targ; from.z -= 0.2f; // below eye float dist = OFDistanceOfVectors3D(from, to); @@ -421,11 +415,11 @@ shoot(DynamicEntity *d, const OFVector3D *targ) to = OFAddVectors3D(from, unitv); } if (d.gunSelect == GUN_SG) - createrays(&from, &to); + createrays(from, to); if (d.quadMillis && attacktime > 200) playsoundc(S_ITEMPUP); - shootv(d.gunSelect, &from, &to, d, true); + shootv(d.gunSelect, from, to, d, true); if (![d isKindOfClass:Monster.class]) addmsg(1, 8, SV_SHOT, d.gunSelect, (int)(from.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) { if (player != [OFNull null]) - raydamage(player, &from, &to, d, i); + raydamage(player, from, to, d, i); }]; for (Monster *monster in Monster.monsters) if (monster != d) - raydamage(monster, &from, &to, d, -2); + raydamage(monster, from, to, d, -2); if ([d isKindOfClass:Monster.class]) - raydamage(player1, &from, &to, d, -1); + raydamage(player1, from, to, d, -1); } diff --git a/src/worldlight.m b/src/worldlight.m index 6171b1d..578a3a5 100644 --- a/src/worldlight.m +++ b/src/worldlight.m @@ -199,7 +199,7 @@ cleardlights() } void -dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength, +dodynlight(OFVector3D vold, OFVector3D v, int reach, int strength, DynamicEntity *owner) { if (!reach) @@ -208,12 +208,12 @@ dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength, reach = reach / 2; if (!reach) 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; int creach = reach + 16; // dependant on lightray random offsets! - struct block b = { (int)v->x - creach, (int)v->y - creach, - creach * 2 + 1, creach * 2 + 1 }; + struct block b = { (int)v.x - creach, (int)v.y - creach, creach * 2 + 1, + creach * 2 + 1 }; if (b.x < 1) b.x = 1; @@ -233,9 +233,9 @@ dodynlight(const OFVector3D *vold, const OFVector3D *v, int reach, int strength, [dlights addItem:©]; Entity *l = [Entity entity]; - l.x = v->x; - l.y = v->y; - l.z = v->z; + l.x = v.x; + l.y = v.y; + l.z = v.z; l.attr1 = reach; l.type = LIGHT; l.attr2 = strength;