Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: exploit records for uplink and pick darkness for ghosts #3909

Merged
merged 21 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SQL/paradise_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ CREATE TABLE `characters` (
`med_record` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`sec_record` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`gen_record` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exploit_record` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`disabilities` mediumint(8) NOT NULL,
`player_alt_titles` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`organ_data` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
Expand Down Expand Up @@ -288,6 +289,7 @@ CREATE TABLE `player` (
`discord_name` varchar(32) NULL DEFAULT NULL,
`keybindings` longtext COLLATE 'utf8mb4_unicode_ci' DEFAULT NULL,
`viewrange` VARCHAR(5) NOT NULL DEFAULT '17x15' COLLATE 'utf8mb4_general_ci',
`ghost_darkness_level` tinyint(1) UNSIGNED NOT NULL DEFAULT '255',
PRIMARY KEY (`id`),
UNIQUE KEY `ckey` (`ckey`),
KEY `lastseen` (`lastseen`),
Expand Down
5 changes: 5 additions & 0 deletions SQL/updates/31-32.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add exploit records
ALTER TABLE `characters`
ADD COLUMN `exploit_record` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER `gen_record`;
# Adds support for persistent ghost darkness
ALTER TABLE `player` ADD COLUMN `ghost_darkness_level` tinyint(1) UNSIGNED NOT NULL DEFAULT '255'
2 changes: 1 addition & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
#define EXPLOSION_BLOCK_PROC -1

// The SQL version required by this version of the code
#define SQL_VERSION 31
#define SQL_VERSION 32

// Vending machine stuff
#define CAT_NORMAL 1
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/ghost.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/mob/dead/observer/create_mob_hud()
if(client && !hud_used)
hud_used = new /datum/hud/ghost(src)
SEND_SIGNAL(src, COMSIG_MOB_HUD_CREATED)

/obj/screen/ghost
icon = 'icons/mob/screen_ghost.dmi'
Expand Down
4 changes: 4 additions & 0 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ GLOBAL_VAR_INIT(record_id_num, 1001)
G.fields["notes"] = H.gen_record
else
G.fields["notes"] = "No notes found."
if(H.exploit_record && !jobban_isbanned(H, "Records"))
G.fields["exploit_record"] = H.exploit_record
else
G.fields["exploit_record"] = "No notes found."
general += G

//Medical Record
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/devices/uplinks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ GLOBAL_LIST_EMPTY(world_uplinks)
"age" = html_encode(L.fields["age"]),
"species" = html_encode(L.fields["species"]),
"rank" = html_encode(L.fields["rank"]),
"fingerprint" = html_encode(L.fields["fingerprint"])
"fingerprint" = html_encode(L.fields["fingerprint"]),
"exploit_record" = html_encode(L.fields["exploit_record"]),
))

data["exploitable"] = exploitable
Expand Down
35 changes: 32 additions & 3 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/med_record = ""
var/sec_record = ""
var/gen_record = ""
var/exploit_record = ""
var/disabilities = 0

var/nanotrasen_relation = "Neutral"
Expand Down Expand Up @@ -245,6 +246,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/list/keybindings_overrides = null
/// View range preference for this client
var/viewrange = DEFAULT_CLIENT_VIEWSIZE
/// How dark things are if client is a ghost, 0-255
var/ghost_darkness_level = LIGHTING_PLANE_ALPHA_VISIBLE

/// Minigames notification about their end, start and etc.
var/minigames_notifications = TRUE
Expand Down Expand Up @@ -921,6 +924,15 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
parent?.update_active_keybindings()
return keybindings

/datum/preferences/proc/null_longtextfix(raw)
var/text
if(raw)
try
text = raw
catch
text = ""
return text

/datum/preferences/proc/capture_keybinding(mob/user, datum/keybinding/KB, old)
var/HTML = {"
<div id='focus' style="outline: 0;" tabindex=0>Keybinding: [KB.name]<br><br><b>Press any key to change<br>Press ESC to clear</b></div>
Expand Down Expand Up @@ -1104,11 +1116,18 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
HTML += "<br><a href=\"byond://?_src_=prefs;preference=records;task=sec_record\">Security Records</a><br>"

if(length(sec_record) <= 40)
HTML += "[sec_record]<br>"
HTML += "[sec_record]"
else
HTML += "[copytext_char(sec_record, 1, 37)]..."

HTML += "<br><a href=\"byond://?_src_=prefs;preference=records;task=exploit_record\">Exploitable Records</a><br>"

if(length(exploit_record) <= 40)
HTML += "[exploit_record]"
else
HTML += "[copytext_char(sec_record, 1, 37)]...<br>"
HTML += "[copytext_char(exploit_record, 1, 37)]..."

HTML += "<a href=\"byond://?_src_=prefs;preference=records;records=-1\">\[Done\]</a>"
HTML += "<br><br><a href=\"byond://?_src_=prefs;preference=records;records=-1\">\[Done\]</a>"
HTML += "</center></tt>"

var/datum/browser/popup = new(user, "records", "<div align='center'>Character Records</div>", 350, 300)
Expand Down Expand Up @@ -1365,6 +1384,15 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts

gen_record = genmsg
SetRecords(user)
if(href_list["task"] == "exploit_record")
var/expmsg = input(usr,"Set your exploitable notes here. This info is available to traitors only.","Exploitable Records",html_decode(exploit_record)) as message

if(expmsg != null)
expmsg = copytext(expmsg, 1, MAX_PAPER_MESSAGE_LEN)
expmsg = html_encode(expmsg)

exploit_record = expmsg
SetRecords(user)

if(href_list["preference"] == "gear")
if(href_list["toggle_gear"])
Expand Down Expand Up @@ -2596,6 +2624,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
character.med_record = med_record
character.sec_record = sec_record
character.gen_record = gen_record
character.exploit_record = exploit_record

character.change_gender(gender)
character.age = age
Expand Down
53 changes: 33 additions & 20 deletions code/modules/client/preference/preferences_mysql.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
discord_id,
discord_name,
keybindings,
viewrange
viewrange,
ghost_darkness_level
FROM [format_table_name("player")]
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
Expand Down Expand Up @@ -53,6 +54,7 @@
discord_name = query.item[18]
keybindings = init_keybindings(raw = query.item[19])
viewrange = query.item[20]
ghost_darkness_level = query.item[21]

qdel(query)

Expand Down Expand Up @@ -105,7 +107,8 @@
clientfps=:clientfps,
parallax=:parallax,
keybindings=:keybindings,
viewrange=:viewrange
viewrange=:viewrange,
ghost_darkness_level=:ghost_darkness_level
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
Expand All @@ -125,7 +128,8 @@
"parallax" = parallax,
"keybindings" = json_encode(keybindings_overrides),
"viewrange" = viewrange,
"ckey" = C.ckey
"ghost_darkness_level" = ghost_darkness_level,
"ckey" = C.ckey,
)
)

Expand Down Expand Up @@ -202,6 +206,7 @@
med_record,
sec_record,
gen_record,
exploit_record,
disabilities,
player_alt_titles,
organ_data,
Expand Down Expand Up @@ -279,6 +284,7 @@
med_record = query.item[42]
sec_record = query.item[43]
gen_record = query.item[44]
exploit_record = null_longtextfix(query.item[45])
// Apparently, the preceding vars weren't always encoded properly...
if(findtext(flavor_text, "<")) // ... so let's clumsily check for tags!
flavor_text = html_encode(flavor_text)
Expand All @@ -288,31 +294,33 @@
sec_record = html_encode(sec_record)
if(findtext(gen_record, "<"))
gen_record = html_encode(gen_record)
disabilities = text2num(query.item[45])
player_alt_titles = params2list(query.item[46])
organ_data = params2list(query.item[47])
rlimb_data = params2list(query.item[48])
nanotrasen_relation = query.item[49]
speciesprefs = text2num(query.item[50])
if(findtext(exploit_record, "<"))
exploit_record = html_encode(exploit_record)
disabilities = text2num(query.item[46])
player_alt_titles = params2list(query.item[47])
organ_data = params2list(query.item[48])
rlimb_data = params2list(query.item[49])
nanotrasen_relation = query.item[50]
speciesprefs = text2num(query.item[51])

//socks
socks = query.item[51]
body_accessory = query.item[52]
loadout_gear = params2list(query.item[53])
autohiss_mode = text2num(query.item[54])
uplink_pref = query.item[55]
socks = query.item[52]
body_accessory = query.item[53]
loadout_gear = params2list(query.item[54])
autohiss_mode = text2num(query.item[55])
uplink_pref = query.item[56]

// TTS
tts_seed = query.item[56]
tts_seed = query.item[57]

//Emotes
custom_emotes_tmp = query.item[57]
custom_emotes_tmp = query.item[58]

// Gradient
h_grad_style = query.item[58]
h_grad_offset_x = query.item[59] // parsed down below
h_grad_colour = query.item[60]
h_grad_alpha = query.item[61]
h_grad_style = query.item[59]
h_grad_offset_x = query.item[60] // parsed down below
h_grad_colour = query.item[61]
h_grad_alpha = query.item[62]

saved = TRUE

Expand Down Expand Up @@ -472,6 +480,7 @@
med_record=:med_record,
sec_record=:sec_record,
gen_record=:gen_record,
exploit_record=:exploit_record,
player_alt_titles=:playertitlelist,
disabilities=:disabilities,
organ_data=:organlist,
Expand Down Expand Up @@ -536,6 +545,7 @@
"med_record" = med_record,
"sec_record" = sec_record,
"gen_record" = gen_record,
"exploit_record" = exploit_record,
"playertitlelist" = (playertitlelist ? playertitlelist : ""), // This it intentnional. It wont work without it!
"disabilities" = disabilities,
"organlist" = (organlist ? organlist : ""),
Expand Down Expand Up @@ -592,6 +602,7 @@
med_record,
sec_record,
gen_record,
exploit_record,
player_alt_titles,
disabilities, organ_data, rlimb_data, nanotrasen_relation, speciesprefs,
socks, body_accessory, gear, autohiss, hair_gradient, hair_gradient_offset, hair_gradient_colour, hair_gradient_alpha, uplink_pref, tts_seed, custom_emotes)
Expand Down Expand Up @@ -620,6 +631,7 @@
:med_record,
:sec_record,
:gen_record,
:exploit_record,
:playertitlelist,
:disabilities, :organlist, :rlimblist, :nanotrasen_relation, :speciesprefs,
:socks, :body_accessory, :gearlist, :autohiss_mode, :h_grad_style, :h_grad_offset, :h_grad_colour, :h_grad_alpha, :uplink_pref, :tts_seed, :custom_emotes)
Expand Down Expand Up @@ -672,6 +684,7 @@
"med_record" = med_record,
"sec_record" = sec_record,
"gen_record" = gen_record,
"exploit_record" = exploit_record,
"playertitlelist" = (playertitlelist ? playertitlelist : ""), // This it intentnional. It wont work without it!
"disabilities" = disabilities,
"organlist" = (organlist ? organlist : ""),
Expand Down
37 changes: 25 additions & 12 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
//starts ghosts off with all HUDs.
show_me_the_hud(THOUGHTS_HUD)
toggle_all_huds_on(body)
RegisterSignal(src, COMSIG_MOB_HUD_CREATED, PROC_REF(set_ghost_darkness_level)) //something something don't call this until we have a HUD
..()


/mob/dead/observer/Destroy()
toggle_all_huds_off()
UnregisterSignal(src, COMSIG_MOB_HUD_CREATED)
if(ghostimage)
GLOB.ghost_images -= ghostimage
QDEL_NULL(ghostimage)
Expand All @@ -114,6 +116,14 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(!invisibility)
. += "<span class='notice'>It seems extremely obvious.</span>"

/mob/dead/observer/proc/set_ghost_darkness_level()
if(!client)
return
UnregisterSignal(src, COMSIG_MOB_HUD_CREATED)
lighting_alpha = client.prefs.ghost_darkness_level //Remembers ghost lighting pref
update_sight()


// This seems stupid, but it's the easiest way to avoid absolutely ridiculous shit from happening
// Copying an appearance directly from a mob includes it's verb list, it's invisibility, it's alpha, and it's density
// You might recognize these things as "fucking ridiculous to put in an appearance"
Expand Down Expand Up @@ -605,19 +615,22 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
update_sight()
to_chat(usr, "You [(ghostvision?"now":"no longer")] have ghost vision.")

/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
/mob/dead/observer/verb/pick_darkness()
set name = "Pick Darkness"
set desc = "Choose how much darkness you want to see."
set category = "Ghost"
switch(lighting_alpha)
if (LIGHTING_PLANE_ALPHA_VISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE
if (LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE
if (LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_INVISIBLE
else
lighting_alpha = LIGHTING_PLANE_ALPHA_VISIBLE

var/list/ghost_darkness_levels = list("Strong Darkness" = LIGHTING_PLANE_ALPHA_VISIBLE,
"Darkness" = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE,
"Light Darkness" = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE,
"No Darkness" = LIGHTING_PLANE_ALPHA_INVISIBLE)
var/desired_dark = tgui_input_list(usr, "Choose how much darkness you want to see", "Pick darkness", ghost_darkness_levels)
if(isnull(desired_dark))
return
if(!client)
return
client.prefs.ghost_darkness_level = ghost_darkness_levels[desired_dark]
client.prefs.save_preferences(src)
lighting_alpha = client.prefs.ghost_darkness_level
update_sight()

/mob/dead/observer/update_sight()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
var/med_record = ""
var/sec_record = ""
var/gen_record = ""
var/exploit_record = ""
var/lying = 0
var/lying_prev = 0
var/lastpuke = 0
Expand Down
2 changes: 1 addition & 1 deletion config/example/dbconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## This value must be set to the version of the paradise schema in use.
## If this value does not match, the SQL database will not be loaded and an error will be generated.
## Roundstart will be delayed.
DB_VERSION 31
DB_VERSION 32

## Server the MySQL database can be found at.
# Examples: localhost, 200.135.5.43, www.mysqldb.com, etc.
Expand Down
3 changes: 3 additions & 0 deletions tgui/packages/tgui/interfaces/Uplink.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ const ExploitableInfoPage = (_properties, context) => {
<Box>Sex: {selectedRecord.sex}</Box>
<Box>Species: {selectedRecord.species}</Box>
</Section>
<Section title={"Exploitable Records"}>
<Box prewrap>{selectedRecord.exploit_record}</Box>
</Section>
</Flex.Item>
</Flex>
</Section>
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tools/ci/dbconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Dont use it ingame
# Remember to update this when you increase the SQL version! -aa
SQL_ENABLED
DB_VERSION 31
DB_VERSION 32
ADDRESS 127.0.0.1
PORT 3306
FEEDBACK_DATABASE feedback
Expand Down
Loading