From 04666982d937a1f14fe7fff22aa735afe7563525 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 1 Feb 2020 14:32:16 +0100 Subject: [PATCH] A lot of updates --- src/Definitions.h | 1 + src/PermissionManager.h | 6 ++++-- src/Properties.h | 2 +- src/protocol/ringbuffer.h | 18 ------------------ 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/Definitions.h b/src/Definitions.h index dfad052..d7e0b0e 100644 --- a/src/Definitions.h +++ b/src/Definitions.h @@ -103,6 +103,7 @@ namespace ts { INIT_HIGH, //Web -> Auth CONNECTED, DISCONNECTING, + DISCONNECTING_FLUSHING, DISCONNECTED }; } diff --git a/src/PermissionManager.h b/src/PermissionManager.h index d54538a..4d43de4 100644 --- a/src/PermissionManager.h +++ b/src/PermissionManager.h @@ -18,7 +18,7 @@ #include "spdlog/fmt/ostr.h" // must be included #define permNotGranted (-2) -#define PERM_ID_GRANT ((ts::permission::PermissionType) (1 << 15)) +#define PERM_ID_GRANT ((ts::permission::PermissionType) (1U << 15U)) namespace ts { class BasicChannel; @@ -36,6 +36,7 @@ namespace ts { permission_id_min = 0, /* we count unknown as defined permission as well */ unknown = (uint16_t) 0, + ok = 0, type_begin = 1, /* global */ @@ -887,12 +888,13 @@ namespace ts { static constexpr size_t PERMISSIONS_BULK_BLOCK_MASK = (~(1 << PERMISSIONS_BULK_BITS)) & ((1 << PERMISSIONS_BULK_BITS) - 1); bool requires_db_save = false; - ts_always_inline void trigger_db_update() { this->requires_db_save = true; } /* todo: pull some kind of trigger? */ + ts_always_inline void trigger_db_update() { this->requires_db_save = true; } spin_lock block_use_count_lock{}; int16_t block_use_count[BULK_COUNT]; PermissionContainerBulk* block_containers[BULK_COUNT]; + //TODO: Bulk permissions for channels as well, specially because they're client permissions in terms of the music bot! std::shared_mutex channel_list_lock{}; std::deque> _channel_permissions{}; diff --git a/src/Properties.h b/src/Properties.h index 7fd76ec..6744781 100644 --- a/src/Properties.h +++ b/src/Properties.h @@ -699,7 +699,7 @@ namespace ts { this->data_ptr->casted_value = ts::converter::from_string_view(this->data_ptr->value); return std::any_cast(this->data_ptr->casted_value); } catch(std::exception&) { - return 0; + return T{}; } } diff --git a/src/protocol/ringbuffer.h b/src/protocol/ringbuffer.h index 9f41e0a..b592e73 100644 --- a/src/protocol/ringbuffer.h +++ b/src/protocol/ringbuffer.h @@ -208,24 +208,6 @@ namespace ts { public: std::recursive_timed_mutex buffer_lock; std::recursive_timed_mutex execute_lock; - - inline uint16_t generation(uint16_t packet_id) { - size_t relative_index = 0; - if(!this->calculate_index(packet_id, relative_index)) - relative_index = 0; /* okey we dont give a fuck */ - - return ((this->_ring_index_full + relative_index) >> 16) & 0xFFFF; - } - - inline void set_generation(uint16_t value) { - this->_ring_index_full = (value << 16) | (this->_ring_index_full & 0xFFFF); - } - - inline void set_generation_packet(uint16_t generation, uint16_t packet) { - this->_ring_index_full = (generation << 16) | (packet & 0xFFFF); - } - - inline uint64_t full_index() { return this->_ring_index_full; } }; } } \ No newline at end of file