* Add this unit to the list of visible units. Returns true if this is a new one. * @param unit * @return */
| 1202 | * @return |
| 1203 | */ |
| 1204 | bool 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. |
no outgoing calls
no test coverage detected