SpringUnitSync Class Reference

#include <springunitsync.h>

Inherits wxEvtHandler.

Collaboration diagram for SpringUnitSync:
Collaboration graph
[legend]

Public Types

enum  GameFeature { USYNC_Sett_Handler, USYNC_GetInfoMap, USYNC_GetDataDir, USYNC_GetSkirmishAI }
enum  MediaType { map, mod }
typedef std::map< wxString,
mmOptionBool
OptionMapBool
typedef std::map< wxString,
mmOptionFloat
OptionMapFloat
typedef std::map< wxString,
mmOptionString
OptionMapString
typedef std::map< wxString,
mmOptionList
OptionMapList
typedef std::map< wxString,
mmOptionSection
OptionMapSection
typedef std::map< wxString,
mmOptionBool >::iterator 
OptionMapBoolIter
typedef std::map< wxString,
mmOptionFloat >::iterator 
OptionMapFloatIter
typedef std::map< wxString,
mmOptionString >::iterator 
OptionMapStringIter
typedef std::map< wxString,
mmOptionList >::iterator 
OptionMapListIter
typedef std::map< wxString,
mmOptionSection >::iterator 
OptionMapSectionIter
typedef std::map< wxString,
mmOptionBool >::const_iterator 
OptionMapBoolConstIter
typedef std::map< wxString,
mmOptionFloat >
::const_iterator 
OptionMapFloatConstIter
typedef std::map< wxString,
mmOptionString >
::const_iterator 
OptionMapStringConstIter
typedef std::map< wxString,
mmOptionList >::const_iterator 
OptionMapListConstIter
typedef std::map< wxString,
mmOptionSection >
::const_iterator 
OptionMapSectionConstIter

Public Member Functions

virtual ~SpringUnitSync ()
int GetNumMods () const
wxArrayString GetModList () const
bool ModExists (const wxString &modname) const
bool ModExists (const wxString &modname, const wxString &hash) const
bool ModExistsCheckHash (const wxString &hash) const
UnitSyncMod GetMod (const wxString &modname)
UnitSyncMod GetMod (int index)
int GetModIndex (const wxString &name) const
 this functions returns index CUSTOM ALPHBETICALLY SORTED, DO NOT USE TO ACCESS UNITSYNC DIRECTLY use m_unsorted_mod_array for real unitsync index
GameOptions GetModOptions (const wxString &name)
wxArrayString GetModDeps (const wxString &name) const
int GetNumMaps () const
wxArrayString GetMapList () const
wxArrayString GetModValidMapList (const wxString &modname) const
bool MapExists (const wxString &mapname) const
bool MapExists (const wxString &mapname, const wxString &hash) const
UnitSyncMap GetMap (const wxString &mapname)
UnitSyncMap GetMap (int index)
UnitSyncMap GetMapEx (const wxString &mapname)
UnitSyncMap GetMapEx (int index)
GameOptions GetMapOptions (const wxString &name)
wxArrayString GetMapDeps (const wxString &name)
wxString GetDefaultNick ()
 function to fetch default singplayer/replay/savegame's default nick
void SetDefaultNick (const wxString &nick)
 function to set default singplayer/replay/savegame's default nick
int GetMapIndex (const wxString &name) const
 this functions returns index CUSTOM ALPHBETICALLY SORTED, DO NOT USE TO ACCESS UNITSYNC DIRECTLY use m_unsorted_map_array for real unitsync index
wxArrayString GetSides (const wxString &modname)
wxImage GetSidePicture (const wxString &modname, const wxString &SideName) const
wxImage GetImage (const wxString &modname, const wxString &image_path, bool useWhiteAsTransparent=true) const
bool LoadUnitSyncLib (const wxString &unitsyncloc)
void FreeUnitSyncLib ()
bool IsLoaded () const
wxString GetSpringVersion () const
bool VersionSupports (GameFeature feature) const
 function wich checks if the version returned from unitsync matches a table of supported feature
void UnSetCurrentMod ()
wxArrayString GetAIList (const wxString &modname) const
wxArrayString GetAIInfos (int index) const
GameOptions GetAIOptions (const wxString &modname, int index)
int GetNumUnits (const wxString &modname) const
wxArrayString GetUnitsList (const wxString &modname)
wxImage GetMinimap (const wxString &mapname)
 get minimap with native width x height
