| 73 | ); |
| 74 | |
| 75 | static command_result autodump_main(color_ostream &out, vector<string> ¶meters) |
| 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 | } |
no test coverage detected