changeset 1046:5758ddc56127

Слияние
author Ritor1
date Tue, 21 May 2013 16:13:48 +0600
parents d3f4c6584ada (current diff) 7735bdb3c30f (diff)
children 76ce871b0076
files
diffstat 6 files changed, 47 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.h	Tue May 21 16:13:43 2013 +0600
+++ b/Indoor.h	Tue May 21 16:13:48 2013 +0600
@@ -252,6 +252,7 @@
 #define FACE_PORTAL             0x00000001 // portal/two-sided
 #define FACE_CAN_SATURATE_COLOR 0x00000002
 #define FACE_FLUID              0x00000010 // wavy animated water or lava
+#define FACE_DONT_CACHE_TEXTURE 0x00000040 // do not load face texture if it isn't loaded already
 #define FACE_XY_PLANE           0x00000100
 #define FACE_XZ_PLANE           0x00000200
 #define FACE_YZ_PLANE           0x00000400
--- a/Outdoor.cpp	Tue May 21 16:13:43 2013 +0600
+++ b/Outdoor.cpp	Tue May 21 16:13:48 2013 +0600
@@ -1935,7 +1935,7 @@
 
       auto *face = &model->pFaces[j];
       //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces;
-      if (~face->uAttributes & 0x40)
+      if (~face->uAttributes & FACE_DONT_CACHE_TEXTURE)
       {
         v62 = pBitmaps_LOD->LoadTexture(texFilename);
 //        v63 = (ODMFace *)pFilename;
@@ -1947,7 +1947,7 @@
       {
         v62 = pBitmaps_LOD->LoadTexture(texFilename);
         //v63 = (ODMFace *)pFilename;
-        face->uAttributes &= 0xFFBFu;
+        face->uAttributes &= ~FACE_DONT_CACHE_TEXTURE;
 LABEL_68:
         face->uTextureID = v62;
         //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0;
@@ -1961,9 +1961,9 @@
       if (face->sCogTriggeredID)
       {
         if (face->HasEventHint())
-          face->uAttributes |= 0x1000u;
+          face->uAttributes |= 0x1000;
         else
-          face->uAttributes &= 0xEFFFu;
+          face->uAttributes &= ~0x1000;
       }
       //++v144;
       //v60 = pBModels;
--- a/Outdoor.h	Tue May 21 16:13:43 2013 +0600
+++ b/Outdoor.h	Tue May 21 16:13:48 2013 +0600
@@ -88,6 +88,7 @@
   inline bool Visible() const   {return !Invisible();}
   inline bool Portal() const    {return uAttributes & FACE_PORTAL;}
   inline bool Fluid() const     {return uAttributes & FACE_FLUID;}
+  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
 
   struct Plane_int_ pFacePlane;
   int zCalc1;
--- a/UiGame.cpp	Tue May 21 16:13:43 2013 +0600
+++ b/UiGame.cpp	Tue May 21 16:13:48 2013 +0600
@@ -790,7 +790,7 @@
         }
         if (PID_TYPE(v18) == OBJECT_BModel)
         {
-          if ( v18 < (signed int)0x2000000 )
+          if ( HIWORD(v18) < 512)
           {
             if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
             {
--- a/mm7_1.cpp	Tue May 21 16:13:43 2013 +0600
+++ b/mm7_1.cpp	Tue May 21 16:13:48 2013 +0600
@@ -984,7 +984,7 @@
 }
 
 //----- (0042213C) --------------------------------------------------------
-void __cdecl OnGameViewportClick()
+void OnGameViewportClick()
 {
   signed int v0; // ebx@2
   POINT *v1; // esi@3
@@ -1086,14 +1086,14 @@
     }
     else
     {
-      if ( PID_TYPE(v0) != OBJECT_BModel || (signed)v0 >= 0x2000000 )
+      if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 )
 	  {
           v4 = pParty->pPickedItem.uItemID;
           if ( !pParty->pPickedItem.uItemID )
             return;
           goto LABEL_14;
 	  }
-      v2 = (signed int)(unsigned __int16)v0 >> 3;
+      v2 = PID_ID(v0);
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
       {
         v3 = &pIndoor->pFaces[v2];
@@ -1160,8 +1160,8 @@
       }
       else
       {
-        v12 = &pOutdoor->pBModels[(signed int)(unsigned __int16)v0 >> 9].pFaces[v2 & 0x3F];
-        if ( !(v12->uAttributes & 0x2000000) )
+        v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F];
+        if ( !v12->Clickable())
           goto LABEL_11;
         v11 = v12->sCogTriggeredID;
       }
@@ -1188,7 +1188,7 @@
   {
     if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) )
     {
-      if ( (unsigned int)v0 >= 0x2000000 )
+      if ( HIWORD(v0) >= 512)
 	  {
           v4 = pParty->pPickedItem.uItemID;
           if ( !pParty->pPickedItem.uItemID )
--- a/mm7_2.cpp	Tue May 21 16:13:43 2013 +0600
+++ b/mm7_2.cpp	Tue May 21 16:13:48 2013 +0600
@@ -10554,10 +10554,11 @@
   if ( pRenderer->pRenderD3D )
   {
     pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter);
-    v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val();
-    if ( v1 != (int *)-1 )
-      DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
-  }
+    auto pid = pGame->pVisInstance->get_picked_object_zbuf_val();
+    if ( pid != -1 )
+      DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid));
+  }
+
   v22 = 0;
   v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer
   if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
@@ -10666,7 +10667,7 @@
   BLVFace *v4; // eax@9
   unsigned int v5; // ecx@9
   unsigned __int16 v6; // ax@11
-  ODMFace *v7; // eax@16
+  //ODMFace *v7; // eax@16
   LevelDecoration *v8; // esi@19
   __int16 v9; // ax@19
   int v10; // eax@22
@@ -10792,34 +10793,36 @@
       break;
 
     default:
-      if ( PID_TYPE(a1) != OBJECT_BModel)
-      {
-        MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
-        return 1;
-      }
-      if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
-      {
-        if ( a1 >> 9 >= pOutdoor->uNumBModels
-          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
-          || (v6 = v7->sCogTriggeredID) == 0 )
+      MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
+      return 1;
+
+    case OBJECT_BModel:
+      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+      {
+        int bmodel_id = a1 >> 9,
+            face_id = PID_ID(a1) &0x3F;
+        if (bmodel_id >= pOutdoor->uNumBModels)
+          return 1;
+        auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id];
+        if (face->uAttributes & 0x100000 || (v6 = face->sCogTriggeredID) == 0 )
           return 1;
         EventProcessor((signed __int16)v6, v2, 1);
-        return 0;
-      }
-      v4 = &pIndoor->pFaces[PID_ID(a1)];
-      v5 = v4->uAttributes;
-      if ( !(v5 & 0x2000000) )
-      {
-        ShowNothingHereStatus();
-        return 1;
-      }
-      if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
-        return 1;
-      if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
-	  {
-        EventProcessor((signed __int16)v6, v2, 1);
-        return 0;
-	  }
+      }
+      else
+      {
+        v4 = &pIndoor->pFaces[PID_ID(a1)];
+        v5 = v4->uAttributes;
+        if ( !(v5 & 0x2000000) )
+        {
+          ShowNothingHereStatus();
+          return 1;
+        }
+        if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
+          return 1;
+        if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
+          EventProcessor((signed __int16)v6, v2, 1);
+      }
+      return 0;
       break;
   }
   return 0;