diff mm7_2.cpp @ 1030:7735bdb3c30f

Doors and other bmodel triggers are now clickable.
author Nomad
date Tue, 21 May 2013 12:52:38 +0200
parents 67e33708d815
children f93d17337113
line wrap: on
line diff
--- a/mm7_2.cpp	Tue May 21 12:10:08 2013 +0200
+++ b/mm7_2.cpp	Tue May 21 12:52:38 2013 +0200
@@ -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;