changeset 146:30e731fc0f7a

Слияние
author Ritor1
date Mon, 11 Feb 2013 09:08:00 +0600
parents bd185c7cbd09 (current diff) fe0e317c0de0 (diff)
children c70fea5013aa
files mm7_5.cpp
diffstat 16 files changed, 413 insertions(+), 467 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.h	Mon Feb 11 09:07:47 2013 +0600
+++ b/GUIWindow.h	Mon Feb 11 09:08:00 2013 +0600
@@ -202,7 +202,7 @@
   UIMSG_ToggleWalkSound = 0xB9,
   UIMSG_ChangeVoiceVolume = 0xBA,
   UIMSG_ToggleShowDamage = 0xBB,
-  UIMSG_BC = 0xBC,
+  UIMSG_ScrollNPCPanel = 0xBC,
   UIMSG_BD = 0xBD,
   UIMSG_BE = 0xBE,
   UIMSG_BF = 0xBF,
--- a/Game.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Game.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -58,8 +58,10 @@
     uFlags2 |= 2u;
   pIndoorCamera->sRotationX = pParty->sRotationX;
   pIndoorCamera->sRotationY = pParty->sRotationY;
-  pIndoorCamera->pos.x = pParty->vPosition.x - pParty->field_18 * (stru_5C6E00->SinCos(pIndoorCamera->sRotationY) / 2048.0);//12552
-  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->field_18 * (stru_5C6E00->SinCos(pIndoorCamera->sRotationY) / 2048.0);//800
+  //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552
+  //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800
+  pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0);
+  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0);
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353
   pIndoorCamera->Initialize2();
   pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
--- a/Indoor.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Indoor.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -373,9 +373,9 @@
   _this.uFlags = v0;
   _this.vPosition.x = pParty->vPosition.x
                    - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
-                                       * (signed __int64)pParty->field_18) >> 16);
+                                       * (signed __int64)pParty->y_rotation_granularity) >> 16);
   v2 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
-  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
+  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->y_rotation_granularity) >> 16;
   _this.field_1C_mb_fov = 65;
   _this.vPosition.y = pParty->vPosition.y - v3;
   _this.sRotationY = pParty->sRotationY;
--- a/Outdoor.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Outdoor.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -60,10 +60,10 @@
   pIndoorCamera->sRotationY = pParty->sRotationY;
   pIndoorCamera->pos.x = pParty->vPosition.x
                       - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
-                                          * (signed __int64)pParty->field_18) >> 16);
-  v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
+                                          * (signed __int64)pParty->y_rotation_granularity) >> 16);
+  //v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
   pIndoorCamera->field_4C = v1;
