From 72376d1d3586a2b79a3e22e9f1bb94f9fe8fcb73 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 20 Apr 2010 18:25:52 +0200 Subject: [PATCH] Color descriptors handling --- dfhack/include/modules/Materials.h | 11 +++++++++++ dfhack/modules/Materials.cpp | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dfhack/include/modules/Materials.h b/dfhack/include/modules/Materials.h index f190e8737..f4073c1ca 100644 --- a/dfhack/include/modules/Materials.h +++ b/dfhack/include/modules/Materials.h @@ -17,6 +17,15 @@ namespace DFHack char name[128]; //this is the name displayed ingame }; + struct t_descriptor_color + { + char id[128]; // id in the raws + float r; + float v; + float b; + char name[128]; //displayed name + }; + struct t_matglossPlant { char id[128]; //the id in the raws @@ -67,6 +76,8 @@ namespace DFHack // TODO: maybe move to creatures? bool ReadCreatureTypes (std::vector & output); bool ReadCreatureTypesEx (vector & creatures); + + bool ReadDescriptorColors(std::vector & output); private: class Private; Private* d; diff --git a/dfhack/modules/Materials.cpp b/dfhack/modules/Materials.cpp index 1505a6796..e0e8da8a7 100644 --- a/dfhack/modules/Materials.cpp +++ b/dfhack/modules/Materials.cpp @@ -223,6 +223,26 @@ bool Materials::ReadCreatureTypes (vector & creatures) return true; } +bool Materials::ReadDescriptorColors (vector & color) +{ + Process * p = d->owner; + DfVector p_colors (p, p->getDescriptor()->getAddress ("descriptor_colors_vector")); + uint32_t size = p_colors.size(); + + color.clear(); + color.reserve(size); + for (uint32_t i = 0; i < size;i++) + { + t_descriptor_color col; + p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_rawname"), col.id, 128); + p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_name"), col.name, 128); + col.r = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_r") ); + col.v = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_v") ); + col.b = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_b") ); + color.push_back(col); + } +} + bool Materials::ReadCreatureTypesEx (vector & creatures) { Process *p = d->owner;