From c6736649a493b37463e81ac8379c4ce1b2629652 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Sat, 15 Nov 2025 19:01:52 -0600 Subject: [PATCH] df structure support implement `operator==`, `operator<`, and `std::hash` for `labor_kitchen_interface_food_key` --- library/include/df/custom/.gitignore | 1 + .../hash/labor_kitchen_interface_food_key.h | 16 ++++++++++++++++ .../labor_kitchen_interface_food_key.custom.inc | 11 +++++++++++ 3 files changed, 28 insertions(+) create mode 100644 library/include/df/custom/.gitignore create mode 100644 library/include/df/custom/hash/labor_kitchen_interface_food_key.h create mode 100644 library/include/df/custom/labor_kitchen_interface_food_key.custom.inc diff --git a/library/include/df/custom/.gitignore b/library/include/df/custom/.gitignore new file mode 100644 index 0000000000..96e79c167d --- /dev/null +++ b/library/include/df/custom/.gitignore @@ -0,0 +1 @@ +!*.h diff --git a/library/include/df/custom/hash/labor_kitchen_interface_food_key.h b/library/include/df/custom/hash/labor_kitchen_interface_food_key.h new file mode 100644 index 0000000000..3ca9676725 --- /dev/null +++ b/library/include/df/custom/hash/labor_kitchen_interface_food_key.h @@ -0,0 +1,16 @@ +template<> +struct std::hash { + auto operator()(const labor_kitchen_interface_food_key &a) const -> size_t { + struct thing { + int16_t t; + int16_t st; + int32_t x; + } thing{ + .t = a.type; + .st = a.subtype, + .x = static_cast(a.mat) ^ (static_cast(a.matg)) + }; + + return hash()(bit_cast(thing)); + } + }; diff --git a/library/include/df/custom/labor_kitchen_interface_food_key.custom.inc b/library/include/df/custom/labor_kitchen_interface_food_key.custom.inc new file mode 100644 index 0000000000..59796a69ba --- /dev/null +++ b/library/include/df/custom/labor_kitchen_interface_food_key.custom.inc @@ -0,0 +1,11 @@ + bool operator<(const labor_kitchen_interface_food_key &b) const { + if (type