-  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->field_18 * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16);
+  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16);
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if ( v2 || pRenderer->pRenderD3D )
   {
@@ -276,7 +276,7 @@
     pIcons_LOD->ReleaseAll2();
     sub_46080D();
     TryLoadLevelFromLOD();
-    if ( !Load((char *)pFilename, (ODMFace *)File, uRespawnInterval, thisa) )
+    if ( !Load(pFilename, (ODMFace *)File, uRespawnInterval, thisa) )
     {
       MessageBoxA(0, "Error!", "Couldn't Load Map!", 0);
       CreateDebugLocation();
@@ -1192,7 +1192,7 @@
 }
 
 //----- (0047D0A6) --------------------------------------------------------
-bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa)// 
+bool OutdoorLocation::Load(const char *pFilename, ODMFace *File, size_t pNumItems, int thisa)// 
 {
   //OutdoorLocation *pOutdoorLocation; // esi@1
   /*bool result; // eax@9
@@ -1644,10 +1644,15 @@
   if (!pGames_LOD->DoesContainerExist(pFilename))
     Abortf("Unable to find %s in Games.LOD", pFilename);
 
+
+  char pMinimapTextureFilename[1024];
+  strcpy(pMinimapTextureFilename, pFilename);
+  pMinimapTextureFilename[strlen(pMinimapTextureFilename) - 4] = 0;
+  viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pMinimapTextureFilename, TEXTURE_16BIT_PALETTE);
+
   //strcpy(FileName, pContainer);
   strcpy(Str, pFilename);
   strcpy(Str + strlen(Str) - 4, ".odm");
-  viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE);
   //v141 = &v139;
   //v38 = strlen(pFilename);
   //strcpy((char *)&v139 + v38, ".odm");
--- a/Outdoor.h	Mon Feb 11 09:07:47 2013 +0600
+++ b/Outdoor.h	Mon Feb 11 09:08:00 2013 +0600
@@ -143,7 +143,7 @@
   unsigned int DrawActors();
   void CreateDebugLocation();
   void Release();
-  bool Load(char *pFilename, ODMFace *File, size_t a4, int thisa);
+  bool Load(const char *pFilename, ODMFace *File, size_t a4, int thisa);
   int _47ECC1(signed int a2);
   unsigned int DoGetTileTexture(unsigned int uX, unsigned int uZ);
   int _47ED83(signed int a2, signed int a3);
--- a/Party.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Party.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -763,7 +763,7 @@
 
   memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu);
   memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u);
-  pNPCStats->pNewNPCData[3].uFlags |= 0x80u;
+  pNPCStats->pNewNPCData[3].uFlags = 128;//|= 0x80u; Lady Margaret
   _494035_timed_effects__water_walking_damage__etc();
   pEventTimer->Pause();
   return 0;
@@ -828,7 +828,7 @@
   this->field_28 = 0;
   this->uDefaultPartyHeight = 120;
   this->field_14 = 37;
-  this->field_18 = 25;
+  this->y_rotation_granularity = 25;
   this->uWalkSpeed = 384;
   this->field_20_prolly_turn_speed = 90;
   this->field_24 = 5;
--- a/Party.h	Mon Feb 11 09:07:47 2013 +0600
+++ b/Party.h	Mon Feb 11 09:08:00 2013 +0600
@@ -127,6 +127,8 @@
 
     field_6FC = 0;
     field_764 = 0;
+
+    y_rotation_granularity = 1;
   }
 
   void _4909F4();
@@ -164,7 +166,7 @@
   int sEyelevel;
   unsigned int uDefaultEyelevel;
   int field_14;
-  int field_18;
+  int y_rotation_granularity;
   unsigned int uWalkSpeed;
   int field_20_prolly_turn_speed;
   int field_24;
--- a/Player.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Player.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -3389,7 +3389,7 @@
   {
     v6 = 0;
     while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6)
-         || *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v7 + 5] != a1 )
+         || *(int *)&this->pInventoryItems[a2-1].uItemID != a1 )
     {
       ++v6;
       if ( (signed int)v6 >= 16 )
@@ -5450,12 +5450,13 @@
     {
       if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
       {
-        v22 = v21->GetEquippedItemEquipType(1u);
+        v22 = this->GetEquippedItemEquipType(1u);
         if ( v22 >= 0 )
         {
           if ( v22 <= 2 )
           {
-            if ( v6->pEquipment.uOffHand || (v24 = v23, pItemsTable->pItems[v23].uSkillType != 4) )
+			  v23 = this->pInventoryItems[this->pEquipment.uMainHand].uItemID;
+            if ( v6->pEquipment.uOffHand || pItemsTable->pItems[v23].uSkillType != 4 )
             {
               v24 = v23;
               v26 = pItemsTable->pItems[v23].uDamageRoll;
@@ -5496,7 +5497,7 @@
     }
     if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
     {
-      v17 = v16->GetEquippedItemEquipType(1u);
+      v17 = this->GetEquippedItemEquipType(1u);
       if ( v17 >= 0 )
       {
         if ( v17 <= 2 )
@@ -5517,15 +5518,15 @@
     }
     if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
     {
-      v9 = v8->GetEquippedItemEquipType(1u);
+      v9 = this->GetEquippedItemEquipType(1u);
       if ( v9 >= 0 )
       {
         if ( v9 <= 2 )
         {
-          v5 = pItemsTable->pItems[v10].uDamageDice + pItemsTable->pItems[v10].uDamageMod;
+          v5 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uDamageDice + pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uDamageMod;
           if ( !v6->pEquipment.uOffHand )
           {
-            if ( pItemsTable->pItems[v10].uSkillType == 4 )
+            if ( pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4 )
               ++v5;
           }
         }
@@ -5533,8 +5534,8 @@
     }
     if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v12 = v11->GetEquippedItemEquipType(0), v12 < 0) || v12 > 2 )
       return v5 + v62 + v61;
-    v14 = pItemsTable->pItems[v13].uDamageMod;
-    v15 = pItemsTable->pItems[v13].uDamageDice;
+    v14 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageMod;
+    v15 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageDice;
 LABEL_88:
     v5 += v15 + v14;
   }
@@ -6041,8 +6042,8 @@
         {
           if ( v2->HasItemEquipped(v71) )
           {
-            v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[*(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v9->uOffHand + 5]].uSkillType;
-            LOBYTE(v12) = v10->GetActualSkillLevel(v11);
+            v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItems[*(_DWORD *)v9].uItemID].uEquipType;
+            LOBYTE(v12) = this->GetActualSkillLevel(v11);
             a1 = v12;
             SkillToMastery(v12);
             v13 = v11 - 5;
@@ -6099,7 +6100,7 @@
       {
         if ( v2->HasItemEquipped(v20) )
         {
-          v22 = *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v21 + 5];
+          v22 = this->pInventoryItems[this->pEquipment.pIndices[v20]].uItemID;
           if ( pItemsTable->pItems[v22].uEquipType <= 1u )
             break;
         }
@@ -6152,7 +6153,7 @@
           if ( v23 == PLAYER_SKILL_MACE )
           {
             v28 = __OFSUB__(v26, 2);
-            v27 = ((v26 - 2) & 0x80000000u) != 0;
+            v27 = v26 - 2 < 0;
             goto LABEL_53;
           }
 LABEL_55:
@@ -6160,7 +6161,7 @@
           return (int)((char *)v69 + v30);
         }
         v28 = __OFSUB__(v26, 3);
-        v27 = ((v26 - 3) & 0x80000000u) != 0;
+        v27 = v26 - 3 < 0;
       }
 LABEL_53:
       if ( !(v27 ^ v28) )
@@ -6184,7 +6185,7 @@
     {
       if ( v2->HasItemEquipped(v35) )
       {
-        v37 = *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v36 + 5];
+        v37 = *(int *)&v2->pInventoryItems[v35].uItemID;
         if ( pItemsTable->pItems[v37].uEquipType <= 1u )
           break;
       }
--- a/Render.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/Render.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -1566,7 +1566,7 @@
   ptr_801A08 = pVerticesSR_806210;
   ptr_801A04 = pVerticesSR_801A10;
   v126 = v69;
-  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )
+  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//
   {
     for ( i = v69; i >= 1; --i )
     {
@@ -1599,14 +1599,12 @@
         v111 = v75 - uStartZ;
         for (int z = uStartZ; z < uEndZ; ++z)
         {
-          ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;
+          ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
           ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512;
           ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]);
-
           ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512;
           ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512;
           ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1);
-
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
             pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1);
@@ -1618,12 +1616,12 @@
           v127 ++;
           //++v116;
           //pHeight = v79;
-		}
+       }
         //while ( v116 < v107 );
       }
-	  v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
+      v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
       v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
-	  if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
+      if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
         Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102);
       else
         Render::DrawTerrainSW(v111, 0, (int)&v102);
@@ -1737,217 +1735,101 @@
   int v63; // [sp+50h] [bp-8h]@3
   int v64; // [sp+57h] [bp-1h]@2
   int v62;
+  struct IndoorCameraD3D *pIndoorCameraD3D;
 
   v63 = 0;
-
   // basic optimizations
- unsigned int uStartX, uEndX,
-              uStartZ, uEndZ;
- if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024)
- {
-  /*      CAMERA
-       /2     512
-            ^
-       \    |    /
-         \  |  /
-     _____\|/______ +  0
- 1024       |        x  0
-            |
-           - y
-       3/2   1536
-  */
-  uStartX = 0, uEndX = 128;
-  uStartZ = 0, uEndZ = 64 + 16;
- }
- else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536)
- {
-  /*         /2     512
-                 + y
-             \    |     
-               \  |   
-CAMERA     _____\| ______ +  0
-       1024      /|        x  0
-               /  |
-             /   - y
-             3/2   1536
-  */
-  uStartX = 0, uEndX = 64 + 16;
-  uStartZ = 0, uEndZ = 128;
- }
- else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512)
- {
-  /*         /2     512
-                 + y
-                  |    /  
-                  |  /  
-           _____ |/______ +  0     CAMERA
-       1024       |\       x  0
-                  |  \
-                 - y   \
-             3/2   1536
-  */
-  uStartX = 64 - 16, uEndX = 128;
-  uStartZ = 0, uEndZ = 128;
- }
- else
- {
-  uStartX = 0, uEndX = 128;
-  uStartZ = 64 - 16, uEndZ = 128;
- }
-
-// uStartX = 0, uEndX = 128;
-// uStartZ = 0, uEndZ = 128;
-
-
- static RenderVertexSoft pTerrainVertices[128 * 128];
- for (unsigned int z = uStartZ; z < uEndZ; ++z)
-   for (unsigned int x = uStartX; x < uEndX; ++x)
-   {
-    pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
-    pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512;
-    pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x];
-
-    struct IndoorCameraD3D *pIndoorCameraD3D = pGame->pIndoorCameraD3D;
-    pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1);
-    pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0);
-   }
-
-
-
- for (unsigned int z = uStartZ; z < uEndZ - 1; ++z)
-   for (unsigned int x = uStartX; x < uEndX - 1; ++x)
-   {
-    v8 = &array_77EC08[pOutdoorCamera->numStru148s];
-    v8->flags = 0;
-    v8->field_32 = 0;
-
-    //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x];
-    //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID);
-    v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
-    /*if (uTileID == 1 ||   //dirttyl BitmapID 88
-        uTileID == 2 ||   //dirt1 BitmapID 126
-        uTileID == 3 ||   //dirttyl BitmapID 88
-        uTileID == 4 ||   //dirt2 BitmapID 127
-        uTileID == 11 ||  //dirttyl BitmapID 127
-
-        uTileID == 90 ||  //grastyl BitmapID 110
-        uTileID == 92 ||  //grastyl BitmapID 110
-
-        uTileID == 102 || //grdrtNE BitmapID 128
-        uTileID == 104 || //grdrtNW BitmapID 130
-        uTileID == 105 || //grdrtSW BitmapID 131
-        uTileID == 106 || //grdrtE BitmapID 132
-        uTileID == 107 || //grdrtW BitmapID 133
-        uTileID == 108 || //grdrtN BitmapID 134
-        uTileID == 109 || //grdrtS BitmapID 135
-        uTileID == 110 || //grdrtXNE BitmapID 136
-        uTileID == 112 || //grdrtXNW BitmapID 138
-        uTileID == 113 || //grdrtXSW BitmapID 139
-
-        uTileID == 126 || uTileID == 127 || uTileID == 128 || uTileID == 129 ||
-        uTileID == 130 || //wtrtyl BitmapID 89
-        uTileID == 131 || //wtrtyl BitmapID 89
-        uTileID == 132 || //wtrtyl BitmapID 89
-        uTileID == 133 || //wtrtyl BitmapID 89
-        uTileID == 134 || //wtrtyl BitmapID 89
-        uTileID == 135 || //wtrtyl BitmapID 89
-        uTileID == 136 || //wtrtyl BitmapID 89
-        uTileID == 137 || //wtrtyl BitmapID 89
-
-        uTileID == 139 || //wtrdrSE BitmapID 141
-        uTileID == 141 || //wrtdrSW BitmapID 143
-        uTileID == 142 || //wrtdrE BitmapID 144
-        uTileID == 143 || //wrtdrW BitmapID 145
-        uTileID == 145 || //wtrdrS BitmapID 147
-        uTileID == 147 || //wtrdrXSE BitmapID 149
-        uTileID == 149 ) //wtrdrXSW BitmapID 151
-      continue;*/
-
-    /*if (uTileID == 199 || //dirttyl BitmapID 0
-        uTileID == 200 || //dirttyl BitmapID 0
-        uTileID == 201 || //dirttyl BitmapID 0
-        uTileID == 202 || //dirttyl BitmapID 0
-        uTileID == 203 || //dirttyl BitmapID 0
-        uTileID == 204 || //dirttyl BitmapID 0
-        uTileID == 212 || //dirttyl BitmapID 0
-        uTileID == 217) //dirttyl BitmapID 0
-     continue;*/
-
-    v6 = v8->uTileBitmapID;
-    v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6];
-
-    if (v8->uTileBitmapID == 0xFFFF)
-      continue;
-
-    v8->sTextureDeltaU = 0;
-    v8->sTextureDeltaV = 0;
-
-
-/* world coordinates, z -> height
-            32767
-             +y
-
- -32768 -x        +x 32767
-
-             -y
-           -32768
-*/
-
-    memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));
-    array_73D150[0].u = 0;
-    array_73D150[0].v = 0;
-
-    memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));
-    array_73D150[1].u = 1;
-    array_73D150[1].v = 0;
-
-    memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));
-    array_73D150[2].u = 1;
-    array_73D150[2].v = 1;
-
-    memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));
-    array_73D150[3].u = 0;
-    array_73D150[3].v = 1;
-
-
+  unsigned int uStartX, uEndX,
+               uStartZ, uEndZ;
+  if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024)
+  {
+    uStartX = 0, uEndX = 128;
+    uStartZ = 0, uEndZ = 64 + 16;
+  }
+  else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536)
+  {
+    uStartX = 0, uEndX = 64 + 16;
+    uStartZ = 0, uEndZ = 128;
+  }
+  else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512)
+  {
+    uStartX = 64 - 16, uEndX = 128;
+    uStartZ = 0, uEndZ = 128;
+  }
+  else
+  {
+    uStartX = 0, uEndX = 128;
+    uStartZ = 64 - 16, uEndZ = 128;
+  }
+//  uStartX = 0, uEndX = 128;
+//  uStartZ = 0, uEndZ = 128;
+  static RenderVertexSoft pTerrainVertices[128 * 128];
+  for (unsigned int z = uStartZ; z < uEndZ; ++z)
+  {
+    for (unsigned int x = uStartX; x < uEndX; ++x)
+    {
+      pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
+      pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512;
+      pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x];
+      pIndoorCameraD3D = pGame->pIndoorCameraD3D;
+      pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1);
+      pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0);
+    }
+  }
+  for (unsigned int z = uStartZ; z < uEndZ - 1; ++z)
+  {
+    for (unsigned int x = uStartX; x < uEndX - 1; ++x)
+    {
+      v8 = &array_77EC08[pOutdoorCamera->numStru148s];
+      v8->flags = 0;
+      v8->field_32 = 0;
+      //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x];
+      //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID);
+      v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
+      v6 = v8->uTileBitmapID;
+      v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6];
+      if (v8->uTileBitmapID == 0xFFFF)
+        continue;
+      v8->sTextureDeltaU = 0;
+      v8->sTextureDeltaV = 0;
+      memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));
+      array_73D150[0].u = 0;
+      array_73D150[0].v = 0;
+      memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));
+      array_73D150[1].u = 1;
+      array_73D150[1].v = 0;
+      memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));
+      array_73D150[2].u = 1;
+      array_73D150[2].v = 1;
+      memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));
+      array_73D150[3].u = 0;
+      array_73D150[3].v = 1;
       v55 = 0;
       v54 = false;
       v58 = 0;
