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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef MAP_INFO_H
#define MAP_INFO_H
#include "MapParser.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:
/** Terrain type, there can be 256 of these:
"MAP\TerrainType0" up to "MAP\TerrainType255" */
static constexpr int NUM_TERRAIN_TYPES = 256;
/**
* @param mapFileName full path to map-file aka SMF
* @param mapHumanName human-readable mapname e.g. DeltaSiegeDry
*/
CMapInfo(const std::string& mapInfoFile, const std::string& mapHumanName);
~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() {}
*/
/** Global settings, ie. from "MAP" section. */
struct map_t {
std::string name; ///< The human name as passed to the constructor.
std::string description; ///< "MAP\\Description"
std::string author;
float hardness; ///< "MAP\\MapHardness"
float gravity; ///< negative elmos/frame^2 (NOT positive elmos/second^2 as in mapfile)
float tidalStrength;
float maxMetal; ///< what metal value 255 in the metal map is worth
float extractorRadius; ///< extraction radius for mines
float voidAlphaMin;
bool notDeformable;
bool voidWater;
bool voidGround;
} map;
/** GUI settings (used by CGuiHandler) */
struct gui_t {
bool autoShowMetal;
} gui;
/** settings read from "MAP\ATMOSPHERE" section */
struct atmosphere_t {
float fluidDensity; ///< in kg/m^3
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;
int maxStrawsPerTurf;
float3 color;
std::string bladeTexName; // defaults to internally-generated texture
} grass;
/** settings read from "MAP\LIGHT" section */
struct light_t {
float4 sunDir; ///< .xyz is direction vector; .w is intensity
float3 groundAmbientColor;
float3 groundDiffuseColor;
float3 groundSpecularColor;
float groundShadowDensity;
float4 modelAmbientColor;
float4 modelDiffuseColor;
float modelShadowDensity;
float3 modelSpecularColor;
float specularExponent;
} light;
/** settings read from "MAP\WATER" section
prefix their name with "Water" to get the TDF variable */
struct water_t {
float fluidDensity; ///< in kg/m^3
float repeatX; ///< (calculated default is in IWater)
float repeatY; ///< (calculated default is in IWater)
float damage; ///< scaled by (UNIT_SLOWUPDATE_RATE / GAME_SPEED)
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 blendNormalsTexName;
std::string lightEmissionTexName;
std::string parallaxHeightTexName;
// Contains the splatted detail normal textures
std::vector<std::string> splatDetailNormalTexNames;
// SMF overrides
std::string minimapTexName;
std::string typemapTexName;
std::string metalmapTexName;
std::string grassmapTexName;
std::vector<std::string> smtFileNames;
float minHeight;
float maxHeight;
bool minHeightOverride;
bool maxHeightOverride;
// Controls whether the alpha channel of each splatted detail normal texture
// contains a diffuse channel, which behaves like the old splatted detail textures
bool splatDetailNormalDiffuseAlpha;
} smf;
struct pfs_t {
struct legacy_constants_t {
} legacy_constants;
struct qtpfs_constants_t {
unsigned int layersPerUpdate;
unsigned int maxTeamSearches;
unsigned int minNodeSizeX;
unsigned int minNodeSizeZ;
unsigned int maxNodeDepth;
unsigned int numSpeedModBins;
float minSpeedModVal;
float maxSpeedModVal;
} qtpfs_constants;
} pfs;
//If this struct is changed, please fix CReadMap::CalcTypemapChecksum accordingly
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 ReadTerrainTypes();
void ReadPFSConstants();
void ReadSound();
MapParser mapInfoParser; // map-info parser root table
LuaTable* resTableRoot; // resource-parser root table
};
extern const CMapInfo* mapInfo;
#endif // MAP_INFO_H
|