2 Commits 246f43d4c4 ... dbaeccdac0

Author SHA1 Message Date
  somewhatlurker dbaeccdac0 amd shader patcher: pyfarc: fix accidentally uncommented test_farc definition 4 years ago
  somewhatlurker 40249fce3c novidia: slightly better error handling (no real-world difference though tbh) 4 years ago

+ 1 - 1
source-code/data/amd-tools/AFT Shader Patcher/pyfarc.py

@@ -224,7 +224,7 @@ def from_stream(s):
 
 
 #test_farc = {'farc_type': 'FArc', 'files': {'aaa': {'data': b'test1'}, 'bbb': {'data': b'test2'}, 'ccc': {'data': b'aaaaaaaaaaaaaaaaaaaaaaaa'}}}
-test_farc = {'farc_type': 'FArC', 'files': {'aaa': {'data': b'test1'}, 'bbb': {'data': b'test2'}, 'ccc': {'data': b'aaaaaaaaaaaaaaaaaaaaaaaa'}}}
+#test_farc = {'farc_type': 'FArC', 'files': {'aaa': {'data': b'test1'}, 'bbb': {'data': b'test2'}, 'ccc': {'data': b'aaaaaaaaaaaaaaaaaaaaaaaa'}}}
 #print (test_farc)
 
 #test_bytes = to_bytes(test_farc, alignment=16)

+ 4 - 3
source-code/source/plugins/Novidia/src/dllmain.cpp

@@ -221,6 +221,7 @@ int64_t hookedGetFileSize(MsString* path) {
 		shader_farc_data = NULL;
 		shader_farc_data_size = 0;
 		shader_farc_path = "";
+		shader_file_handle = NULL;
 	}
 
 
@@ -300,7 +301,7 @@ int64_t hookedGetFileSize(MsString* path) {
 
 	fclose(vcdfile);
 
-
+	
 	// allocate an output buffer and patch shader into it (needs to be done now to know correct size)
 	outbuf_size = 64 * 1024 * 1024; // 64M should be enough
 	outbuf = malloc(outbuf_size);
@@ -350,9 +351,9 @@ int64_t hookedFread(void* dst, int64_t size, int64_t count, FILE* file)
 
 	size_t size_bytes = size * count;
 
-	if (size_bytes > shader_farc_data_size)
+	if ((size_bytes > shader_farc_data_size) || !shader_farc_data)
 	{
-		return divaFread(dst, size, count, file); // this is an error -- the game wants more data than we have for some reason
+		return divaFread(dst, size, count, file); // this is an error -- the game wants more data than we have for some reason, or size has a value but not our buffer
 	}
 
 	memcpy(dst, shader_farc_data, size_bytes);