changeset 635:71ecba604995

Season change affects vegetation; bool change_seasons == true - seasons change, otherwise eternal summer
author Nomad
date Mon, 11 Mar 2013 16:54:56 +0200
parents 3d03a3a674bc
children 96d8aa4d8c95
files Outdoor.cpp Render.cpp mm7_2.cpp
diffstat 3 files changed, 102 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Mon Mar 11 03:38:59 2013 +0200
+++ b/Outdoor.cpp	Mon Mar 11 16:54:56 2013 +0200
@@ -2417,40 +2417,40 @@
  else
    v3 = v3 + this->pTileTypes[3].uTileID - 198;
 
- static int f = 0;
- if (f)
-   pParty->uCurrentMonth = 2;
-
-  switch (pParty->uCurrentMonth)
-  {
-    case 11: case 0: case 1: // winter
-      if (v3 >= 90) // Tileset_Grass begins at TileID = 90
-      {
-        if (v3 <= 95) // some grastyl entries
-          v3 = 348;
-        else if (v3 <= 113)  // rest of grastyl & all grdrt*
-          v3 = 348 + (v3 - 96);
-      }
+  #pragma region "New: seasons change"
+  extern bool change_seasons;
+  if (change_seasons)
+    switch (pParty->uCurrentMonth)
+    {
+      case 11: case 0: case 1: // winter
+        if (v3 >= 90) // Tileset_Grass begins at TileID = 90
+        {
+          if (v3 <= 95) // some grastyl entries
+            v3 = 348;
+          else if (v3 <= 113)  // rest of grastyl & all grdrt*
+            v3 = 348 + (v3 - 96);
+        }
       /*switch (v3)
       {
         case 102: v3 = 354; break;  // grdrtNE -> SNdrtne
         case 104: v3 = 356; break;  // grdrtNW -> SNdrtnw
         case 108: v3 = 360; break;  // grdrtN  -> SNdrtn
       }*/
-    break;
+      break;
+
+      case 2: case 3: case 4: // spring
+      case 8: case 9: case 10: // autumn
+        if (v3 >= 90 && v3 <= 113) // just convert all Tileset_Grass to dirt
+          v3 = 1;
+      break;
 
-    case 2: case 3: case 4: // spring
-    case 8: case 9: case 10: // autumn
-      if (v3 >= 90 && v3 <= 113) // just convert all Tileset_Grass to dirt
-        v3 = 1;
-    break;
+      case 5: case 6: case 7: // summer
+        //all tiles are green grass by default
+      break;
 
-    case 5: case 6: case 7: // summer
-      //all tiles are green grass by default
-    break;
-
-    default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
-  }
+      default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
+    }
+  #pragma endregion
 
  return pTileTable->pTiles[v3].uBitmapID;
 }
--- a/Render.cpp	Mon Mar 11 03:38:59 2013 +0200
+++ b/Render.cpp	Mon Mar 11 16:54:56 2013 +0200
@@ -3483,7 +3483,7 @@
   unsigned int v6; // edi@9
   int v7; // eax@9
   SpriteFrame *v8; // eax@9
-  SpriteFrame *v9; // edi@9
+  //SpriteFrame *v9; // edi@9
   unsigned __int16 *v10; // eax@9
   int v11; // ecx@9
   int v12; // eax@9
@@ -3527,11 +3527,12 @@
     //do
   for (int i = 0; i < uNumLevelDecorations; ++i)
   {
+    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[*((short *)v0 - 4)];
+        v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
         v2 = v1->uFlags;
         if ( (char)v2 >= 0 )
         {
@@ -3544,8 +3545,74 @@
             x = v4;
             v36 = v5;
             v7 = abs(v4 + y);
-            v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
-            v9 = v8;
+
+
+            #pragma region "New: seasons change"
+            extern bool change_seasons;
+            if (change_seasons)
+              switch (pParty->uCurrentMonth)
+              {
+                // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites
+                case 11: case 0: case 1: // winter
+                  switch (v1->uSpriteID)
+                  {
+                    //case 468: //bush02    grows on swamps, which are evergreeen actually
+                    case 548:             // flower10
+                    case 547:             // flower09
+                    case 541:             // flower03
+                    case 539: continue;   // flower01
+
+                    case 483:             // tree01
+                    case 486:             // tree04
+                    case 492:             // tree10
+                      pSpriteFrameTable->InitializeSprite(v1->uSpriteID + 2);
+                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID + 2, v6 + v7);
+                    break;
+
+                    default:
+                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                  }
+                break;
+
+                case 2: case 3: case 4: // spring
+                  switch (v1->uSpriteID)
+                  {
+                  }
+                  v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                break;
+
+                case 8: case 9: case 10: // autumn
+                  switch (v1->uSpriteID)
+                  {
+                    //case 468: //bush02    grows on swamps, which are evergreeen actually
+                    case 548:             // flower10
+                    case 547:             // flower09
+                    case 541:             // flower03
+                    case 539: continue;   // flower01
+                    
+                    case 483:             // tree01
+                    case 486:             // tree04
+                    case 492:             // tree10
+                      pSpriteFrameTable->InitializeSprite(v1->uSpriteID + 1);
+                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID + 1, v6 + v7);
+                    break;
+
+                    default:
+                      v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                  }
+                break;
+
+                case 5: case 6: case 7: // summer
+                  //all green by default
+                  v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+                break;
+
+                default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
+              }
+            #pragma endregion
+            //v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7);
+
+            //v9 = v8;
             v42 = v8->uFlags;
             a5 = v8->uGlowRadius;
             v10 = (unsigned __int16 *)stru_5C6E00->Atan2(
@@ -3629,9 +3696,9 @@
                   v41 = v24 / v39;
                   v40 = pViewport->uScreenCenterY
                       - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16);
-                  v42 = v9->scale;
+                  v42 = v8->scale;
                   v41 = (unsigned __int64)(v42 * v24 / v39) >> 16;
-                  v37 = (unsigned __int16 *)&v9->pHwSpriteIDs[(int)v37];
+                  v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37];
                   if ( pRenderer->pRenderD3D )
                   {
                     v26 = v41;
@@ -3651,7 +3718,7 @@
                     v27 = &pBillboardRenderList[::uNumBillboardsToDraw++];
                     ++uNumDecorationsDrawnThisFrame;
                     v27->uHwSpriteID = *v37;
-                    v28 = v9->uPaletteIndex;
+                    v28 = v8->uPaletteIndex;
                     v27->_screenspace_x_scaler_packedfloat = v26;
                     v27->_screenspace_y_scaler_packedfloat = v26;
                     v29 = v38;
@@ -3669,7 +3736,7 @@
                     v27->uIndoorSectorID = 0;
                     v27->sZValue = v30 + v31;
                     v27->uPaletteSubindex = 0;
-                    v27->pSpriteFrame = v9;
+                    v27->pSpriteFrame = v8;
                     v27->uTintColor = 0;
                   }
                 }
--- a/mm7_2.cpp	Mon Mar 11 03:38:59 2013 +0200
+++ b/mm7_2.cpp	Mon Mar 11 16:54:56 2013 +0200
@@ -10446,6 +10446,7 @@
 }
 
 bool new_sky = false;
+bool change_seasons = true;
 
 //----- (00462C94) --------------------------------------------------------
 bool MM_Main(const wchar_t *pCmdLine)