Files
Yogstation/code/__HELPERS/cmp.dm
TheGamerdk 2e787af654 AI Rework | 2024 edition (#21266)
* fix ui

* oops

* Fixes map bibby broke

* Revert "Fixes map bibby broke"

This reverts commit af1d1c610e.

* e

* Unfucks deltastation

* stuff

* cleans things after bibby

* Fix subcontroller cache

* Fixed APCs and air alarms not working when connected to a subcontroller

* bunch of fixes

* job icon

* tcomms server

Update traffic_control.dm

* make compile

* Update synthetic.dm

* Update synthetic.dm

* Update access.dm

* er

* le runtime

* Update ai_data_core.dm

* le dupe

* wall

* Update decentralized_ai.dm

* Update decentralized_ai.dm

* e

* Update wy_synths.dm

* we do a little trolling

* e

* small cahnges

* more minor changes

* Create conflict_fixer.dmm

* Create conflict_fixer - Kopi.dmm

* minor map cahnges

* broken maps

* oops

* bon

* Update ainetworkinterface.dm

* Update ainetworkinterface.dm

* Update ai.dm

* lol

* light

* fixes

* e

* Update synth_pod.dm

* e

* Update synth_os.dm

* Update objective.dm

* fixes

* Update synthetic.dm

* e

* antag

* tweaks

* e

* Update VRSleeper.js

* e

* Update synth_pod.dm

* Update synth_pod.dm

* 1

* Update synth_pod.dm

* Update synth_os.dm

* Update synthetic.dm

* fixes

* headset and ID go boom

* Update wy_synths.dm

* Update robot_parts.dm

* cremator

* Update communications.dm

* Update synthetic.dm

* no synth control

* Update synthetic.dm

* Update ai_dashboard.dm

* Update miscellaneous.dm

* Update miscellaneous.dm

* Update headset.dm

* Update damage_procs.dm

* Update server_cabinet.dm

* minor fixes

* Update miscellaneous.dm

* Update rack_creator.dm

* Update synthetic.dm

* compiles

* fixes

* brainless

* access request

* cofnlict

* fixes

* controller

* Update yogstation.dme

* Update yogstation.dme

* s

* maps

* Update NtosSynthManager.js

* unrevert this lol

* eat

* Update wy_synths.dm

* sigh

* e

* Update wy_synths.dm

* sigh

* fixed ma

* Update synthetic.dm

* better

* Update ethernet_cable.dm

* Update computer.dm

* Update computer.dm

* i hate this

* Update ai_laws.dm

* Update hardsuit.dm

* initialize

* sigh

* Update synth_os.dm

* Update master_subcontroller.dm

* Update master_subcontroller.dm

* Update synth_requester.dm

* Update synth_requester.dm

* Update room_lockdown.dm

* small fixes

* propa sprite matey

* no latejoin lol

* Update synth_os.dm

* maps fixed

* compiles

* Update brain_item.dm

* fixes

* mappers

* Update hud.dmi

* Update passworddoor.dm

* button puzzle

* mine stuff

* Update yogstation.dme

* le map

* changes

* ye

* Update abandoned_mine.dm

* Update _puzzles.dm

* bingus

* Update abandoned_mine.dm

* maps

* e

* no more quirks

* e

* DMI merge conflict resolver (from TG)

* update yogstation map

* Minor away mission changes

* forgot something

* proper fix

* donut

* maps

* asteroid

* gax

* all maps done

* Update synthetic.dm

* makes it compile

* Update backstabs.dm

* more compile!

* fix this map

* bad item

* remove broken objects

* gax

* Update ticker.dm

* pdas

* omg save the file

* Update networking_machines.dm

* area string moment

* s

* awkward

* revival

* Update ai_dashboard.dm

* fixes

* fixed floopy

* less difficult

* this is important

* Update ai_network.dm

* maps

* fixes the maps

* wHAT

* WHAT

* wet

* start fixing conflicts

* Update yogstation.dme

* start fixing map conflicts

* Update DonutStation.dmm

* updates

* donut conflicts

* update box

* Update IceMeta.dmm

* icon diffs

* Update crew.dm

* Update unsorted.dm

* Update layers.dm

* Update YogStation.dmm

* conflicts

* Update IceMeta.dmm

* will this finally fix it

* Update IceMeta.dmm

* fix all this SHIT

* what

* more shit ugh

* what!

* Update DonutStation.dmm

* Update AsteroidStation.dmm

* Update AsteroidStation.dmm

* Update dead.dm

* Update catwalk_plating.dm

* Update catwalk_plating.dm

---------

Co-authored-by: adamsong <adamsong@users.noreply.github.com>
Co-authored-by: wejengin2 <48154165+wejengin2@users.noreply.github.com>
Co-authored-by: Byemoh <baiomurang@gmail.com>
2024-04-01 16:32:09 -05:00

165 lines
5.0 KiB
Plaintext

/proc/cmp_numeric_dsc(a,b)
return b - a
/proc/cmp_numeric_asc(a,b)
return a - b
/proc/cmp_text_asc(a,b)
return sorttext(b,a)
/proc/cmp_text_dsc(a,b)
return sorttext(a,b)
/proc/cmp_embed_text_asc(a,b)
if(isdatum(a))
a = REF(a)
if(isdatum(b))
b = REF(b)
return sorttext("[b]", "[a]")
/proc/cmp_name_asc(atom/a, atom/b)
return sorttext(b.name, a.name)
/proc/cmp_name_dsc(atom/a, atom/b)
return sorttext(a.name, b.name)
/proc/cmp_username_asc(datum/computer_file/program/pdamessager/a, datum/computer_file/program/pdamessager/b)
return sorttext(b.username, a.username)
/proc/cmp_username_dsc(datum/computer_file/program/pdamessager/a, datum/computer_file/program/pdamessager/b)
return sorttext(a.username, b.username)
GLOBAL_VAR_INIT(cmp_field, "name")
/proc/cmp_records_asc(datum/data/record/a, datum/data/record/b)
return sorttext(b.fields[GLOB.cmp_field], a.fields[GLOB.cmp_field])
/proc/cmp_records_dsc(datum/data/record/a, datum/data/record/b)
return sorttext(a.fields[GLOB.cmp_field], b.fields[GLOB.cmp_field])
/proc/cmp_ai_record_dsc(a, b)
return b["score"] - a["score"]
// Datum cmp with vars is always slower than a specialist cmp proc, use your judgement.
/proc/cmp_datum_numeric_asc(datum/a, datum/b, variable)
return cmp_numeric_asc(a.vars[variable], b.vars[variable])
/proc/cmp_datum_numeric_dsc(datum/a, datum/b, variable)
return cmp_numeric_dsc(a.vars[variable], b.vars[variable])
/proc/cmp_datum_text_asc(datum/a, datum/b, variable)
return sorttext(b.vars[variable], a.vars[variable])
/proc/cmp_datum_text_dsc(datum/a, datum/b, variable)
return sorttext(a.vars[variable], b.vars[variable])
/proc/cmp_ckey_asc(client/a, client/b)
return sorttext(b.ckey, a.ckey)
/proc/cmp_ckey_dsc(client/a, client/b)
return sorttext(a.ckey, b.ckey)
/proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b)
return initial(b.init_order) - initial(a.init_order) //uses initial() so it can be used on types
/proc/cmp_subsystem_display(datum/controller/subsystem/a, datum/controller/subsystem/b)
return sorttext(b.name, a.name)
/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)
return a.priority - b.priority
/proc/cmp_timer(datum/timedevent/a, datum/timedevent/b)
return a.timeToRun - b.timeToRun
/proc/cmp_clientcolour_priority(datum/client_colour/A, datum/client_colour/B)
return B.priority - A.priority
/proc/cmp_clockscripture_priority(datum/clockwork_scripture/A, datum/clockwork_scripture/B)
return initial(A.sort_priority) - initial(B.sort_priority)
/proc/cmp_ruincost_priority(datum/map_template/ruin/A, datum/map_template/ruin/B)
return initial(A.cost) - initial(B.cost)
/proc/cmp_qdel_item_time(datum/qdel_item/A, datum/qdel_item/B)
. = B.hard_delete_time - A.hard_delete_time
if (!.)
. = B.destroy_time - A.destroy_time
if (!.)
. = B.failures - A.failures
if (!.)
. = B.qdels - A.qdels
/proc/cmp_generic_stat_item_time(list/A, list/B)
. = B[STAT_ENTRY_TIME] - A[STAT_ENTRY_TIME]
if (!.)
. = B[STAT_ENTRY_COUNT] - A[STAT_ENTRY_COUNT]
/proc/cmp_profile_avg_time_dsc(list/A, list/B)
return (B[PROFILE_ITEM_TIME]/(B[PROFILE_ITEM_COUNT] || 1)) - (A[PROFILE_ITEM_TIME]/(A[PROFILE_ITEM_COUNT] || 1))
/proc/cmp_profile_time_dsc(list/A, list/B)
return B[PROFILE_ITEM_TIME] - A[PROFILE_ITEM_TIME]
/proc/cmp_profile_count_dsc(list/A, list/B)
return B[PROFILE_ITEM_COUNT] - A[PROFILE_ITEM_COUNT]
/proc/cmp_atom_layer_asc(atom/A,atom/B)
if(A.plane != B.plane)
return A.plane - B.plane
else
return A.layer - B.layer
/proc/cmp_advdisease_resistance_asc(datum/disease/advance/A, datum/disease/advance/B)
return A.totalResistance() - B.totalResistance()
/proc/cmp_quirk_asc(datum/quirk/A, datum/quirk/B)
var/a_sign = SIGN(initial(A.value) * -1)
var/b_sign = SIGN(initial(B.value) * -1)
// Neutral traits go last.
if(a_sign == 0)
a_sign = 2
if(b_sign == 0)
b_sign = 2
var/a_name = initial(A.name)
var/b_name = initial(B.name)
if(a_sign != b_sign)
return a_sign - b_sign
else
return sorttext(b_name, a_name)
/proc/cmp_job_display_asc(datum/job/A, datum/job/B)
return A.display_order - B.display_order
/proc/cmp_department_display_asc(datum/job_department/A, datum/job_department/B)
return A.display_order - B.display_order
/proc/cmp_reagents_asc(datum/reagent/a, datum/reagent/b)
return sorttext(initial(b.name),initial(a.name))
/proc/cmp_mob_realname_dsc(mob/A,mob/B)
return sorttext(A.real_name,B.real_name)
/proc/cmp_typepaths_asc(A, B)
return sorttext("[B]","[A]")
/**
* Sorts crafting recipe requirements before the crafting recipe is inserted into GLOB.crafting_recipes
*
* Prioritises [/datum/reagent] to ensure reagent requirements are always processed first when crafting.
* This prevents any reagent_containers from being consumed before the reagents they contain, which can
* lead to runtimes and item duplication when it happens.
*/
/proc/cmp_crafting_req_priority(A, B)
var/lhs
var/rhs
lhs = ispath(A, /datum/reagent) ? 0 : 1
rhs = ispath(B, /datum/reagent) ? 0 : 1
return lhs - rhs
/proc/cmp_filter_data_priority(list/A, list/B)
return A["priority"] - B["priority"]