From 95223d819761c09b8290be1cb61fc65a015aec6d Mon Sep 17 00:00:00 2001 From: Rose Date: Sat, 7 Jan 2023 14:37:44 -0800 Subject: [PATCH] Got archery target direction back, and cleaned up a few things. --- library/xml | 2 +- .../remotefortressreader/building_reader.cpp | 49 +++++++++---------- .../remotefortressreader.cpp | 25 ---------- 3 files changed, 24 insertions(+), 52 deletions(-) diff --git a/library/xml b/library/xml index d026f34ed..d7de31978 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit d026f34ed1f7ab79aebb1c5bc8a36ee9b30bd13d +Subproject commit d7de31978634d6bd165069e5fcaffc64a0d4a91c diff --git a/plugins/remotefortressreader/building_reader.cpp b/plugins/remotefortressreader/building_reader.cpp index 5a0595eef..e1f29e358 100644 --- a/plugins/remotefortressreader/building_reader.cpp +++ b/plugins/remotefortressreader/building_reader.cpp @@ -316,8 +316,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re material->set_mat_index(local_build->mat_index); remote_build->set_building_flags(local_build->flags.whole); - //FIXME: Figure out what to replace this with. - //remote_build->set_is_room(local_build->is_room); if (local_build->room.width > 0 && local_build->room.height > 0 && local_build->room.extents != nullptr) { auto room = remote_build->mutable_room(); @@ -609,28 +607,29 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re case df::enums::building_type::ArcheryTarget: { //FIXME: Need to decode archery targets again. - //auto actual = strict_virtual_cast(local_build); - //if (actual) - //{ - // auto facing = actual->archery_direction; - // switch (facing) - // { - // case df::building_archerytargetst::TopToBottom: - // remote_build->set_direction(NORTH); - // break; - // case df::building_archerytargetst::BottomToTop: - // remote_build->set_direction(SOUTH); - // break; - // case df::building_archerytargetst::LeftToRight: - // remote_build->set_direction(WEST); - // break; - // case df::building_archerytargetst::RightToLeft: - // remote_build->set_direction(EAST); - // break; - // default: - // break; - // } - //} + auto actual = strict_virtual_cast(local_build); + if (actual) + { + for (size_t i = 0; i < actual->relations.size(); i++) + { + if (actual->relations[i]->getType() != df::enums::building_type::Civzone) + continue; + auto zone = strict_virtual_cast(actual->relations[i]); + if (!zone) + continue; + if (zone->type != df::civzone_type::ArcheryRange) + continue; + if(zone->dir_x < 0) + remote_build->set_direction(EAST); + else if(zone->dir_x > 0) + remote_build->set_direction(WEST); + else if (zone->dir_y < 0) + remote_build->set_direction(SOUTH); + else if (zone->dir_y > 0) + remote_build->set_direction(NORTH); + break; + } + } break; } case df::enums::building_type::Chain: @@ -851,7 +850,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re auto actual = strict_virtual_cast(local_build); if (actual) { -#if DF_VERSION_INT > 34011 if (actual->orient_x < 0) remote_build->set_direction(WEST); else if (actual->orient_x > 0) @@ -861,7 +859,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re else if (actual->orient_y > 0) remote_build->set_direction(SOUTH); else -#endif remote_build->set_direction(WEST); if (actual->machine.machine_id >= 0) { diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index c4e5b99de..d1a269d52 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -859,31 +859,6 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage } } } - //for (size_t i = 0; i < history->figures.size(); i++) - //{ - // df::historical_figure * figure = history->figures[i]; - // if (figure->race < 0) - // continue; - // df::creature_raw * creature = raws->creatures.all[figure->race]; - // for (int j = 0; j < creature->material.size(); j++) - // { - // mat.decode(j + MaterialInfo::FIGURE_BASE, i); - // MaterialDefinition *mat_def = out->add_material_list(); - // mat_def->mutable_mat_pair()->set_mat_type(j + MaterialInfo::FIGURE_BASE); - // mat_def->mutable_mat_pair()->set_mat_index(i); - // stringstream id; - // id << "HF" << i << mat.getToken(); - // mat_def->set_id(id.str()); - // mat_def->set_name(mat.toString()); //find the name at cave temperature; - // if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->descriptors.colors.size()) - // { - // df::descriptor_color *color = raws->descriptors.colors[creature->material[j]->state_color[GetState(creature->material[j])]]; - // mat_def->mutable_state_color()->set_red(color->red * 255); - // mat_def->mutable_state_color()->set_green(color->green * 255); - // mat_def->mutable_state_color()->set_blue(color->blue * 255); - // } - // } - //} for (size_t i = 0; i < raws->plants.all.size(); i++) { df::plant_raw * plant = raws->plants.all[i];