mirror of
https://github.com/arthurdead/proxysend.git
synced 2025-12-06 18:08:22 +00:00
support c++14
This commit is contained in:
parent
ef14a08559
commit
849fc94958
@ -173,13 +173,11 @@ class ExtensionConfig(object):
|
|||||||
'-Wno-unused',
|
'-Wno-unused',
|
||||||
'-Wno-switch',
|
'-Wno-switch',
|
||||||
'-Wno-array-bounds',
|
'-Wno-array-bounds',
|
||||||
'-Wno-register',
|
|
||||||
'-msse',
|
'-msse',
|
||||||
'-m32',
|
'-m32',
|
||||||
'-fvisibility=hidden',
|
'-fvisibility=hidden',
|
||||||
]
|
]
|
||||||
cxx.cxxflags += [
|
cxx.cxxflags += [
|
||||||
'-std=gnu++2a',
|
|
||||||
'-fno-exceptions',
|
'-fno-exceptions',
|
||||||
'-fno-threadsafe-statics',
|
'-fno-threadsafe-statics',
|
||||||
'-Wno-non-virtual-dtor',
|
'-Wno-non-virtual-dtor',
|
||||||
@ -188,6 +186,11 @@ class ExtensionConfig(object):
|
|||||||
]
|
]
|
||||||
cxx.linkflags += ['-m32']
|
cxx.linkflags += ['-m32']
|
||||||
|
|
||||||
|
if cxx.version >= 'clang-5':
|
||||||
|
cxx.cxxflags += ['-Wno-register','-std=c++17']
|
||||||
|
else:
|
||||||
|
cxx.cxxflags += ['-std=c++14']
|
||||||
|
|
||||||
have_gcc = cxx.vendor == 'gcc'
|
have_gcc = cxx.vendor == 'gcc'
|
||||||
have_clang = cxx.vendor == 'clang'
|
have_clang = cxx.vendor == 'clang'
|
||||||
if cxx.version >= 'clang-3.6':
|
if cxx.version >= 'clang-3.6':
|
||||||
|
|||||||
@ -388,7 +388,7 @@ template <typename T>
|
|||||||
class thread_var_base
|
class thread_var_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
using ptr_ret_t = std::conditional_t<std::is_pointer_v<T>, T, T *>;
|
using ptr_ret_t = std::conditional_t<std::is_pointer<T>::value, T, T *>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline void reset(std::nullptr_t) noexcept
|
inline void reset(std::nullptr_t) noexcept
|
||||||
@ -405,7 +405,9 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_var_base() noexcept = default;
|
inline thread_var_base() noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline bool operator!() const noexcept;
|
inline bool operator!() const noexcept;
|
||||||
|
|
||||||
@ -442,9 +444,12 @@ protected:
|
|||||||
if(!ptr) {
|
if(!ptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if constexpr(std::is_pointer_v<T>) {
|
if constexpr(std::is_pointer_v<T>) {
|
||||||
return *ptr;
|
return *ptr;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,6 +537,11 @@ public:
|
|||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline thread_var() noexcept
|
||||||
|
: thread_var_base<T>{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline thread_var(const T &val) noexcept
|
inline thread_var(const T &val) noexcept
|
||||||
{ *this->get_or_allocate_ptr() = val; }
|
{ *this->get_or_allocate_ptr() = val; }
|
||||||
|
|
||||||
@ -584,6 +594,11 @@ public:
|
|||||||
using thread_var_base<bool>::thread_var_base;
|
using thread_var_base<bool>::thread_var_base;
|
||||||
using thread_var_base<bool>::reset;
|
using thread_var_base<bool>::reset;
|
||||||
|
|
||||||
|
inline thread_var()
|
||||||
|
: thread_var_base<bool>{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline bool operator*() const noexcept
|
inline bool operator*() const noexcept
|
||||||
{ return get(); }
|
{ return get(); }
|
||||||
|
|
||||||
@ -723,7 +738,8 @@ struct prop_reference_t
|
|||||||
{
|
{
|
||||||
restores_t::iterator it_restore{restores.find(pProp)};
|
restores_t::iterator it_restore{restores.find(pProp)};
|
||||||
if(it_restore == restores.end()) {
|
if(it_restore == restores.end()) {
|
||||||
it_restore = restores.emplace(std::pair<SendProp *, std::unique_ptr<proxyrestore_t>>{pProp, new proxyrestore_t{pProp, type}}).first;
|
std::unique_ptr<proxyrestore_t> ptr{new proxyrestore_t{pProp, type}};
|
||||||
|
it_restore = restores.emplace(std::pair<SendProp *, std::unique_ptr<proxyrestore_t>>{pProp, std::move(ptr)}).first;
|
||||||
}
|
}
|
||||||
restore = it_restore->second.get();
|
restore = it_restore->second.get();
|
||||||
++restore->ref;
|
++restore->ref;
|
||||||
@ -1312,7 +1328,8 @@ DETOUR_DECL_STATIC6(SendTable_Encode, bool, const SendTable *, pTable, const voi
|
|||||||
const std::size_t slots_size{packentity_params->slots.size()};
|
const std::size_t slots_size{packentity_params->slots.size()};
|
||||||
for(int i{0}; i < slots_size; ++i) {
|
for(int i{0}; i < slots_size; ++i) {
|
||||||
std::vector<packed_entity_data_t> &vec{packentity_params->entity_data[i]};
|
std::vector<packed_entity_data_t> &vec{packentity_params->entity_data[i]};
|
||||||
packed_entity_data_t &packedData{vec.emplace_back()};
|
vec.emplace_back();
|
||||||
|
packed_entity_data_t &packedData{vec.back()};
|
||||||
|
|
||||||
packedData.ref = ref;
|
packedData.ref = ref;
|
||||||
packedData.allocate();
|
packedData.allocate();
|
||||||
@ -1349,10 +1366,11 @@ DETOUR_DECL_STATIC8(SendTable_CalcDelta, int, const SendTable *, pTable, const v
|
|||||||
|
|
||||||
const std::size_t slots_size{packentity_params->slots.size()};
|
const std::size_t slots_size{packentity_params->slots.size()};
|
||||||
for(int i{0}; i < slots_size; ++i) {
|
for(int i{0}; i < slots_size; ++i) {
|
||||||
std::vector<packed_entity_data_t> &entity_data{packentity_params->entity_data[i]};
|
using entity_data_t = std::vector<packed_entity_data_t>;
|
||||||
|
entity_data_t &entity_data{packentity_params->entity_data[i]};
|
||||||
|
|
||||||
packed_entity_data_t *packedData{nullptr};
|
packed_entity_data_t *packedData{nullptr};
|
||||||
for(auto it{entity_data.rbegin()}; it != entity_data.rend(); ++it) {
|
for(entity_data_t::reverse_iterator it{entity_data.rbegin()}; it != entity_data.rend(); ++it) {
|
||||||
if(it->ref == gamehelpers->IndexToReference(objectID)) {
|
if(it->ref == gamehelpers->IndexToReference(objectID)) {
|
||||||
packedData = &*it;
|
packedData = &*it;
|
||||||
break;
|
break;
|
||||||
@ -1681,7 +1699,7 @@ bool Sample::add_listener(const parallel_pack_listener *ptr) noexcept
|
|||||||
|
|
||||||
bool Sample::remove_listener(const parallel_pack_listener *ptr) noexcept
|
bool Sample::remove_listener(const parallel_pack_listener *ptr) noexcept
|
||||||
{
|
{
|
||||||
auto it{std::find(pack_ent_listeners.cbegin(), pack_ent_listeners.cend(), ptr)};
|
pack_ent_listeners_t::const_iterator it{std::find(pack_ent_listeners.cbegin(), pack_ent_listeners.cend(), ptr)};
|
||||||
if(it == pack_ent_listeners.cend()) {
|
if(it == pack_ent_listeners.cend()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1812,11 +1830,13 @@ static bool UTIL_FindInSendTable(SendTable *pTable,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unordered_map<ServerClass *, std::unordered_map<std::string, sm_sendprop_info_ex_t>> propinfos;
|
using propinfo_t = std::unordered_map<std::string, sm_sendprop_info_ex_t>;
|
||||||
|
using propinfos_t = std::unordered_map<ServerClass *, propinfo_t>;
|
||||||
|
static propinfos_t propinfos;
|
||||||
|
|
||||||
bool Sample::remove_serverclass_from_cache(ServerClass *pClass) noexcept
|
bool Sample::remove_serverclass_from_cache(ServerClass *pClass) noexcept
|
||||||
{
|
{
|
||||||
auto it_props{propinfos.find(pClass)};
|
propinfos_t::iterator it_props{propinfos.find(pClass)};
|
||||||
if(it_props == propinfos.cend()) {
|
if(it_props == propinfos.cend()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1827,12 +1847,12 @@ bool Sample::remove_serverclass_from_cache(ServerClass *pClass) noexcept
|
|||||||
|
|
||||||
static bool FindSendPropInfo(ServerClass *pClass, std::string &&name, sm_sendprop_info_ex_t *info) noexcept
|
static bool FindSendPropInfo(ServerClass *pClass, std::string &&name, sm_sendprop_info_ex_t *info) noexcept
|
||||||
{
|
{
|
||||||
auto it_props{propinfos.find(pClass)};
|
propinfos_t::iterator it_props{propinfos.find(pClass)};
|
||||||
if(it_props == propinfos.cend()) {
|
if(it_props == propinfos.cend()) {
|
||||||
it_props = propinfos.emplace(std::pair<ServerClass *, std::unordered_map<std::string, sm_sendprop_info_ex_t>>{pClass, {}}).first;
|
it_props = propinfos.emplace(std::pair<ServerClass *, propinfo_t>{pClass, propinfo_t{}}).first;
|
||||||
}
|
}
|
||||||
if(it_props != propinfos.cend()) {
|
if(it_props != propinfos.cend()) {
|
||||||
auto it_prop{it_props->second.find(name)};
|
propinfo_t::iterator it_prop{it_props->second.find(name)};
|
||||||
if(it_prop == it_props->second.cend()) {
|
if(it_prop == it_props->second.cend()) {
|
||||||
if(UTIL_FindInSendTable(pClass->m_pTable, name.c_str(), info, 0)) {
|
if(UTIL_FindInSendTable(pClass->m_pTable, name.c_str(), info, 0)) {
|
||||||
it_prop = it_props->second.emplace(std::pair<std::string, sm_sendprop_info_ex_t>{std::move(name), std::move(*info)}).first;
|
it_prop = it_props->second.emplace(std::pair<std::string, sm_sendprop_info_ex_t>{std::move(name), std::move(*info)}).first;
|
||||||
|
|||||||
@ -48,7 +48,8 @@
|
|||||||
class Sample final : public SDKExtension, public IPluginsListener, public ISMEntityListener, public IConCommandBaseAccessor, public proxysend
|
class Sample final : public SDKExtension, public IPluginsListener, public ISMEntityListener, public IConCommandBaseAccessor, public proxysend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<const parallel_pack_listener *> pack_ent_listeners;
|
using pack_ent_listeners_t = std::vector<const parallel_pack_listener *>;
|
||||||
|
pack_ent_listeners_t pack_ent_listeners;
|
||||||
|
|
||||||
bool add_listener(const parallel_pack_listener *ptr) noexcept override final;
|
bool add_listener(const parallel_pack_listener *ptr) noexcept override final;
|
||||||
bool remove_listener(const parallel_pack_listener *ptr) noexcept override final;
|
bool remove_listener(const parallel_pack_listener *ptr) noexcept override final;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user