Merge pull request #10694 from Citadel-Station-13/kevinz000-patch-4
[s] more reasonable reagent logging
This commit is contained in:
@@ -165,6 +165,12 @@
|
||||
/proc/log_mapping(text)
|
||||
WRITE_LOG(GLOB.world_map_error_log, text)
|
||||
|
||||
/proc/log_reagent(text)
|
||||
WRITE_LOG(GLOB.reagent_log, text)
|
||||
|
||||
/proc/log_reagent_transfer(text)
|
||||
log_reagent("TRANSFER: [text]")
|
||||
|
||||
/* For logging round startup. */
|
||||
/proc/start_log(log)
|
||||
WRITE_LOG(log, "Starting up round ID [GLOB.round_id].\n-------------------------")
|
||||
|
||||
@@ -32,6 +32,8 @@ GLOBAL_VAR(world_map_error_log)
|
||||
GLOBAL_PROTECT(world_map_error_log)
|
||||
GLOBAL_VAR(subsystem_log)
|
||||
GLOBAL_PROTECT(subsystem_log)
|
||||
GLOBAL_VAR(reagent_log)
|
||||
GLOBAL_PROTECT(reagent_log)
|
||||
GLOBAL_VAR(world_crafting_log)
|
||||
GLOBAL_PROTECT(world_crafting_log)
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
if(!proximity || lit) //can't dip if cigarette is lit (it will heat the reagents in the glass instead)
|
||||
return
|
||||
if(istype(glass)) //you can dip cigarettes into beakers
|
||||
if(glass.reagents.trans_to(src, chem_volume)) //if reagents were transfered, show the message
|
||||
if(glass.reagents.trans_to(src, chem_volume, log = "cigar fill: dip cigarette")) //if reagents were transfered, show the message
|
||||
to_chat(user, "<span class='notice'>You dip \the [src] into \the [glass].</span>")
|
||||
else //if not, either the beaker was empty, or the cigarette was full
|
||||
if(!glass.reagents.total_volume)
|
||||
@@ -154,7 +154,6 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
else
|
||||
to_chat(user, "<span class='notice'>[src] is full.</span>")
|
||||
|
||||
|
||||
/obj/item/clothing/mask/cigarette/proc/light(flavor_text = null)
|
||||
if(lit)
|
||||
return
|
||||
@@ -438,7 +437,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
packeditem = 1
|
||||
name = "[O.name]-packed [initial(name)]"
|
||||
if(O.reagents)
|
||||
O.reagents.trans_to(src, O.reagents.total_volume)
|
||||
O.reagents.trans_to(src, O.reagents.total_volume, log = "cigar fill: pipe pack")
|
||||
qdel(O)
|
||||
else
|
||||
to_chat(user, "<span class='warning'>It has to be dried first!</span>")
|
||||
@@ -687,7 +686,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
if(O.dry)
|
||||
var/obj/item/clothing/mask/cigarette/rollie/R = new /obj/item/clothing/mask/cigarette/rollie(user.loc)
|
||||
R.chem_volume = target.reagents.total_volume
|
||||
target.reagents.trans_to(R, R.chem_volume)
|
||||
target.reagents.trans_to(R, R.chem_volume, log = "cigar fill: rolling paper afterattack")
|
||||
qdel(target)
|
||||
qdel(src)
|
||||
user.put_in_active_hand(R)
|
||||
@@ -903,7 +902,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
|
||||
//Transfer reagents and remove the plant
|
||||
user.show_message("<span class='notice'>You stuff the [DP] into the [src]'s bowl.</span>", MSG_VISUAL)
|
||||
DP.reagents.trans_to(src, 100)
|
||||
DP.reagents.trans_to(src, 100, log = "cigar fill: bong")
|
||||
qdel(DP)
|
||||
return
|
||||
else
|
||||
|
||||
@@ -116,6 +116,7 @@ GLOBAL_LIST(topic_status_cache)
|
||||
GLOB.query_debug_log = "[GLOB.log_directory]/query_debug.log"
|
||||
GLOB.world_job_debug_log = "[GLOB.log_directory]/job_debug.log"
|
||||
GLOB.subsystem_log = "[GLOB.log_directory]/subsystem.log"
|
||||
GLOB.reagent_log = "[GLOB.log_directory]/reagents.log"
|
||||
GLOB.world_crafting_log = "[GLOB.log_directory]/crafting.log"
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
@@ -132,6 +133,7 @@ GLOBAL_LIST(topic_status_cache)
|
||||
start_log(GLOB.world_runtime_log)
|
||||
start_log(GLOB.world_job_debug_log)
|
||||
start_log(GLOB.subsystem_log)
|
||||
start_log(GLOB.reagent_log)
|
||||
start_log(GLOB.world_crafting_log)
|
||||
|
||||
GLOB.changelog_hash = md5('html/changelog.html') //for telling if the changelog has changed recently
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
return master
|
||||
|
||||
/datum/reagents/proc/trans_to(obj/target, amount=1, multiplier=1, preserve_data=1, no_react = 0)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
|
||||
/datum/reagents/proc/trans_to(obj/target, amount = 1, multiplier = 1, preserve_data = 1, no_react = 0, log = FALSE)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
|
||||
var/list/cached_reagents = reagent_list
|
||||
if(!target || !total_volume)
|
||||
return
|
||||
@@ -188,17 +188,23 @@
|
||||
amount = min(min(amount, src.total_volume), R.maximum_volume-R.total_volume)
|
||||
var/part = amount / src.total_volume
|
||||
var/trans_data = null
|
||||
var/list/transferred = list()
|
||||
for(var/reagent in cached_reagents)
|
||||
var/datum/reagent/T = reagent
|
||||
var/transfer_amount = T.volume * part
|
||||
if(preserve_data)
|
||||
trans_data = copy_data(T)
|
||||
|
||||
transferred += "[T] - [transfer_amount]"
|
||||
|
||||
R.add_reagent(T.type, transfer_amount * multiplier, trans_data, chem_temp, T.purity, pH, no_react = TRUE, ignore_pH = TRUE) //we only handle reaction after every reagent has been transfered.
|
||||
|
||||
remove_reagent(T.type, transfer_amount, ignore_pH = TRUE)
|
||||
|
||||
if(log && amount > 0)
|
||||
var/atom/us = my_atom
|
||||
var/atom/them = R.my_atom
|
||||
var/location_string = "FROM [(us && "[us] ([REF(us)]) [COORD(us)]") || "NULL"] TO [(them && "[them] ([REF(them)]) [COORD(them)]") || "NULL"]"
|
||||
log_reagent_transfer("[location_string] - [key_name(usr)][istext(log) ? " - [log]" : ""]: trans_to with arguments [target] [amount] [multiplier] [preserve_data] [no_react] and reagents [english_list(transferred)]")
|
||||
|
||||
update_total()
|
||||
R.update_total()
|
||||
if(!no_react)
|
||||
@@ -237,7 +243,7 @@
|
||||
src.handle_reactions()
|
||||
return amount
|
||||
|
||||
/datum/reagents/proc/trans_id_to(obj/target, reagent, amount=1, preserve_data=1)//Not sure why this proc didn't exist before. It does now! /N
|
||||
/datum/reagents/proc/trans_id_to(obj/target, reagent, amount = 1, preserve_data = TRUE, log = FALSE)//Not sure why this proc didn't exist before. It does now! /N
|
||||
var/list/cached_reagents = reagent_list
|
||||
if (!target)
|
||||
return
|
||||
@@ -257,8 +263,12 @@
|
||||
if(preserve_data)
|
||||
trans_data = current_reagent.data
|
||||
R.add_reagent(current_reagent.type, amount, trans_data, chem_temp, current_reagent.purity, pH, no_react = TRUE)
|
||||
|
||||
remove_reagent(current_reagent.type, amount, 1)
|
||||
if(log && amount > 0)
|
||||
var/atom/us = my_atom
|
||||
var/atom/them = R.my_atom
|
||||
var/location_string = "FROM [(us && "[us] ([REF(us)]) [COORD(us)]") || "NULL"] TO [(them && "[them] ([REF(them)]) [COORD(them)]") || "NULL"]"
|
||||
log_reagent_transfer("[location_string] - [key_name(usr)][istext(log) ? " - [log]" : ""]: trans_id_to with arguments [target] [reagent] [amount] [preserve_data]")
|
||||
break
|
||||
|
||||
src.update_total()
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
log_combat(user, M, "splashed", R)
|
||||
reagents.clear_reagents()
|
||||
else
|
||||
if(M != user)
|
||||
var/self_fed = M == user
|
||||
if(!self_fed)
|
||||
M.visible_message("<span class='danger'>[user] attempts to feed something to [M].</span>", \
|
||||
"<span class='userdanger'>[user] attempts to feed something to you.</span>")
|
||||
if(!do_mob(user, M))
|
||||
@@ -44,7 +45,7 @@
|
||||
to_chat(user, "<span class='notice'>You swallow a gulp of [src].</span>")
|
||||
var/fraction = min(5/reagents.total_volume, 1)
|
||||
reagents.reaction(M, INGEST, fraction)
|
||||
addtimer(CALLBACK(reagents, /datum/reagents.proc/trans_to, M, 5), 5)
|
||||
addtimer(CALLBACK(reagents, /datum/reagents.proc/trans_to, M, 5, null, null, null, self_fed? "self swallowed" : "fed by [user]"), 5)
|
||||
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
|
||||
|
||||
/obj/item/reagent_containers/glass/afterattack(obj/target, mob/user, proximity)
|
||||
@@ -61,7 +62,7 @@
|
||||
to_chat(user, "<span class='warning'>[target] is full.</span>")
|
||||
return
|
||||
|
||||
var/trans = reagents.trans_to(target, amount_per_transfer_from_this)
|
||||
var/trans = reagents.trans_to(target, amount_per_transfer_from_this, log = "reagentcontainer-glass afterattack transfer to")
|
||||
to_chat(user, "<span class='notice'>You transfer [trans] unit\s of the solution to [target].</span>")
|
||||
|
||||
else if(target.is_drainable()) //A dispenser. Transfer FROM it TO us.
|
||||
@@ -73,7 +74,7 @@
|
||||
to_chat(user, "<span class='warning'>[src] is full.</span>")
|
||||
return
|
||||
|
||||
var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this)
|
||||
var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this, log = "reagentcontainer-glass afterattack fill from")
|
||||
to_chat(user, "<span class='notice'>You fill [src] with [trans] unit\s of the contents of [target].</span>")
|
||||
|
||||
else if(reagents.total_volume)
|
||||
@@ -96,7 +97,7 @@
|
||||
to_chat(user, "<span class='notice'>[src] is full.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You break [E] in [src].</span>")
|
||||
E.reagents.trans_to(src, E.reagents.total_volume)
|
||||
E.reagents.trans_to(src, E.reagents.total_volume, log = "reagentcontainer-glass break egg in")
|
||||
qdel(E)
|
||||
return
|
||||
..()
|
||||
@@ -307,7 +308,7 @@
|
||||
if(reagents.total_volume < 1)
|
||||
to_chat(user, "<span class='warning'>[src] is out of water!</span>")
|
||||
else
|
||||
reagents.trans_to(O, 5)
|
||||
reagents.trans_to(O, 5, log = "reagentcontainer-bucket fill mop")
|
||||
to_chat(user, "<span class='notice'>You wet [O] in [src].</span>")
|
||||
playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
|
||||
else if(isprox(O))
|
||||
|
||||
Reference in New Issue
Block a user