Just some refactoring

This commit is contained in:
Eduardo Bart 2012-07-29 07:32:44 -03:00
parent 29a4d467af
commit 73769c62e4
47 changed files with 252 additions and 142 deletions

View File

@ -21,7 +21,6 @@ set(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/pch.h ${CMAKE_CURRENT_LIST_DIR}/pch.h
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp ${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.cpp
${CMAKE_CURRENT_LIST_DIR}/util/color.h ${CMAKE_CURRENT_LIST_DIR}/util/color.h
${CMAKE_CURRENT_LIST_DIR}/util/crypt.cpp ${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.cpp
${CMAKE_CURRENT_LIST_DIR}/util/rsa.h ${CMAKE_CURRENT_LIST_DIR}/util/rsa.h
${CMAKE_CURRENT_LIST_DIR}/util/size.h ${CMAKE_CURRENT_LIST_DIR}/util/size.h
${CMAKE_CURRENT_LIST_DIR}/util/attribstorage.h
# stdext # stdext
${CMAKE_CURRENT_LIST_DIR}/stdext/cast.h ${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/string.h
${CMAKE_CURRENT_LIST_DIR}/stdext/time.h ${CMAKE_CURRENT_LIST_DIR}/stdext/time.h
${CMAKE_CURRENT_LIST_DIR}/stdext/types.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 # core
${CMAKE_CURRENT_LIST_DIR}/core/application.cpp ${CMAKE_CURRENT_LIST_DIR}/core/application.cpp
@ -127,11 +127,11 @@ endif()
# gcc compile flags # gcc compile flags
set(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable") 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_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "-O2") 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") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
# process options # process options

View File

@ -68,9 +68,9 @@ protected:
std::string m_appCompactName; std::string m_appCompactName;
std::string m_appVersion; std::string m_appVersion;
std::string m_startupOptions; std::string m_startupOptions;
Boolean<false> m_running; bool m_running = false;
Boolean<false> m_stopping; bool m_stopping = false;
Boolean<false> m_terminated; stdext::boolean<false> m_terminated;
}; };
#ifdef FW_GRAPHICS #ifdef FW_GRAPHICS

View File

@ -40,7 +40,7 @@ public:
private: private:
std::list<EventPtr> m_eventList; std::list<EventPtr> m_eventList;
int m_pollEventsSize; int m_pollEventsSize;
Boolean<false> m_disabled; bool m_disabled = false;
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList; std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
}; };

View File

@ -60,8 +60,8 @@ protected:
void inputEvent(const InputEvent& event); void inputEvent(const InputEvent& event);
private: private:
Boolean<false> m_onInputEvent; bool m_onInputEvent = false;
Boolean<false> m_mustRepaint; bool m_mustRepaint = false;
AdaptativeFrameCounter m_backgroundFrameCounter; AdaptativeFrameCounter m_backgroundFrameCounter;
AdaptativeFrameCounter m_foregroundFrameCounter; AdaptativeFrameCounter m_foregroundFrameCounter;
TexturePtr m_foreground; TexturePtr m_foreground;

View File

@ -63,10 +63,10 @@ protected:
friend class ModuleManager; friend class ModuleManager;
private: private:
Boolean<false> m_loaded; bool m_loaded = false;
Boolean<false> m_autoLoad; bool m_autoLoad = false;
Boolean<false> m_reloadable; bool m_reloadable = false;
Boolean<false> m_sandboxed; bool m_sandboxed = false;
int m_autoLoadPriority; int m_autoLoadPriority;
int m_sandboxEnv; int m_sandboxEnv;
std::tuple<std::string, std::string> m_onLoadFunc; std::tuple<std::string, std::string> m_onLoadFunc;

View File

@ -72,7 +72,7 @@ public:
private: private:
std::string m_workDir; std::string m_workDir;
std::string m_writeDir; std::string m_writeDir;
Boolean<false> m_hasSearchPath; bool m_hasSearchPath = false;
std::deque<std::string> m_searchPaths; std::deque<std::string> m_searchPaths;
}; };

View File

