Index: src/Monster.m ================================================================== --- src/Monster.m +++ src/Monster.m @@ -331,12 +331,11 @@ // this state is the delay between wanting to shoot and actually // firing 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 r:0]; } Index: src/clientgame.m ================================================================== --- src/clientgame.m +++ src/clientgame.m @@ -161,11 +161,11 @@ moveprojectiles((float)curtime); demoplaybackstep(); 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(); } otherplayers(); Index: src/clients2c.m ================================================================== --- src/clients2c.m +++ src/clients2c.m @@ -219,12 +219,12 @@ s.z = getint(&p) / DMF; e.x = getint(&p) / DMF; 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; } case SV_DAMAGE: { int target = getint(&p); Index: src/protos.h ================================================================== --- src/protos.h +++ src/protos.h @@ -126,12 +126,12 @@ extern Entity *newentity( int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4); // 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); // worldrender @@ -167,23 +167,22 @@ // renderextras 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); extern void readdepth(int w, int h); 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 extern void save_world(OFString *fname); extern void load_world(OFString *mname); @@ -192,11 +191,11 @@ extern void loadgamerest(); 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 extern void moveplayer(DynamicEntity *pl, int moveres, bool local); extern bool collide(DynamicEntity *d, bool spawn, float drop, float rise); @@ -239,14 +238,14 @@ int n, OFString *mapname, int mapsize, unsigned char *mapdata); 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(); extern int reloadtime(int gun); Index: src/renderextras.m ================================================================== --- src/renderextras.m +++ src/renderextras.m @@ -91,11 +91,11 @@ }; 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++) { spheres[i].next = sempty; sempty = &spheres[i]; @@ -103,11 +103,11 @@ sinit = true; } if (sempty) { struct sphere *p = sempty; sempty = p->next; - p->o = *o; + p->o = o; p->max = max; p->size = 1; p->type = type; p->next = slist; slist = p; @@ -187,12 +187,11 @@ for (Entity *e in ents) { 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(); if (e >= 0) { Entity *c = ents[e]; @@ -270,11 +269,11 @@ worldpos.x = (float)worldx; worldpos.y = (float)worldy; 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 drawicon(float tx, float ty, int x, int y) { Index: src/renderparticles.m ================================================================== --- src/renderparticles.m +++ src/renderparticles.m @@ -16,11 +16,11 @@ 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++) { particles[i].next = parempty; parempty = &particles[i]; @@ -28,12 +28,12 @@ parinit = true; } 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; p->next = parlist; parlist = p; @@ -44,24 +44,22 @@ 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); glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); glDisable(GL_FOG); @@ -132,11 +130,11 @@ glDisable(GL_BLEND); glDepthMask(GL_TRUE); } 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; int x, y, z; do { @@ -143,23 +141,22 @@ x = rnd(radius * 2) - radius; y = rnd(radius * 2) - radius; 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); } } Index: src/savegamedemo.m ================================================================== --- src/savegamedemo.m +++ src/savegamedemo.m @@ -283,14 +283,14 @@ starttime = lastmillis; ddamage = bdamage = 0; })) void -demodamage(int damage, const OFVector3D *o) +demodamage(int damage, OFVector3D o) { ddamage = damage; - dorig = *o; + dorig = o; } void demoblend(int damage) { @@ -441,11 +441,11 @@ target.lastMove = playbacktime; if ((bdamage = gzgeti())) 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 } // insert latest copy of player into history Index: src/weapon.m ================================================================== --- src/weapon.m +++ src/weapon.m @@ -69,46 +69,43 @@ (a3.length > 0 ? a3.cube_intValue : -1)); }) // 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; else { float c2 = OFDotProductOfVectors3D(v, v); if (c2 <= c1) 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 * playerincrosshair() { @@ -118,11 +115,11 @@ for (id player in players) { if (player == [OFNull null]) continue; OFVector3D o = player1.origin; - if (intersect(player, &o, &worldpos)) + if (intersect(player, o, worldpos)) return [player name]; } return nil; } @@ -136,12 +133,12 @@ for (size_t i = 0; i < MAXPROJ; i++) projs[i].inuse = false; } 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]; if (p == nil) @@ -149,12 +146,12 @@ if (p.inuse) 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; p.gun = gun; return; @@ -171,27 +168,27 @@ [d incurDamage:damage fromEntity:at]; else { 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; 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) { if (dist < 0) dist = 0; @@ -204,21 +201,21 @@ o.velocity = OFAddVectors3D(o.velocity, temp); } } 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); if (!p.local) return; @@ -243,19 +240,19 @@ }]; } } 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); } } void @@ -279,44 +276,41 @@ v = OFMultiplyVector3D(v, time / dtime); v = OFAddVectors3D(v, p.o); 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); } } } p.o = v; } } // 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); int pspeed = 25; switch (gun) { @@ -323,11 +317,11 @@ case GUN_FIST: break; 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; } case GUN_CG: particle_splash(0, 100, 250, to); @@ -351,22 +345,22 @@ } } 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; int qdam = guns[d.gunSelect].damage; if (d.quadMillis) @@ -374,20 +368,20 @@ if ([d isKindOfClass:Monster.class]) qdam /= MONSTERDAMAGEFACTOR; 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); } else if (intersect(o, from, to)) hitpush(i, qdam, o, d, from, to); } void -shoot(DynamicEntity *d, const OFVector3D *targ) +shoot(DynamicEntity *d, OFVector3D targ) { int attacktime = lastmillis - d.lastAction; if (attacktime < d.gunWait) return; d.gunWait = 0; @@ -402,11 +396,11 @@ return; } 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); OFVector3D unitv = OFSubtractVectors3D(from, to); unitv = OFMultiplyVector3D(unitv, 1.0f / dist); @@ -419,15 +413,15 @@ if (d.gunSelect == GUN_FIST || d.gunSelect == GUN_BITE) { unitv = OFMultiplyVector3D(unitv, 3); // punch range 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), (int)(to.y * DMF), (int)(to.z * DMF)); d.gunWait = guns[d.gunSelect].attackdelay; @@ -435,15 +429,15 @@ if (guns[d.gunSelect].projspeed) return; [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); } Index: src/worldlight.m ================================================================== --- src/worldlight.m +++ src/worldlight.m @@ -197,25 +197,25 @@ OFFreeMemory(backup); } } 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) reach = dynlight; if ([owner isKindOfClass:Monster.class]) 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; if (b.y < 1) b.y = 1; @@ -231,13 +231,13 @@ // backup area before rendering in dynlight struct block *copy = blockcopy(&b); [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; calclightsource(l); postlightarea(&b);