Commit Graph

32 Commits

Author SHA1 Message Date
Gboster-0
2f6ae1dcde Makes ore refineries drop materials below them when not linked to a silo (#93681)
## About The Pull Request

- What it says above, makes them drop materials instead of sending them
to the shadow realm
- Replaces some 1 argument `round()'s` with `floor()'s` in material
logic, someone should regex all of them sometime for a giant conflict
merge PR

## Why It's Good For The Game

> What it says above, makes them drop materials instead of sending them
to the shadow realm
- Makes custom-made refinery setups a bit more viable, alongside
recovering from the ore silo being bombed/eaten by a hungry boi
> Replaces some 1 argument `round()'s` with `floor()'s` in material
logic
- Round() using 1 argument is deprecated, should slowly start switching
over

## Changelog

🆑
fix: the ore refineries now drop stacks of materials below them if they
are not linked to a silo instead of being sent to the shadow realm
/🆑
2025-10-31 14:34:58 +01:00
ArcaneMusic
b617fb3877 Fix for stacks transforming into other stacks when removed from the Protolathe/Techfab. (#93260)
## About The Pull Request

I *think* this should be all that's required to fix this, it looks like
it's just the variable that iterates over all available stacks on the
dropturf needed to compare against the iterator's type as opposed to the
stack we're about to create otherwise.

Fixes #93256 

## Why It's Good For The Game

Prevents a tiiiiny little material transformation/duplication bug.

## Changelog

🆑
fix: Sheets removed from the protolathe/techfab will properly remove the
correct quantity and merge into the right material.
/🆑
2025-10-04 04:39:00 +02:00
Ghom
a28575aa82 [NO GBP] Fixing more issues with sand (you can make sand walls again, also ghost glass sheets?) (#93215)
## About The Pull Request
Apparently wall construction code is snowflaked and indented as fuck
(and the same goes for door assemblies). I'm not bothering refactoring
everything with them, only to reduce the indentation, changing a couple
vars and overall making it easier to work with them later. This includes
wall construction not being hardcoded to sheets but include the
possibility to use other kind of stacks as well (if you don't count the
snowflake interaction with iron rods). In layman's terms, this means you
can make walls made out of sand (distinct from sandstone) again.

Also I've done some small changes to the materials storage, so that it
can eject ores too if the material doesn't have a sheet type.

Also, I've been told there may be issues with broken, uninteractable
(probably not properly initialized) glass sheets beside the ORM. I'm not
100% sure about the deets, but it may have something to do with spawning
the glass on the same turf the ORM is listening to, when smelting sand,
causing some race conditions, so let's spawn it in nullspace

## Why It's Good For The Game
While I'm sure there may be more elegant solutions (just take a look at
the wall and door construction code, they both use text2path oh god!),
I'm just here to make things a lil' cleaner and be done with issues with
the fact that sand is made of sand.

## Changelog

🆑
fix: You can once again make sand walls.
fix: Deconstructing an autolathe with sand in it should now drop sand.
/🆑
2025-10-02 19:12:11 +03:00
MrMelbert
750ca9d2ec Two as anything greps (and some other cleanup) (#92974) 2025-09-20 13:44:28 -04:00
Joshua Kidder
07f6b7e879 [NO GBP] Silo logging hotfix 2 (includes hotfix 1): Multitool linking, decon/recon, funky define fix (#92349)
## About The Pull Request
Includes #92346

Additionally, fixes a non-pattern define that would fling the silo
logging formatting off its spinwheel when it would recursively jsonify
the logs.

Adds an id_read_failure for disassembling ore silos logging all their
dropped materials.

## Why It's Good For The Game
Hotfixes for a PR

## Changelog
🆑 Bisar
fix: Ore silos should be able to be connected/disconnected/disassembled
without any issues now.
fix: The define for CENTCOM_SPECOPS was incorrectly formatted; it has
been fixed.
/🆑
2025-07-28 20:16:49 +02:00
Joshua Kidder
988ca0b482 Ore silo logging & access refactor; UI updates, single-target bans, more robust logging information, more robust access control (#91142)
## About The Pull Request

# More robust logging
## Ore silo logs have now been refactored in the UI to display:
- Number of sheets is now the relative unit when displaying a given log.
- Instead of `100 iron` being displayed when removing one sheet, it just
says `1 iron`
- Instead of `25 iron` being displayed when using a quarter sheet, it
just says `0.25 iron`
- All information from ID_DATA(log_user) now sent to tgui backend
    - The items rendered to ore silo users are:
	- Name on ID, job on ID
- If the ID's bank account (if one is registered) is one of the ore
silo's banned users
- If the user for a given entry was wearing a chameleon card, they will
always appear unbanned
- NOTE: The bank account ID # is (currently) not shown to players using
the ore silo.
- Full log information is rendered within a dropdown; the dropdown
one-liner shows
  - Action (deposit, eject, item created)
- Amount (deposit/eject? amount of material used. item created? number
of items created.)
- Either name of material (if deposit/eject) or the name of items
crafted
- The name of the user who performed a given operation (if wearing an
unbanned ID) or ID_READ_FAILURE (if ore silo ID requirement has been
disabled and the person is not wearing an ID)
  - As name, but instead, the job of the ID (or ID_READ_FAILURE)


![image](https://github.com/user-attachments/assets/bb992a81-8db3-4a92-ad3a-917239fc407a)


# Access control improvements
## Single-user bans
- Anyone with QM access (not silicons) can now ban/unban a user from a
given log from using the ore silo
    - Bans are associated to bank account IDs.
        - Wearers of chameleon cards bypass any ban restrictions.
	- Anyone with QM access on their worn card bypasses ban restrictions.
	- Silicons bypass ban restrictions.
- QM access requirement is removed if the ore silo is emagged.
- Silicons can ban/unban people if the ore silo is emagged.
## Worn ID requirement
- Enabled at roundstart, can be disabled by anyone with QM access (not
silicons)
- If enabled, you must be wearing an ID with a bank account associated
to it to use ore silo materials.
- Wearers of chameleon cards bypass this restriction (so-called ID
requirement free thinkers wearing chameleon ID cards)
- QM access requirement to toggle removed if emagged.
- Silicons can toggle this on/off if the ore silo is emagged.
# Access control radio notifications
## Access control operations reported on the radio
- Any operations for access control are reported on radio channels.
    - Currently, the policy is always the default.
- In the future, the ore silo UI will allow the quartermaster to modify
what operations are reported on what channels (petty QM broadcasting ban
reports on Common)
- Current default policy:
    - Reported on COMMON channel:
- Anyone but the Captain attempts to ban someone with QM access from the
ore silo (nice try dumbass)
	    - Ore silo ID requirement toggling
	- Reported on COMMAND channel:
	    - Common channel reports.
		- Per-user banning/unbanning.
		- Anyone without QM access attempts to ban/unban someone.
		- Anyone without QM access attempts to toggle the restriction for ID.
		- Silicons attempting to tamper with the ID requirement restriction
		- Silicons attempting to tamper with the ban/unbanned user list
- A ban attempt failing because a given log entry had a user with no
bank ID.
	- Reported on SECURITY channel:
	    - Common channel reports.
		- Per-user banning/unbanning.
		- Anyone without QM access tampering with the silo.
	- Reported on SUPPLY channel:
	    - Command channel reports.
- Reporting to the radio is disabled if the ore silo is emagged.
## Modifications to the remote_materials component
- Strictly encompass the behavior for connecting/disconnecting ore silos
to material receptacles (RCDs, machines, etc) into procs on the
component, instead of handling it all over the place

## Why It's Good For The Game

Gives people with ore silo access more fine grained control over ore
silo use without having to resort to heavy-handed fabricator lockouts

Makes the logging on the ore silo more robust so we can make sure we
kill the right Roboticist for using all the materials

Offers an avenue for sidestepping all of this with a chameleon card or
emag if a given traitor (organic or otherwise) is particularly opposed
to DRM mats.



https://github.com/user-attachments/assets/effd2c63-509c-4d33-992f-837a0d62b935



## Changelog
🆑 Bisar
add: The ore silo has had a significant expansion to its logging
capabilities.
add: The ore silo now allows any ID with Quartermaster access (NOT
SILICONS!) to ban/unban specific users from the silo.
add: The ore silo now has a toggle (on by default) that a user of ore
silo materials has an ID with an associated bank account. This can be
toggled by anyone with Quartermaster access (NOT SILICONS!)
add: NanoTrasen discounts any reports that Syndicate contraband
(cryptographic sequencer, agent card) can be used to circumvent any
protocols instituted on the ore silo access control routines.
add: The ore silo now announces operations to ban/unban users and
enable/disable ID requirements on radio channels (check the Github for
actions reported to what channels.)
add: The tgui interface for ore silo log entries has been reworked.
refactor: The code for logging a given access to ore silo materials has
been significantly refactored.
qol: Ore silo log entries now display materials spent in terms of sheets
rather than the obfuscated absolute-units previously display (1 iron
ejected instead of -100 iron, 0.25 used in a craft instead of -25 iron)
/🆑
2025-07-26 22:17:51 -07:00
SmArtKar
3d1a54e129 Moves material item insertion to right click for material containers (#90188)
## About The Pull Request

Inserting material (i.e. made from a material, but not a material
sheet/stack) items into material containers/remotes (ore silos,
autolathes, protolathes, etc) now uses right click instead of left
click. You still insert sheets using left click.

## Why It's Good For The Game

Its super easy to end up having your guns (which are made out of iron)
or armor (also made out of armor) or disks (also made out of iron) eaten
by an autolathe as you try to click a table next to it. This should
resolve players' frustrations while keeping material item insertion an
option via right clicking.

## Changelog
🆑
qol: Moved material item insertion to right click for material
containers
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2025-03-24 14:01:43 +00:00
Ghom
7a2927b288 Autolathes now accept alloys without disassembling them into their components (#90086)
## About The Pull Request
Custom material designs cannot be printed with plasteel and other alloys
because of this small issue. This should fix it.

## Why It's Good For The Game
See above.

## Changelog

🆑
fix: Custom material toolboxes and fishing rods can now be printed with
alloys such a plasteel and plasmaglass.
/🆑
2025-03-21 14:02:38 +01:00
SmArtKar
336d978d4a Autholathes and some misc material containers no longer gluttonously consume players' tools (#89900)
## About The Pull Request
Converted autolathes, drone dispensers, sheetifiers and recyclers to
tool_acts, and autolathes now use base_item_interaction similarly to
flatpackers to avoid the ire of material containers. Material containers
also now refuse to accept materials if the owner is a machine which is
broken or has an open panel.

## Why It's Good For The Game

Autolathe ate my multitool one too many times, can't have shit in space
detroit.

There's been a ton of feedback on autolathes having bad UX and #89859
kinda pushed me over the edge, its just far too confusing to deal with -
now they should be up to parity with protolathes (tools don't get eaten
on left click anymore)

## Changelog
🆑
fix: You no longer can insert sheets into unpowered, broken or opened
autolathes.
qol: Screwdriver/crowbar/multitool interactions on autolathes now work
with left click instead of right click.
/🆑
2025-03-16 18:28:21 +00:00
SyncIt21
26343e0e24 Improves code for recycling circuits in component printer (#87787) 2024-11-10 15:06:40 +01:00
SyncIt21
94ff0ada00 Moves material container attack to item interaction level (#87676)
## About The Pull Request
- Fixes #87664

storage hooks onto pre attack whereas the material container uses
attackby so the storage component was intercepting the bananium before
the material container could consume it.

This also ends the attack chain early so optimization

## Changelog
🆑
fix: MK honk shoes now consume bananium & can clown again
code: material container objects end their attack chain early
/🆑
2024-11-08 03:22:48 +01:00
Ghom
cdebe98a17 refactoring how materials effects are added to atoms (#86901)
## About The Pull Request
I'm "cooking" the materials system a bit, specifically the code
responsible for applying and removing effects. My goal is to move most
of the code to the objects-side, split it in smaller procs that can be
more easily overriden or called for object-specific modifiers and
effects, while also revamping things all around to better support items
made from multiple materials (the cleric mace will most likely be one in
this PR, with the handle and tip made of different materials).

PR NO LONGER WIP, TESTED AND ALL, CLERIC MACES CAN NOW BE MADE OF TWO
MATERIALS.

## Why It's Good For The Game
One of the nastiest flaws with the materials system is that it's just
unfeasable to have items made of multiple mats (with effects enabled)
right now, as they easily tend to override each other, where some of the
modifiers and effects should only be applied the main material.

Beside, the system's starting to show signs of its time, from the
several type checks used to apply different effects, the one letter
variables to the the material flags that are still being passed down as
arguments when you can access them from the atom/source arg anyway. It
would be disonhest of me if I went ahead and coded material fishing rods
or whatever fish fuckery with materials without ensuring it won't
further the technical debt the feature currently has.

## Changelog
🆑
refactor: Refactored materials code. report any issue.
add: Cleric maces (The autolathe-printable weapon design from outer
space) can now be made of two different materials.
balance: Buffed cleric maces a little.
fix: toolboxes' stats are now affected by materials again.
/🆑

---------

Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
2024-10-06 21:56:20 +02:00
klorpa
e1bf793264 Spelling and Grammar Fixes (#86022)
## About The Pull Request
Fixes several errors to spelling, grammar, and punctuation.
## Why It's Good For The Game
## Changelog
🆑
spellcheck: fixed a few typos
/🆑
2024-08-23 21:49:46 +02:00
SmArtKar
f985856a09 Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer (#85648)
## About The Pull Request

Added support for remote material insertion type whitelists and utilized
it to allow circuit printers to recycle components. Removing a component
from UI while the circuit has a linked printer will automatically
recycle it.

Also fixed a rogue space appearing when recycling a single item

## Why It's Good For The Game

You literally cannot do anything with components you remove/do not need
anymore so usually they end up littering circuit lab's floors. This
should make developing circuits slightly less annoying.

## Changelog
🆑
qol: Circuit components can now be recycles in circuit printers, and
automatically do so upon being removed if a circuit has a linked printer
spellcheck: Recycling a single item no longer outputs a line with a
rogue space infront of it
/🆑
2024-08-14 13:12:57 +02:00
SyncIt21
a71ecee6f9 Makes the omnitool lathe proof (#84643)
## About The Pull Request
- Fixes #84600

As mentioned in
https://github.com/tgstation/tgstation/issues/84600#issuecomment-2204975628
there is no problem with omnitool & airlock interactions, but just with
the lathe consuming the omnitool.


## Changelog
🆑
fix: Autolathe won't eat the borg omni tool
/🆑
2024-07-05 20:00:25 +02:00
SyncIt21
0a5f2c9a69 Some material container patches (#84553)
## About The Pull Request
- Fixes #84517. material container won't consume the contents of an item
if that item itself is rejected for any reason(lack of mats, not
suitable for redemption etc)
- You can use any storage medium (not just bags, boxes but anything that
has `atom_storage`) to dump stuff into an material container

## Changelog
🆑
fix: material container won't consume the contents of an item if that
item itself is rejected for any reason
qol: you can use any storage medium & not just bags/boxes to dump stuff
into material containers
/🆑
2024-07-03 11:41:50 -04:00
Jacquerel
6596d75edc Gulag Adjustments Two (#82561)
## About The Pull Request

I have received feedback that after the prior changes in #81971, the
gulag is still a little bit too subject to RNG.
The main culprit (as in my previous PR) is Iron being kind of cheap and
the fact that unlike the old Gulag you no longer have any way of
headhunting more valuable materials (everything appears as boulders on
your ore scanner).

My solution to this is wider than the last one of tweaking point values,
but also much simpler:
Just make every boulder you mine be worth the same amount of points
regardless of what is inside of it.

On the average test I made I could comfortably mine about 40-45 boulders
in ten minutes.
We'll make some adjustments to that rather than leaving 40 as the target
number;
Most players upon being teleported to the gulag are going to spend a few
minutes whining and bemoaning their fate instead of getting straight to
work. I had the benefit of being able to make sure my run started as
soon as a storm ended so I wouldn't need any kind of midpoint break. I
was also always the only person playing on my local instance, there
hadn't been any other pesky prisoners before me who had already mined
out all the nearest available deposits. And of course, let us not
forget, I am an MLG master league ss13 player who was surely performing
well above average.

So we'll round that down to: Each boulder is worth 33 points, meaning
you need to collect 31 boulders to complete a 1000 point (roughly ten
minute) sentence.

How do I ensure that every boulder is worth the same amount of points?
Well it's pretty easy.
One boulder = one material sheet. One material sheet = 33 points.
Simple.

"Now Jacquerel", I hear you not saying because you don't want me to know
about this thing you would prefer to do instead of hitting rocks
outside; "if I simply smash all of the tables and microwaves and botany
trays and bed in the gulag I can easily get like 65 sheets of Iron,
which is almost enough to buy the freedom for two entire people!"
Unfortunately I knew you were going to try and do that and the prisoner
point machine will only give you points for material sheets which have
been printed from the material smelter (well, any material smelter
actually but you should probably use the one in the gulag). You'll be
able to tell because if you examine a valid material sheet it will
mention a little maker's mark on it, which is absent in the beat-up iron
that you get from smashing furniture to bits.

Also glass is worth 0 points. Don't waste time digging up that shit. 

As glass has had all of its point value removed, I have added a "work
pit" to the gulag to compensate. You can pull boulders out of this
indefinitely via effort, however it also stamcrits you every time.
It's not very fun to do this, but that's because I would prefer you to
go find the rocks out in the field instead. This is a last resort.
You can do this if there's no boulders left to mine or if you really
really really hate mining and would rather very slowly click on one tile
repeatedly to get your boulders instead.
As a tiny bonus doing this gives workout experience.

This isn't a totally ideal solution but I think it'll do for now.

## Why It's Good For The Game

What we want out of the gulag is:
- Something where officers can vaguely approximate an expected sentence
duration.
- A task that requires players to actually be spending that time doing
something to get out of here.
- Produces at least some amount of useful materials.

In I think roughly that order.
I hope this change accomplishes all three of these in a way that is
somewhat predictable rather than throwing darts at a board.

## Changelog

🆑
balance: Gulag mining has been rebalanced so that every boulder is worth
the same amount of points to mine for a prisoner regardless of what it
contains, and should be more consistent.
add: A vent which boulders can be hauled out of by hand has been added
to the gulag which you can use if there's nothing left to mine. It is
very slow, but at least it gives you a workout...
/🆑
2024-04-18 17:05:06 +02:00
san7890
c403a6eccc Wraps lowertext() to ensure proper stringification. (#82442)
## About The Pull Request

Fixes #82440

This PR just creates a new macro, `LOWER_TEXT()` (yes the irony is not
lost on me) to wrap around all calls of `lowertext()` and ensure that
whatever we input into that proc will be stringified using the `"[]"`
(or `tostring()` for the nerds) operator. very simple.

I also added a linter to enforce this (and prevent all forms of
regression) because I think that machines should do the menial work and
we shouldn't expect maintainers to remember this, let me know if you
disagree. if there is a time when it should be opted out for some
reason, the linter does respect it if you wrap your input with the
`UNLINT()` function.
2024-04-10 12:19:43 -07:00
SyncIt21
600b856323 Indestructible items are properly rejected by material containers (#81487)
## About The Pull Request
- Fixes #81486

Happens only with items that are Indestructible like the pai card, It's
a 2 part fix
- First display error message saying the item was rejected
- If the item is indestructible but was put inside another object like
an bag or anything else, then move the object to turf where this object
was inserted(`context`) & not the ore silo(`parent`) thus fixing the
teleportation bug

## Changelog
🆑
fix: Indestructible items like the pai card don't teleport to the ore
silo when you insert them into silo linked machine & also displays a
message saying it was rejected.
/🆑
2024-02-16 19:59:28 +01:00
SyncIt21
baad899062 Material container drops sheets only on object deconstruct & not destroy. (#81290)
## About The Pull Request
- Fixes #81289

It has nothing to do with `dump_contents()` but with the material
container that drops its materials on `Destroy()` causing side effects.
Now it only drops sheets when an object is deconstructed but not
destroyed.

For this to work properly on all instances we have to ensure
`deconstruct()` is not overridden at least on machines for now, so they
can send `COMSIG_OBJ_DECONSTRUCT` signal. That comes in the next PR

## Changelog
🆑
fix: deleting objects with local material storage(autolathe, drone
dispenser etc) no longer drops sheets, they only drop materials when
deconstructed
/🆑
2024-02-06 22:44:36 +01:00
scriptis
004c4f0b2b spellcheck: iron sheets's what? (#81045)
## About The Pull Request


![image](https://github.com/tgstation/tgstation/assets/12202230/237ce3f1-4c00-4e00-aabc-0b477b0be293)

literally unplayable

replaced with


![image](https://github.com/tgstation/tgstation/assets/12202230/521ddcf2-e512-4141-a4b1-92b833c76d88)


and with an active tone
## Why It's Good For The Game

spelling
## Changelog
🆑
spellcheck: iron sheets's what?
/🆑
2024-01-22 13:10:53 -08:00
Zephyr
13d2dceb31 Minor Autolathe Refactor | Material Dupe-B-Gone (#80839)
## About The Pull Request

Refactors underlying autolathe code, mostly about how it prints items
Items are now printed sequentially
Items now have their custom materials set to the the materials actually
used to create them
Items are now printed based on their design construction time instead of
a default 3.2 seconds per item always
Closes https://github.com/tgstation/tgstation/issues/80755

## Changelog
🆑
fix: Autolathes no longer allow you to duplicate materials at higher
levels of stock parts
qol: Autolathes now show name instead of typepath when selecting a
custom material
qol: Autolathe now print out items one by one instead of waiting for all
of them to print at once
/🆑
2024-01-15 13:35:02 -05:00
Mothblocks
c1d68698fb Micro-optimize qdel by only permitting one parameter (#80628)
Productionizes #80615.

The core optimization is this:

```patch
-	var/hint = to_delete.Destroy(arglist(args.Copy(2))) // Let our friend know they're about to get fucked up.
+	var/hint = to_delete.Destroy(force) // Let our friend know they're about to get fucked up.
```

We avoid a heap allocation in the form of copying the args over to a new
list. A/B testing shows this results in 33% better overtime, and in a
real round shaving off a full second of self time and 0.4 seconds of
overtime--both of these would be doubled in the event this is merged as
the new proc was only being run 50% of the time.
2023-12-28 13:52:44 -08:00
SyncIt21
d36a5af64f Removes material breakdown flags, traits & miscellaneous fixes. (#80389)
## About The Pull Request
1. Removes material breakdown flags i.e. all flags with the format
`BREAKDOWN_XXX`. These flags do nothing, there are no special checks to
transform materials based on these flags, they are passed around just
because certain procs require them for syntax purposes only.

Apparently there were plans to make these flags do something special
from the comment

302247c0d1/code/__DEFINES/construction/material.dm (L43)
But nobody got any ideas for years now. The only special thing we can do
with them now is remove them and reduce code clutter, so let's do that
    
The only flag that ever did something was the
`BREAKDOWN_INCLUDE_ALCHEMY` flag. This only worked when coupled together
with `TRAIT_MAT_TRANSMUTED` trait(which is only used by the reagent
metalgen) and when both this trait & flag are combined together... they
still do nothing

302247c0d1/code/game/atom/atom_materials.dm (L41-L42)
Yup they cancel out each other to prevent returning an empty list, the
traits only job was to prevent materials from being recycled (like why?
what's the benefit of that? nothing) and the flag was meant to bypass
this restriction so both the trait & the flag cancel out each other
therefore doing nothing meaningful. Best remove them both and call it a
day.

2. Fixes an error in displaying number of sheets inserted into a mat
container when that sheet is made up of alloy materials. it would count
as 2 or more because it would take the sum of total material amount
inserted and not the actual sheets. That's fixed now.

3. Remote materials now properly respect the `MATCONTAINER_NO_INSERT`
flag

4. Adds helper proc to insert materials via the remote material
component with proper context

## Changelog
🆑
fix: mat container displays correct number of sheets inserted for alloy
materials.
fix: remote materials now properly respect the `MATCONTAINER_NO_INSERT`
flag.
code: removes material breakdown flags and related traits.
code: adds helper proc to insert materials via the remote material
component with proper context.
/🆑
2023-12-25 02:29:26 +01:00
SyncIt21
8ff1143972 [NO GBP] Fixes runtime in mat container chat display (#80321)
## About The Pull Request
Forgot to format the chat in the right format when items are rejected by
the mat container. Rather than displaying the item is rejected it would
simply runtime & not display anything. That's fixed now

## Changelog
🆑
fix: items that are rejected by the mat container will display the chat
message saying that.
/🆑
2023-12-14 17:08:47 +00:00
SyncIt21
27635e7640 Mat container related refactors & patches (#80164)
## About The Pull Request
**1. Mat container `user_insert()` tweaks**
- Mat container will now skip over an item & its contents if that item
cannot be processed (not suitable for redemption or not an allowed type)
this is not only realistic(if an item has an tough outer shell you can't
crush it to access its contents) but also saves us computation time as
we can skip over contents quickly
- Mat container now properly respects the `MATCONTAINER_SILENT` flag
- You can now hit machines like autolathe, protolathe etc with iron
sheets (or any other material item type those machines accept) when in
combat mode rather than inserting them because it makes sense
- Mat container now has much reduced chat spam as it will sum up all the
items inserted, and the material collected rather than displaying them
individually.
![Screenshot
(365)](https://github.com/tgstation/tgstation/assets/110812394/1ff444c6-cb0d-4a15-bfd6-71b9e8dcce5a)
Much improved readability and overall faster as we do much less
`to_chat()` calls

**2. ORM Tweaks** 
- Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/25329 .

ORM now generates points correctly always, regardless of how the ore is
inserted be it
  
  - Via hand
  - Thrown at the ORM
  - Ore Box
  - Some other bag containing ore

Points will always be generated at a common proc so no more checking
every inlet on how the ore enters the machine. Once the silo receives
the material it will inform the ORM about it, so it does not have to
check itself therefore reducing code bloat.

## Changelog
🆑
fix: ORM will generate points regardless of how the ore enters it.
fix: Machines like autolathe, techfab etc can now be hit with iron
sheets (or any other material item type those machines accept) when in
combat mode rather than inserting them because it makes sense.
fix: Mat container won't display chats fully if the
`MATCONTAINER_SILENT` flag is passed.
refactor: Machines like autolathe, techfab etc now display summed up
material inserts to chats rather than each item individually. Also, will
skip items & its contents if it cannot be processed thus saving time
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2023-12-14 15:12:04 +01:00
Bloop
19233741c4 [NO GBP] Fixes more retrieve typos (#78069)
## About The Pull Request

Continuation of https://github.com/tgstation/tgstation/pull/77946, I
missed quite a few of these it seems.

## Why It's Good For The Game

Stop the spread of these typos!!

## Changelog

Nothing player facing
2023-09-02 16:14:56 +01:00
SyncIt21
c27a90da71 [NO GBP]Refactors how sheets are ejected from mat container (#77945)
## About The Pull Request
As #77936 pointed out an infinite while loop occurs in the recycler.
This was caused due to my recent mat changes as follows.

When the recycler eats up an item. If it found any material inside, it
would attempt to eject any sheets formed from it over here

ed71735fb3/code/game/machinery/recycler.dm (L199)

Inside this proc i first create the sheets in `null space` why is
explained in the comment

ed71735fb3/code/datums/components/material/material_container.dm (L599-L600)

After doing logging & stuff i then would move the sheets back into its
target turf so it could get merged again

ed71735fb3/code/datums/components/material/material_container.dm (L607-L608)

Unfortunately this would trigger `COMSIG_ATOM_ENTERED` signal which the
recycler is hooked onto. The recycler would then eat the newly ejected
sheets again, which would cause more sheets to be ejected, which would
again trigger the signal `COMSIG_ATOM_ENTERED` and you have your
infinite loop.

I did this because i had no clue how to stop the stack from merging when
it got spawned and this was a poor solution, so upon examining the code
i found there is a var to specifically stops stacks from merging

ed71735fb3/code/game/objects/items/stacks/stack.dm (L81)

Yup there is specific param called `merge=TRUE` which allows you to
explicitly stop stacks from merging. I now use this var and manually
merge stacks afterwards without calling `forceMove()` so it doesn't
trigger the recycler anymore which caused the infinite loops.

## Why It's good for the game
Writing checks to see if an object came from null space is weird. It
makes the code difficult to reason with as such situations never happen.
Now it makes sense for an atom to be moved "into" null space for e.g.
when it gets deleted but for an atom to "return back from it" never
happens and you shouldn't be bothered with figuring out how that
happened.

## Changelog
🆑
refactor: sheets are merged in a better way when ejected from machines &
material related stuff
/🆑
2023-08-29 12:46:45 -04:00
Bloop
86f71eb6b7 Fixes a typo (#77946) 2023-08-27 11:23:57 -04:00
SyncIt21
9aed3b6a8f General code maintenance for Mat container related stuff (#77671)
1. Removes `/obj/machinery/ore_silo/proc/remote_attackby()`. This proc
calls `datum/component/material_container/user_insert()` anyway which
performs all the checks necessary for inserting stuff into the ore silo
and `/obj/machinery/ore_silo/proc/remote_attackby()` was just repeating
its code & checks. So now inserting into the ore silo is directly
handled by the mat container without this proxy proc making the
operation slightly faster
2. Removed silo `attackby` code. Same operations can be done via
`screwdriver_act` & `crowbar_act` procs much cleaner
3. The ore silo now hooks onto signals
`COMSIG_MATCONTAINER_ITEM_CONSUMED` and
`COMSIG_MATCONTAINER_SHEETS_RETRIVED` and logs into silo when they are
triggered. This means when you insert/eject sheets from the silo the
connected machine performing the operation no longer has to do the
logging manually thus the proc `silo_log` has been removed from a lot of
places ,reducing overall code size
4. A lot of stuff that use materials from the ore silo follow this
pattern.

i.e. They first use the materials from the silo and then log it via
`silo_log` proc. This code pattern is repeated in a lot of places so
let's just merge these 2 lines with some extra sanity checks into a
single proc inside `remote_materials` itself. That's what was done and
the number of places where you log manually into the silo has been
removed further reducing code size everywhere.
5. Added auto doc & cleaned up some procs

Since logging is now done by the ore silo directly, we need a way to
pass the machine that is inserting items into the silo to the signal
handlers of the ore silo [via the `context` var]. So other code changes
elsewhere is because of this var
2023-08-21 22:23:01 +00:00
SyncIt21
920551d603 [NO GBP]Mat container Final clean-up & patches (#77092)
## About The Pull Request
1. Fixes #77177 
Some things were not connecting to the ore silo round start because the
silo was not initialized yet so it went to local storage. Now it
connects with the ore silo again
3. Removed some unused code in remote materials
4. Protolathe uses `eject_sheets()` defined in remote materials and not
it's own version because that's redundant
5. Don't put the item back in the players hand when inserting it in the
material container cause we haven't even removed it yet
6. `fast_split()` is now even faster & robust and is a global proc
7. Some code cleanup for RHD silo link

## Changelog
🆑
fix: some things not connecting to the ore silo round start
/🆑
2023-07-29 15:36:46 +02:00
SyncIt21
e92ae5b75b Material container & related stuff ui refactors & clean-up (#76220)
## About The Pull Request

**1. Material container clean-up & refactor**
- Replaced `total_amount` var with `total_amount()` proc, this var can
be easily computed by summing up all material amounts rather than
storing it as a var which is tedious to update & keep track of when
materials are added/removed
- Removed unused procs `transer_amt_to()`, `can_insert_amount_mat()`,
and `get_categories()`. These procs are not used anywhere in the
codebase so let's remove them & make some space.
- Callbacks are replaced with signals, the callbacks don't need to be
explicitly garbage collected & having macros & procs marked with
`SIGNAL_HANDLER` makes your intentions more readable & explicit.
- Fixes #76151 
All material adding, removal, checking operations are "Integer"
operations, i.e. the final value is rounded & them made 1 if the final
value is 0 using the macro `OPTIMIZE_COST`[coudn't come up with a better
name]. No more dealing with decimal value materials
The problem was after the protolathe was upgraded with better parts all
the design costs were multiplied with a decimal `efficiency_coeff`
value, this means even though in the UI the cost was displayed as 60
bluespace crystals its actual cost was `60.0001` something in the
backend causing this check for materials to fail & print the error
message.
- Replaced `GetComponent(/datum/component_material_container)` with just
a simple ref to the material container when adding the component, so we
can save some overhead from calling this proc
- Gave all procs a ton of documentation with documentation having
documentation
- Fixes #76506 RCD and other devices that uses the silo link upgrade now
have the correct material usages
- Fixes #72096. It wasn't just a problem with ancient protolathe but
with all machines that used `datum/component/remote_materials` the
problem was remote materials would add an instance of
`datum/remote/material_container` if it wanted to use local storage but
this component would get added before `datum/component/remote_materials`
could be registered i.e. it comes before remote_materials in the
component list. So when the machine is destroyed it will first destroy
`material_container` & then `remote_materials` therefore destroying the
materials before they could get ejected
- Silo link is established when parent is registered with remote
materials raher than adding an external timer which is faster
- Everything that uses a material container will auto eject their sheets
when destroyed
- Moved this & remote materials into its own folder for better
organization


**2. Material UI Changes**
- Removed the x25 & x50 print buttons from the autolathe, now they just
have x5 & x10 buttons like the protolathe, These buttons were of no use
since you could just type the exact amount you want to print in the
`[Max: <some amount>]` side bar. The code to compute these buttons was
just plain right nasty & some of it unused in the UI.
- The material eject button in the material bar does not gray out when
you can eject exactly one sheet
- All material cost are integer values rounded
- Fixes #76253 Exosuit Fabricator sends the material container static
data to the UI so its material bar is not greyed out when there are
sufficient materials to eject
- Component printer material bar sends the material container static
data to the UI so its material bar is not greyed out when there are
sufficient materials to eject
- Autolathe Material bars now display number of sheets available
- Max printable amount of items are now computed & updated correctly in
the UI. They were displaying wrong values & now get updated when items
are printed, materials are removed
- Silo hold actually works now. When a machine is put on hold it calls
this proc

e929cf39cd/code/datums/components/remote_materials.dm (L78-L87)
Notice how the key is `src` so we should be consistent during checking
if a machine is on hold using the same `src` var. But for some reason we
did dumb shit like this

e929cf39cd/code/datums/components/remote_materials.dm (L150-L153)
What is category? Why do we care for the area the machine is in? None of
it made sense so i removed all that junk and just made it check for
`src` like it should
- Removed redundant `removable` & `sheets` var from the material
container ui_data. These vars are unused in the UI
- If an item does not have the required materials then upon clicking
that item you will not get any error message but instead nothing happens

## Changelog
🆑
fix: items can be printed from autolathe & protolathe when the exact
material amounts are present in them after upgrading
fix: max printable amount now shows the correct value & updates when
items are printed, materials are removed in the autolathe & protolathe
fix: component printer material bar is not greyed out when there are
sufficient materials to eject
fix: rcd and other devices that uses the silo link upgrade now have the
correct material usages
fix: silo hold actually works
fix: machines using local storage to hold materials will eject it's
materials as sheets when deconstructed/destroyed
refactor: Autolathe Material bars now display number of sheets available
refactor: printing an item that does not have enough materials will fail
silently with no error messages
refactor: Drone dispenser will eject sheets upon deconstruction
refactor: all things that store materials will auto ejects its sheets(if
there is sufficient material) when destroyed
refactor: inserting an item into the material container will display the
units consumed as sheets not absolute units
refactor: removed x25 & x50 print buttons from the autolathe
2023-07-24 19:47:14 -04:00