All pastes #1728614 Raw Edit

Anonymous

public diff v1 · immutable
#1728614 ·published 2009-12-27 17:51 UTC
rendered paste body
diff --git a/gemrb/plugins/KEYImporter/KeyImp.cpp b/gemrb/plugins/KEYImporter/KeyImp.cppindex eea1339..a828b4c 100644--- a/gemrb/plugins/KEYImporter/KeyImp.cpp+++ b/gemrb/plugins/KEYImporter/KeyImp.cpp@@ -282,7 +282,7 @@ static bool FindIn(const char *Path, const char *ResRef, const char *Type) 	return false; } -static FileStream *SearchIn(const char * Path,const char * ResRef, const char *Type, const char *foundMessage, bool silent=false)+static FileStream *SearchIn(const char * Path,const char * ResRef, const char *Type) { 	char p[_MAX_PATH], f[_MAX_PATH] = {0}; 	strncpy(f, ResRef, 8);@@ -297,10 +297,6 @@ static FileStream *SearchIn(const char * Path,const char * ResRef, const char *T 		FileStream * fs = new FileStream(); 		if(!fs) return NULL; 		fs->Open(p, true);-		if (!silent) {-			printBracket(foundMessage, LIGHT_GREEN);-			printf("\n");-		} 		return fs; 	} 	return NULL;@@ -376,6 +372,13 @@ static void FindBIFOnCD(BIFEntry *entry) 	entry->found = false; } +static void PrintPossibleFiles(const char* resname, const std::vector<ResourceDesc*> types)+{+	for (size_t j = 0; j < types.size(); j++) {+		printf("%.8s%s ", resname, types[j]->GetExt());+	}+}+ DataStream* KeyImp::GetResource(const char* resname, SClass_ID type, bool silent) { 	if (!strcmp(resname, "")) return NULL;@@ -391,9 +394,14 @@ DataStream* KeyImp::GetResource(const char* resname, SClass_ID type, bool silent  	FileStream *fs; 	for (size_t i = 0; i < searchPath.size(); i++) {-		fs=SearchIn( searchPath[i].path, resname, core->TypeExt(type),-				searchPath[i].description, silent );-		if (fs) return fs;+		fs=SearchIn( searchPath[i].path, resname, core->TypeExt(type));+		if (fs) {+			if (!silent) {+				printBracket(searchPath[i].description, LIGHT_GREEN);+				printf("\n");+			}+			return fs;+		} 	}  	unsigned int ResLocator;@@ -423,8 +431,8 @@ DataStream* KeyImp::GetResource(const char* resname, SClass_ID type, bool silent 		if (ret) { 			strnlwrcpy( ret->filename, resname, 8 ); 			strcat( ret->filename, core->TypeExt( type ) );+			return ret; 		}-		return ret; 	} 	if (!silent) { 		printStatus( "ERROR", LIGHT_RED );@@ -439,7 +447,7 @@ Resource* KeyImp::GetFile(const char* path, const std::vector<ResourceDesc*> &ty  	if (!silent) { 		printMessage( "KEYImporter", "Searching for ", WHITE );-		printf( "%.8s...", path ); // FIXME: Get Extension or something.+		printf( "%.8s... ", path ); // FIXME: Get Extension or something. 	}  	//Search it in the GemRB override Directory@@ -452,11 +460,20 @@ Resource* KeyImp::GetFile(const char* path, const std::vector<ResourceDesc*> &ty 		ResolveFilePath(p); 		if (exists(p)) { 			FileStream * fs = new FileStream();-			if (fs->Open(p, true))-				return types[j]->Create(fs);-			delete fs;+			if (fs->Open(p, true)) {+				Resource *res = types[j]->Create(fs);+				if (res) {+					printBracket("FOUND", LIGHT_GREEN);+					printf("\n");+					return res;+				}+			} else {+				delete fs;+			} 		} 	}+	printf("Tried ");+	PrintPossibleFiles("",types); 	return NULL; } @@ -474,15 +491,16 @@ Resource* KeyImp::GetResource(const char* resname, const std::vector<ResourceDes 	FileStream *fs; 	for (size_t i = 0; i < searchPath.size(); i++) { 		for (size_t j = 0; j < types.size(); j++) {-			fs=SearchIn( searchPath[i].path, resname, types[j]->GetExt(),-					searchPath[i].description, silent );+			fs=SearchIn( searchPath[i].path, resname, types[j]->GetExt()); 			if (fs) { 				Resource * res = types[j]->Create(fs);-				if (res)+				if (res) {+					if (!silent) {+						printBracket(searchPath[i].description, LIGHT_GREEN);+						printf("\n");+					} 					return res;-				printf( "Cannot find %s... Resource unavailable.\n",-						resname );-+				} 			} 		} 	}@@ -490,8 +508,6 @@ Resource* KeyImp::GetResource(const char* resname, const std::vector<ResourceDes 	unsigned int ResLocator; 	char path[_MAX_PATH]; -	//the word masking is a hack for synonyms, currently used for bcs==bs- 	for (size_t j = 0; j < types.size(); j++) { 		if (resources.Lookup( resname, types[j]->GetKeyType(), ResLocator )) { 			int bifnum = ( ResLocator & 0xFFF00000 ) >> 20;@@ -517,11 +533,14 @@ Resource* KeyImp::GetResource(const char* resname, const std::vector<ResourceDes 			if (ret) { 				strnlwrcpy( ret->filename, resname, 8 ); 				strcat( ret->filename, types[j]->GetExt() );++				return types[j]->Create(ret); 			}-			return types[j]->Create(ret); 		} 	} 	if (!silent) {+		printf("Tried ");+		PrintPossibleFiles(resname,types); 		printStatus( "ERROR", LIGHT_RED ); 	} 	return NULL;