Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CAIWorker Class Reference

Implements worker thread for CCmpAIManager. More...

Classes

class  CAIPlayer
 
struct  SCommandSets
 

Public Member Functions

 CAIWorker ()
 
 ~CAIWorker ()
 
bool TryLoadSharedComponent (bool hasTechs)
 
bool AddPlayer (const std::wstring &aiName, player_id_t player, uint8_t difficulty, bool callConstructor)
 
bool RunGamestateInit (const shared_ptr< ScriptInterface::StructuredClone > &gameState, const Grid< u16 > &passabilityMap, const Grid< u8 > &territoryMap)
 
void StartComputation (const shared_ptr< ScriptInterface::StructuredClone > &gameState, const Grid< u16 > &passabilityMap, const Grid< u8 > &territoryMap, bool territoryMapDirty)
 
void WaitToFinishComputation ()
 
void GetCommands (std::vector< SCommandSets > &commands)
 
void RegisterTechTemplates (const shared_ptr< ScriptInterface::StructuredClone > &techTemplates)
 
void LoadEntityTemplates (const std::vector< std::pair< std::string, const CParamNode * > > &templates)
 
void Serialize (std::ostream &stream, bool isDebug)
 
void SerializeState (ISerializer &serializer)
 
void Deserialize (std::istream &stream)
 
int getPlayerSize ()
 
void RegisterSerializablePrototype (std::wstring name, CScriptVal proto)
 

Static Public Member Functions

static void PostCommand (void *cbdata, CScriptValRooted cmd)
 
static void DumpHeap (void *cbdata)
 
static void ForceGC (void *cbdata)
 
