Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Splits reagent log string creation to a standard proc and a bespoke stupid proc that takes an external list instead of using its own reagents_list.
  • Loading branch information
Timberpoes authored Mar 31, 2022
1 parent 30e84eb commit c4b5b53
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion code/datums/components/food/edible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Behavior that's still missing from this component that original food items had t
return
if(IsFoodGone(owner, feeder))
return
log_combat(feeder, eater, "fed", owner.reagents.log_list())
log_combat(feeder, eater, "fed", owner.reagents.get_reagent_log_string())
eater.visible_message(
span_danger("[feeder] forces [eater] to eat [parent]!"),
span_userdanger("[feeder] forces you to eat [parent]!")
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/iv_drip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
return
reagent_container = W
to_chat(user, span_notice("You attach [W] to [src]."))
user.log_message("attached a [W] to [src] at [AREACOORD(src)] containing ([reagent_container.reagents.log_list()])", LOG_ATTACK)
user.log_message("attached a [W] to [src] at [AREACOORD(src)] containing ([reagent_container.reagents.get_reagent_log_string()])", LOG_ATTACK)
add_fingerprint(user)
update_appearance()
return
Expand Down Expand Up @@ -232,7 +232,7 @@
return
usr.visible_message(span_warning("[usr] attaches [src] to [target]."), span_notice("You attach [src] to [target]."))
var/datum/reagents/container = get_reagent_holder()
log_combat(usr, target, "attached", src, "containing: ([container.log_list()])")
log_combat(usr, target, "attached", src, "containing: ([container.get_reagent_log_string()])")
add_fingerprint(usr)
attached = target
START_PROCESSING(SSmachines, src)
Expand Down Expand Up @@ -342,7 +342,7 @@
. = ..()
AddComponent(/datum/component/plumbing/iv_drip, anchored)
AddComponent(/datum/component/simple_rotation)

/obj/machinery/iv_drip/plumbing/wrench_act(mob/living/user, obj/item/I)
..()
default_unfasten_wrench(user, I)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/decals/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
end_life(source)
return

var/puff_reagents_string = reagents.log_list()
var/puff_reagents_string = reagents.get_reagent_log_string()
var/travelled_max_distance = (source.lifetime - source.delay <= 0)
var/turf/our_turf = get_turf(src)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/food_and_drinks/drinks/drinks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
return // The drink might be empty after the delay, such as by spam-feeding
M.visible_message(span_danger("[user] fed [M] the contents of [src]."), \
span_userdanger("[user] fed you the contents of [src]."))
log_combat(user, M, "fed", reagents.log_list())
log_combat(user, M, "fed", reagents.get_reagent_log_string())

SEND_SIGNAL(src, COMSIG_DRINK_DRANK, M, user)
var/fraction = min(gulp_size/reagents.total_volume, 1)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/food_and_drinks/food/condiment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
return // The condiment might be empty after the delay.
M.visible_message(span_warning("[user] fed [M] from [src]."), \
span_warning("[user] fed you from [src]."))
log_combat(user, M, "fed", reagents.log_list())
log_combat(user, M, "fed", reagents.get_reagent_log_string())
reagents.trans_to(M, 10, transfered_by = user, methods = INGEST)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
return TRUE
Expand Down
39 changes: 25 additions & 14 deletions code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@

if(transfered_by && target_atom)
target_atom.add_hiddenprint(transfered_by) //log prints so admins can figure out who touched it last.
log_combat(transfered_by, target_atom, "transferred reagents ([log_list(transfer_log)]) from [my_atom] to")
log_combat(transfered_by, target_atom, "transferred reagents ([get_external_reagent_log_string(transfer_log)]) from [my_atom] to")

update_total()
R.update_total()
Expand Down Expand Up @@ -1465,28 +1465,39 @@
ph = clamp(total_ph/total_volume, 0, 14)

/**
* Used in attack logs for reagents in pills and such
* Outputs a log-friendly list of reagents based on an external reagent list.
*
* Arguments:
* * external_list - assoc list of reagent type = list(REAGENT_TRANSFER_AMOUNT = amounts, REAGENT_PURITY = purity)
* * external_list - Assoc list of (reagent_type) = list(REAGENT_TRANSFER_AMOUNT = amounts, REAGENT_PURITY = purity)
*/
/datum/reagents/proc/log_list(external_list)
if((external_list && !length(external_list)) || !length(reagent_list))
/datum/reagents/proc/get_external_reagent_log_string(external_list)
if(!length(external_list))
return "no reagents"

var/list/data = list()

for(var/reagent_type in external_list)
var/list/qualities = external_list[reagent_type]
data += "[reagent_type] ([round(qualities[REAGENT_TRANSFER_AMOUNT], 0.1)]u, [qualities[REAGENT_PURITY]] purity)"

var/list/data = list()
if(external_list)
for(var/r in external_list)
var/list/qualities = external_list[r]
data += "[r] ([round(qualities[REAGENT_TRANSFER_AMOUNT], 0.1)]u, [qualities[REAGENT_PURITY]] purity)"
else
for(var/datum/reagent/reagent as anything in reagent_list) //no reagents will be left behind
data += "[reagent.type] ([round(reagent.volume, 0.1)]u, [reagent.purity] purity)"
//Using types because SOME chemicals (I'm looking at you, chlorhydrate-beer) have the same names as other chemicals.
return english_list(data)

/**
* Outputs a log-friendly list of reagents based on the internal reagent_list.
*
* Arguments:
* * external_list - Assoc list of (reagent_type) = list(REAGENT_TRANSFER_AMOUNT = amounts, REAGENT_PURITY = purity)
*/
/datum/reagents/proc/get_reagent_log_string()
if(!length(reagent_list))
return "no reagents"

var/list/data = list()

for(var/datum/reagent/reagent as anything in reagent_list)
data += "[reagent.type] ([round(reagent.volume, 0.1)]u, [reagent.purity] purity)"

return english_list(data)

/////////////////////////////////////////////////////////////////////////////////
///////////////////////////UI / REAGENTS LOOKUP CODE/////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reagent_containers/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
return // The drink might be empty after the delay, such as by spam-feeding
M.visible_message(span_danger("[user] feeds [M] something from [src]."), \
span_userdanger("[user] feeds you something from [src]."))
log_combat(user, M, "fed", reagents.log_list())
log_combat(user, M, "fed", reagents.get_reagent_log_string())
else
to_chat(user, span_notice("You swallow a gulp of [src]."))
SEND_SIGNAL(src, COMSIG_GLASS_DRANK, M, user)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/reagent_containers/medigel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
to_chat(M, span_notice("You [apply_method] yourself with [src]."))

else
log_combat(user, M, "attempted to apply", src, reagents.log_list())
log_combat(user, M, "attempted to apply", src, reagents.get_reagent_log_string())
M.visible_message(span_danger("[user] attempts to [apply_method] [src] on [M]."), \
span_userdanger("[user] attempts to [apply_method] [src] on you."))
if(!do_mob(user, M, CHEM_INTERACT_DELAY(3 SECONDS, user)))
Expand All @@ -73,7 +73,7 @@
return

else
log_combat(user, M, "applied", src, reagents.log_list())
log_combat(user, M, "applied", src, reagents.get_reagent_log_string())
playsound(src, 'sound/effects/spray.ogg', 30, TRUE, -6)
reagents.trans_to(M, amount_per_transfer_from_this, transfered_by = user, methods = apply_type)
return
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/reagent_containers/spray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
reagent_puff.color = mix_color_from_reagents(reagent_puff.reagents.reagent_list)
var/wait_step = max(round(2+3/range), 2)

var/puff_reagent_string = reagent_puff.reagents.log_list()
var/puff_reagent_string = reagent_puff.reagents.get_reagent_log_string()
var/turf/src_turf = get_turf(src)

log_combat(user, src_turf, "fired a puff of reagents from", src, addition="with a range of \[[range]\], containing [puff_reagent_string]")
Expand Down Expand Up @@ -140,7 +140,7 @@
if(isturf(usr.loc) && src.loc == usr)
to_chat(usr, span_notice("You empty \the [src] onto the floor."))
reagents.expose(usr.loc)
log_combat(usr, usr.loc, "emptied onto", src, addition="which had [reagents.log_list()]")
log_combat(usr, usr.loc, "emptied onto", src, addition="which had [reagents.get_reagent_log_string()]")
src.reagents.clear_reagents()

/// Handles updating the spray distance when the reagents change.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reagent_containers/syringes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if (!try_syringe(target, user, proximity))
return

var/contained = reagents.log_list()
var/contained = reagents.get_reagent_log_string()
log_combat(user, target, "attempted to inject", src, addition="which had [contained]")

if(!reagents.total_volume)
Expand Down

0 comments on commit c4b5b53

Please sign in to comment.