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. 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`` ``zone assign all own ALPACA minage 3 maxage 10``
Assign all own grazers who are up to 10 years old to the selected pasture. 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`` ``zone assign count 5 own female milkable``
Assign up to 5 own female milkable creatures to the selected pasture. Assign up to 5 own female milkable creatures to the selected pasture.
``zone assign all own race DWARF maxage 2`` ``zone assign all own race DWARF maxage 2``

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