_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Member Functions | Public Attributes | List of all members
CTileset Class Reference

Tileset definition. More...

#include <tileset.h>

Public Member Functions

unsigned int getTileCount () const
 
const PixelSizegetPixelTileSize () const
 
unsigned getRemovedRockTile () const
 
unsigned getRemovedTreeTile () const
 
unsigned getBottomOneTreeTile () const
 
unsigned getTopOneTreeTile () const
 
unsigned getMidOneTreeTile () const
 

Public Attributes

std::string Name
 
std::string ImageFile
 Nice name to display. More...
 
std::vector< CTiletiles
 File containing image data. More...
 
std::vector< unsigned char > TileTypeTable
 

script_tileset.cpp - The tileset ccl functions.

void parse (lua_State *l)
 
void buildTable (lua_State *l)
 
int parseTilesetTileFlags (lua_State *l, int *back, int *j)
 

tileset.cpp - The tileset.

void clear ()
 
unsigned int getDefaultTileIndex () const
 
unsigned int getDefaultWoodTileIndex () const
 
bool isAWallTile (unsigned tile) const
 
bool isARaceWallTile (unsigned tile, bool human) const
 
bool isAWoodTile (unsigned tile) const
 
bool isARockTile (unsigned tile) const
 
unsigned getWallDirection (int tileIndex, bool human) const
 
unsigned getHumanWallTileIndex (int dirFlag) const
 
unsigned getOrcWallTileIndex (int dirFlag) const
 
unsigned getHumanWallTileIndex_broken (int dirFlag) const
 
unsigned getOrcWallTileIndex_broken (int dirFlag) const
 
unsigned getHumanWallTileIndex_destroyed (int dirFlag) const
 
unsigned getOrcWallTileIndex_destroyed (int dirFlag) const
 
unsigned int getSolidTerrainCount () const
 
const std::string & getTerrainName (int solidTerrainIndex) const
 
int findTileIndexByTile (unsigned int tile) const
 
unsigned int getTileNumber (int basic, bool random, bool filler) const
 
void fillSolidTiles (std::vector< unsigned int > *solidTiles) const
 
unsigned getQuadFromTile (unsigned int tile) const
 
int getTileBySurrounding (unsigned short type, int up, int right, int bottom, int left) const
 
int tileFromQuad (unsigned fixed, unsigned quad) const
 
bool isEquivalentTile (unsigned int tile1, unsigned int tile2) const
 
int findTileIndex (unsigned char baseTerrain, unsigned char mixTerrain=0) const
 

Detailed Description

Tileset definition.

#include "tileset.h"

This structure contains information about the tileset of the map. It defines the look and properties of the tiles. Currently only one tileset per map is supported. In the future it is planned to support multiple tilesets on the same map. Also it is planned to support animated tiles.

The tileset structure members:

CTileset::Name

Long name of the tileset. Can be used by the level editor.

CTileset::ImageFile

Name of the graphic file, containing all tiles.

CTileset::Table

Table to map the abstract level (PUD) tile numbers, to tile
numbers in the graphic file (CTileset::File).
FE. 16 (solid light water) in pud to 328 in png.

CTileset::Flags

Table of the tile flags used by the editor.
@see CMapField::Flags

CTileset::solidTerrainTypes

Index to name of the basic tile type. FE. "light-water".
If the index is 0, the tile is not used.

CTileset::MixedNameTable

Index to name of the mixed tile type. FE. "light-water".
If this index is 0, the tile is a solid tile.
@see CTileset::TileNames

CTileset::TileTypeTable

Lookup table of the tile type. Maps the graphic file tile
number back to a tile type (::TileTypeWood, ::TileTypeWater,
...)

@note The creation of this table is currently hardcoded in
the engine. It should be calculated from the flags in the
tileset configuration. And it is created for the map
and not for the tileset.

@note I'm not sure if this table is needed in the future.

@see TileType.

CTileset::topOneTreeTile

The tile number of tile only containing the top part of a tree.
Is created on the map by lumber chopping.

CTileset::midOneTreeTile

The tile number of tile only containing the connection of
the top part to the bottom part of tree.
Is created on the map by lumber chopping.

CTileset::botOneTreeTile

The tile number of tile only containing the bottom part of a
tree. Is created on the map by lumber chopping.

CTileset::removedTreeTile

The tile number of the tile placed where trees are removed.
Is created on the map by lumber chopping.

CTilset::woodTable[20]

Table for wood removable. This table contains the tile which
is placed after a tree removement, depending on the surrounding.

CTileset::mixedLookupTable[] Table for finding what part of the tile contains wood/rock, and which part is grass or bare ground.

CTileset::topOneRockTile

The tile number of tile only containing the top part of a rock.
Is created on the map by destroying rocks.

CTileset::midOneRockTile

The tile number of tile only containing the connection of
the top part to the bottom part of a rock.
Is created on the map by destroying rocks.

CTileset::botOneRockTile

The tile number of tile only containing the bottom part of a
rock. Is created on the map by destroying rocks.

CTileset::removedRockTile

The tile number of the tile placed where rocks are removed.
Is created on the map by destroying rocks.

CTileset::rockTable[20]

Table for rock removable. Depending on the surrinding this
table contains the new tile to be placed.

@todo Johns: I don't think this table or routines look correct.
But they work correct.

