Skip to content

Commit

Permalink
known alts (#7336)
Browse files Browse the repository at this point in the history
admins can now mark players as having "known alts", which do not flag in
connection history

:cl:
admin: you can add "known alts" to players, now
/:cl:

---------

Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com>
  • Loading branch information
harryob and Drulikar authored Nov 3, 2024
1 parent 2c95e49 commit 1feef15
Showing 3 changed files with 132 additions and 12 deletions.
124 changes: 124 additions & 0 deletions code/datums/entities/player_sticky_ban.dm
Original file line number Diff line number Diff line change
@@ -131,3 +131,127 @@ BSQL_PROTECT_DATUM(/datum/entity/stickyban)
"ip",
"linked_stickyban",
)

/// Returns either a list containing the primary CKEYs this alt is connected to,
/// or FALSE.
/proc/get_player_is_alt(ckey)
var/list/datum/view_record/known_alt/alts = DB_VIEW(/datum/view_record/known_alt, DB_COMP("ckey", DB_EQUALS, ckey))
if(!length(alts))
return FALSE

var/ckeys = list()
for(var/datum/view_record/known_alt/alt as anything in alts)
ckeys += alt.player_ckey

return ckeys

/client/proc/add_known_alt()
set name = "Add Known Alt"
set category = "Admin.Alt"

var/player_ckey = ckey(tgui_input_text(src, "What is the player's primary Ckey?", "Player Ckey"))
if(!player_ckey)
return

var/datum/entity/player/player = get_player_from_key(player_ckey)
if(!istype(player))
return

var/existing_alts = get_player_is_alt(player_ckey)
if(existing_alts)
var/confirm = tgui_alert(src, "Primary Ckey [player_ckey] is already an alt for [english_list(existing_alts)].", "Primary Ckey", list("Confirm", "Cancel"))

if(confirm != "Confirm")
return

var/whitelist_to_add = ckey(tgui_input_text(src, "What is the Ckey that should be added to known alts?", "Alt Ckey"))
if(!whitelist_to_add)
return

var/alts_existing_primaries = get_player_is_alt(whitelist_to_add)
if(alts_existing_primaries)
if(player_ckey in alts_existing_primaries)
to_chat(src, SPAN_WARNING("The alt '[whitelist_to_add]' is already set as an alt Ckey for '[player_ckey]'."))
return

var/confirm = tgui_alert(src, "Alt is already an alt for [english_list(alts_existing_primaries)].", "Alt Ckey", list("Confirm", "Cancel"))

if(confirm != "Confirm")
return

var/datum/entity/known_alt/alt = DB_ENTITY(/datum/entity/known_alt)
alt.player_id = player.id
alt.player_ckey = player.ckey
alt.ckey = whitelist_to_add

alt.save()

to_chat(src, SPAN_NOTICE("[alt.ckey] added to the known alts of [player.ckey]."))

/client/proc/remove_known_alt()
set name = "Remove Known Alt"
set category = "Admin.Alt"

var/player_ckey = ckey(tgui_input_text(src, "What is the player's primary Ckey?", "Player Ckey"))
if(!player_ckey)
return

var/datum/entity/player/player = get_player_from_key(player_ckey)
if(!istype(player))
return

var/existing_alts = get_player_is_alt(player_ckey)
if(existing_alts)
var/confirm = tgui_alert(src, "Primary Ckey [player_ckey] is already an alt for [english_list(existing_alts)].", "Primary Ckey", list("Confirm", "Cancel"))

if(confirm != "Confirm")
return

var/list/datum/view_record/known_alt/alts = DB_VIEW(/datum/view_record/known_alt, DB_COMP("player_id", DB_EQUALS, player.id))
if(!length(alts))
to_chat(src, SPAN_WARNING("User has no alts on record."))
return

var/options = list()
for(var/datum/view_record/known_alt/alt in alts)
options[alt.ckey] = alt.id

var/picked = tgui_input_list(src, "Which known alt should be removed?", "Alt Removal", options)
if(!picked)
return

var/picked_id = options[picked]
var/datum/entity/known_alt/to_delete = DB_ENTITY(/datum/entity/known_alt, picked_id)
to_delete.delete()

to_chat(src, SPAN_NOTICE("[picked] removed from the known alts of [player.ckey]."))

/datum/entity/known_alt
var/player_id
var/player_ckey
var/ckey

/datum/entity_meta/known_alt
entity_type = /datum/entity/known_alt
table_name = "known_alts"
field_types = list(
"player_id" = DB_FIELDTYPE_BIGINT,
"player_ckey" = DB_FIELDTYPE_STRING_LARGE,
"ckey" = DB_FIELDTYPE_STRING_LARGE,
)

/datum/view_record/known_alt
var/id
var/player_id
var/player_ckey
var/ckey

/datum/entity_view_meta/known_alt
root_record_type = /datum/entity/known_alt
destination_entity = /datum/view_record/known_alt
fields = list(
"id",
"player_id",
"player_ckey",
"ckey",
)
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
@@ -74,6 +74,8 @@ GLOBAL_LIST_INIT(admin_verbs_default, list(
/client/proc/cmd_admin_tacmaps_panel,
/client/proc/other_records,
/client/proc/toggle_admin_afk_safety,
/client/proc/add_known_alt,
/client/proc/remove_known_alt,
/client/proc/toogle_door_control,
))

18 changes: 6 additions & 12 deletions code/modules/tgui_panel/telemetry.dm
Original file line number Diff line number Diff line change
@@ -65,16 +65,9 @@
if (!ckey)
return

/*
var/list/all_known_alts = GLOB.known_alts.load_known_alts()
var/list/our_known_alts = list()
for (var/known_alt in all_known_alts)
if (known_alt[1] == ckey)
our_known_alts += known_alt[2]
else if (known_alt[2] == ckey)
our_known_alts += known_alt[1]
*/
var/list/known_alts = list()
for(var/datum/view_record/known_alt/alts in DB_VIEW(/datum/view_record/known_alt, DB_COMP("player_ckey", DB_EQUALS, ckey)))
known_alts += alts.ckey

var/list/found

@@ -98,10 +91,11 @@
"address" = row["address"],
"computer_id" = row["computer_id"],
))
*/

if (row["ckey"] in our_known_alts)
if (row["ckey"] in known_alts)
continue
*/


if (world.IsBanned(row["ckey"], row["address"], row["computer_id"], real_bans_only = TRUE, is_telemetry = TRUE))
found = row

0 comments on commit 1feef15

Please sign in to comment.