From 45031eda0b174b5c4fab584846bdbb6d55bda71d Mon Sep 17 00:00:00 2001 From: Volodymir Ohorodnytskyi <102746941+Legendaxe@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:22:56 +0200 Subject: [PATCH] add: Queue implementation (#651) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Что этот PR делает Добавляем промежуточный сервер для очереди Сначала тестим на прайме, когда там не будет людей. ## Почему это хорошо для игры Снижаем нагрузку с сервера ## Изображения изменений ## Тестирование ## Changelog :cl: add: очередь сервер, пока что только для прайма /:cl: --- modular_ss220/modular_ss220.dme | 1 + modular_ss220/queue/_queue.dm | 0 modular_ss220/queue/_queue.dme | 4 +++ modular_ss220/queue/code/new_player_procs.dm | 30 ++++++++++++++++++++ modular_ss220/queue/code/queue_bypass.dm | 17 +++++++++++ 5 files changed, 52 insertions(+) create mode 100644 modular_ss220/queue/_queue.dm create mode 100644 modular_ss220/queue/_queue.dme create mode 100644 modular_ss220/queue/code/new_player_procs.dm create mode 100644 modular_ss220/queue/code/queue_bypass.dm diff --git a/modular_ss220/modular_ss220.dme b/modular_ss220/modular_ss220.dme index ff4752541cbc..4073d4dc2b87 100644 --- a/modular_ss220/modular_ss220.dme +++ b/modular_ss220/modular_ss220.dme @@ -70,6 +70,7 @@ #include "outfits/_outfits.dme" #include "world_view_bigger/_world_view_bigger.dme" #include "mecha_skins/mecha_skins.dme" +#include "queue/_queue.dme" // --- PRIME --- // // #define MODPACK_MAIN_ONLY diff --git a/modular_ss220/queue/_queue.dm b/modular_ss220/queue/_queue.dm new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modular_ss220/queue/_queue.dme b/modular_ss220/queue/_queue.dme new file mode 100644 index 000000000000..4931c496030f --- /dev/null +++ b/modular_ss220/queue/_queue.dme @@ -0,0 +1,4 @@ +#include "_queue.dm" + +#include "code/new_player_procs.dm" +#include "code/queue_bypass.dm" diff --git a/modular_ss220/queue/code/new_player_procs.dm b/modular_ss220/queue/code/new_player_procs.dm new file mode 100644 index 000000000000..7b1c9d1fd20d --- /dev/null +++ b/modular_ss220/queue/code/new_player_procs.dm @@ -0,0 +1,30 @@ +/mob/new_player/Login() + . = ..() + + if(!SSdbcore.IsConnected()) + return + + if(SSqueue.queue_enabled) + if(client?.ckey in SSqueue.queue_bypass_list) + return + + if(client?.holder) + SSqueue.queue_bypass_list |= ckey + return + + if(length(GLOB.clients) < SSqueue.queue_threshold) + SSqueue.queue_bypass_list |= ckey + return + + src << link(GLOB.configuration.overflow.overflow_server_location) + +/mob/new_player/Logout() + . = ..() + + addtimer(CALLBACK(src, PROC_REF(reserve_queue_slot)), 10 MINUTES) + +/mob/new_player/proc/reserve_queue_slot() + if(client?.ckey in GLOB.player_list) + return + + SSqueue.queue_bypass_list.Remove(last_known_ckey) diff --git a/modular_ss220/queue/code/queue_bypass.dm b/modular_ss220/queue/code/queue_bypass.dm new file mode 100644 index 000000000000..0cfa19707ab1 --- /dev/null +++ b/modular_ss220/queue/code/queue_bypass.dm @@ -0,0 +1,17 @@ +/datum/world_topic_handler/queue_bypass + topic_key = "queue_bypass" + requires_commskey = TRUE + +/datum/world_topic_handler/queue_bypass/execute(list/input, key_valid) + var/ckey_check = input["ckey_check"] + + if(!ckey_check) + return json_encode(list("error" = "No ckey supplied")) + + var/list/output_data = list() + output_data["queue_enabled"] = SSqueue.queue_enabled + + if(SSqueue.queue_enabled) + SSqueue.queue_bypass_list |= ckey_check + + return json_encode(output_data)