MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / setMapPixelsOverall

Function setMapPixelsOverall

src/OpenLoco/src/Ui/Windows/MapWindow.cpp:245–431  ·  view source on GitHub ↗

0x0046C5E5

Source from the content-addressed store, hash-verified

243
244 // 0x0046C5E5
245 static void setMapPixelsOverall(PaletteIndex_t* mapPtr, PaletteIndex_t* mapAltPtr, Pos2 pos, Pos2 delta)
246 {
247 for (auto rowCountLeft = kMapColumns; rowCountLeft > 0; rowCountLeft--)
248 {
249 // Coords shouldn't be at map edge
250 if (!(pos.x > 0 && pos.y > 0 && pos.x < kMapWidth - kTileSize && pos.y < kMapHeight - kTileSize))
251 {
252 pos += delta;
253 mapPtr += kRenderedMapWidth + 1;
254 mapAltPtr += kRenderedMapWidth + 1;
255 continue;
256 }
257
258 PaletteIndex_t colourFlash0{}, colourFlash1{}, colour0{}, colour1{};
259 auto tile = TileManager::get(pos);
260 for (auto& el : tile)
261 {
262 switch (el.type())
263 {
264 case ElementType::surface:
265 {
266 auto* surfaceEl = el.as<SurfaceElement>();
267 if (surfaceEl == nullptr)
268 {
269 continue;
270 }
271
272 if (surfaceEl->water() == 0)
273 {
274 const auto* landObj = ObjectManager::get<LandObject>(surfaceEl->terrain());
275 const auto* landImage = Gfx::getG1Element(landObj->mapPixelImage);
276 auto offset = surfaceEl->baseZ() / kMicroToSmallZStep * 2;
277 colourFlash0 = landImage->offset[offset];
278 colourFlash1 = landImage->offset[offset + 1];
279 }
280 else
281 {
282 const auto* waterObj = ObjectManager::get<WaterObject>();
283 const auto* waterImage = Gfx::getG1Element(waterObj->mapPixelImage);
284 auto offset = (surfaceEl->water() * kMicroToSmallZStep - surfaceEl->baseZ()) / 2;
285 colourFlash0 = waterImage->offset[offset - 2];
286 colourFlash1 = waterImage->offset[offset - 1];
287 }
288
289 colour0 = colourFlash0;
290 colour1 = colourFlash1;
291 break;
292 }
293
294 case ElementType::track:
295 if (!el.isGhost() && !el.isAiAllocated())
296 {
297 auto* trackEl = el.as<TrackElement>();
298 if (trackEl == nullptr)
299 {
300 continue;
301 }
302

Callers 1

setMapPixelsFunction · 0.85

Calls 11

getG1ElementFunction · 0.85
typeMethod · 0.80
waterMethod · 0.80
terrainMethod · 0.80
baseZMethod · 0.80
isAiAllocatedMethod · 0.80
trackObjectIdMethod · 0.80
roadObjectIdMethod · 0.80
getFunction · 0.50
isGhostMethod · 0.45
hasFlagsMethod · 0.45

Tested by

no test coverage detected