zone plugin: fixed bug when parsing options

develop
Robert Heinrich 2012-04-04 16:48:22 +02:00
parent b8421c4e1a
commit 796bc18fb0
2 changed files with 20 additions and 16 deletions

@ -845,8 +845,10 @@ Usage with filters
------------------
All filters can be used together with the 'assign' command. The only restriction is that it's not possible to assign units who are inside built cages or chained because in most cases that won't be desirable anyways. Usually you should always use the filter 'own' (which implies tame) unless you want to use the zone tool for pitting hostiles. 'own' ignores own dwarves unless you specify 'race DWARF' (so it's safe to use 'assign all own' to one big pasture if you want to have all your animals at the same place). 'egglayer' and 'milkable' should be used together with 'female' unless you have a mod with egg-laying male elves who give milk or whatever.
``zone assign all own grazer maxage 10``
Assign all own grazers who are up to 10 years old to the selected pasture.
``zone assign all own ALPACA minage 3 maxage 10``
Assign all own alpacas who are between 3 and 10 years old to the selected pasture.
``zone assign all own caged grazer``
Assign all own grazers who are sitting in cages on stockpiles (e.g. after buying them from merchants) to the selected pasture.
``zone assign count 5 own female milkable``
Assign up to 5 own female milkable creatures to the selected pasture.
``zone assign all own race DWARF maxage 2``

@ -1118,11 +1118,22 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
}
else if(p == "assign")
{
if(i == parameters.size()-1)
// if followed by another parameter, check if it's numeric
if(i < parameters.size()-1)
{
stringstream ss(parameters[i+1]);
int new_zone = -1;
ss >> new_zone;
if(new_zone != -1)
{
i++;
target_zone = new_zone;
out << "Assign selected unit(s) to zone #" << target_zone <<std::endl;
}
}
if(target_zone == -1)
{
out.printerr("No zone id specified and current one is invalid!");
out.printerr("No zone id specified and current one is invalid!\n");
return CR_WRONG_USAGE;
}
else
@ -1131,15 +1142,6 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
zone_assign = true;
}
}
else
{
stringstream ss(parameters[i+1]);
i++;
ss >> target_zone;
out << "Assign selected unit to zone #" << target_zone <<std::endl;
zone_assign = true;
}
}
else if(p == "race")
{
if(i == parameters.size()-1)
@ -1291,13 +1293,13 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
{
find_milkable = true;
}
else if(p == "set")
{
zone_set = true;
}
else if(p == "all")
{
out << "Filter: all" << endl;
all = true;
}
else