Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Vedder <vedder@mbits.info>2022-05-04 12:46:32 +0300
committerStephan Vedder <vedder@mbits.info>2022-05-04 12:46:32 +0300
commitb8ef10d11c9da540cd3478b70fcf931e6f534ed9 (patch)
treee18fee3928e3b952b3e9f305234d00c52cd7283e
parent17f92b6ae884fad50612ac7d15135804cba8fb96 (diff)
Allow to disable DDS image search
-rw-r--r--Source/Asset/Asset/averagecolorasset.cpp2
-rw-r--r--Source/Asset/Asset/image_sampler.cpp2
-rw-r--r--Source/Graphics/textures.cpp8
-rw-r--r--Source/Internal/filesystem.cpp7
-rw-r--r--Source/Internal/filesystem.h2
5 files changed, 12 insertions, 9 deletions
diff --git a/Source/Asset/Asset/averagecolorasset.cpp b/Source/Asset/Asset/averagecolorasset.cpp
index 374b0cce..6446a6ca 100644
--- a/Source/Asset/Asset/averagecolorasset.cpp
+++ b/Source/Asset/Asset/averagecolorasset.cpp
@@ -56,7 +56,7 @@ int AverageColor::Load( const string& rel_path, uint32_t load_flags ) {
char abs_path[kPathSize];
ModID modsource;
- if(FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths, true, NULL, true, &modsource) == -1){
+ if(FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths, true, NULL, true, true, &modsource) == -1){
//FatalError("Error", "Could not get average color of %s", rel_path.c_str());
return kLoadErrorMissingFile;
}
diff --git a/Source/Asset/Asset/image_sampler.cpp b/Source/Asset/Asset/image_sampler.cpp
index a1f5d27f..83ce5eac 100644
--- a/Source/Asset/Asset/image_sampler.cpp
+++ b/Source/Asset/Asset/image_sampler.cpp
@@ -120,7 +120,7 @@ int ImageSampler::Load( const std::string& path, uint32_t load_flags ) {
if( loaded_cache == false ) {
char abs_path[kPathSize];
ModID modsource;
- if(FindImagePath(path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kModWriteDirs, true, NULL, false, &modsource) == -1){
+ if(FindImagePath(path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kModWriteDirs, true, NULL, false, false, &modsource) == -1){
return kLoadErrorMissingFile;
}
LOGI << "Loading " << abs_path << std::endl;
diff --git a/Source/Graphics/textures.cpp b/Source/Graphics/textures.cpp
index 2cccc64a..f6ea0888 100644
--- a/Source/Graphics/textures.cpp
+++ b/Source/Graphics/textures.cpp
@@ -562,7 +562,7 @@ void Textures::ReloadInternal() {
SubTexture &sub = texture.sub_textures[s];
LOG_ASSERT(!sub.texture_name.empty());
ModID modsource;
- if (FindImagePath(sub.texture_name.c_str(), abs_path, kPathSize, kAnyPath, false,NULL,true, &modsource) == 0){
+ if (FindImagePath(sub.texture_name.c_str(), abs_path, kPathSize, kAnyPath, false,NULL,true, true, &modsource) == 0){
if(strcmp(abs_path, sub.load_name.c_str()) == 0 && GetDateModifiedInt64(abs_path) == sub.orig_modified){
LogSystem::LogData(LogSystem::debug, "tex", __FILE__, __LINE__) << " slice " << s << ": \"" << sub.texture_name << "\" no" << std::endl;
} else {
@@ -1966,7 +1966,7 @@ int Textures::loadTexture(const std::string& rel_path, unsigned int which, unsig
char abs_path[kPathSize];
PathFlags res_source;
ModID modsource;
- int err = FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kAbsPath | kModWriteDirs, true, &res_source, true, &modsource );
+ int err = FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kAbsPath | kModWriteDirs, true, &res_source, true, true, &modsource );
if(err == -1){
//DisplayError("Error", "Could not find texture: %s", rel_path.c_str());
return kLoadErrorMissingFile;
@@ -2091,7 +2091,7 @@ void Textures::loadArraySlice(const TextureRef& texref, unsigned int slice, cons
char abs_path[kPathSize];
ModID modsource;
- int err = FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kModWriteDirs, true, NULL, true, &modsource);
+ int err = FindImagePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths | kWriteDir | kModWriteDirs, true, NULL, true, true, &modsource);
if(err == -1){
FatalError("Error", "Could not find texture: %s", rel_path.c_str());
}
@@ -2684,7 +2684,7 @@ bool Textures::ReloadAsCompressed(const TextureRef& texref) {
char abs_path[kPathSize];
ModID modsource;
- if(FindImagePath(newName.c_str(), abs_path, kPathSize, kWriteDir | kModWriteDirs, true, NULL, true, &modsource) == -1) {
+ if(FindImagePath(newName.c_str(), abs_path, kPathSize, kWriteDir | kModWriteDirs, true, NULL, true, true, &modsource) == -1) {
LOGE << "Texture not found after writing it" << std::endl;
return false;
}
diff --git a/Source/Internal/filesystem.cpp b/Source/Internal/filesystem.cpp
index 7262efdb..0d42228e 100644
--- a/Source/Internal/filesystem.cpp
+++ b/Source/Internal/filesystem.cpp
@@ -178,7 +178,7 @@ const int overgrowth_dds_cache_version = 1;
//The case for looking for both the normal image and the converted became so common I felt the need for this simplification.
//Currently ignoring the modsource, should set it to the correct source if it's not null TODO
-int FindImagePath( const char* path, char* buf, int buf_size, PathFlagsBitfield flags, bool is_necessary, PathFlags* resulting_path, bool allow_crn, ModID* modsource )
+int FindImagePath( const char* path, char* buf, int buf_size, PathFlagsBitfield flags, bool is_necessary, PathFlags* resulting_path, bool allow_crn, bool allow_dds, ModID* modsource )
{
const char* fallback = "Data/Textures/error.tga";
// We might want a converted image, let's assume it's priority for reasons like performance
@@ -192,7 +192,10 @@ int FindImagePath( const char* path, char* buf, int buf_size, PathFlagsBitfield
ModID dds_modsources[kMaxPaths];
PathFlags orig_flags[kMaxPaths];
ModID orig_modsources[kMaxPaths];
- int num_dds_paths_found = FindFilePaths( dds_converted.c_str(), dds_paths, buf_size, kMaxPaths, flags, false, dds_flags, dds_modsources );
+ int num_dds_paths_found = 0;
+ if( allow_dds) {
+ num_dds_paths_found = FindFilePaths( dds_converted.c_str(), dds_paths, buf_size, kMaxPaths, flags, false, dds_flags, dds_modsources );
+ }
if (num_dds_paths_found == 0 && allow_crn) {
num_dds_paths_found = FindFilePaths( crn_converted.c_str(), dds_paths, buf_size, kMaxPaths, flags, false, dds_flags, dds_modsources );
}
diff --git a/Source/Internal/filesystem.h b/Source/Internal/filesystem.h
index 21642b46..0af2c83f 100644
--- a/Source/Internal/filesystem.h
+++ b/Source/Internal/filesystem.h
@@ -49,7 +49,7 @@ Path FindImagePath( const char* path, PathFlagsBitfield flags = kAnyPath, bool i
Path FindFilePath( const std::string& path, PathFlagsBitfield flags = kAnyPath, bool is_necessary = true );
Path FindFilePath( const char* path, PathFlagsBitfield flags = kAnyPath, bool is_necessary = true );
-int FindImagePath( const char* path, char* buf, int buf_size, PathFlagsBitfield flags, bool is_necessary = true, PathFlags* resulting_path = NULL, bool allow_crn = true, ModID* modsource = NULL);
+int FindImagePath( const char* path, char* buf, int buf_size, PathFlagsBitfield flags, bool is_necessary = true, PathFlags* resulting_path = NULL, bool allow_crn = true, bool allow_dds = true, ModID* modsource = NULL);
int FindFilePath(const char* path, char* buf, int buf_size, PathFlagsBitfield flags, bool is_necessary = true, PathFlags* resulting_path = NULL, ModID* modsource = NULL);
int FindFilePaths(const char* path, char* bufs, int buf_size, int num_bufs, PathFlagsBitfield flags, bool is_necessary, PathFlags* resulting_paths, ModID* modsourceids );
void AddPath(const char* path, PathFlags type);