wxImage GetMinimap (const wxString &mapname, int width, int height)
 get minimap rescaled to given width x height
wxImage GetMetalmap (const wxString &mapname)
 get metalmap with native width x height
wxImage GetMetalmap (const wxString &mapname, int width, int height)
 get metalmap rescaled to given width x height
wxImage GetHeightmap (const wxString &mapname)
 get heightmap with native width x height
wxImage GetHeightmap (const wxString &mapname, int width, int height)
 get heightmap rescaled to given width x height
wxString GetTextfileAsString (const wxString &modname, const wxString &file_path)
bool ReloadUnitSyncLib ()
void ReloadUnitSyncLib (GlobalEvents::GlobalEventData)
bool FastLoadUnitSyncLib (const wxString &unitsyncloc)
bool FastLoadUnitSyncLibInit ()
void SetSpringDataPath (const wxString &path)
wxArrayString GetPlaybackList (bool ReplayType=true) const
bool FileExists (const wxString &name) const
wxString GetArchivePath (const wxString &name) const
void PrefetchMap (const wxString &mapname)
 schedule a map for prefetching
int RegisterEvtHandler (wxEvtHandler *evtHandler)
void UnregisterEvtHandler (int evtHandlerId)
void PostEvent (int evtHandlerId, wxEvent &evt)
void GetMinimapAsync (const wxString &mapname, int evtHandlerId)
void GetMinimapAsync (const wxString &mapname, int width, int height, int evtHandlerId)
void GetMetalmapAsync (const wxString &mapname, int evtHandlerId)
void GetMetalmapAsync (const wxString &mapname, int width, int height, int evtHandlerId)
void GetHeightmapAsync (const wxString &mapname, int evtHandlerId)
void GetHeightmapAsync (const wxString &mapname, int width, int height, int evtHandlerId)
void GetMapExAsync (const wxString &mapname, int evtHandlerId)
wxArrayString GetScreenshotFilenames () const
virtual GameOptions GetModCustomizations (const wxString &modname)
virtual GameOptions GetSkirmishOptions (const wxString &modname, const wxString &skirmish_name)
virtual void OnReload (wxCommandEvent &event)
virtual void AddReloadEvent ()
wxArrayString FindFilesVFS (const wxString &pattern) const
wxString GetNameForShortname (const wxString &shortname, const wxString &version) const

Private Types

typedef std::map< std::pair
< wxString, wxString >
, wxString
ShortnameVersionToNameMap

Private Member Functions

 SpringUnitSync ()
wxString GetFileCachePath (const wxString &name, const wxString &hash, bool IsMod)
 this function returns only the cache path without the file extension, the extension itself would be added in the function as needed
wxArrayString GetCacheFile (const wxString &path) const
 returns an array where each element is a line of the file
void SetCacheFile (const wxString &path, const wxArrayString &data)
 write a file where each element of the array is a line
bool _LoadUnitSyncLib (const wxString &unitsyncloc)
void _FreeUnitSyncLib ()
MapInfo _GetMapInfoEx (const wxString &mapname)
void PopulateArchiveList ()
wxImage _GetMapImage (const wxString &mapname, const wxString &imagename, wxImage(SpringUnitSyncLib::*loadMethod)(const wxString &))
wxImage _GetScaledMapImage (const wxString &mapname, wxImage(SpringUnitSync::*loadMethod)(const wxString &), int width, int height)
void _GetMapImageAsync (const wxString &mapname, wxImage(SpringUnitSync::*loadMethod)(const wxString &), int evtHandlerId)

Private Attributes

ShortnameVersionToNameMap m_shortname_to_name_map
LocalArchivesVector m_maps_list
LocalArchivesVector m_mods_list
 mapname -> hash
LocalArchivesVector m_mods_unchained_hash
 modname -> hash
LocalArchivesVector m_maps_unchained_hash
 modname -> unchained hash
LocalArchivesVector m_mods_archive_name
 mapname -> unchained hash
LocalArchivesVector m_maps_archive_name
 modname -> archive name
