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

Method resetUnitTiles

src/Savegame/SavedBattleGame.cpp:916–948  ·  view source on GitHub ↗

* Resets all the units to their current standing tile(s). */

Source from the content-addressed store, hash-verified

914 * Resets all the units to their current standing tile(s).
915 */
916void SavedBattleGame::resetUnitTiles()
917{
918 for (std::vector<BattleUnit*>::iterator i = _units.begin(); i != _units.end(); ++i)
919 {
920 if (!(*i)->isOut())
921 {
922 int size = (*i)->getArmor()->getSize() - 1;
923 if ((*i)->getTile() && (*i)->getTile()->getUnit() == (*i))
924 {
925 for (int x = size; x >= 0; x--)
926 {
927 for (int y = size; y >= 0; y--)
928 {
929 getTile((*i)->getTile()->getPosition() + Position(x,y,0))->setUnit(0);
930 }
931 }
932 }
933 for (int x = size; x >= 0; x--)
934 {
935 for (int y = size; y >= 0; y--)
936 {
937 Tile *t = getTile((*i)->getPosition() + Position(x,y,0));
938 t->setUnit((*i), getTile(t->getPosition() + Position(0,0,-1)));
939 }
940 }
941
942 }
943 if ((*i)->getFaction() == FACTION_PLAYER)
944 {
945 (*i)->setVisible(true);
946 }
947 }
948}
949
950/**
951 * Gives access to the "storage space" vector, for distribution of items in base defense missions.

Callers 1

btnOkClickMethod · 0.80

Calls 10

isOutMethod · 0.80
getFactionMethod · 0.80
PositionClass · 0.70
getSizeMethod · 0.45
getArmorMethod · 0.45
getTileMethod · 0.45
getUnitMethod · 0.45
setUnitMethod · 0.45
getPositionMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected