changeset 265:96bc024a5fed

Render overflows
author Nomad
date Mon, 18 Feb 2013 10:04:47 +0200
parents 96f3a1177b37
children 006188b68143
files Game.cpp Indoor.cpp LOD.cpp Outdoor.cpp Outdoor_stuff.h Render.cpp Render.h mm7_1.cpp mm7_3.cpp mm7_data.h
diffstat 10 files changed, 42 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/Game.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/Game.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -94,14 +94,14 @@
 
     if ( !pRenderer->pRenderD3D )
       pMouse->DrawCursorToTarget();
-    if ( !sub_4226C2() || viewparams->field_48 == 1 )
+    if ( !PauseGameDrawing() || viewparams->field_48 == 1 )
     {
       if ( pRenderer->pRenderD3D )
       {
         float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
         //v3 = v2 + 6.7553994e15;
         //pRenderer->field_1036A8_bitmapid = LODWORD(v3);
-        pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f);
+        pRenderer->hd_water_current_frame = floorf(v2 + 0.5f);
       }
 
       if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -142,7 +142,7 @@
     GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2);
     if (v4)
     {
-      if ( !sub_4226C2() && pRenderer->pRenderD3D) // clear game viewport with transparent color
+      if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color
         pRenderer->FillRectFast(pViewport->uViewportX, pViewport->uViewportY, pViewport->uViewportZ - pViewport->uViewportX,
                                 pViewport->uViewportW - pViewport->uViewportY + 1,
                                 pRenderer->uTargetGMask | pRenderer->uTargetBMask);
--- a/Indoor.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/Indoor.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -559,10 +559,10 @@
                     pFace->uSectorID);
 
         if (pFace->Animated() &&
-            pFace->uBitmapID == pRenderer->field_1036AC_bitmapid )
+            pFace->uBitmapID == pRenderer->hd_water_tile_id )
         {
           __debugbreak();
-          v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+          v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
           goto LABEL_42;
         }
 
--- a/LOD.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/LOD.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -2869,15 +2869,15 @@
       ptr_011BB4 = new char[1000];
       memset(ptr_011BB4, 0, 1000);
     }
-    if (strcmp(pContainer, "wtrdr"))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' )
+    if (strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' )
     {
-      if (strcmp(pContainer, "WtrTyl"))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' )
+      if (strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' )
       {
         v14 = uNumLoadedFiles;
       }
       else
       {
-        pRenderer->field_1036AC_bitmapid = uNumLoadedFiles;
+        pRenderer->hd_water_tile_id = uNumLoadedFiles;
         v14 = uNumLoadedFiles;
       }
       v13 = pRenderer->LoadTexture(
--- a/Outdoor.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/Outdoor.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -36,7 +36,7 @@
 
 
 stru149 stru_8019C8;
-stru148 array_77EC08[2000];
+stru148 array_77EC08[2000 + 18000];
 Surf stru_80C980;
 Edge defaultEdge; // weak
 Edge stru_80C9A4;
--- a/Outdoor_stuff.h	Mon Feb 18 09:20:47 2013 +0200
+++ b/Outdoor_stuff.h	Mon Feb 18 10:04:47 2013 +0200
@@ -7,6 +7,11 @@
 #pragma pack(push, 1)
 struct stru148
 {
+  inline stru148()
+  {
+    uNumVertices = 0;
+  }
+
   int _479295();
   void _4811A3();
   void _48276F_sr();
@@ -94,7 +99,7 @@
   float field_14;
 };
 #pragma pack(pop)
-extern stru148 array_77EC08[2000];
+extern stru148 array_77EC08[];
 
 
 
--- a/Render.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/Render.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -1834,21 +1834,23 @@
       v8->field_58 = 0;
       ++pOutdoorCamera->numStru148s;
       ++pOutdoorCamera->field_44;
+      assert(pOutdoorCamera->numStru148s < 20000);
+
       v8->uBModelID = 0;
       v8->uBModelFaceID = 0;
       v31 = (8 * (0 | (0 << 6)));
       v8->field_50 = v31 | 6;
-      for (unsigned int k = 0; k < 4; ++k)
+      for (unsigned int k = 0; k < v8->uNumVertices; ++k)
       {
         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
         array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
       }
 
       bool transparent = false;
-            if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
+            if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id)
             {
               //v80 = false;
-              v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+              v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
             }
             else
             {
@@ -1862,7 +1864,7 @@
       if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
       {
         pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);  // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting
-        pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]], false, true);
+        pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true);
         pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
         
       }
