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

Function Copyspatters

plugins/remotefortressreader/remotefortressreader.cpp:1265–1317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263}
1264
1265void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
1266{
1267 NetBlock->set_map_x(DfBlock->map_pos.x);
1268 NetBlock->set_map_y(DfBlock->map_pos.y);
1269 NetBlock->set_map_z(DfBlock->map_pos.z);
1270 std::vector<df::block_square_event_material_spatterst *> materials;
1271#if DF_VERSION_INT > 34011
1272 std::vector<df::block_square_event_item_spatterst *> items;
1273 std::vector<df::block_square_event_grassst *> grasses;
1274 if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, &grasses, NULL, NULL, &items))
1275 return;
1276#else
1277 if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, NULL, NULL))
1278 return;
1279#endif
1280 for (int yy = 0; yy < 16; yy++)
1281 for (int xx = 0; xx < 16; xx++)
1282 {
1283 auto send_pile = NetBlock->add_spatterpile();
1284 for (size_t i = 0; i < materials.size(); i++)
1285 {
1286 auto mat = materials[i];
1287 if (mat->amount[xx][yy] == 0)
1288 continue;
1289 auto send_spat = send_pile->add_spatters();
1290 send_spat->set_state((MatterState)mat->mat_state);
1291 CopyMat(send_spat->mutable_material(), mat->mat_type, mat->mat_index);
1292 send_spat->set_amount(mat->amount[xx][yy]);
1293 }
1294#if DF_VERSION_INT > 34011
1295 for (size_t i = 0; i < items.size(); i++)
1296 {
1297 auto item = items[i];
1298 if (item->amount[xx][yy] == 0)
1299 continue;
1300 auto send_spat = send_pile->add_spatters();
1301 CopyMat(send_spat->mutable_material(), item->mattype, item->matindex);
1302 send_spat->set_amount(item->amount[xx][yy]);
1303 auto send_item = send_spat->mutable_item();
1304 send_item->set_mat_type(item->item_type);
1305 send_item->set_mat_index(item->item_subtype);
1306 }
1307 int grassPercent = 0;
1308 for (size_t i = 0; i < grasses.size(); i++)
1309 {
1310 auto grass = grasses[i];
1311 if (grass->amount[xx][yy] > grassPercent)
1312 grassPercent = grass->amount[xx][yy];
1313 }
1314 NetBlock->add_grass_percent(grassPercent);
1315#endif
1316 }
1317}
1318
1319void CopyItems(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
1320{

Callers 1

GetBlockListFunction · 0.85

Calls 2

CopyMatFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected