diff Render.cpp @ 639:4f2837124c69

Decoration animations
author Nomad
date Mon, 11 Mar 2013 22:20:05 +0200
parents ccf8b4815a1f
children 431a8b0c2bf1
line wrap: on
line diff
--- a/Render.cpp	Mon Mar 11 21:43:26 2013 +0200
+++ b/Render.cpp	Mon Mar 11 22:20:05 2013 +0200
@@ -3485,11 +3485,11 @@
 void Render::PrepareDecorationsRenderList_ODM()
 {
   //char *v0; // esi@2
-  DecorationDesc *v1; // ebx@6
+  //DecorationDesc *v1; // ebx@6
   __int16 v2; // ax@6
   double v3; // st7@7
-  int v4; // eax@9
-  int v5; // edx@9
+  //int v4; // eax@9
+  //int v5; // edx@9
   unsigned int v6; // edi@9
   int v7; // eax@9
   SpriteFrame *v8; // eax@9
@@ -3517,10 +3517,10 @@
   int v30; // ecx@37
   int v31; // ebx@37
   Particle_sw local_0; // [sp+Ch] [bp-98h]@7
-  int x; // [sp+74h] [bp-30h]@9
-  int y; // [sp+78h] [bp-2Ch]@9
+  //int x; // [sp+74h] [bp-30h]@9
+  //int y; // [sp+78h] [bp-2Ch]@9
   //int v35; // [sp+7Ch] [bp-28h]@1
-  int v36; // [sp+80h] [bp-24h]@9
+  //int v36; // [sp+80h] [bp-24h]@9
   unsigned __int16 *v37; // [sp+84h] [bp-20h]@9
   int v38; // [sp+88h] [bp-1Ch]@9
   int v39; // [sp+8Ch] [bp-18h]@24
@@ -3540,21 +3540,22 @@
     auto decor = pLevelDecorations + i;
     auto v0 = (char *)&pLevelDecorations[i].vPosition.y;
 
-      if ( (!(*(v0 - 6) & 0x40) || ((LevelDecoration *)(v0 - 8))->_47A825()) && !(*(v0 - 6) & 0x20) )
-      {
-        v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
-        v2 = v1->uFlags;
+      if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) )
+      {
+        //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
+        auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID;
+        v2 = decor_desc->uFlags;
         if ( (char)v2 >= 0 )
         {
           if ( !(v2 & 0x22) )
           {
-            v4 = *((int *)v0 - 1);
-            v5 = *((int *)v0 + 1);
+            //v4 = decor->vPosition.x;
+            //v5 = decor->vPosition.z;
             v6 = pMiscTimer->uTotalGameTimeElapsed;
-            y = *(int *)v0;
-            x = v4;
-            v36 = v5;
-            v7 = abs(v4 + y);
+            //y = decor->vPosition.y;
+            //x = decor->vPosition.x;
+            //v36 = decor->vPosition.z;
+            v7 = abs(decor->vPosition.x + decor->vPosition.y);
 
 
             #pragma region "New: seasons change"
@@ -3564,7 +3565,7 @@
               {
                 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites
                 case 11: case 0: case 1: // winter
-                  switch (v1->uSpriteID)
+                  switch (decor_desc->uSpriteID)
                   {
                     //case 468: //bush02    grows on swamps, which are evergreeen actually
                     case 548:             // flower10
@@ -3575,24 +3576,24 @@
                     case 483:             // tree01
                     case 486:             // tree04
                     case 492:             // tree10
-                      pSpriteFrameTable->InitializeSprite(v1->uSpriteID + 2);
-                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID + 2, v6 + v7);
+                      pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2);
+                      v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7);
                     break;
 
                     default:
-                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                      v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
                   }
                 break;
 
                 case 2: case 3: case 4: // spring
-                  switch (v1->uSpriteID)
+                  switch (decor_desc->uSpriteID)
                   {
                   }
-                  v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                  v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
                 break;
 
                 case 8: case 9: case 10: // autumn
-                  switch (v1->uSpriteID)
+                  switch (decor_desc->uSpriteID)
                   {
                     //case 468: //bush02    grows on swamps, which are evergreeen actually
                     case 548:             // flower10
@@ -3603,33 +3604,32 @@
                     case 483:             // tree01
                     case 486:             // tree04
                     case 492:             // tree10
-                      pSpriteFrameTable->InitializeSprite(v1->uSpriteID + 1);
-                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID + 1, v6 + v7);
+                      pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1);
+                      v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7);
                     break;
 
                     default:
-                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                      v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
                   }
                 break;
 
                 case 5: case 6: case 7: // summer
                   //all green by default
-                  v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                  v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
                 break;
 
                 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
               }
             else
-              v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+              v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
             #pragma endregion
-            //v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+            //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
 
             //v9 = v8;
             v42 = v8->uFlags;
             a5 = v8->uGlowRadius;
-            v10 = (unsigned __int16 *)stru_5C6E00->Atan2(
-                                        *((int *)v0 - 1) - pIndoorCamera->pos.x,
-                                        *(int *)v0 - pIndoorCamera->pos.y);
+            v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x,
+                                                         decor->vPosition.y - pIndoorCamera->pos.y);
             v11 = *((int *)v0 + 2);
             v37 = v10;
             v12 = v42;
@@ -3651,9 +3651,9 @@
             {
               if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights )
               {
-                v14 = v1->uColoredLightRed;
-                v15 = v1->uColoredLightGreen;
-                v16 = v1->uColoredLightBlue;
+                v14 = decor_desc->uColoredLightRed;
+                v15 = decor_desc->uColoredLightGreen;
+                v16 = decor_desc->uColoredLightBlue;
               }
               else
               {
@@ -3663,25 +3663,25 @@
               }
               b = v16;
               pStationaryLightsStack->AddLight(
-                x,
-                y,
-                v36 + v1->uDecorationHeight / 2,
+                decor->vPosition.x,
+                decor->vPosition.y,
+                decor->vPosition.z + decor_desc->uDecorationHeight / 2,
                 a5,
                 v14,
                 v15,
                 v16,
                 byte_4E94D0);
             }
-            v17 = (x - pIndoorCamera->pos.x) << 16;
+            v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16;
             if ( pIndoorCamera->sRotationX )
             {
-              v40 = (y - pIndoorCamera->pos.y) << 16;
+              v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16;
               v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16)
                   + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16);
               v42 = v18;
               b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16;
               a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16;
-              v40 = (v36 - pIndoorCamera->pos.z) << 16;
+              v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16;
               v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16;
               v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16;
               v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16);
@@ -3738,9 +3738,9 @@
                     HIBYTE(v29) |= 2u;
                     v27->uPalette = v28;
                     v27->field_1E = v29;
-                    v27->world_x = x;
-                    v27->world_y = y;
-                    v27->world_z = v36;
+                    v27->world_x = decor->vPosition.x;
+                    v27->world_y = decor->vPosition.y;
+                    v27->world_z = decor->vPosition.z;
                     v27->uScreenSpaceY = v40;
                     HIWORD(v30) = HIWORD(v39);
                     v31 = 8 * i | OBJECT_Decoration;
@@ -3757,8 +3757,8 @@
             }
             else
             {
-              v42 = (x - pIndoorCamera->pos.x) << 16;
-              v40 = (y - pIndoorCamera->pos.y) << 16;
+              v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16;
+              v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16;
               b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16;
               a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16;
               v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16);
@@ -3769,7 +3769,7 @@
                 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16;
                 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5;
                 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5;
-                v22 = (v36 - pIndoorCamera->pos.z) << 16;
+                v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16;
                 goto LABEL_30;
               }
             }