changeset 855:cb0b3badc7f7

Слияние
author Ritor1
date Sun, 31 Mar 2013 16:44:01 +0600
parents 06fc66ceecd6 (current diff) ceef50611567 (diff)
children 8638d5b2e46d
files GameUIs.cpp Vis.cpp mm7_2.cpp mm7_3.cpp
diffstat 21 files changed, 609 insertions(+), 668 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Actor.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1757,8 +1757,8 @@
   int outx; // [sp+48h] [bp-4h]@6
   float a4a; // [sp+58h] [bp+Ch]@45
 
-  v4 = (signed int)uObj1ID >> 3;
-  v5 = (uObj1ID & 7) - 2;
+  v4 = PID_ID(uObj1ID);
+  v5 = PID_TYPE(uObj1ID) - 2;
   v6 = uObj2ID;
   if ( !v5 )
   {
@@ -1868,8 +1868,8 @@
   }
 LABEL_28:
   v20 = v6;
-  v21 = v6 & 7;
-  v22 = v20 >> 3;
+  v21 = PID_TYPE(v6);
+  v22 = PID_ID(v20);
   if ( v21 == 2 )
   {
     v30 = v22;
@@ -2050,7 +2050,7 @@
 }
 
 //----- (00403C6C) --------------------------------------------------------
-void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
+void Actor::_403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
 {
   Actor *v3; // ebx@1
   char v4; // zf@1
@@ -2071,31 +2071,31 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@12
   AIDirection v20; // [sp+28h] [bp-2Ch]@12
   unsigned int v21; // [sp+44h] [bp-10h]@9
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v23; // [sp+4Ch] [bp-8h]@6
   unsigned int v24; // [sp+50h] [bp-4h]@1
   unsigned int v25; // [sp+5Ch] [bp+8h]@13
 
   v3 = &pActors[uActorID];
-  a2 = edx0;
+  //a2 = edx0;
   v4 = v3->pMonsterInfo.uMovementType == 5;
   v24 = uActorID;
   if ( v4 && v3->pMonsterInfo.uAIType == 1 )
   {
-    Actor::AI_Stand(uActorID, edx0, 0, arg0);
+    Actor::AI_Stand(uActorID, sTargetPid, 0, arg0);
     return;
   }
 
-  if ( (edx0 & 7) == OBJECT_Actor)
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
     {
-      v8 = edx0 >> 3;
+      v8 = PID_ID(sTargetPid);
       v6 = (AIDirection *)pActors[v8].vPosition.x;
       v7 = (AIDirection *)pActors[v8].vPosition.y;
       v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z);
     }
     else
     {
-      if ( (edx0 & 7) == OBJECT_Player)
+      if ( PID_TYPE(sTargetPid) == OBJECT_Player)
       {
         v6 = (AIDirection *)pParty->vPosition.x;
         v7 = (AIDirection *)pParty->vPosition.y;
@@ -2119,7 +2119,7 @@
       v13 = 0;
       if ( !arg0 )
       {
-        v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0);
+        v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0);
         v12 = &v20;
         memcpy(&v20, v14, sizeof(v20));
         v13 = 0;
@@ -2149,7 +2149,7 @@
       v3->UpdateAnimation();
     }
     else
-      Actor::_402AD7(v24, a2, rand() % 2, 64, arg0);
+      Actor::_402AD7(v24, sTargetPid, rand() % 2, 64, arg0);
 }
 
 //----- (00438CF3) --------------------------------------------------------
@@ -2482,16 +2482,16 @@
   v22 = uActorID;
   v3 = &pActors[uActorID];
   a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  if ( PID_TYPE(edx0) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(edx0);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(edx0) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2561,7 +2561,7 @@
 }
 
 //----- (00403854) --------------------------------------------------------
-void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_403854(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2580,24 +2580,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@9
   AIDirection v18; // [sp+28h] [bp-2Ch]@9
   int v19; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v21; // [sp+4Ch] [bp-8h]@3
   unsigned int v22; // [sp+50h] [bp-4h]@1
   unsigned int pDira; // [sp+5Ch] [bp+8h]@10
 
   v22 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2619,7 +2619,7 @@
     v10 = 0;
     if ( !pDir )
     {
-      v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0);
+      v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, sTargetPid, &a3, 0);
       v9 = &v18;
       memcpy(&v18, v11, sizeof(v18));
       v10 = 0;
@@ -2663,11 +2663,11 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v22, a2, v22, 64, pDir);
+    Actor::_402AD7(v22, sTargetPid, v22, 64, pDir);
 }
 
 //----- (0040368B) --------------------------------------------------------
-void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_40368B(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2685,24 +2685,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@9
   AIDirection v17; // [sp+28h] [bp-2Ch]@9
   int v18; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v20; // [sp+4Ch] [bp-8h]@3
   unsigned int v21; // [sp+50h] [bp-4h]@1
   unsigned int pDira; // [sp+5Ch] [bp+8h]@10
 
   v21 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2724,7 +2724,7 @@
     v10 = 0;
     if ( !pDir )
     {
-      v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0);
+      v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0);
       v9 = &v17;
       memcpy(&v17, v11, sizeof(v17));
       v10 = 0;
@@ -2754,11 +2754,11 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v21, a2, v21, 64, pDir);
+    Actor::_402AD7(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (00403476) --------------------------------------------------------
-void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_403476(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   int v4; // esi@3
@@ -2777,24 +2777,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@10
   AIDirection v18; // [sp+28h] [bp-2Ch]@10
   int v19; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   unsigned int v21; // [sp+4Ch] [bp-8h]@1
   int v22; // [sp+50h] [bp-4h]@3
   unsigned int pDira; // [sp+5Ch] [bp+8h]@11
 
   v21 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = pActors[v6].vPosition.x;
     v5 = pActors[v6].vPosition.y;
     v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = pParty->vPosition.x;
       v5 = pParty->vPosition.y;
@@ -2824,7 +2824,7 @@
     v11 = 0;
     if ( !pDir )
     {
-      v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0);
+      v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0);
       v10 = &v18;
       memcpy(&v18, v12, sizeof(v18));
       v11 = 0;
@@ -2858,7 +2858,7 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v21, a2, v21, 64, pDir);
+    Actor::_402AD7(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (004032B2) --------------------------------------------------------
@@ -3304,7 +3304,7 @@
 }
 
 //----- (00402968) --------------------------------------------------------
-void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4)
+void Actor::_402968(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4)
 {
   unsigned int v4; // esi@1
   Actor *v5; // ebx@1
@@ -3318,10 +3318,10 @@
   AIDirection v13; // [sp+5Ch] [bp-28h]@4
   signed int a1; // [sp+78h] [bp-Ch]@2
   unsigned int v15; // [sp+7Ch] [bp-8h]@1
-  signed int a2; // [sp+80h] [bp-4h]@1
+  //signed int a2; // [sp+80h] [bp-4h]@1
 
   v4 = uActorID;
-  a2 = edx0;
+  //a2 = edx0;
   v15 = uActorID;
   v5 = &pActors[uActorID];
   //result = pActors[uActorID].CanAct();
@@ -3332,13 +3332,13 @@
     if ( !a4 )
     {
       a4 = &v12;
-      memcpy(&v12, Actor::GetDirectionInfo(v7, a2, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
+      memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
       v7 = a1;
     }
     memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3));
     memcpy(&v13, &a3, sizeof(v13));
     if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)
-      || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
+      || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
     {
       if ( !uActionLength )
         uActionLength = 256;
@@ -3660,7 +3660,7 @@
       v14 = 4;
     if ( v14 != 0 )
     {
-      v15 = dword_4DF390;
+      v15 = dword_4DF380[4];
       if ( !_this->pMonsterInfo.uHostilityType )
         v15 = dword_4DF380[v14];
       v16 = abs(_this->vPosition.x - pParty->vPosition.x);
--- a/Actor.h	Sun Mar 31 16:42:11 2013 +0600
+++ b/Actor.h	Sun Mar 31 16:44:01 2013 +0600
@@ -43,7 +43,7 @@
   ACTOR_BUFF_CHARM = 1,  // an assumption
   ACTOR_BUFF_SHRINK = 3, // an assumption
   ACTOR_BUFF_STONED = 5,
-  ACTOR_BUFF_PARALYZED = 6,
+  ACTOR_BUFF_PARALYZED = 6
 };
 
 
@@ -204,11 +204,11 @@
   static void _4030AD(unsigned int uActorID, signed int edx0, int arg0);
   static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3);
   static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength);
