diff Viewport.cpp @ 2203:4bfee77e900d

DoInteractionWithTopmostZObject cleaned
author Ritor1
date Tue, 04 Feb 2014 17:29:04 +0600
parents 628a0ad87136
children ff8920a40c21
line wrap: on
line diff
--- a/Viewport.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/Viewport.cpp	Tue Feb 04 17:29:04 2014 +0600
@@ -281,28 +281,28 @@
 
   if ( PID_TYPE(v0) == OBJECT_Item)
   {
-    a2.y = (signed int)(unsigned __int16)v0 >> 3;
-    v21 = (signed int)(unsigned __int16)v0 >> 3;
-    if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID
+    int item_id = PID_ID(v0);
+    //v21 = (signed int)(unsigned __int16)v0 >> 3;
+    if ( !(pObjectList->pObjects[pSpriteObjects[item_id].uObjectDescID].uFlags & 0x10) && item_id < 1000 && pSpriteObjects[item_id].uObjectDescID
       && (unsigned int)v0 < 0x2000000 )
     {
-      if ( pSpriteObjects[v21].stru_24.GetItemEquipType() == 18 )
+      if ( pSpriteObjects[item_id].stru_24.GetItemEquipType() == 18 )
       {
-        pParty->PartyFindsGold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0);
+        pParty->PartyFindsGold(pSpriteObjects[item_id].stru_24.uSpecEnchantmentType, 0);
         viewparams->bRedrawGameUI = 1;
       }
       else
       {
-        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName);
-        ShowStatusBarString(pTmpBuf2.data(), 2u);
-        if ( pSpriteObjects[v21].stru_24.uItemID == ITEM_ARTIFACT_SPLITTER )
+        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[item_id].stru_24.uItemID].pUnidentifiedName);//You found an item (%s)!
+        ShowStatusBarString(pTmpBuf2.data(), 2);
+        if ( pSpriteObjects[item_id].stru_24.uItemID == ITEM_ARTIFACT_SPLITTER )
           _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
-        if ( pSpriteObjects[v21].stru_24.uItemID == 455 )
+        if ( pSpriteObjects[item_id].stru_24.uItemID == 455 )
           _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
-        if ( !pParty->AddItemToParty(&pSpriteObjects[v21].stru_24) )
-          pParty->SetHoldingItem(&pSpriteObjects[v21].stru_24);
+        if ( !pParty->AddItemToParty(&pSpriteObjects[item_id].stru_24) )
+          pParty->SetHoldingItem(&pSpriteObjects[item_id].stru_24);
       }
-      SpriteObject::OnInteraction(a2.y);
+      SpriteObject::OnInteraction(item_id);
       return;
     }
     if ( !pParty->pPickedItem.uItemID )
@@ -339,8 +339,8 @@
     memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
 
     extern int UnprojectX(int);
-    v9 = UnprojectX(v1->x);
-    a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+    //v9 = UnprojectX(v1->x);
+    a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
     pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
     if (pTextureID != -1)
       pIcons_LOD->pTextures[pTextureID].Release();
@@ -350,13 +350,13 @@
   }
   if ( PID_TYPE(v0) == OBJECT_Actor)
   {
-    v16 = (signed int)(unsigned __int16)v0 >> 3;
-    a2.y = v16;
-    if ( pActors[v16].uAIState == 5 )
+    int mon_id = PID_ID(v0);
+    //a2.y = v16;
+    if ( pActors[mon_id].uAIState == Dead )
     {
       if ( (unsigned int)v0 < 0x2000000 )
       {
-        pActors[v16].LootActor();
+        pActors[mon_id].LootActor();
         return;
       }
       if ( !pParty->pPickedItem.uItemID )
@@ -393,8 +393,8 @@
       memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
 
       extern int UnprojectX(int);
-      v9 = UnprojectX(v1->x);
-      a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+      //v9 = UnprojectX(v1->x);
+      a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
       pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
       if (pTextureID != -1)
         pIcons_LOD->pTextures[pTextureID].Release();
@@ -404,7 +404,7 @@
     }
     if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
     {
-      if ( !pActors[v16].GetActorsRelation(0) && !(pActors[v16].uAttributes & 0x80000) )
+      if ( !pActors[mon_id].GetActorsRelation(0) && !(pActors[mon_id].uAttributes & 0x80000) )
       {
         if ( HIWORD(v0) >= clickable_distance)
         {
@@ -442,8 +442,8 @@
           memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
 
           extern int UnprojectX(int);
-          v9 = UnprojectX(v1->x);
-          a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+          //v9 = UnprojectX(v1->x);
+          a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
           pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
           if (pTextureID != -1)
             pIcons_LOD->pTextures[pTextureID].Release();
@@ -451,24 +451,24 @@
           pIcons_LOD->SyncLoadedFilesCount();
           return;
         }
-        if ( !pActors[v16].CanAct() )
+        if ( !pActors[mon_id].CanAct() )
           return;
-        v18 = a2.y;
-        Actor::AI_FaceObject(a2.y, 4, 0, 0);
-        if ( !pActors[v16].sNPC_ID )
+        //v18 = mon_id;
+        Actor::AI_FaceObject(mon_id, 4, 0, 0);
+        if ( !pActors[mon_id].sNPC_ID )
         {
-          if ( pNPCStats->pGroups_copy[pActors[v16].uGroup] )
+          if ( pNPCStats->pGroups_copy[pActors[mon_id].uGroup] )
           {
-            if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]] )
+            if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]] )
             {
-              pParty->uFlags |= 2u;
-              strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]]);
+              pParty->uFlags |= 2;
+              strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]]);
               sub_4451A8_press_any_key(0, 0, 0);
             }
           }
           return;
         }
-        pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, mon_id, 0);
         return;
       }
       if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
@@ -528,8 +528,8 @@
       memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
 
       extern int UnprojectX(int);
-      v9 = UnprojectX(v1->x);
-      a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+      //v9 = UnprojectX(v1->x);
+      a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
       pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
       if (pTextureID != -1)
         pIcons_LOD->pTextures[pTextureID].Release();
@@ -699,8 +699,8 @@
     memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
 
     extern int UnprojectX(int);
-    v9 = UnprojectX(v1->x);
-    a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+    //v9 = UnprojectX(v1->x);
+    a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
     pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
     if (pTextureID != -1)
       pIcons_LOD->pTextures[pTextureID].Release();