diff options
| author | Robert Heinrich | 2012-04-04 16:48:22 +0200 |
|---|---|---|
| committer | Robert Heinrich | 2012-04-04 16:48:22 +0200 |
| commit | 796bc18fb07e3a44252dd7d56307ea453e3ed943 (patch) | |
| tree | af55ea0896adde219406edd6b0ea2dc336821284 /plugins/zone.cpp | |
| parent | b8421c4e1abe8eeb05ecb4908ed0e4f9d5318be3 (diff) | |
| download | dfhack-796bc18fb07e3a44252dd7d56307ea453e3ed943.tar.gz dfhack-796bc18fb07e3a44252dd7d56307ea453e3ed943.tar.bz2 dfhack-796bc18fb07e3a44252dd7d56307ea453e3ed943.tar.xz | |
zone plugin: fixed bug when parsing options
Diffstat (limited to 'plugins/zone.cpp')
| -rw-r--r-- | plugins/zone.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 657b2bd3..5e712510 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -1118,25 +1118,27 @@ 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) { - 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 <<std::endl; } } + if(target_zone == -1) + { + out.printerr("No zone id specified and current one is invalid!\n"); + return CR_WRONG_USAGE; + } else { - stringstream ss(parameters[i+1]); - i++; - ss >> target_zone; - out << "Assign selected unit to zone #" << target_zone <<std::endl; + out << "No zone id specified. Will try to use #" << target_zone << endl; zone_assign = true; } } @@ -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 |
