MCPcopy Create free account
hub / github.com/DFHack/dfhack / add_to_history

Method add_to_history

plugins/spectate.cpp:179–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

spectate_addToHistoryFunction · 0.80

Calls 3

printMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected