A lot of updates

This commit is contained in:
WolverinDEV 2020-02-01 14:32:16 +01:00
parent a8843f5311
commit 04666982d9
4 changed files with 6 additions and 21 deletions

View File

@ -103,6 +103,7 @@ namespace ts {
INIT_HIGH, //Web -> Auth
CONNECTED,
DISCONNECTING,
DISCONNECTING_FLUSHING,
DISCONNECTED
};
}

View File

@ -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<PERMISSIONS_BULK_ENTRY_COUNT>* 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<std::unique_ptr<ChannelPermissionContainer>> _channel_permissions{};

View File

@ -699,7 +699,7 @@ namespace ts {
this->data_ptr->casted_value = ts::converter<T>::from_string_view(this->data_ptr->value);
return std::any_cast<T>(this->data_ptr->casted_value);
} catch(std::exception&) {
return 0;
return T{};
}
}

View File

@ -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; }
};
}
}