mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-04 05:18:12 +00:00
[MIRROR] Fixes silo logging + add log file based logging to silo [MDB IGNORE] (#20748)
* Fixes silo logging + add log file based logging to silo * Update logging.dm * Update logging.dm --------- Co-authored-by: Gamer025 <33846895+Gamer025@users.noreply.github.com> Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
var/mats = stack_mats & mat_container.materials
|
||||
var/amount = gathered_ore.amount
|
||||
mat_container.insert_item(gathered_ore, ore_multiplier, breakdown_flags=BREAKDOWN_FLAGS_ORM) //insert it
|
||||
materials.silo_log(src, "smelted", amount, "someone", mats)
|
||||
materials.silo_log(src, "smelted", amount, gathered_ore.name, mats)
|
||||
qdel(gathered_ore)
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_ORM_COLLECTED_ORE)
|
||||
|
||||
@@ -66,7 +66,8 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
|
||||
// assumes unlimited space...
|
||||
var/amount = I.amount
|
||||
materials.user_insert(I, user, breakdown_flags)
|
||||
silo_log(M, "deposited", amount, "sheets", item_mats)
|
||||
var/list/matlist = I.get_material_composition(breakdown_flags)
|
||||
silo_log(M, "deposited", amount, I.name, matlist)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/ore_silo/attackby(obj/item/W, mob/user, params)
|
||||
@@ -173,7 +174,7 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
|
||||
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
|
||||
var/count = materials.retrieve_sheets(text2num(href_list["eject_amt"]), eject_sheet, drop_location())
|
||||
var/list/matlist = list()
|
||||
matlist[eject_sheet] = MINERAL_MATERIAL_AMOUNT
|
||||
matlist[eject_sheet] = MINERAL_MATERIAL_AMOUNT * count
|
||||
silo_log(src, "ejected", -count, "sheets", matlist)
|
||||
return TRUE
|
||||
else if(href_list["page"])
|
||||
@@ -188,11 +189,20 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
|
||||
I.buffer = src
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Creates a log entry for depositing/withdrawing from the silo both ingame and in text based log
|
||||
*
|
||||
* Arguments:
|
||||
* - [M][/obj/machinery]: The machine performing the action.
|
||||
* - action: Text that visually describes the action (smelted/deposited/resupplied...)
|
||||
* - amount: The amount of sheets/objects deposited/withdrawn by this action. Positive for depositing, negative for withdrawing.
|
||||
* - noun: Name of the object the action was performed with (sheet, units, ore...)
|
||||
* - [mats][list]: Assoc list in format (material datum = amount of raw materials). Wants the actual amount of raw (iron, glass...) materials involved in this action. If you have 10 metal sheets each worth 2000 iron you would pass a list with the iron material datum = 20000
|
||||
*/
|
||||
/obj/machinery/ore_silo/proc/silo_log(obj/machinery/M, action, amount, noun, list/mats)
|
||||
if (!length(mats))
|
||||
return
|
||||
var/datum/ore_silo_log/entry = new(M, action, amount, noun, mats)
|
||||
|
||||
var/list/datum/ore_silo_log/logs = GLOB.silo_access_logs[REF(src)]
|
||||
if(!LAZYLEN(logs))
|
||||
GLOB.silo_access_logs[REF(src)] = logs = list(entry)
|
||||
@@ -226,9 +236,21 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
|
||||
amount = _amount
|
||||
noun = _noun
|
||||
materials = mats.Copy()
|
||||
for(var/each in materials)
|
||||
materials[each] *= abs(_amount)
|
||||
format()
|
||||
var/list/data = list(
|
||||
"machine_name" = machine_name,
|
||||
"area_name" = AREACOORD(M),
|
||||
"action" = action,
|
||||
"amount" = abs(amount),
|
||||
"noun" = noun,
|
||||
"raw_materials" = get_raw_materials(""),
|
||||
"direction" = amount < 0 ? "withdrawn" : "deposited",
|
||||
)
|
||||
GLOB.logger.Log(
|
||||
LOG_CATEGORY_SILO,
|
||||
"[machine_name] in \[[AREACOORD(M)]\] [action] [abs(amount)]x [noun] | [get_raw_materials("")]",
|
||||
data,
|
||||
)
|
||||
|
||||
/datum/ore_silo_log/proc/merge(datum/ore_silo_log/other)
|
||||
if (other == src || action != other.action || noun != other.noun)
|
||||
@@ -245,13 +267,14 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
|
||||
|
||||
/datum/ore_silo_log/proc/format()
|
||||
name = "[machine_name]: [action] [amount]x [noun]"
|
||||
formatted = "([timestamp]) <b>[machine_name]</b> in [area_name]<br>[action] [abs(amount)]x [noun]<br> [get_raw_materials("")]"
|
||||
|
||||
var/list/msg = list("([timestamp]) <b>[machine_name]</b> in [area_name]<br>[action] [abs(amount)]x [noun]<br>")
|
||||
var/sep = ""
|
||||
/datum/ore_silo_log/proc/get_raw_materials(separator)
|
||||
var/list/msg = list()
|
||||
for(var/key in materials)
|
||||
var/datum/material/M = key
|
||||
var/val = round(materials[key]) / MINERAL_MATERIAL_AMOUNT
|
||||
msg += sep
|
||||
sep = ", "
|
||||
var/val = round(materials[key])
|
||||
msg += separator
|
||||
separator = ", "
|
||||
msg += "[amount < 0 ? "-" : "+"][val] [M.name]"
|
||||
formatted = msg.Join()
|
||||
return msg.Join()
|
||||
|
||||
Reference in New Issue
Block a user