-  static void _403476(unsigned int uActorID, signed int edx0, struct AIDirection *pDir);
-  static void _40368B(unsigned int uActorID, signed int edx0, struct AIDirection *pDir);
-  static void _403854(unsigned int uActorID, signed int edx0, struct AIDirection *pDir);
-  static void _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir);
-  static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0);
+  static void _403476(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void _40368B(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void _403854(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void _403A60(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void _403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0);
   static void __fastcall StandAwhile(unsigned int uActorID);
   static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4);
   static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4);
--- a/AudioPlayer.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/AudioPlayer.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -21,7 +21,7 @@
 #include "Bink_Smacker.h"
 
 #include "mm7_data.h"
-
+#include "MM7.h"
 
 
 PCMWAVEFORMAT pcmWaveFormat;
@@ -773,8 +773,8 @@
       }
       else
       {
-        int object_type = a3 & 7,
-            object_id = a3 >> 7;
+        int object_type = PID_TYPE(a3),
+            object_id = PID_ID(a3);
         switch (object_type)
         {
           case OBJECT_BLVDoor:
@@ -971,8 +971,8 @@
         sample_volume = uVolume;
       AIL_set_sample_volume(channel->hSample, sample_volume);
 
-      int object_type = a3 & 7,
-          object_id = a3 >> 7;
+      int object_type = PID_TYPE(a3),
+          object_id = PID_ID(a3);
       if (PartyX != -1)
       {
         if (!PartyX) PartyX = pParty->vPosition.x;
@@ -1065,7 +1065,7 @@
     v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
     goto LABEL_47;
   }
-  if ( (a3 & 7) == 2 )
+  if ( PID_TYPE(a3) == 2 )
   {
     v22 = pAudioPlayer->uNum3DSamples;
     if ( v22 < 16 )
@@ -1078,11 +1078,11 @@
       v96 = 7;
       v12 = 5;
     }
-    pLayingItem = &pSpriteObjects[a3 >> 3];
+    pLayingItem = &pSpriteObjects[PID_ID(a3)];
   }
   else
   {
-    if ( (a3 & 7) == 3 )
+    if ( PID_TYPE(a3) == 3 )
     {
       v18 = pAudioPlayer->uNum3DSamples;
       v12 = 0;
@@ -1090,7 +1090,7 @@
         v96 = 3 * v18 / 16;
       else
         v96 = 3;
-      pActor1 = &pActors[a3 >> 3];
+      pActor1 = &pActors[PID_ID(a3)];
       v20 = pActor1->vPosition.y;
       pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x;
       v100 = pActor1->vPosition.z;
@@ -1098,10 +1098,10 @@
       v21 = (double)v100;
       goto LABEL_47;
     }
-    if ( (a3 & 7) != 5 )
+    if ( PID_TYPE(a3) != 5 )
     {
       v13 = pAudioPlayer->uNum3DSamples;
-      if ( (a3 & 7) == 6 )
+      if ( PID_TYPE(a3) == 6 )
       {
         if ( v13 >= 16 )
         {
@@ -1151,7 +1151,7 @@
       v12 = 4;
       v96 = 4;
     }
-    pLayingItem = (SpriteObject *)&pLevelDecorations[a3 >> 3];
+    pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(a3)];
   }
   pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x;
   pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y;
@@ -1273,12 +1273,12 @@
       AIL_set_3D_sample_loop_count(*(int *)v42, v86);
       if ( PartyX == -1 )
       {
-        if ( (a3 & 7) == 1 )
+        if ( PID_TYPE(a3) == 1 )
         {
           if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
           {
 			//goto LABEL_103;
-            pBLVDoor = &pIndoor->pDoors[a3 >> 3];
+            pBLVDoor = &pIndoor->pDoors[PID_ID(a3)];
             if ( !pBLVDoor->uDoorID )
              return;
             pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets;
@@ -1323,15 +1323,15 @@
           }
           return;
         }
-        if ( (a3 & 7) == 2 )
+        if ( PID_TYPE(a3) == 2 )
         {
-          pLayingItem2 = &pSpriteObjects[a3 >> 3];
+          pLayingItem2 = &pSpriteObjects[PID_ID(a3)];
         }
         else
         {
-          if ( (a3 & 7) == 3 )
+          if ( PID_TYPE(a3) == 3 )
           {
-            pActor = &pActors[a3 >> 3];
+            pActor = &pActors[PID_ID(a3)];
             v46 = pActor->vPosition.y;
             pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x;
             uNumRepeatsb = pActor->vPosition.z;
@@ -1339,7 +1339,7 @@
             v47 = (double)uNumRepeatsb;
             goto LABEL_101;
           }
-          if ( (a3 & 7) != 5 )
+          if ( PID_TYPE(a3) != 5 )
           {
             pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
             v43 = (double)pParty->vPosition.y;
@@ -1348,7 +1348,7 @@
             v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
             goto LABEL_101;
           }
-          pLayingItem2 = (SpriteObject *)&pLevelDecorations[a3 >> 3];
+          pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(a3)];
         }
         pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x;
         pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y;
@@ -1462,7 +1462,7 @@
           v6 = this->p3DSamples;
           while ( 1 )
           {
-            v7 = v6->field_4 & 7;
+            v7 = PID_TYPE(v6->field_4);
             if ( AIL_3D_sample_status(v6->hSample) == 2 )
             {
               AIL_end_3D_sample(v6->hSample);
@@ -1475,7 +1475,7 @@
               break;
             if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
               goto LABEL_31;
-            v15 = &pIndoor->pDoors[v6->field_4 >> 3];
+            v15 = &pIndoor->pDoors[PID_ID(v6->field_4)];
             if ( v15->uDoorID )
             {
               uNumRepeats = *v15->pXOffsets;
@@ -1502,7 +1502,7 @@
             v10 = v9 - 1;
             if ( !v10 )
             {
-              v13 = &pActors[v6->field_4 >> 3];
+              v13 = &pActors[PID_ID(v6->field_4)];
               uNumRepeats = v13->vPosition.x;
               v14 = v13->vPosition.y;
               a1.vWorldPosition.x = (double)uNumRepeats;
@@ -1518,11 +1518,11 @@
               v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
               goto LABEL_21;
             }
-            v12 = (SpriteObject *)&pLevelDecorations[v6->field_4 >> 3];
+            v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)];
           }
           else
           {
-            v12 = &pSpriteObjects[v6->field_4 >> 3];
+            v12 = &pSpriteObjects[PID_ID(v6->field_4)];
           }
           a1.vWorldPosition.x = (double)v12->vPosition.x;
           a1.vWorldPosition.y = (double)v12->vPosition.y;
@@ -1623,8 +1623,8 @@
     if (channel->source_pid <= 0)
       continue;
 
-    int source_type = channel->source_pid & 7,
-        source_id = channel->source_pid >> 3;
+    int source_type = PID_TYPE(channel->source_pid),
+        source_id = PID_ID(channel->source_pid);
     int source_x,
         source_y,
         source_z;
--- a/Chest.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Chest.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -20,7 +20,7 @@
 #include "Overlays.h"
 
 #include "mm7_data.h"
-
+#include "MM7.h"
 
 
 
@@ -109,9 +109,9 @@
     v31 = 813;
     v32 = 814;
     v5 = rand() % 4;
-    v6 = EvtTargetObj >> 3;
+    v6 = PID_ID(EvtTargetObj);
     v35 = v5;
-    if ( (EvtTargetObj & 7) == OBJECT_Decoration)
+    if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration)
     {
       v16 = v6;
       v14 = pLevelDecorations[v6].vPosition.x;
@@ -121,7 +121,7 @@
     }
     else
     {
-      if ( (EvtTargetObj & 7) != OBJECT_BModel)
+      if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel)
         goto LABEL_12;
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
       {
--- a/Game.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Game.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -84,12 +84,13 @@
     if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.y 
        | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sEyelevel != pParty->sPrevEyelevel )
       pParty->uFlags |= 2u;
-    pParty->vPrevPosition = pParty->vPosition;
+    pParty->vPrevPosition.x = pParty->vPosition.x;
     pParty->vPrevPosition.y = pParty->vPosition.y;
+    pParty->vPrevPosition.z = pParty->vPosition.z;
     //v0 = &pRenderer;
     pParty->sPrevRotationY = pParty->sRotationY;
-    pParty->vPrevPosition.z = pParty->vPosition.z;
     pParty->sPrevRotationX = pParty->sRotationX;
+
     pParty->sPrevEyelevel = pParty->sEyelevel;
     pRenderer->BeginSceneD3D();
 
--- a/GameUIs.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-#include <direct.h>
-#include <io.h>
-#include <assert.h>
-
-#include "GUIWindow.h"
-#include "GUIFont.h"
-#include "LOD.h"
-#include "SaveLoad.h"
-#include "Render.h"
-#include "texts.h"
-
-#include "mm7_data.h"
-
-
-//----- (0045E361) --------------------------------------------------------
-void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
-{
-  unsigned int v1; // ebp@5
-  unsigned int v2; // eax@5
-  //signed int v3; // ebp@11
-  FILE *v4; // eax@14
-  FILE *v5; // eax@18
-  unsigned int v6; // eax@25
-  GUIButton *v7; // eax@27
-  const char *v8; // [sp-8h] [bp-26Ch]@25
-  //char *v9; // [sp-4h] [bp-268h]@19
-  enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
-  unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
-  //RGBTexture *pTex; // [sp+10h] [bp-254h]@12
-  //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
-  //const char *Str1; // [sp+18h] [bp-24Ch]@12
-  LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
-  int v16; // [sp+260h] [bp-4h]@1
-
-  uDialogueType_ = uDialogueType;
-  dword_6BE138 = -1;
-  pIcons_LOD->_inlined_sub2();
-
-  memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
-  memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture));
-  uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
-  uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
-  uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-  if ( uDialogueType_ )
-  {
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-    if ( pCurrentScreen == SCREEN_SAVEGAME )
-    {
-      v1 = uTextureID_save_up;
-      v2 = uTextureID_LS_saveU;
-    }
-    else
-    {
-      v1 = uTextureID_load_up;
-      v2 = uTextureID_LS_loadU;
-    }
-    pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-    pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-    pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-  }
-  else
-  {
-    pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
-  }
-  pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_],
-                             saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0);
-  pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
-  pRenderer->Present();
-  pSavegameList->Initialize(0);
-  if ( pSaveListPosition > (signed int)uNumSavegameFiles )
-  {
-    pSaveListPosition = 0;
-    uLoadGameUI_SelectedSlot = 0;
-  }
-  pLODFile.AllocSubIndicesAndIO(0x12C, 0);
-  assert(sizeof(SavegameHeader) == 0x64);
-  //v3 = 0;
-  for (uint i = 0; i < uNumSavegameFiles; ++i)
-  {
-   
-    sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
-    if (_access(pTmpBuf, 6))
-    {
-      pSavegameUsedSlots[i] = 0;
-      strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
-      continue;
-    }
-	pLODFile.LoadFile(pTmpBuf, 1);
-    v4 = pLODFile.FindContainer("header.bin", true);
-    if ( v4 )
-      fread(&pSavegameHeader[i], 0x64, 1, v4);
-    if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
-      strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
-    v5 = pLODFile.FindContainer("image.pcx", true);
-    if ( !v5 )
-    {
-      pSavegameUsedSlots[i] = 0;
-      strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
-    }
-    else
-    {
-      pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
-      pLODFile.CloseWriteFile();
-      pSavegameUsedSlots[i] = 1;
-    }
-  }
-
-//LABEL_24:
-  pLODFile.FreeSubIndexAndIO();
-  if ( pCurrentScreen == SCREEN_SAVEGAME )
-  {
-    uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-    uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE);
-  }
-  else
-  {
-    uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-    uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE);
-  }
-  uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
-  uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
-  pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-                 pIcons_LOD->GetTexture(uTextureID_LS_), 0);
-  pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "",
-                 pIcons_LOD->GetTexture(uTextureID_x_d), 0);
-  pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-                 pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
-  pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "",
-         pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
-
-}
-
-//----- (0045E93E) --------------------------------------------------------
-void  GameUI_DrawSaveMenu()
-{
-  unsigned int v0; // ebp@4
-  unsigned int v1; // eax@4
-  char *v3; // eax@7
-  FILE *v4; // eax@11
-  FILE *v5; // eax@11
-  LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
-
-  ++pIcons_LOD->uTexturePacksCount;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  memset(pSavegameUsedSlots, 0, 0xB4u);
-  memset(&pSavegameThumbnails, 0, 0x708u);
-  uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
-  uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
-  uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-  pRenderer->DrawTextureIndexed( 8u, 8u,
-    (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-  if ( pCurrentScreen == SCREEN_SAVEGAME )
-  {
-    v0 = uTextureID_save_up;
-    v1 = uTextureID_LS_saveU;
-  }
-  else
-  {
-    v0 = uTextureID_load_up;
-    v1 = uTextureID_LS_loadU;
-  }
-  pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-  pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
-    (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-  pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
-  pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
-  pRenderer->Present();
-  pSavegameList->Initialize(1u);
-  v11.AllocSubIndicesAndIO(0x12Cu, 0);
-  //v2 = pSavegameUsedSlots;
- // Dest = pSavegameHeader;
- // this_ = pSavegameThumbnails;
- // v8 = (char *)pSavegameList->pSavesNames;
-  for (uint i = 0; i < 40; ++i)
-	  {
-    v3 = pSavegameList->pFileList[i].pSaveFileName;
-    if ( !*pSavegameList->pFileList[i].pSaveFileName )
-      v3 = "1.mm7";
-    sprintf(pTmpBuf, "saves\\%s", v3);
-    if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
-    {
-      pSavegameUsedSlots[i] = 0;
-      strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
-    }
-    else
-    {
-      v11.LoadFile(pTmpBuf, 1);
-      v4 = v11.FindContainer("header.bin", 1);
-      fread(&pSavegameHeader[i], 100, 1u, v4);
-      v5 = v11.FindContainer("image.pcx", 1);
-      if ( v5 )
-      {
-        pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u);
-        v11.CloseWriteFile();
-        pSavegameUsedSlots[i] = 1;
-      }
-      else
-      {
-        pSavegameUsedSlots[i] = 0;
-      }
-    }
- 
-  }
-  
-  v11.FreeSubIndexAndIO();
-  uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
-  uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
-  uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0);
-  pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-                 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
-  pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "",
-                 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
-  pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-         (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
-  pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "",
-         (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
-}
\ No newline at end of file
--- a/Indoor.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Indoor.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -4082,12 +4082,12 @@
             v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
             v0->uSectorID = LOWORD(stru_721530.uSectorID);
             stru_721530.field_70 += stru_721530.field_7C;
-            v37 = v36 >> 3;
-            if ( (v36 & 7) != OBJECT_Actor)
+            v37 = PID_ID(v36);
+            if ( PID_TYPE(v36) != OBJECT_Actor)
             {
-              if ( (v36 & 7) != OBJECT_Player)
+              if ( PID_TYPE(v36) != OBJECT_Player)
               {
-                if ( (v36 & 7) == OBJECT_Decoration)
+                if ( PID_TYPE(v36) == OBJECT_Decoration)
                 {
                   _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
                   v45 = stru_5C6E00->Atan2(
@@ -4104,7 +4104,7 @@
                   v0->vVelocity.y = WORD1(v48);
                   goto LABEL_119;
                 }
-                if ( (v36 & 7) == OBJECT_BModel)
+                if ( PID_TYPE(v36) == OBJECT_BModel)
                 {
                   stru_721530.field_84 = v36 >> 3;
                   v38 = &pIndoor->pFaces[v37];
--- a/Party.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Party.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -142,7 +142,7 @@
   {
     if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player)
       return 0;
-    v2 = pTurnEngine->pQueue[0].uPackedID >> 3;
+    v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID);
     return v2 + 1;
   }
   v4 = 0;
--- a/SaveLoad.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/SaveLoad.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -230,77 +230,31 @@
 //----- (0045F469) --------------------------------------------------------
 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
     {
-  int result; // eax@1
   unsigned short *pScreenshot; // edi@5
   int text_pos; // eax@6
-  int v5; // eax@6
-  int v6; // eax@6
-  const char *v7; // edi@8
-  FILE *v8; // edi@24
+  FILE *pLLoidFile; // edi@24
   char* compressed_buf; // edi@30
-  void *v10; // esi@31
-  void *v11; // esi@31
-  void *v12; // esi@37
-  void *v13; // esi@37
-  void *v14; // esi@37
-  void *v15; // esi@37
-  void *v16; // esi@37
-  int v17; // esi@37
-  unsigned int v18; // ecx@38
-  unsigned int v19; // esi@39
-  BSPModel *v20; // edx@39
   char *data_write_pos; // esi@41
-  void *v22; // esi@41
-  BSPModel *v23; // eax@42
-  signed int v24; // edi@42
-  unsigned __int8 v25; // zf@43
-  unsigned __int8 v26; // sf@43
-  signed int v27; // edi@47
-  void *v28; // esi@50
-  void *v29; // esi@50
-  void *v30; // esi@50
-  void *v31; // esi@50
-  int v32; // esi@51
-  int v33; // eax@51
-  DWORD v34; // eax@59
-  //std::string v35; // [sp-18h] [bp-288h]@8
-  const char *v36; // [sp-10h] [bp-280h]@6
-  const char *v37; // [sp-Ch] [bp-27Ch]@6
-  unsigned int *v38; // [sp-8h] [bp-278h]@8
-  CHAR Buffer; // [sp+Ch] [bp-264h]@59
+  CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59
   char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
   char Drive[255]; // [sp+ACh] [bp-1C4h]@51
   SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10
-  //int v43; // [sp+CCh] [bp-1A4h]@10
-  //char Dest[20]; // [sp+E0h] [bp-190h]@10
-  //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10
   char Filename[255]; // [sp+130h] [bp-140h]@51
   char Ext[255]; // [sp+150h] [bp-120h]@51
-  char v48; // [sp+151h] [bp-11Fh]@51
   char Source[32]; // [sp+170h] [bp-100h]@51
-  char Str[120]; // [sp+190h] [bp-E0h]@8
-  int v51; // [sp+208h] [bp-68h]@2
+  char work_string[120]; // [sp+190h] [bp-E0h]@8
+  int pPositionY; // [sp+208h] [bp-68h]@2
   int pPositionX; // [sp+20Ch] [bp-64h]@2
-  int v53; // [sp+210h] [bp-60h]@2
-  int v54; // [sp+214h] [bp-5Ch]@2
+  int sPRotationY; // [sp+210h] [bp-60h]@2
+  int sPRotationX; // [sp+214h] [bp-5Ch]@2
   ODMHeader odm_data; // [sp+218h] [bp-58h]@30
-  char v56; // [sp+21Ch] [bp-54h]@30
-  char v57; // [sp+21Dh] [bp-53h]@30
-  char v58; // [sp+21Eh] [bp-52h]@30
-  char v59; // [sp+21Fh] [bp-51h]@30
-  int v60; // [sp+220h] [bp-50h]@30
-  int v61; // [sp+224h] [bp-4Ch]@30
-  int v62; // [sp+228h] [bp-48h]@2
+  int res; // [sp+224h] [bp-4Ch]@30
+  int pPositionZ; // [sp+228h] [bp-48h]@2
   LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2
   size_t Size; // [sp+250h] [bp-20h]@26
-  __int16 *v66; // [sp+254h] [bp-1Ch]@1
   char *uncompressed_buff; // [sp+258h] [bp-18h]@2
-  __int16 *v68; // [sp+25Ch] [bp-14h]@32
   unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23
-  int v70; // [sp+264h] [bp-Ch]@22
-  std::string *v71; // [sp+268h] [bp-8h]@8
-  int a3; // [sp+26Fh] [bp-1h]@8
-  
+ 
   //v66 = a2;
   strcpy(byte_6BE3B0, pCurrentMapName);
   if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena
@@ -309,14 +263,16 @@
   uncompressed_buff = (char*)malloc(1000000);
   pLodDirectory.Reset();
   pPositionX = pParty->vPosition.x;
-  v51 = pParty->vPosition.y;
-  v62 = pParty->vPosition.z;
-  v53 = pParty->sRotationY;
-  v54 = pParty->sRotationX;
+  pPositionY = pParty->vPosition.y;
+  pPositionZ = pParty->vPosition.z;
+  sPRotationY = pParty->sRotationY;
+  sPRotationX = pParty->sRotationX;
   pParty->vPosition.x = pParty->vPrevPosition.x;
-  pParty->vPosition.y = pParty->vPrevPosition.z;
-  pParty->vPosition.z = pParty->vPrevPosition.y;
-  pParty->uFallStartY = pParty->vPrevPosition.y;
+  pParty->vPosition.z = pParty->vPrevPosition.z;
+  pParty->vPosition.y = pParty->vPrevPosition.y;
+
+  pParty->uFallStartY = pParty->vPrevPosition.z;
+
   pParty->sRotationY = pParty->sPrevRotationY;
   pParty->sRotationX = pParty->sPrevRotationX;
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -342,8 +298,8 @@
 
   if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0))
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //  ! Code=%d
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //  ! Code=%d
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
   }
 
   assert(sizeof(SavegameHeader) == 100);
@@ -356,66 +312,66 @@
   pLodDirectory.uDataSize = sizeof(SavegameHeader);
   if (pNew_LOD->Write(&pLodDirectory, &save_header, 0))
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
   }
   strcpy(pLodDirectory.pFilename, "party.bin");
   pLodDirectory.uDataSize = sizeof(Party); //90680;
   if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
   }
   strcpy(pLodDirectory.pFilename, "clock.bin");
   pLodDirectory.uDataSize =sizeof(Timer);// 40;
   if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
   }
   strcpy(pLodDirectory.pFilename, "overlay.bin");
   pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008;
   if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
   }
   strcpy(pLodDirectory.pFilename, "npcdata.bin");
   pLodDirectory.uDataSize = 501 * sizeof(NPCData);
   assert(pLodDirectory.uDataSize == 38076);
   if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
   }
   strcpy(pLodDirectory.pFilename, "npcgroup.bin");
   pLodDirectory.uDataSize = 102;
   if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
   }
   for (int i =  1; i <= 4; ++i) // 4 - players
   {
     for (int j =  1; j <= 5; ++j) // 5 - images
     {
-      sprintf(Str, "data\\lloyd%d%d.pcx", i, j);
-      v8 = fopen(Str, "rb");
-      if ( v8 )
+      sprintf(work_string, "data\\lloyd%d%d.pcx", i, j);
+      pLLoidFile = fopen(work_string, "rb");
+      if ( pLLoidFile )
       {
         __debugbreak();
-        sprintf(Str, "lloyd%d%d.pcx", i, j);
-        fseek(v8, 0, 2);
-        pLodDirectory.uDataSize = ftell(v8);
-        rewind(v8);
-        fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8);
-        strcpy((char *)&pLodDirectory, Str);
-        fclose(v8);
-        remove(Str);
+        sprintf(work_string, "lloyd%d%d.pcx", i, j);
+        fseek(pLLoidFile, 0, SEEK_END);
+        pLodDirectory.uDataSize = ftell(pLLoidFile);
+        rewind(pLLoidFile);
+        fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile);
+        strcpy(pLodDirectory.pFilename, work_string);
+        fclose(pLLoidFile);
+        remove(work_string);
         if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) )
         {
-          sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
+          sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207);
+          MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
           Size = 5080748;
         }
       }
