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

Method addToVisibleUnits

src/Savegame/BattleUnit.cpp:1204–1228  ·  view source on GitHub ↗

* Add this unit to the list of visible units. Returns true if this is a new one. * @param unit * @return */

Source from the content-addressed store, hash-verified

1202 * @return
1203 */
1204bool BattleUnit::addToVisibleUnits(BattleUnit *unit)
1205{
1206 bool add = true;
1207 for (std::vector<BattleUnit*>::iterator i = _unitsSpottedThisTurn.begin(); i != _unitsSpottedThisTurn.end();++i)
1208 {
1209 if ((BattleUnit*)(*i) == unit)
1210 {
1211 add = false;
1212 break;
1213 }
1214 }
1215 if (add)
1216 {
1217 _unitsSpottedThisTurn.push_back(unit);
1218 }
1219 for (std::vector<BattleUnit*>::iterator i = _visibleUnits.begin(); i != _visibleUnits.end(); ++i)
1220 {
1221 if ((BattleUnit*)(*i) == unit)
1222 {
1223 return false;
1224 }
1225 }
1226 _visibleUnits.push_back(unit);
1227 return true;
1228}
1229
1230/**
1231 * Get the pointer to the vector of visible units.

Callers 2

calculateFOVMethod · 0.80
getSpottingUnitsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected