0x0046956E
| 36 | } |
| 37 | // 0x0046956E |
| 38 | void createWave(SurfaceElement& surface, const World::Pos2& pos) |
| 39 | { |
| 40 | const auto waveIndex = getWaveIndex(World::toTileSpace(pos)); |
| 41 | auto& wave = rawWaves()[waveIndex]; |
| 42 | if (!wave.empty()) |
| 43 | { |
| 44 | return; |
| 45 | } |
| 46 | auto vpPoint = gameToScreen(Pos3(pos.x + 16, pos.y + 16, surface.waterHeight()), WindowManager::getCurrentRotation()); |
| 47 | auto w = WindowManager::findWindowShowing(vpPoint); |
| 48 | if (w == nullptr) |
| 49 | { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | uint16_t dx2 = gPrng2().randNext() & 0xFFFF; |
| 54 | if (dx2 > 0x1745) |
| 55 | { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | // Check whether surrounding tiles are water |
| 60 | for (const auto& offset : _offsets) |
| 61 | { |
| 62 | auto searchLoc = pos + offset; |
| 63 | if (!World::validCoords(searchLoc)) |
| 64 | { |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const auto tile = TileManager::get(searchLoc); |
| 69 | if (tile.isNull()) |
| 70 | { |
| 71 | return; |
| 72 | } |
| 73 | const auto* nearbySurface = tile.surface(); |
| 74 | if (nearbySurface == nullptr) |
| 75 | { |
| 76 | return; |
| 77 | } |
| 78 | if (nearbySurface->water() == 0) |
| 79 | { |
| 80 | return; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | wave.loc = pos; |
| 85 | wave.frame = 0; |
| 86 | surface.setFlag6(true); |
| 87 | |
| 88 | ViewportManager::invalidate(pos, surface.waterHeight(), surface.waterHeight(), ZoomLevel::full); |
| 89 | } |
| 90 | |
| 91 | const Wave& getWave(const uint8_t waveIndex) |
| 92 | { |
no test coverage detected