refractor set_all_protections function (untested)

This commit is contained in:
dynamoNg 2024-08-31 12:09:13 +05:30
parent 7e990bef54
commit 1ba0a643c7

View File

@ -4,8 +4,11 @@ namespace big
{ {
static inline void set_all_protections(bool state) static inline void set_all_protections(bool state)
{ {
for (size_t i = (size_t)&g.protections; i <= (size_t) & (g.protections.kick_rejoin); i++) auto start = reinterpret_cast<bool*>(&g.protections);
*(bool*)i = state; auto end = reinterpret_cast<bool*>(reinterpret_cast<std::byte*>(start) + sizeof(g.protections));
for (auto* i = start; i < end; ++i)
*i = state;
} }
static inline void reset_protections() static inline void reset_protections()