2010-04-02 19:52:46 -06:00
|
|
|
/*
|
2011-06-16 15:53:39 -06:00
|
|
|
https://github.com/peterix/dfhack
|
2012-09-29 20:03:37 -06:00
|
|
|
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
2010-04-02 19:52:46 -06:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
|
2011-06-16 15:53:39 -06:00
|
|
|
|
2010-05-26 04:24:45 -06:00
|
|
|
#include "Internal.h"
|
2011-04-10 02:19:15 -06:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <cstring>
|
|
|
|
using namespace std;
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Types.h"
|
|
|
|
#include "modules/Materials.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "MemAccess.h"
|
|
|
|
#include "Error.h"
|
2011-03-18 01:53:59 -06:00
|
|
|
#include "ModuleFactory.h"
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2012-01-03 08:25:55 -07:00
|
|
|
#include "MiscUtils.h"
|
|
|
|
|
|
|
|
#include "df/world.h"
|
2012-01-05 11:04:05 -07:00
|
|
|
#include "df/ui.h"
|
2012-01-03 08:25:55 -07:00
|
|
|
#include "df/item.h"
|
|
|
|
#include "df/creature_raw.h"
|
2012-01-21 09:12:26 -07:00
|
|
|
#include "df/caste_raw.h"
|
|
|
|
#include "df/body_part_raw.h"
|
2012-01-03 08:25:55 -07:00
|
|
|
#include "df/historical_figure.h"
|
|
|
|
|
2012-01-05 11:04:05 -07:00
|
|
|
#include "df/job_item.h"
|
2012-01-03 08:25:55 -07:00
|
|
|
#include "df/job_material_category.h"
|
2012-01-10 06:23:37 -07:00
|
|
|
#include "df/dfhack_material_category.h"
|
2012-01-03 08:25:55 -07:00
|
|
|
#include "df/matter_state.h"
|
2012-01-04 07:46:39 -07:00
|
|
|
#include "df/material_vec_ref.h"
|
2012-01-21 09:12:26 -07:00
|
|
|
#include "df/builtin_mats.h"
|
|
|
|
|
|
|
|
#include "df/descriptor_color.h"
|
|
|
|
#include "df/descriptor_pattern.h"
|
|
|
|
#include "df/descriptor_shape.h"
|
2012-01-03 08:25:55 -07:00
|
|
|
|
2012-01-21 12:24:38 -07:00
|
|
|
#include "df/physical_attribute_type.h"
|
|
|
|
#include "df/mental_attribute_type.h"
|
2012-01-26 21:54:26 -07:00
|
|
|
#include <df/color_modifier_raw.h>
|
2012-01-21 12:24:38 -07:00
|
|
|
|
2010-04-02 19:52:46 -06:00
|
|
|
using namespace DFHack;
|
2012-01-03 08:25:55 -07:00
|
|
|
using namespace df::enums;
|
2012-01-21 18:24:58 -07:00
|
|
|
|
2012-01-21 09:12:26 -07:00
|
|
|
using df::global::world;
|
2012-01-21 18:24:58 -07:00
|
|
|
using df::global::ui;
|
2012-01-03 08:25:55 -07:00
|
|
|
|
|
|
|
bool MaterialInfo::decode(df::item *item)
|
|
|
|
{
|
|
|
|
if (!item)
|
2012-01-04 07:46:39 -07:00
|
|
|
return decode(-1);
|
2012-01-03 08:25:55 -07:00
|
|
|
else
|
2012-01-04 07:46:39 -07:00
|
|
|
return decode(item->getActualMaterial(), item->getActualMaterialIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::decode(const df::material_vec_ref &vr, int idx)
|
|
|
|
{
|
2012-04-20 03:30:37 -06:00
|
|
|
if (size_t(idx) >= vr.mat_type.size() || size_t(idx) >= vr.mat_index.size())
|
2012-01-04 07:46:39 -07:00
|
|
|
return decode(-1);
|
|
|
|
else
|
|
|
|
return decode(vr.mat_type[idx], vr.mat_index[idx]);
|
2012-01-03 08:25:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::decode(int16_t type, int32_t index)
|
|
|
|
{
|
|
|
|
this->type = type;
|
|
|
|
this->index = index;
|
|
|
|
|
|
|
|
material = NULL;
|
|
|
|
mode = Builtin; subtype = 0;
|
|
|
|
inorganic = NULL; plant = NULL; creature = NULL;
|
|
|
|
figure = NULL;
|
|
|
|
|
2012-01-24 04:36:30 -07:00
|
|
|
if (type < 0) {
|
|
|
|
mode = None;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-21 18:24:58 -07:00
|
|
|
df::world_raws &raws = world->raws;
|
2012-01-03 08:25:55 -07:00
|
|
|
|
2012-04-20 03:30:37 -06:00
|
|
|
if (size_t(type) >= sizeof(raws.mat_table.builtin)/sizeof(void*))
|
2012-01-03 08:25:55 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
material = raws.mat_table.builtin[type];
|
|
|
|
}
|
|
|
|
else if (type == 0)
|
|
|
|
{
|
|
|
|
mode = Inorganic;
|
|
|
|
inorganic = df::inorganic_raw::find(index);
|
|
|
|
if (!inorganic)
|
|
|
|
return false;
|
|
|
|
material = &inorganic->material;
|
|
|
|
}
|
|
|
|
else if (type < CREATURE_BASE)
|
|
|
|
{
|
|
|
|
material = raws.mat_table.builtin[type];
|
|
|
|
}
|
|
|
|
else if (type < FIGURE_BASE)
|
|
|
|
{
|
|
|
|
mode = Creature;
|
|
|
|
subtype = type-CREATURE_BASE;
|
|
|
|
creature = df::creature_raw::find(index);
|
2012-04-20 03:30:37 -06:00
|
|
|
if (!creature || size_t(subtype) >= creature->material.size())
|
2012-01-03 08:25:55 -07:00
|
|
|
return false;
|
|
|
|
material = creature->material[subtype];
|
|
|
|
}
|
|
|
|
else if (type < PLANT_BASE)
|
|
|
|
{
|
|
|
|
mode = Creature;
|
|
|
|
subtype = type-FIGURE_BASE;
|
|
|
|
figure = df::historical_figure::find(index);
|
|
|
|
if (!figure)
|
|
|
|
return false;
|
|
|
|
creature = df::creature_raw::find(figure->race);
|
2012-04-20 03:30:37 -06:00
|
|
|
if (!creature || size_t(subtype) >= creature->material.size())
|
2012-01-03 08:25:55 -07:00
|
|
|
return false;
|
|
|
|
material = creature->material[subtype];
|
|
|
|
}
|
|
|
|
else if (type < END_BASE)
|
|
|
|
{
|
|
|
|
mode = Plant;
|
|
|
|
subtype = type-PLANT_BASE;
|
|
|
|
plant = df::plant_raw::find(index);
|
2012-04-20 03:30:37 -06:00
|
|
|
if (!plant || size_t(subtype) >= plant->material.size())
|
2012-01-03 08:25:55 -07:00
|
|
|
return false;
|
|
|
|
material = plant->material[subtype];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
material = raws.mat_table.builtin[type];
|
|
|
|
}
|
|
|
|
|
|
|
|
return (material != NULL);
|
|
|
|
}
|
|
|
|
|
2012-01-08 09:02:12 -07:00
|
|
|
bool MaterialInfo::find(const std::string &token)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
std::vector<std::string> items;
|
|
|
|
split_string(&items, token, ":");
|
2012-04-06 09:56:19 -06:00
|
|
|
return find(items);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::find(const std::vector<std::string> &items)
|
|
|
|
{
|
|
|
|
if (items.empty())
|
|
|
|
return false;
|
2012-01-08 09:02:12 -07:00
|
|
|
|
2012-01-24 04:36:30 -07:00
|
|
|
if (items[0] == "INORGANIC" && items.size() > 1)
|
2012-01-08 09:02:12 -07:00
|
|
|
return findInorganic(vector_get(items,1));
|
|
|
|
if (items[0] == "CREATURE_MAT" || items[0] == "CREATURE")
|
|
|
|
return findCreature(vector_get(items,1), vector_get(items,2));
|
|
|
|
if (items[0] == "PLANT_MAT" || items[0] == "PLANT")
|
|
|
|
return findPlant(vector_get(items,1), vector_get(items,2));
|
|
|
|
|
|
|
|
if (items.size() == 1)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
if (findBuiltin(items[0]))
|
|
|
|
return true;
|
|
|
|
if (findInorganic(items[0]))
|
2012-01-03 08:25:55 -07:00
|
|
|
return true;
|
2012-01-09 05:20:17 -07:00
|
|
|
if (findPlant(items[0], ""))
|
|
|
|
return true;
|
2012-01-03 08:25:55 -07:00
|
|
|
}
|
2012-01-08 09:02:12 -07:00
|
|
|
else if (items.size() == 2)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
if (findPlant(items[0], items[1]))
|
2012-01-03 08:25:55 -07:00
|
|
|
return true;
|
2012-01-08 09:02:12 -07:00
|
|
|
if (findCreature(items[0], items[1]))
|
2012-01-03 08:25:55 -07:00
|
|
|
return true;
|
|
|
|
}
|
2012-01-08 09:02:12 -07:00
|
|
|
|
2012-01-03 08:25:55 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::findBuiltin(const std::string &token)
|
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
if (token.empty())
|
|
|
|
return decode(-1);
|
2012-01-09 05:20:17 -07:00
|
|
|
|
|
|
|
if (token == "NONE") {
|
|
|
|
decode(-1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-21 18:24:58 -07:00
|
|
|
df::world_raws &raws = world->raws;
|
2012-01-03 08:25:55 -07:00
|
|
|
for (int i = 1; i < NUM_BUILTIN; i++)
|
2012-04-06 09:56:19 -06:00
|
|
|
{
|
|
|
|
auto obj = raws.mat_table.builtin[i];
|
|
|
|
if (obj && obj->id == token)
|
2012-01-03 08:25:55 -07:00
|
|
|
return decode(i, -1);
|
2012-04-06 09:56:19 -06:00
|
|
|
}
|
2012-01-03 08:25:55 -07:00
|
|
|
return decode(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::findInorganic(const std::string &token)
|
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
if (token.empty())
|
|
|
|
return decode(-1);
|
2012-01-09 05:20:17 -07:00
|
|
|
|
|
|
|
if (token == "NONE") {
|
|
|
|
decode(0, -1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-21 18:24:58 -07:00
|
|
|
df::world_raws &raws = world->raws;
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < raws.inorganics.size(); i++)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
|
|
|
df::inorganic_raw *p = raws.inorganics[i];
|
|
|
|
if (p->id == token)
|
|
|
|
return decode(0, i);
|
|
|
|
}
|
|
|
|
return decode(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::findPlant(const std::string &token, const std::string &subtoken)
|
|
|
|
{
|
2012-01-09 05:20:17 -07:00
|
|
|
if (token.empty())
|
2012-01-08 09:02:12 -07:00
|
|
|
return decode(-1);
|
2012-01-21 18:24:58 -07:00
|
|
|
df::world_raws &raws = world->raws;
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < raws.plants.all.size(); i++)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
|
|
|
df::plant_raw *p = raws.plants.all[i];
|
|
|
|
if (p->id != token)
|
|
|
|
continue;
|
|
|
|
|
2012-01-09 05:20:17 -07:00
|
|
|
// As a special exception, return the structural material with empty subtoken
|
|
|
|
if (subtoken.empty())
|
|
|
|
return decode(p->material_defs.type_basic_mat, p->material_defs.idx_basic_mat);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t j = 0; j < p->material.size(); j++)
|
2012-01-03 08:25:55 -07:00
|
|
|
if (p->material[j]->id == subtoken)
|
|
|
|
return decode(PLANT_BASE+j, i);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return decode(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MaterialInfo::findCreature(const std::string &token, const std::string &subtoken)
|
|
|
|
{
|
2012-01-08 09:02:12 -07:00
|
|
|
if (token.empty() || subtoken.empty())
|
|
|
|
return decode(-1);
|
2012-01-21 18:24:58 -07:00
|
|
|
df::world_raws &raws = world->raws;
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < raws.creatures.all.size(); i++)
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
|
|
|
df::creature_raw *p = raws.creatures.all[i];
|
|
|
|
if (p->creature_id != token)
|
|
|
|
continue;
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t j = 0; j < p->material.size(); j++)
|
2012-01-03 08:25:55 -07:00
|
|
|
if (p->material[j]->id == subtoken)
|
|
|
|
return decode(CREATURE_BASE+j, i);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return decode(-1);
|
|
|
|
}
|
|
|
|
|
2012-09-17 11:15:51 -06:00
|
|
|
bool MaterialInfo::findProduct(df::material *material, const std::string &name)
|
|
|
|
{
|
|
|
|
if (!material || name.empty())
|
|
|
|
return decode(-1);
|
|
|
|
|
|
|
|
auto &pids = material->reaction_product.id;
|
|
|
|
for (size_t i = 0; i < pids.size(); i++)
|
|
|
|
if ((*pids[i]) == name)
|
|
|
|
return decode(material->reaction_product.material, i);
|
|
|
|
|
|
|
|
return decode(-1);
|
|
|
|
}
|
|
|
|
|
2012-01-24 04:36:30 -07:00
|
|
|
std::string MaterialInfo::getToken()
|
2012-01-03 08:25:55 -07:00
|
|
|
{
|
2012-01-24 04:36:30 -07:00
|
|
|
if (isNone())
|
2012-01-03 08:25:55 -07:00
|
|
|
return "NONE";
|
2012-01-24 04:36:30 -07:00
|
|
|
|
|
|
|
if (!material)
|
|
|
|
return stl_sprintf("INVALID:%d:%d", type, index);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case Builtin:
|
2012-07-04 09:31:41 -06:00
|
|
|
if (material->id == "COAL") {
|
|
|
|
if (index == 0)
|
|
|
|
return "COAL:COKE";
|
|
|
|
else if (index == 1)
|
|
|
|
return "COAL:CHARCOAL";
|
|
|
|
}
|
2012-10-24 11:49:30 -06:00
|
|
|
return material->id + ":NONE";
|
2012-01-24 04:36:30 -07:00
|
|
|
case Inorganic:
|
|
|
|
return "INORGANIC:" + inorganic->id;
|
|
|
|
case Creature:
|
|
|
|
return "CREATURE:" + creature->creature_id + ":" + material->id;
|
|
|
|
case Plant:
|
|
|
|
return "PLANT:" + plant->id + ":" + material->id;
|
|
|
|
default:
|
|
|
|
return stl_sprintf("INVALID_MODE:%d:%d", type, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MaterialInfo::toString(uint16_t temp, bool named)
|
|
|
|
{
|
|
|
|
if (isNone())
|
|
|
|
return "any";
|
|
|
|
|
2012-01-03 08:25:55 -07:00
|
|
|
if (!material)
|
2012-01-24 04:36:30 -07:00
|
|
|
return stl_sprintf("INVALID:%d:%d", type, index);
|
2012-01-03 08:25:55 -07:00
|
|
|
|
|
|
|
df::matter_state state = matter_state::Solid;
|
|
|
|
if (temp >= material->heat.melting_point)
|
|
|
|
state = matter_state::Liquid;
|
|
|
|
if (temp >= material->heat.boiling_point)
|
|
|
|
state = matter_state::Gas;
|
|
|
|
|
|
|
|
std::string name = material->state_name[state];
|
|
|
|
if (!material->prefix.empty())
|
|
|
|
name = material->prefix + " " + name;
|
|
|
|
|
|
|
|
if (named && figure)
|
|
|
|
name += stl_sprintf(" of HF %d", index);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
df::craft_material_class MaterialInfo::getCraftClass()
|
|
|
|
{
|
|
|
|
if (!material)
|
|
|
|
return craft_material_class::None;
|
|
|
|
|
|
|
|
if (type == 0 && index == -1)
|
|
|
|
return craft_material_class::Stone;
|
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(material_flags, i)
|
|
|
|
{
|
|
|
|
df::craft_material_class ccv = ENUM_ATTR(material_flags, type, i);
|
|
|
|
if (ccv == craft_material_class::None)
|
|
|
|
continue;
|
|
|
|
if (material->flags.is_set(i))
|
|
|
|
return ccv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return craft_material_class::None;
|
|
|
|
}
|
|
|
|
|
2012-01-05 11:04:05 -07:00
|
|
|
bool MaterialInfo::isAnyCloth()
|
|
|
|
{
|
|
|
|
using namespace df::enums::material_flags;
|
|
|
|
|
|
|
|
return material && (
|
|
|
|
material->flags.is_set(THREAD_PLANT) ||
|
|
|
|
material->flags.is_set(SILK) ||
|
|
|
|
material->flags.is_set(YARN)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-03 08:25:55 -07:00
|
|
|
bool MaterialInfo::matches(const df::job_material_category &cat)
|
|
|
|
{
|
|
|
|
if (!material)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
#define TEST(bit,flag) if (cat.bits.bit && material->flags.is_set(flag)) return true;
|
2012-01-10 06:23:37 -07:00
|
|
|
|
|
|
|
using namespace df::enums::material_flags;
|
2012-01-03 08:25:55 -07:00
|
|
|
TEST(plant, STRUCTURAL_PLANT_MAT);
|
|
|
|
TEST(wood, WOOD);
|
|
|
|
TEST(cloth, THREAD_PLANT);
|
|
|
|
TEST(silk, SILK);
|
|
|
|
TEST(leather, LEATHER);
|
|
|
|
TEST(bone, BONE);
|
|
|
|
TEST(shell, SHELL);
|
|
|
|
TEST(wood2, WOOD);
|
|
|
|
TEST(soap, SOAP);
|
|
|
|
TEST(tooth, TOOTH);
|
|
|
|
TEST(horn, HORN);
|
|
|
|
TEST(pearl, PEARL);
|
|
|
|
TEST(yarn, YARN);
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2012-01-10 06:23:37 -07:00
|
|
|
bool MaterialInfo::matches(const df::dfhack_material_category &cat)
|
|
|
|
{
|
|
|
|
if (!material)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
df::job_material_category mc;
|
|
|
|
mc.whole = cat.whole;
|
|
|
|
if (matches(mc))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
using namespace df::enums::material_flags;
|
|
|
|
using namespace df::enums::inorganic_flags;
|
|
|
|
TEST(metal, IS_METAL);
|
|
|
|
TEST(stone, IS_STONE);
|
|
|
|
if (cat.bits.stone && type == 0 && index == -1)
|
|
|
|
return true;
|
|
|
|
if (cat.bits.sand && inorganic && inorganic->flags.is_set(SOIL_SAND))
|
|
|
|
return true;
|
|
|
|
TEST(glass, IS_GLASS);
|
|
|
|
if (cat.bits.clay && linear_index(material->reaction_product.id, std::string("FIRED_MAT")) >= 0)
|
|
|
|
return true;
|
2012-01-11 09:50:38 -07:00
|
|
|
return false;
|
2012-01-10 06:23:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef TEST
|
|
|
|
|
2012-01-05 11:04:05 -07:00
|
|
|
bool MaterialInfo::matches(const df::job_item &item)
|
|
|
|
{
|
2012-01-10 06:23:37 -07:00
|
|
|
if (!isValid()) return false;
|
2012-01-05 11:04:05 -07:00
|
|
|
|
|
|
|
df::job_item_flags1 ok1, mask1;
|
|
|
|
getMatchBits(ok1, mask1);
|
|
|
|
|
|
|
|
df::job_item_flags2 ok2, mask2;
|
|
|
|
getMatchBits(ok2, mask2);
|
|
|
|
|
|
|
|
df::job_item_flags3 ok3, mask3;
|
|
|
|
getMatchBits(ok3, mask3);
|
|
|
|
|
2012-01-09 05:20:17 -07:00
|
|
|
return bits_match(item.flags1.whole, ok1.whole, mask1.whole) &&
|
|
|
|
bits_match(item.flags2.whole, ok2.whole, mask2.whole) &&
|
|
|
|
bits_match(item.flags3.whole, ok3.whole, mask3.whole);
|
2012-01-05 11:04:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MaterialInfo::getMatchBits(df::job_item_flags1 &ok, df::job_item_flags1 &mask)
|
|
|
|
{
|
|
|
|
ok.whole = mask.whole = 0;
|
|
|
|
if (!isValid()) return;
|
|
|
|
|
2012-01-21 18:24:58 -07:00
|
|
|
#define MAT_FLAG(name) material->flags.is_set(material_flags::name)
|
2012-01-05 11:04:05 -07:00
|
|
|
#define FLAG(field, name) (field && field->flags.is_set(name))
|
|
|
|
#define TEST(bit, check) \
|
|
|
|
mask.bits.bit = true; ok.bits.bit = !!(check);
|
|
|
|
|
|
|
|
bool structural = MAT_FLAG(STRUCTURAL_PLANT_MAT);
|
|
|
|
|
|
|
|
TEST(millable, structural && FLAG(plant, plant_raw_flags::MILL));
|
|
|
|
TEST(sharpenable, MAT_FLAG(IS_STONE));
|
|
|
|
TEST(distillable, structural && FLAG(plant, plant_raw_flags::DRINK));
|
|
|
|
TEST(processable, structural && FLAG(plant, plant_raw_flags::THREAD));
|
2012-01-09 05:20:17 -07:00
|
|
|
TEST(bag, isAnyCloth() || MAT_FLAG(LEATHER));
|
2012-01-05 11:04:05 -07:00
|
|
|
TEST(cookable, MAT_FLAG(EDIBLE_COOKED));
|
|
|
|
TEST(extract_bearing_plant, structural && FLAG(plant, plant_raw_flags::EXTRACT_STILL_VIAL));
|
|
|
|
TEST(extract_bearing_fish, false);
|
|
|
|
TEST(extract_bearing_vermin, false);
|
|
|
|
TEST(processable_to_vial, structural && FLAG(plant, plant_raw_flags::EXTRACT_VIAL));
|
|
|
|
TEST(processable_to_bag, structural && FLAG(plant, plant_raw_flags::LEAVES));
|
|
|
|
TEST(processable_to_barrel, structural && FLAG(plant, plant_raw_flags::EXTRACT_BARREL));
|
|
|
|
TEST(solid, !(MAT_FLAG(ALCOHOL_PLANT) ||
|
|
|
|
MAT_FLAG(ALCOHOL_CREATURE) ||
|
|
|
|
MAT_FLAG(LIQUID_MISC_PLANT) ||
|
|
|
|
MAT_FLAG(LIQUID_MISC_CREATURE) ||
|
|
|
|
MAT_FLAG(LIQUID_MISC_OTHER)));
|
|
|
|
TEST(tameable_vermin, false);
|
2012-01-09 05:20:17 -07:00
|
|
|
TEST(sharpenable, MAT_FLAG(IS_STONE));
|
2012-01-05 11:04:05 -07:00
|
|
|
TEST(milk, linear_index(material->reaction_product.id, std::string("CHEESE_MAT")) >= 0);
|
|
|
|
//04000000 - "milkable" - vtable[107],1,1
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaterialInfo::getMatchBits(df::job_item_flags2 &ok, df::job_item_flags2 &mask)
|
|
|
|
{
|
|
|
|
ok.whole = mask.whole = 0;
|
|
|
|
if (!isValid()) return;
|
|
|
|
|
|
|
|
bool is_cloth = isAnyCloth();
|
|
|
|
|
|
|
|
TEST(dye, MAT_FLAG(IS_DYE));
|
|
|
|
TEST(dyeable, is_cloth);
|
|
|
|
TEST(dyed, is_cloth);
|
|
|
|
TEST(sewn_imageless, is_cloth);
|
|
|
|
TEST(glass_making, MAT_FLAG(CRYSTAL_GLASSABLE));
|
|
|
|
|
|
|
|
TEST(fire_safe, material->heat.melting_point > 11000);
|
|
|
|
TEST(magma_safe, material->heat.melting_point > 12000);
|
2012-03-03 15:03:35 -07:00
|
|
|
TEST(deep_material, FLAG(inorganic, inorganic_flags::SPECIAL));
|
2012-10-20 10:31:45 -06:00
|
|
|
TEST(non_economic, !inorganic || !(ui && vector_get(ui->economic_stone, index)));
|
2012-01-05 11:04:05 -07:00
|
|
|
|
|
|
|
TEST(plant, plant);
|
|
|
|
TEST(silk, MAT_FLAG(SILK));
|
|
|
|
TEST(leather, MAT_FLAG(LEATHER));
|
|
|
|
TEST(bone, MAT_FLAG(BONE));
|
|
|
|
TEST(shell, MAT_FLAG(SHELL));
|
|
|
|
TEST(totemable, false);
|
|
|
|
TEST(horn, MAT_FLAG(HORN));
|
|
|
|
TEST(pearl, MAT_FLAG(PEARL));
|
|
|
|
TEST(soap, MAT_FLAG(SOAP));
|
|
|
|
TEST(ivory_tooth, MAT_FLAG(TOOTH));
|
|
|
|
//TEST(hair_wool, MAT_FLAG(YARN));
|
|
|
|
TEST(yarn, MAT_FLAG(YARN));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaterialInfo::getMatchBits(df::job_item_flags3 &ok, df::job_item_flags3 &mask)
|
|
|
|
{
|
|
|
|
ok.whole = mask.whole = 0;
|
|
|
|
if (!isValid()) return;
|
|
|
|
|
|
|
|
TEST(hard, MAT_FLAG(ITEMS_HARD));
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef MAT_FLAG
|
|
|
|
#undef FLAG
|
|
|
|
#undef TEST
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2012-01-08 09:02:12 -07:00
|
|
|
bool DFHack::parseJobMaterialCategory(df::job_material_category *cat, const std::string &token)
|
|
|
|
{
|
|
|
|
cat->whole = 0;
|
|
|
|
|
|
|
|
std::vector<std::string> items;
|
|
|
|
split_string(&items, toLower(token), ",", true);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < items.size(); i++)
|
2012-01-08 09:02:12 -07:00
|
|
|
{
|
2012-03-17 02:52:22 -06:00
|
|
|
if (!set_bitfield_field(cat, items[i], 1))
|
2012-01-08 09:02:12 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-10 06:23:37 -07:00
|
|
|
bool DFHack::parseJobMaterialCategory(df::dfhack_material_category *cat, const std::string &token)
|
|
|
|
{
|
|
|
|
cat->whole = 0;
|
|
|
|
|
|
|
|
std::vector<std::string> items;
|
|
|
|
split_string(&items, toLower(token), ",", true);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < items.size(); i++)
|
2012-01-10 06:23:37 -07:00
|
|
|
{
|
2012-03-17 02:52:22 -06:00
|
|
|
if (!set_bitfield_field(cat, items[i], 1))
|
2012-01-10 06:23:37 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-17 07:02:43 -06:00
|
|
|
Module* DFHack::createMaterials()
|
2011-03-18 01:53:59 -06:00
|
|
|
{
|
2011-06-17 07:02:43 -06:00
|
|
|
return new Materials();
|
2011-03-18 01:53:59 -06:00
|
|
|
}
|
|
|
|
|
2010-04-18 13:30:02 -06:00
|
|
|
|
2011-06-17 07:02:43 -06:00
|
|
|
Materials::Materials()
|
2010-04-04 16:48:19 -06:00
|
|
|
{
|
|
|
|
}
|
2011-07-20 07:18:50 -06:00
|
|
|
|
2010-04-18 16:32:50 -06:00
|
|
|
Materials::~Materials()
|
|
|
|
{
|
|
|
|
}
|
2010-06-24 23:11:26 -06:00
|
|
|
|
|
|
|
bool Materials::Finish()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
t_matgloss::t_matgloss()
|
|
|
|
{
|
|
|
|
fore = 0;
|
|
|
|
back = 0;
|
|
|
|
bright = 0;
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
wall_tile = 0;
|
|
|
|
boulder_tile = 0;
|
|
|
|
}
|
2011-07-21 19:00:56 -06:00
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
bool t_matglossInorganic::isOre()
|
|
|
|
{
|
2011-07-21 19:00:56 -06:00
|
|
|
if (!ore_chances.empty())
|
|
|
|
return true;
|
|
|
|
if (!strand_chances.empty())
|
|
|
|
return true;
|
2011-07-20 07:18:50 -06:00
|
|
|
return false;
|
|
|
|
}
|
2011-09-23 22:48:06 -06:00
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
bool t_matglossInorganic::isGem()
|
|
|
|
{
|
2011-09-23 22:48:06 -06:00
|
|
|
return is_gem;
|
2011-07-20 07:18:50 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorganic)
|
2010-04-02 19:52:46 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.inorganics.size();
|
2010-04-28 15:48:50 -06:00
|
|
|
inorganic.clear();
|
|
|
|
inorganic.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2010-04-28 15:48:50 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
df::inorganic_raw *orig = world->raws.inorganics[i];
|
2011-07-20 07:18:50 -06:00
|
|
|
t_matglossInorganic mat;
|
2012-01-21 09:12:26 -07:00
|
|
|
mat.id = orig->id;
|
|
|
|
mat.name = orig->material.stone_name;
|
|
|
|
|
|
|
|
mat.ore_types = orig->metal_ore.mat_index;
|
|
|
|
mat.ore_chances = orig->metal_ore.probability;
|
|
|
|
mat.strand_types = orig->thread_metal.mat_index;
|
|
|
|
mat.strand_chances = orig->thread_metal.probability;
|
|
|
|
mat.value = orig->material.material_value;
|
|
|
|
mat.wall_tile = orig->material.tile;
|
|
|
|
mat.boulder_tile = orig->material.item_symbol;
|
|
|
|
mat.fore = orig->material.basic_color[0];
|
|
|
|
mat.bright = orig->material.basic_color[1];
|
|
|
|
mat.is_gem = orig->material.flags.is_set(material_flags::IS_GEM);
|
2010-04-28 15:48:50 -06:00
|
|
|
inorganic.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-04 02:10:00 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
bool Materials::CopyOrganicMaterials (std::vector<t_matgloss> & organic)
|
2010-04-04 02:10:00 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.plants.all.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
organic.clear();
|
|
|
|
organic.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
|
|
|
t_matgloss mat;
|
|
|
|
mat.id = world->raws.plants.all[i]->id;
|
|
|
|
organic.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-04 02:10:00 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
bool Materials::CopyWoodMaterials (std::vector<t_matgloss> & tree)
|
2010-04-04 02:10:00 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.plants.trees.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
tree.clear();
|
|
|
|
tree.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
|
|
|
t_matgloss mat;
|
|
|
|
mat.id = world->raws.plants.trees[i]->id;
|
|
|
|
tree.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-04 02:10:00 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
bool Materials::CopyPlantMaterials (std::vector<t_matgloss> & plant)
|
2010-04-04 02:10:00 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.plants.bushes.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
plant.clear();
|
|
|
|
plant.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
|
|
|
t_matgloss mat;
|
|
|
|
mat.id = world->raws.plants.bushes[i]->id;
|
|
|
|
plant.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-02 19:52:46 -06:00
|
|
|
}
|
2010-04-18 13:30:02 -06:00
|
|
|
|
2010-04-28 10:09:32 -06:00
|
|
|
bool Materials::ReadCreatureTypes (void)
|
2010-04-04 04:29:56 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.creatures.all.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
race.clear();
|
|
|
|
race.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
|
|
|
t_matgloss mat;
|
|
|
|
mat.id = world->raws.creatures.all[i]->creature_id;
|
|
|
|
race.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-04 04:29:56 -06:00
|
|
|
}
|
2010-04-14 14:12:02 -06:00
|
|
|
|
2010-04-30 09:42:31 -06:00
|
|
|
bool Materials::ReadOthers(void)
|
|
|
|
{
|
2010-08-12 13:38:15 -06:00
|
|
|
other.clear();
|
2012-01-21 18:24:58 -07:00
|
|
|
FOR_ENUM_ITEMS(builtin_mats, i)
|
2010-08-12 13:38:15 -06:00
|
|
|
{
|
|
|
|
t_matglossOther mat;
|
2012-01-21 09:12:26 -07:00
|
|
|
mat.id = world->raws.mat_table.builtin[i]->id;
|
2010-08-12 13:38:15 -06:00
|
|
|
other.push_back(mat);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-30 09:42:31 -06:00
|
|
|
}
|
|
|
|
|
2010-04-28 10:09:32 -06:00
|
|
|
bool Materials::ReadDescriptorColors (void)
|
2010-04-20 10:25:52 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.language.colors.size();
|
2010-05-25 15:52:04 -06:00
|
|
|
|
|
|
|
color.clear();
|
|
|
|
if(size == 0)
|
|
|
|
return false;
|
|
|
|
color.reserve(size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2010-05-25 15:52:04 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
df::descriptor_color *c = world->raws.language.colors[i];
|
2010-05-25 15:52:04 -06:00
|
|
|
t_descriptor_color col;
|
2012-01-21 09:12:26 -07:00
|
|
|
col.id = c->id;
|
|
|
|
col.name = c->name;
|
|
|
|
col.red = c->red;
|
|
|
|
col.green = c->green;
|
|
|
|
col.blue = c->blue;
|
2010-05-25 15:52:04 -06:00
|
|
|
color.push_back(col);
|
|
|
|
}
|
2012-01-21 09:12:26 -07:00
|
|
|
|
|
|
|
size = world->raws.language.patterns.size();
|
|
|
|
alldesc.clear();
|
|
|
|
alldesc.reserve(size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size;i++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
|
|
|
t_matgloss mat;
|
|
|
|
mat.id = world->raws.language.patterns[i]->id;
|
|
|
|
alldesc.push_back(mat);
|
|
|
|
}
|
2010-05-25 15:52:04 -06:00
|
|
|
return true;
|
2010-04-20 10:25:52 -06:00
|
|
|
}
|
|
|
|
|
2010-04-28 10:09:32 -06:00
|
|
|
bool Materials::ReadCreatureTypesEx (void)
|
2010-04-14 14:12:02 -06:00
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t size = world->raws.creatures.all.size();
|
2010-04-28 10:09:32 -06:00
|
|
|
raceEx.clear();
|
|
|
|
raceEx.reserve (size);
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < size; i++)
|
2010-04-14 14:12:02 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
df::creature_raw *cr = world->raws.creatures.all[i];
|
2010-04-14 14:12:02 -06:00
|
|
|
t_creaturetype mat;
|
2012-01-21 09:12:26 -07:00
|
|
|
mat.id = cr->creature_id;
|
|
|
|
mat.tile_character = cr->creature_tile;
|
|
|
|
mat.tilecolor.fore = cr->color[0];
|
|
|
|
mat.tilecolor.back = cr->color[1];
|
|
|
|
mat.tilecolor.bright = cr->color[2];
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t sizecas = cr->caste.size();
|
|
|
|
for (size_t j = 0; j < sizecas;j++)
|
2010-04-14 14:12:02 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
df::caste_raw *ca = cr->caste[j];
|
2010-05-05 05:48:01 -06:00
|
|
|
/* caste name */
|
2010-04-14 14:12:02 -06:00
|
|
|
t_creaturecaste caste;
|
2012-01-21 09:12:26 -07:00
|
|
|
caste.id = ca->caste_id;
|
|
|
|
caste.singular = ca->caste_name[0];
|
|
|
|
caste.plural = ca->caste_name[1];
|
|
|
|
caste.adjective = ca->caste_name[2];
|
2012-01-26 21:54:26 -07:00
|
|
|
|
2012-01-21 09:12:26 -07:00
|
|
|
// color mod reading
|
|
|
|
// Caste + offset > color mod vector
|
2012-01-26 21:54:26 -07:00
|
|
|
auto & colorings = ca->color_modifiers;
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t sizecolormod = colorings.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
caste.ColorModifier.resize(sizecolormod);
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t k = 0; k < sizecolormod;k++)
|
2010-05-05 05:48:01 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
// color mod [0] -> color list
|
2012-01-26 21:54:26 -07:00
|
|
|
auto & indexes = colorings[k]->color_indexes;
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t sizecolorlist = indexes.size();
|
2012-01-21 09:12:26 -07:00
|
|
|
caste.ColorModifier[k].colorlist.resize(sizecolorlist);
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t l = 0; l < sizecolorlist; l++)
|
2012-01-26 21:54:26 -07:00
|
|
|
caste.ColorModifier[k].colorlist[l] = indexes[l];
|
2012-01-21 09:12:26 -07:00
|
|
|
// color mod [color_modifier_part_offset] = string part
|
2012-01-26 21:54:26 -07:00
|
|
|
caste.ColorModifier[k].part = colorings[k]->part;
|
|
|
|
caste.ColorModifier[k].startdate = colorings[k]->start_date;
|
|
|
|
caste.ColorModifier[k].enddate = colorings[k]->end_date;
|
2011-03-24 19:31:27 -06:00
|
|
|
}
|
2012-01-26 21:54:26 -07:00
|
|
|
|
2012-01-21 09:12:26 -07:00
|
|
|
// body parts
|
|
|
|
caste.bodypart.empty();
|
2012-01-31 09:55:38 -07:00
|
|
|
size_t sizebp = ca->body_info.body_parts.size();
|
|
|
|
for (size_t k = 0; k < sizebp; k++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
2012-01-27 10:17:50 -07:00
|
|
|
df::body_part_raw *bp = ca->body_info.body_parts[k];
|
2012-01-21 09:12:26 -07:00
|
|
|
t_bodypart part;
|
2012-05-26 04:49:27 -06:00
|
|
|
part.id = bp->token;
|
|
|
|
part.category = bp->category;
|
2012-01-21 09:12:26 -07:00
|
|
|
caste.bodypart.push_back(part);
|
|
|
|
}
|
2012-02-29 17:52:13 -07:00
|
|
|
using namespace df::enums::mental_attribute_type;
|
|
|
|
using namespace df::enums::physical_attribute_type;
|
2012-01-21 12:24:38 -07:00
|
|
|
for (int32_t k = 0; k < 7; k++)
|
2012-01-21 09:12:26 -07:00
|
|
|
{
|
2012-02-29 17:52:13 -07:00
|
|
|
auto & physical = ca->attributes.phys_att_range;
|
|
|
|
caste.strength[k] = physical[STRENGTH][k];
|
|
|
|
caste.agility[k] = physical[AGILITY][k];
|
|
|
|
caste.toughness[k] = physical[TOUGHNESS][k];
|
|
|
|
caste.endurance[k] = physical[ENDURANCE][k];
|
|
|
|
caste.recuperation[k] = physical[RECUPERATION][k];
|
|
|
|
caste.disease_resistance[k] = physical[DISEASE_RESISTANCE][k];
|
|
|
|
|
|
|
|
auto & mental = ca->attributes.ment_att_range;
|
|
|
|
caste.analytical_ability[k] = mental[ANALYTICAL_ABILITY][k];
|
|
|
|
caste.focus[k] = mental[FOCUS][k];
|
|
|
|
caste.willpower[k] = mental[WILLPOWER][k];
|
|
|
|
caste.creativity[k] = mental[CREATIVITY][k];
|
|
|
|
caste.intuition[k] = mental[INTUITION][k];
|
|
|
|
caste.patience[k] = mental[PATIENCE][k];
|
|
|
|
caste.memory[k] = mental[MEMORY][k];
|
|
|
|
caste.linguistic_ability[k] = mental[LINGUISTIC_ABILITY][k];
|
|
|
|
caste.spatial_sense[k] = mental[SPATIAL_SENSE][k];
|
|
|
|
caste.musicality[k] = mental[MUSICALITY][k];
|
|
|
|
caste.kinesthetic_sense[k] = mental[KINESTHETIC_SENSE][k];
|
|
|
|
caste.empathy[k] = mental[EMPATHY][k];
|
|
|
|
caste.social_awareness[k] = mental[SOCIAL_AWARENESS][k];
|
2010-05-05 05:48:01 -06:00
|
|
|
}
|
2010-04-14 14:12:02 -06:00
|
|
|
mat.castes.push_back(caste);
|
|
|
|
}
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t j = 0; j < world->raws.creatures.all[i]->material.size(); j++)
|
2010-05-25 15:52:04 -06:00
|
|
|
{
|
|
|
|
t_creatureextract extract;
|
2012-01-21 09:12:26 -07:00
|
|
|
extract.id = world->raws.creatures.all[i]->material[j]->id;
|
2010-05-25 15:52:04 -06:00
|
|
|
mat.extract.push_back(extract);
|
|
|
|
}
|
2010-04-28 10:09:32 -06:00
|
|
|
raceEx.push_back(mat);
|
2010-04-14 14:12:02 -06:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-08-04 16:41:31 -06:00
|
|
|
bool Materials::ReadAllMaterials(void)
|
2010-04-28 10:09:32 -06:00
|
|
|
{
|
2011-08-04 16:41:31 -06:00
|
|
|
bool ok = true;
|
|
|
|
ok &= this->ReadCreatureTypes();
|
|
|
|
ok &= this->ReadCreatureTypesEx();
|
|
|
|
ok &= this->ReadDescriptorColors();
|
|
|
|
ok &= this->ReadOthers();
|
|
|
|
return ok;
|
2010-04-28 10:09:32 -06:00
|
|
|
}
|
2010-04-28 10:24:27 -06:00
|
|
|
|
2011-04-12 05:59:07 -06:00
|
|
|
std::string Materials::getDescription(const t_material & mat)
|
2010-04-28 10:24:27 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
MaterialInfo mi(mat.material, mat.index);
|
|
|
|
if (mi.creature)
|
|
|
|
return mi.creature->creature_id + " " + mi.material->id;
|
|
|
|
else if (mi.plant)
|
|
|
|
return mi.plant->id + " " + mi.material->id;
|
2010-05-02 04:50:51 -06:00
|
|
|
else
|
2012-01-21 09:12:26 -07:00
|
|
|
return mi.material->id;
|
2010-04-28 10:24:27 -06:00
|
|
|
}
|
|
|
|
|
2012-01-21 09:12:26 -07:00
|
|
|
// type of material only so we know which vector to retrieve
|
|
|
|
// This is completely worthless now
|
2011-04-12 05:59:07 -06:00
|
|
|
std::string Materials::getType(const t_material & mat)
|
2010-07-15 05:57:45 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
MaterialInfo mi(mat.material, mat.index);
|
|
|
|
switch (mi.mode)
|
2011-04-11 14:13:06 -06:00
|
|
|
{
|
2012-01-21 09:12:26 -07:00
|
|
|
case MaterialInfo::Builtin:
|
|
|
|
return "builtin";
|
|
|
|
case MaterialInfo::Inorganic:
|
|
|
|
return "inorganic";
|
|
|
|
case MaterialInfo::Creature:
|
|
|
|
return "creature";
|
|
|
|
case MaterialInfo::Plant:
|
|
|
|
return "plant";
|
|
|
|
default:
|
|
|
|
return "unknown";
|
2011-04-11 14:13:06 -06:00
|
|
|
}
|
2011-07-20 07:18:50 -06:00
|
|
|
}
|