Index: src/clients2c.mm ================================================================== --- src/clients2c.mm +++ src/clients2c.mm @@ -199,11 +199,11 @@ zapdynent(players[cn]); break; 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; e.x = getint(p) / DMF; e.y = getint(p) / DMF; @@ -272,12 +272,12 @@ case SV_ITEMSPAWN: { uint i = getint(p); 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; } case SV_ITEMACC: // server acknowledges that I picked up this Index: src/command.mm ================================================================== --- src/command.mm +++ src/command.mm @@ -52,12 +52,12 @@ idents[b.name] = b; } else { 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) int Index: src/cube.h ================================================================== --- src/cube.h +++ src/cube.h @@ -100,13 +100,10 @@ #define MINBORD 2 // 2 cubes from the edge of the world are always solid #define OUTBORD(x, y) \ ((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \ (y) >= ssize - MINBORD) -struct vec { - float x, y, z; -}; struct block { int x, y, xs, ys; }; struct mapmodelinfo { int rad, h, zoff, snap; @@ -126,12 +123,12 @@ NUMGUNS }; 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; bool onfloor, jumpnext; int move, strafe; @@ -152,12 +149,12 @@ dynent *enemy; // monster wants to kill this entity float targetyaw; // monster wants to look in this direction bool blocked, moving; // used by physics to signal ai int trigger; // millis at which transition to another monsterstate takes // place - vec attacktarget; // delayed attacks - int anger; // how many times already hit by fellow monster + OFVector3D attacktarget; // delayed attacks + int anger; // how many times already hit by fellow monster string name, team; }; #define SAVEGAMEVERSION \ 4 // bump if dynent/netprotocol changes or any other savegame/demo data @@ -293,11 +290,11 @@ extern dynent *player1; // special client ent that receives input and acts as camera extern dvector players; // all the other clients (in multiplayer) extern bool editmode; extern vector 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; extern int xtraverts; extern bool demoplayback; @@ -339,11 +336,11 @@ (u).x -= (v).x; \ (u).y -= (v).y; \ (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) \ ((v).x > (u).x + (max) || (v).x < (u).x - (max) || \ (v).y > (u).y + (max) || (v).y < (u).y - (max)) Index: src/entities.mm ================================================================== --- src/entities.mm +++ src/entities.mm @@ -296,19 +296,19 @@ case JUMPPAD: { static int lastjumppad = 0; 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() { if (editmode) @@ -320,17 +320,17 @@ continue; if (!ents[i].spawned && e.type != TELEPORT && e.type != JUMPPAD) 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) { if (player1->quadmillis && (player1->quadmillis -= time) < 0) { Index: src/monster.mm ================================================================== --- src/monster.mm +++ src/monster.mm @@ -124,11 +124,11 @@ }; }; 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; float dx = bx - lx; float dy = by - ly; @@ -160,11 +160,11 @@ }; return i >= steps; }; 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, m->enemy->o.z, v); }; @@ -251,11 +251,11 @@ break; 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); float angle = (float)fabs(enemyyaw - m->yaw); if (disttoenemy < 8 // the better the angle to the player, the @@ -281,11 +281,11 @@ case M_HOME: // monster has visual contact, heads straight for player // 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 // then search for player { @@ -378,11 +378,12 @@ entity &e = ents[i]; if (e.type != TELEPORT) 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) { monsters[i]->move = 0; moveplayer(monsters[i], 1, false); Index: src/physics.mm ================================================================== --- src/physics.mm +++ src/physics.mm @@ -238,11 +238,11 @@ 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))); d.z = 0; Index: src/protos.h ================================================================== --- src/protos.h +++ src/protos.h @@ -124,11 +124,11 @@ int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4); // 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); // worldrender @@ -165,22 +165,23 @@ // renderextras 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); 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(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 extern void save_world(OFString *fname); extern void load_world(char *mname); @@ -189,11 +190,11 @@ extern void loadgamerest(); 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 extern void moveplayer(dynent *pl, int moveres, bool local); extern bool collide(dynent *d, bool spawn, float drop, float rise); @@ -200,11 +201,11 @@ extern void entinmap(dynent *d); 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(); // rendermd2 @@ -234,14 +235,14 @@ extern void sendmaps(int n, string mapname, int mapsize, uchar *mapdata); 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(); extern int reloadtime(int gun); Index: src/renderextras.mm ================================================================== --- src/renderextras.mm +++ src/renderextras.mm @@ -78,20 +78,20 @@ glDepthMask(GL_TRUE); }; const int MAXSPHERES = 50; struct sphere { - vec o; + OFVector3D o; float size, max; int type; sphere *next; }; 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) { spheres[i].next = sempty; @@ -182,13 +182,13 @@ loopv(ents) { 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]; @autoreleasepool { sprintf_s(closeent)( @@ -224,11 +224,11 @@ COMMAND(loadsky, ARG_1STR) float cursordepth = 0.9f; GLint viewport[4]; GLdouble mm[16], pm[16]; -vec worldpos; +OFVector3D worldpos; void readmatrices() { glGetIntegerv(GL_VIEWPORT, viewport); @@ -260,12 +260,12 @@ gluUnProject(w / 2, h / 2, depthcorrect(cursordepth), mm, pm, viewport, &worldx, &worldz, &worldy); 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); }; void drawicon(float tx, float ty, int x, int y) Index: src/rendermd2.mm ================================================================== --- src/rendermd2.mm +++ src/rendermd2.mm @@ -30,23 +30,23 @@ int numTriangles; int frameSize; int numFrames; int numVerts; char *frames; - vec **mverts; + OFVector3D **mverts; int displaylist; int displaylistverts; mapmodelinfo mmi; char *loadname; int mdlnum; 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() : numGlCommands(0), frameSize(0), numFrames(0), displaylist(0), loaded(false) {}; @@ -101,11 +101,11 @@ numTriangles = header.numTriangles; numVerts = header.numVertices; fclose(file); - mverts = new vec *[numFrames]; + mverts = new OFVector3D *[numFrames]; loopj(numFrames) mverts[j] = NULL; return true; }; @@ -116,26 +116,26 @@ }; 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; v->z = (snap(sn, cv[2] * cf->scale[2]) + cf->translate[2]) / sc; }; }; 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); glPushMatrix(); @@ -161,12 +161,12 @@ float frac2 = 1 - frac1; fr1 = fr1 % range + frame; 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++; if (numVertex > 0) { glBegin(GL_TRIANGLE_STRIP); @@ -179,12 +179,12 @@ { float tu = *((float *)command++); 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)); }; xtraverts += numVertex; @@ -281,11 +281,11 @@ glBindTexture(GL_TEXTURE_2D, tex ? lookuptexture(tex, xs, ys) : FIRSTMDL + m->mdlnum); 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); float ll = 256.0f; // 0.96f; float of = 0.0f; // 0.1f; Index: src/renderparticles.mm ================================================================== --- src/renderparticles.mm +++ src/renderparticles.mm @@ -3,11 +3,11 @@ #include "cube.h" const int MAXPARTICLES = 10500; const int NUMPARTCUTOFF = 20; struct particle { - vec o, d; + OFVector3D o, d; int fade, type; int millis; particle *next; }; particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL; @@ -14,11 +14,11 @@ 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) { particles[i].next = parempty; @@ -40,26 +40,26 @@ }; 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); glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); glDisable(GL_FOG); @@ -116,25 +116,25 @@ parempty = p; } else { 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); glDepthMask(GL_TRUE); }; void -particle_splash(int type, int num, int fade, vec &p) +particle_splash(int type, int num, int fade, OFVector3D &p) { loopi(num) { const int radius = type == 5 ? 50 : 150; int x, y, z; @@ -141,24 +141,24 @@ do { x = rnd(radius * 2) - radius; 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); - }; -}; + } +} Index: src/savegamedemo.mm ================================================================== --- src/savegamedemo.mm +++ src/savegamedemo.mm @@ -29,13 +29,13 @@ { gzwrite(f, &i, sizeof(int)); } void -gzputv(vec &v) +gzputv(OFVector3D &v) { - gzwrite(f, &v, sizeof(vec)); + gzwrite(f, &v, sizeof(OFVector3D)); } void gzcheck(int a, int b) { @@ -57,13 +57,13 @@ gzcheck(gzread(f, &i, sizeof(int)), sizeof(int)); return i; } void -gzgetv(vec &v) +gzgetv(OFVector3D &v) { - gzcheck(gzread(f, &v, sizeof(vec)), sizeof(vec)); + gzcheck(gzread(f, &v, sizeof(OFVector3D)), sizeof(OFVector3D)); } void stop() { @@ -242,11 +242,11 @@ // demo functions int starttime = 0; int playbacktime = 0; int ddamage, bdamage; -vec dorig; +OFVector3D dorig; void record(OFString *name) { @autoreleasepool { @@ -267,11 +267,11 @@ } } COMMAND(record, ARG_1STR) void -demodamage(int damage, vec &o) +demodamage(int damage, OFVector3D &o) { ddamage = damage; dorig = o; }; void @@ -361,25 +361,26 @@ readdemotime(); } 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); vmul(t2, 0.5f); float s2 = s * s; 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); vadd(dest, t); vmul(t1, s3 - 2 * s2 + s); @@ -405,11 +406,11 @@ if (len < 1 || len > MAXTRANS) { conoutf( @"error: huge packet during demo play (%d)", len); stopreset(); return; - }; + } uchar buf[MAXTRANS]; gzread(f, buf, len); localservertoclient(buf, len); // update game state dynent *target = players[democlientnum]; @@ -432,13 +433,13 @@ if (bdamage = gzgeti()) damageblend(bdamage); 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 && (playerhistory.empty() || playerhistory.last()->lastupdate != playbacktime)) { @@ -447,15 +448,15 @@ d->lastupdate = playbacktime; playerhistory.add(d); if (playerhistory.length() > 20) { zapdynent(playerhistory[0]); playerhistory.remove(0); - }; - }; + } + } readdemotime(); - }; + } if (demoplayback) { int itime = lastmillis - demodelaymsec; loopvrev(playerhistory) if (playerhistory[i]->lastupdate < itime) // find 2 positions in @@ -487,22 +488,23 @@ if (dist < 16) // if teleport or spawn, dont't // interpolate { 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() { if (demoplayback) Index: src/sound.mm ================================================================== --- src/sound.mm +++ src/sound.mm @@ -14,11 +14,11 @@ #define MAXCHAN 32 #define SOUNDFREQ 22050 struct soundloc { - vec loc; + OFVector3D loc; bool inuse; } soundlocs[MAXCHAN]; #ifdef USE_MIXER # include "SDL_mixer.h" @@ -148,11 +148,11 @@ }; VAR(stereo, 0, 1, 1); void -updatechanvol(int chan, vec *loc) +updatechanvol(int chan, OFVector3D *loc) { int vol = soundvol, pan = 255 / 2; if (loc) { vdist(dist, v, *loc, player1->o); vol -= (int)(dist * 3 * soundvol / @@ -176,11 +176,11 @@ FSOUND_SetPan(chan, pan); #endif }; void -newsoundloc(int chan, vec *loc) +newsoundloc(int chan, OFVector3D *loc) { assert(chan >= 0 && chan < MAXCHAN); soundlocs[chan].loc = *loc; soundlocs[chan].inuse = true; }; @@ -211,11 +211,11 @@ }; int soundsatonce = 0, lastsoundmillis = 0; void -playsound(int n, vec *loc) +playsound(int n, OFVector3D *loc) { if (nosound) return; if (!soundvol) return; Index: src/weapon.mm ================================================================== --- src/weapon.mm +++ src/weapon.mm @@ -8,11 +8,11 @@ }; 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"}, {S_SG, 1400, 10, 0, 0, 20, "shotgun"}, // *SGRAYS {S_CG, 100, 30, 0, 0, 7, "chaingun"}, @@ -69,27 +69,29 @@ } } 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); if (c1 <= 0) @@ -127,11 +129,11 @@ return NULL; }; const int MAXPROJ = 100; struct projectile { - vec o, to; + OFVector3D o, to; float speed; dynent *owner; int gun; bool inuse, local; }; @@ -142,12 +144,12 @@ { loopi(MAXPROJ) projs[i].inuse = false; }; 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) { projectile *p = &projs[i]; if (p->inuse) @@ -180,11 +182,11 @@ 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; vdist(dist, temp, v, o->o); dist -= 2; // account for eye distance imprecision @@ -197,12 +199,12 @@ vadd(o->vel, temp); }; }; 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; if (p->gun != GUN_RL) { playsound(S_FEXPLODE, &v); @@ -228,11 +230,11 @@ radialeffect(mv[i], v, i, qdam, p->owner); }; }; 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; if (intersect(o, p->o, v)) { splash(p, v, p->o, i, im, qdam); @@ -262,18 +264,18 @@ { dynent *o = players[i]; 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); else { if (p->gun == GUN_RL) { @@ -281,19 +283,19 @@ particle_splash(5, 2, 200, v); } else { 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); int pspeed = 25; switch (gun) { @@ -326,20 +328,21 @@ break; }; }; 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; int qdam = guns[d->gunselect].damage; if (d->quadmillis) @@ -354,11 +357,11 @@ } else if (intersect(o, from, to)) hitpush(i, qdam, o, d, from, to); }; void -shoot(dynent *d, vec &targ) +shoot(dynent *d, OFVector3D &targ) { int attacktime = lastmillis - d->lastaction; if (attacktime < d->gunwait) return; d->gunwait = 0; @@ -372,17 +375,17 @@ d->lastattackgun = -1; return; }; 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) d->pitch += guns[d->gunselect].kickamount * 0.05f; Index: src/world.mm ================================================================== --- src/world.mm +++ src/world.mm @@ -265,11 +265,11 @@ loopv(ents) { 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; bdist = dist; }; Index: src/worldlight.mm ================================================================== --- src/worldlight.mm +++ src/worldlight.mm @@ -198,11 +198,12 @@ free(backup); } } 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; if (owner->monsterstate) reach = reach / 2;