@ -41,7 +41,7 @@ public:
private: private:
ticks_t m_startTicks; ticks_t m_startTicks;
Boolean<false> m_stopped; bool m_stopped = false;
}; };
#endif #endif

View File

@ -40,7 +40,6 @@
#include "util/rect.h" #include "util/rect.h"
#include "util/size.h" #include "util/size.h"
#include "util/matrix.h" #include "util/matrix.h"
#include "util/boolean.h"
// logger // logger
#include "core/logger.h" #include "core/logger.h"

View File

@ -48,7 +48,7 @@ private:
std::string m_text; std::string m_text;
Size m_textSize; Size m_textSize;
Boolean<true> m_textMustRecache; bool m_textMustRecache = true;
CoordsBuffer m_textCoordsBuffer; CoordsBuffer m_textCoordsBuffer;
Rect m_textCachedScreenCoords; Rect m_textCachedScreenCoords;
BitmapFontPtr m_font; BitmapFontPtr m_font;

View File

@ -61,8 +61,8 @@ private:
Size m_oldViewportSize; Size m_oldViewportSize;
uint m_fbo; uint m_fbo;
uint m_prevBoundFbo; uint m_prevBoundFbo;
Boolean<true> m_backuping; bool m_backuping = true;
Boolean<true> m_smooth; bool m_smooth = true;
static uint boundFbo; static uint boundFbo;
}; };

View File

@ -77,16 +77,16 @@ private:
int m_maxTextureSize; int m_maxTextureSize;
int m_alphaBits; int m_alphaBits;
Boolean<false> m_ok; bool m_ok = false;
Boolean<true> m_useDrawArrays; bool m_useDrawArrays = true;
Boolean<true> m_useFBO; bool m_useFBO = true;
Boolean<false> m_useHardwareBuffers; bool m_useHardwareBuffers = false;
Boolean<true> m_useBilinearFiltering; bool m_useBilinearFiltering = true;
Boolean<true> m_useNonPowerOfTwoTextures; bool m_useNonPowerOfTwoTextures = true;
Boolean<true> m_useMipmaps; bool m_useMipmaps = true;
Boolean<true> m_useHardwareMipmaps; bool m_useHardwareMipmaps = true;
Boolean<true> m_useClampToEdge; bool m_useClampToEdge = true;
Boolean<true> m_cacheBackbuffer; bool m_cacheBackbuffer = true;
PainterEngine m_prefferedPainterEngine; PainterEngine m_prefferedPainterEngine;
PainterEngine m_selectedPainterEngine; PainterEngine m_selectedPainterEngine;
}; };

View File

@ -72,7 +72,7 @@ private:
void updateGlTextureState(); void updateGlTextureState();
GLenum m_matrixMode; GLenum m_matrixMode;
Boolean<false> m_textureEnabled; bool m_textureEnabled = false;
}; };
extern PainterOGL1 *g_painterOGL1; extern PainterOGL1 *g_painterOGL1;

View File

@ -63,10 +63,10 @@ protected:
Size m_size; Size m_size;
Size m_glSize; Size m_glSize;
Matrix3 m_transformMatrix; Matrix3 m_transformMatrix;
Boolean<false> m_hasMipmaps; bool m_hasMipmaps = false;
Boolean<false> m_smooth; bool m_smooth = false;
Boolean<false> m_upsideDown; bool m_upsideDown = false;
Boolean<false> m_repeat; bool m_repeat = false;
}; };
#endif #endif

View File

@ -99,7 +99,7 @@ protected:
void fireKeysPress(); void fireKeysPress();
std::map<int, Fw::Key> m_keyMap; std::map<int, Fw::Key> m_keyMap;
std::map<Fw::Key, Boolean<false>> m_keysState; std::map<Fw::Key, stdext::boolean<false>> m_keysState;
std::map<Fw::Key, ticks_t> m_firstKeysPress; std::map<Fw::Key, ticks_t> m_firstKeysPress;
std::map<Fw::Key, ticks_t> m_lastKeysPress; std::map<Fw::Key, ticks_t> m_lastKeysPress;
Timer m_keyPressTimer; Timer m_keyPressTimer;
@ -109,13 +109,13 @@ protected:
Size m_unmaximizedSize; Size m_unmaximizedSize;
Point m_unmaximizedPos; Point m_unmaximizedPos;
InputEvent m_inputEvent; InputEvent m_inputEvent;
Boolean<false> m_mouseButtonStates[4]; stdext::boolean<false> m_mouseButtonStates[4];
Boolean<false> m_created; bool m_created = false;
Boolean<false> m_visible; bool m_visible = false;
Boolean<false> m_focused; bool m_focused = false;
Boolean<false> m_fullscreen; bool m_fullscreen = false;
Boolean<false> m_maximized; bool m_maximized = false;
std::function<void()> m_onClose; std::function<void()> m_onClose;
OnResizeCallback m_onResize; OnResizeCallback m_onResize;

