mirror of
https://github.com/edubart/otclient.git
synced 2025-04-29 17:19:20 +02:00
Remove stdext::packed_vector (#1106)
Co-authored-by: Kacper Piwiński <cosiekvfj@o2.pl>
This commit is contained in:
parent
59059321a6
commit
b3aaa10646
@ -132,9 +132,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
void checkTranslucentLight();
|
void checkTranslucentLight();
|
||||||
|
|
||||||
stdext::packed_vector<CreaturePtr> m_walkingCreatures;
|
std::vector<CreaturePtr> m_walkingCreatures;
|
||||||
stdext::packed_vector<EffectPtr> m_effects; // leave this outside m_things because it has no stackpos.
|
std::vector<EffectPtr> m_effects; // leave this outside m_things because it has no stackpos.
|
||||||
stdext::packed_vector<ThingPtr> m_things;
|
std::vector<ThingPtr> m_things;
|
||||||
Position m_position;
|
Position m_position;
|
||||||
uint8 m_drawElevation;
|
uint8 m_drawElevation;
|
||||||
uint8 m_minimapColor;
|
uint8 m_minimapColor;
|
||||||
|
@ -49,7 +49,6 @@ set(framework_SOURCES ${framework_SOURCES}
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/net.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/net.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_any.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_any.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_storage.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_storage.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_vector.h
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/shared_object.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/shared_object.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/shared_ptr.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/shared_ptr.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/stdext/stdext.h
|
${CMAKE_CURRENT_LIST_DIR}/stdext/stdext.h
|
||||||
|
@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010-2020 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_PACKEDVECTOR_H
|
|
||||||
#define STDEXT_PACKEDVECTOR_H
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace stdext {
|
|
||||||
|
|
||||||
// disable memory alignment
|
|
||||||
#pragma pack(push,1)
|
|
||||||
|
|
||||||
template<class T, class U = uint8_t>
|
|
||||||
class packed_vector
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef U size_type;
|
|
||||||
typedef T* iterator;
|
|
||||||
typedef const T* const_iterator;
|
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
packed_vector() : m_size(0), m_data(nullptr) { }
|
|
||||||
packed_vector(size_type size) : m_size(size), m_data(new T[size]) { }
|
|
||||||
packed_vector(size_type size, const T& value) : m_size(size), m_data(new T[size]) { std::fill(begin(), end(), value); }
|
|
||||||
template <class InputIterator>
|
|
||||||
packed_vector(InputIterator first, InputIterator last) : m_size(last - first), m_data(new T[m_size]) { std::copy(first, last, m_data); }
|
|
||||||
packed_vector(const packed_vector<T>& other) : m_size(other.m_size), m_data(new T[other.m_size]) { std::copy(other.begin(), other.end(), m_data); }
|
|
||||||
~packed_vector() { delete[] m_data; }
|
|
||||||
|
|
||||||
packed_vector<T,U>& operator=(packed_vector<T,U> other) { other.swap(*this); return *this; }
|
|
||||||
|
|
||||||
iterator begin() { return m_data; }
|
|
||||||
const_iterator begin() const { return m_data; }
|
|
||||||
const_iterator cbegin() const { return m_data; }
|
|
||||||
iterator end() { return m_data + m_size; }
|
|
||||||
const_iterator end() const { return m_data + m_size; }
|
|
||||||
const_iterator cend() const { return m_data + m_size; }
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
|
||||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
|
||||||
const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
|
||||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
|
||||||
const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
size_type size() const { return m_size; }
|
|
||||||
bool empty() const { return m_size == 0; }
|
|
||||||
|
|
||||||
T& operator[](size_type i) { return m_data[i]; }
|
|
||||||
const T& operator[](size_type i) const { return m_data[i]; }
|
|
||||||
T& at(size_type i) { return m_data[i]; }
|
|
||||||
const T& at(size_type i) const { return m_data[i]; }
|
|
||||||
|
|
||||||
T& front() { return m_data[0]; }
|
|
||||||
const T& front() const { return m_data[0]; }
|
|
||||||
T& back() { return m_data[m_size-1]; }
|
|
||||||
const T& back() const { return m_data[m_size-1]; }
|
|
||||||
|
|
||||||
T *data() { return m_data; }
|
|
||||||
const T *data() const { return m_data; }
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
if(m_data) {
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = nullptr;
|
|
||||||
}
|
|
||||||
m_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resize(size_type size) {
|
|
||||||
clear();
|
|
||||||
if(size > 0) {
|
|
||||||
m_data = new T[size];
|
|
||||||
m_size = size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void push_back(const T& x) {
|
|
||||||
T *tmp = new T[m_size+1];
|
|
||||||
std::copy(m_data, m_data + m_size, tmp);
|
|
||||||
tmp[m_size] = x;
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = tmp;
|
|
||||||
m_size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pop_back() {
|
|
||||||
if(m_size == 1) {
|
|
||||||
clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
T *tmp = new T[m_size-1];
|
|
||||||
std::copy(m_data, m_data + m_size - 1, tmp);
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = tmp;
|
|
||||||
m_size--;
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator insert(const_iterator position, const T& x) {
|
|
||||||
T *tmp = new T[m_size+1];
|
|
||||||
size_type i = position - m_data;
|
|
||||||
std::copy(m_data, m_data + i, tmp);
|
|
||||||
tmp[i] = x;
|
|
||||||
std::copy(m_data + i, m_data + m_size, tmp + i + 1);
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = tmp;
|
|
||||||
m_size++;
|
|
||||||
return tmp + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator erase(const_iterator position) {
|
|
||||||
T *tmp = new T[m_size-1];
|
|
||||||
size_type i = position - m_data;
|
|
||||||
std::copy(m_data, m_data + i, tmp);
|
|
||||||
std::copy(m_data + i + 1, m_data + m_size, tmp + i);
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = tmp;
|
|
||||||
m_size--;
|
|
||||||
return tmp + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(packed_vector<T,U>& other) { std::swap(m_size, other.m_size); std::swap(m_data, other.m_data); }
|
|
||||||
|
|
||||||
operator std::vector<T>() const { return std::vector<T>(begin(), end()); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_type m_size;
|
|
||||||
T* m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
// restore memory alignment
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template<class T, class U> void swap(stdext::packed_vector<T,U>& lhs, stdext::packed_vector<T,U>& rhs) { lhs.swap(rhs); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -35,7 +35,6 @@
|
|||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "packed_any.h"
|
#include "packed_any.h"
|
||||||
#include "packed_storage.h"
|
#include "packed_storage.h"
|
||||||
#include "packed_vector.h"
|
|
||||||
#include "shared_object.h"
|
#include "shared_object.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
@ -436,7 +436,6 @@
|
|||||||
<ClInclude Include="..\src\framework\stdext\net.h" />
|
<ClInclude Include="..\src\framework\stdext\net.h" />
|
||||||
<ClInclude Include="..\src\framework\stdext\packed_any.h" />
|
<ClInclude Include="..\src\framework\stdext\packed_any.h" />
|
||||||
<ClInclude Include="..\src\framework\stdext\packed_storage.h" />
|
<ClInclude Include="..\src\framework\stdext\packed_storage.h" />
|
||||||
<ClInclude Include="..\src\framework\stdext\packed_vector.h" />
|
|
||||||
<ClInclude Include="..\src\framework\stdext\shared_object.h" />
|
<ClInclude Include="..\src\framework\stdext\shared_object.h" />
|
||||||
<ClInclude Include="..\src\framework\stdext\shared_ptr.h" />
|
<ClInclude Include="..\src\framework\stdext\shared_ptr.h" />
|
||||||
<ClInclude Include="..\src\framework\stdext\stdext.h" />
|
<ClInclude Include="..\src\framework\stdext\stdext.h" />
|
||||||
@ -474,4 +473,4 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -833,9 +833,6 @@
|
|||||||
<ClInclude Include="..\src\framework\stdext\packed_storage.h">
|
<ClInclude Include="..\src\framework\stdext\packed_storage.h">
|
||||||
<Filter>Header Files\framework\stdext</Filter>
|
<Filter>Header Files\framework\stdext</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\framework\stdext\packed_vector.h">
|
|
||||||
<Filter>Header Files\framework\stdext</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\framework\stdext\shared_object.h">
|
<ClInclude Include="..\src\framework\stdext\shared_object.h">
|
||||||
<Filter>Header Files\framework\stdext</Filter>
|
<Filter>Header Files\framework\stdext</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user