From 53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 7 Jul 2019 13:09:11 +0200 Subject: the great reorganization --- src/RwTexRead.cpp | 126 ------------------------------------------------------ 1 file changed, 126 deletions(-) delete mode 100644 src/RwTexRead.cpp (limited to 'src/RwTexRead.cpp') diff --git a/src/RwTexRead.cpp b/src/RwTexRead.cpp deleted file mode 100644 index a1a7050a..00000000 --- a/src/RwTexRead.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "common.h" -#include "patcher.h" - -RwTexture* -RwTextureGtaStreamRead(RwStream *stream) -{ - RwUInt32 size, version; - RwTexture *tex; - - if(!RwStreamFindChunk(stream, rwID_TEXTURENATIVE, &size, &version)) - return nil; - - // TODO: unused timing - - if(!RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD](stream, &tex, size))) - return nil; - - return tex; -} - -RwTexture* -destroyTexture(RwTexture *texture, void *data) -{ - RwTextureDestroy(texture); - return texture; -} - -RwTexDictionary* -RwTexDictionaryGtaStreamRead(RwStream *stream) -{ - RwUInt32 size, version; - RwInt32 numTextures; - RwTexDictionary *texDict; - RwTexture *tex; - - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size == 4); - if(RwStreamRead(stream, &numTextures, size) != size) - return nil; - - texDict = RwTexDictionaryCreate(); - if(texDict == nil) - return nil; - - while(numTextures--){ - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - return texDict; -} - -static int32 numberTextures = -1; -static int32 streamPosition; - -RwTexDictionary* -RwTexDictionaryGtaStreamRead1(RwStream *stream) -{ - RwUInt32 size, version; - RwInt32 numTextures; - RwTexDictionary *texDict; - RwTexture *tex; - - numberTextures = 0; - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size == 4); - if(RwStreamRead(stream, &numTextures, size) != size) - return nil; - - texDict = RwTexDictionaryCreate(); - if(texDict == nil) - return nil; - - numberTextures = numTextures/2; - - while(numTextures > numberTextures){ - numTextures--; - - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - numberTextures = numTextures; - streamPosition = stream->Type.memory.position; - - return texDict; -} - -RwTexDictionary* -RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict) -{ - RwTexture *tex; - - RwStreamSkip(stream, streamPosition - stream->Type.memory.position); - - while(numberTextures--){ - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - return texDict; -} - -STARTPATCHES - InjectHook(0x592380, RwTextureGtaStreamRead, PATCH_JUMP); - InjectHook(0x5924A0, RwTexDictionaryGtaStreamRead, PATCH_JUMP); - InjectHook(0x592550, RwTexDictionaryGtaStreamRead1, PATCH_JUMP); - InjectHook(0x592650, RwTexDictionaryGtaStreamRead2, PATCH_JUMP); -ENDPATCHES -- cgit v1.2.3