MCPcopy Create free account
hub / github.com/DFHack/dfhack / CopyBuilding

Function CopyBuilding

plugins/remotefortressreader/building_reader.cpp:289–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288
289void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * remote_build)
290{
291 df::building * local_build = df::global::world->buildings.all[buildingIndex];
292 remote_build->set_index(local_build->id);
293 int minZ = local_build->z;
294 if (local_build->getType() == df::enums::building_type::Well)
295 {
296 df::building_wellst * well_building = virtual_cast<df::building_wellst>(local_build);
297 if (well_building)
298 minZ = well_building->bucket_z;
299 }
300 remote_build->set_pos_x_min(local_build->x1);
301 remote_build->set_pos_y_min(local_build->y1);
302 remote_build->set_pos_z_min(minZ);
303
304 remote_build->set_pos_x_max(local_build->x2);
305 remote_build->set_pos_y_max(local_build->y2);
306 remote_build->set_pos_z_max(local_build->z);
307
308 auto buildingType = remote_build->mutable_building_type();
309 auto type = local_build->getType();
310 buildingType->set_building_type(type);
311 buildingType->set_building_subtype(local_build->getSubtype());
312 buildingType->set_building_custom(local_build->getCustomType());
313
314 auto material = remote_build->mutable_material();
315 material->set_mat_type(local_build->mat_type);
316 material->set_mat_index(local_build->mat_index);
317
318 remote_build->set_building_flags(local_build->flags.whole);
319 if (local_build->room.width > 0 && local_build->room.height > 0 && local_build->room.extents != nullptr)
320 {
321 auto room = remote_build->mutable_room();
322 room->set_pos_x(local_build->room.x);
323 room->set_pos_y(local_build->room.y);
324 room->set_width(local_build->room.width);
325 room->set_height(local_build->room.height);
326 for (int i = 0; i < (local_build->room.width * local_build->room.height); i++)
327 {
328 room->add_extents(local_build->room.extents[i]);
329 }
330 }
331
332 //Add building-specific info
333 switch (type)
334 {
335 case df::enums::building_type::NONE:
336 {
337 auto actual = virtual_cast<df::building_actual>(local_build);
338 if (actual)
339 {
340 }
341 break;
342 }
343 case df::enums::building_type::Chair:
344 {
345 auto actual = strict_virtual_cast<df::building_chairst>(local_build);
346 if (actual)

Callers 1

CopyBuildingsFunction · 0.85

Calls 3

getTypeMethod · 0.80
findFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected