[*] Now editor correctly uses randomized mixed tile types
This commit is contained in:
parent
00972d1aa2
commit
b21dc46d49
3 changed files with 23 additions and 2 deletions
|
@ -90,7 +90,7 @@ static int IconHeight; /// Icon height in panels
|
|||
static int ButtonPanelWidth;
|
||||
static int ButtonPanelHeight;
|
||||
|
||||
static char TileToolRandom; /// Tile tool draws random
|
||||
char TileToolRandom; /// Tile tool draws random
|
||||
static char TileToolDecoration; /// Tile tool draws with decorations
|
||||
static int TileCursorSize; /// Tile cursor size 1x1 2x2 ... 4x4
|
||||
static bool UnitPlacedThisPress = false; /// Only allow one unit per press
|
||||
|
|
|
@ -100,7 +100,26 @@ static void EditorChangeTile(const Vec2i &pos, int tileIndex, int d)
|
|||
|
||||
// Change the flags
|
||||
CMapField &mf = *Map.Field(pos);
|
||||
mf.setTileIndex(*Map.Tileset, tileIndex, 0);
|
||||
int tile = tileIndex;
|
||||
if (TileToolRandom) {
|
||||
int n = 0;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
if (!Map.Tileset->tiles[tile + i].tile) {
|
||||
break;
|
||||
} else {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
n = MyRand() % n;
|
||||
int i = -1;
|
||||
do {
|
||||
while (++i < 16 && !Map.Tileset->tiles[tile + i].tile) {
|
||||
}
|
||||
} while (i < 16 && n--);
|
||||
Assert(i != 16);
|
||||
tile += i;
|
||||
}
|
||||
mf.setTileIndex(*Map.Tileset, tile, 0);
|
||||
mf.playerInfo.SeenTile = mf.getGraphicTile();
|
||||
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
|
||||
extern CEditor Editor;
|
||||
|
||||
extern char TileToolRandom;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue