constify some MaterialInfo methods

develop
Myk Taylor 2023-03-05 18:16:49 -08:00
parent d07864e5bb
commit 0562dc5234
No known key found for this signature in database
2 changed files with 15 additions and 15 deletions

@ -139,25 +139,25 @@ namespace DFHack
std::string getToken() const; std::string getToken() const;
std::string toString(uint16_t temp = 10015, bool named = true) const; std::string toString(uint16_t temp = 10015, bool named = true) const;
bool isAnyCloth(); bool isAnyCloth() const;
void getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &mask); void getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &mask) const;
void getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &mask); void getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &mask) const;
void getMatchBits(df::job_item_flags3 &ok, df::job_item_flags3 &mask); void getMatchBits(df::job_item_flags3 &ok, df::job_item_flags3 &mask) const;
df::craft_material_class getCraftClass(); df::craft_material_class getCraftClass();
bool matches(const MaterialInfo &mat) bool matches(const MaterialInfo &mat) const
{ {
if (!mat.isValid()) return true; if (!mat.isValid()) return true;
return (type == mat.type) && return (type == mat.type) &&
(mat.index == -1 || index == mat.index); (mat.index == -1 || index == mat.index);
} }
bool matches(const df::job_material_category &cat); bool matches(const df::job_material_category &cat) const;
bool matches(const df::dfhack_material_category &cat); bool matches(const df::dfhack_material_category &cat) const;
bool matches(const df::job_item &item, bool matches(const df::job_item &item,
df::item_type itype = df::item_type::NONE); df::item_type itype = df::item_type::NONE) const;
}; };
DFHACK_EXPORT bool parseJobMaterialCategory(df::job_material_category *cat, const std::string &token); DFHACK_EXPORT bool parseJobMaterialCategory(df::job_material_category *cat, const std::string &token);

@ -376,7 +376,7 @@ df::craft_material_class MaterialInfo::getCraftClass()
return craft_material_class::None; return craft_material_class::None;
} }
bool MaterialInfo::isAnyCloth() bool MaterialInfo::isAnyCloth() const
{ {
using namespace df::enums::material_flags; using namespace df::enums::material_flags;
@ -387,7 +387,7 @@ bool MaterialInfo::isAnyCloth()
); );
} }
bool MaterialInfo::matches(const df::job_material_category &cat) bool MaterialInfo::matches(const df::job_material_category &cat) const
{ {
if (!material) if (!material)
return false; return false;
@ -416,7 +416,7 @@ bool MaterialInfo::matches(const df::job_material_category &cat)
return false; return false;
} }
bool MaterialInfo::matches(const df::dfhack_material_category &cat) bool MaterialInfo::matches(const df::dfhack_material_category &cat) const
{ {
if (!material) if (!material)
return false; return false;
@ -444,7 +444,7 @@ bool MaterialInfo::matches(const df::dfhack_material_category &cat)
#undef TEST #undef TEST
bool MaterialInfo::matches(const df::job_item &item, df::item_type itype) bool MaterialInfo::matches(const df::job_item &item, df::item_type itype) const
{ {
if (!isValid()) return false; if (!isValid()) return false;
@ -465,7 +465,7 @@ bool MaterialInfo::matches(const df::job_item &item, df::item_type itype)
bits_match(item.flags3.whole, ok3.whole, mask3.whole); bits_match(item.flags3.whole, ok3.whole, mask3.whole);
} }
void MaterialInfo::getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &mask) void MaterialInfo::getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &mask) const
{ {
ok.whole = mask.whole = 0; ok.whole = mask.whole = 0;
if (!isValid()) return; if (!isValid()) return;
@ -500,7 +500,7 @@ void MaterialInfo::getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &ma
//04000000 - "milkable" - vtable[107],1,1 //04000000 - "milkable" - vtable[107],1,1
} }
void MaterialInfo::getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &mask) void MaterialInfo::getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &mask) const
{ {
ok.whole = mask.whole = 0; ok.whole = mask.whole = 0;
if (!isValid()) return; if (!isValid()) return;
@ -538,7 +538,7 @@ void MaterialInfo::getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &ma
TEST(yarn, MAT_FLAG(YARN)); TEST(yarn, MAT_FLAG(YARN));
} }
void MaterialInfo::getMatchBits(df::job_item_flags3 &ok, df::job_item_flags3 &mask) void MaterialInfo::getMatchBits(df::job_item_flags3 &ok, df::job_item_flags3 &mask) const
{ {
ok.whole = mask.whole = 0; ok.whole = mask.whole = 0;
if (!isValid()) return; if (!isValid()) return;