From 796bc18fb07e3a44252dd7d56307ea453e3ed943 Mon Sep 17 00:00:00 2001 From: Robert Heinrich Date: Wed, 4 Apr 2012 16:48:22 +0200 Subject: [PATCH] zone plugin: fixed bug when parsing options --- README.rst | 6 ++++-- plugins/zone.cpp | 30 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index 8c450e287..4ede446bb 100644 --- a/README.rst +++ b/README.rst @@ -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`` diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 657b2bd3e..5e712510c 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -1118,25 +1118,27 @@ command_result df_zone (color_ostream &out, vector & 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) { - if(target_zone == -1) - { - out.printerr("No zone id specified and current one is invalid!"); - return CR_WRONG_USAGE; - } - else + stringstream ss(parameters[i+1]); + int new_zone = -1; + ss >> new_zone; + if(new_zone != -1) { - out << "No zone id specified. Will try to use #" << target_zone << endl; - zone_assign = true; + i++; + target_zone = new_zone; + out << "Assign selected unit(s) to zone #" << target_zone <> target_zone; - out << "Assign selected unit to zone #" << target_zone < & parameters) { find_milkable = true; } - else if(p == "set") { zone_set = true; } else if(p == "all") { + out << "Filter: all" << endl; all = true; } else