void MapReader1800::read_tiles(CMap& map, BinaryFile& mapfile)
{
    //2. load map data

    unsigned short i, j, k;
    for (j = 0; j < MAPHEIGHT; j++) {
        for (i = 0; i < MAPWIDTH; i++) {
            for (k = 0; k < MAPLAYERS; k++) {
                TilesetTile * tile = &map.mapdata[i][j][k];
                tile->iID = mapfile.read_i8();
                tile->iCol = mapfile.read_i8();
                tile->iRow = mapfile.read_i8();

                if (tile->iID >= 0) {
                    if (tile->iID > iMaxTilesetID)
                        tile->iID = 0;

                    //Make sure the column and row we read in is within the bounds of the tileset
                    if (tile->iCol < 0 || tile->iCol >= tilesetwidths[tile->iID])
                        tile->iCol = 0;

                    if (tile->iRow < 0 || tile->iRow >= tilesetheights[tile->iID])
                        tile->iRow = 0;

                    //Convert tileset ids into the current game's tileset's ids
                    tile->iID = translationid[tile->iID];
                }
            }

            map.objectdata[i][j].iType = mapfile.read_i8();
            map.objectdata[i][j].fHidden = mapfile.read_bool();
        }
    }
}
void MapReader1800::read_switchable_blocks(CMap& map, BinaryFile& mapfile)
{
    //Read switch block state data
    int iNumSwitchBlockData = mapfile.read_i32();
    for (short iBlock = 0; iBlock < iNumSwitchBlockData; iBlock++) {
        short iCol = mapfile.read_i8();
        short iRow = mapfile.read_i8();

        map.objectdata[iCol][iRow].iSettings[0] = mapfile.read_i8();
    }
}
void MapReader1800::read_extra_tiledata(CMap& map, BinaryFile& mapfile)
{
    int iNumExtendedDataBlocks = mapfile.read_i32();

    for (short iBlock = 0; iBlock < iNumExtendedDataBlocks; iBlock++) {
        short iCol = mapfile.read_i8();
        short iRow = mapfile.read_i8();

        short iNumSettings = mapfile.read_i8();
        for (short iSetting = 0; iSetting < iNumSettings; iSetting++)
            map.objectdata[iCol][iRow].iSettings[iSetting] = mapfile.read_i8();
    }
}
void MapReader1800::read_platform_tiles(CMap& map, BinaryFile& mapfile,
    short iWidth, short iHeight, TilesetTile**& tiles, MapTile**& types)
{
    for (short iCol = 0; iCol < iWidth; iCol++) {
        tiles[iCol] = new TilesetTile[iHeight];
        types[iCol] = new MapTile[iHeight];

        for (short iRow = 0; iRow < iHeight; iRow++) {
            TilesetTile * tile = &tiles[iCol][iRow];

            tile->iID = mapfile.read_i8();
            tile->iCol = mapfile.read_i8();
            tile->iRow = mapfile.read_i8();

            if (tile->iID >= 0) {
                if (iMaxTilesetID != -1 && tile->iID > iMaxTilesetID)
                    tile->iID = 0;

                //Make sure the column and row we read in is within the bounds of the tileset
                if (tile->iCol < 0 || (tilesetwidths && tile->iCol >= tilesetwidths[tile->iID]))
                    tile->iCol = 0;

                if (tile->iRow < 0 || (tilesetheights && tile->iRow >= tilesetheights[tile->iID]))
                    tile->iRow = 0;

                //Convert tileset ids into the current game's tileset's ids
                if (translationid)
                    tile->iID = translationid[tile->iID];
            }

            TileType iType = (TileType)mapfile.read_i32();

            if (iType >= 0 && iType < NUMTILETYPES) {
                types[iCol][iRow].iType = iType;
                types[iCol][iRow].iFlags = g_iTileTypeConversion[iType];
            } else {
                types[iCol][iRow].iType = tile_nonsolid;
                types[iCol][iRow].iFlags = tile_flag_nonsolid;
            }
        }
    }
}