Skip to content

Commit

Permalink
Use stable sort, since it is possible to have multiple tiles on the same
Browse files Browse the repository at this point in the history
logical layer.

Also fix missed change from previous commit.
  • Loading branch information
zrax committed Jan 3, 2021
1 parent 33ae4b9 commit cddcba5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/libcc2/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,10 @@ cc2::MoveState cc2::CheckMove(const MapData& map, const Tile* tile, int x, int y

const Tile* peekBase = &peek->bottom();
if (peekBase->type() == Tile::SteelWall || peekBase->type() == Tile::StyledWall
|| peekBase->type() >= Tile::NUM_TILE_TYPES || peek->blockLayer() != nullptr
|| peekBase->type() >= Tile::NUM_TILE_TYPES
|| peek->haveTile({Tile::MirrorPlayer, Tile::MirrorPlayer2, Tile::BlueTank,
Tile::YellowTank})) {
Tile::YellowTank, Tile::DirtBlock, Tile::IceBlock,
Tile::DirBlock})) {
// These tiles block ALL mobs
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/libcc2/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ std::vector<const cc2::Tile*> cc2::Tile::sortedLayers() const
sorted.push_back(tp);
tp = tp->lower();
}
std::sort(sorted.begin(), sorted.end(), [](const Tile* t1, const Tile* t2) {
std::stable_sort(sorted.begin(), sorted.end(), [](const Tile* t1, const Tile* t2) {
return t1->layer() < t2->layer();
});
return sorted;
Expand Down
3 changes: 1 addition & 2 deletions lib/libcc2/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ void CC2ETileset::drawAt(QPainter& painter, int x, int y, const cc2::Tile* tile,
bool allLayers) const
{
if (allLayers) {
std::vector<const cc2::Tile*> layers = tile->sortedLayers();
bool needXray = false;
for (const cc2::Tile* lt : layers) {
for (const cc2::Tile* lt : tile->sortedLayers()) {
cc2::Tile::DrawLayer lay = lt->layer();
if ((lay == cc2::Tile::BaseLayer && lt->needXray())
|| (lay == cc2::Tile::ItemLayer || lay == cc2::Tile::MobLayer))
Expand Down

0 comments on commit cddcba5

Please sign in to comment.