aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Dynamic/FactoryHolder.h2
-rw-r--r--src/server/shared/Dynamic/LinkedList.h10
-rw-r--r--src/server/shared/Dynamic/ObjectRegistry.h2
-rw-r--r--src/server/shared/Packets/ByteBuffer.cpp23
-rw-r--r--src/server/shared/Packets/ByteBuffer.h6
-rw-r--r--src/server/shared/PrecompiledHeaders/sharedPCH.h17
6 files changed, 47 insertions, 13 deletions
diff --git a/src/server/shared/Dynamic/FactoryHolder.h b/src/server/shared/Dynamic/FactoryHolder.h
index 317d50ea9fc..c3d9901c1ef 100644
--- a/src/server/shared/Dynamic/FactoryHolder.h
+++ b/src/server/shared/Dynamic/FactoryHolder.h
@@ -19,8 +19,8 @@
#define TRINITY_FACTORY_HOLDER
#include "Define.h"
-#include "Dynamic/TypeList.h"
#include "ObjectRegistry.h"
+#include "TypeList.h"
/** FactoryHolder holds a factory object of a specific type
*/
diff --git a/src/server/shared/Dynamic/LinkedList.h b/src/server/shared/Dynamic/LinkedList.h
index a9bcb2ea98f..0e9e44a2da4 100644
--- a/src/server/shared/Dynamic/LinkedList.h
+++ b/src/server/shared/Dynamic/LinkedList.h
@@ -164,7 +164,7 @@ class LinkedListHead
{ // construct with node pointer _Pnode
}
- Iterator& operator=(const_pointer const &_Right)
+ Iterator& operator=(const_pointer const& _Right)
{
_Ptr = pointer(_Right);
return *this;
@@ -206,22 +206,22 @@ class LinkedListHead
return (_Tmp);
}
- bool operator==(Iterator const &_Right) const
+ bool operator==(Iterator const& _Right) const
{ // test for iterator equality
return (_Ptr == _Right._Ptr);
}
- bool operator!=(Iterator const &_Right) const
+ bool operator!=(Iterator const& _Right) const
{ // test for iterator inequality
return (!(*this == _Right));
}
- bool operator==(pointer const &_Right) const
+ bool operator==(pointer const& _Right) const
{ // test for pointer equality
return (_Ptr != _Right);
}
- bool operator!=(pointer const &_Right) const
+ bool operator!=(pointer const& _Right) const
{ // test for pointer equality
return (!(*this == _Right));
}
diff --git a/src/server/shared/Dynamic/ObjectRegistry.h b/src/server/shared/Dynamic/ObjectRegistry.h
index 973c34fda24..8e501db9eef 100644
--- a/src/server/shared/Dynamic/ObjectRegistry.h
+++ b/src/server/shared/Dynamic/ObjectRegistry.h
@@ -81,6 +81,8 @@ class ObjectRegistry final
// non instanceable, only static
ObjectRegistry() { }
~ObjectRegistry() { }
+ ObjectRegistry(ObjectRegistry const&) = delete;
+ ObjectRegistry& operator=(ObjectRegistry const&) = delete;
};
#endif
diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp
index 1c838248eca..997d1488c64 100644
--- a/src/server/shared/Packets/ByteBuffer.cpp
+++ b/src/server/shared/Packets/ByteBuffer.cpp
@@ -69,15 +69,30 @@ uint32 ByteBuffer::ReadPackedTime()
return uint32(mktime(&lt));
}
-void ByteBuffer::append(const uint8 *src, size_t cnt)
+void ByteBuffer::append(uint8 const* src, size_t cnt)
{
ASSERT(src, "Attempted to put a NULL-pointer in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", _wpos, size());
ASSERT(cnt, "Attempted to put a zero-sized value in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", _wpos, size());
ASSERT(size() < 10000000);
+ size_t const newSize = _wpos + cnt;
+ if (_storage.capacity() < newSize) // custom memory allocation rules
+ {
+ if (newSize < 100)
+ _storage.reserve(300);
+ else if (newSize < 750)
+ _storage.reserve(2500);
+ else if (newSize < 6000)
+ _storage.reserve(10000);
+ else
+ _storage.reserve(400000);
+ }
+
FlushBits();
- _storage.insert(_storage.begin() + _wpos, src, src + cnt);
- _wpos += cnt;
+ if (_storage.size() < newSize)
+ _storage.resize(newSize);
+ std::memcpy(&_storage[_wpos], src, cnt);
+ _wpos = newSize;
}
void ByteBuffer::AppendPackedTime(time_t time)
@@ -87,7 +102,7 @@ void ByteBuffer::AppendPackedTime(time_t time)
append<uint32>((lt.tm_year - 100) << 24 | lt.tm_mon << 20 | (lt.tm_mday - 1) << 14 | lt.tm_wday << 11 | lt.tm_hour << 6 | lt.tm_min);
}
-void ByteBuffer::put(size_t pos, const uint8 *src, size_t cnt)
+void ByteBuffer::put(size_t pos, uint8 const* src, size_t cnt)
{
ASSERT(pos + cnt <= size(), "Attempted to put value with size: " SZFMTD " in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", cnt, pos, size());
ASSERT(src, "Attempted to put a NULL-pointer in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", pos, size());
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 13d77b41c14..36cb0f5f970 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -563,9 +563,9 @@ class TC_SHARED_API ByteBuffer
return append((const uint8 *)src, cnt * sizeof(T));
}
- void append(const uint8 *src, size_t cnt);
+ void append(uint8 const* src, size_t cnt);
- void append(const ByteBuffer& buffer)
+ void append(ByteBuffer const& buffer)
{
if (!buffer.empty())
append(buffer.contents(), buffer.size());
@@ -622,7 +622,7 @@ class TC_SHARED_API ByteBuffer
void AppendPackedTime(time_t time);
- void put(size_t pos, const uint8 *src, size_t cnt);
+ void put(size_t pos, uint8 const* src, size_t cnt);
void print_storage() const;
diff --git a/src/server/shared/PrecompiledHeaders/sharedPCH.h b/src/server/shared/PrecompiledHeaders/sharedPCH.h
index b2b6b602297..e84a3795df8 100644
--- a/src/server/shared/PrecompiledHeaders/sharedPCH.h
+++ b/src/server/shared/PrecompiledHeaders/sharedPCH.h
@@ -1,3 +1,20 @@
+/*
+ * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
//add here most rarely modified headers to speed up debug build compilation
#include "Common.h"