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

Function calculateNextPosition

src/OpenLoco/src/Vehicles/VehicleHead.cpp:1282–1292  ·  view source on GitHub ↗

Returns veh1, veh2 position

Source from the content-addressed store, hash-verified

1280
1281 // Returns veh1, veh2 position
1282 static std::pair<Pos2, Pos2> calculateNextPosition(const uint8_t yaw, const World::Pos2& curPos, const Vehicle1* veh1, const Speed32 speed)
1283 {
1284 auto dist = Math::Trigonometry::computeXYVector(speed.getRaw() >> 5, yaw);
1285
1286 auto bigCoordX = veh1->var_4E + (curPos.x << 16) + dist.x;
1287 auto bigCoordY = veh1->var_50 + (curPos.y << 16) + dist.y;
1288
1289 Pos2 veh1Pos = { static_cast<int16_t>(bigCoordX & 0xFFFF), static_cast<int16_t>(bigCoordY & 0xFFFF) };
1290 Pos2 veh2Pos = { static_cast<int16_t>(bigCoordX >> 16), static_cast<int16_t>(bigCoordY >> 16) };
1291 return std::make_pair(veh1Pos, veh2Pos);
1292 }
1293
1294 // 0x004A8C11
1295 bool VehicleHead::updateLand()

Callers 2

updateWaterMotionMethod · 0.85

Calls 2

computeXYVectorFunction · 0.85
getRawMethod · 0.45

Tested by

no test coverage detected