@@ -467,8 +423,8 @@
       data_write_pos += 112 * uNumSpriteObjects;
       memcpy(data_write_pos, &uNumChests, 4);
       data_write_pos += 4;
-      memcpy(data_write_pos, pChests, 5324 * uNumChests);
-      data_write_pos += 5324 * uNumChests;
+      memcpy(data_write_pos, pChests, sizeof(Chest)*uNumChests);//5324 *
+      data_write_pos += sizeof(Chest)* uNumChests;
       memcpy(data_write_pos, pIndoor->pDoors, 0x3E80);
       data_write_pos += 16000;
       memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
@@ -516,8 +472,8 @@
       data_write_pos += 112 * uNumSpriteObjects;
       memcpy(data_write_pos, &uNumChests, 4);
       data_write_pos += 4;
-      memcpy(data_write_pos, pChests, 5324 * uNumChests);
-      data_write_pos += 5324 * uNumChests;
+      memcpy(data_write_pos, pChests, sizeof(Chest)* uNumChests);
+      data_write_pos += sizeof(Chest)* uNumChests;
       memcpy(data_write_pos, &stru_5E4C90, 0xC8);
       data_write_pos += 200;
       memcpy(data_write_pos, &pOutdoor->loc_time, 0x38);
@@ -525,11 +481,11 @@
     }
     strcpy(Source, pCurrentMapName);
     _splitpath(Source, Drive, Dir, Filename, Ext);