wxArrayString m_map_array
 mapname -> archive name
wxArrayString m_mod_array
wxArrayString m_unsorted_map_array
wxArrayString m_unsorted_mod_array
wxString m_cache_path
 caches sett().GetCachePath(), because that method calls back into susynclib(), there's a good chance main thread blocks on some WorkerThread operation.
wxCriticalSection m_lock
WorkerThreadm_cache_thread
EvtHandlerCollection m_evt_handlers
MostRecentlyUsedImageCache m_map_image_cache
 this cache facilitates async image fetching (image is stored in cache in background thread, then main thread gets it from cache)
MostRecentlyUsedImageCache m_tiny_minimap_cache
 this cache is a real cache, it stores minimaps with max size 100x100
MostRecentlyUsedMapInfoCache m_mapinfo_cache
 this caches MapInfo to facilitate GetMapExAsync
MostRecentlyUsedArrayStringCache m_sides_cache

Friends

class GlobalObjectHolder< SpringUnitSync, LineInfo< SpringUnitSync > >

Detailed Description

Definition at line 53 of file springunitsync.h.


Member Typedef Documentation

Definition at line 76 of file springunitsync.h.

Definition at line 88 of file springunitsync.h.

Definition at line 82 of file springunitsync.h.

Definition at line 77 of file springunitsync.h.

Definition at line 89 of file springunitsync.h.

Definition at line 83 of file springunitsync.h.

Definition at line 79 of file springunitsync.h.

Definition at line 91 of file springunitsync.h.

Definition at line 85 of file springunitsync.h.

Definition at line 80 of file springunitsync.h.

Definition at line 92 of file springunitsync.h.

Definition at line 86 of file springunitsync.h.

Definition at line 78 of file springunitsync.h.

Definition at line 90 of file springunitsync.h.

Definition at line 84 of file springunitsync.h.

typedef std::map< std::pair<wxString,wxString>, wxString> SpringUnitSync::ShortnameVersionToNameMap [private]

Definition at line 208 of file springunitsync.h.


Member Enumeration Documentation

Enumerator:
USYNC_Sett_Handler 
USYNC_GetInfoMap 
USYNC_GetDataDir 
USYNC_GetSkirmishAI 

Definition at line 62 of file springunitsync.h.

Enumerator:
map 
mod 

Definition at line 70 of file springunitsync.h.


Constructor & Destructor Documentation

SpringUnitSync::SpringUnitSync (  )  [private]

Definition at line 51 of file springunitsync.cpp.

SpringUnitSync::~SpringUnitSync (  )  [virtual]

Definition at line 62 of file springunitsync.cpp.


Member Function Documentation

void SpringUnitSync::_FreeUnitSyncLib (  )  [private]
wxImage SpringUnitSync::_GetMapImage ( const wxString mapname,
const wxString imagename,
wxImage(SpringUnitSyncLib::*)(const wxString &)  loadMethod 
) [private]

Definition at line 834 of file springunitsync.cpp.

void SpringUnitSync::_GetMapImageAsync ( const wxString mapname,
wxImage(SpringUnitSync::*)(const wxString &)  loadMethod,
int  evtHandlerId 
) [private]

Definition at line 1272 of file springunitsync.cpp.

MapInfo SpringUnitSync::_GetMapInfoEx ( const wxString mapname  )  [private]

Definition at line 883 of file springunitsync.cpp.

wxImage SpringUnitSync::_GetScaledMapImage ( const wxString mapname,
wxImage(SpringUnitSync::*)(const wxString &)  loadMethod,
int  width,
int  height 
) [private]

Definition at line 869 of file springunitsync.cpp.

bool SpringUnitSync::_LoadUnitSyncLib ( const wxString unitsyncloc  )  [private]

Definition at line 219 of file springunitsync.cpp.

void SpringUnitSync::AddReloadEvent (  )  [virtual]

Definition at line 961 of file springunitsync.cpp.

bool SpringUnitSync::FastLoadUnitSyncLib ( const wxString unitsyncloc  ) 

Definition at line 75 of file springunitsync.cpp.

bool SpringUnitSync::FastLoadUnitSyncLibInit (  ) 

