| 3256 | } |
| 3257 | |
| 3258 | void SyncInitPlrPos(Player &player) |
| 3259 | { |
| 3260 | if (!player.isOnActiveLevel()) |
| 3261 | return; |
| 3262 | |
| 3263 | const WorldTileDisplacement offset[9] = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 }, { 2, 0 }, { 0, 2 }, { 1, 2 }, { 2, 1 }, { 2, 2 } }; |
| 3264 | |
| 3265 | Point position = [&]() { |
| 3266 | for (int i = 0; i < 8; i++) { |
| 3267 | Point position = player.position.tile + offset[i]; |
| 3268 | if (PosOkPlayer(player, position)) |
| 3269 | return position; |
| 3270 | } |
| 3271 | |
| 3272 | std::optional<Point> nearPosition = FindClosestValidPosition( |
| 3273 | [&player](Point testPosition) { |
| 3274 | for (int i = 0; i < numtrigs; i++) { |
| 3275 | if (trigs[i].position == testPosition) |
| 3276 | return false; |
| 3277 | } |
| 3278 | return PosOkPlayer(player, testPosition) && !PosOkPortal(currlevel, testPosition); |
| 3279 | }, |
| 3280 | player.position.tile, |
| 3281 | 1, // skip the starting tile since that was checked in the previous loop |
| 3282 | 50); |
| 3283 | |
| 3284 | return nearPosition.value_or(Point { 0, 0 }); |
| 3285 | }(); |
| 3286 | |
| 3287 | player.position.tile = position; |
| 3288 | dPlayer[position.x][position.y] = player.getId() + 1; |
| 3289 | player.position.future = position; |
| 3290 | |
| 3291 | if (&player == MyPlayer) { |
| 3292 | ViewPosition = position; |
| 3293 | } |
| 3294 | } |
| 3295 | |
| 3296 | void SyncInitPlr(Player &player) |
| 3297 | { |
no test coverage detected