Skip to content

Commit

Permalink
Revert "Revert "[Needs Testmerge] Guestbook, from Mojave Sun (shiptes…
Browse files Browse the repository at this point in the history
…t-ss13#2770)""

This reverts commit 0f52064.
  • Loading branch information
MysticalFaceLesS committed Apr 20, 2024
1 parent 0f52064 commit ac1fb0e
Show file tree
Hide file tree
Showing 46 changed files with 737 additions and 165 deletions.
34 changes: 22 additions & 12 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,29 @@
#define COMSIG_LIVING_GET_PULLED "living_start_pulled"

/////////////////

#define COMSIG_ENTER_AREA "enter_area" //from base of area/Entered(): (/area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.
#define COMSIG_EXIT_AREA "exit_area" //from base of area/Exited(): (/area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.

#define COMSIG_CLICK "atom_click" //from base of atom/Click(): (location, control, params, mob/user)
#define COMSIG_CLICK_SHIFT "shift_click" //from base of atom/ShiftClick(): (/mob)
#define COMPONENT_ALLOW_EXAMINATE 1 //Allows the user to examinate regardless of client.eye.
#define COMSIG_CLICK_CTRL "ctrl_click" //from base of atom/CtrlClickOn(): (/mob)
#define COMSIG_CLICK_ALT "alt_click" //from base of atom/AltClick(): (/mob)
#define COMSIG_CLICK_CTRL_SHIFT "ctrl_shift_click" //from base of atom/CtrlShiftClick(/mob)
#define COMSIG_MOUSEDROP_ONTO "mousedrop_onto" //from base of atom/MouseDrop(): (/atom/over, /mob/user)
//from base of area/Entered(): (/area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.
#define COMSIG_ENTER_AREA "enter_area"
//from base of area/Exited(): (/area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.
#define COMSIG_EXIT_AREA "exit_area"
//from base of atom/Click(): (location, control, params, mob/user)
#define COMSIG_CLICK "atom_click"
//from base of atom/ShiftClick(): (/mob)
#define COMSIG_CLICK_SHIFT "shift_click"
//Allows the user to examinate regardless of client.eye.
#define COMPONENT_ALLOW_EXAMINATE 1
//from base of atom/CtrlClickOn(): (/mob)
#define COMSIG_CLICK_CTRL "ctrl_click"
//from base of atom/AltClick(): (/mob)
#define COMSIG_CLICK_ALT "alt_click"
//from base of atom/CtrlShiftClick(/mob)
#define COMSIG_CLICK_CTRL_SHIFT "ctrl_shift_click"
///from base of atom/CtrlShiftRightClick(/mob)
#define COMSIG_CLICK_CTRL_SHIFT_RIGHT "ctrl_shift_right_click"
//from base of atom/MouseDrop(): (/atom/over, /mob/user)
#define COMSIG_MOUSEDROP_ONTO "mousedrop_onto"
#define COMPONENT_NO_MOUSEDROP 1
#define COMSIG_MOUSEDROPPED_ONTO "mousedropped_onto" //from base of atom/MouseDrop_T: (/atom/from, /mob/user)
//from base of atom/MouseDrop_T: (/atom/from, /mob/user)
#define COMSIG_MOUSEDROPPED_ONTO "mousedropped_onto"

///from base of area/proc/power_change(): ()
#define COMSIG_AREA_POWER_CHANGE "area_power_change"
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
#define SHADOW_SPECIES_LIGHT_THRESHOLD 0.2

//MINOR TWEAKS/MISC
#define AGE_MIN 17 //youngest a character can be
#define AGE_MIN 18 //youngest a character can be
#define AGE_MAX 85 //oldest a character can be
#define AGE_MINOR 20 //legal age of space drinking and smoking
#define WIZARD_AGE_MIN 30 //youngest a wizard can be
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define LAZYCLEARLIST(L) if(L) L.Cut()
#define SANITIZE_LIST(L) (islist(L) ? L : list())
#define reverseList(L) reverseRange(L.Copy())
#define LAZYADDASSOC(L, K, V) if(!L) { L = list(); } L[K] += list(V);
#define LAZYADDASSOC(L, K, V) if(!L) { L = list(); } L[K] += V;
#define LAZYADDASSOCLIST(L, K, V) if(!L) { L = list(); } L[K] += list(V);
#define LAZYREMOVEASSOC(L, K, V) if(L) { if(L[K]) { L[K] -= V; if(!length(L[K])) L -= K; } if(!length(L)) L = null; }
#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
Expand Down
6 changes: 6 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ GLOBAL_LIST_INIT(skin_tones, sortList(list(
"african2"
)))

/proc/pick_species_adjective(mob/living/carbon/human/H)
if(isipc(H))
return pick(GLOB.ipc_preference_adjectives)
else
return pick(GLOB.preference_adjectives)

GLOBAL_LIST_EMPTY(species_list)

/proc/age2agedescription(age)
Expand Down
2 changes: 2 additions & 0 deletions code/_globalvars/lists/names.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ GLOBAL_LIST_INIT(verbs, world.file2list("strings/names/verbs.txt"))
GLOBAL_LIST_INIT(ing_verbs, world.file2list("strings/names/ing_verbs.txt"))
GLOBAL_LIST_INIT(adverbs, world.file2list("strings/names/adverbs.txt"))
GLOBAL_LIST_INIT(adjectives, world.file2list("strings/names/adjectives.txt"))
GLOBAL_LIST_INIT(preference_adjectives, world.file2list("strings/preference_adjectives.txt"))
GLOBAL_LIST_INIT(ipc_preference_adjectives, world.file2list("strings/ipc_preference_adjectives.txt"))
GLOBAL_LIST_INIT(dream_strings, world.file2list("strings/dreamstrings.txt"))
//loaded on startup because of "
//would include in rsc if ' was used
Expand Down
1 change: 0 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@

/**
* Control+Shift click
* Unused except for AI
*/
/mob/proc/CtrlShiftClickOn(atom/A)
A.CtrlShiftClick(src)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ SUBSYSTEM_DEF(pai)
continue
if(!(ROLE_PAI in G.client.prefs.be_special))
continue
to_chat(G, "<span class='ghostalert'>[user] is requesting a pAI personality! Use the pAI button to submit yourself as one.</span>")
to_chat(G, "<span class='ghostalert'>[user.real_name] is requesting a pAI personality! Use the pAI button to submit yourself as one.</span>")
addtimer(CALLBACK(src, PROC_REF(spam_again)), spam_delay)
var/list/available = list()
for(var/datum/paiCandidate/c in SSpai.candidates)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/chatmessage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
message.maptext = complete_text

// View the message
LAZYADDASSOC(owned_by.seen_messages, message_loc, src)
LAZYADDASSOCLIST(owned_by.seen_messages, message_loc, src)
owned_by.images |= message
animate(message, alpha = 255, time = CHAT_MESSAGE_SPAWN_TIME)

Expand Down
148 changes: 148 additions & 0 deletions code/datums/guestbook.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/**
* THE GUESTBOOK DATUM // ripped straight from mojave.
*
* Essentially, this datum handles the people that a given human knows,
* to handle getting the correct names on examine and saycode.
*/
/datum/guestbook
/// Associative list of known guests, real_name = known_name
var/list/known_names

/datum/guestbook/Destroy(force)
known_names = null
return ..()

/datum/guestbook/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Guestbook", "[user.real_name]'s Guestbook")
ui.set_autoupdate(FALSE)
ui.open()

/datum/guestbook/ui_state(mob/user)
return GLOB.always_state

/datum/guestbook/ui_data(mob/user)
var/list/data = list()
var/list/names = list()
for(var/real_name in known_names)
var/given_name = LAZYACCESS(known_names, real_name)
names += list(list("real_name" = real_name, "given_name" = given_name))
data["names"] = names
return data

/datum/guestbook/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return .
switch(action)
if("rename_guest")
var/real_name = params["real_name"]
var/new_name = params["new_name"]
new_name = reject_bad_name(new_name, max_length = 42)
if(!new_name)
to_chat(usr, span_warning("That's a pretty terrible name. <i>You can do better</i>."))
return FALSE
if(!rename_guest(usr, null, real_name, new_name, silent = FALSE))
return FALSE
return TRUE
if("delete_guest")
var/real_name = params["real_name"]
if(!remove_guest(usr, null, real_name, silent = FALSE))
return FALSE
return TRUE

/datum/guestbook/proc/try_add_guest(mob/user, mob/living/carbon/human/guest, silent = FALSE)
if(user == guest)
if(!silent)
to_chat(user, span_warning("That's you! You already know yourself plenty."))
return FALSE
if(!visibility_checks(user, guest, silent))
return FALSE
var/given_name = input(user, "What name do you want to give to [guest]?", "Guestbook Name", guest.get_visible_name())
if(!given_name)
if(!silent)
to_chat(user, span_warning("Nevermind."))
return FALSE
given_name = reject_bad_name(given_name)
if(!given_name)
if(!silent)
to_chat(user, span_warning("That's a pretty terrible name. You can do better."))
return FALSE
if(!visibility_checks(user, guest, silent))
return FALSE
var/face_name = guest.get_face_name("ForgetMeNot")
if(LAZYACCESS(known_names, face_name))
if(!rename_guest(user, guest, face_name, given_name, silent))
return FALSE
else
if(!add_guest(user, guest, face_name, given_name, silent))
return FALSE
return TRUE

/datum/guestbook/proc/add_guest(mob/user, mob/living/carbon/guest, real_name, given_name, silent = TRUE)
//Already exists, should be handled by rename_guest()
var/existing_name = LAZYACCESS(known_names, real_name)
if(existing_name)
if(!silent)
to_chat(user, span_warning("You already know them as \"[existing_name]\"."))
return FALSE
LAZYADDASSOC(known_names, real_name, given_name)
if(!silent)
to_chat(user, span_notice("You memorize the face of [guest] as \"[given_name]\"."))
return TRUE

/datum/guestbook/proc/rename_guest(mob/user, mob/living/carbon/guest, real_name, given_name, silent = TRUE)
var/old_name = LAZYACCESS(known_names, real_name)
if(!old_name)
return FALSE
known_names[real_name] = given_name
if(!silent)
to_chat(user, span_notice("You re-memorize the face of \"[old_name]\" as \"[given_name]\"."))
return TRUE

/datum/guestbook/proc/try_remove_guest(mob/user, mob/living/carbon/human/guest, silent = FALSE)
if(user == guest)
if(!silent)
to_chat(user, span_warning("That's you! You'll never forget yourself."))
return
if(!visibility_checks(user, guest, silent))
return FALSE
var/face_name = guest.get_face_name("ForgetMeNot")
if(!remove_guest(user, guest, face_name, silent))
return FALSE
return TRUE

/datum/guestbook/proc/remove_guest(mob/user, mob/living/carbon/guest, real_name, silent = TRUE)
//Already exists, should be handled by rename_guest()
var/existing_name = LAZYACCESS(known_names, real_name)
if(!existing_name)
if(!silent)
to_chat(user, span_warning("You don't know them in the first place."))
return FALSE
LAZYREMOVE(known_names, real_name)
if(!silent)
to_chat(user, span_notice("You forget the face of \"[existing_name]\"."))
return TRUE

/datum/guestbook/proc/get_known_name(mob/user, mob/living/carbon/guest, real_name)
if(user == guest || isAdminObserver(user))
return real_name
return LAZYACCESS(known_names, real_name)

/datum/guestbook/proc/visibility_checks(mob/user, mob/living/carbon/human/guest, silent = FALSE)
if(QDELETED(guest))
if(!silent)
to_chat(user, span_warning("What?"))
return FALSE
var/visible_name = guest.get_visible_name("")
var/face_name = guest.get_face_name("")
if(!visible_name || !face_name)
if(!silent)
to_chat(user, span_warning("You can't see their face very well!"))
return FALSE
if(get_dist(user, guest) > 4)
if(!silent)
to_chat(user, span_warning("You need to take a closer look at them!"))
return FALSE
return TRUE
5 changes: 5 additions & 0 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
/// The index for our current scar slot, so we don't have to constantly check the savefile (unlike the slots themselves, this index is independent of selected char slot, and increments whenever a valid char is joined with)
var/current_scar_slot_index

/// Guestbook datum, in case we actually make use of the guestbook mechanics
var/datum/guestbook/guestbook

///Skill multiplier, adjusts how much xp you get/loose from adjust_xp. Dont override it directly, add your reason to experience_multiplier_reasons and use that as a key to put your value in there.
var/experience_multiplier = 1
///Skill multiplier list, just slap your multiplier change onto this with the type it is coming from as key.
Expand All @@ -95,13 +98,15 @@
key = _key
soulOwner = src
martial_art = default_martial_art
guestbook = new()
init_known_skills()

/datum/mind/Destroy()
SSticker.minds -= src
if(islist(antag_datums))
QDEL_LIST(antag_datums)
QDEL_NULL(language_holder)
QDEL_NULL(guestbook)
set_current(null)
soulOwner = null
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/progressbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
bar.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
user = User

LAZYADDASSOC(user.progressbars, bar_loc, src)
LAZYADDASSOCLIST(user.progressbars, bar_loc, src)
var/list/bars = user.progressbars[bar_loc]
listindex = bars.len

Expand Down
6 changes: 5 additions & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,11 @@
active_hud.screentip_text.maptext = ""
else
//We inline a MAPTEXT() here, because there's no good way to statically add to a string like this
active_hud.screentip_text.maptext = "<span class='maptext' style='text-align: center; font-size: 32px; color: [user.client.prefs.screentip_color]'>[name]</span>"
active_hud.screentip_text.maptext = "<span class='maptext' style='text-align: center; font-size: 32px; color: [user.client.prefs.screentip_color]'>[get_screentip_name(client)]</span>"

/// Returns the atom name that should be used on screentip
/atom/proc/get_screentip_name(client/hovering_client)
return name

///Called whenever a player is spawned on the same turf as this atom.
/atom/proc/join_player_here(mob/M)
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
if(!client)
return
if(new_virtual_z)
LAZYADDASSOC(SSmobs.players_by_virtual_z, "[new_virtual_z]", src)
LAZYADDASSOCLIST(SSmobs.players_by_virtual_z, "[new_virtual_z]", src)
SSidlenpcpool.try_wakeup_virtual_z(new_virtual_z)

/mob/dead/on_virtual_z_change(new_virtual_z, previous_virtual_z)
Expand All @@ -570,7 +570,7 @@
if(!client)
return
if(new_virtual_z)
LAZYADDASSOC(SSmobs.dead_players_by_virtual_z, "[new_virtual_z]", src)
LAZYADDASSOCLIST(SSmobs.dead_players_by_virtual_z, "[new_virtual_z]", src)

// Make sure you know what you're doing if you call this, this is intended to only be called by byond directly.
// You probably want CanPass()
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/navbeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if(previous_virtual_z)
LAZYREMOVEASSOC(GLOB.navbeacons, "[previous_virtual_z]", src)
if(new_virtual_z)
LAZYADDASSOC(GLOB.navbeacons, "[new_virtual_z]", src)
LAZYADDASSOCLIST(GLOB.navbeacons, "[new_virtual_z]", src)
..()

// set the transponder codes assoc list from codes_txt
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/landmarks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/landmark)
. = ..()
GLOB.start_landmarks_list += src
if(jobspawn_override)
LAZYADDASSOC(GLOB.jobspawn_overrides, name, src)
LAZYADDASSOCLIST(GLOB.jobspawn_overrides, name, src)
if(name != "start")
tag = "start*[name]"

Expand Down
Loading

0 comments on commit ac1fb0e

Please sign in to comment.