From 7b6b83bdcf0d1c9b4a7a18b25bfd2e6d371131c3 Mon Sep 17 00:00:00 2001 From: Japa Mala Illo Date: Sun, 28 Oct 2018 02:01:01 -0500 Subject: [PATCH] added a command to dump all trees in the map for debug. --- .vscode/settings.json | 6 + .../remotefortressreader.cpp | 258 +++++++++++++++++- 2 files changed, 257 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..e0ac3c845 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "vector": "cpp", + "fstream": "cpp" + } +} \ No newline at end of file diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index cd9837f6c..8c1c9c33a 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -255,6 +255,247 @@ command_result dump_bp_mods(color_ostream &out, vector & parameters) return CR_OK; } +command_result Dump_Trees(color_ostream &out, vector ¶meters) +{ + char filename[255]; + for(int columnIndex = 0; columnIndex < world->map.map_block_columns.size(); columnIndex++) + { + auto column = world->map.map_block_columns[columnIndex]; + if(!column) + continue; + if(column->plants.size() == 0) + continue; + for(int plantIndex = 0; plantIndex < column->plants.size(); plantIndex++) + { + auto plant = column->plants[plantIndex]; + if(!plant) + continue; + if(!plant->tree_info) + continue; + sprintf(filename, "plant_%03d,%03d,%03d.txt", plant->pos.z, plant->pos.y, plant->pos.x); + remove(filename); + ofstream output; + output.open(filename); + output << "Pos: " << plant->pos.x << ", " << plant->pos.y << ", " << plant->pos.z << endl; + output << "Material: " << plant->material << endl; + output << "Grow Counter: " << plant->grow_counter << endl; + output << "Damage Flags: "; + if(plant->damage_flags.bits.is_burning) + output << "is_burning, "; + if(plant->damage_flags.bits.is_drowning) + output << "is_drowning, "; + if(plant->damage_flags.bits.anon_1) + output << "anon_1, "; + output << endl; + output << "HP: " << plant->hitpoints << endl; + output << "Update Order: " << plant->update_order << endl; + output << "Site ID: " << plant->site_id << endl; + output << "SRB ID: " << plant->srb_id << endl; + auto treeInfo = plant->tree_info; + output << "Dim X: " << treeInfo->dim_x << endl; + output << "Dim Y: " << treeInfo->dim_y << endl; + output << "Dim Z: " << treeInfo->body_height << endl; + for(int z = 0; z < treeInfo->body_height; z++) + { + for(int y = -1; y < treeInfo->dim_y; y++) + { + for(int x = -1; x < treeInfo->dim_x; x++) + { + if(x < 0) + { + if(y < 0) + { + output << " "; + continue; + } + output << y%9; + continue; + } + if(y < 0) + { + output << x%9; + continue; + } + auto tile = treeInfo->body[z][x + treeInfo->dim_x*y]; + if(tile.bits.blocked) + output << "x"; + else if(tile.bits.twigs) + output << "░"; + else if(tile.bits.branches) + { + if(tile.bits.thick_branches_1) // East Connection + { + if(tile.bits.thick_branches_2) // South Connection + { + if(tile.bits.thick_branches_3) // West Connection + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╬"; + else + output << "┼"; + } + else + { + if(tile.bits.trunk) + output << "╦"; + else + output << "┬"; + } + } + else + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╠"; + else + output << "├"; + } + else + { + if(tile.bits.trunk) + output << "╔"; + else + output << "┌"; + } + } + } + else + { + if(tile.bits.thick_branches_3) // West Connection + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╩"; + else + output << "┴"; + } + else + { + if(tile.bits.trunk) + output << "═"; + else + output << "─"; + } + } + else + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╚"; + else + output << "└"; + } + else + { + if(tile.bits.trunk) + output << "╞"; + else + output << ">"; + } + } + } + } + else + { + if(tile.bits.thick_branches_2) // South Connection + { + if(tile.bits.thick_branches_3) // West Connection + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╣"; + else + output << "┤"; + } + else + { + if(tile.bits.trunk) + output << "╗"; + else + output << "┐"; + } + } + else + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "║"; + else + output << "│"; + } + else + { + if(tile.bits.trunk) + output << "╥"; + else + output << "v"; + } + } + } + else + { + if(tile.bits.thick_branches_3) // West Connection + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╝"; + else + output << "┘"; + } + else + { + if(tile.bits.trunk) + output << "╡"; + else + output << "<"; + } + } + else + { + if(tile.bits.thick_branches_4) // North Connection + { + if(tile.bits.trunk) + output << "╨"; + else + output << "^"; + } + else + { + if(tile.bits.trunk) + output << "o"; + else + output << "▒"; + } + } + } + } + } + else if(tile.bits.trunk) + output << "O"; + else if(tile.whole > 0) + output << +tile.whole; + else + output << " "; + } + output << endl; + } + output << endl; + } + //... + output.close(); + } + } + return CR_OK; +} + command_result RemoteFortressReader_version(color_ostream &out, vector ¶meters) { out.print(RFR_VERSION); @@ -271,12 +512,15 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector