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

Method readNetTile

source/game/StarWorldClient.cpp:1997–2057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1995}
1996
1997bool WorldClient::readNetTile(Vec2I const& pos, NetTile const& netTile, bool updateCollision) {
1998 ClientTile* tile = m_tileArray->modifyTile(pos);
1999 if (!tile)
2000 return false;
2001
2002 if (!m_predictedTiles.empty()) {
2003 auto findPrediction = m_predictedTiles.find(pos);
2004 if (findPrediction != m_predictedTiles.end()) {
2005 auto& p = findPrediction->second;
2006
2007 if (p.collision && *p.collision == netTile.collision)
2008 p.collision.reset();
2009 if (p.foreground && (*p.foreground == StructureMaterialId || *p.foreground == netTile.foreground))
2010 p.foreground.reset();
2011 if (p.foregroundMod && *p.foregroundMod == netTile.foregroundMod)
2012 p.foregroundMod.reset();
2013 if (p.foregroundHueShift && *p.foregroundHueShift == netTile.foregroundHueShift)
2014 p.foregroundHueShift.reset();
2015 if (p.foregroundModHueShift && *p.foregroundModHueShift == netTile.foregroundModHueShift)
2016 p.foregroundModHueShift.reset();
2017
2018 if (p.background && *p.background == netTile.background)
2019 p.background.reset();
2020 if (p.backgroundMod && *p.backgroundMod == netTile.backgroundMod)
2021 p.backgroundMod.reset();
2022 if (p.backgroundHueShift && *p.backgroundHueShift == netTile.backgroundHueShift)
2023 p.backgroundHueShift.reset();
2024 if (p.backgroundModHueShift && *p.backgroundModHueShift == netTile.backgroundModHueShift)
2025 p.backgroundModHueShift.reset();
2026
2027 if (!p)
2028 m_predictedTiles.erase(findPrediction);
2029 }
2030 }
2031
2032 tile->background = netTile.background;
2033 tile->backgroundHueShift = netTile.backgroundHueShift;
2034 tile->backgroundColorVariant = netTile.backgroundColorVariant;
2035 tile->backgroundMod = netTile.backgroundMod;
2036 tile->backgroundModHueShift = netTile.backgroundModHueShift;
2037 tile->foreground = netTile.foreground;
2038 tile->foregroundHueShift = netTile.foregroundHueShift;
2039 tile->foregroundColorVariant = netTile.foregroundColorVariant;
2040 tile->foregroundMod = netTile.foregroundMod;
2041 tile->foregroundModHueShift = netTile.foregroundModHueShift;
2042 tile->collision = netTile.collision;
2043 tile->blockBiomeIndex = netTile.blockBiomeIndex;
2044 tile->environmentBiomeIndex = netTile.environmentBiomeIndex;
2045 tile->liquid = netTile.liquid.liquidLevel();
2046 tile->dungeonId = netTile.dungeonId;
2047
2048 auto materialDatabase = Root::singleton().materialDatabase();
2049 tile->backgroundLightTransparent = materialDatabase->backgroundLightTransparent(tile->background);
2050 tile->foregroundLightTransparent =
2051 materialDatabase->foregroundLightTransparent(tile->foreground) && tile->collision != CollisionKind::Dynamic;
2052
2053 if (updateCollision)
2054 dirtyCollision(RectI::withSize(pos, {1, 1}));

Callers

nothing calls this directly

Calls 11

singletonClass · 0.85
materialDatabaseMethod · 0.80
modifyTileMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
resetMethod · 0.45
eraseMethod · 0.45
liquidLevelMethod · 0.45

Tested by

no test coverage detected