Mercurial > mm7
changeset 1632:69ab7593e7af
Out of bounds (id 65536) texture fixed.
author | Nomad |
---|---|
date | Tue, 17 Sep 2013 12:37:07 +0200 |
parents | 8094f1706b1f |
children | 384a6b9d1333 |
files | LOD.h Outdoor.h Texture.cpp Texture.h mm7_3.cpp |
diffstat | 5 files changed, 42 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/LOD.h Tue Sep 10 21:17:00 2013 +0200 +++ b/LOD.h Tue Sep 17 12:37:07 2013 +0200 @@ -2,11 +2,16 @@ #include <stdio.h> #include <memory.h> +#include "Log.h" #include "Texture.h" #include "ErrorHandling.h" class Sprite; + +#define MAX_LOD_TEXTURES 1000 +#define MAX_LOD_SPRITES 1500 + /* 354 */ enum TEXTURE_TYPE { @@ -164,12 +169,23 @@ void _inlined_sub1(); void _inlined_sub2(); - inline struct Texture *GetTexture(int idx) + inline int LoadDummyTexture() { - Assert(idx < 1000, "Texture index out of bounds (%u)", idx); + for (unsigned int i = 0; i < uNumLoadedFiles; ++i) + if (!strcmp(pTextures[i].pName, "pending")) + return i; + return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE); + } + + inline Texture *GetTexture(int idx) + { + Assert(idx < MAX_LOD_TEXTURES, "Texture index out of bounds (%u)", idx); if (idx == -1) - return nullptr; // we need to return dummy texture here - return &pTextures[idx]; + { + //Log::Warning(L"Texture id = %d missing", idx); + return pTextures + LoadDummyTexture(); + } + return pTextures + idx; } @@ -187,7 +203,7 @@ struct LOD::Directory *pSubIndices; unsigned int uOffsetToSubIndex; FILE *pOutputFileHandle;*/ - struct Texture pTextures[1000]; + Texture pTextures[MAX_LOD_TEXTURES]; unsigned int uNumLoadedFiles; int dword_11B80; int dword_11B84; @@ -278,7 +294,7 @@ struct LOD::Directory *pSubIndices; unsigned int uOffsetToSubIndex; FILE *pOutputFileHandle;*/ - struct LODSprite pSpriteHeaders[1500]; + struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES]; signed int uNumLoadedSprites; int field_ECA0; int field_ECA4;
--- a/Outdoor.h Tue Sep 10 21:17:00 2013 +0200 +++ b/Outdoor.h Tue Sep 17 12:37:07 2013 +0200 @@ -101,7 +101,7 @@ signed __int16 pXInterceptDisplacements[20]; signed __int16 pYInterceptDisplacements[20]; signed __int16 pZInterceptDisplacements[20]; - unsigned __int16 uTextureID; + __int16 uTextureID; __int16 sTextureDeltaU; __int16 sTextureDeltaV; struct BBox_short_ pBoundingBox;
--- a/Texture.cpp Tue Sep 10 21:17:00 2013 +0200 +++ b/Texture.cpp Tue Sep 17 12:37:07 2013 +0200 @@ -335,7 +335,7 @@ } //----- (0044E19A) -------------------------------------------------------- -unsigned int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3) +int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3) { int v3; // esi@1 TextureFrame *v4; // edi@1
--- a/Texture.h Tue Sep 10 21:17:00 2013 +0200 +++ b/Texture.h Tue Sep 17 12:37:07 2013 +0200 @@ -111,7 +111,7 @@ void ToFile(); void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); void LoadAnimationSequenceAndPalettes(signed int uIconID); - unsigned int GetFrameTexture(int uFrameID, signed int a3); + int GetFrameTexture(int uFrameID, int time); unsigned int FindTextureByName(const char *Str2);
--- a/mm7_3.cpp Tue Sep 10 21:17:00 2013 +0200 +++ b/mm7_3.cpp Tue Sep 17 12:37:07 2013 +0200 @@ -4292,16 +4292,16 @@ BSPModel *v2; // ebx@4 int v3; // eax@6 ODMFace *pFace; // esi@6 - Vec3_int_ *v5; // ecx@8 + //Vec3_int_ *v5; // ecx@8 int v6; // eax@8 struct Polygon *v7; // ebx@8 - LightmapBuilder *v8; // eax@8 + //LightmapBuilder *v8; // eax@8 int v9; // ecx@8 - char v10; // zf@8 + //char v10; // zf@8 Texture *pFaceTexture; // eax@10 signed int v12; // ecx@10 - unsigned int v13; // eax@14 - unsigned int v14; // eax@18 + //unsigned int v13; // eax@14 + //unsigned int v14; // eax@18 unsigned int v15; // eax@22 unsigned int v16; // edi@22 int v17; // eax@24 @@ -4338,7 +4338,7 @@ float v45; // [sp+1Ch] [bp-3Ch]@10 ODMFace *v46; // [sp+20h] [bp-38h]@6 //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 - unsigned int v48; // [sp+28h] [bp-30h]@8 + //unsigned int v48; // [sp+28h] [bp-30h]@8 int v49; // [sp+2Ch] [bp-2Ch]@10 int v50; // [sp+30h] [bp-28h]@34 int v51; // [sp+34h] [bp-24h]@35 @@ -4390,53 +4390,44 @@ if (pFace->Invisible()) goto LABEL_85; //v5 = (int)*(v2 - 1); - v5 = v2->pVertices.pVertices; v6 = pFace->pVertexIDs[0]; v53 = 0; v7 = &array_77EC08[pOutdoorCamera->uNumPolygons]; - //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); - v8 = (LightmapBuilder *)v5[v6].z; v7->flags = 0; v7->field_32 = 0; - pLightmapBuilder = v8; + pLightmapBuilder = (LightmapBuilder *)v2->pVertices.pVertices[v6].z; v9 = pFace->uTextureID; - v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0; - v48 = pFace->uTextureID; - if ( !v10 ) + if (pFace->uAttributes & FACE_TEXTURE_FRAME) { - v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); - v9 = v48; + v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); } pFaceTexture = pBitmaps_LOD->GetTexture(v9); v7->pTexture = pFaceTexture; v12 = pFaceTexture->uTextureWidth; v49 = v12; v49 = pFaceTexture->uTextureHeight; - v10 = (pFace->uAttributes & 0x10) == 0; v45 = 1.0 / (double)v12; v44 = 1.0 / (double)v49; - if ( !v10 ) + if (pFace->uAttributes & FACE_FLUID) *(int *)&v7->flags |= 2u; - if ( BYTE2(pFace->uAttributes) & 0x40 ) + if (pFace->uAttributes & FACE_DO_NOT_LIGHT ) HIBYTE(v7->flags) |= 4u; - v13 = pFace->uAttributes; - if ( v13 & 4 ) + if ( pFace->uAttributes & 4 ) { HIBYTE(v7->flags) |= 4u; } else { - if ( v13 & 0x20 ) + if ( pFace->uAttributes & 0x20 ) HIBYTE(v7->flags) |= 8u; } - v14 = pFace->uAttributes; - if ( BYTE1(v14) & 8 ) + if (pFace->uAttributes & 0x0800) { *(int *)&v7->flags |= 0x2000u; } else { - if ( v14 & 0x40 ) + if (pFace->uAttributes & FACE_DONT_CACHE_TEXTURE) HIBYTE(v7->flags) |= 0x10u; } v15 = GetTickCount(); @@ -4520,12 +4511,11 @@ ++v20; ++v20b; ++v20c; - v10 = v51-- == 1; v52 = v22; //*((float *)v19 - 4) = (double)v22 * v44; (v19-1)->v = (double)v22 * v44; } - while ( !v10 ); + while ( !(v51-- == 1) ); //v23 = (char *)&array_73D150[0].vWorldViewPosition; v23 = array_73D150; v51 = uNumVertices; @@ -4671,7 +4661,7 @@ } else { - v40 = (int)pBitmaps_LOD->pHardwareTextures[v48]; + v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; } pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40); }