| 278 | } |
| 279 | |
| 280 | void UpdateViewport(bool scroll) |
| 281 | { |
| 282 | int32_t playerIndex = Network::GetPlayerIndex(static_cast<uint8_t>(number)); |
| 283 | if (playerIndex == -1) |
| 284 | { |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | if (viewport != nullptr) |
| 289 | { |
| 290 | auto coord = Network::GetPlayerLastActionCoord(playerIndex); |
| 291 | if (coord.x != 0 || coord.y != 0 || coord.z != 0) |
| 292 | { |
| 293 | auto centreLoc = centre2dCoordinates(coord, viewport); |
| 294 | if (!centreLoc.has_value()) |
| 295 | { |
| 296 | return; |
| 297 | } |
| 298 | // Don't scroll if the view was originally undefined |
| 299 | if (!_drawViewport) |
| 300 | { |
| 301 | scroll = false; |
| 302 | } |
| 303 | |
| 304 | if (!scroll || savedViewPos != centreLoc.value()) |
| 305 | { |
| 306 | flags |= WindowFlag::scrollingToLocation; |
| 307 | savedViewPos = centreLoc.value(); |
| 308 | if (!scroll) |
| 309 | { |
| 310 | viewport->viewPos = centreLoc.value(); |
| 311 | } |
| 312 | invalidateWidget(WIDX_VIEWPORT); |
| 313 | } |
| 314 | |
| 315 | // Draw the viewport |
| 316 | _drawViewport = true; |
| 317 | } |
| 318 | else |
| 319 | { |
| 320 | // Don't draw the viewport |
| 321 | _drawViewport = false; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | void UpdateTitle() |
| 327 | { |
nothing calls this directly
no test coverage detected