-    v48 = 100;
+   
     Size = (int)data_write_pos - (int)uncompressed_buff;
     compressed_block_size = 999984;
-    LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
-    if ( v33 || (signed int)compressed_block_size > (signed int)Size )
+    res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
+    if (res || (signed int)compressed_block_size > (signed int)Size )
     {
       memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size);
       compressed_block_size = Size;
@@ -538,12 +494,12 @@
     memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
     memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
     sprintf(Source, "%s%s", &Filename, &Ext);
-    strcpy((char *)&pLodDirectory, Source);
+    strcpy(pLodDirectory.pFilename, Source);
     pLodDirectory.uDataSize = compressed_block_size;
     if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
     {
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
+      sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208);
+      MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
     }
     free((void *)compressed_buf);
   }
@@ -552,18 +508,17 @@
   {
     if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
     {
-      v34 = GetLastError();
-      FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0);
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
+      FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0);
+      sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300);
+      MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
     }
   }
   pParty->vPosition.x = pPositionX;
-  pParty->vPosition.y = v51;
-  pParty->vPosition.z = v62;
-  pParty->uFallStartY = v62;
-  pParty->sRotationY = v53;
-  pParty->sRotationX = v54;
+  pParty->vPosition.y = pPositionY;
+  pParty->vPosition.z = pPositionZ;
+  pParty->uFallStartY = pPositionZ;
+  pParty->sRotationY = sPRotationY;
+  pParty->sRotationX = sPRotationX;
 }
 
 
--- a/UIPopup.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/UIPopup.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -2131,20 +2131,20 @@
                         if ( pRenderer->uNumSceneBegins )
                             {
                             pWindow.DrawMessageBox(1);
-                            MonsterPopup_Draw(v6 >> 3, &pWindow);
+                            MonsterPopup_Draw(PID_ID(v6), &pWindow);
                             }
                         else
                             {
                             pRenderer->BeginScene();
                             pWindow.DrawMessageBox(1);
-                            MonsterPopup_Draw(v6 >> 3, &pWindow);
+                            MonsterPopup_Draw(PID_ID(v6), &pWindow);
                             pRenderer->EndScene();
                             }
                         }
                     }
                 else
                     {
-                    v7 = v6 >> 3;
+                    v7 = PID_ID(v6);
                     if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) )
                         {
                         v8 = &pSpriteObjects[v7].stru_24;
--- a/UISaveLoad.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/UISaveLoad.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1,5 +1,5 @@
 #include <assert.h>
-
+#include <io.h>
 #include "MM7.h"
 
 #include "MapInfo.h"
@@ -134,7 +134,7 @@
     pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName);
     pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3);
     v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60;
-    pMinutes = (int)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32;
+    pMinutes = (int)(((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32);
     v9 = v8;
     v8 /= 60i64;
     pAMPM2 = v8;
@@ -156,7 +156,7 @@
     pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261;
     HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12)
                 && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24);
-    if ( v14  != 0 || (signed int)v14 <= 0 && (unsigned int)pOurHour <= 12 )
+    if ( v14  != 0 || ((signed int)v14 <= 0) && (unsigned int)pOurHour <= 12 )
     {
       if ( !(v14 | (unsigned int)pOurHour) )
       {
@@ -264,3 +264,230 @@
         //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels);
         pSavegameThumbnails[i].Release();
     }
+
+//----- (0045E361) --------------------------------------------------------
+void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
+    {
+    unsigned int v1; // ebp@5
+    unsigned int v2; // eax@5
+    //signed int v3; // ebp@11
+    FILE *v4; // eax@14
+    FILE *v5; // eax@18
+    unsigned int v6; // eax@25
+    GUIButton *v7; // eax@27
+    const char *v8; // [sp-8h] [bp-26Ch]@25
+    //char *v9; // [sp-4h] [bp-268h]@19
+    enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
+    unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
+    //RGBTexture *pTex; // [sp+10h] [bp-254h]@12
+    //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
+    //const char *Str1; // [sp+18h] [bp-24Ch]@12
+    LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
+    int v16; // [sp+260h] [bp-4h]@1
+
+    uDialogueType_ = uDialogueType;
+    dword_6BE138 = -1;
+    pIcons_LOD->_inlined_sub2();
+
+    memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
+    memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture));
+    uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
+    uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
+    uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
+    uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
+    uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
+    uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
+    if ( uDialogueType_ )
+        {
+        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+        if ( pCurrentScreen == SCREEN_SAVEGAME )
+            {
+            v1 = uTextureID_save_up;
+            v2 = uTextureID_LS_saveU;
+            }
+        else
+            {
+            v1 = uTextureID_load_up;
+            v2 = uTextureID_LS_loadU;
+            }
+        pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
+        pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
+        pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+        }
+    else
+        {
+        pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
+        }
+    pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_],
+        saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
+    pRenderer->Present();
+    pSavegameList->Initialize(0);
+    if ( pSaveListPosition > (signed int)uNumSavegameFiles )
+        {
+        pSaveListPosition = 0;
+        uLoadGameUI_SelectedSlot = 0;
+        }
+    pLODFile.AllocSubIndicesAndIO(0x12C, 0);
+    assert(sizeof(SavegameHeader) == 0x64);
+    //v3 = 0;
+    for (uint i = 0; i < uNumSavegameFiles; ++i)
+        {
+
+        sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
+        if (_access(pTmpBuf, 6))
+            {
+            pSavegameUsedSlots[i] = 0;
+            strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
+            continue;
+            }
+        pLODFile.LoadFile(pTmpBuf, 1);
+        v4 = pLODFile.FindContainer("header.bin", true);
+        if ( v4 )
+            fread(&pSavegameHeader[i], 0x64, 1, v4);
+        if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
+            strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
+        v5 = pLODFile.FindContainer("image.pcx", true);
+        if ( !v5 )
+            {
+            pSavegameUsedSlots[i] = 0;
+            strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
+            }
+        else
+            {
+            pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
+            pLODFile.CloseWriteFile();
+            pSavegameUsedSlots[i] = 1;
+            }
+        }
+
+    //LABEL_24:
+    pLODFile.FreeSubIndexAndIO();
+    if ( pCurrentScreen == SCREEN_SAVEGAME )
+        {
+        uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
+        uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE);
+        }
+    else
+        {
+        uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
+        uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE);
+        }
+    uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
+    uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
+    pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
+    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "",
+        pIcons_LOD->GetTexture(uTextureID_LS_), 0);
+    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "",
+        pIcons_LOD->GetTexture(uTextureID_x_d), 0);
+    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "",
+        pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "",
+        pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
+
+    }
+
+//----- (0045E93E) --------------------------------------------------------
+void  GameUI_DrawSaveMenu()
+    {
+    unsigned int v0; // ebp@4
+    unsigned int v1; // eax@4
+    char *v3; // eax@7
+    FILE *v4; // eax@11
+    FILE *v5; // eax@11
+    LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
+
+    ++pIcons_LOD->uTexturePacksCount;
+    if ( !pIcons_LOD->uNumPrevLoadedFiles )
+        pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+    memset(pSavegameUsedSlots, 0, 0xB4u);
+    memset(&pSavegameThumbnails, 0, 0x708u);
+    uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
+    uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
+    uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
+    uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
+    uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
+    uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
+    pRenderer->DrawTextureIndexed( 8u, 8u,
+        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+    if ( pCurrentScreen == SCREEN_SAVEGAME )
+        {
+        v0 = uTextureID_save_up;
+        v1 = uTextureID_LS_saveU;
+        }
+    else
+        {
+        v0 = uTextureID_load_up;
+        v1 = uTextureID_LS_loadU;
+        }
+    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
+    pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
+        (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+    pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
+    pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
+    pRenderer->Present();
+    pSavegameList->Initialize(1u);
+    v11.AllocSubIndicesAndIO(0x12Cu, 0);
+    //v2 = pSavegameUsedSlots;
+    // Dest = pSavegameHeader;
+    // this_ = pSavegameThumbnails;
+    // v8 = (char *)pSavegameList->pSavesNames;
+    for (uint i = 0; i < 40; ++i)
+        {
+        v3 = pSavegameList->pFileList[i].pSaveFileName;
+        if ( !*pSavegameList->pFileList[i].pSaveFileName )
+            v3 = "1.mm7";
+        sprintf(pTmpBuf, "saves\\%s", v3);
+        if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
+            {
+            pSavegameUsedSlots[i] = 0;
+            strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
+            }
+        else
+            {
+            v11.LoadFile(pTmpBuf, 1);
+            v4 = v11.FindContainer("header.bin", 1);
+            fread(&pSavegameHeader[i], 100, 1u, v4);
+            v5 = v11.FindContainer("image.pcx", 1);
+            if ( v5 )
+                {
+                pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u);
+                v11.CloseWriteFile();
+                pSavegameUsedSlots[i] = 1;
+                }
+            else
+                {
+                pSavegameUsedSlots[i] = 0;
+                }
+            }
+
+        }
+
+    v11.FreeSubIndexAndIO();
+    uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
+    uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
+    uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
+    uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
+    pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0);
+    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "",
+        (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
+    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "",
+        (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
+    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "",
+        (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "",
+        (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
+    }
--- a/UiGame.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/UiGame.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1420,7 +1420,7 @@
                             if ( pParty->uFlags & 0x20 )
                                 v16 = dword_5079C8;
                             }
-                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
+                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4,
                             0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
                         }
                     }
--- a/Vis.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/Vis.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1559,8 +1559,8 @@
     case VisObjectType_Sprite:
     {
       v5 = filter->field_10;
-      int object_idx = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 0xFFFF) >> 3;
-      int object_type = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 7;
+      int object_idx = PID_ID(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid);
+      int object_type = PID_TYPE(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid);
       if ( v5 & 2 )
       {
         if (object_type == filter->object_id)
--- a/mm7_1.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_1.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1076,7 +1076,7 @@
     v1 = pMouse->GetCursorPos(&a2);
     v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]];
   }
-  if ( (v0 & 7) == OBJECT_Item)
+  if ( PID_TYPE(v0) == OBJECT_Item)
   {
     a2.y = (signed int)(unsigned __int16)v0 >> 3;
     v21 = (signed int)(unsigned __int16)v0 >> 3;
@@ -1111,9 +1111,9 @@
 		return;
     goto LABEL_14;
   }
