| 1476 | } |
| 1477 | |
| 1478 | TileModificationList WorldServer::doApplyTileModifications(TileModificationList const& modificationList, bool allowEntityOverlap, bool ignoreTileProtection, bool updateNeighbors) { |
| 1479 | auto materialDatabase = Root::singleton().materialDatabase(); |
| 1480 | |
| 1481 | TileModificationList unapplied = modificationList; |
| 1482 | size_t unappliedSize = unapplied.size(); |
| 1483 | auto it = makeSMutableIterator(unapplied); |
| 1484 | while (it.hasNext()) { |
| 1485 | Vec2I pos; |
| 1486 | TileModification modification; |
| 1487 | std::tie(pos, modification) = it.next(); |
| 1488 | |
| 1489 | if (!ignoreTileProtection && isTileProtected(pos)) |
| 1490 | continue; |
| 1491 | |
| 1492 | if (auto placeMaterial = modification.ptr<PlaceMaterial>()) { |
| 1493 | bool allowTileOverlap = placeMaterial->collisionOverride != TileCollisionOverride::None && collisionKindFromOverride(placeMaterial->collisionOverride) < CollisionKind::Dynamic; |
| 1494 | if (!WorldImpl::canPlaceMaterial(m_entityMap, pos, placeMaterial->layer, placeMaterial->material, allowEntityOverlap, allowTileOverlap, m_tileGetterFunction)) |
| 1495 | continue; |
| 1496 | |
| 1497 | ServerTile* tile = m_tileArray->modifyTile(pos); |
| 1498 | if (!tile) |
| 1499 | continue; |
| 1500 | |
| 1501 | if (placeMaterial->layer == TileLayer::Background) { |
| 1502 | tile->background = placeMaterial->material; |
| 1503 | if (placeMaterial->materialHueShift) |
| 1504 | tile->backgroundHueShift = *placeMaterial->materialHueShift; |
| 1505 | else |
| 1506 | tile->backgroundHueShift = m_worldTemplate->biomeMaterialHueShift(tile->blockBiomeIndex, placeMaterial->material); |
| 1507 | |
| 1508 | tile->backgroundColorVariant = DefaultMaterialColorVariant; |
| 1509 | if (tile->background == EmptyMaterialId) { |
| 1510 | // Remove the background mod if removing the background. |
| 1511 | tile->backgroundMod = NoModId; |
| 1512 | } else if (tile->liquid.source) { |
| 1513 | tile->liquid.pressure = 1.0f; |
| 1514 | tile->liquid.source = false; |
| 1515 | } |
| 1516 | } else { |
| 1517 | tile->foreground = placeMaterial->material; |
| 1518 | if (placeMaterial->materialHueShift) |
| 1519 | tile->foregroundHueShift = *placeMaterial->materialHueShift; |
| 1520 | else |
| 1521 | tile->foregroundHueShift = m_worldTemplate->biomeMaterialHueShift(tile->blockBiomeIndex, placeMaterial->material); |
| 1522 | |
| 1523 | tile->foregroundColorVariant = DefaultMaterialColorVariant; |
| 1524 | if (placeMaterial->collisionOverride != TileCollisionOverride::None) |
| 1525 | tile->updateCollision(collisionKindFromOverride(placeMaterial->collisionOverride)); |
| 1526 | else |
| 1527 | tile->updateCollision(materialDatabase->materialCollisionKind(tile->foreground)); |
| 1528 | if (tile->foreground == EmptyMaterialId) { |
| 1529 | // Remove the foreground mod if removing the foreground. |
| 1530 | tile->foregroundMod = NoModId; |
| 1531 | } |
| 1532 | if (materialDatabase->blocksLiquidFlow(tile->foreground)) |
| 1533 | tile->liquid = LiquidStore(); |
| 1534 | } |
| 1535 |
nothing calls this directly
no test coverage detected