View File

@ -61,8 +61,8 @@ private:
SoundSourcePtr m_musicSource; SoundSourcePtr m_musicSource;
ALCdevice *m_device; ALCdevice *m_device;
ALCcontext *m_context; ALCcontext *m_context;
Boolean<false> m_musicEnabled; bool m_musicEnabled = false;
Boolean<false> m_soundEnabled; bool m_soundEnabled = false;
std::string m_currentMusic; std::string m_currentMusic;
}; };

View File

@ -56,7 +56,7 @@ private:
SoundFilePtr m_soundFile; SoundFilePtr m_soundFile;
std::array<SoundBufferPtr,STREAM_FRAGMENTS> m_buffers; std::array<SoundBufferPtr,STREAM_FRAGMENTS> m_buffers;
DownMix m_downMix; DownMix m_downMix;
Boolean<false> m_looping; bool m_looping = false;
}; };
#endif #endif

View File

@ -20,21 +20,21 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef ATTRIBSTORAGE_H #ifndef STDEXT_ATTRIBSTORAGE_H
#define ATTRIBSTORAGE_H #define STDEXT_ATTRIBSTORAGE_H
#include "../stdext/types.h" #include "types.h"
#include <tuple> #include <tuple>
#include <boost/any.hpp> #include <boost/any.hpp>
// disable memory alignment
#pragma pack(push,1) // disable memory alignment #pragma pack(push,1)
// this class was designed to use less memory as possible // this class was designed to use less memory as possible
class AttribStorage { namespace stdext {
class attrib_storage {
public: public:
AttribStorage() : m_attribs(nullptr), m_size(0) { } ~attrib_storage() { if(m_attribs) delete[] m_attribs; }
~AttribStorage() { if(m_attribs) delete[] m_attribs; }
template<typename T> template<typename T>
void set(uint8 id, T value) { void set(uint8 id, T value) {
@ -72,10 +72,15 @@ public:
return true; return true;
return false; return false;
} }
private: private:
std::tuple<uint8, boost::any>* m_attribs; std::tuple<uint8, boost::any>* m_attribs = nullptr;
uint8 m_size; uint8 m_size = 0;
}; };
// restore memory alignment
#pragma pack(pop) #pragma pack(pop)
}
#endif #endif

View File

@ -23,10 +23,11 @@
#ifndef BOOLEAN_H #ifndef BOOLEAN_H
#define BOOLEAN_H #define BOOLEAN_H
/// Boolean with default value namespace stdext {
template<bool def> template<bool def>
struct Boolean { struct boolean {
Boolean() : v(def) { } boolean() : v(def) { }
operator bool &() { return v; } operator bool &() { return v; }
operator bool const &() const { return v; } operator bool const &() const { return v; }
bool& operator=(const bool& o) { v = o; return v; } bool& operator=(const bool& o) { v = o; return v; }
@ -34,4 +35,6 @@ private:
bool v; bool v;
}; };
}
#endif #endif

View File

@ -27,8 +27,8 @@
// clang is supported // clang is supported
#undef _GLIBCXX_USE_FLOAT128 #undef _GLIBCXX_USE_FLOAT128
#elif defined(__GNUC__) #elif defined(__GNUC__)
#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
#error "Sorry, you need gcc 4.6 or greater to compile." #error "Sorry, you need gcc 4.7 or greater to compile."
#endif #endif
#else #else
#error "Compiler not supported." #error "Compiler not supported."

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/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 <boost/checked_delete.hpp>
#include <boost/intrusive_ptr.hpp>
namespace stdext {
template<typename T>
using shared_object_ptr = boost::intrusive_ptr<T>;
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<typename T>
shared_object_ptr<T> self_cast() { return shared_object_ptr<T>(static_cast<T*>(this)); }
template<typename T>
shared_object_ptr<T> dynamic_self_cast() { return shared_object_ptr<T>(dynamic_cast<T*>(this)); }
private:
unsigned int m_refs;
};
template<class T, typename... Args>
shared_object_ptr<T> make_shared_object(Args... args) { return shared_object_ptr<T>(new T(args...)); }
}
namespace std {
template<typename T>
struct hash<boost::intrusive_ptr<T>> : public __hash_base<size_t, boost::intrusive_ptr<T>> {
size_t operator()(const boost::intrusive_ptr<T>& p) const noexcept { return std::hash<T*>()(p.get()); }
};
}
template<typename T>
struct remove_const_ref {
typedef typename std::remove_const<typename std::remove_reference<T>::type>::type type;
};
template<typename T>
void intrusive_ptr_add_ref(T* p) { (static_cast<stdext::shared_object*>(p))->add_ref(); }
template<typename T>
void intrusive_ptr_release(T* p) { (static_cast<stdext::shared_object*>(p))->dec_ref(); }
#endif

View File

@ -33,5 +33,7 @@
#include "dumper.h" #include "dumper.h"
#include "time.h" #include "time.h"
#include "shared_object.h" #include "shared_object.h"
#include "attrib_storage.h"
#include "boolean.h"
#endif #endif

View File

@ -35,6 +35,17 @@ inline ticks_t micros() { return std::chrono::duration_cast<std::chrono::microse
inline void millisleep(uint32 ms) { usleep(ms * 1000); }; inline void millisleep(uint32 ms) { usleep(ms * 1000); };
inline void microsleep(uint32 us) { usleep(us); }; inline void microsleep(uint32 us) { usleep(us); };
struct timer {
public:
timer() { restart(); }
float elapsed_seconds() { return (stdext::micros() - m_start)/1000000.0; }
ticks_t elapsed_millis() { return (stdext::micros() - m_start)/1000; }
ticks_t elapsed_micros() { return stdext::micros() - m_start; }
void restart() { m_start = stdext::micros(); }
private:
ticks_t m_start;
};
} }
#endif #endif

View File

@ -39,6 +39,19 @@ typedef int32_t int32;
typedef int16_t int16; typedef int16_t int16;
typedef int8_t int8; typedef int8_t int8;
typedef unsigned char fast_uchar;
typedef unsigned long fast_ushort;
typedef unsigned long fast_uint;
typedef unsigned long fast_ulong;
typedef uint_fast64_t fast_uint64;
typedef uint_fast32_t fast_uint32;
typedef uint_fast16_t fast_uint16;
typedef uint_fast8_t fast_uint8;
typedef int_fast64_t fast_int64;
typedef int_fast32_t fast_int32;
typedef int_fast16_t fast_int16;
typedef int_fast8_t fast_int8;
typedef int64_t ticks_t; typedef int64_t ticks_t;
#endif #endif

View File

@ -41,7 +41,7 @@ public:
bool isUIBoxLayout() { return true; } bool isUIBoxLayout() { return true; }
protected: protected:
Boolean<false> m_fitChildren; bool m_fitChildren = false;
int m_spacing; int m_spacing;
}; };

View File

@ -55,9 +55,9 @@ private:
int m_cellSpacing; int m_cellSpacing;
int m_numColumns; int m_numColumns;
int m_numLines; int m_numLines;
Boolean<false> m_autoSpacing; bool m_autoSpacing = false;
Boolean<false> m_fitChildren; bool m_fitChildren = false;
Boolean<false> m_flow; bool m_flow = false;
}; };
#endif #endif

View File

@ -39,7 +39,7 @@ public:
protected: protected:
bool internalUpdate(); bool internalUpdate();
Boolean<false> m_alignRight; bool m_alignRight = false;
}; };
#endif #endif

View File

@ -58,8 +58,8 @@ protected:
virtual bool internalUpdate() = 0; virtual bool internalUpdate() = 0;
int m_updateDisabled; int m_updateDisabled;
Boolean<false> m_updating; bool m_updating = false;
Boolean<false> m_updateScheduled; bool m_updateScheduled = false;
UIWidgetPtr m_parentWidget; UIWidgetPtr m_parentWidget;
}; };

View File

@ -82,8 +82,8 @@ private:
UIWidgetPtr m_draggingWidget; UIWidgetPtr m_draggingWidget;
UIWidgetPtr m_hoveredWidget; UIWidgetPtr m_hoveredWidget;
UIWidgetPtr m_pressedWidget; UIWidgetPtr m_pressedWidget;
Boolean<false> m_hoverUpdateScheduled; bool m_hoverUpdateScheduled = false;
Boolean<false> m_drawDebugBoxes; bool m_drawDebugBoxes = false;
std::unordered_map<std::string, OTMLNodePtr> m_styles; std::unordered_map<std::string, OTMLNodePtr> m_styles;
UIWidgetList m_destroyedWidgets; UIWidgetList m_destroyedWidgets;
ScheduledEventPtr m_checkEvent; ScheduledEventPtr m_checkEvent;

View File

@ -40,7 +40,7 @@ public:
protected: protected:
bool internalUpdate(); bool internalUpdate();
Boolean<false> m_alignBottom; stdext::boolean<false> m_alignBottom;
}; };
#endif #endif

View File

@ -61,14 +61,14 @@ protected:
std::string m_id; std::string m_id;
Rect m_rect; Rect m_rect;
Point m_virtualOffset; Point m_virtualOffset;
Boolean<true> m_enabled; stdext::boolean<true> m_enabled;
Boolean<true> m_visible; stdext::boolean<true> m_visible;
Boolean<true> m_focusable; stdext::boolean<true> m_focusable;
Boolean<false> m_fixedSize; stdext::boolean<false> m_fixedSize;
Boolean<false> m_phantom; stdext::boolean<false> m_phantom;
Boolean<false> m_dragable; stdext::boolean<false> m_dragable;
Boolean<false> m_destroyed; stdext::boolean<false> m_destroyed;
Boolean<false> m_clipping; stdext::boolean<false> m_clipping;
UILayoutPtr m_layout; UILayoutPtr m_layout;
UIWidgetPtr m_parent; UIWidgetPtr m_parent;
UIWidgetList m_children; UIWidgetList m_children;
@ -155,8 +155,8 @@ public:
UIWidgetPtr backwardsGetWidgetById(const std::string& id); UIWidgetPtr backwardsGetWidgetById(const std::string& id);
private: private:
Boolean<false> m_updateEventScheduled; stdext::boolean<false> m_updateEventScheduled;
Boolean<false> m_loadingStyle; stdext::boolean<false> m_loadingStyle;
// state managment // state managment
@ -171,8 +171,8 @@ private:
void updateChildrenIndexStates(); void updateChildrenIndexStates();
void updateStyle(); void updateStyle();
Boolean<false> m_updateStyleScheduled; stdext::boolean<false> m_updateStyleScheduled;
Boolean<true> m_firstOnStyle; stdext::boolean<true> m_firstOnStyle;
OTMLNodePtr m_stateStyle; OTMLNodePtr m_stateStyle;
int m_states; int m_states;
@ -394,8 +394,8 @@ private:
CoordsBuffer m_imageCoordsBuffer; CoordsBuffer m_imageCoordsBuffer;
Rect m_imageCachedScreenCoords; Rect m_imageCachedScreenCoords;
Boolean<true> m_imageMustRecache; stdext::boolean<true> m_imageMustRecache;
Boolean<false> m_imageBordered; stdext::boolean<false> m_imageBordered;
protected: protected:
void drawImage(const Rect& screenCoords); void drawImage(const Rect& screenCoords);
@ -404,9 +404,9 @@ protected:
Rect m_imageClipRect; Rect m_imageClipRect;
Rect m_imageRect; Rect m_imageRect;
Color m_imageColor; Color m_imageColor;
Boolean<false> m_imageFixedRatio; stdext::boolean<false> m_imageFixedRatio;
Boolean<false> m_imageRepeated; stdext::boolean<false> m_imageRepeated;
Boolean<false> m_imageSmooth; stdext::boolean<false> m_imageSmooth;
EdgeGroup<int> m_imageBorder; EdgeGroup<int> m_imageBorder;
public: public:
@ -451,7 +451,7 @@ private:
void updateText(); void updateText();
void parseTextStyle(const OTMLNodePtr& styleNode); void parseTextStyle(const OTMLNodePtr& styleNode);
Boolean<true> m_textMustRecache; stdext::boolean<true> m_textMustRecache;
CoordsBuffer m_textCoordsBuffer; CoordsBuffer m_textCoordsBuffer;
Rect m_textCachedScreenCoords; Rect m_textCachedScreenCoords;
@ -465,8 +465,8 @@ protected:
std::string m_drawText; std::string m_drawText;
Fw::AlignmentFlag m_textAlign; Fw::AlignmentFlag m_textAlign;
Point m_textOffset; Point m_textOffset;
Boolean<false> m_textWrap; stdext::boolean<false> m_textWrap;
Boolean<false> m_textAutoResize; stdext::boolean<false> m_textAutoResize;
BitmapFontPtr m_font; BitmapFontPtr m_font;
public: public:

View File

@ -121,14 +121,14 @@ protected:
TexturePtr m_skullTexture; TexturePtr m_skullTexture;
TexturePtr m_shieldTexture; TexturePtr m_shieldTexture;
TexturePtr m_emblemTexture; TexturePtr m_emblemTexture;
Boolean<true> m_showShieldTexture; stdext::boolean<true> m_showShieldTexture;
Boolean<false> m_shieldBlink; stdext::boolean<false> m_shieldBlink;
Boolean<false> m_passable; stdext::boolean<false> m_passable;
Color m_timedSquareColor; Color m_timedSquareColor;
Color m_staticSquareColor; Color m_staticSquareColor;
Boolean<false> m_showTimedSquare; stdext::boolean<false> m_showTimedSquare;
Boolean<false> m_showStaticSquare; stdext::boolean<false> m_showStaticSquare;
Boolean<false> m_removed; stdext::boolean<false> m_removed;
CachedText m_nameCache; CachedText m_nameCache;
Color m_informationColor; Color m_informationColor;
@ -140,8 +140,8 @@ protected:
TilePtr m_walkingTile; TilePtr m_walkingTile;
int m_walkInterval; int m_walkInterval;
int m_walkAnimationInterval; int m_walkAnimationInterval;
Boolean<false> m_walking; stdext::boolean<false> m_walking;
Boolean<false> m_footStepDrawn; stdext::boolean<false> m_footStepDrawn;
ScheduledEventPtr m_walkUpdateEvent; ScheduledEventPtr m_walkUpdateEvent;
Point m_walkOffset; Point m_walkOffset;
Otc::Direction m_walkTurnDirection; Otc::Direction m_walkTurnDirection;

View File

@ -25,7 +25,6 @@
#include "declarations.h" #include "declarations.h"
#include <framework/luaengine/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/util/attribstorage.h>
#include "outfit.h" #include "outfit.h"
enum CreatureAttr : uint8 enum CreatureAttr : uint8
@ -51,7 +50,7 @@ public:
int getSpawnTime() { return m_attribs.get<int>(CreatureAttrSpawnTime); } int getSpawnTime() { return m_attribs.get<int>(CreatureAttrSpawnTime); }
private: private:
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
}; };
class Creatures class Creatures
@ -72,7 +71,7 @@ protected:
private: private:
std::vector<CreatureTypePtr> m_creatures; std::vector<CreatureTypePtr> m_creatures;
Boolean<false> m_loaded; stdext::boolean<false> m_loaded;
}; };
#endif #endif

View File