static void DumpImage (void *cbdata, std::wstring name, std::vector< u32 > data, u32 w, u32 h, u32 max)
 Debug function for AI scripts to dump 2D array data (e.g. More...
 

Private Member Functions

CScriptValRooted LoadMetadata (const VfsPath &path)
 
void PerformComputation ()
 

Private Attributes

shared_ptr< ScriptRuntimem_ScriptRuntime
 
ScriptInterface m_ScriptInterface
 
boost::rand48 m_RNG
 
u32 m_TurnNum
 
CScriptValRooted m_EntityTemplates
 
bool m_HasLoadedEntityTemplates
 
CScriptValRooted m_TechTemplates
 
std::map< VfsPath,
CScriptValRooted
m_PlayerMetadata
 
std::vector< shared_ptr
< CAIPlayer > > 
m_Players
 
bool m_HasSharedComponent
 
CScriptValRooted m_SharedAIObj
 
std::vector< SCommandSetsm_Commands
 
shared_ptr
< ScriptInterface::StructuredClone
m_GameState
 
Grid< u16m_PassabilityMap
 
CScriptValRooted m_PassabilityMapVal
 
Grid< u8m_TerritoryMap
 
CScriptValRooted m_TerritoryMapVal
 
bool m_CommandsComputed
 
std::map< JSObject
*, std::wstring > 
m_SerializablePrototypes
 
std::map< std::wstring,
JSObject * > 
m_DeserializablePrototypes
 

Detailed Description

Implements worker thread for CCmpAIManager.

Definition at line 73 of file CCmpAIManager.cpp.

Constructor & Destructor Documentation

CAIWorker::CAIWorker ( )
inline

Definition at line 310 of file CCmpAIManager.cpp.

CAIWorker::~CAIWorker ( )
inline

Definition at line 336 of file CCmpAIManager.cpp.

Member Function Documentation

bool CAIWorker::AddPlayer ( const std::wstring &  aiName,
player_id_t  player,
uint8_t  difficulty,
bool  callConstructor 
)
inline

Definition at line 512 of file CCmpAIManager.cpp.

void CAIWorker::Deserialize ( std::istream &  stream)
inline

Definition at line 690 of file CCmpAIManager.cpp.

static void CAIWorker::DumpHeap ( void *  cbdata)
inlinestatic

Definition at line 360 of file CCmpAIManager.cpp.

static void CAIWorker::DumpImage ( void *  cbdata,
std::wstring  name,
std::vector< u32 data,
u32  w,
u32  h,
u32  max 
)
inlinestatic

Debug function for AI scripts to dump 2D array data (e.g.

terrain tile weights).

Definition at line 383 of file CCmpAIManager.cpp.

static void CAIWorker::ForceGC ( void *  cbdata)
inlinestatic

Definition at line 369 of file CCmpAIManager.cpp.

void CAIWorker::GetCommands ( std::vector< SCommandSets > &  commands)
inline

Definition at line 590 of file CCmpAIManager.cpp.

int CAIWorker::getPlayerSize ( )
inline

Definition at line 769 of file CCmpAIManager.cpp.

void CAIWorker::LoadEntityTemplates ( const std::vector< std::pair< std::string, const CParamNode * > > &  templates)
inline

Definition at line 608 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::LoadMetadata ( const VfsPath path)
inlineprivate

Definition at line 786 of file CCmpAIManager.cpp.

void CAIWorker::PerformComputation ( )
inlineprivate

Definition at line 797 of file CCmpAIManager.cpp.

static void CAIWorker::PostCommand ( void *  cbdata,
CScriptValRooted  cmd 
)
inlinestatic

Definition at line 350 of file CCmpAIManager.cpp.

void CAIWorker::RegisterSerializablePrototype ( std::wstring  name,
CScriptVal  proto 
)
inline

Definition at line 774 of file CCmpAIManager.cpp.

void CAIWorker::RegisterTechTemplates ( const shared_ptr< ScriptInterface::StructuredClone > &  techTemplates)
inline

Definition at line 603 of file CCmpAIManager.cpp.

bool CAIWorker::RunGamestateInit ( const shared_ptr< ScriptInterface::StructuredClone > &  gameState,
const Grid< u16 > &  passabilityMap,
const Grid< u8 > &  territoryMap 
)
inline

Definition at line 529 of file CCmpAIManager.cpp.

void CAIWorker::Serialize ( std::ostream &  stream,
bool  isDebug 
)
inline

Definition at line 625 of file CCmpAIManager.cpp.

void CAIWorker::SerializeState ( ISerializer serializer)
inline

Definition at line 644 of file CCmpAIManager.cpp.

void CAIWorker::StartComputation ( const shared_ptr< ScriptInterface::StructuredClone > &  gameState,
const Grid< u16 > &  passabilityMap,
const Grid< u8 > &  territoryMap,
bool  territoryMapDirty 
)
inline

Definition at line 556 of file CCmpAIManager.cpp.

bool CAIWorker::TryLoadSharedComponent ( bool  hasTechs)
inline

Definition at line 419 of file CCmpAIManager.cpp.

void CAIWorker::WaitToFinishComputation ( )
inline

Definition at line 581 of file CCmpAIManager.cpp.

Member Data Documentation

std::vector<SCommandSets> CAIWorker::m_Commands
private

Definition at line 877 of file CCmpAIManager.cpp.

bool CAIWorker::m_CommandsComputed
private

Definition at line 885 of file CCmpAIManager.cpp.

std::map<std::wstring, JSObject*> CAIWorker::m_DeserializablePrototypes
private

Definition at line 888 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::m_EntityTemplates
private

Definition at line 868 of file CCmpAIManager.cpp.

shared_ptr<ScriptInterface::StructuredClone> CAIWorker::m_GameState
private

Definition at line 879 of file CCmpAIManager.cpp.

bool CAIWorker::m_HasLoadedEntityTemplates
private

Definition at line 869 of file CCmpAIManager.cpp.

bool CAIWorker::m_HasSharedComponent
private

Definition at line 875 of file CCmpAIManager.cpp.

Grid<u16> CAIWorker::m_PassabilityMap
private

Definition at line 880 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::m_PassabilityMapVal
private

Definition at line 881 of file CCmpAIManager.cpp.

std::map<VfsPath, CScriptValRooted> CAIWorker::m_PlayerMetadata
private

Definition at line 872 of file CCmpAIManager.cpp.

std::vector<shared_ptr<CAIPlayer> > CAIWorker::m_Players
private

Definition at line 873 of file CCmpAIManager.cpp.

boost::rand48 CAIWorker::m_RNG
private

Definition at line 865 of file CCmpAIManager.cpp.

ScriptInterface CAIWorker::m_ScriptInterface
private

Definition at line 864 of file CCmpAIManager.cpp.

shared_ptr<ScriptRuntime> CAIWorker::m_ScriptRuntime
private

Definition at line 863 of file CCmpAIManager.cpp.

std::map<JSObject*, std::wstring> CAIWorker::m_SerializablePrototypes
private

Definition at line 887 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::m_SharedAIObj
private

Definition at line 876 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::m_TechTemplates
private

Definition at line 870 of file CCmpAIManager.cpp.

Grid<u8> CAIWorker::m_TerritoryMap
private

Definition at line 882 of file CCmpAIManager.cpp.

CScriptValRooted CAIWorker::m_TerritoryMapVal
private

Definition at line 883 of file CCmpAIManager.cpp.

u32 CAIWorker::m_TurnNum
private

Definition at line 866 of file CCmpAIManager.cpp.


The documentation for this class was generated from the following file: