| 177 | } |
| 178 | |
| 179 | void add_to_history(color_ostream &out, int32_t unit_id) { |
| 180 | if (offset > 0) { |
| 181 | DEBUG(cycle,out).print("trimming history forward of offset {}\n", offset); |
| 182 | history.resize(history.size() - offset); |
| 183 | offset = 0; |
| 184 | } |
| 185 | if (history.size() && history.back() == unit_id) { |
| 186 | DEBUG(cycle,out).print("unit {} is already current unit; not adding to history\n", unit_id); |
| 187 | } else { |
| 188 | history.push_back(unit_id); |
| 189 | if (history.size() > MAX_HISTORY) { |
| 190 | DEBUG(cycle,out).print("history full, truncating\n"); |
| 191 | history.pop_front(); |
| 192 | } |
| 193 | } |
| 194 | DEBUG(cycle,out).print("history now has {} entries\n", history.size()); |
| 195 | } |
| 196 | |
| 197 | void add_and_follow(color_ostream &out, df::unit *unit) { |
| 198 | // if we're currently following a unit, add it to the history if it's not already there |
no test coverage detected