diff --git a/ContentLoader.cpp b/ContentLoader.cpp index 3f7429a1..4c24dd80 100644 --- a/ContentLoader.cpp +++ b/ContentLoader.cpp @@ -20,6 +20,7 @@ #include "df/entity_position_raw.h" #include "df/entity_raw.h" #include "df/historical_entity.h" +#include "df/inorganic_raw.h" #include "df/itemdef.h" #include "df/itemdef_armorst.h" #include "df/itemdef_glovesst.h" @@ -29,6 +30,7 @@ #include "df/itemdef_shoesst.h" #include "df/itemdef_weaponst.h" #include "df/material.h" +#include "df/plant_raw.h" #include "df/tissue_style_raw.h" #include "df/world.h" @@ -328,17 +330,17 @@ bool ContentLoader::parseCreatureContent(TiXmlElement* elemRoot ) bool ContentLoader::parseShrubContent(TiXmlElement* elemRoot ) { - return addSingleVegetationConfig( elemRoot, &shrubConfigs, organic ); + return addSingleVegetationConfig( elemRoot, &shrubConfigs ); } bool ContentLoader::parseTreeContent(TiXmlElement* elemRoot ) { - return addSingleVegetationConfig( elemRoot, &treeConfigs, organic ); + return addSingleVegetationConfig( elemRoot, &treeConfigs ); } bool ContentLoader::parseGrassContent(TiXmlElement* elemRoot ) { - return addSingleVegetationConfig( elemRoot, &grassConfigs, organic ); + return addSingleVegetationConfig( elemRoot, &grassConfigs ); } bool ContentLoader::parseTerrainContent(TiXmlElement* elemRoot ) @@ -420,19 +422,12 @@ char getAnimFrames(const char* framestring) int lookupMaterialIndex(int matType, const char* strValue) { - auto& contentLoader = stonesenseState.contentLoader; - auto& ssConfig = stonesenseState.ssConfig; - // for appropriate elements, look up subtype - if (matType == INORGANIC && !ssConfig.skipInorganicMats) { - return lookupIndexedType(strValue, contentLoader->inorganic); - } else if (matType == WOOD && !ssConfig.skipOrganicMats) { - return lookupIndexedType(strValue, contentLoader->organic); - } else if (matType == PLANT && !ssConfig.skipOrganicMats) { - return lookupIndexedType(strValue, contentLoader->organic); - } else if (matType == PLANTCLOTH && !ssConfig.skipOrganicMats) { - return lookupIndexedType(strValue, contentLoader->organic); - } else if (matType == LEATHER && !ssConfig.skipCreatureTypes) { + if (matType == INORGANIC) { + return lookupIndexedType(strValue, df::global::world->raws.inorganics.all, &df::inorganic_raw::id); + } else if (matType == WOOD || matType == PLANT || matType == PLANTCLOTH) { + return lookupIndexedType(strValue, df::global::world->raws.plants.all, &df::plant_raw::id); + } else if (matType == LEATHER) { return lookupIndexedType(strValue, df::global::world->raws.creatures.all, &df::creature_raw::creature_id); } else { //maybe allow some more in later @@ -546,59 +541,27 @@ using DFHack::t_matgloss; const char *lookupMaterialName(int matType,int matIndex) { - auto& contentLoader = stonesenseState.contentLoader; - auto& ssConfig = stonesenseState.ssConfig; - if (matIndex < 0) { return NULL; } - vector* typeVector; - // for appropriate elements, look up subtype - if ((matType == INORGANIC) && (!ssConfig.skipInorganicMats)) { - if(size_t(matIndex) < contentLoader->inorganic.size()) { - return contentLoader->inorganic[matIndex].id.c_str(); - } else { - return NULL; - } - } - else if (((matType == WOOD) || (matType == PLANT)) && (!ssConfig.skipOrganicMats)) { - typeVector=&(contentLoader->organic); - } else if ((matType == PLANTCLOTH) && (!ssConfig.skipOrganicMats)) { - typeVector=&(contentLoader->organic); + + if (matType == INORGANIC) { + return (df::global::world->raws.inorganics.all)[matIndex]->id.c_str(); + } else if (matType == WOOD || matType == PLANT || matType == PLANTCLOTH) { + return (df::global::world->raws.plants.all)[matIndex]->name.c_str(); } else if (matType == LEATHER) { - if(!ssConfig.skipCreatureTypes) { - return (df::global::world->raws.creatures.all)[matIndex]->creature_id.c_str(); - } else { - return NULL; - } + return (df::global::world->raws.creatures.all)[matIndex]->creature_id.c_str(); } else { - //maybe allow some more in later - return NULL; - } - if (size_t(matIndex) >= typeVector->size()) { return NULL; } - return (*typeVector)[matIndex].id.c_str(); } const char *lookupTreeName(int matIndex) { - auto& contentLoader = stonesenseState.contentLoader; - auto& ssConfig = stonesenseState.ssConfig; - - if(ssConfig.skipOrganicMats) { - return NULL; - } if (matIndex < 0) { return NULL; } - vector* typeVector; - // for appropriate elements, look up subtype - typeVector=&(contentLoader->organic); - if (size_t(matIndex) >= typeVector->size()) { - return NULL; - } - return (*typeVector)[matIndex].id.c_str(); + return (df::global::world->raws.plants.all)[matIndex]->name.c_str();; } const char * lookupFormName(int formType) diff --git a/ContentLoader.h b/ContentLoader.h index ba81330c..a3c877cd 100644 --- a/ContentLoader.h +++ b/ContentLoader.h @@ -131,8 +131,6 @@ class ContentLoader std::vector professionStrings; std::map custom_workshop_types; - std::vector organic; - std::vector inorganic; uint32_t currentTick = 0; uint32_t currentYear = 0; diff --git a/GameConfiguration.h b/GameConfiguration.h index 64f1c633..f570fd70 100644 --- a/GameConfiguration.h +++ b/GameConfiguration.h @@ -44,11 +44,8 @@ struct GameConfiguration { bool skipCreatureTypesEx; bool skipDescriptorColors; bool skipBuildings; - bool skipVegetation; bool skipConstructions; bool skipMaps; - bool skipInorganicMats; - bool skipOrganicMats; //following are threading stuff ALLEGRO_COND* readCond; diff --git a/GroundMaterialConfiguration.cpp b/GroundMaterialConfiguration.cpp index d619bc15..54a74bd4 100644 --- a/GroundMaterialConfiguration.cpp +++ b/GroundMaterialConfiguration.cpp @@ -38,15 +38,6 @@ TerrainConfiguration::TerrainConfiguration() //dont really care about the rest of the sprite right now. } -void DumpInorganicMaterialNamesToDisk() -{ - std::ofstream fp{ std::filesystem::path { "dump.txt"} }; - auto& contentLoader = stonesenseState.contentLoader; - for (uint32_t j = 0; j < contentLoader->inorganic.size(); j++) { - fp << j << ':' << contentLoader->inorganic[j].id << '\n'; - } -} - void TerrainMaterialConfiguration::updateSprite(int j, c_sprite& sprite, int x) { if (defaultSprite[j].second == INVALID_INDEX || defaultSprite[j].second > x) diff --git a/GroundMaterialConfiguration.h b/GroundMaterialConfiguration.h index f04f87ec..4107b423 100644 --- a/GroundMaterialConfiguration.h +++ b/GroundMaterialConfiguration.h @@ -68,4 +68,3 @@ class TerrainConfiguration bool addSingleTerrainConfig( TiXmlElement* elemRoot); void flushTerrainConfig(std::vector>& config); -void DumpInorganicMaterialNamesToDisk(); diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index 0d3e4094..94d5c354 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -13,6 +13,7 @@ #include "df/color_modifier_raw.h" #include "df/descriptor_color.h" #include "df/descriptor_pattern.h" +#include "df/global_objects.h" #include "df/itemdef_ammost.h" #include "df/itemdef_armorst.h" #include "df/itemdef_foodst.h" @@ -28,6 +29,7 @@ #include "df/itemdef_trapcompst.h" #include "df/itemdef_weaponst.h" #include "df/material.h" +#include "df/plant_raw.h" #include "df/unit.h" #include "df/world.h" @@ -681,7 +683,7 @@ void c_sprite::set_by_xml(TiXmlElement *elemSprite) if (idstr == NULL || idstr[0] == 0) { grasstype = INVALID_INDEX; } else { - grasstype = lookupIndexedType(idstr, stonesenseState.contentLoader->organic); + grasstype = lookupIndexedType(idstr, df::global::world->raws.plants.all, &df::plant_raw::id); } //find the item type diff --git a/VegetationConfiguration.cpp b/VegetationConfiguration.cpp index fd9a9efb..6ea07b97 100644 --- a/VegetationConfiguration.cpp +++ b/VegetationConfiguration.cpp @@ -6,6 +6,7 @@ #include "ContentLoader.h" #include "SpriteObjects.h" +#include "df/global_objects.h" #include "tinyxml.h" VegetationConfiguration::VegetationConfiguration(int gameID, c_tile_tree &tree, bool live, bool grown) : @@ -20,7 +21,7 @@ VegetationConfiguration::~VegetationConfiguration(void) { } -bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vector>*vegetationConfigs, std::vector& plantNames) +bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vector>*vegetationConfigs) { int basefile = -1; @@ -38,7 +39,7 @@ bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vectorAttribute("gameID"); int gameID = INVALID_INDEX; if (idstr && idstr[0]) { - gameID = lookupIndexedType(idstr,plantNames); + gameID = lookupIndexedType(idstr, df::global::world->raws.plants.all, &df::plant_raw::id); if (gameID == INVALID_INDEX) { contentWarning("No matching plant type",elemTree); continue; diff --git a/VegetationConfiguration.h b/VegetationConfiguration.h index 6e771da2..4b8eed4f 100644 --- a/VegetationConfiguration.h +++ b/VegetationConfiguration.h @@ -16,5 +16,5 @@ class VegetationConfiguration }; -bool addSingleVegetationConfig(TiXmlElement* elemRoot, std::vector>* vegetationConfigs, std::vector& plantNames); +bool addSingleVegetationConfig(TiXmlElement* elemRoot, std::vector>* vegetationConfigs); c_tile_tree * getVegetationTree(std::vector>& vegetationConfigs, int index, bool live, bool grown);