-  if ( (v0 & 7) != OBJECT_Actor)
+  if ( PID_TYPE(v0) != OBJECT_Actor)
   {
-    if ( (v0 & 7) == OBJECT_Decoration)
+    if ( PID_TYPE(v0) == OBJECT_Decoration)
     {
       v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
       if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 )
@@ -1139,7 +1139,7 @@
     }
     else
     {
-      if ( (v0 & 7) != OBJECT_BModel || (signed)v0 >= 0x2000000 )
+      if ( PID_TYPE(v0) != OBJECT_BModel || (signed)v0 >= 0x2000000 )
 	  {
           v4 = pParty->pPickedItem.uItemID;
           if ( !pParty->pPickedItem.uItemID )
--- a/mm7_2.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_2.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -382,7 +382,7 @@
 		  do
 		  {
 			v2 = v1->uAIState;
-			if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == OBJECT_Player)
+			if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && PID_TYPE(v3) == OBJECT_Player)
 			  ++v0;
 			++v1;
 			--v7;
@@ -4982,7 +4982,7 @@
   LOWORD(v7) = v5 & 0xE0;
   v12 = v7 + v11;
   LOWORD(v7) = v8 & 0xE0;
-  return ((v8 & 7) + (v5 & 7) + (a3a & 7) + (v6 & 7)) | (v7 + v12) | ((v8 & 0x1C00)
+  return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00)
                                                                     + (v5 & 0x1C00)
                                                                     + v9
                                                                     + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
@@ -10213,11 +10213,11 @@
 				}
 				while ( v6 < v22 );
 			  }
-			  if ( (v7 & 7) == OBJECT_Decoration)
+			  if ( PID_TYPE(v7) == OBJECT_Decoration)
 			  {
-				v16 = (unsigned int)v7 >> 3;
+				v16 = (unsigned int)PID_ID(v7);
 				if ( (signed int)(((unsigned int)*v21 >> 16)
-								- pDecorationList->pDecorations[pLevelDecorations[(unsigned int)v7 >> 3].uDecorationDescID].uRadius) <= 512 )
+								- pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 )
 				  if ( v19 == v22 && v4 < 100 )
 				  {
 					++v22;
@@ -10311,12 +10311,12 @@
 
   v26 = a2;
   v2 = a1;
-  switch ( a1 & 7 )
+  switch ( PID_TYPE(a1) )
   {
     case OBJECT_Item: // take the item
-      v17 = a1 >> 3;
-      v26 = a1 >> 3;
-      v18 = a1 >> 3;
+      v17 = PID_ID(a1);
+      v26 = PID_ID(a1);
+      v18 = PID_ID(a1);
       if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10
         || v17 >= 1000
         || !pSpriteObjects[v18].uObjectDescID )
@@ -10348,14 +10348,14 @@
       break;
 
     case OBJECT_Actor:
-      v12 = a1 >> 3;
-      v13 = &pActors[a1 >> 3];
+      v12 = PID_ID(a1);
+      v13 = &pActors[PID_ID(a1)];
       v14 = v13->uAIState;
       if ( v14 == 4 || v14 == 17 )
         return 1;
       if ( v14 == 5 )
       {
-        stru_50C198.LootActor(&pActors[a1 >> 3]);
+        stru_50C198.LootActor(&pActors[PID_ID(a1)]);
       }
       else
       {
@@ -10392,7 +10392,7 @@
       break;
 
     case OBJECT_Decoration:
-      v8 = &pLevelDecorations[a1 >> 3];
+      v8 = &pLevelDecorations[PID_ID(a1)];
       v9 = v8->field_16_event_id;
       if ( v9 )
       {
@@ -10401,7 +10401,7 @@
       }
       else
       {
-        if ( !pLevelDecorations[a1 >> 3].IsInteractive() )
+        if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() )
           return 1;
         v10 = v8->_idx_in_stru123;
         v24 = 1;
@@ -10413,7 +10413,7 @@
       break;
 
     default:
-      if ( (a1 & 7) != OBJECT_BModel)
+      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;
@@ -10421,13 +10421,13 @@
       if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
       {
         if ( a1 >> 9 >= pOutdoor->uNumBModels
-          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
+          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
           || (v6 = v7->sCogTriggeredID) == 0 )
           return 1;
         EventProcessor((signed __int16)v6, v2, 1);
         return 0;
       }
-      v4 = &pIndoor->pFaces[a1 >> 3];
+      v4 = &pIndoor->pFaces[PID_ID(a1)];
       v5 = v4->uAttributes;
       if ( !(v5 & 0x2000000) )
       {
@@ -10488,11 +10488,11 @@
           v6 = ((v12 - v4 - 1) >> 1) + 1;
           do
           {
-            if ( (*(char *)v5 & 7) == OBJECT_Actor)
+            if ( PID_TYPE(*(char *)v5) == OBJECT_Actor)
             {
               if ( *v5 <= a3 << 16 )
               {
-                v7 = (signed int)(unsigned __int16)*v5 >> 3;
+                v7 = PID_ID((signed int)(unsigned __int16)*v5);
                 v8 = pActors[v7].uAIState;
                 if ( v8 != 5 )
                 {
@@ -10559,11 +10559,11 @@
       v3 = pRenderer->GetParentBillboardID(a1a);
       v4 = pBillboardRenderList[v3].sZValue;
       v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
-      if ( (v5 & 7) == OBJECT_Actor)
+      if ( PID_TYPE(v5) == OBJECT_Actor)
       {
         if ( v4 <= (unsigned int)(a3 << 16) )
         {
-          v6 = v5 >> 3;
+          v6 = PID_ID(v5);
           v7 = v6;
           v8 = pActors[v6].uAIState;
           if ( v8 != 5 )
@@ -10817,8 +10817,8 @@
   while ( 1 )
   {
     v19 = dword_720020_zvalues[v18] & 0xFFFF;
-    v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3;
-    if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Item)
+    v20 = PID_ID(dword_720020_zvalues[v18]);
+    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Item)
     {
       if ( v20 >= 0x3E8 )
         return 0;
@@ -10831,16 +10831,16 @@
       }
       goto LABEL_41;
     }
-    if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Actor)
+    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
     {
       if ( v20 >= 0xBB8 )
         return 0;
       v24 = (const char *)&pActors[v20];
       goto LABEL_51;
     }
-    if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Decoration)
+    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
       break;
-    if ( (dword_720020_zvalues[v18] & 7) == OBJECT_BModel)
+    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
     {
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
       {
@@ -10853,7 +10853,7 @@
       {
         if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels )
           goto LABEL_41;
-        v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[((dword_720020_zvalues[v18] & 0xFFFFu) >> 3) & 0x3F].sCogTriggeredID;
+        v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
       }
       if ( v22 )
       {
@@ -11160,15 +11160,15 @@
   v2 = &pSpriteObjects[uLayingItemID];
   v3 = &pObjectList->pObjects[v2->uObjectDescID];
   v145 = a2;
-  v151 = a2 & 7;
-  if ( (a2 & 7) == OBJECT_Actor)
-  {
-    if ( (v2->spell_caster_pid & 7) == OBJECT_Actor && !pActors[v2->spell_caster_pid >> 3].GetActorsRelation(&pActors[a2 >> 3]) )
+  v151 = PID_TYPE(a2);
+  if ( PID_TYPE(a2) == OBJECT_Actor)
+  {
+    if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) )
       return 1;
   }
   else
   {
-    if ( (a2 & 7) == OBJECT_Player && (v2->spell_caster_pid & 7) == OBJECT_Player)
+    if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player)
       return 1;
   }
   if ( pParty->bTurnBasedModeOn == 1 )
@@ -11180,8 +11180,8 @@
       v2->uAttributes = v5 & 0xFFFB;
     }
   }
-  if ( v151 == OBJECT_BModel && (v2->spell_caster_pid & 7) != OBJECT_Player)
-    BYTE2(pActors[v2->spell_caster_pid >> 3].uAttributes) |= 4u;
+  if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player)
+    BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4u;
   v6 = v2->uType;
   v7 = v2->uType;
   if ( v7 > 3060 )
@@ -11295,7 +11295,7 @@
         }
         v106 = v145;
         v150 = 0;
-        v139 = v106 >> 3;
+        v139 = PID_ID(v106);
         v137 = v2->spell_level;
         v152 = v2->spell_skill;
         v136 = v2->spell_id;
@@ -11368,7 +11368,7 @@
       if ( v7 == 8010 )
       {
         if ( v151 == 3
-          && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
+          && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
           sub_43A97E(v153, v145);
         v93 = pObjectList->uNumObjects;
         ++v2->uType;
--- a/mm7_3.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_3.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -898,9 +898,9 @@
   //int v34; // ebx@64
   int v35; // edi@64
   int v36; // eax@64
-  unsigned __int16 v37; // cx@66
+  //unsigned __int16 v37; // cx@66
   signed int v38; // edx@71
-  signed int v39; // edi@71
+  unsigned int v39; // edi@71
   BSPModel *v40; // eax@75
   ODMFace *v41; // edi@75
   int v42; // ebx@76
@@ -913,8 +913,8 @@
   int v49; // edi@85
   int v50; // eax@85
   unsigned __int64 v51; // qax@85
-  unsigned __int8 v52; // zf@87
-  unsigned __int8 v53; // sf@87
+  //unsigned __int8 v52; // zf@87
+  //unsigned __int8 v53; // sf@87
  // unsigned __int8 v54; // of@104
   int v55; // eax@107
   unsigned int v56; // edi@107
@@ -1139,8 +1139,7 @@
       {
         if ( v35 < v36 + 60 )
         {
-          v37 = v0->uAIState;
-          if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 )
+          if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled )
           {
             if ( v64 )
               v61 = v36 + 30;
@@ -1167,7 +1166,7 @@
       v38 = stru_721530.uFaceID;
       v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
       stru_721530.field_70 += stru_721530.field_7C;
-      v39 = v38 >> 3;
+	  v39 = PID_ID(v38);
       switch ( PID_TYPE(v38) )
       {
         case OBJECT_Actor:
@@ -1207,8 +1206,8 @@
             Actor::FaceObject(v75, v38, 0, (AIDirection *)0);
             break;
           }
-          v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
-          v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0;
+          //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
+          //v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0;
           v0->vVelocity.y = 0;
           v0->vVelocity.x = 0;
           //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) )
@@ -1372,7 +1371,7 @@
       v4 = &pObjectList->pObjects[item->uObjectDescID];
       if (item->AttachedToActor())
       {
-          v5 = item->spell_target_pid >> 3;
+          v5 = PID_ID(item->spell_target_pid);
           *(int *)(v2 - 26) = pActors[v5].vPosition.x;
           *(int *)(v2 - 22) = pActors[v5].vPosition.y;
           *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
@@ -1915,7 +1914,7 @@
     uSectorID = stru_721530.uSectorID;
     stru_721530.field_70 += stru_721530.field_7C;
     auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z;
-    if ( (stru_721530.uFaceID & 7) == OBJECT_Actor)
+    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
     {
       if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
         && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) )
@@ -1923,7 +1922,7 @@
       viewparams->bRedrawGameUI = 1;
       goto LABEL_152;
     }
-    if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration)
+    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v53 = integer_sqrt(v2 * v2 + v1 * v1);
       v80 = v53;
@@ -1935,7 +1934,7 @@
     }
     else
     {
-      if ( (stru_721530.uFaceID & 7) == OBJECT_BModel)
+      if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
         v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
         v45 = v44->uPolygonType;
@@ -2839,7 +2838,7 @@
     pY = _angle_y;
     v45 = stru_721530.uFaceID;
     pZ = v40;
-    if ( (stru_721530.uFaceID & 7) == OBJECT_Actor)
+    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
     {
       if (pParty->Invisible())
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
@@ -2847,7 +2846,7 @@
       viewparams->bRedrawGameUI = 1;
       goto LABEL_234;
     }
-    if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration)
+    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v56 = integer_sqrt(v2 * v2 + v128 * v128);
       v118 = v56;
@@ -2868,7 +2867,7 @@
     }
     else
     {
-      if ( (stru_721530.uFaceID & 7) == OBJECT_BModel)
+      if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
         pParty->bFlying = 0;
         v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
@@ -12789,7 +12788,7 @@
           ++num_dead_actors;
         else
         {
-          int sumonner_type = pActors[i].uSummonerID & 7;;
+          int sumonner_type = PID_TYPE(pActors[i].uSummonerID);
           if (sumonner_type == OBJECT_Player)
             ++num_dead_actors;
         }
@@ -15144,7 +15143,7 @@
 	AIDirection a3; // [sp+1Ch] [bp-94h]@129
 	AIDirection v74; // [sp+38h] [bp-78h]@246
 	AIDirection v75; // [sp+54h] [bp-5Ch]@129
-	int actor_pid_type; // [sp+70h] [bp-40h]@83
+	int target_pid_type; // [sp+70h] [bp-40h]@83
 	signed int a1; // [sp+74h] [bp-3Ch]@129
 	int v78; // [sp+78h] [bp-38h]@79
 	AIDirection pDir; // [sp+7Ch] [bp-34h]@129
@@ -15153,7 +15152,7 @@
 	//int v82; // [sp+A0h] [bp-10h]@45
 	//unsigned int uActorID; // [sp+A4h] [bp-Ch]@32
 	unsigned int v84; // [sp+A8h] [bp-8h]@11
-	signed int actor_pid; // [sp+ACh] [bp-4h]@83
+	signed int target_pid; // [sp+ACh] [bp-4h]@83
 	AIState uAIState;
 	
 	if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
@@ -15343,9 +15342,9 @@
 			Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true);
 			if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
 				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-			actor_pid = ai_near_actors_targets_pid[actor_id];
