MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / destroy

Method destroy

src/Savegame/Tile.cpp:444–472  ·  view source on GitHub ↗

* Destroy a part on this tile. We first remove the old object, then replace it with the destroyed one. * This is because the object type of the old and new one are not necessarily the same. * If the destroyed part is an explosive, set the tile's explosive value, which will trigger a chained explosion. * @param part * @return bool Return true objective was destroyed */

Source from the content-addressed store, hash-verified

442 * @return bool Return true objective was destroyed
443 */
444bool Tile::destroy(int part)
445{
446 bool _objective = false;
447 if (_objects[part])
448 {
449 if (_objects[part]->isGravLift())
450 return false;
451 _objective = _objects[part]->getSpecialType() == MUST_DESTROY;
452 MapData *originalPart = _objects[part];
453 int originalMapDataSetID = _mapDataSetID[part];
454 setMapData(0, -1, -1, part);
455 if (originalPart->getDieMCD())
456 {
457 MapData *dead = originalPart->getDataset()->getObjects()->at(originalPart->getDieMCD());
458 setMapData(dead, originalPart->getDieMCD(), originalMapDataSetID, dead->getObjectType());
459 }
460 if (originalPart->getExplosive())
461 {
462 setExplosive(originalPart->getExplosive());
463 }
464 }
465 /* check if the floor on the lowest level is gone */
466 if (part == MapData::O_FLOOR && getPosition().z == 0 && _objects[MapData::O_FLOOR] == 0)
467 {
468 /* replace with scorched earth */
469 setMapData(MapDataSet::getScorchedEarthTile(), 1, 0, MapData::O_FLOOR);
470 }
471 return _objective;
472}
473
474/**
475 * damage terrain - check against armor

Callers 2

prepareNewTurnMethod · 0.80
detonateMethod · 0.80

Calls 7

isGravLiftMethod · 0.80
getSpecialTypeMethod · 0.80
getDieMCDMethod · 0.80
getObjectsMethod · 0.80
getDatasetMethod · 0.80
getObjectTypeMethod · 0.80
getExplosiveMethod · 0.45

Tested by

no test coverage detected