improve applyTileModifications to be more aggressive
This commit is contained in:
parent
7860262a3b
commit
156c243360
@ -324,20 +324,31 @@ TileModificationList WorldClient::applyTileModifications(TileModificationList co
|
|||||||
|
|
||||||
// thanks to new prediction: do each one by one so that previous modifications affect placeability
|
// thanks to new prediction: do each one by one so that previous modifications affect placeability
|
||||||
|
|
||||||
TileModificationList success;
|
TileModificationList success, failures, temp;
|
||||||
TileModificationList failures;
|
TileModificationList const* list = &modificationList;
|
||||||
for (auto const& pair : modificationList) {
|
|
||||||
|
while (true) {
|
||||||
|
bool yay = false;
|
||||||
|
for (size_t i = 0; i != list->size(); ++i) {
|
||||||
|
auto& pair = list->at(i);
|
||||||
if (!isTileProtected(pair.first)) {
|
if (!isTileProtected(pair.first)) {
|
||||||
auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction);
|
auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction);
|
||||||
|
|
||||||
if (result.first) {
|
if (result.first) {
|
||||||
informTilePrediction(pair.first, pair.second);
|
informTilePrediction(pair.first, pair.second);
|
||||||
success.append(pair);
|
success.append(pair);
|
||||||
|
yay = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
failures.append(pair);
|
failures.append(pair);
|
||||||
}
|
}
|
||||||
|
if (yay) {
|
||||||
|
list = &(temp = move(failures));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!success.empty())
|
if (!success.empty())
|
||||||
m_outgoingPackets.append(make_shared<ModifyTileListPacket>(move(success), true));
|
m_outgoingPackets.append(make_shared<ModifyTileListPacket>(move(success), true));
|
||||||
|
@ -103,9 +103,10 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
|||||||
if (*m_lastAimPosition != aimPosition) {
|
if (*m_lastAimPosition != aimPosition) {
|
||||||
diff = geo.diff(*m_lastAimPosition, aimPosition);
|
diff = geo.diff(*m_lastAimPosition, aimPosition);
|
||||||
float magnitude = diff.magnitude();
|
float magnitude = diff.magnitude();
|
||||||
if (magnitude > 32) {
|
float limit = max(4.f, 64.f / radius);
|
||||||
m_lastAimPosition = aimPosition + diff.normalized() * 32;
|
if (magnitude > limit) {
|
||||||
magnitude = 32;
|
m_lastAimPosition = aimPosition + diff.normalized() * limit;
|
||||||
|
magnitude = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
steps = (int)ceil(magnitude * (Constants::pi / 2));
|
steps = (int)ceil(magnitude * (Constants::pi / 2));
|
||||||
@ -133,8 +134,8 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
|||||||
if (!fail) {
|
if (!fail) {
|
||||||
auto sound = Random::randValueFrom(m_placeSounds, "");
|
auto sound = Random::randValueFrom(m_placeSounds, "");
|
||||||
if (total && !sound.empty()) {
|
if (total && !sound.empty()) {
|
||||||
float intensity = clamp((float)total / 20, 0.0f, 1.0f);
|
float intensity = clamp((float)total / 96, 0.0f, 1.0f);
|
||||||
owner()->addSound(sound, 1.0f + intensity, (1.25f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
owner()->addSound(sound, 1.0f + intensity, (1.125f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
||||||
}
|
}
|
||||||
FireableItem::fire(mode, shifting, edgeTriggered);
|
FireableItem::fire(mode, shifting, edgeTriggered);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user