@ -27,7 +27,6 @@
#include "tile.h" #include "tile.h"
#include <framework/luaengine/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/util/attribstorage.h>
enum HouseAttr : uint8 enum HouseAttr : uint8
{ {
@ -64,9 +63,9 @@ protected:
void save(TiXmlElement &elem) { } // TODO void save(TiXmlElement &elem) { } // TODO
private: private:
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
TileMap m_tiles; TileMap m_tiles;
Boolean<false> m_isGuildHall; stdext::boolean<false> m_isGuildHall;
friend class Houses; friend class Houses;
}; };

View File

@ -24,7 +24,6 @@
#define ITEM_H #define ITEM_H
#include <framework/global.h> #include <framework/global.h>
#include <framework/util/attribstorage.h>
#include "thing.h" #include "thing.h"
#include "itemtype.h" #include "itemtype.h"
@ -125,7 +124,7 @@ private:
uint16 m_id; uint16 m_id;
uint16 m_otbId; uint16 m_otbId;
uint8 m_countOrSubType; uint8 m_countOrSubType;
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -27,7 +27,6 @@
#include <framework/core/declarations.h> #include <framework/core/declarations.h>
#include <framework/luaengine/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/xml/tinyxml.h> #include <framework/xml/tinyxml.h>
#include <framework/util/attribstorage.h>
enum ItemCategory { enum ItemCategory {
ItemCategoryInvalid = 0, ItemCategoryInvalid = 0,
@ -102,9 +101,9 @@ public:
private: private:
ItemCategory m_category; ItemCategory m_category;
Boolean<true> m_null; stdext::boolean<true> m_null;
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
}; };
#endif #endif

View File

