1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/****************************************************************
**
** Attal : Lords of Doom
**
** genericMap.h
** generic class for managing (not graphical) map
**
** Version : $Id: genericMap.h,v 1.16 2008/02/25 21:52:23 lusum Exp $
**
** Author(s) : Pascal Audoux - Cyrille Verrier
**
** Date : 02/08/2000
**
** Licence :
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2, or (at your option)
** any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
****************************************************************/
#ifndef GENERICMAP_H
#define GENERICMAP_H
// generic include files
// include files for QT
#include <QTextStream>
// application specific includes
#include "libCommon/genericCell.h"
#include "libCommon/log.h"
class QString;
class QTextStream;
class PathFinder;
class GenericBase;
class GenericLord;
class GenericDecoration;
/* ------------------------------
* GenericMap
* ------------------------------ */
/** generic class for managing (not graphical) cells */
class GenericMap
{
public:
/** Constructor */
GenericMap();
/** Destructor */
virtual ~GenericMap();
/** Return heigth of the map */
uint getHeight() { return _height; }
/** Return width of the map */
uint getWidth() { return _width; }
/** Return cell of the map */
GenericCell * at( uint i, uint j )
{ return _theCells[i][j]; }
/** */
virtual void newUnknownMap( int h, int w );
virtual void newMapType( int h, int w, int typ );
/** Return the path finder */
PathFinder * getPath() { return _path; }
/** Load a map file */
virtual bool load( QTextStream *, int width, int heigth );
/** Load a map */
virtual bool load( const QString filename );
virtual void changeCell( int i, int j, int typ,
int transition, int typtra, uint decorationGroup, uint decorationItem, uchar diversification );
/** Save a map */
void save( QTextStream * );
/** Clear map */
virtual void clear();
virtual void clearData();
/** Compute the tiles where we can't stop because of this base */
void computeStoppable( GenericBase * base );
/** Compute the tiles where we can't stop because of this building */
void computeStoppable( GenericBuilding * building );
void computeStoppable( GenericDecoration * deco , GenericCell * cell);
/** Compute the tiles where we can't stop because there is a base on it */
void computeStoppable();
static int computeDist( GenericCell * cell1, GenericCell * cell2 );
static inline int computeDist( int row1, int col1 , int row2, int col2 );
bool isPlaceBaseFree( int race , GenericCell * cell);
bool isPlaceBuilFree( int type , GenericCell * cell);
bool isPlaceDecoFree( GenericDecoration * deco , GenericCell * cell);
bool inMap( uint row, uint col );
QList<GenericCell *> giveRadiusCell( GenericCell * cell, int radius );
/** Returns the minimal cost for the next movement of this lord */
int computeMinimalNextCost( GenericLord * lord );
protected:
uint _height, _width;
GenericCell *** _theCells;
PathFinder * _path;
};
#endif // GENERICMAP_H
|