-			actor_pid_type = PID_TYPE(actor_pid);
-			if ( actor_pid_type == OBJECT_Actor)
+			target_pid = ai_near_actors_targets_pid[actor_id];
+			target_pid_type = PID_TYPE(target_pid);
+			if ( target_pid_type == OBJECT_Actor)
 				v80 = 0.5;
 			else
 				v80 = 1.0;
@@ -15390,7 +15389,7 @@
 			if ( !(v21->uAttributes & 0x8000) )
 				v21->uAttributes |= 0x8000;
 			a1 = 8 * actor_id | OBJECT_Actor;
-			v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, actor_pid, &a3, 0);
+			v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, target_pid, &a3, 0);
 			memcpy(&v75, v30, sizeof(v75));
 			memcpy(&pDir, &v75, sizeof(pDir));
 			uAIState = v21->uAIState; 
@@ -15401,13 +15400,14 @@
 				|| ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) )
 			{
 				v32 = actor_id;
-			}*/
+			}
+			else
+			*/
 			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
 				|| (signed int)v21->pMonsterInfo.uRecoveryTime > 0
 				|| v80 * 307.2 < (double)(signed int)v75.uDistance
 				|| uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting
 				&&  !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
-			//else
 			{
 				if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
 				{
@@ -15436,31 +15436,28 @@
 					v34 = v21->pMonsterInfo.uMissleAttack2Type;
 					Actor::_404874(actor_id, &pDir, v34, 1);
 				}
-				else
+				else if ( v21->uAIState == AttackingRanged3 )
 				{
-					if ( v21->uAIState == AttackingRanged3 )
-					{
-						v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
-						v33 = v21->pMonsterInfo.uSpell1ID;
-						Actor::_404AC7(actor_id, &pDir, v33, 2, v65);
-					}
-					else if ( v21->uAIState == AttackingRanged4 )
-					{
-						v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
-						v33 = v21->pMonsterInfo.uSpell2ID;
-						Actor::_404AC7(actor_id, &pDir, v33, 3, v65);
-					}
+					v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
+					v33 = v21->pMonsterInfo.uSpell1ID;
+					Actor::_404AC7(actor_id, &pDir, v33, 2, v65);
+				}
+				else if ( v21->uAIState == AttackingRanged4 )
+				{
+					v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
+					v33 = v21->pMonsterInfo.uSpell2ID;
+					Actor::_404AC7(actor_id, &pDir, v33, 3, v65);
 				}
 			}
 
 			v36 = v75.uDistance;
 			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
 			{
-				if ( actor_pid_type == OBJECT_Actor )
+				if ( target_pid_type == OBJECT_Actor )
 				{
 					v36 = v75.uDistance;
 					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
-						+ (pActors[actor_pid >> 3].pMonsterInfo.uID - 1) / 3);
+						+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
 				}
 				else
 				{
@@ -15489,29 +15486,29 @@
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
-					Actor::_4032B2(actor_id, actor_pid, 1024, 0);
+					Actor::_4032B2(actor_id, target_pid, 1024, 0);
 				}
 				else
 				{
 					//peasents after attacked
 					//guard after attacked
-					Actor::_402968(actor_id, actor_pid, 0, &pDir);
+					Actor::_402968(actor_id, target_pid, 0, &pDir);
 				}
 				continue;
 			}
 
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && actor_pid )
+			if ( /*v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long &&*/ target_pid ) // temporary
 			{
 
 				if ( v21->pMonsterInfo.uAIType == 1 )
 				{
 					if ( v21->pMonsterInfo.uMovementType == 5 )
 					{
-						Actor::AI_Stand(actor_id, actor_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
 					}
 					else
 					{
-						Actor::_402968(actor_id, actor_pid, 0, &pDir);
+						Actor::_402968(actor_id, target_pid, 0, &pDir);
 						continue;
 					}
 						
@@ -15528,15 +15525,15 @@
 						v42 = (double)(signed int)v84;
 						if ( v43 > v42 && (signed int)v36 < 10240 )
 						{
-							Actor::_402968(actor_id, actor_pid, 0, &pDir);
+							Actor::_402968(actor_id, target_pid, 0, &pDir);
 							continue;
 						}
 					}
 				}
 				
 				v81 = v36 - v21->uActorRadius;
-				if ( actor_pid_type == OBJECT_Actor )
-					v81 -= pActors[actor_pid >> 3].uActorRadius;
+				if ( target_pid_type == OBJECT_Actor )
+					v81 -= pActors[PID_ID(target_pid)].uActorRadius;
 				if ( v81 < 0 )
 					v81 = 0;
 				rand();
@@ -15550,13 +15547,13 @@
 						{
 							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
 							{
-								Actor::_403476(actor_id, actor_pid, &pDir);
+								Actor::_403476(actor_id, target_pid, &pDir);
 							}
 							else if ( v21->pMonsterInfo.uMovementType == 5 )
 							{
 								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
@@ -15564,10 +15561,10 @@
 								if ( !(v54 | v55) )
 								{
 									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									continue;
 								}
-								Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir);
+								Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 							}
 						}
 						else
@@ -15581,19 +15578,19 @@
 									{
 										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
 										//monsters
-										Actor::_402686(actor_id, actor_pid, 0, &pDir);
+										Actor::_402686(actor_id, target_pid, 0, &pDir);
 									}
 								}
 								else if ( v21->pMonsterInfo.uMovementType == 5 )
 								{
 									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
 								else
 								{
@@ -15601,19 +15598,19 @@
 									//monsters
 									//guard after player runs away
 									// follow player
-									Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70);
+									Actor::_40281C(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
 							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
 							{
 								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
 								//monsters
-								Actor::_403C6C(actor_id, actor_pid, &pDir);
+								Actor::_403C6C(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
@@ -15629,20 +15626,20 @@
 							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
 							{
 								if ( v45 == 2 )
-									Actor::_403854(actor_id, actor_pid, &pDir);
+									Actor::_403854(actor_id, target_pid, &pDir);
 								else
-									Actor::_403A60(actor_id, actor_pid, &pDir);
+									Actor::_403A60(actor_id, target_pid, &pDir);
 							}
 							else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 )
 							{
 								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
 								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir);
+								Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 							}
 						}
 						else
@@ -15656,34 +15653,34 @@
 									{
 										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
-										Actor::_402686(actor_id, actor_pid, 256, &pDir);
+										Actor::_402686(actor_id, target_pid, 256, &pDir);
 									}
 								}
 								else if ( v21->pMonsterInfo.uMovementType == 5 )
 								{
 									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
 								else
 								{
 									v70 = (signed __int64)v48;
-									Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70);
+									Actor::_40281C(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
 							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
 							{
 								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								Actor::_403C6C(actor_id, actor_pid, &pDir);
+								Actor::_403C6C(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
@@ -15691,7 +15688,7 @@
 				}
 			}
 
-			if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !actor_pid || v81 >= 5120 || v45 != 1 )
+			if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
 			{
 				if ( !v21->pMonsterInfo.uMovementType )
 				{
@@ -15730,34 +15727,34 @@
 						{
 							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 							v64 = (signed __int64)v47;
-							Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+							Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 						}
 						else
 						{
-							Actor::_402686(actor_id, actor_pid, 256, &pDir);
+							Actor::_402686(actor_id, target_pid, 256, &pDir);
 						}
 					}
 					else if ( v21->pMonsterInfo.uMovementType == 5 )
 					{
 						v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 						v64 = (signed __int64)v47;
-						Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+						Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 					}
 					else
 					{
 						v70 = (signed __int64)v56;
-						Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70);
+						Actor::_40281C(actor_id, target_pid, 0, &pDir, v70);
 					}
 				}
 				else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
 				{
 					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::_403C6C(actor_id, actor_pid, &pDir);
+					Actor::_403C6C(actor_id, target_pid, &pDir);
 				}
 			}
 			else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
@@ -15766,16 +15763,16 @@
 				if ( !(v54 | v55) || v21->pMonsterInfo.uMovementType == 5 )
 				{
 					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, actor_pid, v64, &pDir);
+					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir);
+					Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 				}
 			}
 			else
 			{
-				Actor::_40368B(actor_id, actor_pid, &pDir);
+				Actor::_40368B(actor_id, target_pid, &pDir);
 			}
 		}
 	}
