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

Method applyTileModifications

source/game/StarWorldClient.cpp:355–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355TileModificationList WorldClient::applyTileModifications(TileModificationList const& modificationList, bool allowEntityOverlap) {
356 if (!inWorld())
357 return {};
358
359 // thanks to new prediction: do each one by one so that previous modifications affect placeability
360
361 TileModificationList success, failures, temp;
362 TileModificationList const* list = &modificationList;
363
364 while (true) {
365 bool yay = false;
366 for (size_t i = 0; i != list->size(); ++i) {
367 auto& pair = list->at(i);
368 if (!isTileProtected(pair.first)) {
369 auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction);
370
371 if (result.first) {
372 informTilePrediction(pair.first, pair.second);
373 success.append(pair);
374 yay = true;
375 continue;
376 }
377 }
378 failures.append(pair);
379 }
380 if (yay) {
381 list = &(temp = std::move(failures));
382 failures = {};
383 continue;
384 }
385 else break;
386 }
387
388 if (!success.empty())
389 m_outgoingPackets.append(make_shared<ModifyTileListPacket>(std::move(success), true));
390
391 return failures;
392}
393
394TileModificationList WorldClient::replaceTiles(TileModificationList const& modificationList, TileDamage const& tileDamage, bool applyDamage) {
395 if (!inWorld())

Callers 3

fireMethod · 0.45
fireMethod · 0.45
fireMethod · 0.45

Calls 5

validateTileModificationFunction · 0.85
sizeMethod · 0.45
atMethod · 0.45
appendMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected