From 46ead6262bd1ac152a0490c95b7752eb287420a5 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 7 Sep 2023 05:37:05 -0500 Subject: [PATCH] Condense lambda. --- Crawler/Crawler.cpp | 47 +++++++++++++++++---------------------------- Crawler/Version.h | 2 +- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index fa32619b..1e5a931a 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -932,21 +932,24 @@ void Crawler::LoadLevel(MapName map){ if(x0)tileGroupChecks.push({x,y-1}); if(ySprite()->width/24; - int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24; - int tileSheetIndex=tileID-(tileSheet.firstgid-1); - int tileSheetX=tileSheetIndex%tileSheetWidth; - int tileSheetY=tileSheetIndex/tileSheetWidth; - TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24}; - if(IsForeground(tileSheet,tileSheetIndex)){ - foregroundTilesIncluded.insert({x,y}); - group.InsertTile(tile); + auto IterateThroughOtherLayers=[&](vi2d pos){ + for(LayerTag&layer2:MAP_DATA[currentLevel].LayerData){ + if(&layer==&layer2)continue; + int tileID=layer2.tiles[pos.y][pos.x]-1; + TilesheetData tileSheet=GetTileSheet(currentLevel,tileID); + int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24; + int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24; + int tileSheetIndex=tileID-(tileSheet.firstgid-1); + int tileSheetX=tileSheetIndex%tileSheetWidth; + int tileSheetY=tileSheetIndex/tileSheetWidth; + TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{pos.x,pos.y}*24,vi2d{tileSheetX,tileSheetY}*24}; + if(IsForeground(tileSheet,tileSheetIndex)){ + foregroundTilesIncluded.insert({pos.x,pos.y}); + group.InsertTile(tile); + } } - } + }; + IterateThroughOtherLayers({x,y}); while(!tileGroupChecks.empty()){ vi2d&pos=tileGroupChecks.front(); tileGroupChecks.pop(); @@ -965,21 +968,7 @@ void Crawler::LoadLevel(MapName map){ if(pos.x0)tileGroupChecks.push(pos+vi2d{0,-1}); if(pos.ySprite()->width/24; - int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24; - int tileSheetIndex=tileID-(tileSheet.firstgid-1); - int tileSheetX=tileSheetIndex%tileSheetWidth; - int tileSheetY=tileSheetIndex/tileSheetWidth; - TileRenderData tile={tileSheet.tileset.tileset->Decal(),pos*24,vi2d{tileSheetX,tileSheetY}*24}; - if(IsForeground(tileSheet,tileSheetIndex)){ - foregroundTilesIncluded.insert(pos); - group.InsertTile(tile); - } - } + IterateThroughOtherLayers(pos); } } groups.push_back(group); diff --git a/Crawler/Version.h b/Crawler/Version.h index f61c7600..27b56c55 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1093 +#define VERSION_BUILD 1094 #define stringify(a) stringify_(a) #define stringify_(a) #a