#include <simulator.h>
Inheritance diagram for Simulator:
Public Types | |
enum | SIMULATOR_STATE { SIMULATOR_RUNNING, SIMULATOR_STOPED, SIMULATOR_RETURN } |
Public Member Functions | |
Simulator () | |
do NOT use this | |
Simulator (SDL_mutex *mutex, BuildingLayer *pblayer, Map *pmap) | |
void | SaveTo (std::fstream &rfs) |
void | LoadFrom (std::fstream &rfs) |
virtual int | Main ()=0 |
virtual void | AddStructure (const uint &w1, const uint &h1, const uint &w2, const uint &h2) |
virtual void | RemoveStructure (const uint &w1, const uint &h1, const uint &w2, const uint &h2) |
void | Run () |
void | Stop () |
void | Return () |
const bool | CheckRange (const uint &w, const uint &l, const uint &range, const OPENCITY_STRUCTURE_CODE &enumStructCode) const |
const bool | CheckLevelUp (const uint w, const uint l, const Structure *pStruct) const |
const bool | CheckLevelDown (const uint w, const uint l, const Structure *pStruct) const |
const int & | GetVariation () const |
const int | GetValue () const |
void | SetVariation (const int rcVariation) |
void | SetValue (const int rcValue) |
Static Public Member Functions | |
static int | ThreadWrapper (void *pSim) |
static void | RCIDelay (void) |
Protected Attributes | |
int | _iVariation |
The average variation of the structures stimulated. | |
int | _iValue |
The current global value of the simulator. | |
SIMULATOR_STATE | enumSimState |
The current state of the simulator. | |
SDL_mutex * | mutexMain |
Points to the global mutex. | |
BuildingLayer * | pbuildlayer |
Map * | pmapOfCity |
Definition at line 65 of file simulator.h.
|
Check if the structure at the specified coodinates can "level down" Mainly, it consists of structure's size checking Definition at line 205 of file simulator.cpp. References Structure::GetCode(), Structure::GetGraphicCode(), Layer::GetLayerSize(), Structure::GetPreviousLevelGraphicCode(), PropertyManager::GetWLH(), and GlobalVar::gpPropertyMgr. |
|
Check if the structure at the specified coodinates can "level up". Mainly, it consists of structure's size checking Definition at line 135 of file simulator.cpp. References Structure::GetCode(), Structure::GetGraphicCode(), Layer::GetLayerSize(), Structure::GetNextLevelGraphicCode(), PropertyManager::GetWLH(), and GlobalVar::gpPropertyMgr. |
|
Given the (w, l) coordinates and a range in integer, this method return "true" if there's at least one required structure within the range and "false" otherwise Definition at line 113 of file simulator.cpp. References BuildingLayer::ContainStructure(), and Map::GetPossibleWH(). |
|
Return the global total value of the micro simulator Definition at line 282 of file simulator.cpp. References _iValue. |
|
Load the data from the specified stream
Implements Persistence. Reimplemented in ElectricitySim, and MainSim. Definition at line 78 of file simulator.cpp. References _iValue, and _iVariation. Referenced by MainSim::LoadFrom(), and ElectricitySim::LoadFrom(). |
|
Each RCI (residential, commercial, industrial) micro simulator should call this at the end of each treatement so that the main thread can execute. Definition at line 319 of file simulator.cpp. References Structure::GetNumber(), and GlobalVar::gfMsSimDelayMax. Referenced by MainSim::Main(). |
|
Save the data to the specified fstream
Implements Persistence. Reimplemented in ElectricitySim, and MainSim. Definition at line 67 of file simulator.cpp. References _iValue, and _iVariation. Referenced by MainSim::SaveTo(), and ElectricitySim::SaveTo(). |