-
       if (v58 == 4) // if all y == first y;  primitive in xz plane 
         v8->field_32 |= 0x0001;
-
       v8->pODMFace = nullptr;
       v8->uNumVertices = 4;
       v8->field_59 = 5;
-
       v8->field_58 = 0;
-
       ++pOutdoorCamera->numStru148s;
       ++pOutdoorCamera->field_44;
-
-
-
-        v8->uBModelID = 0;
-        v8->uBModelFaceID = 0;
-        v31 = (8 * (0 | (0 << 6)));
-        v8->field_50 = v31 | 6;
-
-        for (unsigned int k = 0; k < 4; ++k)
-        {
-         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
-         array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
-        }
-
-
-        pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]);
-
+      v8->uBModelID = 0;
+      v8->uBModelFaceID = 0;
+      v31 = (8 * (0 | (0 << 6)));
+      v8->field_50 = v31 | 6;
+      for (unsigned int k = 0; k < 4; ++k)
+      {
+        memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
+        array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
+      }
+      pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]);
       --pOutdoorCamera->numStru148s;
       --pOutdoorCamera->field_44;
-
-    }
-
-  }
+    }
+  }
+}
 
 //----- (0048034E) --------------------------------------------------------
 void Render::DrawTerrainD3D(int a1, int a2, int a3)
--- a/mm7_1.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_1.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -6733,10 +6733,7 @@
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
           v15 = &_50B744_view_transformed_ys[i];
-          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i])
-                                                * v18
-                                                / v16) >> 16)
-                            + _50B834_view_transformed_zs[i];
+          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i]) * v18 / v16) >> 16) + _50B834_view_transformed_zs[i];
           thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
         }
         v19 = v79++;
--- a/mm7_2.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_2.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -13758,7 +13758,7 @@
   }
   else
   {
-    uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64;
+    uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64; // adjust turn speed to estimated fps
   }
   return true;
 }
@@ -13849,6 +13849,7 @@
   }
 
   pNPCStats = new NPCStats;
+  memset(pNPCStats->pNPCData, 0, 0x94BCu);
   pNPCStats->Initialize();
 
   Initialize_GlobalEVT();
--- a/mm7_3.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_3.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
@@ -1426,6 +1428,7 @@
   ObjectDesc *v37; // [sp+78h] [bp-18h]@1
   unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
   int v39; // [sp+80h] [bp-10h]@33
+  Actor *v39b;
   int v40; // [sp+84h] [bp-Ch]@28
   int v41; // [sp+88h] [bp-8h]@34
   int v42; // [sp+8Ch] [bp-4h]@4
@@ -1488,16 +1491,18 @@
         {
           if ( (signed int)uNumActors > v8 )
           {
-            v39 = (int)&pActors[0].word_000086_some_monster_id;
+            v39b = pActors;//[0].word_000086_some_monster_id;
             do
             {
-              v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
-              v14 = (signed __int64)((double)v41 * 0.3333333333333333);
-              v41 = *(short *)(v39 - 38) - 1;
-              if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
-                _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
+              //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
+              //v14 = (signed __int64)((double)v41 * 0.3333333333333333);
+              //v41 = *(short *)(v39 - 38) - 1;
+              //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
+				if( pActors[v1->field_58 >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID )
+					//not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
+					_46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[v39b->word_000086_some_monster_id] - 73));
               ++v42;
-              v39 += 836;
+              ++v39b;// += 836;
             }
             while ( v42 < (signed int)uNumActors );
             v8 = 0;
@@ -1507,11 +1512,11 @@
         {
           if ( (signed int)uNumActors > v8 )
           {
-            v39 = (int)&pActors[0].word_000086_some_monster_id;
+            v39b = pActors;//[0].word_000086_some_monster_id;
             do
             {
-              _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
-              v39 += 836;
+              _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39b] - 73));
+              ++v39b;
             }
             while ( v42 < (signed int)uNumActors );
           }
