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

Function getQuadrantOrCentreFromPos

src/OpenLoco/src/Map/MapSelection.cpp:220–232  ·  view source on GitHub ↗

0x0045FD8E NOTE: Original call getSurfaceLocFromUi within this function instead OpenLoco has split it in two. Also note that result of original was a Pos2 start i.e. (& 0xFFE0) both components

Source from the content-addressed store, hash-verified

218 // instead OpenLoco has split it in two. Also note that result of original
219 // was a Pos2 start i.e. (& 0xFFE0) both components
220 MapSelectionType getQuadrantOrCentreFromPos(const Pos2& loc)
221 {
222 // Determine to which quadrants the cursor is closest 4 == all quadrants
223 const auto xNibbleCentre = std::abs((loc.x & 0xFFE0) + 16 - loc.x);
224 const auto yNibbleCentre = std::abs((loc.y & 0xFFE0) + 16 - loc.y);
225 if (std::max(xNibbleCentre, yNibbleCentre) <= 7)
226 {
227 // Is centre so all quadrants
228 return MapSelectionType::full;
229 }
230
231 return getQuadrantFromPos(loc);
232 }
233
234 // 0x0045FE05
235 // NOTE: Original call getSurfaceLocFromUi within this function

Callers 1

Calls 1

getQuadrantFromPosFunction · 0.85

Tested by

no test coverage detected