diff --git a/source/collada/CommonConvert.cpp b/source/collada/CommonConvert.cpp index 6998e21c0c..3d7a5e702c 100644 --- a/source/collada/CommonConvert.cpp +++ b/source/collada/CommonConvert.cpp @@ -204,7 +204,7 @@ static bool IsVisible_XSI(FCDSceneNode* node, bool& visible) static bool IsVisible(FCDSceneNode* node) { - bool visible; + bool visible = false; // Try the XSI visibility property if (IsVisible_XSI(node, visible)) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 66db1f17fc..7d0636b230 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -513,7 +513,7 @@ void CGUI::Draw() glPopMatrix(); } -void CGUI::DrawSprite(CGUISpriteInstance& Sprite, +void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Z, const CRect& Rect, diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index b0aee80ba3..d6c77f3770 100644 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -148,7 +148,7 @@ public: * @param Rect Position and Size * @param Clipping The sprite shouldn't be drawn outside this rectangle */ - void DrawSprite(CGUISpriteInstance& Sprite, int CellID, const float &Z, + void DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float &Z, const CRect &Rect, const CRect &Clipping=CRect()); /** diff --git a/source/gui/CGUIScrollBarVertical.cpp b/source/gui/CGUIScrollBarVertical.cpp index 70f5884f10..2e9b5bf1a7 100644 --- a/source/gui/CGUIScrollBarVertical.cpp +++ b/source/gui/CGUIScrollBarVertical.cpp @@ -67,7 +67,7 @@ void CGUIScrollBarVertical::Draw() if (m_UseEdgeButtons) { // Get Appropriate sprites - CGUISpriteInstance *button_top, *button_bottom; + const CGUISpriteInstance *button_top, *button_bottom; // figure out what sprite to use for top button if (m_ButtonMinusHovered) diff --git a/source/gui/CGUISprite.cpp b/source/gui/CGUISprite.cpp index 132a2c3afb..54e68bac86 100644 --- a/source/gui/CGUISprite.cpp +++ b/source/gui/CGUISprite.cpp @@ -18,7 +18,7 @@ #include "precompiled.h" #include "CGUISprite.h" -void CGUISpriteInstance::Draw(CRect Size, int CellID, std::map &Sprites) +void CGUISpriteInstance::Draw(CRect Size, int CellID, std::map &Sprites) const { if (m_CachedSize != Size || m_CachedCellID != CellID) { diff --git a/source/gui/CGUISprite.h b/source/gui/CGUISprite.h index 611286492f..d239e59ed8 100644 --- a/source/gui/CGUISprite.h +++ b/source/gui/CGUISprite.h @@ -156,7 +156,7 @@ public: CGUISpriteInstance(const CStr& SpriteName); CGUISpriteInstance(const CGUISpriteInstance &Sprite); CGUISpriteInstance &operator=(const CStr& SpriteName); - void Draw(CRect Size, int CellID, std::map &Sprites); + void Draw(CRect Size, int CellID, std::map &Sprites) const; void Invalidate(); bool IsEmpty() const; const CStr& GetName() { return m_SpriteName; } @@ -165,11 +165,11 @@ private: CStr m_SpriteName; // Stored drawing calls, for more efficient rendering - GUIRenderer::DrawCalls m_DrawCallCache; + mutable GUIRenderer::DrawCalls m_DrawCallCache; // Relevant details of previously rendered sprite; the cache is invalidated // whenever any of these values changes. - CRect m_CachedSize; - int m_CachedCellID; + mutable CRect m_CachedSize; + mutable int m_CachedCellID; }; #endif diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp index a185cab05b..bea43c8f00 100644 --- a/source/gui/GUIRenderer.cpp +++ b/source/gui/GUIRenderer.cpp @@ -344,7 +344,7 @@ public: // Functions to perform drawing-related actions: -void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, CStr& SpriteName, CRect &Size, int CellID, std::map &Sprites) +void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, const CStr& SpriteName, const CRect &Size, int CellID, std::map &Sprites) { // This is called only when something has changed (like the size of the // sprite), so it doesn't need to be particularly efficient. diff --git a/source/gui/GUIRenderer.h b/source/gui/GUIRenderer.h index 8a94fd2148..9ea4a4f434 100644 --- a/source/gui/GUIRenderer.h +++ b/source/gui/GUIRenderer.h @@ -69,7 +69,7 @@ namespace GUIRenderer namespace GUIRenderer { - void UpdateDrawCallCache(DrawCalls &Calls, CStr&SpriteName, CRect& Size, int CellID, std::map &Sprites); + void UpdateDrawCallCache(DrawCalls &Calls, const CStr& SpriteName, const CRect& Size, int CellID, std::map &Sprites); void Draw(DrawCalls &Calls); } diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index f3ca795684..1456de8349 100644 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -291,7 +291,8 @@ void CInternalCGUIAccessorBase::HandleMessage(IGUIObject *pObject, const SGUIMes #ifndef NDEBUG #define TYPE(T) \ template<> void CheckType(const IGUIObject* obj, const CStr& setting) { \ - if (((IGUIObject*)obj)->m_Settings[setting].m_Type != GUIST_##T) \ + std::map::const_iterator it = obj->m_Settings.find(setting); \ + if (it == obj->m_Settings.end() || it->second.m_Type != GUIST_##T) \ { \ /* Abort now, to avoid corrupting everything by invalidly \ casting pointers */ \ diff --git a/source/gui/GUIutil.h b/source/gui/GUIutil.h index 157b60bd42..f16ace598b 100644 --- a/source/gui/GUIutil.h +++ b/source/gui/GUIutil.h @@ -222,9 +222,9 @@ public: * @param sec Secondary sprite if Primary should fail * @return Resulting string */ - static CGUISpriteInstance& FallBackSprite( - CGUISpriteInstance& prim, - CGUISpriteInstance& sec) + static const CGUISpriteInstance& FallBackSprite( + const CGUISpriteInstance& prim, + const CGUISpriteInstance& sec) { // CStr() == empty string, null return (prim.IsEmpty() ? sec : prim); diff --git a/source/gui/IGUIScrollBar.cpp b/source/gui/IGUIScrollBar.cpp index 704439eb2b..128328b166 100644 --- a/source/gui/IGUIScrollBar.cpp +++ b/source/gui/IGUIScrollBar.cpp @@ -50,7 +50,7 @@ void IGUIScrollBar::SetupBarSize() m_BarSize = std::min((float)m_ScrollSpace/(float)m_ScrollRange, 1.f); } -SGUIScrollBarStyle *IGUIScrollBar::GetStyle() const +const SGUIScrollBarStyle *IGUIScrollBar::GetStyle() const { if (!m_pHostObject) return NULL; diff --git a/source/gui/IGUIScrollBar.h b/source/gui/IGUIScrollBar.h index ce3378dcd6..3516a1de95 100644 --- a/source/gui/IGUIScrollBar.h +++ b/source/gui/IGUIScrollBar.h @@ -304,7 +304,7 @@ public: * Get style used by the scrollbar * @return Scroll bar style struct. */ - SGUIScrollBarStyle * GetStyle() const; + const SGUIScrollBarStyle * GetStyle() const; /** * Get the rectangle of the actual BAR. not the whole scroll-bar. diff --git a/source/gui/IGUIScrollBarOwner.cpp b/source/gui/IGUIScrollBarOwner.cpp index 65836a7577..5511d4a7d7 100644 --- a/source/gui/IGUIScrollBarOwner.cpp +++ b/source/gui/IGUIScrollBarOwner.cpp @@ -58,21 +58,22 @@ void IGUIScrollBarOwner::AddScrollBar(IGUIScrollBar * scrollbar) m_ScrollBars.push_back(scrollbar); } -SGUIScrollBarStyle * IGUIScrollBarOwner::GetScrollBarStyle(const CStr& style) const +const SGUIScrollBarStyle * IGUIScrollBarOwner::GetScrollBarStyle(const CStr& style) const { if (!GetGUI()) { // TODO Gee: Output in log return NULL; } - - if (GetGUI()->m_ScrollBarStyles.count(style) == 0) + + std::map::const_iterator it = GetGUI()->m_ScrollBarStyles.find(style); + if (it == GetGUI()->m_ScrollBarStyles.end()) { // TODO Gee: Output in log return NULL; } - return &((CGUI*)GetGUI())->m_ScrollBarStyles.find(style)->second; + return &it->second; } void IGUIScrollBarOwner::HandleMessage(const SGUIMessage &Message) diff --git a/source/gui/IGUIScrollBarOwner.h b/source/gui/IGUIScrollBarOwner.h index d010b26ed8..de8ea4951d 100644 --- a/source/gui/IGUIScrollBarOwner.h +++ b/source/gui/IGUIScrollBarOwner.h @@ -81,7 +81,7 @@ public: /** * Interface for the m_ScrollBar to use. */ - virtual SGUIScrollBarStyle *GetScrollBarStyle(const CStr& style) const; + virtual const SGUIScrollBarStyle *GetScrollBarStyle(const CStr& style) const; /** * Add a scroll-bar diff --git a/source/i18n/CLocale.cpp b/source/i18n/CLocale.cpp index e216d77de7..c90c78b33c 100644 --- a/source/i18n/CLocale.cpp +++ b/source/i18n/CLocale.cpp @@ -109,7 +109,7 @@ bool CLocale::LoadStrings(const char* data) u8 NameLength = *(u8*)data; data += 1; - std::string NameText ((char*)data, (char*)(data + NameLength)); + std::string NameText ((const char*)data, (const char*)(data + NameLength)); data += NameLength; u8 ParamCount = *(u8*)data; diff --git a/source/lib/allocators/string_pool.cpp b/source/lib/allocators/string_pool.cpp index 0d155db72e..10d023cf39 100644 --- a/source/lib/allocators/string_pool.cpp +++ b/source/lib/allocators/string_pool.cpp @@ -55,11 +55,11 @@ const char* StringPool::UniqueCopy(const char* string) return existingString; const size_t length = strlen(string); - const char* uniqueCopy = (const char*)pool_alloc(&m_pool, length+1); + char* uniqueCopy = (char*)pool_alloc(&m_pool, length+1); if(!uniqueCopy) throw std::bad_alloc(); cpu_memcpy((void*)uniqueCopy, string, length); - ((char*)uniqueCopy)[length] = '\0'; + uniqueCopy[length] = '\0'; m_map.insert(uniqueCopy, uniqueCopy); diff --git a/source/scripting/DOMEvent.cpp b/source/scripting/DOMEvent.cpp index a6525bb604..3739834e29 100644 --- a/source/scripting/DOMEvent.cpp +++ b/source/scripting/DOMEvent.cpp @@ -77,9 +77,9 @@ bool IEventTarget::_DispatchEvent( CScriptEvent* evt, IEventTarget* target ) // returns: whether the event arrived (i.e. wasn't cancelled) [bool] bool IEventTarget::DispatchEvent( CScriptEvent* evt ) { - char* data; + const char* data; PROFILE_START( "intern string" ); - data = (char*) g_Profiler.InternString( "script: " + (CStr8)evt->m_Type ); + data = g_Profiler.InternString( "script: " + (CStr8)evt->m_Type ); PROFILE_END( "intern string" ); g_Profiler.StartScript( data ); evt->m_Target = this; diff --git a/source/scripting/SpiderMonkey.h b/source/scripting/SpiderMonkey.h index 25472e088d..8b5cc16b6c 100644 --- a/source/scripting/SpiderMonkey.h +++ b/source/scripting/SpiderMonkey.h @@ -15,6 +15,9 @@ * along with 0 A.D. If not, see . */ +#ifndef INCLUDED_SPIDERMONKEY +#define INCLUDED_SPIDERMONKEY + // Master header for the SpiderMonkey Javascript library. // // Include this instead of accessing any headers directly. @@ -58,3 +61,5 @@ #ifndef NDEBUG # define JS_AddRoot(cx, rp) JS_AddNamedRoot((cx), (rp), __FILE__ ) #endif + +#endif // INCLUDED_SPIDERMONKEY diff --git a/source/simulation/EntitySupport.h b/source/simulation/EntitySupport.h index 753c50a73c..7ab5cb86f6 100644 --- a/source/simulation/EntitySupport.h +++ b/source/simulation/EntitySupport.h @@ -25,8 +25,8 @@ struct SEntityAction { int m_Id; - float m_MaxRange; float m_MinRange; + float m_MaxRange; int m_Speed; CStr8 m_Animation; SEntityAction() diff --git a/source/tools/atlas/AtlasUI/Misc/DLLInterface.h b/source/tools/atlas/AtlasUI/Misc/DLLInterface.h index 4971bfc161..526a05132c 100644 --- a/source/tools/atlas/AtlasUI/Misc/DLLInterface.h +++ b/source/tools/atlas/AtlasUI/Misc/DLLInterface.h @@ -15,6 +15,9 @@ * along with 0 A.D. If not, see . */ +#ifndef DLLINTERFACE_INCLUDED +#define DLLINTERFACE_INCLUDED + #include namespace AtlasMessage { class MessagePasser; } @@ -31,4 +34,4 @@ ATLASDLLIMPEXP void Atlas_DisplayError(const wchar_t* text, size_t flags); ATLASDLLIMPEXP void Atlas_ReportError(); -ATLASDLLIMPEXP void Atlas_ReportError(); +#endif // DLLINTERFACE_INCLUDED