@@ -3163,7 +3168,7 @@
     bWaterWalk = 1;
     *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
     if ( !(pParty->pPartyBuffs[18].uFlags & 1)
-      && *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
+		&& pParty->pPlayers[pParty->pPartyBuffs[18].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
       bWaterWalk = 0;
   }
   v3 = sub_46D49E_prolly_get_world_y_under_party(v116, v117, v123, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
@@ -3264,7 +3269,7 @@
           pParty->bFlying = 0;
           if ( bUnderwater
             || pParty->pPartyBuffs[7].uFlags & 1
-            || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
+            || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
             if ( pParty->vPosition.z < 4000 || bJumping )
             {
@@ -3304,7 +3309,7 @@
           pParty->bFlying = 0;
           if ( bUnderwater
             || pParty->pPartyBuffs[7].uFlags & 1
-            || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
+            || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
             v123 -= 30;
             v113 -= 30;
@@ -8033,7 +8038,7 @@
   stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
   v62._48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
-  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
+  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
   if ( !v62.pTexture )
     return;
   v8 = pBLVRenderParams->sPartyRotX;
@@ -13556,13 +13561,13 @@
   double v20; // st7@30
   double v21; // st6@30
   double v22; // st5@33
-  unsigned __int16 *v26; // edx@37
+  //unsigned __int16 *v26; // edx@37
   signed int v27; // eax@37
   unsigned __int16 *v28; // ecx@37
   signed int v29; // edi@40
-  int v30; // eax@42
-  unsigned __int16 *v31; // ebx@43
-  signed int v32; // edi@46
+  //int v30; // eax@42
+  //unsigned __int16 *v31; // ebx@43
+  //signed int v32; // edi@46
   signed int v33; // ebx@50
   unsigned int v34; // eax@50
   signed int v35; // ecx@50
@@ -13580,7 +13585,7 @@
   int v47; // eax@108
   unsigned int v48; // ebx@114
   unsigned int v49; // ST64_4@114
-  double v50; // ST20_8@117
+  //double v50; // ST20_8@117
   unsigned int v51; // [sp-10h] [bp-64h]@79
   unsigned int v52; // [sp-10h] [bp-64h]@100
   unsigned int v53; // [sp-Ch] [bp-60h]@79
@@ -13592,9 +13597,9 @@
   unsigned __int16 v59; // [sp-4h] [bp-58h]@100
   unsigned __int16 v60; // [sp+10h] [bp-44h]@66
   unsigned int v61; // [sp+10h] [bp-44h]@85
-  unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
+  //unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
   unsigned int v63; // [sp+14h] [bp-40h]@85
-  int v64; // [sp+18h] [bp-3Ch]@39
+  //int v64; // [sp+18h] [bp-3Ch]@39
   unsigned int v65; // [sp+18h] [bp-3Ch]@85
   unsigned int lPitch; // [sp+20h] [bp-34h]@1
   unsigned int lPitcha; // [sp+20h] [bp-34h]@23
@@ -13604,30 +13609,30 @@
   unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
   signed int uBluea; // [sp+28h] [bp-2Ch]@37
   int v73; // [sp+2Ch] [bp-28h]@30
-  unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
+  //unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
   int v76; // [sp+34h] [bp-20h]@91
   int v77; // [sp+34h] [bp-20h]@108
-  signed int v78; // [sp+38h] [bp-1Ch]@37
+  //signed int v78; // [sp+38h] [bp-1Ch]@37
   int v79; // [sp+38h] [bp-1Ch]@72
-  signed int a2b; // [sp+40h] [bp-14h]@41
+  //signed int a2b; // [sp+40h] [bp-14h]@41
   char *a2c; // [sp+40h] [bp-14h]@68
-  int a3a; // [sp+44h] [bp-10h]@40
+  //int a3a; // [sp+44h] [bp-10h]@40
   signed int uCenterY; // [sp+48h] [bp-Ch]@1
   signed int uCenterX; // [sp+4Ch] [bp-8h]@1
   //signed int uZb; // [sp+5Ch] [bp+8h]@27
   signed int uWidth; // [sp+5Ch] [bp+8h]@30
-  signed int uZd; // [sp+5Ch] [bp+8h]@45
+  //signed int uZd; // [sp+5Ch] [bp+8h]@45
   signed int uZe; // [sp+5Ch] [bp+8h]@67
   signed int uZf; // [sp+5Ch] [bp+8h]@85
   signed int uZg; // [sp+5Ch] [bp+8h]@105
   unsigned int uWa; // [sp+60h] [bp+Ch]@23
   float uWb; // [sp+60h] [bp+Ch]@30
-  unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
+  //unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
   unsigned int uWd; // [sp+60h] [bp+Ch]@95
   float uZooma; // [sp+64h] [bp+10h]@117
-  signed int flagsa; // [sp+68h] [bp+14h]@42
+  //signed int flagsa; // [sp+68h] [bp+14h]@42
   unsigned int flagsb; // [sp+68h] [bp+14h]@66
-  char *flagsc; // [sp+68h] [bp+14h]@86
+  Actor *flagsc; // [sp+68h] [bp+14h]@86
   unsigned int flagsd; // [sp+68h] [bp+14h]@105
 
   //a3 = uY;
@@ -13651,102 +13656,114 @@
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
     v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
-    v74 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
-    v62 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
+    auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
+    auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
     v73 = (1 << (v17 + 16)) / (signed int)uZoom;
     v18 = (double)(1 << (16 - v17));
     v19 = v18;
     v20 = (double)(pParty->vPosition.x + 32768) / v18;
     v21 = (double)(32768 - pParty->vPosition.y) / v19;
     uWb = v21;
-    if ( uZoom == 512 )
-    {
-      v20 = v20 - (double)(uWidth / 2);
-      v22 = (double)(uHeight / 2);
-    }
-    else
-    {
-      if ( uZoom == 1024 )
+    switch (uZoom)
+    {
+      case 512:
+      {
+        v20 = v20 - (double)(uWidth / 2);
+        v22 = (double)(uHeight / 2);
+        uWb = v21 - v22;
+      }
+      break;
+
+      case 1024:
       {
         v20 = v20 - (double)(uWidth / 4);
         v22 = (double)(uHeight / 4);
-      }
-      else
-      {
-        if ( uZoom != 2048 )
-          goto LABEL_37;
+        uWb = v21 - v22;
+      }
+      break;
+
+      case 2048:
+      {
         v20 = v20 - (double)(uWidth / 8);
         v22 = (double)(uHeight / 8);
-      }
-    }
-    uWb = v21 - v22;
-LABEL_37:
+        uWb = v21 - v22;
+      }
+      break;
+
+      default: assert(false);
+    }
+//LABEL_37:
     //v23 = v20 * 65536.0;
     //v24 = v23 + 6.7553994e15;
     v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
     //uWe = uWb * 65536.0;
     //v25 = uWe + 6.7553994e15;
-    v78 = v70;
+    //v78 = v70;
     uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
-    v26 = (unsigned __int16 *)_56EFD8_minimap;
     v27 = uBluea >> 16;
-    uWc = (unsigned __int16 *)_56EFD8_minimap;
     v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
-    if ( flags )
-    {
-      if ( v74 )
-      {
-        v64 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        if ( uHeight > 0 )
-        {
-          a3a = uHeight;
+    if ( flags && pMapLod0)
+    {
+      auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
+      //if ( v74 )
+      //{
+        auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
+        //if ( uHeight > 0 )
+        //{
+          //a3a = uHeight;
           v29 = v70 >> 16;
-          do
-          {
-            a2b = 0;
-            if ( uWidth > 0 )
-            {
-              v30 = (int)&v74[v27 * v64];
-              flagsa = uWidth;
-              a2b = uWidth;
-              do
-              {
-                v31 = uWc;
-                ++uWc;
-                *v31 = v62[*(char *)(v30 + v29)];
-                v78 += v73;
-                v29 = v78 >> 16;
-                --flagsa;
-              }
-              while ( flagsa );
-            }
-            v78 = v70;
+          //do
+          for (int y = 0; y < uHeight; ++y)
+          {
+            //a2b = 0;
+            //if ( uWidth > 0 )
+            //{
+              auto pMapLod0Line = &pMapLod0[v27 * mapWidth];
+              //flagsa = uWidth;
+              //a2b = uWidth;
+              for (int x = 0; x < uWidth; ++x)
+              //do
+              {
+                //v31 = uWc;
+                //++uWc;
+                *pMinimap++ = pPal[pMapLod0Line[v29]];
+                //v78 += v73;
+                v29 = (v70 + x * v73) >> 16;
+                //--flagsa;
+              }
+              //while ( flagsa );
+            //}
+            //v78 = v70;
             v29 = v70 >> 16;
-            v28 += 137 - a2b;
+            v28 += 137 - uWidth;
             uBluea += v73;
             v27 = uBluea >> 16;
-            --a3a;
-          }
-          while ( a3a );
-        }
-      }
-    }
-    uZd = 117;
-    do
-    {
-      v32 = 137;
-      do
-      {
-        *v28 = *v26;
-        ++v28;
-        ++v26;
-        --v32;
-      }
-      while ( v32 );
+            //--a3a;
+          }
+          //while ( a3a );
+        //}
+      //}
+    }
+
+    auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
+    //uZd = 117;
+    //do
+    for (int y = 0; y < 117; ++y)
+    {
+      //v32 = 137;
+      //do
+      for (int x = 0; x < 137; ++x)
+      {
+        *v28++ = *pMinimap++;
+        //++v28;
+        //++v26;
+        //--v32;
+      }
+      //while ( v32 );
       v28 += lPitch - 137;
-      --uZd;
-    }
-    while ( uZd );
+      //--uZd;
+    }
+    //while ( uZd );
     uNumBlueFacesInBLVMinimap = 0;
   }
   else
@@ -13880,7 +13897,7 @@
   v35 = v57;
 LABEL_66:
   pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3,
-    (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
+    (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
   v36 = 255;
   flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
   v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
@@ -13949,16 +13966,16 @@
     uZf = v33;
     if ( (signed int)uNumActors > v33 )
     {
-      flagsc = (char *)&pActors[0].uAIState;
+      flagsc = pActors;//[0].uAIState;
       do
       {
-        v39 = *(short *)flagsc;
-        if ( *(short *)flagsc != 11 && v39 != 19 && (v39 == 5 || *(flagsc - 139) & 0x80) )
-        {
-          v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
+		v39 = flagsc->uAIState;
+		if ( flagsc->uAIState != 11 && v39 != 19 && (v39 == 5 || BYTE1(flagsc->uAttributes) & 0x80) )
+        {
+		  v40 = ((unsigned __int64)(( flagsc->vPosition.x - pParty->vPosition.x)
                                   * (signed __int64)(signed int)uZoom) >> 16)
               + uCenterX;
-          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.y)
+          v76 = (unsigned __int64)(( flagsc->vPosition.y - pParty->vPosition.y)
                                  * (signed __int64)(signed int)uZoom) >> 16;
           v41 = uCenterY - v76;
           if ( v40 >= pRenderer->field_1C_clipx )
@@ -13966,9 +13983,9 @@
             if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
             {
               uWd = v61;
-              if ( *(flagsc - 137) & 1 )
+			  if ( BYTE3(flagsc->uAttributes) & 1 )
                 uWd = v63;
-              if ( *(short *)flagsc == 5 )
+              if ( flagsc->uAIState == 5 )
                 uWd = v65;
               if ( (signed int)uZoom > 1024 )
               {
@@ -13998,7 +14015,7 @@
           }
         }
         ++uZf;
-        flagsc += 836;
+        ++flagsc;
       }
       while ( uZf < (signed int)uNumActors );
       v36 = 255;
@@ -14048,9 +14065,9 @@
   }
   pRenderer->DrawTextureTransparent(0x1D4u, v33, (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
   uZooma = (double)pParty->sRotationY * 0.1171875;
-  v50 = uZooma + 6.7553994e15;
+  //v50 = uZooma + 6.7553994e15;
   pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
-  pRenderer->DrawTextureIndexed(LODWORD(v50) + 285, 0x88u, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
+  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 0x88u, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
   pRenderer->ResetClip();
 }
 
@@ -16863,11 +16880,11 @@
   int v38; // eax@78
   int v39; // ecx@78
   size_t v40; // edx@78
-  char *v41; // esi@79
+  Actor *v41; // esi@79
   int v42; // eax@84
   int v43; // ecx@84
   size_t v44; // edx@84
-  char *v45; // esi@85
+  Actor *v45; // esi@85
   void *v46; // eax@91
   GUIWindow *v47; // eax@93
   GUIButton *v48; // ecx@93
@@ -17251,12 +17268,12 @@
             __debugbreak();
             if ( (signed int)uNumActors > 0 )
             {
-              v41 = (char *)&pActors[0].uGroup;
+              v41 = pActors;//[0].uGroup;
               do
               {
-                if ( *(int *)v41 == v38 )
-                  *(int *)v41 = v39;
-                v41 += 836;
+				if ( v41->uGroup == v38 )
+				  v41->uGroup = v39;
+                ++v41;
                 --v40;
               }
               while ( v40 );
@@ -17269,12 +17286,12 @@
             __debugbreak();
             if ( (signed int)uNumActors > 0 )
             {
-              v45 = (char *)&pActors[0].uAlly;
+              v45 = pActors;//[0].uAlly;
               do
               {
-                if ( *((int *)v45 - 1) == v42 )
-                  *(int *)v45 = v43;
-                v45 += 836;
+				if ( v45->uGroup == v42 )
+				  v45->uAlly = v43;
+                ++v45;
                 --v44;
               }
               while ( v44 );
@@ -19752,7 +19769,7 @@
 //----- (004014E6) --------------------------------------------------------
 int __cdecl ODM_4014E6_AI()
 {
-  int v0; // esi@2
+  Actor *v0; // esi@2
   int v1; // eax@4
   int v2; // ebx@4
   unsigned int v3; // ecx@4
@@ -19786,15 +19803,16 @@
   v25 = 0;
   if ( (signed int)uNumActors > 0 )
   {
-    v0 = (int)&pActors[0].uAttributes;
-    do
-    {
-      *(char *)(v0 + 1) &= 0xFBu;
-      if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
+    v0 = pActors;//[0].uAttributes;
+    do
+    {
+	  //*(char *)(v0 + 1) &= 0xFBu;
+	  BYTE1(v0->uAttributes) &= 0xFBu;
+      if ( ! v0->CanAct() )
         goto LABEL_37;
-      v22 = abs(pParty->vPosition.z - *(short *)(v0 + 110));
-      v21 = abs(pParty->vPosition.y - *(short *)(v0 + 108));
-      v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
+	  v22 = abs(pParty->vPosition.z - v0->vPosition.z);
+      v21 = abs(pParty->vPosition.y - v0->vPosition.y);
+      v1 = abs(pParty->vPosition.x - v0->vPosition.x);
       v2 = v21;
       v3 = v22;
       if ( v1 < v21 )
@@ -19816,7 +19834,7 @@
         v2 = v6;
       }
       v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
-      v8 = *(short *)(v0 + 100);
+	  v8 = v0->uActorRadius;
       v9 = v7 - v8;
       v23 = v7 - v8;
       if ( v23 < 0 )
@@ -19826,18 +19844,18 @@
       }
       if ( v9 < 5632 )
       {
-        v10 = *(int *)v0 & 0xFEFFFFFF;
-        *(int *)v0 = v10;
-        if ( v10 & 0x80000 || ((Actor *)(v0 - offsetof(Actor, uAttributes)))->GetActorsRelation(0) )
+        v10 = v0->uAttributes & 0xFEFFFFFF;
+        v0->uAttributes = v10;
+        if ( v10 & 0x80000 || v0->GetActorsRelation(0) )
         {
           v11 = (pParty->uFlags & 0x10) == 0;
-          *(int *)v0 = v10 | 0x1000000;
+          v0->uAttributes = v10 | 0x1000000;
           if ( v11 && (double)v23 < 307.2 )
             pParty->uFlags |= 0x10u;
           if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
             pParty->uFlags |= 0x20u;
         }
-        *(char *)(v0 + 1) |= 0x40u;
+		BYTE1(v0->uAttributes) |= 0x40u;
         v12 = v27++;
         ai_array_4F75E0[v12] = v9;
         ai_array_4F7DB0_actor_ids[v12] = v25;
@@ -19845,10 +19863,10 @@
       else
       {
 LABEL_37:
-        *(char *)(v0 + 1) &= 0xBFu;
+		  BYTE1(v0->uAttributes) &= 0xBFu;
       }
       ++v25;
-      v0 += 836;
+      ++v0;
     }
     while ( v25 < (signed int)uNumActors );
   }
--- a/mm7_4.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_4.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -79,7 +79,7 @@
   unsigned int v6; // ecx@3
   unsigned int v7; // edx@6
   unsigned int v8; // edx@8
-  char *v9; // edi@13
+  Actor *v9; // edi@13
   int v10; // ebx@14
   int v11; // eax@14
   int v12; // ebx@14
@@ -153,12 +153,12 @@
       v37 = 0;
       if ( (signed int)uNumActors > 0 )
       {
-        v9 = (char *)&pActors[0].vPosition.y;
+        v9 = pActors;//[0].vPosition.y;
         do
         {
-          v10 = abs(v33 - *((short *)v9 - 1));
-          v29 = abs(v32 - *(short *)v9);
-          v26 = abs(v35 - *((short *)v9 + 1));
+		  v10 = abs(v33 - v9->vPosition.x);
+          v29 = abs(v32 - v9->vPosition.y);
+          v26 = abs(v35 - v9->vPosition.z);
           v11 = v10;
           v12 = v29;
           v13 = v26;
@@ -183,7 +183,7 @@
           if ( (signed int)(((unsigned int)(11 * v12) >> 5) + (v13 >> 2) + v11) < v31 )
             EventProcessor(v1->field_16_event_id, 0, 1);
           ++v37;
-          v9 += 836;
+          ++v9;
         }
         while ( v37 < (signed int)uNumActors );
       }
@@ -3399,9 +3399,9 @@
   int result; // eax@1
   int v4; // eax@2
   int v5; // edi@5
-  char *v6; // ecx@5
+  int *v6; // ecx@5
   char v7; // sf@5
-  char *v8; // ecx@10
+  int *v8; // ecx@10
   int v9; // edi@15
   signed int v10; // eax@15
   __int16 *v11; // edx@16
@@ -3462,12 +3462,12 @@
         {
           v5 = v4 * pParty->pPartyBuffs[7].uPower;
           __debugbreak();
-          v6 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000];
-          v7 = *(int *)v6 - v5 < 0;
-          *(int *)v6 -= v5;
+		  v6 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[7].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000];
+          v7 = *v6 < v5;
+          *v6 -= v5;
           if ( v7 )
           {
-            *(int *)v6 = 0;
+            *v6 = 0;
             pParty->uFlags &= 0xFFFFFFBFu;
             pParty->bFlying = 0;
             v51 = 1;
@@ -3482,12 +3482,12 @@
         if ( !(pParty->pPartyBuffs[18].uFlags & 1) )
         {
           __debugbreak();
-          v8 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000];
-          v7 = *(int *)v8 - v4 < 0;
-          *(int *)v8 -= v4;
+          v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[18].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000];
+          v7 = *v8 < v4;
+          *v8 -= v4;
           if ( v7 )
           {
-            *(int *)v8 = 0;
+            *v8 = 0;
             LOBYTE(pParty->uFlags) &= 0x7Fu;
             v51 = 1;
           }
@@ -9214,7 +9214,7 @@
   signed __int64 v3; // ST1C_8@1
   unsigned __int64 v4; // qax@1
   unsigned int v5; // ebx@1
-  void *v6; // ebx@1
+  Player *v6; // ebx@1
 
   pParty->pHirelings[0].bHasUsedTheAbility = 0;
   pParty->pHirelings[1].bHasUsedTheAbility = 0;
@@ -9233,14 +9233,14 @@
   pParty->uCurrentYear = v5 / 0xC + 1168;
   pParty->RestAndHeal();
   dword_507B94 = 1;
-  v6 = &pParty->pPlayers[0].uNumDivineInterventionCastsThisDay;
+  v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
   do
   {
-    *((short *)v6 - 258) = 0;
-    memset(v6, 0, 4u);
-    v6 = (char *)v6 + 6972;
-  }
-  while ( (signed int)v6 < (signed int)&pParty->field_871C[694] );
+	v6->uTimeToRecovery = 0;
+	memset(&v6->uTimeToRecovery, 0, 4u);
+    ++v6;
+  }
+  while ( v6 <= &pParty->pPlayers[3] );
   pParty->_4909F4();
 }
 // 507B94: using guessed type int dword_507B94;
@@ -15092,7 +15092,7 @@
   unsigned int v10; // esi@16
   int v11; // ecx@17
   unsigned int v12; // kr00_4@25
-  void *v13; // esi@25
+  Player *v13; // esi@25
   int v14; // eax@25
   Player *v15; // esi@27
   signed int v16; // eax@32
@@ -15189,17 +15189,17 @@
       v25 = (HOUSE_TYPE)187;
       v12 = LODWORD(pParty->uTimePlayed);
       LODWORD(pParty->uTimePlayed) += 0x7620000u;
-      v13 = &pParty->pPlayers[0].uNumDivineInterventionCastsThisDay;
+      v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
       v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[186].uAnimationID].field_C);
       pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000;
       dword_F8B198 = v14;
       do
       {
-        *((short *)v13 - 258) = 0;
-        memset(v13, 0, 4u);
-        v13 = (char *)v13 + 6972;
-      }
-      while ( (signed int)v13 < (signed int)&pParty->field_871C[694] );
+		v13->uTimeToRecovery = 0;
+		memset(&v13->uTimeToRecovery, 0, 4u);
+        ++v13;
+      }
+      while ( v13 <= &pParty->pPlayers[3] );
       ++pParty->uNumPrisonTerms;
       pParty->uFine = 0;
       v15 = pParty->pPlayers;
@@ -15208,7 +15208,7 @@
         v15->SetVariable(VAR_Award, 87);
         ++v15;
       }
-      while ( (signed int)v15 < (signed int)pParty->pHirelings );
+      while ( v15 <= &pParty->pPlayers[3] );
       v10 = v25;
     }
     ++pIcons_LOD->uTexturePacksCount;
--- a/mm7_5.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_5.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -68,7 +68,7 @@
   unsigned int v2; // edx@7
   Actor *pActor; // ecx@13
   int v4; // ecx@18
-  NPCData *pNPCData; // eax@18
+  NPCData *pNPCData0; // eax@18
   int v6; // edx@20
   int v7; // ecx@29
   unsigned int v8; // edx@59
@@ -341,18 +341,18 @@
             uAction = 0;
             uNumSeconds = uMessage - 134;
             v4 = 0;
-            pNPCData = pParty->pHirelings;
+            pNPCData0 = pParty->pHirelings;
             do
             {
-              if ( pNPCData->pName )
+              if ( pNPCData0->pName )
               {
                 v6 = uAction++;
                 pTmpBuf[v6] = v4;
               }
-              ++pNPCData;
+              ++pNPCData0;
               ++v4;
             }
-            while ( (signed int)pNPCData < (signed int)&pParty->pPickedItem );
+            while ( (signed int)pNPCData0 < (signed int)&pParty->pPickedItem );
             _this = 0;
             if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
             {
@@ -1777,21 +1777,21 @@
           }
           sub_41426F();
           continue;
-        case UIMSG_BC:
+        case UIMSG_ScrollNPCPanel://Right and Left button for NPCPanel
           if ( uMessageParam )
           {
-            GUIWindow::Create(0x272u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCRight, 0);
+            GUIWindow::Create(626, 179, 0, 0, (enum WindowType)90, (int)pBtn_NPCRight, 0);
             v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2;
             if ( (unsigned __int8)pParty->field_709 < v37 )
             {
-              ++pParty->field_709;
+              ++pParty->field_709;//??? maybe number of the first cell???
               if ( (unsigned __int8)pParty->field_709 >= v37 )
                 pParty->field_709 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + pParty->field_70A - 2;
             }
           }
           else
           {
-            GUIWindow::Create(0x1D5u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCLeft, 0);
+            GUIWindow::Create(469, 179, 0, 0, (enum WindowType)90, (int)pBtn_NPCLeft, 0);
             if ( pParty->field_709 )
             {
               --pParty->field_709;
@@ -15999,7 +15999,7 @@
 
 
 //----- (00416B01) --------------------------------------------------------
-void __thiscall sub_416B01(void *_this)
+void __thiscall sub_416B01(void *_this)//PopupWindowForBenefitAndJoinText
 {
   int v1; // edi@2
   int v2; // ecx@2
@@ -16026,18 +16026,23 @@
     v1 = 0;
     v2 = 0;
     v3 = pParty->pHirelings;
-    do
+    /*do
     {
       if ( v3->pName )
         pTmpBuf[v1++] = v2;
       ++v3;
       ++v2;
     }
-    while ( (signed int)v3 < (signed int)&pParty->pPickedItem );
+    while ( (signed int)v3 < (signed int)&pParty->pPickedItem );*/
+    for (int i = 0; i < 2; ++i)
+    {
+     if (pParty->pHirelings[i].pName)
+        pTmpBuf[v1++] = i;
+    }
     lpsz = 0;
     if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
     {
-      v4 = pNPCStats->pNewNPCData;
+      /*v4 = pNPCStats->pNewNPCData;
       do
       {
         if ( v4->uFlags & 0x80
@@ -16047,7 +16052,18 @@
         ++lpsz;
         ++v4;
       }
-      while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );
+      while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/
+      for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+      {
+        if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+        {
+          if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
+          {
+            if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName))
+              pTmpBuf[v1++] = i + 2;
+          }
+        }
+      }
     }
     if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
     {
@@ -16059,11 +16075,11 @@
         if ( a2 == 57 )
           v7 = pNPCTopics[512].pText;
         else
-          v7 = (const CHAR *)*(&pNPCStats->field_13A5C + 5 * v5->uProfession);
+          v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits;
         lpsz = v7;
         if ( !v7 )
         {
-          lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
+          lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText;
           if ( !lpsz )
             lpsz = "";
         }
--- a/mm7_6.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_6.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -2902,7 +2902,7 @@
   int v354; // ecx@686
   int v355; // ecx@687
   int v356; // eax@689
-  SpellBuff *v357; // edi@694
+  Player *v357; // edi@694
   unsigned __int16 v358; // ST1C_2@695
   __int16 v359; // ST18_2@695
   stru6 *v360; // eax@695
@@ -2920,7 +2920,7 @@
   int v372; // ecx@710
   int v373; // eax@715
   int v374; // eax@717
-  char *v375; // edi@717
+  Player *v375; // edi@717
   int v376; // eax@717
   Player *v377; // ecx@719
   int v378; // ecx@721
@@ -3164,7 +3164,7 @@
   __int16 v616; // ST1C_2@1122
   __int16 v617; // ST18_2@1122
   stru6 *v618; // eax@1122
-  SpellBuff *v619; // edi@1123
+  Player *v619; // edi@1123
   unsigned __int16 v620; // ST1C_2@1124
   __int16 v621; // ST18_2@1124
   stru6 *v622; // eax@1124
@@ -3905,8 +3905,9 @@
         v726 = (Player *)(23040 * v2);
         v58 = (signed __int64)((double)(23040 * v2) * 0.033333335);
         v59 = v721;
-        ((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
-          pParty->uTimePlayed + (signed int)v58,
+        //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
+		pActors[a2 >> 3].pActorBuffs[7].Apply(
+		  pParty->uTimePlayed + (signed int)v58,
           v731,
           amount,
           v1,
@@ -3931,10 +3932,13 @@
           if ( v731 == 3 )
             LODWORD(v733) = 29030400;
         }
-        ((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
-        ((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset();
-        v726 = (Player *)((int)v733 << 7);
-        ((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply(
+        //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
+		pActors[a2 >> 3].pActorBuffs[9].Reset();
+        //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset();
+        pActors[a2 >> 3].pActorBuffs[12].Reset();
+		v726 = (Player *)((int)v733 << 7);
+        //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply(
+		pActors[a2 >> 3].pActorBuffs[1].Apply(
           pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
           v731,
           v1,
@@ -5897,18 +5901,18 @@
         a2 = v1;
         v732 = (int)v733 << 7;
         v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
-        v357 = &pParty->pPlayers[0].pPlayerBuffs[11];
+        v357 = pParty->pPlayers;//[0].pPlayerBuffs[11];
         do
         {
           v358 = a2;
           v359 = v3->spellnum;
           v360 = pGame->GetStru6();
           pGame->GetStru6()->SetPlayerBuffAnim(v359, v358);
-          v357->Apply(pParty->uTimePlayed + v717, v731, v1, v1, v1);
+		  v357->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v717, v731, v1, v1, v1);
           ++a2;
-          v357 = (SpellBuff *)((char *)v357 + 6972);
-        }
-        while ( (signed int)v357 < (signed int)&pParty->field_871C[508] );
+          ++v357;// = (SpellBuff *)((char *)v357 + 6972);
+        }
+        while ( v357 <= &pParty->pPlayers[3] );
         goto LABEL_1056;
       case 48:
         v364 = v12 - 2;
@@ -5978,7 +5982,6 @@
         if ( v14 )
         {
           v374 = v3->uPlayerID_2;
-          v375 = (char *)pParty->pPlayers;
           LODWORD(pParty->pPlayers[v374].pConditions[14]) = v1;
           HIDWORD(pParty->pPlayers[v374].pConditions[14]) = v1;
           v376 = v3->uPlayerID_2;
@@ -5989,7 +5992,6 @@
         {
           v732 = amount << 7;
           *(float *)&a2 = (double)(amount << 7) * 0.033333335;
-          v375 = (char *)pParty->pPlayers;
           pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
             0xEu,
             (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
@@ -5997,7 +5999,7 @@
             0xDu,
             (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
         }
-        v377 = (Player *)&v375[6972 * v3->uPlayerID_2];
+        v377 = &pParty->pPlayers[v3->uPlayerID_2];
         goto LABEL_720;
       case 54:
         v378 = v12 - 2;
@@ -6099,13 +6101,11 @@
             v399 = v3->uPlayerID_2;
             LODWORD(pParty->pPlayers[v399].pConditions[13]) = v1;
             HIDWORD(pParty->pPlayers[v399].pConditions[13]) = v1;
-            v400 = (char *)pParty->pPlayers;
           }
           else
           {
             v732 = amount << 7;
             *(float *)&a2 = (double)(amount << 7) * 0.033333335;
-            v400 = (char *)pParty->pPlayers;
             pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
               0x10u,
               (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
@@ -6117,7 +6117,7 @@
               (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
           }
           v83 = 1;
-          ((Player *)&v400[6972 * v3->uPlayerID_2])->SetCondition(1u, 1);
+          pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1);
           v401 = pGame;
           pParty->pPlayers[v3->uPlayerID_2].sHealth = 1;
           v402 = v3->uPlayerID_2;
@@ -6679,7 +6679,6 @@
         pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan(
           6u,
           (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-        v473 = (char *)pParty->pPlayers;
         pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
           8u,
           (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
@@ -6791,14 +6790,13 @@
           pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan(
             7u,
             (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-          v473 = (char *)pParty->pPlayers;
           pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
             9u,
             (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
           v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
           v656 = 11;
 LABEL_937:
-          v325 = (Player *)&v473[6972 * v3->uPlayerID_2];
+          v325 = &pParty->pPlayers[v3->uPlayerID_2];
 LABEL_641:
           v325->DiscardConditionIfLastsLongerThan(v656, v663);
         }
@@ -7585,18 +7583,18 @@
         a2 = v1;
         v732 = (int)v733 << 7;
         v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
-        v619 = &pParty->pPlayers[0].pPlayerBuffs[10];
+        v619 = pParty->pPlayers;//[0].pPlayerBuffs[10];
         do
         {
           v620 = a2;
           v621 = v3->spellnum;
           v622 = pGame->GetStru6();
           pGame->GetStru6()->SetPlayerBuffAnim(v621, v620);
-          v619->Apply(pParty->uTimePlayed + v717, v731, amount, v716, v1);
+		  v619->pPlayerBuffs[10].Apply(pParty->uTimePlayed + v717, v731, amount, v716, v1);
           ++a2;
-          v619 = (SpellBuff *)((char *)v619 + 6972);
-        }
-        while ( (signed int)v619 < (signed int)&pParty->field_871C[504] );
+          ++v619;
+        }
+        while ( v619 <= &pParty->pPlayers[3] );
         goto LABEL_1056;
       case 99:
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -7863,7 +7861,8 @@
   Vec3_int_ a3; // [sp+Ch] [bp-30h]@19
   unsigned int a2; // [sp+18h] [bp-24h]@20
   unsigned int v27; // [sp+1Ch] [bp-20h]@1
-  char *v28; // [sp+20h] [bp-1Ch]@9
+  int v28; // [sp+20h] [bp-1Ch]@9
+  unsigned int *v28b;
   int v29; // [sp+24h] [bp-18h]@16
   int v30; // [sp+28h] [bp-14h]@16
   int v31; // [sp+2Ch] [bp-10h]@4
@@ -7889,27 +7888,27 @@
     v33 = 0;
     if ( v4 )
     {
-      v5 = (char *)v1 + 36 * v4;
-      if ( !(v5[516] & 2) )
+      //v5 = (char *)v1 + 36 * v4;
+	  if ( !(v1->pInventoryItems[v4].field_1A & 2) )//v5[516] & 2) )
       {
-        v28 = v5 + 496;
-        v6 = *((int *)v5 + 124);
+		v28b = &v1->pInventoryItems[v4].uItemID;
+        v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124);
         if ( pItemsTable->pItems[v6].uEquipType == 12 )
         {
-          if ( *((int *)v5 + 128) <= 0 )
+		  if ( v1->pInventoryItems[v4]._bonus_type <= 0 )
           {
-            *(int *)v28 = 0;
+            *v28b = 0;
             v1->pEquipment.uMainHand = 0;
           }
           else
           {
-            v32 = *((int *)v5 + 124);
+			v32 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124);
           }
         }
         else
         {
           if ( v6 == 64 || v6 == 65 )
-            v33 = *((int *)v5 + 124);
+            v33 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124);
         }
       }
     }
@@ -7939,7 +7938,7 @@
       }
       if ( v33 != v9 )
       {
-        v28 = (char *)1;
+        v28 = 1;
         v22 = v0 + 8;
         v20 = v9;
         v18 = v9;
@@ -8003,7 +8002,7 @@
     }
     if ( v33 )
     {
-      v28 = (char *)1;
+      v28 = 1;
       v23 = v0 + 8;
       v21 = 0;
       v19 = 0;
@@ -8035,7 +8034,7 @@
         {
           if ( v29 != v3 )
             return 1;
-          if ( v28 == (char *)v3 )
+          if ( v28 == v3 )
           {
             v15 = v1->pEquipment.uMainHand;
             if ( v1->HasItemEquipped(EQUIP_TWO_HANDED) )
--- a/mm7_data.cpp	Mon Feb 11 09:07:47 2013 +0600
+++ b/mm7_data.cpp	Mon Feb 11 09:08:00 2013 +0600
@@ -287,7 +287,12 @@
 #include "MM7.h"
 stru161 stru_4ECBB8[6];
 stru289 stru_6BE158;
-stru329 array_4E4C30[4];
+stru329 array_4E4C30[4] ={
+	{0x80, 0xCD, 0x1E, 0x90, 0x58, 0x55, 0, 0, 0, 0, 0, 0, 0x11, 0x68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+	{0x83, 0xC9, 0x26, 0x9E, 0x62, 0x57, 0, 0, 0, 0, 0, 0, 0x15, 0x64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+	{0x83, 0xD8, 0x1D, 0xBA, 0x58, 0x77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+	{0x7B, 0xD8, 0x23, 0xB8, 0x62, 0x77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+};
 stru332 stru_511698;
 stru333 stru_511718;
 stru334 array_4E2940[26];
@@ -643,8 +648,26 @@
 char aErrorNoMouseFo[22]; // weak
 int pPaperdoll_BodyX = 481;
 int pPaperdoll_BodyY = 0;
-int paperdoll_array_4E4E30[4][17][2];
-int dword_4E5050[8];
+int paperdoll_array_4E4E30[4][17][2] =
+{
+0x2C, 0x67, 0x30, 0x69, 0x2D, 0x67, 0x2C, 0x64, 0x14, 0x66, 0x22,
+0x67, 0x20, 0x66, 0x25, 0x66, 0x12, 0x66, 0x0A, 0x66, 0x13, 0x64,
+0x0E, 0x64, 0x0A, 0x63, 0x14, 0x66, 0x0A, 0x63, 0x0A, 0x66, 0x25,
+0x66, 0x32, 0x68, 0x32, 0x69, 0x35, 0x69, 0x33, 0x68, 0x24, 0x67,
+0x30, 0x69, 0x33, 0x68, 0x31, 0x69, 0x19, 0x69, 0x19, 0x6A, 0x16,
+0x66, 0x16, 0x65, 0x0F, 0x6B, 0x24, 0x67, 0x0F, 0x6B, 0x19, 0x6A,
+0x31, 0x69, 0x2A, 0x8C, 0x29, 0x8C, 0x2A, 0x89, 0x29, 0x86, 0x12,
+0x87, 0x2D, 0x89, 0x2A, 0x88, 0x25, 0x87, 0x12, 0x8B, 0x12, 0x8B,
+0x11, 0x8A, 0x15, 0x87, 0x09, 0x89, 0x12, 0x87, 0x09, 0x89, 0x12, 0x8B,
+0x25, 0x87, 0x33, 0x90, 0x32, 0x90, 0x34, 0x91, 0x32, 0x8E, 0x21,
+0x8B, 0x31, 0x8B, 0x33, 0x8E, 0x2F, 0x8F, 0x16, 0x8D, 0x18, 0x8C,
+0x19, 0x8C, 0x1B, 0x8E, 0x0C, 0x8C, 0x21, 0x8B, 0x0C, 0x8C, 0x18,
+0x8C, 0x2F, 0x8F
+};
+int dword_4E5050[8] = 
+{
+0x64, 0x67, 0x61, 0x67, 0x65, 0x68, 0x6E, 0x74
+};
 int dword_4E5270[8];
 int dword_4E5490[4][7][2];
 int paredoll_array_4E54B8[3][14];