| 623 | static std::array<Vehicle *, 1 << (GEN_HASHX_BITS + GEN_HASHY_BITS)> _vehicle_viewport_hash{}; |
| 624 | |
| 625 | static void UpdateVehicleViewportHash(Vehicle *v, int x, int y, int old_x, int old_y) |
| 626 | { |
| 627 | Vehicle **old_hash, **new_hash; |
| 628 | |
| 629 | new_hash = (x == INVALID_COORD) ? nullptr : &_vehicle_viewport_hash[GetViewportHash(x, y)]; |
| 630 | old_hash = (old_x == INVALID_COORD) ? nullptr : &_vehicle_viewport_hash[GetViewportHash(old_x, old_y)]; |
| 631 | |
| 632 | if (old_hash == new_hash) return; |
| 633 | |
| 634 | /* remove from hash table? */ |
| 635 | if (old_hash != nullptr) { |
| 636 | if (v->hash_viewport_next != nullptr) v->hash_viewport_next->hash_viewport_prev = v->hash_viewport_prev; |
| 637 | *v->hash_viewport_prev = v->hash_viewport_next; |
| 638 | } |
| 639 | |
| 640 | /* insert into hash table? */ |
| 641 | if (new_hash != nullptr) { |
| 642 | v->hash_viewport_next = *new_hash; |
| 643 | if (v->hash_viewport_next != nullptr) v->hash_viewport_next->hash_viewport_prev = &v->hash_viewport_next; |
| 644 | v->hash_viewport_prev = new_hash; |
| 645 | *new_hash = v; |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | void ResetVehicleHash() |
| 650 | { |
no test coverage detected