本文整理汇总了C++中dfhack::Maps::WriteTileTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ Maps::WriteTileTypes方法的具体用法?C++ Maps::WriteTileTypes怎么用?C++ Maps::WriteTileTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfhack::Maps
的用法示例。
在下文中一共展示了Maps::WriteTileTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
{
for (uint32_t y=0;y<16;++y)
{
if ( (pattern[x][y]>1) || (roof && pattern[x][y]) )
{
tp = getTileRow(block.tiletypes[x][y]);
d = &block.designation[x][y];
//Only modify this level if it's 'empty'
if ( EMPTY != tp->shape && RAMP_TOP != tp->shape && STAIR_DOWN != tp->shape && DFHack::TILE_STREAM_TOP != tp->special)
{
continue;
}
//Need a floor for empty space.
if (reveal)
{
d->bits.hidden = 0; //topblock.designation[x][y].bits.hidden;
}
//Always clear the dig designation.
d->bits.dig = designation_no;
//unlock fluids, so they fall down the pit.
d->bits.flow_forbid = d->bits.liquid_static=0;
block.blockflags.bits.liquid_1 = block.blockflags.bits.liquid_2 = 1;
//Remove aquifer, to prevent bugginess
d->bits.water_table=0;
//Set the tile.
block.tiletypes[x][y] = cap + rand()%4;
}
}
}
//Write the block.
Mapz->WriteBlockFlags(bx,by,bz, block.blockflags );
Mapz->WriteDesignations(bx,by,bz, &block.designation );
Mapz->WriteTileTypes(bx,by,bz, &block.tiletypes );
Mapz->WriteDirtyBit(bx,by,bz,1);
}
///////////////////////////////////////////////////////////////////////////////////////////////
//All levels in between.
int done=0;
uint32_t t,v;
int32_t z = bz-1;
int32_t bottom = max(0,bz-pitdepth-1);
assert( bottom>=0 && bottom<=bz );
for ( ; !done && z>=bottom ; --z)
{
int watercount=0;
int magmacount=0;
int moltencount=0;
int rockcount=0;
int veincount=0;
int emptycount=0;
int hellcount=0;
int templecount=0;
int adamcount=0;
int featcount=0;
int tpat;
cout << z << endl;
assert( Mapz->isValidBlock(bx,by,z) );
if (!Mapz->ReadBlock40d( bx, by, z , &block ))
{
cout << "Bad block! " << bx << "," << by << "," << z << endl;
}
//Pre-process this z-level, to get some tile statistics.
示例2: main
//.........这里部分代码省略.........
BrushClass = DFHack::tileshape_invalid ;
BrushMat = DFHack::tilematerial_invalid;
BrushType = atol( command.c_str()+1 );
cout << "Tile brush type set to:" << endl;
printtiletype(BrushType);
break;
case 'q':
end = true;
cout << "Bye!" << endl;
break;
case 'd':
{
count=0;
cout << "Beginning to draw at cursor." << endl << "Press any key to stop drawing." << endl;
//DF->Suspend();
kbhit(); //throw away, just to be sure.
for(;;)
{
if(!Maps->Start())
{
cout << "Can't see any DF map loaded." << endl;
break;
}
if(!Gui->getCursorCoords(x,y,z))
{
cout << "Can't get cursor coords! Make sure you have a cursor active in DF." << endl;
break;
}
//cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
tx=x%16; ty=y%16;
if(!Maps->isValidBlock(x/16,y/16,z))
{
cout << "Invalid block." << endl;
break;
}
//Read the tiles.
dirty=0;
Maps->ReadTileTypes((x/16),(y/16),z, &tiles);
oldT = tiles[tx][ty];
newT = -1;
if( 0<BrushType ){
//Explicit tile type set. Trust the user.
newT = BrushType;
}else if( 0==BrushMat && 0==BrushClass ){
//Special case, Empty Air.
newT = 32;
}else if( BrushMat>=0 && BrushClass>=0 && ( BrushClass != DFHack::tileTypeTable[oldT].shape || BrushMat != DFHack::tileTypeTable[oldT].material) ){
//Set tile material and class
newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tileTypeTable[oldT].variant , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction );
if(newT<0) newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tilevariant_invalid, DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction );
if(newT<0) newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , (uint32_t)0 );
}else if( BrushMat<0 && BrushClass>=0 && BrushClass != DFHack::tileTypeTable[oldT].shape ){
//Set current tile class only, as accurately as can be expected
newT = DFHack::findSimilarTileType(oldT,BrushClass);
}else if( BrushClass<0 && BrushMat>=0 && BrushMat != DFHack::tileTypeTable[oldT].material ){
//Set current tile material only
newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tileTypeTable[oldT].variant , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction );
if(newT<0) newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction );
if(newT<0) newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , (uint32_t)0 );
}
//If no change, skip it (couldn't find a good tile type, or already what we want)
if ( newT > 0 && oldT != newT ){
//Set new tile type
tiles[tx][ty] = newT;
dirty=-1;
}
//If anything was changed, write it all.
if (dirty)
{
//Maps->WriteDesignations(x/16,y/16,z/16, &designations);
Maps->WriteTileTypes(x/16,y/16,z, &tiles);
printf("(%4d,%4d,%4d)",x,y,z);
++count;
}
Maps->Finish();
Sleep(10);
if( kbhit() ) break;
}
cin.clear();
cout << endl << count << " tiles were drawn." << endl << "Drawing halted. Entering command mode." << endl;
}
continue;
break;
default:
cout << "Unknown command: " << command << endl;
}
}
DF->Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}
示例3: tubefill
DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string> & params)
{
uint32_t x_max,y_max,z_max;
DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
int32_t oldT, newT;
uint64_t count = 0;
int dirty=0;
for(int i = 0; i < params.size();i++)
{
if(params[i] == "help" || params[i] == "?")
{
c->con.print("Replenishes mined out adamantine and hollow adamantine tubes.\n"
"May cause !!FUN!!\n"
);
return CR_OK;
}
}
c->Suspend();
DFHack::Maps *Mapz = c->getMaps();
// init the map
if (!Mapz->Start())
{
c->con.printerr("Can't init map.\n");
c->Resume();
return CR_FAILURE;
}
Mapz->getSize(x_max,y_max,z_max);
if(!Mapz->StartFeatures())
{
c->con.printerr("Can't get map features.\n");
c->Resume();
return CR_FAILURE;
}
// walk the map
for (uint32_t x = 0; x< x_max;x++)
{
for (uint32_t y = 0; y< y_max;y++)
{
for (uint32_t z = 0; z< z_max;z++)
{
DFHack::t_feature * locf = 0;
DFHack::t_feature * glof = 0;
if (Mapz->ReadFeatures(x,y,z,&locf,&glof))
{
// we're looking for addy tubes
if(!locf) continue;
if(locf->type != DFHack::feature_Adamantine_Tube) continue;
dirty=0;
Mapz->ReadDesignations(x,y,z, &designations);
Mapz->ReadTileTypes(x,y,z, &tiles);
for (uint32_t ty=0;ty<16;++ty)
{
for (uint32_t tx=0;tx<16;++tx)
{
if(!designations[tx][ty].bits.feature_local) continue;
oldT = tiles[tx][ty];
if ( DFHack::tileShape(oldT) != DFHack::WALL )
{
//Current tile is not a wall.
//Set current tile, as accurately as can be expected
//newT = DFHack::findSimilarTileType(oldT,DFHack::WALL);
newT = DFHack::findTileType( DFHack::WALL, DFHack::FEATSTONE, DFHack::tilevariant_invalid, DFHack::TILE_NORMAL, DFHack::TileDirection() );
//If no change, skip it (couldn't find a good tile type)
if ( oldT == newT) continue;
//Set new tile type, clear designation
tiles[tx][ty] = newT;
dirty=1;
++count;
}
}
}
//If anything was changed, write it all.
if (dirty)
{
Mapz->WriteTileTypes(x,y,z, &tiles);
}
}
}
}
}
c->Resume();
c->con.print("Found and changed %d tiles.\n", count);
return CR_OK;
}
示例4: main
int main (void)
{
bool temporary_terminal = TemporaryTerminal();
uint32_t x_max,y_max,z_max;
DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
int32_t oldT, newT;
uint64_t count = 0;
int dirty=0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
//Init
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
DFHack::Maps *Mapz = DF->getMaps();
// init the map
if (!Mapz->Start())
{
cerr << "Can't init map." << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
Mapz->getSize(x_max,y_max,z_max);
if(!Mapz->StartFeatures())
{
cerr << "Can't get features." << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
// walk the map
for (uint32_t x = 0; x< x_max;x++)
{
for (uint32_t y = 0; y< y_max;y++)
{
for (uint32_t z = 0; z< z_max;z++)
{
DFHack::t_feature * locf = 0;
DFHack::t_feature * glof = 0;
if (Mapz->ReadFeatures(x,y,z,&locf,&glof))
{
// we're looking for addy tubes
if(!locf) continue;
if(locf->type != DFHack::feature_Adamantine_Tube) continue;
dirty=0;
Mapz->ReadDesignations(x,y,z, &designations);
Mapz->ReadTileTypes(x,y,z, &tiles);
for (uint32_t ty=0;ty<16;++ty)
{
for (uint32_t tx=0;tx<16;++tx)
{
if(!designations[tx][ty].bits.feature_local) continue;
oldT = tiles[tx][ty];
if ( DFHack::tileShape(oldT) != DFHack::WALL )
{
//Current tile is not a wall.
//Set current tile, as accurately as can be expected
//newT = DFHack::findSimilarTileType(oldT,DFHack::WALL);
newT = DFHack::findTileType( DFHack::WALL, DFHack::FEATSTONE, DFHack::tilevariant_invalid, DFHack::TILE_NORMAL, DFHack::TileDirection() );
//If no change, skip it (couldn't find a good tile type)
if ( oldT == newT) continue;
//Set new tile type, clear designation
tiles[tx][ty] = newT;
dirty=1;
++count;
}
}
}
//If anything was changed, write it all.
if (dirty)
{
Mapz->WriteTileTypes(x,y,z, &tiles);
}
}
}
}
}
DF->Detach();
cout << "Found and changed " << count << " tiles." << endl;
if(temporary_terminal)
//.........这里部分代码省略.........