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

Function autodump_main

plugins/autodump.cpp:75–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73);
74
75static command_result autodump_main(color_ostream &out, vector<string> &parameters)
76{ // Command line options.
77 bool destroy = false;
78 bool here = false;
79 bool need_visible = false;
80 bool need_hidden = false;
81 bool need_forbidden = false;
82 for (size_t i = 0; i < parameters.size(); i++)
83 {
84 string &p = parameters[i];
85 if(p == "destroy")
86 destroy = true;
87 else if (p == "destroy-here")
88 destroy = here = true;
89 else if (p == "visible")
90 need_visible = true;
91 else if (p == "hidden")
92 need_hidden = true;
93 else if (p == "forbidden")
94 need_forbidden = true;
95 else
96 return CR_WRONG_USAGE;
97 }
98
99 if (need_visible && need_hidden) {
100 out.printerr("An item can't be both hidden and visible.\n");
101 return CR_WRONG_USAGE;
102 }
103 else if (!Maps::IsValid()) {
104 out.printerr("Map is not available!\n");
105 return CR_FAILURE;
106 }
107
108 int dumped_total = 0;
109 bool make_projectile = false;
110
111 df::coord pos_cursor;
112 if(!destroy || here)
113 {
114 pos_cursor = Gui::getCursorPos();
115 if (!pos_cursor.isValid()) {
116 out.printerr("Keyboard cursor must be over a suitable map tile.\n");
117 return CR_FAILURE;
118 }
119 }
120
121 if (!destroy) {
122 auto ttype = Maps::getTileType(pos_cursor);
123 if(!ttype) {
124 out.printerr("Cursor is in an invalid/uninitialized area.\n");
125 return CR_FAILURE;
126 }
127 else if(!isWalkable(*ttype) && tileShape(*ttype) != tiletype_shape::FORTIFICATION)
128 { // Not floor, stair, ramp, nor fortification.
129 if (tileShapeBasic(tileShape(*ttype)) == tiletype_shape_basic::Wall) {
130 out.printerr("Can't dump inside walls.\n");
131 return CR_FAILURE;
132 }

Callers 2

df_autodumpFunction · 0.85
df_autodump_destroy_hereFunction · 0.85

Calls 7

getTileTypeFunction · 0.85
isWalkableFunction · 0.85
tileShapeFunction · 0.85
tileShapeBasicFunction · 0.85
sizeMethod · 0.45
isValidMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected