MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / replaceTiles

Method replaceTiles

source/game/StarWorldServer.cpp:918–971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

916}
917
918TileModificationList 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
973bool WorldServer::damageWouldDestroy(Vec2I const& pos, TileLayer layer, TileDamage const& tileDamage) const {
974 return WorldImpl::damageWouldDestroy(m_tileArray, pos, layer, tileDamage);

Callers

nothing calls this directly

Calls 5

damageWouldDestroyFunction · 0.85
appendAllMethod · 0.80
appendMethod · 0.45
emptyMethod · 0.45
visitLocationMethod · 0.45

Tested by

no test coverage detected