@@ -15853,10 +15850,10 @@
     v2 = this->pQueue;
     do
     {
-      if ( (v2->uPackedID & 7) == OBJECT_Actor )
-      {
-        v3 = &pActors[v2->uPackedID >> 3];
-        v4 = &pActors[v2->uPackedID >> 3];
+      if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor )
+      {
+        v3 = &pActors[PID_ID(v2->uPackedID)];
+        v4 = &pActors[PID_ID(v2->uPackedID)];
         LOBYTE(v4->uAttributes) |= 0x80u;
         if ( !v4->CanAct() )
         {
@@ -15865,7 +15862,7 @@
           LOBYTE(v3->uAttributes) &= 0x7Fu;
         }
       }
-      if ( (v2->uPackedID & 7) == OBJECT_Player)
+      if ( PID_TYPE(v2->uPackedID) == OBJECT_Player)
       {
         v5 = &pParty->pPlayers[v2->uPackedID >> 3];
         if ( v5->pConditions[14]
@@ -15901,8 +15898,8 @@
           v10 = v7->field_4;
           if ( v9 < v10
             || v9 == v10
-            && ((v11 = v8->uPackedID & 7, v11 == OBJECT_Player) && (v7->uPackedID & 7) == OBJECT_Actor
-             || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) )
+            && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor
+             || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) )
           {
             v12 = v7->uPackedID;
             v13 = v7->field_4;
@@ -15930,7 +15927,7 @@
   }
   v1->uActorQueueSize = v19;
   result = v1->pQueue[0].uPackedID;
-  if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player)
+  if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player)
   {
     result = (result >> 3) + 1;
     uActiveCharacter = result;
@@ -15947,7 +15944,7 @@
     v17 = v1->pQueue;
     do
     {
-      if ( (v17->uPackedID & 7) == OBJECT_Player)
+      if ( PID_TYPE(v17->uPackedID) == OBJECT_Player)
         pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875);
       ++v22;
       ++v17;
@@ -16085,7 +16082,7 @@
     v12 = (char *)&v1->pQueue[0].field_4;
     while ( 1 )
     {
-      v13 = *((int *)v12 - 1) & 7;
+      v13 = PID_TYPE(*((int *)v12 - 1));
       if ( v13 != OBJECT_Player )
         break;
       v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery;
--- a/mm7_4.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_4.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1119,7 +1119,7 @@
             do
             {
               v4 = *v3;
-              if ( (v4 & 7) == OBJECT_Decoration)
+              if ( PID_TYPE(v4) == OBJECT_Decoration)
               {
                 v5 = &pLevelDecorations[(signed __int16)v4 >> 3];
                 if ( !(v5->field_2 & 0x20) )
@@ -1515,7 +1515,7 @@
   v2 = this;
   v3 = operator new(8 * a2 + 16);
   v2->pBlockBase = v3;
-  v4 = (char *)v3 + (-(signed int)v3 & 7);
+  v4 = (char *)v3 + PID_TYPE(-(signed int)v3);
   result = v2;
   v2->pAlignedBlock = v4;
 }
@@ -8582,8 +8582,8 @@
     v7 = this->pQueue;
     do
     {
-      if ( (v7->uPackedID & 7) == OBJECT_Actor )
-        LOBYTE(pActors[v7->uPackedID >> 3].uAttributes) &= 0x7Fu;
+      if ( PID_TYPE(v7->uPackedID) == OBJECT_Actor )
+        LOBYTE(pActors[PID_ID(v7->uPackedID)].uAttributes) &= 0x7Fu;
       ++v4;
       ++v7;
     }
@@ -8612,8 +8612,8 @@
     v11 = v2->pQueue;
     do
     {
-      objType = (ObjectType)(v11->uPackedID & 7);
-      objID = v11->uPackedID >> 3;
+      objType = (ObjectType)PID_TYPE(v11->uPackedID);
+      objID = PID_ID(v11->uPackedID);
       if ( objType == OBJECT_Player )
       {
         pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)v11->field_4 * 2.133333333333333);
--- a/mm7_5.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_5.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -1741,9 +1741,9 @@
             v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]];
           }
           v44 = (unsigned __int16)v42;
-          v45 = v44 & 7;
+          v45 = PID_TYPE(v44);
           uNumSeconds = v44;
-          v46 = v44 >> 3;
+          v46 = PID_ID(v44);
           if ( v45 == 3 )
           {
             v47 = pActors[v46].uAIState == Dead;
@@ -2397,7 +2397,7 @@
           v83 = v81;
           v44 = (unsigned __int16)v81;
           v84 = v83 >> 16;
-          if ( (v44 & 7) != 3 || v84 >= 5120 )
+          if ( PID_TYPE(v44) != 3 || v84 >= 5120 )
             //goto LABEL_90;
             {
             v1 = "";
@@ -4532,24 +4532,24 @@
     v1 = (char *)stru_50FE08.pZs;
     do
     {
-      v2 = *((short *)v1 - 300) & 7;
-      v3 = (signed int)*((short *)v1 - 300) >> 3;
-      v39 = (signed int)*((short *)v1 - 300) >> 3;
+      v2 = PID_TYPE(*((short *)v1 - 300));
+      v3 = PID_ID((signed int)*((short *)v1 - 300));
+      v39 = PID_ID((signed int)*((short *)v1 - 300));
       if ( v2 == 2 )
       {
         v4 = &pSpriteObjects[v3];
         v36 = v4;
         v5 = v4->spell_caster_pid;
-        v2 = v5 & 7;
-        v3 = v5 >> 3;
+        v2 = PID_TYPE(v5);
+        v3 = PID_ID(v5);
       }
       v41 = v2;
       v37 = v3;
       if ( stru_50FE08.field_3EC[v0] & 1 )
       {
         v6 = ai_near_actors_targets_pid[v3];
-        v7 = v6 >> 3;
-        v8 = (v6 & 7) - 3;
+        v7 = PID_ID(v6);
+        v8 = PID_TYPE(v6) - 3;
         uActorID = v7;
         if ( v8 )
         {
@@ -4775,9 +4775,9 @@
   v61 = 0;
   v59 = 0;
   v62 = 0;
-  if ( (a1 & 7) == OBJECT_Item)
-  {
-    v4 = &pSpriteObjects[a1 >> 3];
+  if ( PID_TYPE(a1) == OBJECT_Item)
+  {
+    v4 = &pSpriteObjects[PID_ID(a1)];
     //uDamageAmount = (int)v4;
     v61 = v4->field_60_distance_related_prolly_lod;
     a1 = v4->spell_caster_pid;
@@ -4785,11 +4785,11 @@
   }
   //v5 = a1 & 7;
   //uPlayerID = a1 >> 3;
-  if ((a1 & 7) != OBJECT_Player)
+  if (PID_TYPE(a1) != OBJECT_Player)
     return;
 
-  assert(abs(a1 >> 3) < 4);
-  auto player = &pParty->pPlayers[a1 >> 3];
+  assert(PID_ID(abs(a1)) < 4);
+  auto player = &pParty->pPlayers[PID_ID(a1)];
   pMonster = &pActors[uActorID_Monster_];
   //uPlayerID = pMonster->IsAlive();
   if (pMonster->IsNotAlive())
@@ -5250,8 +5250,8 @@
   signed int a4a; // [sp+60h] [bp+Ch]@162
   Player *a4b; // [sp+60h] [bp+Ch]@168
 
-  v4 = (signed int)uObjID >> 3;
-  v5 = (uObjID & 7) - 2;
+  v4 = PID_ID(uObjID);
+  v5 = PID_TYPE(uObjID) - 2;
   v74 = a2;
   uActorID = v4;
   if ( v5 )
@@ -5448,10 +5448,10 @@
     return;
   }
   v37 = &pSpriteObjects[uActorID];
-  v38 = v37->spell_caster_pid & 7;
-  v39 = v37->spell_caster_pid >> 3;
-  v40 = v37->spell_caster_pid & 7;
-  uActorID = v37->spell_caster_pid >> 3;
+  v38 = PID_TYPE(v37->spell_caster_pid);
+  v39 = PID_ID(v37->spell_caster_pid);
+  v40 = PID_TYPE(v37->spell_caster_pid);
+  uActorID = PID_ID(v37->spell_caster_pid);
   v41 = v40 - 2;
   if ( !v41 )
     goto LABEL_80;
@@ -5847,9 +5847,9 @@
   a2 = uObjID;
   if ( !pActors[uActorID].IsNotAlive() )
   {
-    if ( (a2 & 7) == OBJECT_Item)
-    {
-      v4 = &pSpriteObjects[(signed int)a2 >> 3];
+    if ( PID_TYPE(a2) == OBJECT_Item)
+    {
+      v4 = &pSpriteObjects[PID_ID(a2)];
       v5 = v4->spell_id;
       if ( v5 )
       {
@@ -5906,17 +5906,17 @@
   v4 = 0;
   uActorID = a2;
   v17 = a1;
-  if ( (a1 & 7) == OBJECT_Item)
-  {
-    v5 = &pSpriteObjects[a1 >> 3];
+  if ( PID_TYPE(a1) == OBJECT_Item)
+  {
+    v5 = &pSpriteObjects[PID_ID(a1)];
     v4 = v5->field_60_distance_related_prolly_lod;
     v17 = v5->spell_caster_pid;
   }
-  LOWORD(v6) = v17 & 7;
+  LOWORD(v6) = PID_TYPE(v17);
   if ( v6 == OBJECT_Actor)
   {
     v7 = &pActors[a2];
-    v8 = &pActors[v17 >> 3];
+    v8 = &pActors[PID_ID(v17)];
     v6 = pActors[a2].IsNotAlive();
     if ( !v6 )
     {
@@ -6759,7 +6759,7 @@
     while ( 1 )
     {
       v5 = v16->uPackedID;
-      if ( (v16->uPackedID & 7) == OBJECT_Player)
+      if ( PID_TYPE(v16->uPackedID) == OBJECT_Player)
         break;
 LABEL_8:
       ++v17;
@@ -6767,8 +6767,8 @@
       if ( v17 >= v1->uActorQueueSize )
         goto LABEL_11;
     }
-    v15 = v5 >> 3;
-    if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 )
+    v15 = PID_ID(v5);
+    if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 )
     {
       v2 = 0;
       goto LABEL_8;
@@ -6802,7 +6802,7 @@
         v8 = v1->pQueue;
         do
         {
-          if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_near_actors_ids[v20] == v8->uPackedID >> 3 )
+          if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) )
             break;
           ++v18;
           ++v8;
@@ -6846,7 +6846,7 @@
     v13 = (char *)&v1->pQueue[0].field_4;
     do
     {
-      v11 = *((int *)v13 - 1) & 7;
+      v11 = PID_TYPE(*((int *)v13 - 1));
       if ( (char)v11 == 4 )
         break;
       if ( *(int *)v13 > 0 )
@@ -6936,7 +6936,7 @@
           if ( v6 != 8 )
             goto LABEL_19;
           v3 = 0;
-          Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0);
+          Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0);
         }
       }
     }
@@ -7039,7 +7039,7 @@
     }
     else
     {
-      v8 = &pActors[v1->pQueue[0].uPackedID >> 3];
+      v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)];
       if ( v4 > 0 )
       {
         do
@@ -7091,10 +7091,10 @@
 
   v2 = this;
   v3 = *(&this->field_0 + 4 * (a2 + 2));
-  if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == OBJECT_Player)
-  {
-    v4 = v3 >> 3;
-    v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3];
+  if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player)
+  {
+    v4 = PID_ID(v3);
+    v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)];
     v6 = *(int *)v5;
     if ( *(int *)v5 )
       *(int *)v5 = 0;
@@ -7105,7 +7105,7 @@
   }
   else
   {
-    v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime;
+    v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime;
   }
   v2->pQueue[a2].field_4 = v6;
   v2->_404544();
