From 80ca208bccd4ee90c761d6d02c74e6562a018c44 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 24 Oct 2008 21:55:58 +0000 Subject: [PATCH] don't modify flag ent during ctf games git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3233 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 6 +++--- source/src/entities.cpp | 22 ++++++++++------------ source/src/entity.h | 2 +- source/src/physics.cpp | 2 +- source/src/protos.h | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 5e02e235..ae8b7c0b 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -647,9 +647,9 @@ void preparectf(bool cleanonly=false) if(e.attr2>2) { conoutf("\f3invalid ctf-flag entity (%i)", i); e.attr2 = 0; } flaginfo &f = flaginfos[e.attr2]; f.flagent = &e; - f.originalpos.x = (float) e.x; - f.originalpos.y = (float) e.y; - f.originalpos.z = (float) e.z; + f.pos.x = (float) e.x; + f.pos.y = (float) e.y; + f.pos.z = (float) e.z; } } } diff --git a/source/src/entities.cpp b/source/src/entities.cpp index d30fa520..4eaa0795 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -119,7 +119,7 @@ void renderentities() { entity &e = *f.flagent; s_sprintfd(path)("pickups/flags/%s%s", m_ktf ? "" : team_string(i), m_htf ? "_htf" : m_ktf ? "ktf" : ""); - rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, f.state==CTFF_INBASE ? (float)S(e.x, e.y)->floor : e.z), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 120.0f); + rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(f.pos.x, f.pos.y, f.state==CTFF_INBASE ? (float)S(int(f.pos.x), int(f.pos.y))->floor : f.pos.z), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 120.0f); break; } case CTFF_IDLE: @@ -248,15 +248,15 @@ void checkitems(playerent *d) flaginfo &f = flaginfos[i]; entity &e = *f.flagent; if(!e.spawned || !f.ack || (f.state == CTFF_INBASE && !numflagspawn[i])) continue; - if(OUTBORD(e.x, e.y)) continue; + if(OUTBORD(int(f.pos.x), int(f.pos.y))) continue; if(f.state==CTFF_DROPPED) // 3d collision for dropped ctf flags { - vec v(e.x, e.y, e.z); - if(objcollide(d, v, 2.5f, 4.0f)) trypickupflag(i, d); + if(objcollide(d, f.pos, 2.5f, 4.0f)) trypickupflag(i, d); } else // simple 2d collision { - vec v(e.x, e.y, S(e.x, e.y)->floor+eyeheight); + vec v = f.pos; + v.z = S(int(v.x), int(v.y))->floor + eyeheight; if(d->o.dist(v)<2.5f) trypickupflag(i, d); } } @@ -394,10 +394,10 @@ void flagdropped(int flag, short x, short y, short z) } if(f.actor) f.actor->cancollide = oldcancollide; // restore settings - f.flagent->x = (short)round(p.o.x); - f.flagent->y = (short)round(p.o.y); - f.flagent->z = (short)round(p.o.z); - if(f.flagent->z < hdr.waterlevel) f.flagent->z = (short) hdr.waterlevel; + f.pos.x = round(p.o.x); + f.pos.y = round(p.o.y); + f.pos.z = round(p.o.z); + if(f.pos.z < hdr.waterlevel) f.pos.z = (short) hdr.waterlevel; f.flagent->spawned = true; f.ack = true; } @@ -406,9 +406,7 @@ void flaginbase(int flag) { flaginfo &f = flaginfos[flag]; f.actor = NULL; f.actor_cn = -1; - f.flagent->x = (ushort) f.originalpos.x; - f.flagent->y = (ushort) f.originalpos.y; - f.flagent->z = (ushort) f.originalpos.z; + f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z); f.flagent->spawned = true; f.ack = true; } diff --git a/source/src/entity.h b/source/src/entity.h index 5ed2a533..4cf592dc 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -476,7 +476,7 @@ struct flaginfo entity *flagent; int actor_cn; playerent *actor; - vec originalpos; + vec pos; int state; // one of CTFF_* bool ack; flaginfo() : flagent(0), actor(0), state(CTFF_INBASE), ack(false) {} diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 2945789c..5653bb5e 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -143,7 +143,7 @@ bool mmcollide(physent *d, float &hi, float &lo) // collide with a map return true; } -bool objcollide(physent *d, vec &objpos, float objrad, float objheight) // collide with custom/typeless objects +bool objcollide(physent *d, const vec &objpos, float objrad, float objheight) // collide with custom/typeless objects { const float r = d->radius+objrad; if(fabs(objpos.x-d->o.x)o.y)