Merge branch '1.5.0' into new-groups

# Conflicts:
#	server/src/Group.h
#	server/src/InstanceHandler.cpp
#	server/src/InstanceHandler.h
#	server/src/VirtualServer.cpp
#	server/src/client/DataClient.cpp
#	server/src/client/DataClient.h
This commit is contained in:
WolverinDEV
2021-03-01 19:22:15 +01:00
44 changed files with 400 additions and 363 deletions
+11 -11
View File
@@ -38,8 +38,8 @@ SpeakingClient::~SpeakingClient() {
bool SpeakingClient::shouldReceiveVoice(const std::shared_ptr<ConnectedClient> &sender) {
//if(this->properties()[property::CLIENT_AWAY].as<bool>()) return false;
if(!this->properties()[property::CLIENT_OUTPUT_HARDWARE].as<bool>()) return false;
if(this->properties()[property::CLIENT_OUTPUT_MUTED].as<bool>()) return false;
if(!this->properties()[property::CLIENT_OUTPUT_HARDWARE].as_or<bool>(true)) return false;
if(this->properties()[property::CLIENT_OUTPUT_MUTED].as_or<bool>(false)) return false;
{
shared_lock client_lock(this->channel_lock);
@@ -241,7 +241,7 @@ command_result SpeakingClient::handleCommandClientInit(Command& cmd) {
}
if(this->getType() == ClientType::CLIENT_TEAMSPEAK && permission::v2::permission_granted(1, permissions[permission::b_client_enforce_valid_hwid])) {
auto hwid = this->properties()[property::CLIENT_HARDWARE_ID].as<string>();
auto hwid = this->properties()[property::CLIENT_HARDWARE_ID].value();
if(
!std::regex_match(hwid, regex_hwid_windows) &&
!std::regex_match(hwid, regex_hwid_unix) &&
@@ -352,8 +352,8 @@ command_result SpeakingClient::handleCommandClientInit(Command& cmd) {
count++;
}
auto maxClients = this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as<size_t>();
auto reserved = this->server->properties()[property::VIRTUALSERVER_RESERVED_SLOTS].as<size_t>();
auto maxClients = this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0);
auto reserved = this->server->properties()[property::VIRTUALSERVER_RESERVED_SLOTS].as_or<size_t>(0);
bool allowReserved = permission::v2::permission_granted(1, permissions[permission::b_client_use_reserved_slot]);
if(reserved > maxClients){
@@ -364,10 +364,10 @@ command_result SpeakingClient::handleCommandClientInit(Command& cmd) {
TIMING_STEP(timings, "max clients");
auto old_last_connected = this->properties()[property::CLIENT_LASTCONNECTED].as<int64_t>();
auto old_last_connected = this->properties()[property::CLIENT_LASTCONNECTED].as_or<int64_t>(0);
this->properties()[property::CONNECTION_CLIENT_IP] = this->getLoggingPeerIp();
this->properties()[property::CLIENT_LASTCONNECTED] = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
this->properties()[property::CLIENT_TOTALCONNECTIONS]++;
this->properties()[property::CLIENT_TOTALCONNECTIONS].increment_by<uint64_t>(1);
{
auto time_point = system_clock::time_point() + seconds(old_last_connected);
if(time_point < build::version()->timestamp) {
@@ -453,14 +453,14 @@ void SpeakingClient::processJoin() {
}
}
//this->updateChannelClientProperties(false); /* will be already updated via assignChannel */
if(ref_server->properties()[property::VIRTUALSERVER_HOSTMESSAGE_MODE].as<int>() == 3 && !ref_server->properties()[property::VIRTUALSERVER_HOSTMESSAGE].as<string>().empty()) {
if(ref_server->properties()[property::VIRTUALSERVER_HOSTMESSAGE_MODE].as_or<int>(0) == 3 && !ref_server->properties()[property::VIRTUALSERVER_HOSTMESSAGE].value().empty()) {
auto weak = this->_this;
threads::Thread([weak](){
threads::self::sleep_for(milliseconds(2000));
auto client = weak.lock();
if(!client || !client->server) return;
client->disconnect(client->server->properties()[property::VIRTUALSERVER_HOSTMESSAGE].as<string>());
client->disconnect(client->server->properties()[property::VIRTUALSERVER_HOSTMESSAGE].value());
}).detach();
}
@@ -583,13 +583,13 @@ void SpeakingClient::updateSpeak(bool only_update, const std::chrono::system_clo
if(this->speak_last_packet + this->speak_accuracy < now) {
if(this->speak_last_packet > this->speak_begin) {
if(!this->properties()[property::CLIENT_FLAG_TALKING].as<bool>()) {
if(!this->properties()[property::CLIENT_FLAG_TALKING].as_or<bool>(false)) {
this->properties()[property::CLIENT_FLAG_TALKING] = true;
}
this->speak_time += duration_cast<milliseconds>(this->speak_last_packet - this->speak_begin);
} else {
if(this->properties()[property::CLIENT_FLAG_TALKING].as<bool>()) {
if(this->properties()[property::CLIENT_FLAG_TALKING].as_or<bool>(false)) {
this->properties()[property::CLIENT_FLAG_TALKING] = false;
}
}