| 140 | } |
| 141 | |
| 142 | void DFHack::describeMaterial(BasicMaterialInfo *info, df::material *mat, |
| 143 | const BasicMaterialInfoMask *mask) |
| 144 | { |
| 145 | info->set_token(mat->id); |
| 146 | |
| 147 | if (mask && mask->flags()) |
| 148 | flagarray_to_ints(info->mutable_flags(), mat->flags); |
| 149 | |
| 150 | if (!mat->prefix.empty()) |
| 151 | info->set_name_prefix(mat->prefix); |
| 152 | |
| 153 | if (!mask || mask->states_size() == 0) |
| 154 | { |
| 155 | df::matter_state state = matter_state::Solid; |
| 156 | int temp = (mask && mask->has_temperature()) ? mask->temperature() : 10015; |
| 157 | |
| 158 | if (temp >= mat->heat.melting_point) |
| 159 | state = matter_state::Liquid; |
| 160 | if (temp >= mat->heat.boiling_point) |
| 161 | state = matter_state::Gas; |
| 162 | |
| 163 | info->add_state_color(mat->state_color[state]); |
| 164 | info->add_state_name(mat->state_name[state]); |
| 165 | info->add_state_adj(mat->state_adj[state]); |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | for (int i = 0; i < mask->states_size(); i++) |
| 170 | { |
| 171 | info->add_state_color(mat->state_color[i]); |
| 172 | info->add_state_name(mat->state_name[i]); |
| 173 | info->add_state_adj(mat->state_adj[i]); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (mask && mask->reaction()) |
| 178 | { |
| 179 | for (size_t i = 0; i < mat->reaction_class.size(); i++) |
| 180 | info->add_reaction_class(*mat->reaction_class[i]); |
| 181 | |
| 182 | for (size_t i = 0; i < mat->reaction_product.id.size(); i++) |
| 183 | { |
| 184 | auto ptr = info->add_reaction_product(); |
| 185 | ptr->set_id(*mat->reaction_product.id[i]); |
| 186 | ptr->set_type(mat->reaction_product.material.mat_type[i]); |
| 187 | ptr->set_index(mat->reaction_product.material.mat_index[i]); |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | void DFHack::describeMaterial(BasicMaterialInfo *info, const MaterialInfo &mat, |
| 193 | const BasicMaterialInfoMask *mask) |
nothing calls this directly
no test coverage detected