avoid double assignment of worldobjrefs

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2369 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-08-23 20:59:23 +00:00
parent 5762dbe2ff
commit 9a484785c0
+9 -3
View File
@@ -399,6 +399,7 @@ struct worldobjreference
worldobjreference(int t) : type(t) {};
virtual ~worldobjreference() {};
virtual worldobjreference* clone() = 0;
virtual vec& currentposition() = 0;
virtual bool nodistance() = 0;
virtual bool operator==(const worldobjreference &other) = 0;
@@ -410,6 +411,7 @@ struct worldobjreference
struct camerareference : worldobjreference
{
camerareference() : worldobjreference(WR_CAMERA) {};
worldobjreference *clone() { return new camerareference(*this); }
vec& currentposition() { return camera1->o; }
bool nodistance() { return true; }
bool operator==(const worldobjreference &other) { return type==other.type; }
@@ -425,6 +427,7 @@ struct physentreference : worldobjreference
phys = ref;
}
worldobjreference *clone() { return new physentreference(*this); }
vec &currentposition() { return phys->o; }
bool nodistance() { return phys==camera1; }
bool operator==(const worldobjreference &other) { return type==other.type && phys==((physentreference &)other).phys; }
@@ -441,6 +444,8 @@ struct entityreference : worldobjreference
ent = ref;
}
worldobjreference *clone() { return new entityreference(*this); }
vec &currentposition()
{
tmp = vec(ent->x, ent->y, ent->z);
@@ -462,6 +467,7 @@ struct staticreference : worldobjreference
pos = ref;
}
worldobjreference *clone() { return new staticreference(*this); }
vec &currentposition() { return pos; }
bool nodistance() { return false; }
bool operator==(const worldobjreference &other) { return type==other.type && pos==((staticreference &)other).pos; }
@@ -1063,13 +1069,13 @@ struct locvector : vector<location *>
delete loc;
}
void replaceworldobjreference(const worldobjreference &oldr, worldobjreference *newr)
void replaceworldobjreference(const worldobjreference &oldr, worldobjreference &newr)
{
loopv(*this)
{
location *l = buf[i];
if(!l) continue;
if(*(l->ref)==oldr) l->attachworldobjreference(newr);
if(*(l->ref)==oldr) l->attachworldobjreference(newr.clone());
}
}
@@ -1578,7 +1584,7 @@ void detachsounds(playerent *owner)
{
if(nosound) return;
// make all dependent locations static
locations.replaceworldobjreference(physentreference(owner), new staticreference(owner->o));
locations.replaceworldobjreference(physentreference(owner), staticreference(owner->o));
}
void soundtest()