@ -430,6 +430,7 @@ bool Map::loadOtcm(const std::string& fileName)
if(!fin) if(!fin)
stdext::throw_exception("unable to open file"); stdext::throw_exception("unable to open file");
stdext::timer loadTimer;
fin->cache(); fin->cache();
uint32 signature = fin->getU32(); uint32 signature = fin->getU32();
@ -491,6 +492,7 @@ bool Map::loadOtcm(const std::string& fileName)
fin->close(); fin->close();
g_logger.debug(stdext::format("Otcm load time: %.2f seconds", loadTimer.elapsed_seconds()));
return true; return true;
} catch(stdext::exception& e) { } catch(stdext::exception& e) {
g_logger.error(stdext::format("failed to load OTCM map: %s", e.what())); g_logger.error(stdext::format("failed to load OTCM map: %s", e.what()));

View File

@ -31,7 +31,6 @@
#include "statictext.h" #include "statictext.h"
#include <framework/core/clock.h> #include <framework/core/clock.h>
#include <framework/util/attribstorage.h>
enum OTBM_ItemAttr enum OTBM_ItemAttr
{ {
@ -268,7 +267,7 @@ private:
Position m_centralPosition; Position m_centralPosition;
Rect m_tilesRect; Rect m_tilesRect;
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
Houses m_houses; Houses m_houses;
Towns m_towns; Towns m_towns;
Creatures m_creatures; Creatures m_creatures;

View File

@ -35,6 +35,18 @@
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/core/application.h> #include <framework/core/application.h>
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() MapView::MapView()
{ {
m_viewMode = NEAR_VIEW; m_viewMode = NEAR_VIEW;

View File

@ -32,17 +32,6 @@
// @bindclass // @bindclass
class MapView : public LuaObject 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: public:
enum ViewMode { enum ViewMode {
NEAR_VIEW, NEAR_VIEW,
@ -135,16 +124,16 @@ private:
Point m_virtualCenterOffset; Point m_virtualCenterOffset;
Point m_visibleCenterOffset; Point m_visibleCenterOffset;
Position m_customCameraPosition; Position m_customCameraPosition;
Boolean<true> m_mustUpdateVisibleTilesCache; stdext::boolean<true> m_mustUpdateVisibleTilesCache;
Boolean<true> m_mustDrawVisibleTilesCache; stdext::boolean<true> m_mustDrawVisibleTilesCache;
Boolean<true> m_mustCleanFramebuffer; stdext::boolean<true> m_mustCleanFramebuffer;
Boolean<true> m_multifloor; stdext::boolean<true> m_multifloor;
Boolean<true> m_animated; stdext::boolean<true> m_animated;
Boolean<true> m_autoViewMode; stdext::boolean<true> m_autoViewMode;
Boolean<true> m_drawTexts; stdext::boolean<true> m_drawTexts;
Boolean<true> m_smooth; stdext::boolean<true> m_smooth;
Boolean<false> m_drawMinimapColors; stdext::boolean<false> m_drawMinimapColors;
Boolean<true> m_follow; stdext::boolean<true> m_follow;
std::vector<TilePtr> m_cachedVisibleTiles; std::vector<TilePtr> m_cachedVisibleTiles;
std::vector<CreaturePtr> m_cachedFloorVisibleCreatures; std::vector<CreaturePtr> m_cachedFloorVisibleCreatures;
CreaturePtr m_followingCreature; CreaturePtr m_followingCreature;

View File

@ -36,7 +36,7 @@ struct MinimapArea
ImagePtr img; ImagePtr img;
TexturePtr tex; TexturePtr tex;
uint8 colors[MINIMAP_AREA_SIZE][MINIMAP_AREA_SIZE]; uint8 colors[MINIMAP_AREA_SIZE][MINIMAP_AREA_SIZE];
Boolean<true> mustUpdate; stdext::boolean<true> mustUpdate;
}; };
class Minimap class Minimap

View File

@ -214,8 +214,8 @@ public:
Position getPosition(const InputMessagePtr& msg); Position getPosition(const InputMessagePtr& msg);
private: private:
Boolean<false> m_enableSendExtendedOpcode; stdext::boolean<false> m_enableSendExtendedOpcode;
Boolean<false> m_gameInitialized; stdext::boolean<false> m_gameInitialized;
std::string m_accountName; std::string m_accountName;
std::string m_accountPassword; std::string m_accountPassword;
std::string m_characterName; std::string m_characterName;

View File

@ -44,7 +44,7 @@ public:
bool isLoaded() { return m_loaded; } bool isLoaded() { return m_loaded; }
private: private:
Boolean<false> m_loaded; stdext::boolean<false> m_loaded;
uint32 m_signature; uint32 m_signature;
int m_spritesCount; int m_spritesCount;
int m_spritesOffset; int m_spritesOffset;

View File

@ -51,7 +51,7 @@ private:
void scheduleUpdate(); void scheduleUpdate();
void compose(); void compose();
Boolean<false> m_yell; stdext::boolean<false> m_yell;
std::deque<std::pair<std::string, ticks_t>> m_messages; std::deque<std::pair<std::string, ticks_t>> m_messages;
std::string m_name; std::string m_name;
Otc::MessageMode m_mode; Otc::MessageMode m_mode;

View File

@ -57,7 +57,7 @@ public:
private: private:
uint32 m_signature; uint32 m_signature;
Boolean<false> m_loaded; stdext::boolean<false> m_loaded;
ThingTypeList m_things[LastCategory]; ThingTypeList m_things[LastCategory];
static ThingType m_emptyThingType; static ThingType m_emptyThingType;
}; };

View File

@ -29,7 +29,6 @@
#include <framework/graphics/coordsbuffer.h> #include <framework/graphics/coordsbuffer.h>
#include <framework/luaengine/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/net/server.h> #include <framework/net/server.h>
#include <framework/util/attribstorage.h>
enum ThingCategory : uint8 { enum ThingCategory : uint8 {
ThingCategoryItem = 0, ThingCategoryItem = 0,
@ -180,7 +179,7 @@ private:
ThingCategory m_category; ThingCategory m_category;
uint16 m_id; uint16 m_id;
bool m_null; bool m_null;
AttribStorage m_attribs; stdext::attrib_storage m_attribs;
Size m_size; Size m_size;
Point m_displacement; Point m_displacement;

View File

@ -42,7 +42,7 @@ protected:
void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode); void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
CreaturePtr m_creature; CreaturePtr m_creature;
Boolean<false> m_fixedCreatureSize; stdext::boolean<false> m_fixedCreatureSize;
}; };
#endif #endif

View File

@ -50,7 +50,7 @@ protected:
void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode); void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
ItemPtr m_item; ItemPtr m_item;
Boolean<false> m_virtual; stdext::boolean<false> m_virtual;
}; };
#endif #endif