changeset 2226:5944810e88e2

occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
author Ritor1
date Thu, 20 Feb 2014 12:20:49 +0600
parents 080fd5a5433d
children e87b5709a502
files Indoor.cpp Outdoor.cpp Render.cpp Render.h
diffstat 4 files changed, 21 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Feb 19 22:30:39 2014 +0100
+++ b/Indoor.cpp	Thu Feb 20 12:20:49 2014 +0600
@@ -3881,7 +3881,7 @@
         ++uNumBillboardsToDraw;
         ++uNumSpritesDrawnThisFrame;
         pActors[i].uAttributes |= 8;
-        pBillboardRenderList[uNumBillboardsToDraw - 1].uHwSpriteID = v9->pHwSpriteIDs[v6];
+        pBillboardRenderList[uNumBillboardsToDraw - 1].HwSpriteID = v9->pHwSpriteIDs[v6];
         pBillboardRenderList[uNumBillboardsToDraw - 1].uPalette = v9->uPaletteIndex;
         pBillboardRenderList[uNumBillboardsToDraw - 1].uIndoorSectorID = pActors[i].uSectorID;
         /*if ( !pRenderer->pRenderD3D )
@@ -3978,9 +3978,9 @@
                                     pSpriteObjects[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
             LOWORD(v7) = pSpriteObjects[i].uFacing;
             v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
-            pBillboardRenderList[uNumBillboardsToDraw].uHwSpriteID = v4->pHwSpriteIDs[v9];
+            pBillboardRenderList[uNumBillboardsToDraw].HwSpriteID = v4->pHwSpriteIDs[v9];
             if ( v4->uFlags & 0x20 )
-              pSpriteObjects[i].vPosition.z -= (signed int)(fixpoint_mul(v4->scale, pSprites_LOD->pSpriteHeaders[pBillboardRenderList[uNumBillboardsToDraw].uHwSpriteID].uHeight) / 2);
+              pSpriteObjects[i].vPosition.z -= (signed int)(fixpoint_mul(v4->scale, pSprites_LOD->pSpriteHeaders[pBillboardRenderList[uNumBillboardsToDraw].HwSpriteID].uHeight) / 2);
 
             v34 = 0;
             if ( v4->uFlags & 2 )
@@ -4213,7 +4213,7 @@
 
       ++uNumBillboardsToDraw;
       ++uNumDecorationsDrawnThisFrame;
-      pBillboardRenderList[uNumBillboardsToDraw - 1].uHwSpriteID = v11->pHwSpriteIDs[v9];
+      pBillboardRenderList[uNumBillboardsToDraw - 1].HwSpriteID = v11->pHwSpriteIDs[v9];
       pBillboardRenderList[uNumBillboardsToDraw - 1].uPalette = v11->uPaletteIndex;
       pBillboardRenderList[uNumBillboardsToDraw - 1].uIndoorSectorID = uSectorID;
       /*if ( !pRenderer->pRenderD3D )
--- a/Outdoor.cpp	Wed Feb 19 22:30:39 2014 +0100
+++ b/Outdoor.cpp	Thu Feb 20 12:20:49 2014 +0600
@@ -2793,7 +2793,7 @@
         ++uNumBillboardsToDraw;
         ++uNumSpritesDrawnThisFrame;
         pActors[i].uAttributes |= 8;
-        pBillboardRenderList[uNumBillboardsToDraw - 1].uHwSpriteID = v15->pHwSpriteIDs[v41];
+        pBillboardRenderList[uNumBillboardsToDraw - 1].HwSpriteID = v15->pHwSpriteIDs[v41];
         pBillboardRenderList[uNumBillboardsToDraw - 1].uIndoorSectorID = 0;
         pBillboardRenderList[uNumBillboardsToDraw - 1].uPalette = v15->uPaletteIndex;
         pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_x_scaler_packedfloat = fixpoint_mul(v15->scale, v58);
--- a/Render.cpp	Wed Feb 19 22:30:39 2014 +0100
+++ b/Render.cpp	Thu Feb 20 12:20:49 2014 +0600
@@ -152,7 +152,7 @@
       soft_billboard.sZValue = p->sZValue;
       soft_billboard.uFlags = p->field_1E;
       soft_billboard.sTintColor = p->sTintColor;
-      v2 = p->uHwSpriteID;
+      v2 = p->HwSpriteID;
       if ( v2 != -1 )
       {
         if ( pRenderer->pRenderD3D )
@@ -164,7 +164,7 @@
             soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette];
           if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 )
             soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1);
-          v5 = p->uHwSpriteID;
+          v5 = p->HwSpriteID;
           if ( v5 >= 0 )
             pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1);
         }
@@ -416,23 +416,21 @@
 
   for (int i = 0; i < ::uNumBillboardsToDraw; ++i)
   {
-    RenderBillboard* pBillboard = &pBillboardRenderList[i];
-
-    billboard.uScreenSpaceX = pBillboard->uScreenSpaceX;
-    billboard.uScreenSpaceY = pBillboard->uScreenSpaceY;
+    billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX;
+    billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY;
     billboard.sParentBillboardID = i;
-    billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat;
-    billboard.sTintColor = pBillboard->sTintColor;
-    billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat;
-    billboard.sZValue = pBillboard->sZValue;
-    billboard.uFlags = pBillboard->field_1E;
-    if (pBillboard->uHwSpriteID != -1)
+    billboard._screenspace_x_scaler_packedfloat = pBillboardRenderList[i]._screenspace_x_scaler_packedfloat;
+    billboard.sTintColor = pBillboardRenderList[i].sTintColor;
+    billboard._screenspace_y_scaler_packedfloat = pBillboardRenderList[i]._screenspace_y_scaler_packedfloat;
+    billboard.sZValue = pBillboardRenderList[i].sZValue;
+    billboard.uFlags = pBillboardRenderList[i].field_1E;
+    if (pBillboardRenderList[i].HwSpriteID != -1)
     {
       if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering
       //if (pRenderer->pRenderD3D)
         pRenderer->TransformBillboard(&billboard,
-                                      &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID],
-                                      pBillboard->dimming_level, pBillboard);
+                                      &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID],
+                                      pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]);
       /*else
       {
           assert(false);
@@ -516,7 +514,7 @@
       //LOWORD(v7) = object->uFacing;
       //v8 = v36;
       v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
-      pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = frame->pHwSpriteIDs[v9];
+      pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9];
       if ( frame->uFlags & 0x20 )
       {
         //v8 = v36;
@@ -999,7 +997,7 @@
                 {
                   if (::uNumBillboardsToDraw >= 500)
                     return;
-                  pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = v8->pHwSpriteIDs[(int)v37];
+                  pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37];
                   pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
                   pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
                   v29 = v38;
@@ -1051,7 +1049,7 @@
                 {
                   if (::uNumBillboardsToDraw >= 500)
                     return;
-                  pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = v8->pHwSpriteIDs[(int)v37];
+                  pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37];
                   pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
                   pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
                   v29 = v38;
--- a/Render.h	Wed Feb 19 22:30:39 2014 +0100
+++ b/Render.h	Thu Feb 20 12:20:49 2014 +0600
@@ -80,7 +80,7 @@
     };
   };
   int field_14_actor_id;
-  unsigned __int16 uHwSpriteID;
+  signed __int16 HwSpriteID;
   __int16 uPalette;
   __int16 uIndoorSectorID;
   __int16 field_1E;