Closed DivFord closed 9 years ago
The 'replace' bool is used on line 166 (or at least, it is in my editor. The line straight after 'case OBJ_BLOCK:').
Either way, yeah, that is odd. I'll have a poke around if it's still unsolved when I get back from my lecture.
Sorry, I worded that badly. I meant that the function is only called from one place, so the bool is irrelevant.
I think it's also used in Room::clear, where replace = false so that destroyed blocks aren't replaced by air.
In that case, the problem is the:
if(objectAtPoint(objects_[index]->mid(), &Object::type, OBJ_BLOCK) != objects_[index].get()) {
For some reason, that always evaluates to false.
I may be wrong, but doesn't objectAtPoint always return the first object it finds at that point, even if there are multiple objects?
The comment says "If there's nothing else in the same tile, replace it with an air block", but doesn't this do the opposite of that? It looks like it will only be true if the first object found in that space is not the object being erased.
Ok, I've fixed it. There were two issues:
1) replace defaults to false, so we need to set it explicitly in checkDead() 2) That if statement needed to be == rather than !=
I've pushed the fix.
EDIT: Though if I'm right about objectAtPoint, that may become a problem later...
Tiling seems to have stopped working properly. When you destroy a block, nothing changes.
I've tracked this down to Room:erase. There's a 'replace' boolean that's never being used - is there a reason for it?
Even with the 'replace' commented out, the if-statement inside it never evaluates to true, so we're not adding air blocks.
Since we should never have multiple blocks in the same space anyway, can we just replace with air without checking that?