void Migration::Impl::createMigrationToCity( PlayerCityPtr city ) { unsigned int vh = calcVacantHouse( city ); if( vh == 0 ) { return; } EmigrantList migrants; migrants << city->walkers(); if( vh <= migrants.size() * 5 ) { return; } Tile& roadTile = city->tilemap().at( city->borderInfo().roadEntry ); ImmigrantPtr emigrant = Immigrant::create( city ); if( emigrant.isValid() ) { bool success = emigrant->send2city( roadTile ); emigrant->setSpeedMultiplier( 0.8f + math::random( 40 ) / 100.f ); if( success ) lastMonthComing += emigrant->peoples().count(); } }
static void __removeCorners(Game& game ) { PlayerCityPtr oCity = game.city(); Tilemap& oTilemap = oCity->tilemap(); unsigned int mapSize = oTilemap.size(); TilePos psAr[8] = { TilePos(0, 1), TilePos(-1, 1), TilePos(-1, 0), TilePos(-1, -1), TilePos(0, -1), TilePos(1, -1), TilePos(1, 0), TilePos(1, 1)}; //check one water tiles for( unsigned int i=0; i < mapSize; i++ ) for( unsigned int j=0; j < mapSize; j++ ) { TilePos tpos = TilePos( i, j ); Tile& wtile = oTilemap.at( tpos ); if( wtile.originalImgId() == 0 || wtile.getFlag( Tile::tlWater ) || wtile.getFlag( Tile::tlDeepWater ) ) continue; for( int k=0; k < 8; k++ ) { Tile& t = oTilemap.at( tpos + psAr[k] ); bool isWater = ( t.getFlag( Tile::tlWater ) || t.getFlag( Tile::tlDeepWater ) ); if( isWater ) { wtile.setFlag( Tile::clearAll, true ); wtile.setOriginalImgId( 0 ); wtile.setPicture( Picture() ); break; } } } }
void LowBridge::_computePictures(PlayerCityPtr city, const TilePos& startPos, const TilePos& endPos, constants::Direction dir ) { Tilemap& tilemap = city->tilemap(); //Picture& water = Picture::load( "land1a", 120 ); switch( dir ) { case northWest: { TilesArray tiles = tilemap.getArea( endPos, startPos ); if (tiles.size() < 3) break; tiles.pop_back(); tiles.erase( tiles.begin() ); _d->addSpan( tiles.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest ); foreach( it, tiles ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest ); } _d->addSpan( tiles.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest ); } break; case northEast: { TilesArray tiles = tilemap.getArea( startPos, endPos ); if (tiles.size() < 3) break; tiles.pop_back(); tiles.erase( tiles.begin() ); _d->addSpan( tiles.back()->pos() - startPos + TilePos( 0, 1 ), LowBridgeSubTile::liftingNorth ); for( TilesArray::reverse_iterator it=tiles.rbegin(); it != tiles.rend(); ++it ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanNorth ); } _d->addSpan( tiles.front()->pos() - startPos - TilePos( 0, 1 ), LowBridgeSubTile::descentNorth ); } break; case southEast: { TilesArray tiles = tilemap.getArea( startPos, endPos ); if( tiles.size() < 3 ) break; tiles.pop_back(); tiles.erase( tiles.begin() ); _d->addSpan( tiles.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest ); foreach( it, tiles ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest ); //_d->subtiles.push_back( LowBridgeSubTile( (*it)->getIJ() - startPos, water ) ); } _d->addSpan( tiles.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest ); }
void LowBridge::_computePictures(PlayerCityPtr city, const TilePos& startPos, const TilePos& endPos, Direction dir ) { Tilemap& tilemap = city->tilemap(); //Picture& water = Picture::load( "land1a", 120 ); switch( dir ) { case direction::northWest: { Bridge::Area area( tilemap, endPos, startPos ); if (area.size() < 3) break; area.cropCorners(); _d->addSpan( area.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest ); foreach( it, area ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest ); } _d->addSpan( area.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest ); } break; case direction::northEast: { Bridge::Area area( tilemap, startPos, endPos ); if (area.size() < 3) break; area.cropCorners(); _d->addSpan( area.back()->pos() - startPos + TilePos( 0, 1 ), LowBridgeSubTile::liftingNorth ); for( TilesArray::reverse_iterator it=area.rbegin(); it != area.rend(); ++it ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanNorth ); } _d->addSpan( area.front()->pos() - startPos - TilePos( 0, 1 ), LowBridgeSubTile::descentNorth ); } break; case direction::southEast: { Bridge::Area area( tilemap, startPos, endPos ); if( area.size() < 3 ) break; area.cropCorners(); _d->addSpan( area.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest ); foreach( it, area ) { _d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest ); } _d->addSpan( area.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest ); }
bool MarbleQuarry::canBuild(PlayerCityPtr city, TilePos pos, const TilesArray& aroundTiles ) const { bool is_constructible = Construction::canBuild( city, pos, aroundTiles ); bool near_mountain = false; // tells if the factory is next to a mountain Tilemap& tilemap = city->tilemap(); TilesArray perimetr = tilemap.getRectangle( pos + TilePos( -1, -1 ), size() + Size( 2 ), Tilemap::checkCorners); foreach( tile, perimetr ) { near_mountain |= (*tile)->getFlag( Tile::tlRock ); }
void C3Map::Impl::initCameraStartPos(std::fstream &f, PlayerCityPtr ioCity) { /*unsigned short int i = 0; unsigned short int j = 0; f.seekg(kCamera, std::ios::beg); f.read((char*)&i, 2); f.read((char*)&j, 2);*/ int mapSize = ioCity->tilemap().size(); ioCity->setCameraPos( TilePos( mapSize / 2, mapSize / 2 ) ); }
bool Construction::canBuild(PlayerCityPtr city, TilePos pos , const TilesArray& ) const { Tilemap& tilemap = city->tilemap(); bool is_constructible = true; //return area for available tiles TilesArray area = tilemap.getArea( pos, size() ); //on over map size if( (int)area.size() != size().area() ) return false; foreach( tile, area ) {is_constructible &= (*tile)->getFlag( Tile::isConstructible );}
void Shoreline::Impl::checkMap( PlayerCityPtr city ) { const TilesArray& tiles = city->tilemap().allTiles(); foreach( it, tiles ) { int imgId = (*it)->originalImgId(); if( (imgId >= 372 && imgId <= 403) || (imgId>=414 && imgId<=418) || (*it)->getFlag( Tile::tlCoast ) ) { slTiles.push_back( *it ); } if( (*it)->getFlag( Tile::tlDeepWater ) ) { dwTiles.push_back( *it ); } }
void C3Sav::Impl::initEntryExit(std::fstream &f, PlayerCityPtr ioCity) { unsigned int size = ioCity->tilemap().size(); const unsigned int savePos = f.tellg(); // init road entry/exit point unsigned short int i = 0; unsigned short int j = 0; f.seekg(1236, std::ios::cur); f.read((char*)&i, 2); f.read((char*)&j, 2); BorderInfo borderInfo; borderInfo.roadEntry = TilePos( i, size - j - 1 ); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.roadExit = TilePos( i, size - j - 1 ); // init boat entry/exit point f.seekg(savePos, std::ios::beg); f.seekg(1276, std::ios::cur); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.boatEntry = TilePos( i, size - j - 1 ); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.boatExit = TilePos( i, size - j - 1); ioCity->setBorderInfo( borderInfo ); f.seekg(savePos, std::ios::beg); }
void C3Map::Impl::initEntryExit(std::fstream &f, PlayerCityPtr ioCity) { unsigned int size = ioCity->tilemap().size(); // init road entry/exit point unsigned short int i = 0; unsigned short int j = 0; f.seekg(kRoadEntry, std::ios::beg); f.read((char*)&i, 2); f.read((char*)&j, 2); BorderInfo borderInfo; borderInfo.roadEntry = TilePos( i, size - j - 1 ); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.roadExit = TilePos( i, size - j - 1 ); // init boat entry/exit point f.seekg(kBoatEntry, std::ios::beg); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.boatEntry = TilePos( i, size - j - 1 ); f.read((char*)&i, 2); f.read((char*)&j, 2); borderInfo.boatExit = TilePos( i, size - j - 1); ioCity->setBorderInfo( borderInfo ); //std::cout << "road entry at:" << ioCity.getRoadEntryI() << "," << ioCity.getRoadEntryJ() << std::endl; //std::cout << "road exit at:" << ioCity.getRoadExitI() << "," << ioCity.getRoadExitJ() << std::endl; //std::cout << "boat entry at:" << ioCity.getBoatEntryI() << "," << ioCity.getBoatEntryJ() << std::endl; //std::cout << "boat exit at:" << ioCity.getBoatExitI() << "," << ioCity.getBoatExitJ() << std::endl; }
void OMap::Impl::initCameraStartPos(const VariantMap& vm, PlayerCityPtr ioCity) { int mapSize = ioCity->tilemap().size(); ioCity->setCameraPos( TilePos( mapSize / 2, mapSize / 2 ) ); }
bool C3Sav::Impl::loadCity( std::fstream& f, Game& game ) { uint32_t tmp; // need to rewrite better std::vector<short int> graphicGrid; graphicGrid.resize( 26244, 0 ); std::vector<unsigned char> edgeGrid; edgeGrid.resize( 26244, 0 ); std::vector<short int> terrainGrid; terrainGrid.resize( 26244, 0 ); std::vector<unsigned char> rndmTerGrid; rndmTerGrid.resize(26244, 0); std::vector<unsigned char> randomGrid; randomGrid.resize( 26244, 0 ); std::vector<unsigned char> zeroGrid; zeroGrid.resize( 26244, 0 ); if( !f.is_open() ) { Logger::warning( "GameLoaderC3Sav: can't open file " ); return false; } f.read( (char*)&tmp, 4); // read dummy std::string cityName = LoaderHelper::getDefaultCityName( tmp ); game.city()->setName( cityName ); f.read((char*)&tmp, 4); // read scenario flag try { f.read((char*)&tmp, 4); // read length of compressed chunk Logger::warning( "GameLoaderC3Sav: length of compressed ids is %d", tmp ); PKWareInputStream *pk = new PKWareInputStream(&f, false, tmp); for (int i = 0; i < 162 * 162; i++) { graphicGrid[i] = pk->readShort(); } pk->empty(); delete pk; f.read((char*)&tmp, 4); // read length of compressed chunk Logger::warning( "GameLoaderC3Sav: length of compressed egdes is %d", tmp ); pk = new PKWareInputStream(&f, false, tmp); for (int i = 0; i < 162 * 162; i++) { edgeGrid[i] = pk->readByte(); } pk->empty(); delete pk; SkipCompressed(f); // skip building ids f.read((char*)&tmp, 4); // read length of compressed chunk Logger::warning( "GameLoaderC3Sav: length of compressed terraindata is %d", tmp ); pk = new PKWareInputStream(&f, false, tmp); for (int i = 0; i < 162 * 162; i++) { terrainGrid[i] = pk->readShort(); } pk->empty(); delete pk; SkipCompressed(f); SkipCompressed(f); SkipCompressed(f); SkipCompressed(f); f.read((char*)&randomGrid[0], 26244); SkipCompressed(f); SkipCompressed(f); SkipCompressed(f); SkipCompressed(f); SkipCompressed(f); // here goes walkers array f.read((char*)&tmp, 4); // read length of compressed chunk Logger::warning( "GameLoaderC3Sav: length of compressed walkers data is %d", tmp ); pk = new PKWareInputStream(&f, false, tmp); for (int j = 0; j < 1000; j++) { pk->skip(10); pk->readShort(); pk->skip(8); pk->readByte(); pk->readByte(); pk->skip(106); } pk->empty(); delete pk; int length; f.read((char*)&length, 4); // read next length :-) if (length <= 0) f.seekg(1200, std::ios::cur); else f.seekg(length, std::ios::cur); SkipCompressed(f); SkipCompressed(f); // 3x int f.read((char*)&tmp, 4); f.read((char*)&tmp, 4); f.read((char*)&tmp, 4); SkipCompressed(f); f.seekg(70, std::ios::cur); SkipCompressed(f); // skip building list f.seekg(208, std::ios::cur); SkipCompressed(f); // skip unknown f.seekg(788, std::ios::cur); // skip unused data f.read((char*)&tmp, 4); //mapsize int size = tmp; PlayerCityPtr oCity = game.city(); Tilemap& oTilemap = oCity->tilemap(); oCity->resize(size); oCity->setCameraPos( TilePos( 0, 0 ) ); initEntryExit( f, game.city() ); f.seekg(1312, std::ios::cur); char climate; f.read(&climate, 1); oCity->setClimate((ClimateType)climate); // here goes the WORK! // loads the graphics map int border_size = (162 - size) / 2; std::map< int, std::map< int, unsigned char > > edgeData; game.city()->setCameraPos( TilePos( size/2, size/2 ) ); for (int itA = 0; itA < size; ++itA) { for (int itB = 0; itB < size; ++itB) { int i = itB; int j = size - itA - 1; int index = 162 * (border_size + itA) + border_size + itB; Tile& tile = oTilemap.at(i, j); unsigned int imgId = graphicGrid[index]; Picture pic = imgid::toPicture( imgId ); if( pic.isValid() ) { tile.setPicture( pic ); tile.setOriginalImgId( imgId ); } else { TileOverlay::Type ovType = LoaderHelper::convImgId2ovrType( imgId ); if( ovType == constants::objects::unknown ) { Logger::warning( "!!! GameLoaderC3Sav: Unknown building %x at [%d,%d]", imgId, i, j ); } baseBuildings[ tile.pos() ] = imgId; pic = Picture::load( ResourceGroup::land1a, 230 + math::random( 57 ) ); tile.setPicture( pic ); tile.setOriginalImgId( imgid::fromResource( pic.name() ) ); } edgeData[ i ][ j ] = edgeGrid[index]; tile::decode( tile, terrainGrid[index] ); tile::fixPlateauFlags( tile ); } } for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) { unsigned char ed = edgeData[ i][ j ]; if( ed == 0x00) { int size = 1; { int dj; try { // find size, 5 is maximal size for building for (dj = 0; dj < 5; ++dj) { int edd = edgeData[ i ][ j - dj ]; // find bottom left corner if (edd == 8 * dj + 0x40) { size = dj + 1; break; } } } catch(...) { size = dj + 1; } } Tile& master = oTilemap.at(i, j - size + 1); //Logger::warning( "Master will be at (%d,%d)", master.i(), master.j() ); for (int di = 0; di < size; ++di) { for (int dj = 0; dj < size; ++dj) { oTilemap.at(master.i() + di, master.j() + dj).setMasterTile(&master); } } } // Check if it is building and type of building //if (ttile.getMasterTile() == NULL) std::map<TilePos, unsigned int>::iterator bbIt = baseBuildings.find( TilePos( i, j ) ); unsigned int bbImgId = bbIt == baseBuildings.end() ? 0 : bbIt->second; Tile& tile = oTilemap.at( i, j ); Tile* masterTile = tile.masterTile(); if( !masterTile ) masterTile = &tile; if( masterTile->overlay().isNull() ) { LoaderHelper::decodeTerrain( *masterTile, oCity, bbImgId ); } } } } catch(PKException) { THROW("fatal error when unpacking"); } return true; }
void C3Map::Impl::loadCity(std::fstream& f, PlayerCityPtr oCity) { Tilemap& oTilemap = oCity->tilemap(); /* get number of city */ f.seekg(kLocation, std::ios::beg); unsigned int location=0; f.read((char*)&location, 1); Logger::warning( "C3MapLoader: location of city is %d", (int)(location) ); std::string cityName = LoaderHelper::getDefaultCityName( location ); oCity->setName( cityName ); f.seekg(kSize, std::ios::beg); int map_size; // 32bits int size_2; f.read((char*)&map_size, 4); f.read((char*)&size_2, 4); Logger::warning( "C3MapLoader: map size is %d", map_size ); if (map_size != size_2) { THROW("Horizontal and vertical map sizes are different!"); } oCity->resize(map_size); // need to rewrite better ScopedArrayPtr<short> pGraphicGrid( new short[tilemap::c3mapSizeSq] ); ScopedArrayPtr<unsigned char> pEdgeGrid( new unsigned char[tilemap::c3mapSizeSq] ); ScopedArrayPtr<short> pTerrainGrid( new short[tilemap::c3mapSizeSq] ); ScopedArrayPtr<unsigned char> pRndmTerGrid( new unsigned char[tilemap::c3mapSizeSq] ); ScopedArrayPtr<unsigned char> pRandomGrid( new unsigned char[tilemap::c3mapSizeSq] ); ScopedArrayPtr<unsigned char> pElevationGrid( new unsigned char[tilemap::c3mapSizeSq] ); if( pGraphicGrid.isNull() || pEdgeGrid.isNull() || pTerrainGrid.isNull() || pRndmTerGrid.isNull() || pRandomGrid.isNull() || pElevationGrid.isNull() ) { THROW("NOT ENOUGH MEMORY!!!! FATAL"); } // here also make copy of original arrays in memory f.seekg(kGraphicGrid, std::ios::beg); f.read((char*)pGraphicGrid.data(), tilemap::c3mapSizeSq*2); f.seekg(kEdgeGrid, std::ios::beg); f.read((char*)pEdgeGrid.data(), tilemap::c3mapSizeSq); f.seekg(kTerrainGrid, std::ios::beg); f.read((char*)pTerrainGrid.data(), tilemap::c3mapSizeSq*2); f.seekg(kRndmTerGrid, std::ios::beg); f.read((char*)pRndmTerGrid.data(), tilemap::c3mapSizeSq); f.seekg(kRandomGrid, std::ios::beg); f.read((char*)pRandomGrid.data(), tilemap::c3mapSizeSq); f.seekg(kElevationGrid, std::ios::beg); f.read((char*)pElevationGrid.data(), tilemap::c3mapSizeSq); std::map< int, std::map< int, unsigned char > > edgeData; // loads the graphics map int border_size = (gfx::tilemap::c3mapSize - map_size) / 2; for (int itA = 0; itA < map_size; ++itA) { for (int itB = 0; itB < map_size; ++itB) { int i = itB; int j = map_size - itA - 1; int index = gfx::tilemap::c3mapSize * (border_size + itA) + border_size + itB; Tile& tile = oTilemap.at(i, j); tile.setPicture( imgid::toResource( pGraphicGrid.data()[index] ) ); tile.setOriginalImgId( pGraphicGrid.data()[index] ); //tile.setHeight( pElevationGrid.data()[ index ] ); edgeData[ i ][ j ] = pEdgeGrid.data()[index]; tile::decode( tile, pTerrainGrid.data()[index] ); tile::fixPlateauFlags( tile ); } } for (int i = 0; i < map_size; ++i) { for (int j = 0; j < map_size; ++j) { unsigned char ed = edgeData[ i ][ j ]; if( ed == 0x00) { int size = 1; { int dj; try { // find size, 5 is maximal size for building for (dj = 0; dj < gfx::tilemap::c3bldSize; ++dj) { int edd = edgeData[ i ][ j - dj ]; // find bottom left corner if (edd == 8 * dj + 0x40) { size = dj + 1; break; } } } catch(...) { size = dj + 1; } } Tile& master = oTilemap.at(i, j - size + 1); for (int di = 0; di < size; ++di) { for (int dj = 0; dj < size; ++dj) { oTilemap.at(master.pos() + TilePos( di, dj ) ).setMasterTile(&master); } } } // Check if it is building and type of building //if (ttile.getMasterTile() == NULL) LoaderHelper::decodeTerrain( oTilemap.at( i, j ), oCity ); } } }
static void __createRivers(Game& game ) { PlayerCityPtr oCity = game.city(); Tilemap& oTilemap = oCity->tilemap(); TerrainGeneratorHelper tgHelper; Pathfinder& pathfinder = Pathfinder::instance(); pathfinder.setCondition( makeDelegate( &tgHelper, &TerrainGeneratorHelper::canBuildRiver ) ); TilesArray terrainTiles = oTilemap.getArea( TilePos(0,0), Size( oTilemap.size() ) ); for( TilesArray::iterator it=terrainTiles.begin(); it != terrainTiles.end(); ) { Tile* tile = *it; if( tile->isWalkable( true ) || tile->getFlag( Tile::tlTree ) ) { ++it; } else { it = terrainTiles.erase( it ); } } int riverCount = 0; for( int tryCount=0; tryCount < 20; tryCount++ ) { if( riverCount++ > oTilemap.size() / 60 ) break; Tile* centertile = terrainTiles.random(); Pathway way; for( int range=0; range < 99; range++ ) { TilesArray perimeter = oTilemap.getRectangle( range, centertile->pos() ); foreach( it, perimeter ) { Tile* currentTile = *it; if( currentTile->getFlag( Tile::tlWater ) ) { way = pathfinder.getPath( *centertile, *currentTile, Pathfinder::customCondition | Pathfinder::fourDirection ); if( way.isValid() ) { break; } } } if( way.isValid() ) break; } if( way.isValid() ) { TilesArray wayTiles = way.allTiles(); foreach( it, wayTiles ) { TileOverlayPtr overlay = TileOverlayFactory::instance().create( constants::objects::river ); //Picture pic = Picture::load( ResourceGroup::land1a, 62 + math::random( 57 ) ); (*it)->setPicture( Picture::getInvalid() ); //(*it)->setOriginalImgId( TileHelper::convPicName2Id( pic.name() ) ); (*it)->setOriginalImgId( 0 ); bool isWater = (*it)->getFlag( Tile::tlWater ); CityAreaInfo info = { oCity, (*it)->pos(), TilesArray() }; overlay->build( info ); oCity->overlays().push_back( overlay ); if( isWater ) break; }
static void __finalizeMap(Game& game, int pass ) { PlayerCityPtr oCity = game.city(); Tilemap& oTilemap = oCity->tilemap(); unsigned int mapSize = oTilemap.size(); //check one water tiles for( unsigned int i=0; i < mapSize; i++ ) for( unsigned int j=0; j < mapSize; j++ ) { TilePos tpos = TilePos( i, j ); Tile& wtile = oTilemap.at( tpos ); if( wtile.originalImgId() > 0 ) continue; int direction = 0; for( int k=0; k < 8; k++ ) { Tile& t = oTilemap.at( tpos + psAr[k] ); bool isWater = !t.getFlag( Tile::tlCoast ) && ( t.getFlag( Tile::tlWater ) || t.getFlag( Tile::tlDeepWater ) ); if( isWater ) { direction += directions[k]; } } int start=0, rnd=4; switch( pass ) { case passCheckNorthCoastTiles: switch( direction ) { case drN: case drN|drNW: case drNW|drNE|drN: case drNE|drN: case drNE|drNW: start=128; break; } break; case passCheckEastCoastTiles: switch( direction ) { case drE: case drNE|drE: case drNE|drSE: case drNE|drSE|drE: case drSE|drE: start=132; break; } break; case passCheckSouthCoastTiles: switch( direction ) { case drS: case drSW|drS: case drSE|drS: case drSW|drSE|drS: case drSW|drSE: start=136; break; } break; case passCheckWestCoastTiles: switch( direction ) { case drW: case drSW|drNW|drW: case drSW|drW: case drNW|drW: case drSW|drNW: start=140; break; } break; case passCheckSmallCoastTiles: switch( direction ) { case drE|drS|drSE: case drE|drNE|drSE|drS: case drE|drSW|drSE|drS: case drE|drSW|drSE|drS|drNE: case drE|drSW|drSE|drNE: case drE|drSW|drNE: case drNE|drSE|drSW|drS: case drSE|drNE|drS: case drNE|drS|drE: case drSW|drE: case drSW|drS|drE: case drNE|drS: case drNE|drSW|drS: case drNE|drSW|drE|drS: case drE|drS: case drNE|drSE|drSW: case drSW|drSE|drE: start = 171; rnd=0; break; case drNW|drSW|drW|drN: case drNW|drW|drN: case drNW|drNE|drW|drN: case drNW|drNE|drW: case 0xd9: case 0x58: case 0x19: case 0xd8: case 0xd1: case 0x49: case 0x18: case 0xc1: case 0x41: case 0x51: case 0x09: case 0x59: case 0xd0: start=173; rnd=0; break; case 0x13: case 0xb1: case 0x23: case 0x93: case 0x33: case 0xb3: case 0x83: case 0x31: case 0xa3: case 0x21: case 0x82: case 0xa1: case 0xa2: case 0x92: case 0xb2: case 0x03: case 0xb0: start=170; rnd=0; break; case 0xa0: start=168; rnd=0; break; case 0x50: start=169; rnd=0; break; case 0xcc: case 0x4c: case 0x6c: case 0xec: case 0xc4: case 0x68: case 0xe4: case 0xe8: case 0xa8: case 0x84: case 0x28: case 0xac: case 0xa4: case 0x0c: case 0x8c: case 0x2c: case 0xe0: start = 172; rnd=0; break; } break; case 6: break; case passCheckInsideCornerTiles: switch( direction ) { case drNE: start=PicID::coastNE; break; case drSE: start=PicID::coastSE; break; case 0x40: start=152; break; case 0x80: start=156; break; } break; case 8: switch( direction ) { case 0x6e: case 0xed: case 0x9b: case 0xcd: case 0xff: case 0xee: case 0xdf: case 0x05: case 0x37: case 0x77: case 0xfb: case 0x9a: case 0xeb: case 0xa5: case 0xf9: case 0xb7: case 0xbf: case 0x1b: case 0x35: case 0xe5: case 0x95: case 0x17: case 0x7d: case 0xe7: case 0xad: case 0x71: case 0xdc: case 0xdb: case 0xa6: case 0xb9: case 0xa7: case 0x27: case 0xdd: case 0xf3: case 0x7e: case 0x75: case 0xd3: case 0xc5: case 0x55: case 0xfe: case 0xbb: case 0x7c: case 0x5a: case 0x53: case 0x45: case 0xce: case 0xef: case 0x7f: case 0x8d: case 0x1d: case 0xf5: case 0xf7: case 0xf1: case 0x97: case 0x2e: case 0xc3: case 0x5c: case 0x0a: case 0x69: case 0xb5: case 0x25: case 0x8a: case 0x3b: case 0xe6: case 0x6a: case 0xcb: case 0x3f: case 0xaa: case 0x57: case 0xfd: case 0xd5: case 0x7a: case 0x85: case 0xfc: case 0xca: case 0x8b: case 0x9f: case 0x4f: case 0xde: case 0x9d: case 0xe9: case 0x6f: case 0xd7: case 0xae: case 0xaf: case 0xf8: case 0x3c: case 0xe2: case 0xea: case 0x96: case 0x3a: case 0xcf: case 0xbd: case 0xbe: case 0x94: case 0x73: case 0x4a: case 0xc6: case 0x5d: case 0x2a: case 0xa9: case 0x6d: case 0xf4: case 0xda: case 0x5e: case 0xfa: case 0x7b: case 0x79: case 0x65: case 0xc7: case 0xe1: case 0x4d: case 0x2b: case 0xab: case 0x0e: case 0x87: case 0x1a: case 0x67: case 0x3d: case 0xf6: case 0x1f: case 0xd6: case 0xb4: case 0x8f: case 0x9c: case 0x48: case 0x5f: case 0x5b: case 0xd4: case 0xf0: case 0x0f: case 0x15: case 0x0b: case 0xb8: case 0x07: case 0x1c: case 0x61: case 0x8e: case 0x86: case 0x2d: case 0x4b: case 0xe3: case 0xc2: case 0xba: case 0xf2: case 0x1e: case 0x39: case 0x38: case 0xd2: case 0x78: case 0x0d: case 0x6b: case 0x3e: case 0x63: case 0x29: case 0x47: case 0x21: case 0xbc: case 0x2f: case 0xb6: case 0x43: case 0x9e: case 0x4e: start=120; rnd=0; break; } break; case 9: switch( direction ) { case 0: { Picture pic = Picture::load( ResourceGroup::land1a, 62 + math::random( 57 ) ); wtile.setPicture( pic ); //wtile.setOriginalImgId( TileHelper::convPicName2Id( pic.name() ) ); wtile.setOriginalImgId( direction ); } break; } break; case 0xff: wtile.setOriginalImgId( direction ); break; } if( start > 0 ) { if( rnd > 0 ) rnd = math::random( 4 ); wtile.setFlag( Tile::tlWater, true ); wtile.setFlag( Tile::tlCoast, true ); Picture pic = Picture::load( ResourceGroup::land1a, start + rnd ); wtile.setPicture( pic ); wtile.setOriginalImgId( imgid::fromResource( pic.name() ) ); } } }