changeset 1480:61451d5980bf

LevelDecoration maintenance changes Move LevelDecoration to Level/Decoration.* files. Cleanup of LevelDecoration::_47A825.
author yoctozepto
date Wed, 28 Aug 2013 22:10:13 +0200
parents 59d1da1863df
children 0356a84be1cf
files DecorationList.cpp Indoor.h Level/Decoration.cpp Level/Decoration.h mm7_2.cpp mm7_3.cpp
diffstat 6 files changed, 217 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/DecorationList.cpp	Wed Aug 28 22:02:03 2013 +0200
+++ b/DecorationList.cpp	Wed Aug 28 22:10:13 2013 +0200
@@ -249,19 +249,6 @@
   fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3);
   fclose(v3);
 }
-//----- (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;
-}
 //----- (004488B6) --------------------------------------------------------
 unsigned __int16 DecorationList::GetDecorIdByName(const char *pName)
 {
--- a/Indoor.h	Wed Aug 28 22:02:03 2013 +0200
+++ b/Indoor.h	Wed Aug 28 22:10:13 2013 +0200
@@ -1,5 +1,5 @@
 #pragma once
-#include "VectorTypes.h"
+#include "Level/Decoration.h"
 #include "Indoor_stuff.h"
 
 
@@ -28,28 +28,7 @@
 
 
 
-/*   74 */
-#pragma pack(push, 1)
-struct LevelDecoration
-{
-  LevelDecoration();
-  int GetGlobalEvent();
-  bool IsInteractive();
-  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;
-};
-#pragma pack(pop)
 extern std::array<LevelDecoration, 3000> pLevelDecorations;
 extern size_t uNumLevelDecorations;
 extern LevelDecoration* activeLevelDecoration;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Level/Decoration.cpp	Wed Aug 28 22:10:13 2013 +0200
@@ -0,0 +1,179 @@
+#include <assert.h>
+
+#include "Decoration.h"
+#include "../Party.h"
+#include "../mm7_data.h" // for _449B57_test_bit
+
+//----- (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;
+}
+
+//----- (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
+
+  switch (uDecorationDescID)
+  {
+    case   0: case 1:
+    case   2: case 3:
+      return 0;
+
+    case   4: return 16;               // dec01 "Trash Pile"
+    case   5: return 32;               // dec02 "Campfire"
+    case   6: return 12 + rand() % 4;  // dec03 "Cauldron"
+    case   7: case 8:
+    case   9: case 10:
+      return 0;
+
+    case  11: return 34;               // dec08 "Fruit plate"
+    case  12:
+      return 0;
+
+    case  13: return 17;               // dec10 "Trash Pile"
+    case  14: return 18;               // dec11 "Filth"
+    case  15: case 16: case 17:
+    case  18: case 19: case 20:
+    case  21: case 22: case 23:
+      return 0;
+
+    case  24: return 36;               // dec21 "Keg"
+    case  25: case 26: case 27: case 28: case 29:
+    case  30: case 31: case 32: case 33:
+      return 0;
+
+    case  34: return 4 + rand() % 6;   // dec32 "Barrel"
+    case  35: case  36: case  37: case  38: case  39:
+    case  40: case  41: case  42: case  43: case  44: case  45: case  46: case  47: case  48: case  49:
+    case  50: case  51: case  52: case  53: case  54: case  55: case  56: case  57: case  58: case  59:
+    case  60: case  61: case  62: case  63: case  64: case  65: case  66: case  67: case  68: case  69:
+    case  70: case  71: case  72: case  73: case  74: case  75: case  76: case  77: case  78: case  79:
+    case  80: case  81: case  82: case  83: case  84: case  85: case  86: case  87: case  88: case  89:
+    case  90: case  91: case  92: case  93: case  94: case  95: case  96: case  97: case  98: case  99:
+    case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109:
+    case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119:
+    case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129:
+    case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139:
+    case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149:
+    case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159:
+    case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169:
+    case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179:
+    case 180: case 181: case 182: case 183:
+
+    case 184: return 33;               // dec24 "Campfire"
+    case 185: case 186:
+      return 0;
+
+    case 187:                          // dec88 "Mushroom"
+    case 190:                          // dec91 "Mushroom"
+      return 37;
+
+    case 188: case 189:
+    case 191: case 192: case 193: case 194: case 195: case 196:
+    case 197: case 198: case 199: case 200: case 201: case 202:
+    case 203: case 204: case 205:
+      return 0;
+
+    case 206: return 162 + rand() % 7; // dec60
+    case 207: return 169 + rand() % 7; // dec61
+    case 208: return 176 + rand() % 7; // dec62
+    case 209: return 183 + rand() % 7; // dec63
+    case 210: return 150;              // dec64 "Magic Pedistal"
+    case 211: return 151;              // dec65 "Magic Pedistal"
+    case 212: return 152;              // dec66 "Magic Pedistal"
+    case 213: return 153;              // dec67 "Magic Pedistal"
+    case 214: return 154;              // dec68 "Magic Pedistal"
+    case 215: return 155;              // dec69 "Magic Pedistal"
+    case 216: return 156;              // dec70 "Magic Pedistal"
+    case 217: return 157;              // dec71 "Magic Pedistal"
+    case 218: return 158;              // dec72 "Magic Pedistal"
+    case 219: return 159;              // dec73 "Magic Pedistal"
+    case 220: return 160;              // dec74 "Magic Pedistal"
+    case 221: return 161;              // dec75 "Magic Pedistal"
+
+    case 222: case 223: case 224:
+    case 225: case 226: case 227:
+      return 0;
+
+    default: assert(false && "Invalid Decoration");
+  }
+}
+
+//----- (0047A825) --------------------------------------------------------
+bool LevelDecoration::_47A825()
+{
+  //bool v1; // ebx@1
+  //LevelDecoration *v2; // edi@1
+
+  if (pParty->uCurrentHour == 0
+      && !_449B57_test_bit(pParty->_quest_bits, 178)
+      && _449B57_test_bit(pParty->_quest_bits, 164)
+      && _449B57_test_bit(pParty->_quest_bits, 165)
+      && _449B57_test_bit(pParty->_quest_bits, 166)
+      && _449B57_test_bit(pParty->_quest_bits, 167)
+      && _449B57_test_bit(pParty->_quest_bits, 168)
+      && _449B57_test_bit(pParty->_quest_bits, 169)
+      && _449B57_test_bit(pParty->_quest_bits, 170)
+      && _449B57_test_bit(pParty->_quest_bits, 171)
+      && _449B57_test_bit(pParty->_quest_bits, 172)
+      && _449B57_test_bit(pParty->_quest_bits, 173)
+      && _449B57_test_bit(pParty->_quest_bits, 174)
+      && _449B57_test_bit(pParty->_quest_bits, 175)
+      && _449B57_test_bit(pParty->_quest_bits, 176)
+      && _449B57_test_bit(pParty->_quest_bits, 177))
+  {
+    this->field_2 &= ~LEVEL_DECORATION_INVISIBLE;
+    return true;
+  }
+
+  this->field_2 |= LEVEL_DECORATION_INVISIBLE;
+  return false;
+}
+
+//----- (0044C2F4) --------------------------------------------------------
+bool LevelDecoration::IsInteractive()
+{
+  switch (uDecorationDescID)
+  {
+    case 4:    // trash pile
+    case 5:    // campfire
+    case 6:    // cauldron
+    case 11:   // fruit plate
+    case 13:   // trash pile
+    case 14:   // dirt
+    case 24:   // keg
+    case 184:  // fire
+    case 187:  // fire
+    case 190:  // fire
+      return true;
+  }
+
+  if (uDecorationDescID >= 206 && uDecorationDescID <= 209) // lighthouse fire
+    return true;
+  if (uDecorationDescID >= 210 && uDecorationDescID <= 221) // magic pedistal
+    return true;
+
+  return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Level/Decoration.h	Wed Aug 28 22:10:13 2013 +0200
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "../VectorTypes.h"
+
+enum LEVEL_DECORATION_FLAGS
+{
+  LEVEL_DECORATION_TRIGGERED_BY_TOUCH = 0x01,
+  LEVEL_DECORATION_TRIGGERED_BY_MONSTER = 0x02,
+  LEVEL_DECORATION_TRIGGERED_BY_OBJECT = 0x04,
+  LEVEL_DECORATION_VISIBLE_ON_MAP = 0x08,
+  LEVEL_DECORATION_CHEST = 0x10,
+  LEVEL_DECORATION_INVISIBLE = 0x20,
+  LEVEL_DECORATION_OBELISK_CHEST = 0x40,
+};
+
+/*   74 */
+#pragma pack(push, 1)
+struct LevelDecoration
+{
+  LevelDecoration();
+  int GetGlobalEvent();
+  bool IsInteractive();
+  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;
+};
+#pragma pack(pop)
--- a/mm7_2.cpp	Wed Aug 28 22:02:03 2013 +0200
+++ b/mm7_2.cpp	Wed Aug 28 22:10:13 2013 +0200
@@ -1776,109 +1776,6 @@
   return result;
 }
 
-//----- (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
-
-  switch (uDecorationDescID)
-  {
-    case   0: case 1:
-    case   2: case 3:
-      return 0;
-
-    case   4: return 16;               // dec01 "Trash Pile"
-    case   5: return 32;               // dec02 "Campfire"
-    case   6: return 12 + rand() % 4;  // dec03 "Cauldron"
-    case   7: case 8:
-    case   9: case 10:
-      return 0;
-
-    case  11: return 34;               // dec08 "Fruit plate"
-    case  12:
-      return 0;
-
-    case  13: return 17;               // dec10 "Trash Pile"
-    case  14: return 18;               // dec11 "Filth"
-    case  15: case 16: case 17:
-    case  18: case 19: case 20:
-    case  21: case 22: case 23:
-      return 0;
-
-    case  24: return 36;               // dec21 "Keg"
-    case  25: case 26: case 27: case 28: case 29:
-    case  30: case 31: case 32: case 33:
-      return 0;
-
-    case  34: return 4 + rand() % 6;   // dec32 "Barrel"
-    case  35: case  36: case  37: case  38: case  39:
-    case  40: case  41: case  42: case  43: case  44: case  45: case  46: case  47: case  48: case  49:
-    case  50: case  51: case  52: case  53: case  54: case  55: case  56: case  57: case  58: case  59:
-    case  60: case  61: case  62: case  63: case  64: case  65: case  66: case  67: case  68: case  69:
-    case  70: case  71: case  72: case  73: case  74: case  75: case  76: case  77: case  78: case  79:
-    case  80: case  81: case  82: case  83: case  84: case  85: case  86: case  87: case  88: case  89:
-    case  90: case  91: case  92: case  93: case  94: case  95: case  96: case  97: case  98: case  99:
-    case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109:
-    case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119:
-    case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129:
-    case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139:
-    case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149:
-    case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159:
-    case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169:
-    case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179:
-    case 180: case 181: case 182: case 183:
-
-    case 184: return 33;               // dec24 "Campfire"
-    case 185: case 186:
-      return 0;
-
-    case 187:                          // dec88 "Mushroom"
-    case 190:                          // dec91 "Mushroom"
-      return 37;
-
-    case 188: case 189:
-    case 191: case 192: case 193: case 194: case 195: case 196:
-    case 197: case 198: case 199: case 200: case 201: case 202:
-    case 203: case 204: case 205:
-      return 0;
-
-    case 206: return 162 + rand() % 7; // dec60
-    case 207: return 169 + rand() % 7; // dec61
-    case 208: return 176 + rand() % 7; // dec62
-    case 209: return 183 + rand() % 7; // dec63
-    case 210: return 150;              // dec64 "Magic Pedistal"
-    case 211: return 151;              // dec65 "Magic Pedistal"
-    case 212: return 152;              // dec66 "Magic Pedistal"
-    case 213: return 153;              // dec67 "Magic Pedistal"
-    case 214: return 154;              // dec68 "Magic Pedistal"
-    case 215: return 155;              // dec69 "Magic Pedistal"
-    case 216: return 156;              // dec70 "Magic Pedistal"
-    case 217: return 157;              // dec71 "Magic Pedistal"
-    case 218: return 158;              // dec72 "Magic Pedistal"
-    case 219: return 159;              // dec73 "Magic Pedistal"
-    case 220: return 160;              // dec74 "Magic Pedistal"
-    case 221: return 161;              // dec75 "Magic Pedistal"
-
-    case 222: case 223: case 224:
-    case 225: case 226: case 227:
-      return 0;
-
-    default: assert(false && "Invalid Decoration");
-  }
-}
-
 //----- (00450AAA) --------------------------------------------------------
 void RespawnGlobalDecorations()
 {
--- a/mm7_3.cpp	Wed Aug 28 22:02:03 2013 +0200
+++ b/mm7_3.cpp	Wed Aug 28 22:10:13 2013 +0200
@@ -5639,45 +5639,6 @@
   MM7Initialization();
 }
 
-//----- (0047A825) --------------------------------------------------------
-bool LevelDecoration::_47A825()
-{
-  bool v1; // ebx@1
-  LevelDecoration *v2; // edi@1
-
-  v1 = 0;
-  v2 = this;
-  if ( pParty->uCurrentHour >= 1 || (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 178) )
-  {
-    v1 = 0;
-  }
-  else
-  {
-    if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 164)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 165)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 166)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 167)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 168)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 169)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 170)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 171)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 172)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 173)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 174)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 175)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 176)
-      && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 177) )
-    {
-      v1 = 1;
-      LOBYTE(v2->field_2) &= 0xDFu;
-      return v1;
-    }
-  }
-  LOBYTE(v2->field_2) |= 0x20u;
-  return v1;
-}
-
-
 //----- (0047C370) --------------------------------------------------------
 unsigned int GetLevelFogColor()
 {
@@ -7799,32 +7760,6 @@
   return true;
 }
 
-//----- (0044C2F4) --------------------------------------------------------
-bool LevelDecoration::IsInteractive()
-{
-  switch (uDecorationDescID)
-  {
-    case 4:    // trash pile
-    case 5:    // campfire
-    case 6:    // cauldron
-    case 11:   // fruit plate
-    case 13:   // trash pile
-    case 14:   // dirt
-    case 24:   // keg
-    case 184:  // fire
-    case 187:  // fire
-    case 190:  // fire
-      return true;
-  }
-
-  if (uDecorationDescID >= 206 && uDecorationDescID <= 209) // lighthouse fire
-    return true;
-  if (uDecorationDescID >= 210 && uDecorationDescID <= 221) // magic pedistal
-    return true;
-
-  return false;
-}
-
 //----- (0044C362) --------------------------------------------------------
 void Vec3_int_::Normalize_float()
 {