| 93 | } |
| 94 | |
| 95 | static command_result df_probe(color_ostream &out, vector<string> & parameters) { |
| 96 | |
| 97 | auto& inorganic = world->raws.inorganics.all; |
| 98 | |
| 99 | if (!Maps::IsValid()) { |
| 100 | out.printerr("Map is not available!\n"); |
| 101 | return CR_FAILURE; |
| 102 | } |
| 103 | |
| 104 | MapExtras::MapCache mc; |
| 105 | |
| 106 | int32_t regionX, regionY, regionZ; |
| 107 | Maps::getPosition(regionX,regionY,regionZ); |
| 108 | |
| 109 | df::coord cursor; |
| 110 | |
| 111 | if (parameters.size()) |
| 112 | Lua::CallLuaModuleFunction(out, "plugins.probe", "parse_commandline", parameters, |
| 113 | 1, [&](lua_State *L){ |
| 114 | if (!lua_isnil(L, -1)) |
| 115 | Lua::CheckDFAssign(L, &cursor, -1); |
| 116 | }); |
| 117 | |
| 118 | if (!Maps::isValidTilePos(cursor)) { |
| 119 | if (!Gui::getCursorCoords(cursor)) { |
| 120 | out.printerr("No cursor; place cursor over tile to probe.\n"); |
| 121 | return CR_FAILURE; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | uint32_t blockX = cursor.x / 16; |
| 126 | uint32_t tileX = cursor.x % 16; |
| 127 | uint32_t blockY = cursor.y / 16; |
| 128 | uint32_t tileY = cursor.y % 16; |
| 129 | |
| 130 | MapExtras::Block * b = mc.BlockAt(cursor/16); |
| 131 | if (!b || !b->is_valid()) { |
| 132 | out.printerr("No data.\n"); |
| 133 | return CR_OK; |
| 134 | } |
| 135 | |
| 136 | auto &block = *b->getRaw(); |
| 137 | out.print("block addr: {}\n\n", static_cast<void*>(&block)); |
| 138 | |
| 139 | df::tiletype tiletype = mc.tiletypeAt(cursor); |
| 140 | df::tile_designation &des = block.designation[tileX][tileY]; |
| 141 | df::tile_occupancy &occ = block.occupancy[tileX][tileY]; |
| 142 | uint8_t fog_of_war = block.fog_of_war[tileX][tileY]; |
| 143 | |
| 144 | out.print("tiletype: "); |
| 145 | describeTile(out, tiletype); |
| 146 | out.print("static: "); |
| 147 | describeTile(out, mc.staticTiletypeAt(cursor)); |
| 148 | out.print("base: "); |
| 149 | describeTile(out, mc.baseTiletypeAt(cursor)); |
| 150 | |
| 151 | out.print("temperature1: {} U\n", mc.temperature1At(cursor)); |
| 152 | out.print("temperature2: {} U\n", mc.temperature2At(cursor)); |
nothing calls this directly
no test coverage detected