0ad/source/simulation/Simulation.h
Ykkrosh ee3243ff92 # Fixes for simulation speed in scenario edtior. Various code cleanups.
Game, Simulation, etc: Separated 'update' and 'interpolate', and made
'update' return whether it's going fast enough (so callers can decide to
do more updates per render). Changed some time variables to 'double' so
they have enough precision in long games.
Atlas: Added "Fast" playback button. Made simulation sometimes go at
real-time speed, if it's just slightly too slow at rendering.
VertexBuffer: Removed some non-useful glGetError calls.
Entity: Commented out redundant Tick code. Fixed syntax error in
disabled code that confused the IDE.
Aura: Changed string code again, to simply use ASCII instead of UTF-16.
(SpiderMonkey seems to handle it just as efficiently, for small
strings.)
Misc: Some more minor header-file cleanup.
SVN log: Added feed link.

This was SVN commit r4807.
2007-01-24 20:17:28 +00:00

67 lines
1.8 KiB
C++

#ifndef _Simulation_H
#define _Simulation_H
#include <boost/random.hpp>
class CGame;
class CGameAttributes;
class CWorld;
class CTurnManager;
class CNetMessage;
class CSimulation
{
CGame *m_pGame;
CWorld *m_pWorld;
CTurnManager *m_pTurnManager;
double m_DeltaTime;
// Random number generator
boost::mt19937 m_Random;
// Simulate: move the deterministic simulation forward by one interval
void Simulate();
// Interpolate: interpolate a data point for rendering between simulation
// frames.
void Interpolate(double frameTime, double offset);
public:
CSimulation(CGame *pGame);
~CSimulation();
inline void SetTurnManager(CTurnManager *pTurnManager)
{ m_pTurnManager=pTurnManager; }
inline CTurnManager *GetTurnManager()
{ return m_pTurnManager; }
void RegisterInit(CGameAttributes *pGameAttributes);
int Initialize(CGameAttributes *pGameAttributes);
// Perform simulation updates for the specified elapsed time. If it is
// shorter than the time until the next simulation turn, nothing happens.
// Returns false if it can't keep up with the desired simulation rate.
bool Update(double frameTime);
// Update the graphical representations of the simulation by the given time.
void Interpolate(double frameTime);
// Calculate the message mask of a message to be queued
static uint GetMessageMask(CNetMessage *, uint oldMask, void *userdata);
// Translate the command message into an entity order and queue it
// Returns oldMask
static uint TranslateMessage(CNetMessage *, uint oldMask, void *userdata);
void QueueLocalCommand(CNetMessage *pMsg);
// Get a random integer between 0 and maxVal-1 from the simulation's random number generator
int RandInt(int maxVal);
// Get a random float in [0, 1) from the simulation's random number generator
float RandFloat();
};
#endif