本文整理汇总了C++中PlayerCityPtr::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerCityPtr::resize方法的具体用法?C++ PlayerCityPtr::resize怎么用?C++ PlayerCityPtr::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerCityPtr
的用法示例。
在下文中一共展示了PlayerCityPtr::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PKWareInputStream
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);
//.........这里部分代码省略.........
示例2: THROW
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 ];
//.........这里部分代码省略.........