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
|
#ifndef GLOBAL_UNSYNCED_H
#define GLOBAL_UNSYNCED_H
#include <string>
#include "float3.h"
#include "creg/creg_cond.h"
class CGameSetup;
class CTeam;
class CPlayer;
/**
* @brief Global synced stuff
*
* Class contains globally accessible
* stuff that remains synced.
*/
class CGlobalSyncedStuff
{
public:
CR_DECLARE(CGlobalSyncedStuff);
CGlobalSyncedStuff(); //!< Constructor
~CGlobalSyncedStuff(); //!< Destructor
void LoadFromSetup(const CGameSetup*);
int randInt(); //!< synced random int
float randFloat(); //!< synced random float
float3 randVector(); //!< synced random vector
void SetRandSeed(unsigned int seed, bool init = false) {
randSeed = seed;
if (init) { initRandSeed = randSeed; }
}
unsigned int GetRandSeed() const { return randSeed; }
unsigned int GetInitRandSeed() const { return initRandSeed; }
/**
* @brief frame number
*
* Stores the current frame number
*/
int frameNum;
/**
* @brief speed factor
*
* Contains the actual gamespeed used by the game
*/
float speedFactor;
/**
* @brief user speed factor
*
* Contains the user's speed factor.
* The real gamespeed can be up to this
* but is lowered if a computer can't keep up
*/
float userSpeedFactor;
/**
* @brief paused
*
* Holds whether the game is paused
*/
bool paused;
/**
* @brief map x
*
* The map's number of squares in the x direction
* (note that the number of vertices is one more)
*/
int mapx;
/**
* @brief map y
*
* The map's number of squares in the y direction
*/
int mapy;
/**
* @brief map squares
*
* Total number of squares on the map
*/
int mapSquares;
/**
* @brief half map x
*
* Contains half of the number of squares in the x direction
*/
int hmapx;
/**
* @brief half map y
*
* Contains half of the number of squares in the y direction
*/
int hmapy;
/**
* @brief map x power of 2
*
* Map's size in the x direction rounded
* up to the next power of 2
*/
int pwr2mapx;
/**
* @brief map y power of 2
*
* Map's size in the y direction rounded
* up to the next power of 2
*/
int pwr2mapy;
/**
* @brief temp num
*
* Used for getting temporary but unique numbers
* (increase after each use)
*/
int tempNum;
/**
* @brief god mode
*
* Whether god mode is enabled, allows all players to control all units (even specs)
*/
bool godMode;
/**
* @brief global line-of-sight
*
* Whether everything on the map is visible at all times
*/
bool globalLOS;
/**
* @brief cheat enabled
*
* Whether cheating is enabled
*/
bool cheatEnabled;
/**
* @brief disable helper AIs
*
* Whether helper AIs are allowed, including LuaUI control widgets
*/
bool noHelperAIs;
/**
* @brief definition editing enabled
*
* Whether definition editing is enabled
*/
bool editDefsEnabled;
/**
* @brief LuaGaia control
*
* Whether or not LuaGaia is enabled
*/
bool useLuaGaia;
private:
/**
* @brief random seed
*
* Holds the synced random seed
*/
int randSeed;
/**
* @brief initial random seed
*
* Holds the synced initial random seed
*/
int initRandSeed;
};
extern CGlobalSyncedStuff* gs;
class SyncedRNG
{
public:
int operator()(unsigned N)
{
return gs->randInt()%N;
};
};
#endif //GLOBAL_UNSYNCED_H
|