From 73769c62e4d19aeecfb5498f3b939147be1ad823 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 29 Jul 2012 07:32:44 -0300 Subject: [PATCH] Just some refactoring --- src/framework/CMakeLists.txt | 8 +- src/framework/core/application.h | 6 +- src/framework/core/eventdispatcher.h | 2 +- src/framework/core/graphicalapplication.h | 4 +- src/framework/core/module.h | 8 +- src/framework/core/resourcemanager.h | 2 +- src/framework/core/timer.h | 2 +- src/framework/global.h | 1 - src/framework/graphics/cachedtext.h | 2 +- src/framework/graphics/framebuffer.h | 4 +- src/framework/graphics/graphics.h | 20 ++--- src/framework/graphics/painterogl1.h | 2 +- src/framework/graphics/texture.h | 8 +- src/framework/platform/platformwindow.h | 14 ++-- src/framework/sound/soundmanager.h | 4 +- src/framework/sound/streamsoundsource.h | 2 +- .../attrib_storage.h} | 25 +++--- src/framework/{util => stdext}/boolean.h | 9 ++- src/framework/stdext/compiler.h | 4 +- src/framework/stdext/shared_object.h | 80 +++++++++++++++++++ src/framework/stdext/stdext.h | 2 + src/framework/stdext/time.h | 11 +++ src/framework/stdext/types.h | 13 +++ src/framework/ui/uiboxlayout.h | 2 +- src/framework/ui/uigridlayout.h | 6 +- src/framework/ui/uihorizontallayout.h | 2 +- src/framework/ui/uilayout.h | 4 +- src/framework/ui/uimanager.h | 4 +- src/framework/ui/uiverticallayout.h | 2 +- src/framework/ui/uiwidget.h | 40 +++++----- src/otclient/creature.h | 16 ++-- src/otclient/creatures.h | 5 +- src/otclient/houses.h | 5 +- src/otclient/item.h | 3 +- src/otclient/itemtype.h | 5 +- src/otclient/map.cpp | 2 + src/otclient/map.h | 3 +- src/otclient/mapview.cpp | 12 +++ src/otclient/mapview.h | 31 +++---- src/otclient/minimap.h | 2 +- src/otclient/protocolgame.h | 4 +- src/otclient/spritemanager.h | 2 +- src/otclient/statictext.h | 2 +- src/otclient/thingstype.h | 2 +- src/otclient/thingtype.h | 3 +- src/otclient/uicreature.h | 2 +- src/otclient/uiitem.h | 2 +- 47 files changed, 252 insertions(+), 142 deletions(-) rename src/framework/{util/attribstorage.h => stdext/attrib_storage.h} (87%) rename src/framework/{util => stdext}/boolean.h (94%) create mode 100644 src/framework/stdext/shared_object.h diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 09db3bd8..aee1c970 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -21,7 +21,6 @@ set(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/pch.h ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp - ${CMAKE_CURRENT_LIST_DIR}/util/boolean.h ${CMAKE_CURRENT_LIST_DIR}/util/color.cpp ${CMAKE_CURRENT_LIST_DIR}/util/color.h ${CMAKE_CURRENT_LIST_DIR}/util/crypt.cpp @@ -33,7 +32,6 @@ set(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/util/rsa.cpp ${CMAKE_CURRENT_LIST_DIR}/util/rsa.h ${CMAKE_CURRENT_LIST_DIR}/util/size.h - ${CMAKE_CURRENT_LIST_DIR}/util/attribstorage.h # stdext ${CMAKE_CURRENT_LIST_DIR}/stdext/cast.h @@ -46,6 +44,8 @@ set(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/stdext/string.h ${CMAKE_CURRENT_LIST_DIR}/stdext/time.h ${CMAKE_CURRENT_LIST_DIR}/stdext/types.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/attrib_storage.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/shared_object.h # core ${CMAKE_CURRENT_LIST_DIR}/core/application.cpp @@ -127,11 +127,11 @@ endif() # gcc compile flags set(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=c++11 -pipe") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS_RELEASE "-O2") -set(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmxx -msee -msee2") +set(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmmx -msse -msse2") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") # process options diff --git a/src/framework/core/application.h b/src/framework/core/application.h index 8cd93174..fc9944fc 100644 --- a/src/framework/core/application.h +++ b/src/framework/core/application.h @@ -68,9 +68,9 @@ protected: std::string m_appCompactName; std::string m_appVersion; std::string m_startupOptions; - Boolean m_running; - Boolean m_stopping; - Boolean m_terminated; + bool m_running = false; + bool m_stopping = false; + stdext::boolean m_terminated; }; #ifdef FW_GRAPHICS diff --git a/src/framework/core/eventdispatcher.h b/src/framework/core/eventdispatcher.h index d1b1728b..15ee7a01 100644 --- a/src/framework/core/eventdispatcher.h +++ b/src/framework/core/eventdispatcher.h @@ -40,7 +40,7 @@ public: private: std::list m_eventList; int m_pollEventsSize; - Boolean m_disabled; + bool m_disabled = false; std::priority_queue, lessScheduledEvent> m_scheduledEventList; }; diff --git a/src/framework/core/graphicalapplication.h b/src/framework/core/graphicalapplication.h index 683e7001..2feadc82 100644 --- a/src/framework/core/graphicalapplication.h +++ b/src/framework/core/graphicalapplication.h @@ -60,8 +60,8 @@ protected: void inputEvent(const InputEvent& event); private: - Boolean m_onInputEvent; - Boolean m_mustRepaint; + bool m_onInputEvent = false; + bool m_mustRepaint = false; AdaptativeFrameCounter m_backgroundFrameCounter; AdaptativeFrameCounter m_foregroundFrameCounter; TexturePtr m_foreground; diff --git a/src/framework/core/module.h b/src/framework/core/module.h index 24b00a34..75c4b26b 100644 --- a/src/framework/core/module.h +++ b/src/framework/core/module.h @@ -63,10 +63,10 @@ protected: friend class ModuleManager; private: - Boolean m_loaded; - Boolean m_autoLoad; - Boolean m_reloadable; - Boolean m_sandboxed; + bool m_loaded = false; + bool m_autoLoad = false; + bool m_reloadable = false; + bool m_sandboxed = false; int m_autoLoadPriority; int m_sandboxEnv; std::tuple m_onLoadFunc; diff --git a/src/framework/core/resourcemanager.h b/src/framework/core/resourcemanager.h index c4cd28f9..d970899c 100644 --- a/src/framework/core/resourcemanager.h +++ b/src/framework/core/resourcemanager.h @@ -72,7 +72,7 @@ public: private: std::string m_workDir; std::string m_writeDir; - Boolean m_hasSearchPath; + bool m_hasSearchPath = false; std::deque m_searchPaths; }; diff --git a/src/framework/core/timer.h b/src/framework/core/timer.h index a4874d97..fe338cb1 100644 --- a/src/framework/core/timer.h +++ b/src/framework/core/timer.h @@ -41,7 +41,7 @@ public: private: ticks_t m_startTicks; - Boolean m_stopped; + bool m_stopped = false; }; #endif diff --git a/src/framework/global.h b/src/framework/global.h index 9d529f1d..04764c27 100644 --- a/src/framework/global.h +++ b/src/framework/global.h @@ -40,7 +40,6 @@ #include "util/rect.h" #include "util/size.h" #include "util/matrix.h" -#include "util/boolean.h" // logger #include "core/logger.h" diff --git a/src/framework/graphics/cachedtext.h b/src/framework/graphics/cachedtext.h index c3b37f47..7fed574f 100644 --- a/src/framework/graphics/cachedtext.h +++ b/src/framework/graphics/cachedtext.h @@ -48,7 +48,7 @@ private: std::string m_text; Size m_textSize; - Boolean m_textMustRecache; + bool m_textMustRecache = true; CoordsBuffer m_textCoordsBuffer; Rect m_textCachedScreenCoords; BitmapFontPtr m_font; diff --git a/src/framework/graphics/framebuffer.h b/src/framework/graphics/framebuffer.h index 8b6e69b2..22c24303 100644 --- a/src/framework/graphics/framebuffer.h +++ b/src/framework/graphics/framebuffer.h @@ -61,8 +61,8 @@ private: Size m_oldViewportSize; uint m_fbo; uint m_prevBoundFbo; - Boolean m_backuping; - Boolean m_smooth; + bool m_backuping = true; + bool m_smooth = true; static uint boundFbo; }; diff --git a/src/framework/graphics/graphics.h b/src/framework/graphics/graphics.h index 0a09665f..f02521a7 100644 --- a/src/framework/graphics/graphics.h +++ b/src/framework/graphics/graphics.h @@ -77,16 +77,16 @@ private: int m_maxTextureSize; int m_alphaBits; - Boolean m_ok; - Boolean m_useDrawArrays; - Boolean m_useFBO; - Boolean m_useHardwareBuffers; - Boolean m_useBilinearFiltering; - Boolean m_useNonPowerOfTwoTextures; - Boolean m_useMipmaps; - Boolean m_useHardwareMipmaps; - Boolean m_useClampToEdge; - Boolean m_cacheBackbuffer; + bool m_ok = false; + bool m_useDrawArrays = true; + bool m_useFBO = true; + bool m_useHardwareBuffers = false; + bool m_useBilinearFiltering = true; + bool m_useNonPowerOfTwoTextures = true; + bool m_useMipmaps = true; + bool m_useHardwareMipmaps = true; + bool m_useClampToEdge = true; + bool m_cacheBackbuffer = true; PainterEngine m_prefferedPainterEngine; PainterEngine m_selectedPainterEngine; }; diff --git a/src/framework/graphics/painterogl1.h b/src/framework/graphics/painterogl1.h index cda15233..995eebcd 100644 --- a/src/framework/graphics/painterogl1.h +++ b/src/framework/graphics/painterogl1.h @@ -72,7 +72,7 @@ private: void updateGlTextureState(); GLenum m_matrixMode; - Boolean m_textureEnabled; + bool m_textureEnabled = false; }; extern PainterOGL1 *g_painterOGL1; diff --git a/src/framework/graphics/texture.h b/src/framework/graphics/texture.h index f67d8538..e87b3607 100644 --- a/src/framework/graphics/texture.h +++ b/src/framework/graphics/texture.h @@ -63,10 +63,10 @@ protected: Size m_size; Size m_glSize; Matrix3 m_transformMatrix; - Boolean m_hasMipmaps; - Boolean m_smooth; - Boolean m_upsideDown; - Boolean m_repeat; + bool m_hasMipmaps = false; + bool m_smooth = false; + bool m_upsideDown = false; + bool m_repeat = false; }; #endif diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index 82c66b4c..df9af277 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -99,7 +99,7 @@ protected: void fireKeysPress(); std::map m_keyMap; - std::map> m_keysState; + std::map> m_keysState; std::map m_firstKeysPress; std::map m_lastKeysPress; Timer m_keyPressTimer; @@ -109,13 +109,13 @@ protected: Size m_unmaximizedSize; Point m_unmaximizedPos; InputEvent m_inputEvent; - Boolean m_mouseButtonStates[4]; + stdext::boolean m_mouseButtonStates[4]; - Boolean m_created; - Boolean m_visible; - Boolean m_focused; - Boolean m_fullscreen; - Boolean m_maximized; + bool m_created = false; + bool m_visible = false; + bool m_focused = false; + bool m_fullscreen = false; + bool m_maximized = false; std::function m_onClose; OnResizeCallback m_onResize; diff --git a/src/framework/sound/soundmanager.h b/src/framework/sound/soundmanager.h index 85c8faff..7a9c2108 100644 --- a/src/framework/sound/soundmanager.h +++ b/src/framework/sound/soundmanager.h @@ -61,8 +61,8 @@ private: SoundSourcePtr m_musicSource; ALCdevice *m_device; ALCcontext *m_context; - Boolean m_musicEnabled; - Boolean m_soundEnabled; + bool m_musicEnabled = false; + bool m_soundEnabled = false; std::string m_currentMusic; }; diff --git a/src/framework/sound/streamsoundsource.h b/src/framework/sound/streamsoundsource.h index 3fbaa4da..86c2143d 100644 --- a/src/framework/sound/streamsoundsource.h +++ b/src/framework/sound/streamsoundsource.h @@ -56,7 +56,7 @@ private: SoundFilePtr m_soundFile; std::array m_buffers; DownMix m_downMix; - Boolean m_looping; + bool m_looping = false; }; #endif diff --git a/src/framework/util/attribstorage.h b/src/framework/stdext/attrib_storage.h similarity index 87% rename from src/framework/util/attribstorage.h rename to src/framework/stdext/attrib_storage.h index 2643925a..029029bc 100644 --- a/src/framework/util/attribstorage.h +++ b/src/framework/stdext/attrib_storage.h @@ -20,21 +20,21 @@ * THE SOFTWARE. */ -#ifndef ATTRIBSTORAGE_H -#define ATTRIBSTORAGE_H +#ifndef STDEXT_ATTRIBSTORAGE_H +#define STDEXT_ATTRIBSTORAGE_H -#include "../stdext/types.h" +#include "types.h" #include #include - -#pragma pack(push,1) // disable memory alignment +// disable memory alignment +#pragma pack(push,1) // this class was designed to use less memory as possible -class AttribStorage { +namespace stdext { +class attrib_storage { public: - AttribStorage() : m_attribs(nullptr), m_size(0) { } - ~AttribStorage() { if(m_attribs) delete[] m_attribs; } + ~attrib_storage() { if(m_attribs) delete[] m_attribs; } template void set(uint8 id, T value) { @@ -72,10 +72,15 @@ public: return true; return false; } + private: - std::tuple* m_attribs; - uint8 m_size; + std::tuple* m_attribs = nullptr; + uint8 m_size = 0; }; + +// restore memory alignment #pragma pack(pop) +} + #endif diff --git a/src/framework/util/boolean.h b/src/framework/stdext/boolean.h similarity index 94% rename from src/framework/util/boolean.h rename to src/framework/stdext/boolean.h index 2121b8eb..31a1fac6 100644 --- a/src/framework/util/boolean.h +++ b/src/framework/stdext/boolean.h @@ -23,10 +23,11 @@ #ifndef BOOLEAN_H #define BOOLEAN_H -/// Boolean with default value +namespace stdext { + template -struct Boolean { - Boolean() : v(def) { } +struct boolean { + boolean() : v(def) { } operator bool &() { return v; } operator bool const &() const { return v; } bool& operator=(const bool& o) { v = o; return v; } @@ -34,4 +35,6 @@ private: bool v; }; +} + #endif diff --git a/src/framework/stdext/compiler.h b/src/framework/stdext/compiler.h index 061dcf7a..e09521c9 100644 --- a/src/framework/stdext/compiler.h +++ b/src/framework/stdext/compiler.h @@ -27,8 +27,8 @@ // clang is supported #undef _GLIBCXX_USE_FLOAT128 #elif defined(__GNUC__) - #if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - #error "Sorry, you need gcc 4.6 or greater to compile." + #if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) + #error "Sorry, you need gcc 4.7 or greater to compile." #endif #else #error "Compiler not supported." diff --git a/src/framework/stdext/shared_object.h b/src/framework/stdext/shared_object.h new file mode 100644 index 00000000..54b7bee1 --- /dev/null +++ b/src/framework/stdext/shared_object.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2010-2012 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef STDEXT_SHARED_OBJECT_H +#define STDEXT_SHARED_OBJECT_H + +#include +#include + +namespace stdext { + +template +using shared_object_ptr = boost::intrusive_ptr; + +class shared_object +{ +public: + shared_object() : m_refs(0) { } + virtual ~shared_object() { } + void add_ref() { ++m_refs; assert(m_refs != 0xffffffff); } + void dec_ref() { + if(--m_refs == 0) + boost::checked_delete(this); + } + bool is_unique_ref() { return m_refs == 1; } + unsigned long ref_count() { return m_refs; } + template + shared_object_ptr self_cast() { return shared_object_ptr(static_cast(this)); } + template + shared_object_ptr dynamic_self_cast() { return shared_object_ptr(dynamic_cast(this)); } + +private: + unsigned int m_refs; +}; + +template +shared_object_ptr make_shared_object(Args... args) { return shared_object_ptr(new T(args...)); } + +} + +namespace std { +template +struct hash> : public __hash_base> { + size_t operator()(const boost::intrusive_ptr& p) const noexcept { return std::hash()(p.get()); } +}; +} + +template +struct remove_const_ref { + typedef typename std::remove_const::type>::type type; +}; + +template +void intrusive_ptr_add_ref(T* p) { (static_cast(p))->add_ref(); } + +template +void intrusive_ptr_release(T* p) { (static_cast(p))->dec_ref(); } + +#endif + + diff --git a/src/framework/stdext/stdext.h b/src/framework/stdext/stdext.h index e94a1f1c..87e02fc6 100644 --- a/src/framework/stdext/stdext.h +++ b/src/framework/stdext/stdext.h @@ -33,5 +33,7 @@ #include "dumper.h" #include "time.h" #include "shared_object.h" +#include "attrib_storage.h" +#include "boolean.h" #endif diff --git a/src/framework/stdext/time.h b/src/framework/stdext/time.h index 88bf345a..e647f9f5 100644 --- a/src/framework/stdext/time.h +++ b/src/framework/stdext/time.h @@ -35,6 +35,17 @@ inline ticks_t micros() { return std::chrono::duration_cast m_fitChildren; + bool m_fitChildren = false; int m_spacing; }; diff --git a/src/framework/ui/uigridlayout.h b/src/framework/ui/uigridlayout.h index 08dbe3be..7d299c73 100644 --- a/src/framework/ui/uigridlayout.h +++ b/src/framework/ui/uigridlayout.h @@ -55,9 +55,9 @@ private: int m_cellSpacing; int m_numColumns; int m_numLines; - Boolean m_autoSpacing; - Boolean m_fitChildren; - Boolean m_flow; + bool m_autoSpacing = false; + bool m_fitChildren = false; + bool m_flow = false; }; #endif diff --git a/src/framework/ui/uihorizontallayout.h b/src/framework/ui/uihorizontallayout.h index 16f08f70..a23a1fcf 100644 --- a/src/framework/ui/uihorizontallayout.h +++ b/src/framework/ui/uihorizontallayout.h @@ -39,7 +39,7 @@ public: protected: bool internalUpdate(); - Boolean m_alignRight; + bool m_alignRight = false; }; #endif diff --git a/src/framework/ui/uilayout.h b/src/framework/ui/uilayout.h index b4cb4967..5187e559 100644 --- a/src/framework/ui/uilayout.h +++ b/src/framework/ui/uilayout.h @@ -58,8 +58,8 @@ protected: virtual bool internalUpdate() = 0; int m_updateDisabled; - Boolean m_updating; - Boolean m_updateScheduled; + bool m_updating = false; + bool m_updateScheduled = false; UIWidgetPtr m_parentWidget; }; diff --git a/src/framework/ui/uimanager.h b/src/framework/ui/uimanager.h index 27280fdd..03c17891 100644 --- a/src/framework/ui/uimanager.h +++ b/src/framework/ui/uimanager.h @@ -82,8 +82,8 @@ private: UIWidgetPtr m_draggingWidget; UIWidgetPtr m_hoveredWidget; UIWidgetPtr m_pressedWidget; - Boolean m_hoverUpdateScheduled; - Boolean m_drawDebugBoxes; + bool m_hoverUpdateScheduled = false; + bool m_drawDebugBoxes = false; std::unordered_map m_styles; UIWidgetList m_destroyedWidgets; ScheduledEventPtr m_checkEvent; diff --git a/src/framework/ui/uiverticallayout.h b/src/framework/ui/uiverticallayout.h index 6e6dea85..57ed094e 100644 --- a/src/framework/ui/uiverticallayout.h +++ b/src/framework/ui/uiverticallayout.h @@ -40,7 +40,7 @@ public: protected: bool internalUpdate(); - Boolean m_alignBottom; + stdext::boolean m_alignBottom; }; #endif diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 07ebe8c2..12049737 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -61,14 +61,14 @@ protected: std::string m_id; Rect m_rect; Point m_virtualOffset; - Boolean m_enabled; - Boolean m_visible; - Boolean m_focusable; - Boolean m_fixedSize; - Boolean m_phantom; - Boolean m_dragable; - Boolean m_destroyed; - Boolean m_clipping; + stdext::boolean m_enabled; + stdext::boolean m_visible; + stdext::boolean m_focusable; + stdext::boolean m_fixedSize; + stdext::boolean m_phantom; + stdext::boolean m_dragable; + stdext::boolean m_destroyed; + stdext::boolean m_clipping; UILayoutPtr m_layout; UIWidgetPtr m_parent; UIWidgetList m_children; @@ -155,8 +155,8 @@ public: UIWidgetPtr backwardsGetWidgetById(const std::string& id); private: - Boolean m_updateEventScheduled; - Boolean m_loadingStyle; + stdext::boolean m_updateEventScheduled; + stdext::boolean m_loadingStyle; // state managment @@ -171,8 +171,8 @@ private: void updateChildrenIndexStates(); void updateStyle(); - Boolean m_updateStyleScheduled; - Boolean m_firstOnStyle; + stdext::boolean m_updateStyleScheduled; + stdext::boolean m_firstOnStyle; OTMLNodePtr m_stateStyle; int m_states; @@ -394,8 +394,8 @@ private: CoordsBuffer m_imageCoordsBuffer; Rect m_imageCachedScreenCoords; - Boolean m_imageMustRecache; - Boolean m_imageBordered; + stdext::boolean m_imageMustRecache; + stdext::boolean m_imageBordered; protected: void drawImage(const Rect& screenCoords); @@ -404,9 +404,9 @@ protected: Rect m_imageClipRect; Rect m_imageRect; Color m_imageColor; - Boolean m_imageFixedRatio; - Boolean m_imageRepeated; - Boolean m_imageSmooth; + stdext::boolean m_imageFixedRatio; + stdext::boolean m_imageRepeated; + stdext::boolean m_imageSmooth; EdgeGroup m_imageBorder; public: @@ -451,7 +451,7 @@ private: void updateText(); void parseTextStyle(const OTMLNodePtr& styleNode); - Boolean m_textMustRecache; + stdext::boolean m_textMustRecache; CoordsBuffer m_textCoordsBuffer; Rect m_textCachedScreenCoords; @@ -465,8 +465,8 @@ protected: std::string m_drawText; Fw::AlignmentFlag m_textAlign; Point m_textOffset; - Boolean m_textWrap; - Boolean m_textAutoResize; + stdext::boolean m_textWrap; + stdext::boolean m_textAutoResize; BitmapFontPtr m_font; public: diff --git a/src/otclient/creature.h b/src/otclient/creature.h index 6180de04..42795f2d 100644 --- a/src/otclient/creature.h +++ b/src/otclient/creature.h @@ -121,14 +121,14 @@ protected: TexturePtr m_skullTexture; TexturePtr m_shieldTexture; TexturePtr m_emblemTexture; - Boolean m_showShieldTexture; - Boolean m_shieldBlink; - Boolean m_passable; + stdext::boolean m_showShieldTexture; + stdext::boolean m_shieldBlink; + stdext::boolean m_passable; Color m_timedSquareColor; Color m_staticSquareColor; - Boolean m_showTimedSquare; - Boolean m_showStaticSquare; - Boolean m_removed; + stdext::boolean m_showTimedSquare; + stdext::boolean m_showStaticSquare; + stdext::boolean m_removed; CachedText m_nameCache; Color m_informationColor; @@ -140,8 +140,8 @@ protected: TilePtr m_walkingTile; int m_walkInterval; int m_walkAnimationInterval; - Boolean m_walking; - Boolean m_footStepDrawn; + stdext::boolean m_walking; + stdext::boolean m_footStepDrawn; ScheduledEventPtr m_walkUpdateEvent; Point m_walkOffset; Otc::Direction m_walkTurnDirection; diff --git a/src/otclient/creatures.h b/src/otclient/creatures.h index 65af229d..af887b1e 100644 --- a/src/otclient/creatures.h +++ b/src/otclient/creatures.h @@ -25,7 +25,6 @@ #include "declarations.h" #include -#include #include "outfit.h" enum CreatureAttr : uint8 @@ -51,7 +50,7 @@ public: int getSpawnTime() { return m_attribs.get(CreatureAttrSpawnTime); } private: - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; }; class Creatures @@ -72,7 +71,7 @@ protected: private: std::vector m_creatures; - Boolean m_loaded; + stdext::boolean m_loaded; }; #endif diff --git a/src/otclient/houses.h b/src/otclient/houses.h index d0bf9fde..443c7edb 100644 --- a/src/otclient/houses.h +++ b/src/otclient/houses.h @@ -27,7 +27,6 @@ #include "tile.h" #include -#include enum HouseAttr : uint8 { @@ -64,9 +63,9 @@ protected: void save(TiXmlElement &elem) { } // TODO private: - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; TileMap m_tiles; - Boolean m_isGuildHall; + stdext::boolean m_isGuildHall; friend class Houses; }; diff --git a/src/otclient/item.h b/src/otclient/item.h index a01f571e..d9fb5113 100644 --- a/src/otclient/item.h +++ b/src/otclient/item.h @@ -24,7 +24,6 @@ #define ITEM_H #include -#include #include "thing.h" #include "itemtype.h" @@ -125,7 +124,7 @@ private: uint16 m_id; uint16 m_otbId; uint8 m_countOrSubType; - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; }; #pragma pack(pop) diff --git a/src/otclient/itemtype.h b/src/otclient/itemtype.h index 08634122..228c5f82 100644 --- a/src/otclient/itemtype.h +++ b/src/otclient/itemtype.h @@ -27,7 +27,6 @@ #include #include #include -#include enum ItemCategory { ItemCategoryInvalid = 0, @@ -102,9 +101,9 @@ public: private: ItemCategory m_category; - Boolean m_null; + stdext::boolean m_null; - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; }; #endif diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index c744a45e..0c60380b 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -430,6 +430,7 @@ bool Map::loadOtcm(const std::string& fileName) if(!fin) stdext::throw_exception("unable to open file"); + stdext::timer loadTimer; fin->cache(); uint32 signature = fin->getU32(); @@ -491,6 +492,7 @@ bool Map::loadOtcm(const std::string& fileName) fin->close(); + g_logger.debug(stdext::format("Otcm load time: %.2f seconds", loadTimer.elapsed_seconds())); return true; } catch(stdext::exception& e) { g_logger.error(stdext::format("failed to load OTCM map: %s", e.what())); diff --git a/src/otclient/map.h b/src/otclient/map.h index 7c76758e..9276886d 100644 --- a/src/otclient/map.h +++ b/src/otclient/map.h @@ -31,7 +31,6 @@ #include "statictext.h" #include -#include enum OTBM_ItemAttr { @@ -268,7 +267,7 @@ private: Position m_centralPosition; Rect m_tilesRect; - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; Houses m_houses; Towns m_towns; Creatures m_creatures; diff --git a/src/otclient/mapview.cpp b/src/otclient/mapview.cpp index 61855839..25b138da 100644 --- a/src/otclient/mapview.cpp +++ b/src/otclient/mapview.cpp @@ -35,6 +35,18 @@ #include #include + +enum { + // 3840x2160 => 1080p optimized + // 2560x1440 => 720p optimized + // 1728x972 => 480p optimized + + NEAR_VIEW_AREA = 32*32, + MID_VIEW_AREA = 64*64, + FAR_VIEW_AREA = 128*128, + MAX_TILE_DRAWS = NEAR_VIEW_AREA*7 +}; + MapView::MapView() { m_viewMode = NEAR_VIEW; diff --git a/src/otclient/mapview.h b/src/otclient/mapview.h index 22f48b8e..42fdffd2 100644 --- a/src/otclient/mapview.h +++ b/src/otclient/mapview.h @@ -32,17 +32,6 @@ // @bindclass class MapView : public LuaObject { - enum { - // 3840x2160 => 1080p optimized - // 2560x1440 => 720p optimized - // 1728x972 => 480p optimized - - NEAR_VIEW_AREA = 32*32, - MID_VIEW_AREA = 64*64, - FAR_VIEW_AREA = 128*128, - MAX_TILE_DRAWS = NEAR_VIEW_AREA*7 - }; - public: enum ViewMode { NEAR_VIEW, @@ -135,16 +124,16 @@ private: Point m_virtualCenterOffset; Point m_visibleCenterOffset; Position m_customCameraPosition; - Boolean m_mustUpdateVisibleTilesCache; - Boolean m_mustDrawVisibleTilesCache; - Boolean m_mustCleanFramebuffer; - Boolean m_multifloor; - Boolean m_animated; - Boolean m_autoViewMode; - Boolean m_drawTexts; - Boolean m_smooth; - Boolean m_drawMinimapColors; - Boolean m_follow; + stdext::boolean m_mustUpdateVisibleTilesCache; + stdext::boolean m_mustDrawVisibleTilesCache; + stdext::boolean m_mustCleanFramebuffer; + stdext::boolean m_multifloor; + stdext::boolean m_animated; + stdext::boolean m_autoViewMode; + stdext::boolean m_drawTexts; + stdext::boolean m_smooth; + stdext::boolean m_drawMinimapColors; + stdext::boolean m_follow; std::vector m_cachedVisibleTiles; std::vector m_cachedFloorVisibleCreatures; CreaturePtr m_followingCreature; diff --git a/src/otclient/minimap.h b/src/otclient/minimap.h index 0fd09e06..84540f39 100644 --- a/src/otclient/minimap.h +++ b/src/otclient/minimap.h @@ -36,7 +36,7 @@ struct MinimapArea ImagePtr img; TexturePtr tex; uint8 colors[MINIMAP_AREA_SIZE][MINIMAP_AREA_SIZE]; - Boolean mustUpdate; + stdext::boolean mustUpdate; }; class Minimap diff --git a/src/otclient/protocolgame.h b/src/otclient/protocolgame.h index b00e016d..61b4e9ae 100644 --- a/src/otclient/protocolgame.h +++ b/src/otclient/protocolgame.h @@ -214,8 +214,8 @@ public: Position getPosition(const InputMessagePtr& msg); private: - Boolean m_enableSendExtendedOpcode; - Boolean m_gameInitialized; + stdext::boolean m_enableSendExtendedOpcode; + stdext::boolean m_gameInitialized; std::string m_accountName; std::string m_accountPassword; std::string m_characterName; diff --git a/src/otclient/spritemanager.h b/src/otclient/spritemanager.h index 68e1be72..40ff7309 100644 --- a/src/otclient/spritemanager.h +++ b/src/otclient/spritemanager.h @@ -44,7 +44,7 @@ public: bool isLoaded() { return m_loaded; } private: - Boolean m_loaded; + stdext::boolean m_loaded; uint32 m_signature; int m_spritesCount; int m_spritesOffset; diff --git a/src/otclient/statictext.h b/src/otclient/statictext.h index f6b1803b..916e7d95 100644 --- a/src/otclient/statictext.h +++ b/src/otclient/statictext.h @@ -51,7 +51,7 @@ private: void scheduleUpdate(); void compose(); - Boolean m_yell; + stdext::boolean m_yell; std::deque> m_messages; std::string m_name; Otc::MessageMode m_mode; diff --git a/src/otclient/thingstype.h b/src/otclient/thingstype.h index f4407e61..9995ff14 100644 --- a/src/otclient/thingstype.h +++ b/src/otclient/thingstype.h @@ -57,7 +57,7 @@ public: private: uint32 m_signature; - Boolean m_loaded; + stdext::boolean m_loaded; ThingTypeList m_things[LastCategory]; static ThingType m_emptyThingType; }; diff --git a/src/otclient/thingtype.h b/src/otclient/thingtype.h index 7f6539cb..d307cd2e 100644 --- a/src/otclient/thingtype.h +++ b/src/otclient/thingtype.h @@ -29,7 +29,6 @@ #include #include #include -#include enum ThingCategory : uint8 { ThingCategoryItem = 0, @@ -180,7 +179,7 @@ private: ThingCategory m_category; uint16 m_id; bool m_null; - AttribStorage m_attribs; + stdext::attrib_storage m_attribs; Size m_size; Point m_displacement; diff --git a/src/otclient/uicreature.h b/src/otclient/uicreature.h index feded127..98813b01 100644 --- a/src/otclient/uicreature.h +++ b/src/otclient/uicreature.h @@ -42,7 +42,7 @@ protected: void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode); CreaturePtr m_creature; - Boolean m_fixedCreatureSize; + stdext::boolean m_fixedCreatureSize; }; #endif diff --git a/src/otclient/uiitem.h b/src/otclient/uiitem.h index df58dbdf..8d84491e 100644 --- a/src/otclient/uiitem.h +++ b/src/otclient/uiitem.h @@ -50,7 +50,7 @@ protected: void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode); ItemPtr m_item; - Boolean m_virtual; + stdext::boolean m_virtual; }; #endif