@@ -2174,10 +2176,10 @@
           //v37 = *(int *)&v16->flags;
           if ( ~v16->flags & 1 )
           {
-            if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
+            if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id )
             {
               v80 = false;
-              v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+              v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
             }
             else
             {
@@ -2324,10 +2326,10 @@
       }
       else
       {
-        if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
+        if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id )
         {
           v81 = 0;
-          v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+          v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
@@ -2439,10 +2441,10 @@
           v74 = v71->flags;
           if ( !(BYTE1(v74) & 1) )
           {
-            if ( v74 & 2 && v71->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
+            if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id )
             {
               v80 = false;
-              v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+              v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
             }
             else
             {
@@ -4694,6 +4696,9 @@
   v1->_gpu_memory_used = 0;
   uNumBillboardsToDraw = 0;
   bFogEnabled = false;
+
+  hd_water_tile_id = -1;
+  hd_water_current_frame = 0;
 }
 
 bool Render::Initialize(bool bWindowed, uint uDefaultDevice,
--- a/Render.h	Mon Feb 18 09:20:47 2013 +0200
+++ b/Render.h	Mon Feb 18 10:04:47 2013 +0200
@@ -441,8 +441,8 @@
   int field_103668;
   unsigned int pHDWaterBitmapIDs[7];
   char field_103688[32];
-  int field_1036A8_bitmapid;
-  int field_1036AC_bitmapid;
+  int hd_water_current_frame;
+  int hd_water_tile_id;
   IDirectDrawSurface4 *pSurface;
   IDirect3DTexture2 *pTexture;
   int field_1036B8;
--- a/mm7_1.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/mm7_1.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -6198,18 +6198,18 @@
 }
 
 //----- (004226C2) --------------------------------------------------------
-bool __cdecl sub_4226C2()
+bool PauseGameDrawing()
 {
-  if ( pCurrentScreen
+  if ( pCurrentScreen != SCREEN_GAME
     && pCurrentScreen != SCREEN_NPC_DIALOGUE
     && pCurrentScreen != SCREEN_CHANGE_LOCATION )
   {
     if ( pCurrentScreen == SCREEN_INPUT_BLV )
       return pVideoPlayer->pSmackerMovie != 0;
     if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
-      return 1;
-  }
-  return 0;
+      return true;
+  }
+  return false;
 }
 // 4E28F8: using guessed type int pCurrentScreen;
 
--- a/mm7_3.cpp	Mon Feb 18 09:20:47 2013 +0200
+++ b/mm7_3.cpp	Mon Feb 18 10:04:47 2013 +0200
@@ -5654,7 +5654,7 @@
         v7->field_58 = 0;
       if ( v7->field_58 > 31 )
         v7->field_58 = 31;
-      if ( pOutdoorCamera->numStru148s >= 1999 )
+      if ( pOutdoorCamera->numStru148s >= 1999 + 5000)
         return result;
       ++pOutdoorCamera->numStru148s;
       ++pOutdoorCamera->field_44;
@@ -5754,7 +5754,7 @@
             if ( BYTE1(v33) & 0x3C )
               v34 = pRenderer->pHDWaterBitmapIDs[0];
             else
-              v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+              v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
             v40 = (int)pBitmaps_LOD->pHardwareTextures[v34];
           }
           else
@@ -8393,7 +8393,7 @@
 
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
   pRenderer->DrawTerrainPolygon(uNumVertices, this,
-    pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]],
+    pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_tile_id]],
     0, 0);
 
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
--- a/mm7_data.h	Mon Feb 18 09:20:47 2013 +0200
+++ b/mm7_data.h	Mon Feb 18 10:04:47 2013 +0200
@@ -1648,7 +1648,7 @@
 extern int dword_80AA1C; // weak
 extern int dword_80AA20; // weak
 extern unsigned int uNumElementsIn80AA28;
-extern struct stru148 *ptr_80AA28[2000];
+extern struct stru148 *ptr_80AA28[];
 extern struct Edge *pNewEdges;
 extern struct Surf *pSurfs;
 extern struct Edge *pEdges;
@@ -1912,7 +1912,7 @@
 void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb
 void __cdecl sub_421EA6_OnInventoryLeftClick();
 void __cdecl OnGameViewportClick();
-bool __cdecl sub_4226C2();
+bool PauseGameDrawing();
 void __fastcall SetUserInterface(int a1, bool bReplace);
 void __cdecl reset_some_strus_flt_2Cs();
 void __cdecl j_sub_423B4A();