mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 13:03:27 +02:00
Huge engine change, replace all std::shared_ptrs
Create a new shared pointer type stdext::shared_object_ptr and stdext::shared_obj using boost::intrusive_ptr Advantages: * half memory usage * faster and lightweight Disadvantages: * using weak_ptr is not supported anymore * compiling seems slower
This commit is contained in:
@@ -33,7 +33,7 @@ enum {
|
||||
BINARYTREE_NODE_END = 0xFF
|
||||
};
|
||||
|
||||
class BinaryTree
|
||||
class BinaryTree : public stdext::shared_object
|
||||
{
|
||||
public:
|
||||
BinaryTree(const FileStreamPtr& fin);
|
||||
|
@@ -33,13 +33,11 @@ class ScheduledEvent;
|
||||
class FileStream;
|
||||
class BinaryTree;
|
||||
|
||||
typedef std::shared_ptr<Module> ModulePtr;
|
||||
typedef std::shared_ptr<Event> EventPtr;
|
||||
typedef std::shared_ptr<ScheduledEvent> ScheduledEventPtr;
|
||||
typedef std::shared_ptr<FileStream> FileStreamPtr;
|
||||
typedef std::shared_ptr<BinaryTree> BinaryTreePtr;
|
||||
|
||||
typedef std::weak_ptr<BinaryTree> BinaryTreeWeakPtr;
|
||||
typedef stdext::shared_object_ptr<Module> ModulePtr;
|
||||
typedef stdext::shared_object_ptr<Event> EventPtr;
|
||||
typedef stdext::shared_object_ptr<ScheduledEvent> ScheduledEventPtr;
|
||||
typedef stdext::shared_object_ptr<FileStream> FileStreamPtr;
|
||||
typedef stdext::shared_object_ptr<BinaryTree> BinaryTreePtr;
|
||||
|
||||
typedef std::vector<BinaryTreePtr> BinaryTreeVec;
|
||||
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
void addString(const std::string& v);
|
||||
BinaryTreePtr makeTree();
|
||||
|
||||
FileStreamPtr asFileStream() { return std::static_pointer_cast<FileStream>(shared_from_this()); }
|
||||
FileStreamPtr asFileStream() { return self_cast<FileStream>(); }
|
||||
|
||||
private:
|
||||
void checkWrite();
|
||||
|
@@ -56,7 +56,7 @@ public:
|
||||
int getAutoLoadPriority() { return m_autoLoadPriority; }
|
||||
|
||||
// @dontbind
|
||||
ModulePtr asModule() { return std::static_pointer_cast<Module>(shared_from_this()); }
|
||||
ModulePtr asModule() { return self_cast<Module>(); }
|
||||
|
||||
protected:
|
||||
void discover(const OTMLNodePtr& moduleNode);
|
||||
|
@@ -46,7 +46,7 @@ void ModuleManager::discoverModules()
|
||||
if(boost::ends_with(moduleFile, ".otmod")) {
|
||||
ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile);
|
||||
if(module && module->isAutoLoad())
|
||||
m_autoLoadModules.insert(make_pair(module->getAutoLoadPriority(), module));
|
||||
m_autoLoadModules.insert(std::make_pair(module->getAutoLoadPriority(), module));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user