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

Method init_item_counts

library/modules/MapCache.cpp:1155–1176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1153}
1154
1155void MapExtras::Block::init_item_counts()
1156{
1157 if (item_counts) return;
1158
1159 item_counts = new T_item_counts[16];
1160 memset(item_counts, 0, sizeof(T_item_counts)*16);
1161
1162 if (!block) return;
1163
1164 for (size_t i = 0; i < block->items.size(); i++)
1165 {
1166 auto it = df::item::find(block->items[i]);
1167 if (!it || !it->flags.bits.on_ground)
1168 continue;
1169
1170 df::coord tidx = it->pos - block->map_pos;
1171 if (!is_valid_tile_coord(tidx) || tidx.z != 0)
1172 continue;
1173
1174 item_counts[tidx.x][tidx.y]++;
1175 }
1176}
1177
1178bool MapExtras::Block::addItemOnGround(df::item *item)
1179{

Callers

nothing calls this directly

Calls 3

is_valid_tile_coordFunction · 0.85
findFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected