changeset 1489:a27cdb3d753e

Cleanup of LevelDecoration and related.
author yoctozepto
date Thu, 29 Aug 2013 22:22:33 +0200
parents f62e6d06acac
children db0dfdb9871e
files Events.cpp Indoor.cpp Level/Decoration.cpp Level/Decoration.h Outdoor.cpp Render.cpp SaveLoad.cpp Sprites.cpp UI/Books/UIMapBook.cpp mm7_3.cpp mm7_4.cpp
diffstat 11 files changed, 47 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Events.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -663,7 +663,7 @@
 					{
 					v26 = (LevelDecoration *)activeLevelDecoration;
 					stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0;
-					v26->field_2 |= 0x0020;
+          v26->uFlags |= LEVEL_DECORATION_INVISIBLE;
 					}
 				++curr_seq_num;
 				v4 = v124;
--- a/Indoor.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Indoor.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -2245,7 +2245,7 @@
 
   for (uint i = 0; i < uNumLevelDecorations; ++i)
   {
-    memcpy(&pLevelDecorations[i].field_2, pData, 2);
+    memcpy(&pLevelDecorations[i].uFlags, pData, 2);
     pData += 2;
   }
 
@@ -3868,7 +3868,7 @@
         _6807B8_level_decorations_ids[v16] = i;
     }
 
-    if ( !(pDecortaion->field_2 & 0x20) )
+    if (!(pDecortaion->uFlags & LEVEL_DECORATION_INVISIBLE))
     {
       v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID];
       if (!v17->DontDraw())
@@ -3908,7 +3908,7 @@
             v22 = stru_5E4C90._decor_events[v21 + 74 - 75];
             v35 = v21;
             if ( !v22 )
-              pDecortaion->field_2 |= 0x20;
+              pDecortaion->uFlags |= LEVEL_DECORATION_INVISIBLE;
           }
         }
       }
@@ -4984,7 +4984,7 @@
   //v26 = uDecorationID;
   //LODWORD(v31) = uSectorID;
   v2 = &pLevelDecorations[uDecorationID];
-  if (v2->field_2 & 0x20)
+  if (v2->uFlags & LEVEL_DECORATION_INVISIBLE)
     return;
 
     v3 = &pDecorationList->pDecorations[v2->uDecorationDescID];
@@ -6159,7 +6159,7 @@
       if ( v9 )
       {
         EventProcessor(v9, a1, 1);
-        LOBYTE(v8->field_2) |= 8u;
+        v8->uFlags |= LEVEL_DECORATION_VISIBLE_ON_MAP;
       }
       else
       {
--- a/Level/Decoration.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Level/Decoration.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -7,33 +7,25 @@
 //----- (004583B0) --------------------------------------------------------
 LevelDecoration::LevelDecoration()
 {
-  this->field_1A = 0;
-  this->field_18 = 0;
-  this->vPosition.z = 0;
-  this->vPosition.y = 0;
-  this->vPosition.x = 0;
-  this->uDecorationDescID = 0;
-  this->field_2 = 0;
-  this->field_16_event_id = 0;
-  this->uCog = 0;
+  memset(this, 0, sizeof(this));
 }
 
 //----- (00450929) --------------------------------------------------------
 int LevelDecoration::GetGlobalEvent()
 {
-  LevelDecoration *v1; // esi@1
-  signed int v2; // eax@1
-  int v3; // eax@5
-  int v4; // eax@6
-  int v5; // eax@7
-  int v6; // eax@8
-  int v7; // eax@9
-  int result; // eax@14
-  int v9; // eax@18
-  int v10; // eax@19
-  int v11; // eax@20
-  int v12; // eax@21
-  int v13; // eax@22
+  //LevelDecoration *v1; // esi@1
+  //signed int v2; // eax@1
+  //int v3; // eax@5
+  //int v4; // eax@6
+  //int v5; // eax@7
+  //int v6; // eax@8
+  //int v7; // eax@9
+  //int result; // eax@14
+  //int v9; // eax@18
+  //int v10; // eax@19
+  //int v11; // eax@20
+  //int v12; // eax@21
+  //int v13; // eax@22
 
   switch (uDecorationDescID)
   {
@@ -144,11 +136,11 @@
       && _449B57_test_bit(pParty->_quest_bits, 176)
       && _449B57_test_bit(pParty->_quest_bits, 177))
   {
-    this->field_2 &= ~LEVEL_DECORATION_INVISIBLE;
+    this->uFlags &= ~LEVEL_DECORATION_INVISIBLE;
     return true;
   }
 
-  this->field_2 |= LEVEL_DECORATION_INVISIBLE;
+  this->uFlags |= LEVEL_DECORATION_INVISIBLE;
   return false;
 }
 
--- a/Level/Decoration.h	Fri Aug 30 01:49:29 2013 +0600
+++ b/Level/Decoration.h	Thu Aug 29 22:22:33 2013 +0200
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <cstdint>
+
 #include "../VectorTypes.h"
 
 enum LEVEL_DECORATION_FLAGS
@@ -23,15 +25,15 @@
   bool _47A825();
 
 
-  unsigned __int16 uDecorationDescID;
-  __int16 field_2;
-  struct Vec3_int_ vPosition;
-  int field_10_y_rot;
-  __int16 uCog;
-  __int16 field_16_event_id;
-  __int16 field_18;
-  __int16 field_1A;
-  __int16 _idx_in_stru123;
-  __int16 field_1E;
+  uint16_t uDecorationDescID;
+  uint16_t uFlags;
+  Vec3_int_ vPosition;
+  int32_t field_10_y_rot;
+  uint16_t uCog;
+  int16_t field_16_event_id;
+  int16_t field_18;
+  int16_t field_1A;
+  int16_t _idx_in_stru123;
+  int16_t field_1E;
 };
 #pragma pack(pop)
--- a/Outdoor.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Outdoor.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -2271,7 +2271,7 @@
     //thisa = (int)&pLevelDecorations[0].field_2;
     //do
     //{
-    memcpy(&pLevelDecorations[i].field_2, pSrc, 2);
+    memcpy(&pLevelDecorations[i].uFlags, pSrc, 2);
     pSrc += 2;
       //thisa += 32;
       //v85 = (char *)v85 + 2;
@@ -2717,7 +2717,7 @@
         _6807B8_level_decorations_ids[v5] = i;
       }
       if ( v8 && decor->uCog == 20 )
-        decor->field_2 |= 0x0040u;
+        decor->uFlags |= LEVEL_DECORATION_OBELISK_CHEST;
       if ( !decor->field_16_event_id )
       {
         if ( decor->IsInteractive() )
@@ -2727,7 +2727,7 @@
             v6 = v1 + 75;
             decor->_idx_in_stru123 = v6;
             if ( !stru_5E4C90._decor_events[v1++] )
-              decor->field_2 |= 0x0020u;
+              decor->uFlags |= LEVEL_DECORATION_INVISIBLE;
           }
         }
       }
--- a/Render.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Render.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -915,7 +915,7 @@
     auto decor = &pLevelDecorations[i];
     auto v0 = (char *)&pLevelDecorations[i].vPosition.y;
 
-      if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) )
+    if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->_47A825()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE))
       {
         //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
         auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID;
--- a/SaveLoad.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/SaveLoad.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -415,7 +415,7 @@
 
         for (int i =  0; i <(signed int)uNumLevelDecorations; ++i)
         {
-          memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2);
+          memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
      
           data_write_pos+= 2;
         }
@@ -465,7 +465,7 @@
       
         for (int i = 0; i < (signed int)uNumLevelDecorations; ++i)
         {
-          memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2);
+          memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
           data_write_pos += 2;
         }
       memcpy(data_write_pos, &uNumActors, 4);
--- a/Sprites.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/Sprites.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -753,7 +753,7 @@
               if ( PID_TYPE(v4) == OBJECT_Decoration)
               {
                 v5 = &pLevelDecorations[(signed __int16)v4 >> 3];
-                if ( !(v5->field_2 & 0x20) )
+                if (!(v5->uFlags & LEVEL_DECORATION_INVISIBLE))
                 {
                   v6 = &pDecorationList->pDecorations[v5->uDecorationDescID];
                   if (!v6->CanMoveThrough())
--- a/UI/Books/UIMapBook.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/UI/Books/UIMapBook.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -551,7 +551,7 @@
   {
     for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
     {
-      if ( pLevelDecorations[i].field_2 & 8 )
+      if (pLevelDecorations[i].uFlags & LEVEL_DECORATION_VISIBLE_ON_MAP)
       {
         screenHeight = pLevelDecorations[i].vPosition.y - pCenterY;
         v93 = (unsigned __int16 *)(pLevelDecorations[i].vPosition.x - viewparams->sViewCenterX);
--- a/mm7_3.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/mm7_3.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -7203,7 +7203,7 @@
   v6 = uCog;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
-    v4 = (char *)&pLevelDecorations[0].field_2;
+    v4 = (char *)&pLevelDecorations[0].uFlags;
     do
     {
       if ( *((_WORD *)v4 + 9) == v6 )
--- a/mm7_4.cpp	Fri Aug 30 01:49:29 2013 +0600
+++ b/mm7_4.cpp	Thu Aug 29 22:22:33 2013 +0200
@@ -99,7 +99,7 @@
     v32 = v1->vPosition.y;
     v35 = v1->vPosition.z;
     v31 = v1->field_18;
-    if ( v1->field_2 & 1 )
+    if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH)
     {
       v36 = abs(v1->vPosition.x - pParty->vPosition.x);
       v25 = abs(v3 - pParty->vPosition.y);
@@ -127,7 +127,7 @@
       if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 )
         EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1);
     }
-    if ( v1->field_2 & 2 )
+    if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER)
     {
       v37 = 0;
       if ( (signed int)uNumActors > 0 )
@@ -167,7 +167,7 @@
         while ( v37 < (signed int)uNumActors );
       }
     }
-    if ( v1->field_2 & 4 )
+    if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT)
     {
       v38 = 0;
       if ( (signed int)uNumSpriteObjects > 0 )
@@ -466,7 +466,7 @@
   for ( i = 0; i < v0->uNumDecorations; ++i )
   {
     v1 = &pLevelDecorations[v0->pDecorationIDs[i]];
-    if ( !(v1->field_2 & 0x20) )
+    if (!(v1->uFlags & LEVEL_DECORATION_INVISIBLE))
     {
       v2 = &pDecorationList->pDecorations[v1->uDecorationDescID];
       if (!v2->CanMoveThrough())