X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fcontainer.cpp;h=c867eaf80224c59609925d49eed1ec35683d3103;hb=5446001bd9adfd9f4787f5de5a2a7afd8d7cdb5a;hp=e125672eac63c6690d4d1cbc4da044e08a9e6ee7;hpb=7b7c8ec7d7f5379e09a8b7392f465f41639b0c79;p=architektonas diff --git a/src/container.cpp b/src/container.cpp index e125672..c867eaf 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -16,6 +16,7 @@ #include "container.h" #include +#include "dimension.h" Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p), @@ -117,8 +118,34 @@ Like so: { if (objects[i]->Collided(point)) { +Dimension * dimension = objects[i]->GetAttachedDimension(); + objects.erase(objects.begin() + i); // Calls the destructor, (deletes the object, I presume... O_o) + +// If this object had an attached dimension, reattach it to another object, if any... +// The only problem with that approach is if the object it gets attached to is deleted, +// it will call the dimension to use a NULL pointer and BLAMMO +if (dimension) +{ + Vector p1 = dimension->GetPoint1(); + Vector p2 = dimension->GetPoint2(); + for(int j=0; j<(int)objects.size(); j++) + { + Vector * objectP1 = objects[i]->GetPointAt(p1); + Vector * objectP2 = objects[i]->GetPointAt(p2); + + if (objectP1) + dimension->SetPoint1(objectP1); + + if (objectP2) + dimension->SetPoint2(objectP2); + } +} + + // This only allows deleting objects one at a time... break; + // however, this way of doing things could be problematic if we don't + // delete one at a time... Need to come up with a better approach. } } }