Okay, it seems I still do something wrong.
What I try to at the moment is clearing my world from all embeded objects to automatically place them in a second step.
To achieve that I loop trough all areas, selecting all the embeded objects and deleting them:
Code:
void cleanTerrainObjects () {
for (Int iteratorTX = -32; iteratorTX <= 32; iteratorTX++) {
for (Int iteratorTY = -32; iteratorTY <= 32; iteratorTY++) {
Edit::Area *area = Edit::World.grid.get(VecI2(iteratorTX,iteratorTY))->data();
for (Int i = area->objs()-1; i >= 0; i--) {
Edit::Obj obj = area->obj(i);
if (obj.access() == Game::ACCESS_EMBED) {
area->setChanged();
Edit::World.objSelSelect(&obj);
Edit::World.objDelete();
area->hmChanged();
}
}
}
}
}
I get an Exception in "EditStateUpdate" it seems. It happens after the code above has run and the Method it is in has ended (this Method gets called by the method bound to a button in the custom edit mode, but this Method is empty besides the Method call at the moment).
I assume some of the code written above must somehow cause this.... because the Exception happens at the end of the calling MEthod, and no other code is in it.
Anyway, one step further.
Gian-Reto
EDIT:
Got it working after some debugging. I'm not 100% why the first version didn't work, but being the C++ noob and Java-Code-Monkey that I am, I probably did something really stupid when I assigned the object. Pointers, oh the horror!
Code:
void cleanTerrainObjects () {
for (Int iteratorTX = -32; iteratorTX <= 32; iteratorTX++) {
for (Int iteratorTY = -32; iteratorTY <= 32; iteratorTY++) {
Edit::Area *area = Edit::World.grid.get(VecI2(iteratorTX,iteratorTY))->data();
for (Int i = area->objs()-1; i >= 0; i--) {
//Edit::Obj foundObject = area->obj(i);
if (area->obj(i).access() == Game::ACCESS_EMBED) {
area->setChanged();
Edit::World.objSelSelect(&area->obj(i));
Edit::World.objDelete();
area->hmChanged();
}
}
}
}
}
Now onwards to creating the objects...