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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef MAP_INFO_H
#define MAP_INFO_H
#include "System/float3.h"
#include "System/float4.h"
#include <string>
#include <vector>
class LuaTable;
class MapParser;
#if !defined(HEADLESS) && !defined(NO_SOUND)
struct EAXSfxProps;
#endif
class CMapInfo
{
public:
/**
* @param mapInfoFile mapinfo file, aka sm3 / smf (full path)
* @param mapName human readable mapname e.g. DeltaSiegeDry
*/
CMapInfo(const std::string& mapInfoFile, const std::string& mapName);
~CMapInfo();
/* The settings are just public members because:
1) it's quite some work to encapsulate all of them, and
2) nothing too bad happens if you modify them, there are no complex
pointer members that really beg for encapsulation.
Instead of encapsulation it is as effective and much easier make the
global mapInfo const, ie. const CMapInfo* mapInfo;
*/
/* Note: this could (should) have been anonymous structures if only MSVC 8
didn't crap out on it. Specifically, it craps out on any class with at
least 1 user defined non-inline constructor and at least 2 anonymous
structures, each with at least 1 object with a constructor in it.
In other words, it probably assigns the same name to each anonymous
structure, and later gets confused by that.
This sample code triggers the problem in MSVC:
class A {
A::A();
struct { std::string s1; } a1;
struct { std::string s2; } a2;
};
A::A() {}
*/
std::string GetStringValue(const std::string& key) const; // can be used before Load()
/** Global settings, ie. from "MAP" section. */
struct map_t {
std::string name; ///< The filename as passed to the constructor.
std::string description; ///< "MAP\\Description"
std::string author;
float hardness; ///< "MAP\\MapHardness"
bool notDeformable;
/** Stores the gravity as a negative number in units/frame^2
(NOT positive units/second^2 as in the mapfile) */
float gravity;
float tidalStrength;
float maxMetal; ///< what metal value 255 in the metal map is worth
float extractorRadius; ///< extraction radius for mines
bool voidWater;
} map;
/** GUI settings (used by CGuiHandler) */
struct gui_t {
bool autoShowMetal;
} gui;
/** settings read from "MAP\ATMOSPHERE" section */
struct atmosphere_t {
float cloudDensity;
float fogStart;
float fogEnd;
float4 fogColor;
float3 skyColor;
float3 skyDir;
float3 sunColor;
float3 cloudColor;
float minWind;
float maxWind;
std::string skyBox;
} atmosphere;
/** settings read from "MAP\SPLATS" section */
struct splats_t {
float4 texScales;
float4 texMults;
} splats;
/** settings read from "MAP\GRASS" section */
struct grass_t {
float bladeWaveScale; //! how strongly wind affects grass-blade waving (if 0, disables vertex animation)
float bladeWidth;
float bladeHeight; //! actual blades will be (bladeHeight + randf(0, bladeHeight)) tall
float bladeAngle;
float4 color;
std::string grassBladeTexName; // defaults to internally-generated texture
} grass;
/** settings read from "MAP\LIGHT" section */
struct light_t {
float4 sunDir; ///< Holds vector for the direction of the sun
float sunOrbitTime;
float sunStartAngle;
float3 groundAmbientColor;
float3 groundSunColor;
float3 groundSpecularColor;
float groundShadowDensity;
float4 unitAmbientColor;
float4 unitSunColor;
float unitShadowDensity;
float3 unitSpecularColor;
float specularExponent;
} light;
/** settings read from "MAP\WATER" section
prefix their name with "Water" to get the TDF variable */
struct water_t {
float repeatX; ///< (calculated default is in IWater)
float repeatY; ///< (calculated default is in IWater)
float damage;
float3 absorb;
float3 baseColor;
float3 minColor;
float3 surfaceColor;
float surfaceAlpha;
float4 planeColor;
float3 diffuseColor;
float3 specularColor;
float ambientFactor;
float diffuseFactor;
float specularFactor;
float specularPower;
float fresnelMin;
float fresnelMax;
float fresnelPower;
float reflDistortion;
float blurBase;
float blurExponent;
float perlinStartFreq;
float perlinLacunarity;
float perlinAmplitude;
float windSpeed;
bool shoreWaves;
bool forceRendering; ///< if false the renderers will render it only if currentMinMapHeight<0
bool hasWaterPlane; ///< true if "MAP\WATER\WaterPlaneColor" is set
unsigned char numTiles;
std::string texture;
std::string foamTexture;
std::string normalTexture;
std::vector<std::string> causticTextures;
} water;
/** SMF specific settings */
struct smf_t {
std::string detailTexName; ///< "MAP\DetailTex"
std::string specularTexName; ///< "MAP\SpecularTex"
std::string splatDistrTexName;
std::string splatDetailTexName;
std::string grassShadingTexName; // defaults to minimap texture
std::string skyReflectModTexName;
std::string detailNormalTexName;
std::string lightEmissionTexName;
std::string parallaxHeightTexName;
float minHeight;
bool minHeightOverride;
float maxHeight;
bool maxHeightOverride;
std::vector<std::string> smtFileNames;
} smf;
/** SM3 specific settings
This is NOT complete, SM3 stores so much in the map settings
that it really isn't a good idea to put them here. */
struct sm3_t {
std::string minimap; ///< "MAP\minimap"
} sm3;
/** Terrain type, there can be 256 of these:
"MAP\TerrainType0" up to "MAP\TerrainType255" */
static const int NUM_TERRAIN_TYPES = 256;
struct TerrainType {
std::string name;
float hardness;
float tankSpeed; ///< "TankMoveSpeed"
float kbotSpeed; ///< "KbotMoveSpeed"
float hoverSpeed; ///< "HoverMoveSpeed"
float shipSpeed; ///< "ShipMoveSpeed"
bool receiveTracks;
};
TerrainType terrainTypes[NUM_TERRAIN_TYPES];
/**
* Sound EFX param structure
*/
#if !defined(HEADLESS) && !defined(NO_SOUND)
EAXSfxProps* efxprops;
#endif
private:
void ReadGlobal();
void ReadGui();
void ReadAtmosphere();
void ReadSplats();
void ReadGrass();
void ReadLight();
void ReadWater();
void ReadSMF();
void ReadSM3();
void ReadTerrainTypes();
void ReadSound();
std::string mapInfoFile;
MapParser* parser; // map parser root table
LuaTable* resRoot; // resources parser root table
};
extern const CMapInfo* mapInfo;
#endif // MAP_INFO_H
|