2013-07-02 08:40:43 +02:00
|
|
|
#pragma once
|
2013-12-20 17:02:46 +01:00
|
|
|
#ifndef _GAMEDATA_HPP_
|
|
|
|
#define _GAMEDATA_HPP_
|
2013-07-02 08:40:43 +02:00
|
|
|
|
2014-06-06 18:04:00 +02:00
|
|
|
#include <engine/RWTypes.hpp>
|
2013-12-20 15:03:32 +01:00
|
|
|
#include <loaders/LoaderIMG.hpp>
|
|
|
|
#include <loaders/TextureLoader.hpp>
|
|
|
|
#include <loaders/LoaderDFF.hpp>
|
|
|
|
#include <loaders/LoaderIDE.hpp>
|
|
|
|
#include <loaders/LoaderIFP.hpp>
|
|
|
|
#include <loaders/WeatherLoader.hpp>
|
|
|
|
#include <objects/VehicleInfo.hpp>
|
|
|
|
#include <data/CollisionModel.hpp>
|
2014-07-28 07:20:39 +02:00
|
|
|
#include <data/GameTexts.hpp>
|
2013-07-02 08:40:43 +02:00
|
|
|
|
2014-08-01 22:04:58 +02:00
|
|
|
#include <audio/MADStream.hpp>
|
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2014-01-03 21:37:21 +01:00
|
|
|
struct DynamicObjectData;
|
2014-06-26 18:55:17 +02:00
|
|
|
struct WeaponData;
|
2013-12-20 17:02:46 +01:00
|
|
|
class GameWorld;
|
2013-09-11 20:23:31 +02:00
|
|
|
class TextureAtlas;
|
2014-07-24 00:57:21 +02:00
|
|
|
class SCMFile;
|
2013-09-11 20:23:31 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-09 06:04:48 +02:00
|
|
|
* @brief Stores simple data about Textures such as transparency flags.
|
|
|
|
*
|
|
|
|
* @todo Covert usage to TextureHandles or something for streaming.
|
2013-09-11 20:23:31 +02:00
|
|
|
*/
|
|
|
|
struct TextureInfo
|
|
|
|
{
|
2013-09-14 04:46:14 +02:00
|
|
|
/// Texture Name
|
|
|
|
GLuint texName;
|
2013-12-20 14:43:12 +01:00
|
|
|
|
|
|
|
/// Transparent flag.
|
|
|
|
bool transparent;
|
2013-09-11 20:23:31 +02:00
|
|
|
|
2013-12-20 14:43:12 +01:00
|
|
|
TextureInfo(GLuint tex, bool t)
|
|
|
|
: texName(tex), transparent(t) {}
|
2013-09-14 04:46:14 +02:00
|
|
|
TextureInfo()
|
2013-12-20 14:43:12 +01:00
|
|
|
: texName(0), transparent(false) {}
|
2013-09-11 20:23:31 +02:00
|
|
|
};
|
2013-08-11 22:50:29 +02:00
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
2014-07-09 06:04:48 +02:00
|
|
|
* @brief Loads and stores all "static" data such as loaded models, handling
|
|
|
|
* information, weather etc.
|
|
|
|
*
|
|
|
|
* @todo Move parsing of one-off data files from this class.
|
|
|
|
* @todo Improve how Loaders and written and used
|
|
|
|
* @todo Considering implementation of streaming data and object handles.
|
2013-07-02 08:06:03 +02:00
|
|
|
*/
|
2013-12-20 17:02:46 +01:00
|
|
|
class GameData
|
2013-07-02 08:06:03 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::string datpath;
|
|
|
|
std::string splash;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2014-06-06 18:04:00 +02:00
|
|
|
* @struct FileInfo
|
2013-07-02 08:06:03 +02:00
|
|
|
* Stores information about a file the engine might want to load
|
|
|
|
*/
|
2014-06-06 18:04:00 +02:00
|
|
|
struct FileInfo
|
2013-07-02 08:06:03 +02:00
|
|
|
{
|
|
|
|
bool archived; /// Is the file inside an IMG or on the filesystem?
|
2014-06-06 13:18:32 +02:00
|
|
|
std::string path; /// Path to the file containing the file.
|
2013-07-02 08:06:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ctor
|
|
|
|
* @param path Path to the root of the game data.
|
|
|
|
*/
|
2014-02-11 06:46:29 +01:00
|
|
|
GameData(const std::string& path = "");
|
2014-08-04 23:21:01 +02:00
|
|
|
~GameData();
|
2013-07-02 08:06:03 +02:00
|
|
|
|
2013-12-20 17:02:46 +01:00
|
|
|
GameWorld* engine;
|
2013-07-06 02:39:54 +02:00
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
|
|
|
* Returns the current platform
|
|
|
|
*/
|
|
|
|
std::string getPlatformString()
|
|
|
|
{
|
|
|
|
return "PC";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the data contained in the given file
|
|
|
|
*/
|
|
|
|
void loadIDE(const std::string& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the parsing of a COL file.
|
|
|
|
*/
|
|
|
|
void loadCOL(const size_t zone, const std::string& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the loading of an IMG's data
|
|
|
|
*/
|
|
|
|
void loadIMG(const std::string& name);
|
|
|
|
|
|
|
|
void loadIPL(const std::string& name);
|
|
|
|
|
2013-07-04 01:23:12 +02:00
|
|
|
void loadCarcols(const std::string& path);
|
2013-07-04 12:00:30 +02:00
|
|
|
|
|
|
|
void loadWeather(const std::string& path);
|
2013-09-15 03:42:35 +02:00
|
|
|
|
|
|
|
void loadHandling(const std::string& path);
|
2014-07-24 00:57:21 +02:00
|
|
|
|
|
|
|
SCMFile* loadSCM(const std::string& path);
|
2014-07-28 07:20:39 +02:00
|
|
|
|
|
|
|
void loadGXT(const std::string& name);
|
2013-07-04 01:23:12 +02:00
|
|
|
|
2013-07-04 12:43:28 +02:00
|
|
|
/**
|
|
|
|
* Loads water level data
|
|
|
|
*/
|
|
|
|
void loadWaterpro(const std::string& path);
|
2013-07-04 18:03:44 +02:00
|
|
|
void loadWater(const std::string& path);
|
2013-07-04 12:43:28 +02:00
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
void load();
|
|
|
|
|
2013-07-02 16:33:15 +02:00
|
|
|
/**
|
|
|
|
* Loads a GTA3.dat file with the name path
|
|
|
|
*/
|
|
|
|
void parseDAT(const std::string& path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load a TXD, or does nothing if it has already been loaded
|
|
|
|
*/
|
2014-06-06 13:18:32 +02:00
|
|
|
void loadTXD(const std::string& name, bool async = false);
|
|
|
|
|
2013-07-02 16:33:15 +02:00
|
|
|
/**
|
|
|
|
* Attempts to load a DFF or does nothing if is already loaded
|
|
|
|
*/
|
2014-06-06 13:18:32 +02:00
|
|
|
void loadDFF(const std::string& name, bool async = false);
|
2013-07-26 07:40:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads an IFP file containing animations
|
|
|
|
*/
|
|
|
|
void loadIFP(const std::string& name);
|
2013-07-02 16:33:15 +02:00
|
|
|
|
2014-01-03 21:37:21 +01:00
|
|
|
/**
|
|
|
|
* Loads data from an object definition dat.
|
|
|
|
*/
|
|
|
|
void loadDynamicObjects(const std::string& name);
|
2014-06-06 13:18:32 +02:00
|
|
|
|
2014-06-26 18:55:17 +02:00
|
|
|
/**
|
|
|
|
* Loads weapon.dat
|
|
|
|
*/
|
|
|
|
void loadWeaponDAT(const std::string& name);
|
|
|
|
|
2014-08-01 22:04:58 +02:00
|
|
|
bool loadAudio(MADStream &music, const std::string& name);
|
|
|
|
|
2014-08-01 23:03:00 +02:00
|
|
|
void loadSplash(const std::string& name);
|
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
2014-06-06 13:18:32 +02:00
|
|
|
* Returns a pointer to the named file if it is available,
|
|
|
|
* the memory must be freed by the caller.
|
2013-07-02 08:06:03 +02:00
|
|
|
* @param name the filename in the archive
|
2014-06-06 13:18:32 +02:00
|
|
|
* @return pointer to the data, NULL if it is not available
|
|
|
|
*/
|
|
|
|
char* openFile(const std::string& name);
|
2014-07-28 03:27:55 +02:00
|
|
|
FileHandle openFile2(const std::string& name);
|
2014-06-06 13:18:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief loadFile Marks a file as open, and opens it.
|
|
|
|
* @param name
|
|
|
|
* @return
|
2013-07-02 08:06:03 +02:00
|
|
|
*/
|
|
|
|
char* loadFile(const std::string& name);
|
2013-09-11 20:23:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getAtlas Returns atlas i, creating it if the situation calls for it.
|
|
|
|
* "the situation" being the last atlas has more than 0 textures packed.
|
|
|
|
* @param i
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
TextureAtlas* getAtlas(size_t i);
|
2013-07-02 08:06:03 +02:00
|
|
|
|
2013-07-02 16:33:15 +02:00
|
|
|
/**
|
|
|
|
* Files that have been loaded previously
|
|
|
|
*/
|
|
|
|
std::map<std::string, bool> loadedFiles;
|
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
|
|
|
* Maps the paths in GTA3.dat to the real paths
|
|
|
|
*/
|
|
|
|
std::map<std::string, std::string> iplLocations;
|
2013-07-02 14:49:20 +02:00
|
|
|
std::map<std::string, std::string> ideLocations;
|
2013-07-02 08:06:03 +02:00
|
|
|
|
|
|
|
/**
|
2014-06-06 13:18:32 +02:00
|
|
|
* Maps file names to data about the file.
|
2013-07-02 08:06:03 +02:00
|
|
|
*/
|
2014-06-06 18:04:00 +02:00
|
|
|
std::map<std::string, FileInfo> _knownFiles;
|
2013-07-02 08:06:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Map of loaded archives
|
|
|
|
*/
|
|
|
|
std::map<std::string, LoaderIMG> archives;
|
|
|
|
|
2013-07-04 01:23:12 +02:00
|
|
|
/**
|
|
|
|
* The vehicle colour palettes
|
|
|
|
*/
|
2014-08-22 15:29:46 +02:00
|
|
|
std::vector<glm::u8vec3> vehicleColours;
|
2013-07-04 01:23:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The vehicle colours for each vehicle type
|
|
|
|
*/
|
|
|
|
std::map<std::string, std::vector<std::pair<size_t,size_t>>> vehiclePalettes;
|
2013-09-15 03:42:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Vehicle information
|
|
|
|
*/
|
2014-02-28 12:23:51 +01:00
|
|
|
std::map<std::string, VehicleInfoHandle> vehicleInfo;
|
2013-07-04 01:23:12 +02:00
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
|
|
|
* Texture Loader
|
|
|
|
*/
|
|
|
|
TextureLoader textureLoader;
|
2013-07-04 12:00:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Weather Loader
|
|
|
|
*/
|
|
|
|
WeatherLoader weatherLoader;
|
2014-06-06 13:18:32 +02:00
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
/**
|
|
|
|
* Loaded models
|
|
|
|
*/
|
2014-06-06 13:18:32 +02:00
|
|
|
std::map<std::string, ModelHandle*> models;
|
2013-09-11 20:23:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loaded Textures and their atlas entries.
|
|
|
|
*/
|
2014-06-18 07:59:24 +02:00
|
|
|
std::map<std::pair<std::string, std::string>, TextureInfo> textures;
|
2013-09-11 20:23:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Texture atlases.
|
|
|
|
*/
|
|
|
|
std::vector<TextureAtlas*> atlases;
|
|
|
|
|
2013-07-26 07:40:21 +02:00
|
|
|
/**
|
|
|
|
* Loaded Animations
|
|
|
|
*/
|
2013-08-11 22:50:29 +02:00
|
|
|
AnimationSet animations;
|
2013-07-26 07:40:21 +02:00
|
|
|
|
2013-07-21 06:12:27 +02:00
|
|
|
/**
|
2013-11-17 17:06:38 +01:00
|
|
|
* CollisionModel data.
|
2013-07-21 06:12:27 +02:00
|
|
|
*/
|
2013-11-17 16:34:24 +01:00
|
|
|
std::map<std::string, std::unique_ptr<CollisionModel>> collisions;
|
2013-07-21 06:12:27 +02:00
|
|
|
|
2014-01-03 21:37:21 +01:00
|
|
|
/**
|
|
|
|
* DynamicObjectData
|
|
|
|
*/
|
|
|
|
std::map<std::string, std::shared_ptr<DynamicObjectData>> dynamicObjectData;
|
|
|
|
|
2014-06-26 18:55:17 +02:00
|
|
|
std::map<std::string, std::shared_ptr<WeaponData>> weaponData;
|
2014-06-08 20:04:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @struct WaterArea
|
|
|
|
* Stores Water Rectangle Information
|
|
|
|
*/
|
|
|
|
struct WaterArea
|
|
|
|
{
|
|
|
|
float height;
|
|
|
|
float xLeft, yBottom;
|
|
|
|
float xRight, yTop;
|
|
|
|
};
|
|
|
|
|
2013-07-04 18:03:44 +02:00
|
|
|
/**
|
2014-06-08 20:04:47 +02:00
|
|
|
* Water Areas
|
2013-07-04 18:03:44 +02:00
|
|
|
*/
|
2014-06-08 20:04:47 +02:00
|
|
|
std::vector<WaterArea> waterBlocks;
|
2013-07-04 18:03:44 +02:00
|
|
|
|
2013-07-04 12:43:28 +02:00
|
|
|
/**
|
|
|
|
* Water heights
|
|
|
|
*/
|
|
|
|
float waterHeights[48];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Visible water heights
|
|
|
|
*/
|
|
|
|
uint8_t visibleWater[64*64];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The "real" water heights
|
|
|
|
*/
|
|
|
|
uint8_t realWater[128*128];
|
2014-06-13 22:54:17 +02:00
|
|
|
|
|
|
|
int getWaterIndexAt(const glm::vec3& ws) const;
|
2014-06-14 19:48:14 +02:00
|
|
|
float getWaveHeightAt(const glm::vec3& ws) const;
|
2014-07-28 07:20:39 +02:00
|
|
|
|
|
|
|
GameTexts texts;
|
2013-07-02 08:06:03 +02:00
|
|
|
};
|
|
|
|
|
2013-07-24 02:44:08 +02:00
|
|
|
#endif
|