Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 17 additions & 54 deletions ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<t_matgloss>* 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<t_matgloss>* 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)
Expand Down
2 changes: 0 additions & 2 deletions ContentLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ class ContentLoader

std::vector<std::string> professionStrings;
std::map <uint32_t, std::string> custom_workshop_types;
std::vector<DFHack::t_matgloss> organic;
std::vector<DFHack::t_matglossInorganic> inorganic;

uint32_t currentTick = 0;
uint32_t currentYear = 0;
Expand Down
3 changes: 0 additions & 3 deletions GameConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ struct GameConfiguration {
bool skipCreatureTypesEx;
bool skipDescriptorColors;
bool skipBuildings;
bool skipVegetation;
bool skipConstructions;
Comment thread
ctrlaltmilk marked this conversation as resolved.
bool skipMaps;
bool skipInorganicMats;
bool skipOrganicMats;

//following are threading stuff
ALLEGRO_COND* readCond;
Expand Down
9 changes: 0 additions & 9 deletions GroundMaterialConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion GroundMaterialConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ class TerrainConfiguration
bool addSingleTerrainConfig( TiXmlElement* elemRoot);

void flushTerrainConfig(std::vector<std::unique_ptr<TerrainConfiguration>>& config);
void DumpInorganicMaterialNamesToDisk();
4 changes: 3 additions & 1 deletion SpriteObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions VegetationConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand All @@ -20,7 +21,7 @@ VegetationConfiguration::~VegetationConfiguration(void)
{
}

bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vector<std::unique_ptr<VegetationConfiguration>>*vegetationConfigs, std::vector<DFHack::t_matgloss>& plantNames)
bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vector<std::unique_ptr<VegetationConfiguration>>*vegetationConfigs)
{
int basefile = -1;

Expand All @@ -38,7 +39,7 @@ bool addSingleVegetationConfig( TiXmlElement* elemRoot, std::vector<std::unique_
const char* idstr = elemTree->Attribute("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;
Expand Down
2 changes: 1 addition & 1 deletion VegetationConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class VegetationConfiguration
};


bool addSingleVegetationConfig(TiXmlElement* elemRoot, std::vector<std::unique_ptr<VegetationConfiguration>>* vegetationConfigs, std::vector<DFHack::t_matgloss>& plantNames);
bool addSingleVegetationConfig(TiXmlElement* elemRoot, std::vector<std::unique_ptr<VegetationConfiguration>>* vegetationConfigs);
c_tile_tree * getVegetationTree(std::vector<std::unique_ptr<VegetationConfiguration>>& vegetationConfigs, int index, bool live, bool grown);
Loading