| 1775 | } |
| 1776 | |
| 1777 | void WorldClient::initWorld(WorldStartPacket const& startPacket) { |
| 1778 | clearWorld(); |
| 1779 | m_outgoingPackets.append(make_shared<WorldStartAcknowledgePacket>()); |
| 1780 | |
| 1781 | auto assets = Root::singleton().assets(); |
| 1782 | if (startPacket.localInterpolationMode) |
| 1783 | m_interpolationTracker = InterpolationTracker(m_clientConfig.query("interpolationSettings.local")); |
| 1784 | else |
| 1785 | m_interpolationTracker = InterpolationTracker(m_clientConfig.query("interpolationSettings.normal")); |
| 1786 | |
| 1787 | m_entityUpdateTimer = GameTimer(m_interpolationTracker.entityUpdateDelta()); |
| 1788 | |
| 1789 | m_clientId = startPacket.clientId; |
| 1790 | m_mainPlayer->clientContext()->setConnectionId(startPacket.clientId); |
| 1791 | auto entitySpace = connectionEntitySpace(startPacket.clientId); |
| 1792 | m_worldTemplate = make_shared<WorldTemplate>(startPacket.templateData); |
| 1793 | m_entityMap = make_shared<EntityMap>(m_worldTemplate->size(), entitySpace.first, entitySpace.second); |
| 1794 | m_tileArray = make_shared<ClientTileSectorArray>(m_worldTemplate->size()); |
| 1795 | m_tileGetterFunction = [&, tile = ClientTile()](Vec2I pos) mutable -> ClientTile const& { |
| 1796 | if (!m_predictedTiles.empty()) { |
| 1797 | if (auto p = m_predictedTiles.ptr(pos)) { |
| 1798 | p->apply(tile = m_tileArray->tile(pos)); |
| 1799 | if (p->liquid) { |
| 1800 | if (p->liquid->liquid == tile.liquid.liquid) |
| 1801 | tile.liquid.level += p->liquid->level; |
| 1802 | else { |
| 1803 | tile.liquid.liquid = p->liquid->liquid; |
| 1804 | tile.liquid.level = p->liquid->level; |
| 1805 | } |
| 1806 | } |
| 1807 | return tile; |
| 1808 | } |
| 1809 | } |
| 1810 | return m_tileArray->tile(pos); |
| 1811 | }; |
| 1812 | m_damageManager = make_shared<DamageManager>(this, startPacket.clientId); |
| 1813 | m_playerStart = startPacket.playerRespawn; |
| 1814 | m_respawnInWorld = startPacket.respawnInWorld; |
| 1815 | m_worldProperties = startPacket.worldProperties.optObject().value(); |
| 1816 | m_dungeonIdGravity = startPacket.dungeonIdGravity; |
| 1817 | m_dungeonIdBreathable = startPacket.dungeonIdBreathable; |
| 1818 | m_protectedDungeonIds = startPacket.protectedDungeonIds; |
| 1819 | |
| 1820 | m_geometry = WorldGeometry(m_worldTemplate->size()); |
| 1821 | |
| 1822 | m_particles = make_shared<ParticleManager>(m_geometry, m_tileArray); |
| 1823 | m_particles->setUndergroundLevel(m_worldTemplate->undergroundLevel()); |
| 1824 | |
| 1825 | setupForceRegions(); |
| 1826 | |
| 1827 | m_sky = make_shared<Sky>(); |
| 1828 | m_sky->readUpdate(startPacket.skyData, m_clientState.netCompatibilityRules()); |
| 1829 | |
| 1830 | m_weather.setup(m_geometry, [this](Vec2I const& pos) { |
| 1831 | auto const& tile = m_tileArray->tile(pos); |
| 1832 | return !isRealMaterial(tile.background) && !isSolidColliding(tile.getCollision()); |
| 1833 | }); |
| 1834 | m_weather.readUpdate(startPacket.weatherData, m_clientState.netCompatibilityRules()); |
nothing calls this directly
no test coverage detected