MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / MinimapScreenCallback

Function MinimapScreenCallback

src/screenshot.cpp:473–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471
472
473static void MinimapScreenCallback(void *buf, uint y, uint pitch, uint n)
474{
475 uint32_t *ubuf = (uint32_t *)buf;
476 uint num = (pitch * n);
477 for (uint i = 0; i < num; i++) {
478 uint row = y + (int)(i / pitch);
479 uint col = (Map::SizeX() - 1) - (i % pitch);
480
481 TileIndex tile = TileXY(col, row);
482 uint8_t val = GetSmallMapOwnerPixels(tile, GetTileType(tile), IncludeHeightmap::Never) & 0xFF;
483
484 uint32_t colour_buf = 0;
485 colour_buf = (_cur_palette.palette[val].b << 0);
486 colour_buf |= (_cur_palette.palette[val].g << 8);
487 colour_buf |= (_cur_palette.palette[val].r << 16);
488
489 *ubuf = colour_buf;
490 ubuf++; // Skip alpha
491 }
492}
493
494/**
495 * Make a minimap screenshot.

Callers

nothing calls this directly

Calls 3

TileXYFunction · 0.85
GetSmallMapOwnerPixelsFunction · 0.85
GetTileTypeFunction · 0.85

Tested by

no test coverage detected