From f5911a14a6833a7b80597cb233918512f828e8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 12 Apr 2011 13:59:07 +0200 Subject: [PATCH] Some const correctness, re-enabled job printing in the creature dump tool. --- library/include/dfhack/modules/Materials.h | 4 ++-- library/modules/Items.cpp | 9 +-------- library/modules/Materials.cpp | 4 ++-- tools/examples/creaturedump.cpp | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/library/include/dfhack/modules/Materials.h b/library/include/dfhack/modules/Materials.h index 07e8c40f4..3407aeb06 100644 --- a/library/include/dfhack/modules/Materials.h +++ b/library/include/dfhack/modules/Materials.h @@ -174,8 +174,8 @@ namespace DFHack void ReadAllMaterials(void); - std::string getType(t_material & mat); - std::string getDescription(t_material & mat); + std::string getType(const t_material & mat); + std::string getDescription(const t_material & mat); private: class Private; Private* d; diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index d62aadec9..817a87a01 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -485,12 +485,7 @@ std::string Items::getItemClass(int32_t index) std::string Items::getItemDescription(const dfh_item & item, Materials * Materials) { - /* - DFHack::t_item item; std::string out; - - if(!this->getItemData(itemptr, item)) - return "??"; switch(item.quality) { case 0: break; @@ -504,7 +499,5 @@ std::string Items::getItemDescription(const dfh_item & item, Materials * Materia out.append(Materials->getDescription(item.matdesc)); out.append(" "); out.append(this->getItemClass(item.matdesc.itemType)); - */ - //return out; - return getItemClass(item.matdesc.itemType); + return out; } diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 2a7ecf917..d1bc8840c 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -479,7 +479,7 @@ void Materials::ReadAllMaterials(void) this->ReadOthers(); } -std::string Materials::getDescription(t_material & mat) +std::string Materials::getDescription(const t_material & mat) { std::string out; int32_t typeC; @@ -542,7 +542,7 @@ std::string Materials::getDescription(t_material & mat) } //type of material only so we know which vector to retrieve -std::string Materials::getType(t_material & mat) +std::string Materials::getType(const t_material & mat) { if((mat.subIndex<419) || (mat.subIndex>618)) { diff --git a/tools/examples/creaturedump.cpp b/tools/examples/creaturedump.cpp index c8e660ed7..e22760388 100644 --- a/tools/examples/creaturedump.cpp +++ b/tools/examples/creaturedump.cpp @@ -197,12 +197,12 @@ void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature) { cout << ", custom profession: " << creature.custom_profession; } - /* + if(creature.current_job.active) { cout << ", current job: " << mem->getJob(creature.current_job.jobId); } - */ + cout << endl; dayoflife = creature.birth_year*12*28 + creature.birth_time/1200; cout << "Born on the year " << creature.birth_year << ", month " << (creature.birth_time/1200/28) << ", day " << ((creature.birth_time/1200) % 28 + 1) << ", " << dayoflife << " days lived." << endl;