Definition at line 103 of file springunitsync.cpp.

bool SpringUnitSync::FileExists ( const wxString name  )  const

Definition at line 1042 of file springunitsync.cpp.

wxArrayString SpringUnitSync::FindFilesVFS ( const wxString pattern  )  const

Definition at line 967 of file springunitsync.cpp.

void SpringUnitSync::FreeUnitSyncLib (  ) 

Definition at line 230 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetAIInfos ( int  index  )  const

Definition at line 699 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetAIList ( const wxString modname  )  const

Definition at line 642 of file springunitsync.cpp.

GameOptions SpringUnitSync::GetAIOptions ( const wxString modname,
int  index 
)

Definition at line 710 of file springunitsync.cpp.

wxString SpringUnitSync::GetArchivePath ( const wxString name  )  const

Definition at line 1051 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetCacheFile ( const wxString path  )  const [private]

returns an array where each element is a line of the file

Definition at line 1004 of file springunitsync.cpp.

wxString SpringUnitSync::GetDefaultNick (  ) 

function to fetch default singplayer/replay/savegame's default nick

Definition at line 1072 of file springunitsync.cpp.

wxString SpringUnitSync::GetFileCachePath ( const wxString name,
const wxString hash,
bool  IsMod 
) [private]

this function returns only the cache path without the file extension, the extension itself would be added in the function as needed

Definition at line 984 of file springunitsync.cpp.

wxImage SpringUnitSync::GetHeightmap ( const wxString mapname,
int  width,
int  height 
)

get heightmap rescaled to given width x height

Definition at line 827 of file springunitsync.cpp.

wxImage SpringUnitSync::GetHeightmap ( const wxString mapname  ) 

get heightmap with native width x height

Definition at line 820 of file springunitsync.cpp.

void SpringUnitSync::GetHeightmapAsync ( const wxString mapname,
int  width,
int  height,
int  evtHandlerId 
)

Definition at line 1322 of file springunitsync.cpp.

void SpringUnitSync::GetHeightmapAsync ( const wxString mapname,
int  evtHandlerId 
)

Definition at line 1316 of file springunitsync.cpp.

wxImage SpringUnitSync::GetImage ( const wxString modname,
const wxString image_path,
bool  useWhiteAsTransparent = true 
) const

Definition at line 582 of file springunitsync.cpp.

UnitSyncMap SpringUnitSync::GetMap ( int  index  ) 

Definition at line 380 of file springunitsync.cpp.

UnitSyncMap SpringUnitSync::GetMap ( const wxString mapname  ) 

Definition at line 368 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetMapDeps ( const wxString name  ) 

Definition at line 475 of file springunitsync.cpp.

UnitSyncMap SpringUnitSync::GetMapEx ( int  index  ) 

Definition at line 392 of file springunitsync.cpp.

UnitSyncMap SpringUnitSync::GetMapEx ( const wxString mapname  ) 

Definition at line 487 of file springunitsync.cpp.

void SpringUnitSync::GetMapExAsync ( const wxString mapname,
int  evtHandlerId 
)

Definition at line 1327 of file springunitsync.cpp.

int SpringUnitSync::GetMapIndex ( const wxString name  )  const

this functions returns index CUSTOM ALPHBETICALLY SORTED, DO NOT USE TO ACCESS UNITSYNC DIRECTLY use m_unsorted_map_array for real unitsync index

Definition at line 496 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetMapList (  )  const

Definition at line 336 of file springunitsync.cpp.

GameOptions SpringUnitSync::GetMapOptions ( const wxString name  ) 

Definition at line 463 of file springunitsync.cpp.

wxImage SpringUnitSync::GetMetalmap ( const wxString mapname,
int  width,
int  height 
)

get metalmap rescaled to given width x height

Definition at line 813 of file springunitsync.cpp.

wxImage SpringUnitSync::GetMetalmap ( const wxString mapname  ) 

get metalmap with native width x height

Definition at line 806 of file springunitsync.cpp.

void SpringUnitSync::GetMetalmapAsync ( const wxString mapname,
int  width,
int  height,
int  evtHandlerId 
)

Definition at line 1311 of file springunitsync.cpp.

