| 64 | |
| 65 | |
| 66 | void CopyImage(const df::art_image * image, ArtImage * netImage) |
| 67 | { |
| 68 | auto id = netImage->mutable_id(); |
| 69 | id->set_mat_type(image->id); |
| 70 | id->set_mat_index(image->subid); |
| 71 | for (size_t i = 0; i < image->elements.size(); i++) |
| 72 | { |
| 73 | auto element = image->elements[i]; |
| 74 | auto netElement = netImage->add_elements(); |
| 75 | auto elementType = element->getType(); |
| 76 | netElement->set_type((ArtImageElementType)elementType); |
| 77 | |
| 78 | netElement->set_count(element->count); |
| 79 | |
| 80 | switch (elementType) |
| 81 | { |
| 82 | case df::enums::art_image_element_type::CREATURE: |
| 83 | { |
| 84 | VIRTUAL_CAST_VAR(creature, df::art_image_element_creaturest, element); |
| 85 | auto cret = netElement->mutable_creature_item(); |
| 86 | cret->set_mat_type(creature->race); |
| 87 | cret->set_mat_index(creature->caste); |
| 88 | break; |
| 89 | } |
| 90 | case df::enums::art_image_element_type::PLANT: |
| 91 | { |
| 92 | VIRTUAL_CAST_VAR(plant, df::art_image_element_plantst, element); |
| 93 | netElement->set_id(plant->plant_id); |
| 94 | break; |
| 95 | } |
| 96 | case df::enums::art_image_element_type::TREE: |
| 97 | { |
| 98 | VIRTUAL_CAST_VAR(tree, df::art_image_element_treest, element); |
| 99 | netElement->set_id(tree->plant_id); |
| 100 | break; |
| 101 | } |
| 102 | case df::enums::art_image_element_type::SHAPE: |
| 103 | { |
| 104 | VIRTUAL_CAST_VAR(shape, df::art_image_element_shapest, element); |
| 105 | netElement->set_id(shape->shape_id); |
| 106 | break; |
| 107 | } |
| 108 | case df::enums::art_image_element_type::ITEM: |
| 109 | { |
| 110 | VIRTUAL_CAST_VAR(item, df::art_image_element_itemst, element); |
| 111 | auto it = netElement->mutable_creature_item(); |
| 112 | it->set_mat_type(item->item_type); |
| 113 | it->set_mat_index(item->item_subtype); |
| 114 | netElement->set_id(item->item_id); |
| 115 | switch (item->item_type) |
| 116 | { |
| 117 | case item_type::PLANT: |
| 118 | it->set_mat_index(item->mat_index); |
| 119 | default: |
| 120 | break; |
| 121 | } |
| 122 | auto mat = netElement->mutable_material(); |
| 123 | mat->set_mat_type(item->mat_type); |
no test coverage detected