GMM correctly adjusts ordered materials with proper feedback (#92009)

## About The Pull Request
- Fixes #82910

Cargo now adjusts the material market quantity & prices when the shuttle
is called from the order console itself instead of adjusting it after
the shuttle arrives 1 minute later. This has 2 implications
- If the market crashes 1 minute after calling the shuttle i.e when it
arrives, the ordered quantities are not affected because it retrieved
those sheets from the market at the time of calling the shuttle from the
order console
- If some orders could not be satisfied because there were not enough
materials at the time of calling the shuttle then instead of arriving
with an empty crate a detailed summary is displayed explaining which
orders could not be delivered & why, even cancelling the order if needed

**a) Order adjusted**
![Screenshot
(489)](https://github.com/user-attachments/assets/39aa8746-8848-4415-a23d-c0a7cbd433db)

**b) Order adjusted & cancelled**
![Screenshot
(491)](https://github.com/user-attachments/assets/7a800f55-47d9-4d22-b871-c67858c8329a)

**c) Order fully cancelled**
![Screenshot
(492)](https://github.com/user-attachments/assets/e3231156-aaa8-44f5-b50a-2a8bd34d9064)


## Changelog
🆑
fix: ordering materials from the GMM won't result in empty crates & will
display detailed feedback if there weren't enough sheets in the market
/🆑
This commit is contained in:
SyncIt21
2025-07-11 15:00:35 -04:00
committed by GitHub
parent b4f8c5f1fa
commit 177dc73236
3 changed files with 41 additions and 17 deletions
@@ -169,6 +169,21 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
for(var/datum/supply_order/spawning_order in SSshuttle.shopping_list)
if(!empty_turfs.len)
break
//adjust galactic material market based on the ordered quantities
var/datum/supply_pack/custom/minerals/sheets = astype(spawning_order.pack)
if(!isnull(sheets))
var/list/orders_adjusted = sheets.adjust_market()
if(orders_adjusted.len)
var/datum/bank_account/paying_for_this = spawning_order.paying_account || SSeconomy.get_dep_account(ACCOUNT_CAR)
if(!sheets.contains.len) //no sheets in the market at all
paying_for_this.bank_card_talk("Order #[spawning_order.id] ([spawning_order.pack.name]) was cancelled due to insufficient materials in the market!.")
SSshuttle.shopping_list -= spawning_order
clean_up_orders += spawning_order
continue
//some of the orders were adjusted(quantity changed or cancelled) according to the market
paying_for_this.bank_card_talk("Order #[spawning_order.id] ([spawning_order.pack.name]) had the following orders adjusted<br>[orders_adjusted.Join("<br>")]<br>.")
price = spawning_order.get_final_cost()
// department orders EARN money for cargo, not the other way around