void SpringUnitSync::GetMetalmapAsync ( const wxString mapname,
int  evtHandlerId 
)

Definition at line 1305 of file springunitsync.cpp.

wxImage SpringUnitSync::GetMinimap ( const wxString mapname,
int  width,
int  height 
)

get minimap rescaled to given width x height

Definition at line 766 of file springunitsync.cpp.

wxImage SpringUnitSync::GetMinimap ( const wxString mapname  ) 

get minimap with native width x height

Definition at line 759 of file springunitsync.cpp.

void SpringUnitSync::GetMinimapAsync ( const wxString mapname,
int  width,
int  height,
int  evtHandlerId 
)

Definition at line 1291 of file springunitsync.cpp.

void SpringUnitSync::GetMinimapAsync ( const wxString mapname,
int  evtHandlerId 
)

Definition at line 1285 of file springunitsync.cpp.

UnitSyncMod SpringUnitSync::GetMod ( int  index  ) 

Definition at line 319 of file springunitsync.cpp.

UnitSyncMod SpringUnitSync::GetMod ( const wxString modname  ) 

Definition at line 307 of file springunitsync.cpp.

GameOptions SpringUnitSync::GetModCustomizations ( const wxString modname  )  [virtual]

Definition at line 516 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetModDeps ( const wxString name  )  const

Definition at line 540 of file springunitsync.cpp.

int SpringUnitSync::GetModIndex ( const wxString name  )  const

this functions returns index CUSTOM ALPHBETICALLY SORTED, DO NOT USE TO ACCESS UNITSYNC DIRECTLY use m_unsorted_mod_array for real unitsync index

Definition at line 276 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetModList (  )  const

Definition at line 270 of file springunitsync.cpp.

GameOptions SpringUnitSync::GetModOptions ( const wxString name  ) 

Definition at line 504 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetModValidMapList ( const wxString modname  )  const

Definition at line 342 of file springunitsync.cpp.

wxString SpringUnitSync::GetNameForShortname ( const wxString shortname,
const wxString version 
) const

Definition at line 1386 of file springunitsync.cpp.

int SpringUnitSync::GetNumMaps (  )  const

Definition at line 329 of file springunitsync.cpp.

int SpringUnitSync::GetNumMods (  )  const

Definition at line 263 of file springunitsync.cpp.

int SpringUnitSync::GetNumUnits ( const wxString modname  )  const

Definition at line 722 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetPlaybackList ( bool  ReplayType = true  )  const

Definition at line 1031 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetScreenshotFilenames (  )  const

Definition at line 1058 of file springunitsync.cpp.

wxImage SpringUnitSync::GetSidePicture ( const wxString modname,
const wxString SideName 
) const

Definition at line 566 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetSides ( const wxString modname  ) 

Definition at line 551 of file springunitsync.cpp.

GameOptions SpringUnitSync::GetSkirmishOptions ( const wxString modname,
const wxString skirmish_name 
) [virtual]

Definition at line 528 of file springunitsync.cpp.

wxString SpringUnitSync::GetSpringVersion (  )  const

Definition at line 244 of file springunitsync.cpp.

wxString SpringUnitSync::GetTextfileAsString ( const wxString modname,
const wxString file_path 
)

Definition at line 1342 of file springunitsync.cpp.

wxArrayString SpringUnitSync::GetUnitsList ( const wxString modname  ) 

Definition at line 733 of file springunitsync.cpp.

bool SpringUnitSync::IsLoaded (  )  const

Definition at line 238 of file springunitsync.cpp.

bool SpringUnitSync::LoadUnitSyncLib ( const wxString unitsyncloc  ) 

Definition at line 121 of file springunitsync.cpp.

bool SpringUnitSync::MapExists ( const wxString mapname,
const wxString hash 
) const

Definition at line 360 of file springunitsync.cpp.

bool SpringUnitSync::MapExists ( const wxString mapname  )  const

Definition at line 354 of file springunitsync.cpp.

bool SpringUnitSync::ModExists ( const wxString modname,
const wxString hash 
) const

Definition at line 290 of file springunitsync.cpp.

bool SpringUnitSync::ModExists ( const wxString modname  )  const

