# housekeeping
replaced all (*) CStr / CStrW by-value params with const reference. hoo boy. please always perform this optimization (actually standard idiom) when writing the code - it takes little work, tells the next guy that the string won't be modified, and makes a large performance difference. (* where possible.. a few require other changes and will follow later) This was SVN commit r4151.
This commit is contained in:
parent
3baa2d04b5
commit
c817566222
@ -331,13 +331,13 @@ void CCinemaTrack::MoveToPointAbsolute(float time)
|
||||
m_CPA->MoveToPointAt(m_CPA->m_TimeElapsed, m_StartRotation);
|
||||
}
|
||||
|
||||
void CCinemaManager::AddTrack(CCinemaTrack track, CStrW name)
|
||||
void CCinemaManager::AddTrack(CCinemaTrack track, const CStrW& name)
|
||||
{
|
||||
debug_assert( m_Tracks.find( name ) == m_Tracks.end() );
|
||||
m_Tracks[name] = track;
|
||||
}
|
||||
|
||||
void CCinemaManager::QueueTrack(CStrW name, bool queue )
|
||||
void CCinemaManager::QueueTrack(const CStrW& name, bool queue )
|
||||
{
|
||||
if (!m_TrackQueue.empty() && queue == false)
|
||||
{
|
||||
@ -350,7 +350,7 @@ void CCinemaManager::QueueTrack(CStrW name, bool queue )
|
||||
m_TrackQueue.back().m_CPA = m_TrackQueue.back().m_Paths.begin();
|
||||
}
|
||||
}
|
||||
void CCinemaManager::OverrideTrack(CStrW name)
|
||||
void CCinemaManager::OverrideTrack(const CStrW& name)
|
||||
{
|
||||
m_TrackQueue.clear();
|
||||
debug_assert(HasTrack(name));
|
||||
|
@ -139,20 +139,20 @@ public:
|
||||
CCinemaManager() { m_Active=false; }
|
||||
~CCinemaManager() {}
|
||||
|
||||
void AddTrack(CCinemaTrack track, CStrW name);
|
||||
void AddTrack(CCinemaTrack track, const CStrW& name);
|
||||
int LoadTracks(); //Loads tracks from file
|
||||
|
||||
//Adds track to list of being played. (Called by triggers?)
|
||||
void QueueTrack(CStrW name, bool queue);
|
||||
void OverrideTrack(CStrW name); //clears track queue and replaces with 'name'
|
||||
void QueueTrack(const CStrW& name, bool queue);
|
||||
void OverrideTrack(const CStrW& name); //clears track queue and replaces with 'name'
|
||||
bool Update(float DeltaTime);
|
||||
|
||||
inline bool IsPlaying() const { return !m_TrackQueue.empty(); }
|
||||
bool HasTrack(CStrW name) const { return m_Tracks.find(name) != m_Tracks.end(); }
|
||||
bool HasTrack(const CStrW& name) const { return m_Tracks.find(name) != m_Tracks.end(); }
|
||||
inline bool IsActive() const { return m_Active; }
|
||||
inline void SetActive(bool active) { m_Active=active; }
|
||||
|
||||
CCinemaTrack* GetTrack(CStrW name) { debug_assert(HasTrack(name)); return &m_Tracks[name]; }
|
||||
CCinemaTrack* GetTrack(const CStrW& name) { debug_assert(HasTrack(name)); return &m_Tracks[name]; }
|
||||
inline const std::map<CStrW, CCinemaTrack>& GetAllTracks() { return m_Tracks; }
|
||||
inline void SetAllTracks( const std::map<CStrW, CCinemaTrack>& tracks) { m_Tracks = tracks; }
|
||||
private:
|
||||
|
@ -148,19 +148,19 @@ void CMaterial::SetPlayerColor(CColor &colour)
|
||||
}
|
||||
|
||||
|
||||
void CMaterial::SetTexture(const CStr &texture)
|
||||
void CMaterial::SetTexture(const CStr& texture)
|
||||
{
|
||||
m_Texture = texture;
|
||||
ComputeHash();
|
||||
}
|
||||
|
||||
void CMaterial::SetVertexProgram(const CStr &prog)
|
||||
void CMaterial::SetVertexProgram(const CStr& prog)
|
||||
{
|
||||
m_VertexProgram = prog;
|
||||
ComputeHash();
|
||||
}
|
||||
|
||||
void CMaterial::SetFragmentProgram(const CStr &prog)
|
||||
void CMaterial::SetFragmentProgram(const CStr& prog)
|
||||
{
|
||||
m_FragmentProgram = prog;
|
||||
ComputeHash();
|
||||
|
@ -55,9 +55,9 @@ public:
|
||||
void Unbind();
|
||||
float GetHash() { return m_Hash; }
|
||||
|
||||
CStr GetTexture() { return m_Texture; }
|
||||
CStr GetVertexProgram() { return m_VertexProgram; }
|
||||
CStr GetFragmentProgram() { return m_FragmentProgram; }
|
||||
const CStr& GetTexture() { return m_Texture; }
|
||||
const CStr& GetVertexProgram() { return m_VertexProgram; }
|
||||
const CStr& GetFragmentProgram() { return m_FragmentProgram; }
|
||||
SMaterialColor GetDiffuse();
|
||||
SMaterialColor GetAmbient();
|
||||
SMaterialColor GetSpecular();
|
||||
@ -78,9 +78,9 @@ public:
|
||||
void SetPlayerColor(int id);
|
||||
void SetPlayerColor(CColor &colour);
|
||||
|
||||
void SetTexture(const CStr &texture);
|
||||
void SetVertexProgram(const CStr &prog);
|
||||
void SetFragmentProgram(const CStr &prog);
|
||||
void SetTexture(const CStr& texture);
|
||||
void SetVertexProgram(const CStr& prog);
|
||||
void SetFragmentProgram(const CStr& prog);
|
||||
void SetDiffuse(const SMaterialColor &color);
|
||||
void SetAmbient(const SMaterialColor &color);
|
||||
void SetSpecular(const SMaterialColor &color);
|
||||
|
@ -145,7 +145,7 @@ public:
|
||||
CModelDefRPrivate* GetRenderData(const void* key) const;
|
||||
|
||||
// accessor: get model name (for debugging)
|
||||
CStr GetName() const { return m_Name; }
|
||||
const CStr& GetName() const { return m_Name; }
|
||||
|
||||
public:
|
||||
// vertex data
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
static CTerrainPropertiesPtr FromXML(CTerrainPropertiesPtr parent, const char* path);
|
||||
|
||||
// Save the object to an XML file. Implement when needed! ;-)
|
||||
// bool WriteXML(CStr path);
|
||||
// bool WriteXML(const CStr& path);
|
||||
|
||||
inline CTerrainPropertiesPtr GetParent() const
|
||||
{ return m_pParent; }
|
||||
|
@ -21,7 +21,7 @@ map<Handle, CTextureEntry *> CTextureEntry::m_LoadedTextures;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// CTextureEntry constructor
|
||||
CTextureEntry::CTextureEntry(CTerrainPropertiesPtr props, CStr path):
|
||||
CTextureEntry::CTextureEntry(CTerrainPropertiesPtr props, const CStr& path):
|
||||
m_pProperties(props),
|
||||
m_Bitmap(NULL),
|
||||
m_Handle(-1),
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
public:
|
||||
// Most of the texture's data is delay-loaded, so after the constructor has
|
||||
// been called, the texture entry is ready to be used.
|
||||
CTextureEntry(CTerrainPropertiesPtr props, CStr path);
|
||||
CTextureEntry(CTerrainPropertiesPtr props, const CStr& path);
|
||||
~CTextureEntry();
|
||||
|
||||
CStr GetTag() const
|
||||
|
@ -73,7 +73,7 @@ CTerrainPropertiesPtr CTextureManager::GetPropertiesFromFile(CTerrainPropertiesP
|
||||
return CTerrainProperties::FromXML(props, path);
|
||||
}
|
||||
|
||||
CTextureEntry *CTextureManager::AddTexture(CTerrainPropertiesPtr props, CStr path)
|
||||
CTextureEntry *CTextureManager::AddTexture(CTerrainPropertiesPtr props, const CStr& path)
|
||||
{
|
||||
CTextureEntry *entry = new CTextureEntry(props, path);
|
||||
m_TextureEntries.push_back(entry);
|
||||
@ -177,7 +177,7 @@ int CTextureManager::LoadTerrainTextures()
|
||||
return 0;
|
||||
}
|
||||
|
||||
CTerrainGroup *CTextureManager::FindGroup(CStr name)
|
||||
CTerrainGroup *CTextureManager::FindGroup(const CStr& name)
|
||||
{
|
||||
TerrainGroupMap::const_iterator it=m_TerrainGroups.find(name);
|
||||
if (it != m_TerrainGroups.end())
|
||||
|
@ -91,14 +91,14 @@ public:
|
||||
|
||||
// Create a texture object for a new terrain texture at path, using the
|
||||
// property sheet props.
|
||||
CTextureEntry *AddTexture(CTerrainPropertiesPtr props, CStr path);
|
||||
CTextureEntry *AddTexture(CTerrainPropertiesPtr props, const CStr& path);
|
||||
|
||||
// Remove the texture from all our maps and lists and delete it afterwards.
|
||||
void DeleteTexture(CTextureEntry* entry);
|
||||
|
||||
// Find or create a new texture group. All terrain groups are owned by the
|
||||
// texturemanager (TerrainTypeManager)
|
||||
CTerrainGroup *FindGroup(CStr name);
|
||||
CTerrainGroup *FindGroup(const CStr& name);
|
||||
// Use the default group for all terrain types that don't have their own
|
||||
// ScEd currently relies on every texture having one group (and is happy ignorant of any
|
||||
// extra groups that might exist)
|
||||
|
@ -321,7 +321,7 @@ void CGUI::TickObjects()
|
||||
m_Tooltip.Update(pNearest, m_MousePos, this);
|
||||
}
|
||||
|
||||
void CGUI::SendEventToAll(CStr EventName)
|
||||
void CGUI::SendEventToAll(const CStr& EventName)
|
||||
{
|
||||
// janwas 2006-03-03: spoke with Ykkrosh about EventName case.
|
||||
// when registering, case is converted to lower - this avoids surprise
|
||||
@ -621,7 +621,7 @@ struct SGenerateTextImage
|
||||
// TODO Gee: CRect => CPoint ?
|
||||
void SetupSpriteCall(const bool Left, SGUIText::SSpriteCall &SpriteCall,
|
||||
const float width, const float y,
|
||||
const CSize &Size, const CStr &TextureName,
|
||||
const CSize &Size, const CStr& TextureName,
|
||||
const float BufferZone, const int CellID)
|
||||
{
|
||||
// TODO Gee: Temp hardcoded values
|
||||
@ -1001,7 +1001,7 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor,
|
||||
// -- GL
|
||||
}
|
||||
|
||||
bool CGUI::GetPreDefinedColor(const CStr &name, CColor &Output)
|
||||
bool CGUI::GetPreDefinedColor(const CStr& name, CColor &Output)
|
||||
{
|
||||
if (m_PreDefinedColors.count(name) == 0)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
/**
|
||||
* Sends a specified event to every object
|
||||
*/
|
||||
void SendEventToAll(CStr EventName);
|
||||
void SendEventToAll(const CStr& EventName);
|
||||
|
||||
/**
|
||||
* Displays the whole GUI
|
||||
@ -252,18 +252,18 @@ public:
|
||||
/**
|
||||
* Check if an icon exists
|
||||
*/
|
||||
bool IconExists(const CStr &str) const { return (m_Icons.count(str) != 0); }
|
||||
bool IconExists(const CStr& str) const { return (m_Icons.count(str) != 0); }
|
||||
|
||||
/**
|
||||
* Get Icon (a copy, can never be changed)
|
||||
*/
|
||||
SGUIIcon GetIcon(const CStr &str) const { return m_Icons.find(str)->second; }
|
||||
SGUIIcon GetIcon(const CStr& str) const { return m_Icons.find(str)->second; }
|
||||
|
||||
/**
|
||||
* Get pre-defined color (if it exists)
|
||||
* Returns false if it fails.
|
||||
*/
|
||||
bool GetPreDefinedColor(const CStr &name, CColor &Output);
|
||||
bool GetPreDefinedColor(const CStr& name, CColor &Output);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -32,7 +32,7 @@ CGUISpriteInstance::CGUISpriteInstance()
|
||||
{
|
||||
}
|
||||
|
||||
CGUISpriteInstance::CGUISpriteInstance(CStr SpriteName)
|
||||
CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName)
|
||||
: m_SpriteName(SpriteName)
|
||||
{
|
||||
}
|
||||
@ -42,7 +42,7 @@ CGUISpriteInstance::CGUISpriteInstance(const CGUISpriteInstance &Sprite)
|
||||
{
|
||||
}
|
||||
|
||||
CGUISpriteInstance &CGUISpriteInstance::operator=(CStr SpriteName)
|
||||
CGUISpriteInstance &CGUISpriteInstance::operator=(const CStr& SpriteName)
|
||||
{
|
||||
m_SpriteName = SpriteName;
|
||||
m_DrawCallCache.clear();
|
||||
|
@ -142,13 +142,13 @@ class CGUISpriteInstance
|
||||
{
|
||||
public:
|
||||
CGUISpriteInstance();
|
||||
CGUISpriteInstance(CStr SpriteName);
|
||||
CGUISpriteInstance(const CStr& SpriteName);
|
||||
CGUISpriteInstance(const CGUISpriteInstance &Sprite);
|
||||
CGUISpriteInstance &operator=(CStr SpriteName);
|
||||
CGUISpriteInstance &operator=(const CStr& SpriteName);
|
||||
void Draw(CRect Size, int CellID, std::map<CStr, CGUISprite> &Sprites);
|
||||
void Invalidate();
|
||||
bool IsEmpty() const;
|
||||
CStr GetName() { return m_SpriteName; }
|
||||
const CStr& GetName() { return m_SpriteName; }
|
||||
|
||||
private:
|
||||
CStr m_SpriteName;
|
||||
|
@ -301,9 +301,9 @@ void CList::Draw()
|
||||
}
|
||||
|
||||
void CList::DrawList(const int &selected,
|
||||
const CStr &_sprite,
|
||||
const CStr &_sprite_selected,
|
||||
const CStr &_textcolor)
|
||||
const CStr& _sprite,
|
||||
const CStr& _sprite_selected,
|
||||
const CStr& _textcolor)
|
||||
{
|
||||
float bz = GetBufferedZ();
|
||||
|
||||
|
@ -109,8 +109,8 @@ protected:
|
||||
|
||||
// Extended drawing interface, this is so that classes built on the this one
|
||||
// can use other sprite names.
|
||||
void DrawList(const int &selected, const CStr &_sprite,
|
||||
const CStr &_sprite_selected, const CStr &_textcolor);
|
||||
void DrawList(const int &selected, const CStr& _sprite,
|
||||
const CStr& _sprite_selected, const CStr& _textcolor);
|
||||
|
||||
// Get the area of the list. This is so that i can easily be changed, like in CDropDown
|
||||
// where the area is not equal to m_CachedActualSize.
|
||||
|
@ -321,7 +321,7 @@ public:
|
||||
|
||||
// Functions to perform drawing-related actions:
|
||||
|
||||
void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, CStr &SpriteName, CRect &Size, int CellID, std::map<CStr, CGUISprite> &Sprites)
|
||||
void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, CStr& SpriteName, CRect &Size, int CellID, std::map<CStr, CGUISprite> &Sprites)
|
||||
{
|
||||
// This is called only when something has changed (like the size of the
|
||||
// sprite), so it doesn't need to be particularly efficient.
|
||||
|
@ -51,7 +51,7 @@ namespace GUIRenderer
|
||||
|
||||
namespace GUIRenderer
|
||||
{
|
||||
void UpdateDrawCallCache(DrawCalls &Calls, CStr &SpriteName, CRect& Size, int CellID, std::map<CStr, CGUISprite> &Sprites);
|
||||
void UpdateDrawCallCache(DrawCalls &Calls, CStr&SpriteName, CRect& Size, int CellID, std::map<CStr, CGUISprite> &Sprites);
|
||||
|
||||
void Draw(DrawCalls &Calls);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ GUITooltip::GUITooltip()
|
||||
|
||||
const double CooldownTime = 0.25; // TODO: Don't hard-code this value
|
||||
|
||||
static bool GetTooltip(IGUIObject* obj, CStr &style)
|
||||
static bool GetTooltip(IGUIObject* obj, CStr&style)
|
||||
{
|
||||
if (obj && obj->SettingExists("tooltip_style")
|
||||
&& GUI<CStr>::GetSetting(obj, "tooltip_style", style) == PS_OK)
|
||||
|
@ -275,7 +275,7 @@ public:
|
||||
/**
|
||||
* Get String, without tags
|
||||
*/
|
||||
CStrW GetRawString() const { return m_RawString; }
|
||||
const CStrW& GetRawString() const { return m_RawString; }
|
||||
|
||||
/**
|
||||
* Generate Text Call from specified range. The range
|
||||
|
@ -159,7 +159,7 @@ bool __ParseString<CPos>(const CStr& Value, CPos &Output)
|
||||
}
|
||||
|
||||
template <>
|
||||
bool __ParseString<EAlign>(const CStr &Value, EAlign &Output)
|
||||
bool __ParseString<EAlign>(const CStr& Value, EAlign &Output)
|
||||
{
|
||||
if (Value == "left")
|
||||
Output = EAlign_Left;
|
||||
@ -176,7 +176,7 @@ bool __ParseString<EAlign>(const CStr &Value, EAlign &Output)
|
||||
}
|
||||
|
||||
template <>
|
||||
bool __ParseString<EVAlign>(const CStr &Value, EVAlign &Output)
|
||||
bool __ParseString<EVAlign>(const CStr& Value, EVAlign &Output)
|
||||
{
|
||||
if (Value == "top")
|
||||
Output = EVAlign_Top;
|
||||
@ -203,7 +203,7 @@ bool __ParseString<CGUIString>(const CStr& Value, CGUIString &Output)
|
||||
}
|
||||
|
||||
template <>
|
||||
bool __ParseString<CStr>(const CStr& Value, CStr &Output)
|
||||
bool __ParseString<CStr>(const CStr& Value, CStr&Output)
|
||||
{
|
||||
// Do very little.
|
||||
Output = Value;
|
||||
@ -211,7 +211,7 @@ bool __ParseString<CStr>(const CStr& Value, CStr &Output)
|
||||
}
|
||||
|
||||
template <>
|
||||
bool __ParseString<CStrW>(const CStr& Value, CStrW &Output)
|
||||
bool __ParseString<CStrW>(const CStr& Value, CStrW& Output)
|
||||
{
|
||||
// Translate the Value and retrieve the localised string in
|
||||
// Unicode.
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
//@{
|
||||
|
||||
/// Get object name, name is unique
|
||||
CStr GetName() const { return m_Name; }
|
||||
const CStr& GetName() const { return m_Name; }
|
||||
|
||||
/// Get object name
|
||||
void SetName(const CStr& Name) { m_Name = Name; }
|
||||
|
@ -327,7 +327,7 @@ static inline void pre_libc_init()
|
||||
static int SEH_wrapped_entry()
|
||||
{
|
||||
int ret;
|
||||
__try
|
||||
//__try
|
||||
{
|
||||
pre_libc_init();
|
||||
#ifdef USE_WINMAIN
|
||||
@ -336,7 +336,7 @@ static int SEH_wrapped_entry()
|
||||
ret = mainCRTStartup(); // calls _cinit and then our main
|
||||
#endif
|
||||
}
|
||||
__except(wdbg_exception_filter(GetExceptionInformation()))
|
||||
//__except(wdbg_exception_filter(GetExceptionInformation()))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ void CConsole::SetBuffer(const wchar_t* szMessage, ...)
|
||||
m_iBufferPos = std::min(oldBufferPos, m_iBufferLength);
|
||||
}
|
||||
|
||||
void CConsole::UseHistoryFile( CStr filename, int max_history_lines )
|
||||
void CConsole::UseHistoryFile( const CStr& filename, int max_history_lines )
|
||||
{
|
||||
m_MaxHistoryLines = max_history_lines;
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
|
||||
void SetBuffer(const wchar_t* szMessage, ...);
|
||||
|
||||
void UseHistoryFile( CStr filename, int historysize );
|
||||
void UseHistoryFile( const CStr& filename, int historysize );
|
||||
|
||||
// Only returns a pointer to the buffer; copy out of here if you want to keep it.
|
||||
const wchar_t* GetBuffer();
|
||||
|
@ -16,7 +16,7 @@
|
||||
// Only include these function definitions in the first instance of CStr.cpp:
|
||||
|
||||
CStrW::CStrW(const CStr8 &asciStr) : std::wstring(asciStr.begin(), asciStr.end()) {}
|
||||
CStr8::CStr8(const CStrW &wideStr) : std:: string(wideStr.begin(), wideStr.end()) {}
|
||||
CStr8::CStr8(const CStrW& wideStr) : std:: string(wideStr.begin(), wideStr.end()) {}
|
||||
|
||||
// UTF conversion code adapted from http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
|
||||
|
||||
@ -156,7 +156,7 @@ using namespace std;
|
||||
#define _totupper toupper
|
||||
#endif
|
||||
|
||||
CStr CStr::Repeat(CStr String, size_t Reps)
|
||||
CStr CStr::Repeat(const CStr& String, size_t Reps)
|
||||
{
|
||||
CStr ret;
|
||||
ret.reserve(String.Length() * Reps);
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
CStr(std::tstring String) : std::tstring(String) {}
|
||||
|
||||
// Named constructor, to avoid overload overload.
|
||||
static CStr Repeat(CStr String, size_t Reps);
|
||||
static CStr Repeat(const CStr& String, size_t Reps);
|
||||
|
||||
// CStr(8|W) construction from utf16strings.
|
||||
// allowed on MSVC as of 2006-02-03 because utf16string is
|
||||
@ -100,7 +100,7 @@ public:
|
||||
// Transparent CStrW/8 conversion. Non-ASCII characters are not
|
||||
// handled correctly.
|
||||
#ifndef _UNICODE
|
||||
CStr8(const CStrW &wideStr);
|
||||
CStr8(const CStrW& wideStr);
|
||||
#else
|
||||
CStrW(const CStr8 &asciiStr);
|
||||
#endif
|
||||
|
@ -191,14 +191,14 @@ CConfigDB::CConfigDB()
|
||||
g_ScriptingHost.SetGlobal("g_ConfigDB", OBJECT_TO_JSVAL(js_ConfigDB));
|
||||
}
|
||||
|
||||
CConfigValue *CConfigDB::GetValue(EConfigNamespace ns, CStr name)
|
||||
CConfigValue *CConfigDB::GetValue(EConfigNamespace ns, const CStr& name)
|
||||
{
|
||||
CConfigValueSet* values = GetValues( ns, name );
|
||||
if( !values ) return( NULL );
|
||||
return &( (*values)[0] );
|
||||
}
|
||||
|
||||
CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name )
|
||||
CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, const CStr& name )
|
||||
{
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
@ -216,7 +216,7 @@ CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name)
|
||||
CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, const CStr& name)
|
||||
{
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
@ -227,7 +227,7 @@ CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name)
|
||||
return &(it->second[0]);
|
||||
}
|
||||
|
||||
void CConfigDB::SetConfigFile(EConfigNamespace ns, bool useVFS, CStr path)
|
||||
void CConfigDB::SetConfigFile(EConfigNamespace ns, bool useVFS, const CStr& path)
|
||||
{
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
@ -326,7 +326,7 @@ bool CConfigDB::Reload(EConfigNamespace ns)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, CStr path)
|
||||
bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, const CStr& path)
|
||||
{
|
||||
debug_assert(ns >= 0 && ns < CFG_LAST);
|
||||
|
||||
|
@ -72,14 +72,14 @@ public:
|
||||
//
|
||||
// Returns a pointer to the config value structure for the variable, or
|
||||
// NULL if such a variable could not be found
|
||||
CConfigValue *GetValue(EConfigNamespace ns, CStr name);
|
||||
CConfigValue *GetValue(EConfigNamespace ns, const CStr& name);
|
||||
|
||||
// GetValues()
|
||||
// Attempt to retrieve a vector of values corresponding to the given setting;
|
||||
// will search all namespaces from system up to the specified namespace.
|
||||
//
|
||||
// Returns a pointer to the vector, or NULL if the setting could not be found.
|
||||
CConfigValueSet *GetValues(EConfigNamespace ns, CStr name);
|
||||
CConfigValueSet *GetValues(EConfigNamespace ns, const CStr& name);
|
||||
|
||||
// CreateValue()
|
||||
// Create a new config value in the specified namespace. If such a
|
||||
@ -88,7 +88,7 @@ public:
|
||||
//
|
||||
// Returns a pointer to the value of the newly created config variable, or
|
||||
// that of the already existing config variable.
|
||||
CConfigValue *CreateValue(EConfigNamespace ns, CStr name);
|
||||
CConfigValue *CreateValue(EConfigNamespace ns, const CStr& name);
|
||||
|
||||
// SetConfigFile()
|
||||
// Set the path to the config file used to populate the specified namespace
|
||||
@ -99,7 +99,7 @@ public:
|
||||
// VFS: relative to VFS root
|
||||
// non-VFS: relative to current working directory (binaries/data/)
|
||||
// 'useVFS': true if the path is a VFS path, false if it is a real path
|
||||
void SetConfigFile(EConfigNamespace ns, bool useVFS, CStr path);
|
||||
void SetConfigFile(EConfigNamespace ns, bool useVFS, const CStr& path);
|
||||
|
||||
// Reload()
|
||||
// Reload the config file associated with the specified config namespace
|
||||
@ -117,7 +117,7 @@ public:
|
||||
// Returns:
|
||||
// true: if the config namespace was successfully written to the file
|
||||
// false: if an error occured
|
||||
bool WriteFile(EConfigNamespace ns, bool useVFS, CStr path);
|
||||
bool WriteFile(EConfigNamespace ns, bool useVFS, const CStr& path);
|
||||
};
|
||||
|
||||
|
||||
|
@ -387,7 +387,7 @@ void CGameAttributes::FinalizeSlots()
|
||||
m_NumSlots=assignedSlots;
|
||||
}
|
||||
|
||||
void CGameAttributes::SetValue(CStrW name, CStrW value)
|
||||
void CGameAttributes::SetValue(const CStrW& name, const CStrW& value)
|
||||
{
|
||||
ISynchedJSProperty *prop=GetSynchedProperty(name);
|
||||
if (prop)
|
||||
@ -396,7 +396,7 @@ void CGameAttributes::SetValue(CStrW name, CStrW value)
|
||||
}
|
||||
}
|
||||
|
||||
void CGameAttributes::Update(CStrW name, ISynchedJSProperty *attrib)
|
||||
void CGameAttributes::Update(const CStrW& name, ISynchedJSProperty *attrib)
|
||||
{
|
||||
if (m_UpdateCB)
|
||||
m_UpdateCB(name, attrib->ToString(), m_UpdateCBData);
|
||||
|
@ -113,7 +113,7 @@ class CGameAttributes:
|
||||
public Singleton<CGameAttributes>
|
||||
{
|
||||
public:
|
||||
typedef void (UpdateCallback)(CStrW name, CStrW newValue, void *data);
|
||||
typedef void (UpdateCallback)(const CStrW& name, const CStrW& newValue, void *data);
|
||||
|
||||
CStrW m_MapFile;
|
||||
CStrW m_ResourceLevel;
|
||||
@ -143,7 +143,7 @@ private:
|
||||
PlayerSlotAssignmentCB *m_PlayerSlotAssignmentCB;
|
||||
void *m_PlayerSlotAssignmentCBData;
|
||||
|
||||
virtual void Update(CStrW name, ISynchedJSProperty *attrib);
|
||||
virtual void Update(const CStrW& name, ISynchedJSProperty *attrib);
|
||||
static void OnNumSlotsUpdate(CSynchedJSObjectBase *owner);
|
||||
|
||||
jsval JSI_GetPlayerSlots(JSContext* cx);
|
||||
@ -154,7 +154,7 @@ public:
|
||||
CGameAttributes();
|
||||
virtual ~CGameAttributes();
|
||||
|
||||
void SetValue(CStrW name, CStrW value);
|
||||
void SetValue(const CStrW& name, const CStrW& value);
|
||||
|
||||
inline void SetUpdateCallback(UpdateCallback *cb, void *userdata)
|
||||
{
|
||||
|
@ -12,8 +12,8 @@ class CGameRecord
|
||||
CTurnManager *m_pTurnManager;
|
||||
|
||||
public:
|
||||
void Load(CStr filename);
|
||||
void Record(CStr filename);
|
||||
void Load(const CStr& filename);
|
||||
void Record(const CStr& filename);
|
||||
|
||||
bool IsRecording();
|
||||
|
||||
|
@ -46,7 +46,7 @@ CStr g_AutostartMap = "";
|
||||
// config and profile
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
static void LoadProfile( CStr profile )
|
||||
static void LoadProfile( const CStr& profile )
|
||||
{
|
||||
CStr base = CStr( "profiles/" ) + profile;
|
||||
g_ConfigDB.SetConfigFile(CFG_USER, true, base + "/settings/user.cfg");
|
||||
|
@ -118,7 +118,7 @@ extern void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName
|
||||
|
||||
extern void initKeyNameMap();
|
||||
extern CStr getKeyName( int keycode );
|
||||
extern int getKeyCode( CStr keyname );
|
||||
extern int getKeyCode( const CStr& keyname );
|
||||
|
||||
extern bool keyRespondsTo( int hotkey, int sdlkey );
|
||||
|
||||
|
@ -295,7 +295,7 @@ void initKeyNameMap()
|
||||
};
|
||||
}
|
||||
|
||||
int getKeyCode( CStr keyname )
|
||||
int getKeyCode( const CStr& keyname )
|
||||
{
|
||||
std::map<CStr,int>::iterator it;
|
||||
it = keymap.find( keyname.LowerCase() );
|
||||
|
@ -20,7 +20,7 @@ CNetClient *g_NetClient=NULL;
|
||||
extern "C" int fps;
|
||||
extern CConsole *g_Console;
|
||||
|
||||
CNetClient::CServerSession::CServerSession(int sessionID, const CStrW &name):
|
||||
CNetClient::CServerSession::CServerSession(int sessionID, const CStrW& name):
|
||||
m_SessionID(sessionID),
|
||||
m_Name(name)
|
||||
{
|
||||
@ -387,7 +387,7 @@ bool CNetClient::ChatHandler(CNetMessage *pMsg, CNetSession *pSession)
|
||||
}
|
||||
}
|
||||
|
||||
void CNetClient::OnClientConnect(int sessionID, const CStrW &name)
|
||||
void CNetClient::OnClientConnect(int sessionID, const CStrW& name)
|
||||
{
|
||||
// Find existing server session, if any, and delete it
|
||||
SessionMap::iterator it=m_ServerSessions.find(sessionID);
|
||||
|
@ -23,7 +23,7 @@ class CNetClient: public CNetSession, protected CTurnManager, public CJSObject<C
|
||||
static void ScriptingInit();
|
||||
|
||||
public:
|
||||
CServerSession(int sessionID, const CStrW &name);
|
||||
CServerSession(int sessionID, const CStrW& name);
|
||||
|
||||
int m_SessionID;
|
||||
CStrW m_Name;
|
||||
@ -48,7 +48,7 @@ class CNetClient: public CNetSession, protected CTurnManager, public CJSObject<C
|
||||
CScriptObject m_OnClientConnect;
|
||||
CScriptObject m_OnClientDisconnect;
|
||||
|
||||
void OnClientConnect(int sessionID, const CStrW &name);
|
||||
void OnClientConnect(int sessionID, const CStrW& name);
|
||||
void OnClientDisconnect(int sessionID);
|
||||
|
||||
// JS Interface Functions
|
||||
|
@ -29,7 +29,7 @@ class CChatEvent: public CScriptEvent
|
||||
CStrW m_Message;
|
||||
|
||||
public:
|
||||
CChatEvent(CStrW sender, CStrW message):
|
||||
CChatEvent(const CStrW& sender, const CStrW& message):
|
||||
CScriptEvent(L"chat", NET_JS_EVENT_CHAT, false ),
|
||||
m_Sender(sender),
|
||||
m_Message(message)
|
||||
@ -45,7 +45,7 @@ class CConnectCompleteEvent: public CScriptEvent
|
||||
bool m_Success;
|
||||
|
||||
public:
|
||||
CConnectCompleteEvent(CStrW message, bool success):
|
||||
CConnectCompleteEvent(const CStrW& message, bool success):
|
||||
CScriptEvent(L"connectComplete", NET_JS_EVENT_CONNECT_COMPLETE, false),
|
||||
m_Message(message),
|
||||
m_Success(success)
|
||||
@ -60,7 +60,7 @@ class CDisconnectEvent: public CScriptEvent
|
||||
CStrW m_Message;
|
||||
|
||||
public:
|
||||
CDisconnectEvent(CStrW message):
|
||||
CDisconnectEvent(const CStrW& message):
|
||||
CScriptEvent(L"disconnect", NET_JS_EVENT_DISCONNECT, false),
|
||||
m_Message(message)
|
||||
{
|
||||
@ -76,7 +76,7 @@ class CClientConnectDisconnectCommon: public CScriptEvent
|
||||
|
||||
public:
|
||||
CClientConnectDisconnectCommon(const wchar_t* UNUSED(eventName), int UNUSED(eventType),
|
||||
int sessionID, const CStrW &name, CNetServerSession* pSession)
|
||||
int sessionID, const CStrW& name, CNetServerSession* pSession)
|
||||
: CScriptEvent(L"clientConnect", NET_JS_EVENT_CLIENT_CONNECT, false),
|
||||
m_SessionID(sessionID),
|
||||
m_Name(name),
|
||||
@ -91,7 +91,7 @@ public:
|
||||
|
||||
struct CClientConnectEvent: public CClientConnectDisconnectCommon
|
||||
{
|
||||
CClientConnectEvent(int sessionID, const CStrW &name):
|
||||
CClientConnectEvent(int sessionID, const CStrW& name):
|
||||
CClientConnectDisconnectCommon(
|
||||
L"clientConnect",
|
||||
NET_JS_EVENT_CLIENT_CONNECT,
|
||||
@ -112,7 +112,7 @@ struct CClientConnectEvent: public CClientConnectDisconnectCommon
|
||||
|
||||
struct CClientDisconnectEvent: public CClientConnectDisconnectCommon
|
||||
{
|
||||
CClientDisconnectEvent(int sessionID, const CStrW &name):
|
||||
CClientDisconnectEvent(int sessionID, const CStrW& name):
|
||||
CClientConnectDisconnectCommon(
|
||||
L"clientDisconnect",
|
||||
NET_JS_EVENT_CLIENT_DISCONNECT,
|
||||
|
@ -282,7 +282,7 @@ CNetMessage *CNetMessage::CreateEntityIntMessage( const CEntityList& entities, c
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
CNetMessage *CNetMessage::CreateProduceMessage( const CEntityList& entities, const int type, int proType, CStrW name )
|
||||
CNetMessage *CNetMessage::CreateProduceMessage( const CEntityList& entities, const int type, int proType, const CStrW& name )
|
||||
{
|
||||
#define ProMessage(_msg)\
|
||||
case NMT_ ## _msg: \
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
//These can create a net message without JS args
|
||||
static CNetMessage *CreatePositionMessage( const CEntityList& entities, const int type, CVector2D pos );
|
||||
static CNetMessage *CreateEntityIntMessage( const CEntityList& entities, const int type, HEntity& target, int action );
|
||||
static CNetMessage *CreateProduceMessage( const CEntityList& entities, const int type, int proType, CStrW name );
|
||||
static CNetMessage *CreateProduceMessage( const CEntityList& entities, const int type, int proType, const CStrW& name );
|
||||
};
|
||||
|
||||
typedef CNetMessage * (*NetMessageDeserializer) (const u8 *buffer, uint length);
|
||||
|
@ -133,7 +133,7 @@ PS_RESULT CNetServer::Bind(const CSocketAddress &address)
|
||||
return res;
|
||||
}
|
||||
|
||||
void FillSetGameConfigCB(CStrW name, ISynchedJSProperty *prop, void *userdata)
|
||||
void FillSetGameConfigCB(const CStrW& name, ISynchedJSProperty *prop, void *userdata)
|
||||
{
|
||||
CSetGameConfig *pMsg=(CSetGameConfig *)userdata;
|
||||
size_t size=pMsg->m_Values.size();
|
||||
@ -147,7 +147,7 @@ void CNetServer::FillSetGameConfig(CSetGameConfig *pMsg)
|
||||
m_pGameAttributes->IterateSynchedProperties(FillSetGameConfigCB, pMsg);
|
||||
}
|
||||
|
||||
void FillSetPlayerConfigCB(CStrW name, ISynchedJSProperty *prop, void *userdata)
|
||||
void FillSetPlayerConfigCB(const CStrW& name, ISynchedJSProperty *prop, void *userdata)
|
||||
{
|
||||
CSetPlayerConfig *pMsg=(CSetPlayerConfig *)userdata;
|
||||
size_t size=pMsg->m_Values.size();
|
||||
@ -219,7 +219,7 @@ void CNetServer::AddSession(CNetServerSession *pSession)
|
||||
OnClientConnect(pSession);
|
||||
}
|
||||
|
||||
void CNetServer::AttributeUpdate(CStrW name, CStrW newValue, void *userdata)
|
||||
void CNetServer::AttributeUpdate(const CStrW& name, const CStrW& newValue, void *userdata)
|
||||
{
|
||||
CNetServer *pServer=(CNetServer *)userdata;
|
||||
g_Console->InsertMessage(L"AttributeUpdate: %ls = \"%ls\"", name.c_str(), newValue.c_str());
|
||||
@ -232,7 +232,7 @@ void CNetServer::AttributeUpdate(CStrW name, CStrW newValue, void *userdata)
|
||||
pServer->Broadcast(pMsg);
|
||||
}
|
||||
|
||||
void CNetServer::PlayerAttributeUpdate(CStrW name, CStrW newValue, CPlayer *pPlayer, void *userdata)
|
||||
void CNetServer::PlayerAttributeUpdate(const CStrW& name, const CStrW& newValue, CPlayer *pPlayer, void *userdata)
|
||||
{
|
||||
CNetServer *pServer=(CNetServer *)userdata;
|
||||
g_Console->InsertMessage(L"PlayerAttributeUpdate(%d): %ls = \"%ls\"", pPlayer->GetPlayerID(), name.c_str(), newValue.c_str());
|
||||
@ -404,7 +404,7 @@ void CNetServer::QueueIncomingCommand(CNetMessage *pMsg)
|
||||
QueueMessage(2, pMsg);
|
||||
}
|
||||
|
||||
void CNetServer::OnChat(CStrW from, CStrW message)
|
||||
void CNetServer::OnChat(const CStrW& from, const CStrW& message)
|
||||
{
|
||||
if (m_OnChat.Defined())
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ protected:
|
||||
void QueueIncomingCommand(CNetMessage *pMsg);
|
||||
|
||||
// Call the JS callback for incoming events
|
||||
void OnChat(CStrW from, CStrW message);
|
||||
void OnChat(const CStrW& from, const CStrW& message);
|
||||
void OnClientConnect(CNetServerSession *pSession);
|
||||
void OnClientDisconnect(CNetServerSession *pSession);
|
||||
|
||||
@ -129,10 +129,10 @@ public:
|
||||
static void GetDefaultListenAddress(CSocketAddress &address);
|
||||
PS_RESULT Bind(const CSocketAddress &address);
|
||||
|
||||
inline void SetPassword(CStr password)
|
||||
inline void SetPassword(const CStr& password)
|
||||
{ m_Password=password; }
|
||||
|
||||
inline CStrW GetServerPlayerName()
|
||||
inline const CStrW& GetServerPlayerName()
|
||||
{ return m_ServerPlayerName; }
|
||||
|
||||
inline ENetServerState GetServerState()
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
inline CStrW GetName()
|
||||
inline const CStrW& GetName()
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ void CPlayer::ScriptingInit()
|
||||
CJSObject<CPlayer>::ScriptingInit( "Player" );
|
||||
}
|
||||
|
||||
void CPlayer::Update(CStrW name, ISynchedJSProperty *prop)
|
||||
void CPlayer::Update(const CStrW& name, ISynchedJSProperty *prop)
|
||||
{
|
||||
if (m_UpdateCB)
|
||||
m_UpdateCB(name, prop->ToString(), this, m_UpdateCBData);
|
||||
}
|
||||
|
||||
void CPlayer::SetValue(CStrW name, CStrW value)
|
||||
void CPlayer::SetValue(const CStrW& name, const CStrW& value)
|
||||
{
|
||||
ISynchedJSProperty *prop=GetSynchedProperty(name);
|
||||
if (prop)
|
||||
|
@ -15,7 +15,7 @@ typedef SColour SPlayerColour;
|
||||
class CPlayer : public CSynchedJSObject<CPlayer>
|
||||
{
|
||||
public:
|
||||
typedef void (UpdateCallback)(CStrW name, CStrW value, CPlayer *player, void *userdata);
|
||||
typedef void (UpdateCallback)(const CStrW& name, const CStrW& value, CPlayer *player, void *userdata);
|
||||
|
||||
private:
|
||||
CStrW m_Name;
|
||||
@ -29,7 +29,7 @@ private:
|
||||
|
||||
std::vector<CTechnology*> m_ActiveTechs;
|
||||
|
||||
virtual void Update(CStrW name, ISynchedJSProperty *prop);
|
||||
virtual void Update(const CStrW& name, ISynchedJSProperty *prop);
|
||||
|
||||
public:
|
||||
CPlayer( uint playerID );
|
||||
@ -45,9 +45,9 @@ public:
|
||||
inline PS_uint GetLOSToken() const
|
||||
{ return m_LOSToken; }
|
||||
|
||||
inline const CStrW &GetName() const
|
||||
inline const CStrW& GetName() const
|
||||
{ return m_Name; }
|
||||
inline void SetName(const CStrW &name)
|
||||
inline void SetName(const CStrW& name)
|
||||
{ m_Name = name; }
|
||||
|
||||
inline const SPlayerColour &GetColour() const
|
||||
@ -60,7 +60,7 @@ public:
|
||||
m_UpdateCB=cb;
|
||||
m_UpdateCBData=userdata;
|
||||
}
|
||||
void SetValue(CStrW name, CStrW value);
|
||||
void SetValue(const CStrW& name, const CStrW& value);
|
||||
|
||||
inline void AddActiveTech(CTechnology* tech)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
|
||||
bool StoreVFS(Handle h);
|
||||
|
||||
CStr HACK_GetData() { return m_Data; }
|
||||
const CStr& HACK_GetData() { return m_Data; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -666,7 +666,7 @@ CStr CRenderer::GetRenderPathName(RenderPath rp)
|
||||
}
|
||||
}
|
||||
|
||||
CRenderer::RenderPath CRenderer::GetRenderPathByName(CStr name)
|
||||
CRenderer::RenderPath CRenderer::GetRenderPathByName(const CStr& name)
|
||||
{
|
||||
if (name == "fixed")
|
||||
return RP_FIXED;
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
void SetRenderPath(RenderPath rp);
|
||||
RenderPath GetRenderPath() const { return m_Options.m_RenderPath; }
|
||||
static CStr GetRenderPathName(RenderPath rp);
|
||||
static RenderPath GetRenderPathByName(CStr name);
|
||||
static RenderPath GetRenderPathByName(const CStr& name);
|
||||
|
||||
// return view width
|
||||
int GetWidth() const { return m_Width; }
|
||||
|
@ -117,7 +117,7 @@ void SkyManager::UnloadSkyTextures()
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Switch to a different sky set (while the game is running)
|
||||
void SkyManager::SetSkySet( CStrW newSet )
|
||||
void SkyManager::SetSkySet( const CStrW& newSet )
|
||||
{
|
||||
if( newSet != m_SkySet )
|
||||
{
|
||||
|
@ -49,14 +49,14 @@ public:
|
||||
/**
|
||||
* GetSkySet(): Return the currently selected sky set name.
|
||||
*/
|
||||
inline CStrW GetSkySet() const {
|
||||
inline const CStrW& GetSkySet() const {
|
||||
return m_SkySet;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetSkySet(): Set the sky set name, potentially loading the textures.
|
||||
*/
|
||||
void SetSkySet(CStrW name);
|
||||
void SetSkySet(const CStrW& name);
|
||||
|
||||
/**
|
||||
* Return a sorted list of available sky sets, in a form suitable
|
||||
|
@ -80,7 +80,7 @@ bool IEventTarget::AddHandler( int TypeCode, DOMEventHandler handler )
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool IEventTarget::AddHandler( CStrW TypeString, DOMEventHandler handler )
|
||||
bool IEventTarget::AddHandler( const CStrW& TypeString, DOMEventHandler handler )
|
||||
{
|
||||
HandlerMap::iterator it;
|
||||
HandlerRange range = m_Handlers_name.equal_range( TypeString );
|
||||
@ -103,7 +103,7 @@ bool IEventTarget::RemoveHandler( int TypeCode, DOMEventHandler handler )
|
||||
return( false );
|
||||
}
|
||||
|
||||
bool IEventTarget::RemoveHandler( CStrW TypeString, DOMEventHandler handler )
|
||||
bool IEventTarget::RemoveHandler( const CStrW& TypeString, DOMEventHandler handler )
|
||||
{
|
||||
HandlerMap::iterator it;
|
||||
HandlerRange range = m_Handlers_name.equal_range( TypeString );
|
||||
|
@ -57,11 +57,11 @@ public:
|
||||
// Register a handler for the given event type.
|
||||
// Returns false if the handler was already present
|
||||
bool AddHandler( int TypeCode, DOMEventHandler handler );
|
||||
bool AddHandler( CStrW TypeString, DOMEventHandler handler );
|
||||
bool AddHandler( const CStrW& TypeString, DOMEventHandler handler );
|
||||
// Remove a previously registered handler for the specified event.
|
||||
// Returns false if the handler was not present
|
||||
bool RemoveHandler( int TypeCode, DOMEventHandler handler );
|
||||
bool RemoveHandler( CStrW TypeString, DOMEventHandler handler );
|
||||
bool RemoveHandler( const CStrW& TypeString, DOMEventHandler handler );
|
||||
|
||||
// called by ScriptGlue.cpp for add|RemoveGlobalHandler
|
||||
bool AddHandlerJS( JSContext* cx, uintN argc, jsval* argv );
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
// Add a property (with immediate value)
|
||||
virtual void AddProperty( const CStrW& PropertyName, jsval Value ) = 0;
|
||||
virtual void AddProperty( const CStrW& PropertyName, CStrW Value ) = 0;
|
||||
virtual void AddProperty( const CStrW& PropertyName, const CStrW& Value ) = 0;
|
||||
|
||||
inline IJSObject() {}
|
||||
};
|
||||
@ -281,7 +281,7 @@ public:
|
||||
CJSValProperty* newProp = new CJSValProperty( Value );
|
||||
m_ScriptProperties[PropertyName] = newProp;
|
||||
}
|
||||
void AddProperty( const CStrW& PropertyName, CStrW Value )
|
||||
void AddProperty( const CStrW& PropertyName, const CStrW& Value )
|
||||
{
|
||||
AddProperty( PropertyName, JSParseString( Value ) );
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ CStrW ScriptingHost::ValueToUCString( const jsval value )
|
||||
return CStrW(ValueToUTF16(value));
|
||||
}
|
||||
|
||||
jsval ScriptingHost::UCStringToValue( const CStrW &str )
|
||||
jsval ScriptingHost::UCStringToValue( const CStrW& str )
|
||||
{
|
||||
utf16string utf16=str.utf16();
|
||||
return UTF16ToValue(utf16);
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
double ValueToDouble(const jsval value);
|
||||
|
||||
jsval UTF16ToValue(const utf16string &str);
|
||||
jsval UCStringToValue(const CStrW &str);
|
||||
jsval UCStringToValue(const CStrW& str);
|
||||
|
||||
static void ErrorReporter(JSContext * context, const char * message, JSErrorReport * report);
|
||||
};
|
||||
|
@ -11,16 +11,16 @@ CStrW ToNetString(const uint &val)
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetFromNetString(uint &val, CStrW string)
|
||||
void SetFromNetString(uint &val, const CStrW& string)
|
||||
{
|
||||
val=string.ToUInt();
|
||||
}
|
||||
|
||||
template <>
|
||||
CStrW ToNetString(const CStrW &data)
|
||||
CStrW ToNetString(const CStrW& data)
|
||||
{ return data; }
|
||||
|
||||
template <> void SetFromNetString(CStrW &data, CStrW string)
|
||||
template <> void SetFromNetString(CStrW& data, const CStrW& string)
|
||||
{ data=string; }
|
||||
|
||||
template <>
|
||||
@ -34,7 +34,7 @@ CStrW ToNetString(const SColour &data)
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetFromNetString(SColour &data, CStrW wstring)
|
||||
void SetFromNetString(SColour &data, const CStrW& wstring)
|
||||
{
|
||||
CParser &parser(CParserCache::Get("$value_$value_$value_$value"));
|
||||
CParserLine line;
|
||||
@ -67,7 +67,7 @@ void CSynchedJSObjectBase::IterateSynchedProperties(IterateCB *cb, void *userdat
|
||||
}
|
||||
}
|
||||
|
||||
ISynchedJSProperty *CSynchedJSObjectBase::GetSynchedProperty(CStrW name)
|
||||
ISynchedJSProperty *CSynchedJSObjectBase::GetSynchedProperty(const CStrW& name)
|
||||
{
|
||||
SynchedPropertyIterator prop=m_SynchedProperties.find(name);
|
||||
if (prop != m_SynchedProperties.end())
|
||||
|
@ -39,14 +39,14 @@
|
||||
#include "ScriptableObject.h"
|
||||
|
||||
template <typename T>
|
||||
void SetFromNetString(T &data, CStrW string);
|
||||
void SetFromNetString(T &data, const CStrW& string);
|
||||
|
||||
template <typename T>
|
||||
CStrW ToNetString(const T &data);
|
||||
|
||||
#define TYPE(type) \
|
||||
template <> CStrW ToNetString(const type &data); \
|
||||
template <> void SetFromNetString(type &data, CStrW string);
|
||||
template <> void SetFromNetString(type &data, const CStrW& string);
|
||||
|
||||
TYPE(uint)
|
||||
TYPE(CStrW)
|
||||
@ -56,7 +56,7 @@ TYPE(CStrW)
|
||||
class ISynchedJSProperty: public IJSProperty
|
||||
{
|
||||
public:
|
||||
virtual void FromString(CStrW value)=0;
|
||||
virtual void FromString(const CStrW& value)=0;
|
||||
virtual CStrW ToString()=0;
|
||||
};
|
||||
|
||||
@ -95,7 +95,7 @@ struct CSynchedJSObjectBase
|
||||
*m_Data = *( ((CSynchedJSProperty<PropType, ReadOnly>*)other)->m_Data );
|
||||
}
|
||||
|
||||
virtual void FromString(CStrW value)
|
||||
virtual void FromString(const CStrW& value)
|
||||
{
|
||||
SetFromNetString(*m_Data, value);
|
||||
if (m_Update)
|
||||
@ -108,7 +108,7 @@ struct CSynchedJSObjectBase
|
||||
}
|
||||
|
||||
public:
|
||||
inline CSynchedJSProperty(CStrW name, PropType* native, CSynchedJSObjectBase *owner, UpdateFn update=NULL):
|
||||
inline CSynchedJSProperty(const CStrW& name, PropType* native, CSynchedJSObjectBase *owner, UpdateFn update=NULL):
|
||||
m_Data(native),
|
||||
m_Name(name),
|
||||
m_Owner(owner),
|
||||
@ -126,12 +126,12 @@ protected:
|
||||
|
||||
// Called every time a property changes.
|
||||
// This is where the individual callbacks are dispatched from.
|
||||
virtual void Update(CStrW name, ISynchedJSProperty *prop)=0;
|
||||
virtual void Update(const CStrW& name, ISynchedJSProperty *prop)=0;
|
||||
|
||||
public:
|
||||
ISynchedJSProperty *GetSynchedProperty(CStrW name);
|
||||
ISynchedJSProperty *GetSynchedProperty(const CStrW& name);
|
||||
|
||||
typedef void (IterateCB)(CStrW name, ISynchedJSProperty *prop, void *userdata);
|
||||
typedef void (IterateCB)(const CStrW& name, ISynchedJSProperty *prop, void *userdata);
|
||||
void IterateSynchedProperties(IterateCB *cb, void *userdata);
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ extern int g_xres, g_yres;
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStrW>& actorSelections, CStrW building )
|
||||
CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStrW>& actorSelections, const CStrW& building )
|
||||
{
|
||||
ent_flags = 0;
|
||||
|
||||
@ -207,9 +207,7 @@ void CEntity::kill()
|
||||
m_listeners[i].m_sender->DestroyNotifier( this );
|
||||
DestroyAllNotifiers();
|
||||
|
||||
if( m_bounds )
|
||||
delete( m_bounds );
|
||||
m_bounds = NULL;
|
||||
SAFE_DELETE(m_bounds);
|
||||
|
||||
m_extant = false;
|
||||
|
||||
@ -226,7 +224,7 @@ void CEntity::kill()
|
||||
updateCollisionPatch();
|
||||
|
||||
|
||||
me = HEntity(); // will deallocate the entity, assuming nobody else has a reference to it
|
||||
me = HEntity(); // will deallocate the entity, assuming nobody else has a reference to it
|
||||
}
|
||||
|
||||
void CEntity::SetPlayer(CPlayer *pPlayer)
|
||||
@ -309,7 +307,6 @@ void CEntity::setClassSet( jsval value )
|
||||
|
||||
if( brk != 0 )
|
||||
{
|
||||
|
||||
if( entry[0] == '-' )
|
||||
{
|
||||
entry = entry.GetSubstring( 1, entry.Length() );
|
||||
|
@ -275,7 +275,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStrW>& actorSelections, CStrW building = L"" );
|
||||
CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStrW>& actorSelections, const CStrW& building = L"" );
|
||||
|
||||
uint processGotoHelper( CEntityOrder* current, size_t timestep_milli, HEntity& collide );
|
||||
|
||||
|
@ -99,7 +99,7 @@ HEntity CEntityManager::create( CEntityTemplate* base, CVector3D position, float
|
||||
return( HEntity( m_nextalloc++ ) );
|
||||
}
|
||||
|
||||
HEntity CEntityManager::create( CStrW templateName, CPlayer* player, CVector3D position, float orientation, CStrW building )
|
||||
HEntity CEntityManager::create( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation, CStrW building )
|
||||
{
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.getTemplate( templateName, player );
|
||||
debug_assert( base );
|
||||
@ -111,7 +111,7 @@ HEntity CEntityManager::create( CStrW templateName, CPlayer* player, CVector3D p
|
||||
return create( base, position, orientation, selections, building );
|
||||
}
|
||||
|
||||
HEntity CEntityManager::createFoundation( CStrW templateName, CPlayer* player, CVector3D position, float orientation )
|
||||
HEntity CEntityManager::createFoundation( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation )
|
||||
{
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.getTemplate( templateName, player );
|
||||
debug_assert( base );
|
||||
|
@ -58,10 +58,10 @@ public:
|
||||
HEntity create( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
const std::set<CStrW>& actorSelections, CStrW building = L"" );
|
||||
|
||||
HEntity create( CStrW templateName, CPlayer* player, CVector3D position,
|
||||
HEntity create( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
float orientation, CStrW building = L"" );
|
||||
|
||||
HEntity createFoundation( CStrW templateName, CPlayer* player, CVector3D position,
|
||||
HEntity createFoundation( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
float orientation );
|
||||
|
||||
HEntity* getByHandle( u16 index );
|
||||
|
@ -158,7 +158,7 @@ template<> class CBoundProperty<jsval> : public IBoundProperty
|
||||
public:
|
||||
CBoundProperty() { m_data = JSVAL_NULL; m_inherited = true; RootJSVal(); }
|
||||
CBoundProperty( const jsval value ) { set( value ); m_inherited = false; RootJSVal(); }
|
||||
CBoundProperty( CStrW value )
|
||||
CBoundProperty( const CStrW& value )
|
||||
{
|
||||
m_data = STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.getContext(), value ) );
|
||||
RootJSVal();
|
||||
|
@ -31,7 +31,7 @@ struct SClassSet
|
||||
|
||||
inline SClassSet() { m_Parent = NULL; }
|
||||
|
||||
inline bool IsMember( CStrW Test )
|
||||
inline bool IsMember( const CStrW& Test )
|
||||
{ return( m_Set.find( Test ) != m_Set.end() ); }
|
||||
|
||||
inline void SetParent( SClassSet* Parent )
|
||||
|
@ -150,7 +150,7 @@ void CEntityTemplate::rebuildClassSet()
|
||||
(*it)->rebuildClassSet();
|
||||
}
|
||||
|
||||
bool CEntityTemplate::loadXML( CStr filename )
|
||||
bool CEntityTemplate::loadXML( const CStr& filename )
|
||||
{
|
||||
CXeromyces XeroFile;
|
||||
if (XeroFile.Load(filename) != PSRETURN_OK)
|
||||
@ -341,10 +341,10 @@ bool CEntityTemplate::loadXML( CStr filename )
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEntityTemplate::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, CStrW BasePropertyName )
|
||||
void CEntityTemplate::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, const CStrW& BasePropertyName )
|
||||
{
|
||||
// Add a property, put the node text into it.
|
||||
CStrW PropertyName = BasePropertyName + CStr8( XeroFile.getElementString( Source.getNodeName() ) );
|
||||
CStrW PropertyName = BasePropertyName + CStrW( XeroFile.getElementString( Source.getNodeName() ) );
|
||||
|
||||
IJSComplexProperty* Existing = HasProperty( PropertyName );
|
||||
if( Existing )
|
||||
|
@ -38,9 +38,9 @@ public:
|
||||
CEntityTemplate( CPlayer* player );
|
||||
~CEntityTemplate();
|
||||
// Load from XML
|
||||
bool loadXML( CStr filename );
|
||||
bool loadXML( const CStr& filename );
|
||||
// Load a tree of properties from an XML (XMB) node.
|
||||
void XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, CStrW BasePropertyName );
|
||||
void XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, const CStrW& BasePropertyName );
|
||||
|
||||
// Base stats
|
||||
CEntityTemplate* m_base;
|
||||
|
@ -51,7 +51,7 @@ int CEntityTemplateCollection::loadTemplates()
|
||||
return 0;
|
||||
}
|
||||
|
||||
CEntityTemplate* CEntityTemplateCollection::getTemplate( CStrW name, CPlayer* player )
|
||||
CEntityTemplate* CEntityTemplateCollection::getTemplate( const CStrW& name, CPlayer* player )
|
||||
{
|
||||
// Find player ID
|
||||
int id = ( player == 0 ? NULL_PLAYER : player->GetPlayerID() );
|
||||
|
@ -39,7 +39,7 @@ class CEntityTemplateCollection : public Singleton<CEntityTemplateCollection>
|
||||
TemplateFilenameMap m_templateFilenames;
|
||||
public:
|
||||
~CEntityTemplateCollection();
|
||||
CEntityTemplate* getTemplate( CStrW entityType, CPlayer* player = 0 );
|
||||
CEntityTemplate* getTemplate( const CStrW& entityType, CPlayer* player = 0 );
|
||||
|
||||
// Load list of template filenames
|
||||
int loadTemplates();
|
||||
|
@ -10,7 +10,7 @@ CFormation::CFormation()
|
||||
{
|
||||
m_numSlots = 0;
|
||||
}
|
||||
bool CFormation::loadXML(CStr filename)
|
||||
bool CFormation::loadXML(const CStr& filename)
|
||||
{
|
||||
CXeromyces XeroFile;
|
||||
|
||||
|
@ -28,18 +28,18 @@ public:
|
||||
CFormation();
|
||||
~CFormation(){}
|
||||
|
||||
CStr GetBonus(){ return m_bonus; }
|
||||
CStr GetBonusBase(){ return m_bonusBase; }
|
||||
CStr GetBonusType(){ return m_bonusType; }
|
||||
const CStr& GetBonus(){ return m_bonus; }
|
||||
const CStr& GetBonusBase(){ return m_bonusBase; }
|
||||
const CStr& GetBonusType(){ return m_bonusType; }
|
||||
float GetBonusVal(){ return m_bonusVal; }
|
||||
|
||||
CStr GetPenalty(){ return m_penalty; }
|
||||
CStr GetPenaltyBase(){ return m_penaltyBase; }
|
||||
CStr GetPenaltyType(){ return m_penaltyType; }
|
||||
const CStr& GetPenalty(){ return m_penalty; }
|
||||
const CStr& GetPenaltyBase(){ return m_penaltyBase; }
|
||||
const CStr& GetPenaltyType(){ return m_penaltyType; }
|
||||
float GetPenaltyVal(){ return m_penaltyVal; }
|
||||
|
||||
CStr GetAnglePenalty(){ return m_anglePenalty; }
|
||||
CStr GetAnglePenaltyType(){ return m_anglePenaltyType; }
|
||||
const CStr& GetAnglePenalty(){ return m_anglePenalty; }
|
||||
const CStr& GetAnglePenaltyType(){ return m_anglePenaltyType; }
|
||||
int GetAnglePenaltyDivs(){ return m_anglePenaltyDivs; }
|
||||
float GetAnglePenaltyVal(){ return m_anglePenaltyVal; }
|
||||
|
||||
@ -76,7 +76,7 @@ private:
|
||||
//The key is the "order" of the slot
|
||||
std::map<int, FormationSlot> m_slots;
|
||||
|
||||
bool loadXML(CStr filename);
|
||||
bool loadXML(const CStr& filename);
|
||||
void AssignCategory(int order, CStr category); //takes care of formatting strings
|
||||
};
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ int CFormationCollection::loadTemplates()
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFormation* CFormationCollection::getTemplate( CStrW name )
|
||||
CFormation* CFormationCollection::getTemplate( const CStrW& name )
|
||||
{
|
||||
// Check whether this template has already been loaded
|
||||
templateMap::iterator it = m_templates.find( name );
|
||||
|
@ -25,7 +25,7 @@ class CFormationCollection : public Singleton<CFormationCollection>
|
||||
templateFilenameMap m_templateFilenames;
|
||||
public:
|
||||
~CFormationCollection();
|
||||
CFormation* getTemplate( CStrW formationType );
|
||||
CFormation* getTemplate( const CStrW& formationType );
|
||||
int loadTemplates();
|
||||
void LoadFile( const char* path );
|
||||
|
||||
|
@ -25,7 +25,7 @@ CTechnology::CTechnology( CPlayer* player ) : m_player(player)
|
||||
m_JSFirst = false;
|
||||
m_inProgress = false;
|
||||
}
|
||||
bool CTechnology::loadXML( CStr filename )
|
||||
bool CTechnology::loadXML( const CStr& filename )
|
||||
{
|
||||
CXeromyces XeroFile;
|
||||
|
||||
@ -176,7 +176,7 @@ bool CTechnology::loadELReq( XMBElement Req, CXeromyces& XeroFile )
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CTechnology::loadELEffect( XMBElement effect, CXeromyces& XeroFile, CStr& filename )
|
||||
bool CTechnology::loadELEffect( XMBElement effect, CXeromyces& XeroFile, const CStr& filename )
|
||||
{
|
||||
#define EL(x) int el_##x = XeroFile.getElementID(#x)
|
||||
#define AT(x) int at_##x = XeroFile.getAttributeID(#x)
|
||||
|
@ -46,10 +46,10 @@ public:
|
||||
|
||||
void setExclusion( bool exclude ) { m_excluded=exclude; }
|
||||
|
||||
bool loadXML( CStr filename );
|
||||
bool loadXML( const CStr& filename );
|
||||
bool loadELID( XMBElement ID, CXeromyces& XeroFile );
|
||||
bool loadELReq( XMBElement Req, CXeromyces& XeroFile );
|
||||
bool loadELEffect( XMBElement Effect, CXeromyces& XeroFile, CStr& filename );
|
||||
bool loadELEffect( XMBElement Effect, CXeromyces& XeroFile, const CStr& filename );
|
||||
|
||||
private:
|
||||
CStr m_Generic;
|
||||
|
@ -28,7 +28,7 @@ int CTechnologyCollection::loadTechnologies()
|
||||
return 0;
|
||||
}
|
||||
|
||||
CTechnology* CTechnologyCollection::getTechnology( CStrW name, CPlayer* player )
|
||||
CTechnology* CTechnologyCollection::getTechnology( const CStrW& name, CPlayer* player )
|
||||
{
|
||||
// Find player ID
|
||||
debug_assert( player != 0 );
|
||||
|
@ -23,7 +23,7 @@ class CTechnologyCollection : public Singleton<CTechnologyCollection>
|
||||
public:
|
||||
std::vector<CTechnology*> activeTechs[PS_MAX_PLAYERS+1];
|
||||
|
||||
CTechnology* getTechnology( CStrW techType, CPlayer* player );
|
||||
CTechnology* getTechnology( const CStrW& techType, CPlayer* player );
|
||||
~CTechnologyCollection();
|
||||
|
||||
int loadTechnologies();
|
||||
|
Loading…
Reference in New Issue
Block a user