2004-05-29 13:56:24 -07:00
|
|
|
#ifndef _MAPREADER_H
|
|
|
|
|
#define _MAPREADER_H
|
|
|
|
|
|
|
|
|
|
#include "MapIO.h"
|
2005-08-12 10:06:53 -07:00
|
|
|
#include "lib/res/handle.h"
|
2006-06-01 19:10:27 -07:00
|
|
|
#include "ps/CStr.h"
|
2004-05-29 13:56:24 -07:00
|
|
|
#include "LightEnv.h"
|
2006-06-01 19:10:27 -07:00
|
|
|
#include "ps/FileUnpacker.h"
|
2004-05-29 13:56:24 -07:00
|
|
|
|
|
|
|
|
class CObjectEntry;
|
2004-07-31 08:57:18 -07:00
|
|
|
class CTerrain;
|
|
|
|
|
class CUnitManager;
|
2006-06-11 00:03:59 -07:00
|
|
|
class WaterManager;
|
2004-07-31 08:57:18 -07:00
|
|
|
class CLightEnv;
|
2006-03-21 12:55:45 -08:00
|
|
|
class CCamera;
|
2004-05-29 13:56:24 -07:00
|
|
|
|
2005-05-03 14:42:09 -07:00
|
|
|
class CXMLReader;
|
|
|
|
|
|
2004-05-29 13:56:24 -07:00
|
|
|
class CMapReader : public CMapIO
|
|
|
|
|
{
|
2005-05-10 20:07:08 -07:00
|
|
|
friend class CXMLReader;
|
|
|
|
|
|
2004-05-29 13:56:24 -07:00
|
|
|
public:
|
|
|
|
|
// constructor
|
|
|
|
|
CMapReader();
|
|
|
|
|
// LoadMap: try to load the map from given file; reinitialise the scene to new data if successful
|
2006-06-11 00:03:59 -07:00
|
|
|
void LoadMap(const char* filename, CTerrain *pTerrain, CUnitManager *pUnitMan,
|
|
|
|
|
WaterManager* pWaterMan, CLightEnv *pLightEnv, CCamera *pCamera);
|
2004-05-29 13:56:24 -07:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// UnpackTerrain: unpack the terrain from the input stream
|
2005-05-04 16:12:46 -07:00
|
|
|
int UnpackTerrain();
|
2004-05-29 13:56:24 -07:00
|
|
|
// UnpackObjects: unpack world objects from the input stream
|
2005-03-22 13:00:56 -08:00
|
|
|
void UnpackObjects();
|
2004-05-29 13:56:24 -07:00
|
|
|
// UnpackObjects: unpack lighting parameters from the input stream
|
2005-03-22 13:00:56 -08:00
|
|
|
void UnpackLightEnv();
|
2004-05-29 13:56:24 -07:00
|
|
|
|
2005-05-03 14:42:09 -07:00
|
|
|
// UnpackMap: unpack the given data from the raw data stream into local variables
|
|
|
|
|
int UnpackMap();
|
|
|
|
|
|
2004-05-29 13:56:24 -07:00
|
|
|
// ApplyData: take all the input data, and rebuild the scene from it
|
2005-05-03 14:42:09 -07:00
|
|
|
int ApplyData();
|
2004-05-29 13:56:24 -07:00
|
|
|
|
2005-01-12 06:31:47 -08:00
|
|
|
// ReadXML: read some other data (entities, etc) in XML format
|
2005-05-03 14:42:09 -07:00
|
|
|
int ReadXML();
|
2005-03-22 13:00:56 -08:00
|
|
|
|
|
|
|
|
// clean up everything used during delayed load
|
2005-05-03 14:42:09 -07:00
|
|
|
int DelayLoadFinished();
|
2005-01-12 06:31:47 -08:00
|
|
|
|
2004-05-29 13:56:24 -07:00
|
|
|
// size of map
|
|
|
|
|
u32 m_MapSize;
|
|
|
|
|
// heightmap for map
|
|
|
|
|
std::vector<u16> m_Heightmap;
|
|
|
|
|
// list of terrain textures used by map
|
|
|
|
|
std::vector<Handle> m_TerrainTextures;
|
|
|
|
|
// tile descriptions for each tile
|
|
|
|
|
std::vector<STileDesc> m_Tiles;
|
|
|
|
|
// list of object types used by map
|
2005-03-19 03:55:27 -08:00
|
|
|
std::vector<CStr> m_ObjectTypes;
|
2004-05-29 13:56:24 -07:00
|
|
|
// descriptions for each objects
|
|
|
|
|
std::vector<SObjectDesc> m_Objects;
|
|
|
|
|
// lightenv stored in file
|
|
|
|
|
CLightEnv m_LightEnv;
|
2005-03-22 13:00:56 -08:00
|
|
|
|
|
|
|
|
// state latched by LoadMap and held until DelayedLoadFinished
|
|
|
|
|
CFileUnpacker unpacker;
|
2005-05-03 14:42:09 -07:00
|
|
|
CTerrain* pTerrain;
|
|
|
|
|
CUnitManager* pUnitMan;
|
2006-06-11 00:03:59 -07:00
|
|
|
WaterManager* pWaterMan;
|
2005-05-03 14:42:09 -07:00
|
|
|
CLightEnv* pLightEnv;
|
2006-03-21 12:55:45 -08:00
|
|
|
CCamera* pCamera;
|
2005-03-22 13:00:56 -08:00
|
|
|
CStr filename_xml;
|
2005-05-03 14:42:09 -07:00
|
|
|
|
2005-05-04 16:12:46 -07:00
|
|
|
// UnpackTerrain generator state
|
2005-05-10 20:07:08 -07:00
|
|
|
u32 cur_terrain_tex;
|
|
|
|
|
u32 num_terrain_tex;
|
2005-05-04 16:12:46 -07:00
|
|
|
|
2005-05-03 14:42:09 -07:00
|
|
|
CXMLReader* xml_reader;
|
2004-05-29 13:56:24 -07:00
|
|
|
};
|
|
|
|
|
|
2004-06-02 08:03:17 -07:00
|
|
|
#endif
|