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

Function insertElement

src/OpenLoco/src/Map/TileManager.cpp:280–310  ·  view source on GitHub ↗

0x004616D6

Source from the content-addressed store, hash-verified

278
279 // 0x004616D6
280 TileElement* insertElement(ElementType type, const Pos2& pos, uint8_t baseZ, uint8_t occupiedQuads)
281 {
282 checkFreeElementsAndReorganise();
283
284 auto [source, dest] = insertElementPrepareDest(toTileSpace(pos));
285 if (source == nullptr)
286 {
287 return nullptr;
288 }
289
290 bool lastFound = false;
291 // Copy all of the elements that are underneath the new tile (or till end)
292 while (baseZ >= source->baseZ())
293 {
294 *dest = *source;
295 source->setBaseZ(0xFFU);
296 source++;
297 if (dest->isLast())
298 {
299 // The new element will become the last
300 // so we are clearing the flag
301 dest->setLastFlag(false);
302 dest++;
303 lastFound = true;
304 break;
305 }
306 dest++;
307 }
308
309 return insertElementEnd(type, baseZ, occupiedQuads, source, dest, lastFound);
310 }
311
312 // 0x0046166C
313 RoadElement* insertElementRoad(const Pos2& pos, uint8_t baseZ, uint8_t occupiedQuads)

Callers

nothing calls this directly

Calls 8

insertElementPrepareDestFunction · 0.85
toTileSpaceFunction · 0.85
insertElementEndFunction · 0.85
baseZMethod · 0.80
setBaseZMethod · 0.80
setLastFlagMethod · 0.80
isLastMethod · 0.45

Tested by

no test coverage detected