MCPcopy Create free account
hub / github.com/DFHack/dfhack / parseRectangle

Function parseRectangle

plugins/Brushes.h:211–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209};
210
211DFHack::command_result parseRectangle(DFHack::color_ostream & out,
212 vector<string> & input, int start, int end,
213 int & width, int & height, int & zLevels,
214 bool hasConsole = true)
215{
216 using namespace DFHack;
217 int newWidth = 0, newHeight = 0, newZLevels = 0, rv = 0;
218
219 if (end > start + 1)
220 {
221 newWidth = atoi(input[start++].c_str());
222 newHeight = atoi(input[start++].c_str());
223 if (end > start) {
224 newZLevels = atoi(input[start++].c_str());
225 } else {
226 newZLevels = 1; // So 'range w h' won't ask for it.
227 }
228 }
229
230 string command = "";
231 std::stringstream str;
232 CommandHistory hist;
233
234 if (newWidth < 1) {
235 if (hasConsole) {
236 Console &con = static_cast<Console&>(out);
237
238 str.str("");
239 str << "Set range width <" << width << "> ";
240 while ((rv = con.lineedit(str.str(), command, hist))
241 == Console::RETRY);
242 if (rv <= Console::FAILURE)
243 return rv == Console::FAILURE ? CR_FAILURE : CR_FAILURE;
244 hist.add(command);
245 newWidth = command.empty() ? width : atoi(command.c_str());
246 } else {
247 return CR_WRONG_USAGE;
248 }
249 }
250
251 if (newHeight < 1) {
252 if (hasConsole) {
253 Console &con = static_cast<Console&>(out);
254
255 str.str("");
256 str << "Set range height <" << height << "> ";
257 while ((rv = con.lineedit(str.str(), command, hist))
258 == Console::RETRY);
259 if (rv <= Console::FAILURE)
260 return rv == Console::FAILURE ? CR_FAILURE : CR_OK;
261 hist.add(command);
262 newHeight = command.empty() ? height : atoi(command.c_str());
263 } else {
264 return CR_WRONG_USAGE;
265 }
266 }
267
268 if (newZLevels < 1) {

Callers 2

df_liquidsFunction · 0.85
processCommandFunction · 0.85

Calls 5

c_strMethod · 0.80
strMethod · 0.45
lineeditMethod · 0.45
addMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected