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

Function doGetTile_map

library/modules/Screen.cpp:243–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243static Pen doGetTile_map(int x, int y, int32_t * df::graphic_viewportst::*texpos_field) {
244 auto &vp = gps->main_viewport;
245
246 if (x < 0 || x >= vp->dim_x || y < 0 || y >= vp->dim_y)
247 return Pen(0, 0, 0, -1);
248
249 size_t max_index = vp->dim_x * vp->dim_y - 1;
250 size_t index = (x * vp->dim_y) + y;
251
252 if (index < 0 || index > max_index)
253 return Pen(0, 0, 0, -1);
254
255 int tile = 0;
256 if (!texpos_field) {
257 tile = vp->screentexpos_interface[index];
258 if (tile == 0)
259 tile = vp->screentexpos[index];
260 if (tile == 0)
261 tile = vp->screentexpos_item[index];
262 if (tile == 0)
263 tile = vp->screentexpos_building_one[index];
264 if (tile == 0)
265 tile = vp->screentexpos_background_two[index];
266 if (tile == 0)
267 tile = vp->screentexpos_background[index];
268 } else {
269 tile = (vp->*texpos_field)[index];
270 }
271
272 char ch = 0;
273 uint8_t fg = 0;
274 uint8_t bg = 0;
275 return Pen(ch, fg, bg, tile, false);
276}
277
278static uint8_t to_16_bit_color(uint8_t *rgb) {
279 for (uint8_t c = 0; c < 16; ++c) {

Callers 1

doGetTile_defaultFunction · 0.85

Calls 1

PenClass · 0.50

Tested by

no test coverage detected