| 916 | } |
| 917 | |
| 918 | TileModificationList WorldServer::replaceTiles(TileModificationList const& modificationList, TileDamage const& tileDamage, bool applyDamage) { |
| 919 | TileModificationList success, failures; |
| 920 | |
| 921 | if (applyDamage) { |
| 922 | List<Vec2I> toDamage; |
| 923 | TileLayer layer; |
| 924 | |
| 925 | for (auto pair : modificationList) { |
| 926 | if (auto placeMaterial = pair.second.ptr<PlaceMaterial>()) { |
| 927 | layer = placeMaterial->layer; |
| 928 | |
| 929 | if (placeMaterial->material == material(pair.first, layer)) { |
| 930 | failures.append(pair); |
| 931 | continue; |
| 932 | } |
| 933 | |
| 934 | if (damageWouldDestroy(pair.first, layer, tileDamage)) { |
| 935 | if (replaceTile(pair.first, pair.second, tileDamage)) |
| 936 | success.append(pair); |
| 937 | else |
| 938 | failures.append(pair); |
| 939 | continue; |
| 940 | } |
| 941 | |
| 942 | toDamage.append(pair.first); |
| 943 | success.append(pair); |
| 944 | continue; |
| 945 | } |
| 946 | |
| 947 | failures.append(pair); |
| 948 | } |
| 949 | |
| 950 | if (!toDamage.empty()) |
| 951 | damageTiles(toDamage, layer, Vec2F(), tileDamage, Maybe<EntityId>()); |
| 952 | |
| 953 | } else { |
| 954 | for (auto pair : modificationList) { |
| 955 | if (replaceTile(pair.first, pair.second, tileDamage)) |
| 956 | success.append(pair); |
| 957 | else |
| 958 | failures.append(pair); |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | failures.appendAll(doApplyTileModifications(success, true, false, false)); |
| 963 | |
| 964 | for (auto pair : success) { |
| 965 | checkEntityBreaks(RectF::withSize(Vec2F(pair.first), Vec2F(1, 1))); |
| 966 | m_liquidEngine->visitLocation(pair.first); |
| 967 | m_fallingBlocksAgent->visitLocation(pair.first); |
| 968 | } |
| 969 | |
| 970 | return failures; |
| 971 | } |
| 972 | |
| 973 | bool WorldServer::damageWouldDestroy(Vec2I const& pos, TileLayer layer, TileDamage const& tileDamage) const { |
| 974 | return WorldImpl::damageWouldDestroy(m_tileArray, pos, layer, tileDamage); |
nothing calls this directly
no test coverage detected