mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 12:08:55 +01:00
[MIRROR] Fixes a minor client disconnection runtime (#7567)
* Fixes a minor client disconnection runtime * Update sql_ban_system.dm Co-authored-by: Rohesie <rohesie@gmail.com> Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
co-authored by
Rohesie
Gandalf
parent
d4e11d2080
commit
b9ca4fb280
@@ -6,15 +6,16 @@
|
||||
/proc/is_banned_from(player_ckey, list/roles)
|
||||
if(!player_ckey)
|
||||
return
|
||||
var/client/C = GLOB.directory[player_ckey]
|
||||
if(C)
|
||||
if(!C.ban_cache)
|
||||
build_ban_cache(C)
|
||||
var/client/player_client = GLOB.directory[player_ckey]
|
||||
if(player_client)
|
||||
var/list/ban_cache = player_client.ban_cache || build_ban_cache(player_client)
|
||||
if(!islist(ban_cache))
|
||||
return // Disconnected while building the list.
|
||||
if(islist(roles))
|
||||
for(var/R in roles)
|
||||
if(R in C.ban_cache)
|
||||
for(var/role in roles)
|
||||
if(role in ban_cache)
|
||||
return TRUE //they're banned from at least one role, no need to keep checking
|
||||
else if(roles in C.ban_cache)
|
||||
else if(roles in ban_cache)
|
||||
return TRUE
|
||||
else
|
||||
var/values = list(
|
||||
@@ -96,32 +97,40 @@
|
||||
. += list(list("id" = query_check_ban.item[1], "bantime" = query_check_ban.item[2], "round_id" = query_check_ban.item[3], "expiration_time" = query_check_ban.item[4], "duration" = query_check_ban.item[5], "applies_to_admins" = query_check_ban.item[6], "reason" = query_check_ban.item[7], "key" = query_check_ban.item[8], "ip" = query_check_ban.item[9], "computerid" = query_check_ban.item[10], "admin_key" = query_check_ban.item[11]))
|
||||
qdel(query_check_ban)
|
||||
|
||||
/proc/build_ban_cache(client/C)
|
||||
|
||||
/proc/build_ban_cache(client/player_client)
|
||||
if(!SSdbcore.Connect())
|
||||
return
|
||||
if(C && istype(C))
|
||||
C.ban_cache = list()
|
||||
var/is_admin = FALSE
|
||||
if(GLOB.admin_datums[C.ckey] || GLOB.deadmins[C.ckey])
|
||||
is_admin = TRUE
|
||||
var/ssqlname = CONFIG_GET(string/serversqlname) // SKYRAT EDIT ADDITION BEGIN - MULTISERVER
|
||||
var/server_check
|
||||
if(CONFIG_GET(flag/respect_global_bans))
|
||||
server_check = "(server_name = '[ssqlname]' OR global_ban = '1')"
|
||||
else
|
||||
server_check = "server_name = '[ssqlname]'" // SKYRAT EDIT ADDITION END - MULTISERVER
|
||||
var/datum/db_query/query_build_ban_cache = SSdbcore.NewQuery(
|
||||
"SELECT role, applies_to_admins FROM [format_table_name("ban")] WHERE ckey = :ckey AND unbanned_datetime IS NULL AND (expiration_time IS NULL OR expiration_time > NOW()) AND [server_check]", // SKYRAT EDIT CHANGE - MULTISERVER
|
||||
list("ckey" = C.ckey)
|
||||
)
|
||||
if(!query_build_ban_cache.warn_execute())
|
||||
qdel(query_build_ban_cache)
|
||||
return
|
||||
while(query_build_ban_cache.NextRow())
|
||||
if(is_admin && !text2num(query_build_ban_cache.item[2]))
|
||||
continue
|
||||
C.ban_cache[query_build_ban_cache.item[1]] = TRUE
|
||||
if(QDELETED(player_client))
|
||||
return
|
||||
var/ckey = player_client.ckey
|
||||
var/list/ban_cache = list()
|
||||
var/is_admin = FALSE
|
||||
if(GLOB.admin_datums[ckey] || GLOB.deadmins[ckey])
|
||||
is_admin = TRUE
|
||||
var/ssqlname = CONFIG_GET(string/serversqlname) // SKYRAT EDIT ADDITION BEGIN - MULTISERVER
|
||||
var/server_check
|
||||
if(CONFIG_GET(flag/respect_global_bans))
|
||||
server_check = "(server_name = '[ssqlname]' OR global_ban = '1')"
|
||||
else
|
||||
server_check = "server_name = '[ssqlname]'" // SKYRAT EDIT ADDITION END - MULTISERVER
|
||||
var/datum/db_query/query_build_ban_cache = SSdbcore.NewQuery(
|
||||
"SELECT role, applies_to_admins FROM [format_table_name("ban")] WHERE ckey = :ckey AND unbanned_datetime IS NULL AND (expiration_time IS NULL OR expiration_time > NOW())",
|
||||
list("ckey" = ckey)
|
||||
)
|
||||
if(!query_build_ban_cache.warn_execute())
|
||||
qdel(query_build_ban_cache)
|
||||
return
|
||||
while(query_build_ban_cache.NextRow())
|
||||
if(is_admin && !text2num(query_build_ban_cache.item[2]))
|
||||
continue
|
||||
ban_cache[query_build_ban_cache.item[1]] = TRUE
|
||||
qdel(query_build_ban_cache)
|
||||
if(QDELETED(player_client)) // Disconnected while working with the DB.
|
||||
return
|
||||
player_client.ban_cache = ban_cache
|
||||
return ban_cache
|
||||
|
||||
|
||||
/datum/admins/proc/ban_panel(player_key, player_ip, player_cid, role, duration = 1440, applies_to_admins, reason, edit_id, page, admin_key, global_ban) // SKYRAT EDIT CHANGE - MULTISERVER
|
||||
var/panel_height = 620
|
||||
|
||||
Reference in New Issue
Block a user