autobutcher: fixed behaviour of keywords 'all' and 'new'. (didn't work properly with watch, unwatch and forget)

develop
Robert Heinrich 2012-04-09 18:36:01 +02:00
parent 64a7168b83
commit 37f3056fdd
1 changed files with 59 additions and 31 deletions

@ -2226,19 +2226,19 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
{ {
parameters.erase(parameters.begin()); parameters.erase(parameters.begin());
watch_race = true; watch_race = true;
out << "Start watching race(s)." << endl; out << "Start watching race(s): "; // << endl;
} }
else if(p == "unwatch") else if(p == "unwatch")
{ {
parameters.erase(parameters.begin()); parameters.erase(parameters.begin());
unwatch_race = true; unwatch_race = true;
out << "Stop watching race(s)." << endl; out << "Stop watching race(s): "; // << endl;
} }
else if(p == "forget") else if(p == "forget")
{ {
parameters.erase(parameters.begin()); parameters.erase(parameters.begin());
forget_race = true; forget_race = true;
out << "Removing race(s) from watchlist." << endl; out << "Removing race(s) from watchlist: "; // << endl;
} }
else if(p == "target") else if(p == "target")
{ {
@ -2261,7 +2261,7 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
ma >> target_ma; ma >> target_ma;
parameters.erase(parameters.begin(), parameters.begin()+5); parameters.erase(parameters.begin(), parameters.begin()+5);
change_target = true; change_target = true;
out << "Setting new target count for race(s):" << endl; out << "Setting new target count for race(s): "; // << endl;
} }
} }
else if(p == "autowatch") else if(p == "autowatch")
@ -2406,7 +2406,7 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
out << endl; out << endl;
} }
if(target_racenames.size() && target_racenames[0] == "all") if(change_target && target_racenames.size() && target_racenames[0] == "all")
{ {
out << "Setting target count for all races on watchlist." << endl; out << "Setting target count for all races on watchlist." << endl;
for(size_t i=0; i<watched_races.size(); i++) for(size_t i=0; i<watched_races.size(); i++)
@ -2421,6 +2421,8 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
} }
if(target_racenames.size() && (target_racenames[0] == "all" || target_racenames[0] == "new")) if(target_racenames.size() && (target_racenames[0] == "all" || target_racenames[0] == "new"))
{
if(change_target)
{ {
out << "Setting target count for the future." << endl; out << "Setting target count for the future." << endl;
default_fk = target_fk; default_fk = target_fk;
@ -2436,8 +2438,33 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
} }
return CR_OK; return CR_OK;
} }
else if(target_racenames[0] == "new")
{
out << "The only valid usage of 'new' is in combination when setting a target count!" << endl;
// hm, maybe instead of complaining start/stop autowatch instead? and get rid of the autowatch option?
if(unwatch_race)
out << "'unwatch new' makes no sense! Use 'noautowatch' instead." << endl;
else if(forget_race)
out << "'forget new' makes no sense, 'forget' is only for existing watchlist entries! Use 'noautowatch' instead." << endl;
else if(watch_race)
out << "'watch new' makes no sense! Use 'autowatch' instead." << endl;
return CR_WRONG_USAGE;
}
}
// map race names to ids if(target_racenames.size() && target_racenames[0] == "all")
{
// fill with race ids from watchlist
for(size_t i=0; i<watched_races.size(); i++)
{
WatchedRace * w = watched_races[i];
target_raceids.push_back(w->raceId);
}
}
else
{
// map race names from parameter list to ids
size_t num_races = df::global::world->raws.creatures.all.size(); size_t num_races = df::global::world->raws.creatures.all.size();
while(target_racenames.size()) while(target_racenames.size())
{ {
@ -2458,6 +2485,7 @@ command_result df_autobutcher(color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
} }
}
while(target_raceids.size()) while(target_raceids.size())
{ {