@@ -7143,7 +7143,7 @@
 //----- (0040652A) --------------------------------------------------------
 void stru262_TurnBased::_40652A()
 {
-  char *v1; // edx@2
+  int *v1; // edx@2
   Actor *v2; // eax@5
   unsigned __int16 v3; // si@5
   unsigned int v4; // esi@8
@@ -7152,14 +7152,14 @@
   v5 = 0;
   if ( this->uActorQueueSize > 0 )
   {
-    v1 = (char *)&this->pQueue[0].field_4;
+    v1 = &this->pQueue[0].field_4;
     do
     {
       if ( !*(int *)v1 )
       {
-        if ( (*(v1 - 4) & 7) == OBJECT_Player)
+        if ( PID_TYPE(*(v1 - 4)) == OBJECT_Player)
           return;
-        v2 = &pActors[*((int *)v1 - 1) >> 3];
+        v2 = &pActors[PID_ID(*(v1 - 1))];
         v3 = v2->uAIState;
         if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting)
         {
@@ -7188,7 +7188,7 @@
   v1 = this;
   LOWORD(v2) = _404544();
   if ( v1->pQueue[0].field_4 <= 0
-    || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2),
+    || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (PID_ID(v2)) + 1, uActiveCharacter = v2),
         viewparams->bRedrawGameUI = 1,
         v1->pQueue[0].field_4 <= 0) )
   {
@@ -7199,7 +7199,7 @@
       do
       {
         v2 = *(int *)v4;
-        if ( (*(char *)v4 & 7) == OBJECT_Player || *(int *)(v4 + 4) > 0 )
+        if ( PID_TYPE(*(char *)v4) == OBJECT_Player || *(int *)(v4 + 4) > 0 )
           break;
         if ( *(int *)(v4 + 8) <= 0 )
         {
@@ -7262,7 +7262,7 @@
     a2a = ai_near_actors_targets_pid[PID_ID(v3)];
     memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3));
     memcpy(&a4, &a3, sizeof(a4));
-    v5 = &pActors[PID_ID(v3 >> 3)];
+    v5 = &pActors[PID_ID(v3)];
     LOWORD(v3) = v5->uAIState;
     if ( (short)v3 != Dead )
     {
@@ -7369,8 +7369,8 @@
 __int16 stru262_TurnBased::_40680F(int a2)
 {
   TurnBased_QueueElem *v2; // eax@1
-  TurnBased_QueueElem *v3; // eax@1
-  TurnBased_QueueElem *v4; // edi@2
+  unsigned int v3; // eax@1
+  unsigned int v4; // edi@2
   Actor *v5; // ebx@2
   unsigned int *v6; // esi@7
   AIDirection *v7; // esi@10
@@ -7392,13 +7392,13 @@
   v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
   v21 = v2;
   v2->uActionLength = 0;
-  v3 = (TurnBased_QueueElem *)v2->uPackedID;
+  v3 = v2->uPackedID;
   if ( (unsigned __int8)v3 & 3 )
   {
-    v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3);
+    v3 = PID_ID(v3);
     v4 = v3;
-    a2a = (int)v3;
-    v5 = &pActors[(int)v3];
+    a2a = v3;
+    v5 = &pActors[v3];
     LOWORD(v3) = v5->uAIState;
     if ( (short)v3 != 5 )
     {
@@ -7421,7 +7421,7 @@
           v20 = 0;
         }
         if (PID_TYPE(v22) == OBJECT_Actor)
-          v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
+          v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
         else
           v10 = 4;
         if ( v10 == 1 )
@@ -7496,24 +7496,25 @@
           {
             Actor::_403476(v13, v22, &v18);
 LABEL_43:
-            v3 = v21;
+            //v3 = v21;
             v21->field_C = 1;
 LABEL_48:
-            v3->uActionLength = v5->uCurrentActionLength;
-            return (signed __int16)v3;
+            v21->uActionLength = v5->uCurrentActionLength;
+            //return (signed __int16)v3;
+			return (signed __int16)&v21;
           }
         }
 LABEL_44:
         if ( (double)(signed int)v20 < 307.2 )
         {
           Actor::_403C6C(v13, v22, &v18);
-          v3 = v21;
+          //v3 = v21;
           v21->field_C = 3;
           goto LABEL_48;
         }
 LABEL_47:
         Actor::AI_Stand(v13, v22, 0x40u, &v18);
-        v3 = v21;
+        //v3 = v21;
         v21->field_C = 0;
         goto LABEL_48;
       }
@@ -7555,7 +7556,7 @@
         v8 = ai_near_actors_targets_pid[PID_ID(v5)];
         memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
         if ( !v1->_406D10(a2) )
-          Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7);
+          Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 0x20u, &v7);
       }
       ++a2;
       ++v10;
@@ -7646,7 +7647,7 @@
       a1 = v14->uPackedID;
       if (PID_TYPE(a1) != OBJECT_Player)
       {
-        v5 = v4 >> 3;
+        v5 = PID_ID(v4);
         v12 = v5;
         v6 = &pActors[v5];
         if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
@@ -8042,8 +8043,8 @@
   int v65; // [sp+60h] [bp-8h]@4
   int v66; // [sp+64h] [bp-4h]@7
 
-  v2 = (signed int)uObjID >> 3;
-  v3 = (uObjID & 7) - 2;
+  v2 = PID_ID(uObjID);
+  v3 = PID_TYPE(uObjID) - 2;
   v4 = uObj2ID;
   if ( v3 )
   {
@@ -8078,8 +8079,8 @@
     v65 = v11;
   }
   v66 = v7;
-  v12 = v4 >> 3;
-  v13 = (v4 & 7) - 2;
+  v12 = PID_ID(v4);
+  v13 = PID_TYPE(v4) - 2;
   if ( v13 )
   {
     v14 = v13 - 1;
--- a/mm7_6.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_6.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -3557,7 +3557,7 @@
         a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
         a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
         a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-        a1.spell_target_pid = PID(OBJECT_Actor, a2 >> 3);
+        a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
         auto obj_id = a1.Create(0, 0, 0, 0);
         DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
         LODWORD(v727) = 1;
@@ -3569,12 +3569,12 @@
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
 
-        if ( !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u) )
+        if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) )
         {
           LODWORD(v727) = 1;
           goto play_sound_and_continue;
         }
-        pActors[a2 >> 3].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
+        pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
         v704.x = 0;
         v704.y = 0;
         v704.z = 0;
@@ -3730,7 +3730,7 @@
         if (PID_TYPE(a2) != OBJECT_Actor ||
             (v730 = PID_ID(a2),
               v721 = (int)&pActors[PID_ID(a2)],
-              !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) )
+              !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) )
         {
         LODWORD(v727) = 1;
         goto play_sound_and_continue;
@@ -3784,7 +3784,7 @@
         v58 = (signed __int64)((double)(23040 * v2) * 0.033333335);
         v59 = v721;
         //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
-		pActors[a2 >> 3].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58,
+		pActors[PID_ID(a2)].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58,
           v731,
           amount,
           0,
@@ -3826,7 +3826,7 @@
         a1.spell_level = v2;
         a1.spell_skill = v731;
         v60 = pObjectList->ObjectIDByItemID(a1.uType);
-        v61 = a2 >> 3;
+        v61 = PID_ID(a2);
         goto LABEL_1086;
       }
 
@@ -4365,7 +4365,7 @@
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
-        LODWORD(v725) = a2 & 7;
+        LODWORD(v725) = PID_TYPE(a2);
         if (PID_TYPE(a2) == OBJECT_Actor)
         {
           uRequiredMana = pActors[PID_ID(a2)].vPosition.x;
@@ -4731,11 +4731,11 @@
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
-        v208 = a2 & 7;
-        LODWORD(v725) = a2 & 7;
+        v208 = PID_TYPE(a2);
+        LODWORD(v725) = PID_TYPE(a2);
         if ( v208 == 3 )
         {
-          v209 = a2 >> 3;
+          v209 = PID_ID(a2);
           LODWORD(v718) = pActors[v209].vPosition.x;
           v210 = pActors[v209].vPosition.y;
           v211 = pActors[v209].vPosition.z;
@@ -5672,7 +5672,7 @@
         }
         if (PID_TYPE(v342) == OBJECT_Actor)
         {
-          v343 = v342 >> 3;
+          v343 = PID_ID(v342);
           HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32);
           LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280;
           pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0);
@@ -7028,7 +7028,7 @@
           }
           goto play_sound_and_continue;
         }
-        v577 = (Player *)(v576 >> 3);
+        v577 = (Player *)(PID_ID(v576));
         //v726 = v577;
         if ( v577 == (Player *)-1 )
         {
@@ -7791,13 +7791,13 @@
     //v7 = pMouse->uPointingObjectID;
 
   int target_pid = pMouse->uPointingObjectID;
-  int target_type = target_pid & 7,
-      target_id = target_pid >> 3;
+  int target_type = PID_TYPE(target_pid),
+      target_id = PID_ID(target_pid);
   if (target_type != OBJECT_Actor || !pActors[target_id].CanAct())
   {
     target_pid = stru_50C198.FindClosestActor(5120, 0, 0);
-    target_type = target_pid & 7;
-    target_id = target_pid >> 3;
+    target_type = PID_TYPE(target_pid);
+    target_id = PID_ID(target_pid);
   }
 
   auto actor = &pActors[target_id];
--- a/mm7_data.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/mm7_data.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -346,8 +346,8 @@
 int (__stdcall *off_4DAFDC)(char); // weak
 char asc_4DB724[777]; // idb
 int dword_4DBD94; // weak
-int dword_4DF380[777]; // weak
-int dword_4DF390; // weak
+int dword_4DF380[5]={0,1024,2560,5120,10240}; // weak
+//int dword_4DF390; // weak
 char Str2[777]; // idb
 int dword_4DF3A4; // weak
 char byte_4E185C; // weak
--- a/stru6.cpp	Sun Mar 31 16:42:11 2013 +0600
+++ b/stru6.cpp	Sun Mar 31 16:44:01 2013 +0600
@@ -832,7 +832,7 @@
       AddMobileLight(a2, 0xFF3C1E, 256);
       if (pRenderer->pRenderD3D)
       {
-        result = a2->spell_caster_pid & 7;
+        result = PID_TYPE(a2->spell_caster_pid);
         if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor &&
             PID_TYPE(a2->spell_caster_pid) != OBJECT_Item)
         {