Esempio n. 1
0
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();
        }
    }
}
Esempio n. 2
0
void MapReader1800::read_warp_locations(CMap& map, BinaryFile& mapfile)
{
    for (unsigned short j = 0; j < MAPHEIGHT; j++) {
        for (unsigned short i = 0; i < MAPWIDTH; i++) {
            TileType iType = (TileType)mapfile.read_i32();

            if (iType >= 0 && iType < NUMTILETYPES) {
                map.mapdatatop[i][j].iType = iType;
                map.mapdatatop[i][j].iFlags = g_iTileTypeConversion[iType];
            } else {
                map.mapdatatop[i][j].iType = tile_nonsolid;
                map.mapdatatop[i][j].iFlags = tile_flag_nonsolid;
            }

            map.warpdata[i][j].direction = (WarpEnterDirection)mapfile.read_i32();
            map.warpdata[i][j].connection = (short)mapfile.read_i32();
            map.warpdata[i][j].id = (short)mapfile.read_i32();

            for (short sType = 0; sType < NUMSPAWNAREATYPES; sType++)
                map.nospawn[sType][i][j] = mapfile.read_bool();

        }
    }
}