From 156c243360d8a747c5951fe6a49abec9dafb11e0 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sat, 19 Aug 2023 00:18:51 +1000 Subject: [PATCH] improve applyTileModifications to be more aggressive --- source/game/StarWorldClient.cpp | 31 +++++++++++++++++--------- source/game/items/StarMaterialItem.cpp | 11 ++++----- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index d3fbdce..40c046c 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -324,19 +324,30 @@ TileModificationList WorldClient::applyTileModifications(TileModificationList co // thanks to new prediction: do each one by one so that previous modifications affect placeability - TileModificationList success; - TileModificationList failures; - for (auto const& pair : modificationList) { - if (!isTileProtected(pair.first)) { - auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction); + TileModificationList success, failures, temp; + TileModificationList const* list = &modificationList; - if (result.first) { - informTilePrediction(pair.first, pair.second); - success.append(pair); - continue; + while (true) { + bool yay = false; + for (size_t i = 0; i != list->size(); ++i) { + auto& pair = list->at(i); + if (!isTileProtected(pair.first)) { + auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction); + + if (result.first) { + informTilePrediction(pair.first, pair.second); + success.append(pair); + yay = true; + continue; + } } + failures.append(pair); } - failures.append(pair); + if (yay) { + list = &(temp = move(failures)); + continue; + } + else break; } if (!success.empty()) diff --git a/source/game/items/StarMaterialItem.cpp b/source/game/items/StarMaterialItem.cpp index 99cdead..9ca9862 100644 --- a/source/game/items/StarMaterialItem.cpp +++ b/source/game/items/StarMaterialItem.cpp @@ -103,9 +103,10 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) { if (*m_lastAimPosition != aimPosition) { diff = geo.diff(*m_lastAimPosition, aimPosition); float magnitude = diff.magnitude(); - if (magnitude > 32) { - m_lastAimPosition = aimPosition + diff.normalized() * 32; - magnitude = 32; + float limit = max(4.f, 64.f / radius); + if (magnitude > limit) { + m_lastAimPosition = aimPosition + diff.normalized() * limit; + magnitude = limit; } steps = (int)ceil(magnitude * (Constants::pi / 2)); @@ -133,8 +134,8 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) { if (!fail) { auto sound = Random::randValueFrom(m_placeSounds, ""); if (total && !sound.empty()) { - float intensity = clamp((float)total / 20, 0.0f, 1.0f); - owner()->addSound(sound, 1.0f + intensity, (1.25f - intensity * 0.75f) * Random::randf(0.9f, 1.1f)); + float intensity = clamp((float)total / 96, 0.0f, 1.0f); + owner()->addSound(sound, 1.0f + intensity, (1.125f - intensity * 0.75f) * Random::randf(0.9f, 1.1f)); } FireableItem::fire(mode, shifting, edgeTriggered); }