Implements plugin: spectate v1.0.3b

test
develop
Josh Cooper 2022-11-21 12:13:11 -08:00
parent 4a0abd1915
commit 5352649b88
1 changed files with 9 additions and 9 deletions

@ -46,8 +46,6 @@ using namespace Pausing;
using namespace df::enums; using namespace df::enums;
struct Configuration { struct Configuration {
bool debug = false;
bool unpause = false; bool unpause = false;
bool disengage = false; bool disengage = false;
bool animals = false; bool animals = false;
@ -86,12 +84,14 @@ namespace SP {
std::default_random_engine RNG; std::default_random_engine RNG;
void DebugUnitVector(std::vector<df::unit*> units) { void DebugUnitVector(std::vector<df::unit*> units) {
for (auto unit : units) { if (debug_plugin.isEnabled(DFHack::DebugCategory::LDEBUG)) {
INFO(plugin).print("[id: %d]\n animal: %d\n hostile: %d\n visiting: %d\n", for (auto unit: units) {
unit->id, DEBUG(plugin).print("[id: %d]\n animal: %d\n hostile: %d\n visiting: %d\n",
Units::isAnimal(unit), unit->id,
Units::isDanger(unit), Units::isAnimal(unit),
Units::isVisiting(unit)); Units::isDanger(unit),
Units::isVisiting(unit));
}
} }
} }
@ -306,7 +306,7 @@ namespace SP {
if (!at_least_one) { if (!at_least_one) {
return false; return false;
} }
//DebugUnitVector(units); DebugUnitVector(units);
std::piecewise_linear_distribution<> follow_any(i.begin(), i.end(), w.begin()); std::piecewise_linear_distribution<> follow_any(i.begin(), i.end(), w.begin());
// if you're looking at a warning about a local address escaping, it means the unit* from units (which aren't local) // if you're looking at a warning about a local address escaping, it means the unit* from units (which aren't local)
size_t idx = follow_any(RNG); size_t idx = follow_any(RNG);