Definition at line 284 of file springunitsync.cpp.

bool SpringUnitSync::ModExistsCheckHash ( const wxString hash  )  const

Definition at line 297 of file springunitsync.cpp.

void SpringUnitSync::OnReload ( wxCommandEvent &  event  )  [virtual]

Definition at line 956 of file springunitsync.cpp.

void SpringUnitSync::PopulateArchiveList (  )  [private]

Definition at line 141 of file springunitsync.cpp.

void SpringUnitSync::PostEvent ( int  evtHandlerId,
wxEvent &  evt 
)

Definition at line 1267 of file springunitsync.cpp.

void SpringUnitSync::PrefetchMap ( const wxString mapname  ) 

schedule a map for prefetching

Definition at line 1217 of file springunitsync.cpp.

int SpringUnitSync::RegisterEvtHandler ( wxEvtHandler evtHandler  ) 

Definition at line 1257 of file springunitsync.cpp.

void SpringUnitSync::ReloadUnitSyncLib ( GlobalEvents::GlobalEventData   )  [inline]

Definition at line 170 of file springunitsync.h.

bool SpringUnitSync::ReloadUnitSyncLib (  ) 

Definition at line 972 of file springunitsync.cpp.

void SpringUnitSync::SetCacheFile ( const wxString path,
const wxArrayString &  data 
) [private]

write a file where each element of the array is a line

Definition at line 1019 of file springunitsync.cpp.

void SpringUnitSync::SetDefaultNick ( const wxString nick  ) 

function to set default singplayer/replay/savegame's default nick

Definition at line 1082 of file springunitsync.cpp.

void SpringUnitSync::SetSpringDataPath ( const wxString path  ) 

Definition at line 978 of file springunitsync.cpp.

void SpringUnitSync::UnregisterEvtHandler ( int  evtHandlerId  ) 

Definition at line 1262 of file springunitsync.cpp.

void SpringUnitSync::UnSetCurrentMod (  ) 

Definition at line 691 of file springunitsync.cpp.

bool SpringUnitSync::VersionSupports ( GameFeature  feature  )  const

function wich checks if the version returned from unitsync matches a table of supported feature

Definition at line 257 of file springunitsync.cpp.


Friends And Related Function Documentation

Definition at line 57 of file springunitsync.h.


Field Documentation

caches sett().GetCachePath(), because that method calls back into susynclib(), there's a good chance main thread blocks on some WorkerThread operation.

.. cache is invalidated on reload.

Definition at line 225 of file springunitsync.h.

Definition at line 228 of file springunitsync.h.

Definition at line 229 of file springunitsync.h.

wxCriticalSection SpringUnitSync::m_lock [mutable, private]

Definition at line 227 of file springunitsync.h.

wxArrayString SpringUnitSync::m_map_array [private]

mapname -> archive name

Definition at line 217 of file springunitsync.h.

this cache facilitates async image fetching (image is stored in cache in background thread, then main thread gets it from cache)

Definition at line 233 of file springunitsync.h.

this caches MapInfo to facilitate GetMapExAsync

Definition at line 238 of file springunitsync.h.

modname -> archive name

Definition at line 216 of file springunitsync.h.

Definition at line 211 of file springunitsync.h.

modname -> unchained hash

Definition at line 214 of file springunitsync.h.

wxArrayString SpringUnitSync::m_mod_array [private]

Definition at line 218 of file springunitsync.h.

mapname -> unchained hash

Definition at line 215 of file springunitsync.h.

mapname -> hash

Definition at line 212 of file springunitsync.h.

modname -> hash

Definition at line 213 of file springunitsync.h.

Definition at line 209 of file springunitsync.h.

Definition at line 240 of file springunitsync.h.

this cache is a real cache, it stores minimaps with max size 100x100

Definition at line 235 of file springunitsync.h.

wxArrayString SpringUnitSync::m_unsorted_map_array [private]

Definition at line 219 of file springunitsync.h.

wxArrayString SpringUnitSync::m_unsorted_mod_array [private]

Definition at line 220 of file springunitsync.h.


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

Generated on Thu Dec 29 00:11:49 2011 for SpringLobby by doxygen 1.6.3