CTileset::humanWallTable

Table of human wall tiles, index depends on the surroundings.

CTileset::orcWallTable

Table of orc wall tiles, index depends on the surroundings.

Member Function Documentation

◆ buildTable()

void CTileset::buildTable ( lua_State *  l)

◆ clear()

void CTileset::clear ( )

◆ fillSolidTiles()

void CTileset::fillSolidTiles ( std::vector< unsigned int > *  solidTiles) const

◆ findTileIndex()

int CTileset::findTileIndex ( unsigned char  baseTerrain,
unsigned char  mixTerrain = 0 
) const

◆ findTileIndexByTile()

int CTileset::findTileIndexByTile ( unsigned int  tile) const

◆ getBottomOneTreeTile()

unsigned CTileset::getBottomOneTreeTile ( ) const
inline

◆ getDefaultTileIndex()

unsigned int CTileset::getDefaultTileIndex ( ) const

◆ getDefaultWoodTileIndex()

unsigned int CTileset::getDefaultWoodTileIndex ( ) const

◆ getHumanWallTileIndex()

unsigned CTileset::getHumanWallTileIndex ( int  dirFlag) const

◆ getHumanWallTileIndex_broken()

unsigned CTileset::getHumanWallTileIndex_broken ( int  dirFlag) const

◆ getHumanWallTileIndex_destroyed()

unsigned CTileset::getHumanWallTileIndex_destroyed ( int  dirFlag) const

◆ getMidOneTreeTile()

unsigned CTileset::getMidOneTreeTile ( ) const
inline

◆ getOrcWallTileIndex()

unsigned CTileset::getOrcWallTileIndex ( int  dirFlag) const

◆ getOrcWallTileIndex_broken()

unsigned CTileset::getOrcWallTileIndex_broken ( int  dirFlag) const

◆ getOrcWallTileIndex_destroyed()

unsigned CTileset::getOrcWallTileIndex_destroyed ( int  dirFlag) const

◆ getPixelTileSize()

const PixelSize& CTileset::getPixelTileSize ( ) const
inline

◆ getQuadFromTile()

unsigned CTileset::getQuadFromTile ( unsigned int  tile) const

Get quad from tile.

A quad is a 32 bit value defining the content of the tile.

A tile is split into 4 parts, the basic tile type of this part is stored as 8bit value in the quad.

ab cd -> abcd

If the tile is 100% light grass(0x05) the value is 0x05050505. If the tile is 3/4 light grass and dark grass(0x06) in upper left corner the value is 0x06050505.

◆ getRemovedRockTile()

unsigned CTileset::getRemovedRockTile ( ) const
inline

◆ getRemovedTreeTile()

unsigned CTileset::getRemovedTreeTile ( ) const
inline

◆ getSolidTerrainCount()

unsigned int CTileset::getSolidTerrainCount ( ) const

◆ getTerrainName()

const std::string & CTileset::getTerrainName ( int  solidTerrainIndex) const

◆ getTileBySurrounding()

int CTileset::getTileBySurrounding ( unsigned short  type,
int  up,
int  right,
int  bottom,
int  left 
) const

◆ getTileCount()

unsigned int CTileset::getTileCount ( ) const
inline

◆ getTileNumber()

unsigned int CTileset::getTileNumber ( int  basic,
bool  random,
bool  filler 
) const

Get tile number.

Parameters
basicBasic tile number
randomReturn random tile
fillerGet a decorated tile.
Returns
Tile index number.
Todo:
FIXME: Solid tiles are here still hardcoded.

◆ getTopOneTreeTile()

unsigned CTileset::getTopOneTreeTile ( ) const
inline

◆ getWallDirection()

unsigned CTileset::getWallDirection ( int  tileIndex,
bool  human 
) const

◆ isARaceWallTile()

bool CTileset::isARaceWallTile ( unsigned  tile,
bool  human 
) const

◆ isARockTile()

bool CTileset::isARockTile ( unsigned  tile) const

◆ isAWallTile()

bool CTileset::isAWallTile ( unsigned  tile) const

◆ isAWoodTile()

bool CTileset::isAWoodTile ( unsigned  tile) const

◆ isEquivalentTile()

bool CTileset::isEquivalentTile ( unsigned int  tile1,
unsigned int  tile2 
) const

◆ parse()

void CTileset::parse ( lua_State *  l)

◆ parseTilesetTileFlags()

int CTileset::parseTilesetTileFlags ( lua_State *  l,
int *  back,
int *  j 
)

Parse the flag section of a tile definition.

Parameters
lLua state.
backpointer for the flags (return).
jpointer for the location in the array. in and out
Returns
index for basename, if the name this tile should be available as a different basename, or 0

◆ tileFromQuad()

int CTileset::tileFromQuad ( unsigned  fixed,
unsigned  quad 
) const

Get tile from quad.

Parameters
fixedPart can't be changed.
quadQuad of the tile type.
Returns
Best matching tile.

Member Data Documentation

◆ ImageFile

std::string CTileset::ImageFile

Nice name to display.

◆ Name

std::string CTileset::Name

◆ tiles

std::vector<CTile> CTileset::tiles

File containing image data.

◆ TileTypeTable

std::vector<unsigned char> CTileset::TileTypeTable

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.