autofarm.cpp: whitespace, complexity

Clean up autofarm.cpp
develop
Kelly Kinkade 2019-11-21 18:58:06 -06:00
parent ef703873c8
commit dfafafdf9b
1 changed files with 32 additions and 32 deletions

@ -50,7 +50,6 @@ const char *usage = (
); );
class AutoFarm { class AutoFarm {
private: private:
map<int, int> thresholds; map<int, int> thresholds;
int defaultThreshold = 50; int defaultThreshold = 50;
@ -85,7 +84,6 @@ private:
const df::plant_raw_flags seasons[4] = { df::plant_raw_flags::SPRING, df::plant_raw_flags::SUMMER, df::plant_raw_flags::AUTUMN, df::plant_raw_flags::WINTER }; const df::plant_raw_flags seasons[4] = { df::plant_raw_flags::SPRING, df::plant_raw_flags::SUMMER, df::plant_raw_flags::AUTUMN, df::plant_raw_flags::WINTER };
public: public:
bool is_plantable(df::plant_raw* plant) bool is_plantable(df::plant_raw* plant)
{ {
bool has_seed = plant->flags.is_set(df::plant_raw_flags::SEED); bool has_seed = plant->flags.is_set(df::plant_raw_flags::SEED);
@ -182,7 +180,6 @@ public:
df::item_plantst* i = (df::item_plantst*)ii; df::item_plantst* i = (df::item_plantst*)ii;
if ((i->flags.whole & bad_flags.whole) == 0) if ((i->flags.whole & bad_flags.whole) == 0)
counts[i->mat_index] += i->stack_size; counts[i->mat_index] += i->stack_size;
} }
for (auto ci : counts) for (auto ci : counts)
@ -333,7 +330,6 @@ public:
} }
out << "Default: " << defaultThreshold << endl; out << "Default: " << defaultThreshold << endl;
} }
}; };
static AutoFarm* autofarmInstance; static AutoFarm* autofarmInstance;
@ -387,19 +383,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
return CR_OK; return CR_OK;
} }
static command_result autofarm(color_ostream &out, vector <string> & parameters) static command_result setThresholds(color_ostream& out, vector<string> & parameters)
{
CoreSuspender suspend;
if (parameters.size() == 1 && parameters[0] == "runonce")
autofarmInstance->process(out);
else if (parameters.size() == 1 && parameters[0] == "enable")
plugin_enable(out, true);
else if (parameters.size() == 1 && parameters[0] == "disable")
plugin_enable(out, false);
else if (parameters.size() == 2 && parameters[0] == "default")
autofarmInstance->setDefault(atoi(parameters[1].c_str()));
else if (parameters.size() >= 3 && parameters[0] == "threshold")
{ {
int val = atoi(parameters[1].c_str()); int val = atoi(parameters[1].c_str());
for (int i = 2; i < parameters.size(); i++) for (int i = 2; i < parameters.size(); i++)
@ -423,7 +407,23 @@ static command_result autofarm(color_ostream &out, vector <string> & parameters)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
} }
return CR_OK;
} }
static command_result autofarm(color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;
if (parameters.size() == 1 && parameters[0] == "runonce")
autofarmInstance->process(out);
else if (parameters.size() == 1 && parameters[0] == "enable")
plugin_enable(out, true);
else if (parameters.size() == 1 && parameters[0] == "disable")
plugin_enable(out, false);
else if (parameters.size() == 2 && parameters[0] == "default")
autofarmInstance->setDefault(atoi(parameters[1].c_str()));
else if (parameters.size() >= 3 && parameters[0] == "threshold")
return setThresholds(out, parameters);
else if (parameters.size() == 0 || parameters.size() == 1 && parameters[0] == "status") else if (parameters.size() == 0 || parameters.size() == 1 && parameters[0] == "status")
autofarmInstance->status(out); autofarmInstance->status(out);
else else