changeset 1438:bc99e1a48bea

m
author Ritor1
date Mon, 22 Jul 2013 18:00:34 +0600
parents 47975067d6a8
children 468f434a8d8a
files Indoor.cpp Render.cpp mm7_2.cpp mm7_3.cpp
diffstat 4 files changed, 466 insertions(+), 245 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Sat Jul 06 09:07:04 2013 +0600
+++ b/Indoor.cpp	Mon Jul 22 18:00:34 2013 +0600
@@ -7177,13 +7177,13 @@
   //signed int v9; // ecx@10
   //int v10; // eax@10
   //int v11; // edx@11
-  int v12; // ST28_4@12
-  signed int v13; // edx@12
-  signed __int64 v14; // qtt@12
-  char *v15; // ebx@12
-  int v16; // ST28_4@14
-  signed int v17; // eax@14
-  signed __int64 v18; // qtt@14
+  int t;
+  //signed int v13; // edx@12
+  //signed __int64 v14; // qtt@12
+  //char *v15; // ebx@12
+  //int v16; // ST28_4@14
+  //signed int v17; // eax@14
+  //signed __int64 v18; // qtt@14
   signed int v19; // edx@15
   signed int v20; // edx@17
   signed int v21; // ebx@19
@@ -7323,42 +7323,35 @@
       if ( current_vertices_flag ^ next_vertices_flag )
       {
         //v11 = stru_50B700._view_transformed_xs[i + 2];
-        if ( stru_50B700._view_transformed_xs[i + 3] >= 524288 )
+        if ( next_vertices_flag )
         {
-          v12 = stru_50B700._view_transformed_xs[i + 3] - stru_50B700._view_transformed_xs[i + 2];
-          v13 = 524288 - stru_50B700._view_transformed_xs[i + 2];
-          LODWORD(v14) = v13 << 16;
-          HIDWORD(v14) = v13 >> 16;
-          v15 = (char *)&stru_50B700._view_transformed_ys[i + 2];
-          stru_50B700._view_transformed_zs[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i + 3]
-                                                                     - stru_50B700._view_transformed_zs[i + 2])
-                                                                    * v14
-                                                                    / v12) >> 16)
-                                                + stru_50B700._view_transformed_zs[i + 2];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i + 3] - stru_50B700._view_transformed_ys[i + 2])
-                                   * v14
-                                   / v12) >> 16;
+          //t = near_clip - v0.z/v1.z - v0.z
+          // near_clip = 8.0(524288)
+          t = 524288 - stru_50B700._view_transformed_xs[i + 2] / stru_50B700._view_transformed_xs[i + 3] - stru_50B700._view_transformed_xs[i + 2];
+          // new_x = (v1.x - v0.x) * t + v0.x
+          stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 3]
+                                                                 - stru_50B700._view_transformed_zs[i + 2]) * t + stru_50B700._view_transformed_zs[i + 2];
+          //new_y = (v1.y - v0.y)*t + v0.y
+          stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 3] - stru_50B700._view_transformed_ys[i + 2])
+                                   * t + stru_50B700._view_transformed_ys[i + 2];
+          stru_50B700._view_transformed_xs[depth_num_vertices] = 524288;
         }
         else
         {
-          v16 = stru_50B700._view_transformed_xs[i + 2] - stru_50B700._view_transformed_xs[i + 3];
-          v17 = 524288 - stru_50B700._view_transformed_xs[i + 3];
-          LODWORD(v18) = v17 << 16;
-          HIDWORD(v18) = v17 >> 16;
-          v15 = (char *)&stru_50B700._view_transformed_ys[i + 3];
-          stru_50B700._view_transformed_zs[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i + 2]
-                                                                     - stru_50B700._view_transformed_zs[i + 3])
-                                                                    * v18
-                                                                    / v16) >> 16)
-                                                + stru_50B700._view_transformed_zs[i + 3];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i + 2] - stru_50B700._view_transformed_ys[i + 3])
-                                   * v18
-                                   / v16) >> 16;
+          //t = near_clip - v1.z/v0.z - v1.z
+          t = 524288 - stru_50B700._view_transformed_xs[i + 3] / stru_50B700._view_transformed_xs[i + 2] - stru_50B700._view_transformed_xs[i + 3];
+          // new_x = (v0.x - v1.x) * t + v1.x
+          stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 2]
+                                                               - stru_50B700._view_transformed_zs[i + 3]) * t + stru_50B700._view_transformed_zs[i + 3];
+          //new_y = (v0.y - v1.y)*t + v1.y
+          stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 2] - stru_50B700._view_transformed_ys[i + 3])
+                                                * t + stru_50B700._view_transformed_ys[i + 3];
+          stru_50B700._view_transformed_xs[depth_num_vertices] = 524288;
         }
         v19 = depth_num_vertices++;
         //v7 = pFace->uNumVertices;
-        stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15;
-        stru_50B700._view_transformed_xs[v19] = 524288;
+        //stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15;
+        //stru_50B700._view_transformed_xs[v19] = 524288;
       }
       if ( next_vertices_flag )
       {
@@ -7371,17 +7364,16 @@
     }
   }
 
-  v87 = 0;
+  
   v21 = depth_num_vertices;
   stru_50B700._view_transformed_xs[depth_num_vertices] = stru_50B700._view_transformed_xs[0];
   stru_50B700._view_transformed_zs[depth_num_vertices] = stru_50B700._view_transformed_zs[0];
-  for ( stru_50B700._view_transformed_ys[depth_num_vertices] = stru_50B700._view_transformed_ys[0];
-        v87 < depth_num_vertices;
-        stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 )
+  stru_50B700._view_transformed_ys[depth_num_vertices] = stru_50B700._view_transformed_ys[0];
+  for ( v87 = 0; v87 < depth_num_vertices; ++v87 )
   {
     v22 = v87;
     thisc = abs(stru_50B700._view_transformed_xs[v87]);
-    if ( abs(stru_50B700._view_transformed_zs[v87]) >> 13 <= thisc )
+    if ( (abs(stru_50B700._view_transformed_zs[v87]) >> 13) <= thisc )
     {
       v27 = stru_50B700._view_transformed_zs[v22];
       LODWORD(v28) = v27 << 16;
@@ -7416,7 +7408,7 @@
 
     v29 = stru_50B700._view_transformed_ys[v22];
     stru_50B700._screen_space_x[v22 + 12] = v26;
-    if ( abs(v29) >> 13 <= thisc )
+    if ( (abs(v29) >> 13) <= thisc )
     {
       v33 = stru_50B700._view_transformed_ys[v22];
       LODWORD(v34) = v33 << 16;
@@ -7451,7 +7443,8 @@
                                                              * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16;
     v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16;
     stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12];
-    ++v87;
+    stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35;
+    //++v87;
   }
   v36 = 0;
   stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12];
--- a/Render.cpp	Sat Jul 06 09:07:04 2013 +0600
+++ b/Render.cpp	Mon Jul 22 18:00:34 2013 +0600
@@ -1672,24 +1672,8 @@
 
 void Render::RenderTerrainD3D() // New function
 {
-  char result; // al@3
-  int v6; // ecx@8
- struct stru148 *pTile; // ebx@8
- struct stru148 *v16;
-  unsigned int v18; // edi@22
-  int v35; // edi@63
-  int v37; // eax@73
-  int v39; // eax@80
-  char v40; // [sp-18h] [bp-70h]@2
-  int v41; // [sp-14h] [bp-6Ch]@2
-  int v42; // [sp-10h] [bp-68h]@2
-  int v43; // [sp-Ch] [bp-64h]@2
-  const char *v44; // [sp-8h] [bp-60h]@2
-  int v45; // [sp-4h] [bp-5Ch]@2
-  int v56;
-  int v57; // [sp+38h] [bp-20h]@36
-  int v64; // [sp+57h] [bp-1h]@2
-  int v62;
+  int pTextureID; // ecx@8
+  struct stru148 *pTile; // ebx@8
 
   //warning: the game uses CW culling by default, ccw is incosistent
   pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
@@ -1787,7 +1771,7 @@
 
       ++pOutdoorCamera->numStru148s;
       ++pOutdoorCamera->field_44;
-      assert(pOutdoorCamera->numStru148s < 20000);
+      assert(pOutdoorCamera->numStru148s < 20000);// numStru148s - это количество фейсов(numFaces)
 
       pTile->uBModelID = 0;
       pTile->uBModelFaceID = 0;
@@ -1805,22 +1789,22 @@
         if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id)
         {
           //transparent = false;
-          v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
+          pTextureID = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
-          v6 = pTile->uTileBitmapID;
+          pTextureID = pTile->uTileBitmapID;
           if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) )
             transparent = true;
         }
 
-      assert(v6 < 1000); // many random crashes here
+      assert(pTextureID < 1000); // many random crashes here
 
       // for all shore tiles - draw a tile water under them since they're half-empty
       if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
         pTile->DrawBorderTiles();
 
-      pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
+      pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[pTextureID], transparent, true);
       }
       //else //здесь уже пограничные тайлы воды
         //pTile->DrawBorderTiles();
--- a/mm7_2.cpp	Sat Jul 06 09:07:04 2013 +0600
+++ b/mm7_2.cpp	Mon Jul 22 18:00:34 2013 +0600
@@ -7132,8 +7132,8 @@
   char *v11; // edx@20
   unsigned __int16 v12; // ax@23
   int v13; // eax@27
-  unsigned int v14; // ebx@33
-  unsigned __int16 v15; // ax@35
+  //unsigned int v14; // ebx@33
+  //unsigned __int16 v15; // ax@35
   int v16; // eax@36
   unsigned int v17; // eax@37
   __int16 v18; // di@37
@@ -7243,15 +7243,15 @@
   unsigned int v122; // eax@260
   char *v123; // edx@261
   int v124; // eax@267
-  int v125; // [sp-20h] [bp-4Ch]@28
-  signed int v126; // [sp-1Ch] [bp-48h]@27
-  unsigned int v127; // [sp-18h] [bp-44h]@27
-  signed int v128; // [sp-14h] [bp-40h]@27
-  signed int v129; // [sp-10h] [bp-3Ch]@27
-  int v130; // [sp-Ch] [bp-38h]@27
-  unsigned int v131; // [sp-8h] [bp-34h]@27
+  //int v125; // [sp-20h] [bp-4Ch]@28
+  //signed int v126; // [sp-1Ch] [bp-48h]@27
+  //unsigned int v127; // [sp-18h] [bp-44h]@27
+  //signed int v128; // [sp-14h] [bp-40h]@27
+  //signed int v129; // [sp-10h] [bp-3Ch]@27
+  //int v130; // [sp-Ch] [bp-38h]@27
+  //unsigned int v131; // [sp-8h] [bp-34h]@27
   char v132; // [sp-8h] [bp-34h]@131
-  int v133; // [sp-4h] [bp-30h]@27
+  //int v133; // [sp-4h] [bp-30h]@27
   char v134; // [sp-4h] [bp-30h]@131
   signed int v135; // [sp-4h] [bp-30h]@217
   int v136; // [sp+Ch] [bp-20h]@208
@@ -7305,13 +7305,13 @@
 
   v6 = v2->uType;
   v7 = v2->uType;
-  if ( v7 > 3060 )
-  {
-    if ( v7 > 6090 )
-    {
-      if ( v7 > 8090 )
+  if ( v2->uType > 3060 )
+  {
+    if ( v2->uType > 6090 )
+    {
+      if ( v2->uType > 8090 )
       {
-        if ( v7 == 9010 )
+        if ( v2->uType == 9010 )
           goto LABEL_247;
         if ( v7 != 9030 )
         {
@@ -7333,13 +7333,88 @@
                 ++v146;
                 v144 += 56;
                 if ( v146 >= (signed int)v99 )
-                  goto LABEL_195;
+                {
+                  v46 = 0;
+                  v2->uObjectDescID = v46;
+                  if ( v46 == (short)v32 )
+                    SpriteObject::OnInteraction(v153);
+                  v100 = v2->field_61;
+                  v101 = v2->vPosition.z;
+                  v2->uSpriteFrameID = v32;
+                  v102 = 8 * v153;
+                  v103 = v2->vPosition.y;
+                  LOBYTE(v102) = PID(OBJECT_Item,v153);
+                  v2->vVelocity.x = v32;
+                  v2->vVelocity.y = v32;
+                  v104 = v2->vPosition.x;
+                  v2->vVelocity.z = v32;
+                  v149 = v102;
+                  stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+                  if ( HIBYTE(v3->uFlags) & 1 )
+                    array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+                  v105 = v2->uSoundID;
+                  if ( v105 == (short)v32 )
+                    v47 = 0;
+                  else
+                    v47 = (signed __int16)v105 + 4;
+                  v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+                  pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+                  return 0;
+                }
               }
-              goto LABEL_80;
+              v46 = v146;
+              v2->uObjectDescID = v46;
+              if ( v46 == (short)v32 )
+                SpriteObject::OnInteraction(v153);
+              v100 = v2->field_61;
+              v101 = v2->vPosition.z;
+              v2->uSpriteFrameID = v32;
+              v102 = 8 * v153;
+              v103 = v2->vPosition.y;
+              LOBYTE(v102) = PID(OBJECT_Item,v153);
+              v2->vVelocity.x = v32;
+              v2->vVelocity.y = v32;
+              v104 = v2->vPosition.x;
+              v2->vVelocity.z = v32;
+              v149 = v102;
+              stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+              if ( HIBYTE(v3->uFlags) & 1 )
+                array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+              v105 = v2->uSoundID;
+              if ( v105 == (short)v32 )
+                v47 = 0;
+              else
+                v47 = (signed __int16)v105 + 4;
+              v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+              pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+              return 0;
             }
-LABEL_195:
             v46 = 0;
-            goto LABEL_196;
+            v2->uObjectDescID = v46;
+            if ( v46 == (short)v32 )
+              SpriteObject::OnInteraction(v153);
+            v100 = v2->field_61;
+            v101 = v2->vPosition.z;
+            v2->uSpriteFrameID = v32;
+            v102 = 8 * v153;
+            v103 = v2->vPosition.y;
+            LOBYTE(v102) = PID(OBJECT_Item,v153);
+            v2->vVelocity.x = v32;
+            v2->vVelocity.y = v32;
+            v104 = v2->vPosition.x;
+            v2->vVelocity.z = v32;
+            v149 = v102;
+            stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+            if ( HIBYTE(v3->uFlags) & 1 )
+            array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+            v105 = v2->uSoundID;
+            if ( v105 == (short)v32 )
+              v47 = 0;
+            else
+              v47 = (signed __int16)v105 + 4;
+            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+            pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+            return 0;
           }
           goto LABEL_93;
         }
@@ -7361,7 +7436,10 @@
         if ( v151 != OBJECT_Actor)
         {
           if ( v6 != 9030 || v2->spell_skill != 4 )
-            goto LABEL_246;
+          {
+            SpriteObject::OnInteraction(v153);
+            return 0;
+          }
           v2->_46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
@@ -7398,19 +7476,12 @@
               v114 = (signed __int16)v113 + 4;
             else
               v114 = 0;
-            v133 = 0;
-            v131 = 0;
-            v130 = v114;
             v115 = 8 * v153;
-            v129 = 0;
-            v128 = -1;
             LOBYTE(v115) = PID(OBJECT_Item,v153);
-            v127 = 0;
-            v126 = v115;
-            v116 = v143;
-            goto LABEL_269;
+            v116 = v143 + 1;
+            pAudioPlayer->PlaySound((SoundID)v116, v115, 0, -1, 0, 0, 0, 0);
+            return 0;
           }
-LABEL_246:
           SpriteObject::OnInteraction(v153);
           return 0;
         }
@@ -7461,12 +7532,8 @@
                     pActors[v108].uAIState = Standing;
                     pActors[v108].UpdateAnimation();
                   }
-                  pActors[v108].pActorBuffs[v136].Apply(
-                    pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
-                    v152,
-                    v150,
-                    0,
-                    0);
+                  pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
+                    v152, v150, 0, 0);
                 }
               }
               else
@@ -7503,11 +7570,67 @@
             ++v52;
             v94 += 56;
             if ( v52 >= (signed int)v93 )
-              goto LABEL_181;
+            {
+              v95 = 0;
+              v2->uObjectDescID = v95;
+              if ( v95 == (short)v9 )
+                SpriteObject::OnInteraction(v153);
+              v96 = v2->uSoundID;
+              v2->vVelocity.z = v9;
+              v2->vVelocity.y = v9;
+              v2->vVelocity.x = v9;
+              v2->uSpriteFrameID = v9;
+              if ( v96 == (short)v9 )
+                v97 = 0;
+              else
+                v97 = (signed __int16)v96 + 4;
+              v92 = v153;
+              v124 = 8 * v92;
+              LOBYTE(v124) = v124 | 2;
+              v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+              pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+              return 0;
+            }
           }
-          goto LABEL_202;
+          v95 = v52;
+          v2->uObjectDescID = v95;
+          if ( v95 == (short)v9 )
+            SpriteObject::OnInteraction(v153);
+          v96 = v2->uSoundID;
+          v2->vVelocity.z = v9;
+          v2->vVelocity.y = v9;
+          v2->vVelocity.x = v9;
+          v2->uSpriteFrameID = v9;
+          if ( v96 == (short)v9 )
+            v97 = 0;
+          else
+            v97 = (signed __int16)v96 + 4;
+          v92 = v153;
+          v124 = 8 * v92;
+          LOBYTE(v124) = v124 | 2;
+          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+          return 0;
         }
-        goto LABEL_181;
+        v95 = 0;
+        v2->uObjectDescID = v95;
+        if ( v95 == (short)v9 )
+          SpriteObject::OnInteraction(v153);
+        v96 = v2->uSoundID;
+        v2->vVelocity.z = v9;
+        v2->vVelocity.y = v9;
+        v2->vVelocity.x = v9;
+        v2->uSpriteFrameID = v9;
+        if ( v96 == (short)v9 )
+          v97 = 0;
+        else
+          v97 = (signed __int16)v96 + 4;
+        v92 = v153;
+        v124 = 8 * v92;
+        LOBYTE(v124) = v124 | 2;
+        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+        pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+        return 0;
       }
       v79 = v7 == 8030;
     }
@@ -7559,34 +7682,22 @@
             v2->uObjectDescID = v58;
             if ( !v58 )
               SpriteObject::OnInteraction(v153);
-            v14 = v153;
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
             v2->vVelocity.x = 0;
             v2->uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-LABEL_35:
-            v15 = v2->uSoundID;
-            if ( v15 == (short)v9 )
+            //v15 = v2->uSoundID;
+            if ( v2->uSoundID == (short)v9 )
               v16 = 0;
             else
-              v16 = (signed __int16)v15 + 4;
-            v133 = v9;
-            v131 = v9;
-            v130 = v16;
-            v92 = v14;
-LABEL_267:
+              v16 = (signed __int16)v2->uSoundID + 4;
+            v92 = v153;
             v124 = 8 * v92;
-            v129 = v9;
-            v128 = -1;
             LOBYTE(v124) = v124 | 2;
-            v127 = v9;
-            v126 = v124;
-LABEL_268:
-            v116 = word_4EE088_sound_ids[v2->spell_id - 1];
-LABEL_269:
-            v125 = v116 + 1;
-            goto LABEL_29;
+            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+            pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
+            return 0;
           }
           v59 = v6 + 2;
           v60 = pObjectList->uNumObjects;
@@ -7635,10 +7746,17 @@
             while ( v141 );
           }
 LABEL_160:
-          v14 = v153;
-LABEL_34:
-          SpriteObject::OnInteraction(v14);
-          goto LABEL_35;
+          SpriteObject::OnInteraction(v153);
+          if ( v2->uSoundID == (short)v9 )
+            v16 = 0;
+          else
+            v16 = (signed __int16)v2->uSoundID + 4;
+          v92 = v153;
+          v124 = 8 * v92;
+          LOBYTE(v124) = v124 | 2;
+          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
+          return 0;
         }
         if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
           return 1;
@@ -7671,7 +7789,6 @@
         v134 = 0;
         v72 = v153;
         v132 = 0;
-LABEL_132:
         v73 = v2->vPosition.z;
         v74 = v2->vPosition.y;
         v75 = PID(OBJECT_Item,v72);
@@ -7686,14 +7803,9 @@
           v78 = 0;
         else
           v78 = (signed __int16)v77 + 4;
-        v133 = v66;
-        v131 = v66;
-        v130 = v78;
-        v129 = v66;
-        v128 = -1;
-        v127 = v66;
-        v126 = v75;
-        goto LABEL_268;
+        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+        pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66);
+        return 0;
       }
       if ( v7 == 4090 )
       {
@@ -7774,7 +7886,23 @@
         v134 = 0;
         v72 = v153;
         v132 = v2->field_61;
-        goto LABEL_132;
+        v73 = v2->vPosition.z;
+        v74 = v2->vPosition.y;
+        v75 = PID(OBJECT_Item,v72);
+        v2->vVelocity.z = v66;
+        v2->vVelocity.y = v66;
+        v76 = v2->vPosition.x;
+        v2->vVelocity.x = v66;
+        v2->uSpriteFrameID = v66;
+        stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134);
+        v77 = v2->uSoundID;
+        if ( v77 == (short)v66 )
+          v78 = 0;
+        else
+          v78 = (signed __int16)v77 + 4;
+        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+        pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66);
+        return 0;
       }
       if ( v7 == 4100 || v7 == 6010 )
         goto LABEL_93;
@@ -7840,21 +7968,33 @@
           v9 = 0;
           v10 = 0;
           if ( (signed int)v8 <= 0 )
-            goto LABEL_23;
+          {
+            v12 = 0;
+            goto LABEL_24;
+          }
           v11 = (char *)&pObjectList->pObjects->uObjectID;
           break;
         case 545:
         case 550:
           if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 )
           {
-            v14 = v153;
             v9 = 0;
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
             v2->vVelocity.x = 0;
             v2->uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-            goto LABEL_34;
+            SpriteObject::OnInteraction(v153);
+            if ( v2->uSoundID == (short)v9 )
+              v16 = 0;
+            else
+              v16 = (signed __int16)v2->uSoundID + 4;
+            v92 = v153;
+            v124 = 8 * v92;
+            LOBYTE(v124) = v124 | 2;
+            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+            pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
+            return 0;
           }
           v17 = pObjectList->uNumObjects;
           v18 = 0;
@@ -7883,7 +8023,6 @@
         v11 += 56;
         if ( v10 >= (signed int)v8 )
         {
-LABEL_23:
           v12 = 0;
           goto LABEL_24;
         }
@@ -7899,7 +8038,12 @@
       v2->vVelocity.x = 0;
       v2->uSpriteFrameID = 0;
       if ( !v44 )
-        goto LABEL_27;
+      {
+        v13 = 8 * v153;
+        LOBYTE(v13) = PID(OBJECT_Item,v153);
+        pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9);
+        return 0;
+      }
     }
     return 0;
   }
@@ -7934,13 +8078,49 @@
         ++v52;
         v53 += 56;
         if ( v52 >= (signed int)v51 )
-          goto LABEL_181;
+        {
+          v95 = 0;
+          v2->uObjectDescID = v95;
+          if ( v95 == (short)v9 )
+            SpriteObject::OnInteraction(v153);
+          v96 = v2->uSoundID;
+          v2->vVelocity.z = v9;
+          v2->vVelocity.y = v9;
+          v2->vVelocity.x = v9;
+          v2->uSpriteFrameID = v9;
+          if ( v96 == (short)v9 )
+            v97 = 0;
+          else
+            v97 = (signed __int16)v96 + 4;
+          v92 = v153;
+          v124 = 8 * v92;
+          LOBYTE(v124) = v124 | 2;
+          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+          return 0;
+        }
       }
-      goto LABEL_202;
-    }
-LABEL_181:
+      v95 = v52;
+      v2->uObjectDescID = v95;
+      if ( v95 == (short)v9 )
+        SpriteObject::OnInteraction(v153);
+      v96 = v2->uSoundID;
+      v2->vVelocity.z = v9;
+      v2->vVelocity.y = v9;
+      v2->vVelocity.x = v9;
+      v2->uSpriteFrameID = v9;
+      if ( v96 == (short)v9 )
+        v97 = 0;
+      else
+        v97 = (signed __int16)v96 + 4;
+      v92 = v153;
+      v124 = 8 * v92;
+      LOBYTE(v124) = v124 | 2;
+      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+      pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+      return 0;
+    }
     v95 = 0;
-LABEL_182:
     v2->uObjectDescID = v95;
     if ( v95 == (short)v9 )
       SpriteObject::OnInteraction(v153);
@@ -7953,11 +8133,12 @@
       v97 = 0;
     else
       v97 = (signed __int16)v96 + 4;
-    v133 = v9;
-    v131 = v9;
-    v130 = v97;
     v92 = v153;
-    goto LABEL_267;
+    v124 = 8 * v92;
+    LOBYTE(v124) = v124 | 2;
+    v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+    pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+   return 0;
   }
   if ( v7 == 1100 )
     goto LABEL_93;
@@ -8002,14 +8183,8 @@
     stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0);
     if ( HIBYTE(v3->uFlags) & 1 )
       array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor);
-    v133 = 0;
-    v131 = 0;
-    v130 = 0;
-    v129 = 0;
-    v128 = -1;
-    v127 = 0;
-    v126 = v147;
-    goto LABEL_28;
+    pAudioPlayer->PlaySound((SoundID)8, v147, 0, -1, 0, 0, 0, 0);
+    return 0;
   }
   v27 = v26 - 410;
   if ( !v27 )
@@ -8038,11 +8213,36 @@
           ++v146;
           v140 += 56;
           if ( v146 >= (signed int)v31 )
-            goto LABEL_195;
+          {
+            v46 = 0;
+            v2->uObjectDescID = v46;
+            if ( v46 == (short)v32 )
+              SpriteObject::OnInteraction(v153);
+            v100 = v2->field_61;
+            v101 = v2->vPosition.z;
+            v2->uSpriteFrameID = v32;
+            v102 = 8 * v153;
+            v103 = v2->vPosition.y;
+            LOBYTE(v102) = PID(OBJECT_Item,v153);
+            v2->vVelocity.x = v32;
+            v2->vVelocity.y = v32;
+            v104 = v2->vPosition.x;
+            v2->vVelocity.z = v32;
+            v149 = v102;
+            stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+            if ( HIBYTE(v3->uFlags) & 1 )
+              array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+            v105 = v2->uSoundID;
+            if ( v105 == (short)v32 )
+              v47 = 0;
+            else
+              v47 = (signed __int16)v105 + 4;
+            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+            pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+            return 0;
+          }
         }
-LABEL_80:
         v46 = v146;
-LABEL_196:
         v2->uObjectDescID = v46;
         if ( v46 == (short)v32 )
           SpriteObject::OnInteraction(v153);
@@ -8059,27 +8259,42 @@
         v149 = v102;
         stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
         if ( HIBYTE(v3->uFlags) & 1 )
-          array_5118E8._440E91(
-            v2->vPosition.x,
-            v2->vPosition.y,
-            v2->vPosition.z,
-            v32,
-            v3->uParticleTrailColor);
+          array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
         v105 = v2->uSoundID;
         if ( v105 == (short)v32 )
           v47 = 0;
         else
           v47 = (signed __int16)v105 + 4;
-        v133 = v32;
-        v131 = v32;
-        v130 = v47;
-        v129 = v32;
-        v128 = -1;
-        v127 = v32;
-        v126 = v149;
-        goto LABEL_268;
+        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+        pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+        return 0;
       }
-      goto LABEL_195;
+      v46 = 0;
+      v2->uObjectDescID = v46;
+      if ( v46 == (short)v32 )
+      SpriteObject::OnInteraction(v153);
+      v100 = v2->field_61;
+      v101 = v2->vPosition.z;
+      v2->uSpriteFrameID = v32;
+      v102 = 8 * v153;
+      v103 = v2->vPosition.y;
+      LOBYTE(v102) = PID(OBJECT_Item,v153);
+      v2->vVelocity.x = v32;
+      v2->vVelocity.y = v32;
+      v104 = v2->vPosition.x;
+      v2->vVelocity.z = v32;
+      v149 = v102;
+      stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+      if ( HIBYTE(v3->uFlags) & 1 )
+        array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+      v105 = v2->uSoundID;
+      if ( v105 == (short)v32 )
+        v47 = 0;
+      else
+        v47 = (signed __int16)v105 + 4;
+      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+      pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
+      return 0;
     }
     return 1;
   }
@@ -8100,13 +8315,67 @@
         ++v52;
         v123 += 56;
         if ( v52 >= (signed int)v122 )
-          goto LABEL_181;
+        {
+          v95 = 0;
+          v2->uObjectDescID = v95;
+          if ( v95 == (short)v9 )
+            SpriteObject::OnInteraction(v153);
+          v96 = v2->uSoundID;
+          v2->vVelocity.z = v9;
+          v2->vVelocity.y = v9;
+          v2->vVelocity.x = v9;
+          v2->uSpriteFrameID = v9;
+          if ( v96 == (short)v9 )
+            v97 = 0;
+          else
+            v97 = (signed __int16)v96 + 4;
+          v92 = v153;
+          v124 = 8 * v92;
+          LOBYTE(v124) = v124 | 2;
+          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+          return 0;
+        }
       }
-LABEL_202:
       v95 = v52;
-      goto LABEL_182;
-    }
-    goto LABEL_181;
+      v2->uObjectDescID = v95;
+      if ( v95 == (short)v9 )
+        SpriteObject::OnInteraction(v153);
+      v96 = v2->uSoundID;
+      v2->vVelocity.z = v9;
+      v2->vVelocity.y = v9;
+      v2->vVelocity.x = v9;
+      v2->uSpriteFrameID = v9;
+      if ( v96 == (short)v9 )
+        v97 = 0;
+      else
+        v97 = (signed __int16)v96 + 4;
+      v92 = v153;
+      v124 = 8 * v92;
+      LOBYTE(v124) = v124 | 2;
+      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+      pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+      return 0;
+    }
+    v95 = 0;
+    v2->uObjectDescID = v95;
+    if ( v95 == (short)v9 )
+      SpriteObject::OnInteraction(v153);
+    v96 = v2->uSoundID;
+    v2->vVelocity.z = v9;
+    v2->vVelocity.y = v9;
+    v2->vVelocity.x = v9;
+    v2->uSpriteFrameID = v9;
+    if ( v96 == (short)v9 )
+      v97 = 0;
+    else
+      v97 = (signed __int16)v96 + 4;
+    v92 = v153;
+    v124 = 8 * v92;
+    LOBYTE(v124) = v124 | 2;
+    v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
+    pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
+   return 0;
   }
   v117 = v6 + 1;
   v118 = pObjectList->uNumObjects;
@@ -8138,19 +8407,8 @@
   v2->vVelocity.y = 0;
   v2->vVelocity.x = 0;
   v2->uSpriteFrameID = 0;
-LABEL_27:
-  v133 = v9;
-  v131 = v9;
-  v130 = v9;
   v13 = 8 * v153;
-  v129 = v9;
-  v128 = -1;
   LOBYTE(v13) = PID(OBJECT_Item,v153);
-  v127 = v9;
-  v126 = v13;
-LABEL_28:
-  v125 = 8;
-LABEL_29:
-  pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+  pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9);
   return 0;
 }
--- a/mm7_3.cpp	Sat Jul 06 09:07:04 2013 +0600
+++ b/mm7_3.cpp	Mon Jul 22 18:00:34 2013 +0600
@@ -5958,36 +5958,21 @@
 {
   int v0; // esi@2
   int v1; // eax@2
-  //double v2; // st7@2
-  //double v3; // st6@2
-  //double v4; // st5@2
-  //double v5; // st4@2
-  //double v6; // st7@2
-  //char *v7; // esi@3
   int v8; // eax@4
   int v9; // eax@4
   int v10; // ebx@4
   signed __int64 v11; // qax@6
-  double v12; // st7@6
+  //double v12; // st7@6
   int v13; // edi@6
   int v14; // ecx@6
-  int v15; // eax@8
+  //int v15; // eax@8
   int v16; // eax@12
   signed __int64 v17; // qtt@13
-  signed int v18; // ecx@13
-  //Texture *v19; // eax@15
-  //double v20; // st6@15
-  //double v21; // st7@15
-  //double v22; // st6@15
-  //unsigned __int8 v23; // sf@15
-  //unsigned __int8 v24; // of@15
+  signed int pShading; // ecx@13
   stru148 pSky; // [sp+14h] [bp-150h]@1
-  //double v26; // [sp+120h] [bp-44h]@4
-  //float v27; // [sp+128h] [bp-3Ch]@4
   float v28; // [sp+12Ch] [bp-38h]@2
   int v29; // [sp+130h] [bp-34h]@4
   int v30; // [sp+134h] [bp-30h]@1
-  //int v31; // [sp+138h] [bp-2Ch]@2
   int v32; // [sp+13Ch] [bp-28h]@6
   int v33; // [sp+140h] [bp-24h]@2
   int v34; // [sp+144h] [bp-20h]@1
@@ -6021,10 +6006,10 @@
   pSky.dimming_level = 0;//затемнение
   pSky.uNumVertices = 4;//количество вершин
 
-  //tilt(наклон)---------------------------------------------------------------
-  pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);
+  //centering(центруем)---------------------------------------------------------------
+  pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216
   pSky.v_18.y = 0;
-  pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);
+  pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457
   //---------------------------------------------------------------------------
 
   pSky.field_24 = 0x2000000;
@@ -6047,7 +6032,7 @@
   //--------------------------------------------------------------------------
 
   //pParty->sRotationY / 2048.0f
-  // move sky(двидение неба)--------------include-----------------------------
+  // move sky(движение неба)--------------include-----------------------------
     float t = (GetTickCount() % 96000) / 96000.0f;
     array_50AC10[0].u = t - pParty->sRotationY / 1024.0f;
     array_50AC10[0].v = t - pParty->sRotationX / 512.0f;
@@ -6063,21 +6048,21 @@
   //--------------------------------------------------------------------------
 
   //rotate skydome(вращение купола неба)--------------------------------------
-  v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//центр экрана
-  v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);
+  v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//центр экрана 230
+  v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);//214
 
   for (uint i = 0; i < pSky.uNumVertices; ++i)
   {
-    v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);
-    v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;
-    v8 = v39 + pSky.ptr_38->field_C;
-
-    v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;
-    v36 = v39 + pSky.ptr_38->field_18;
-
-    v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;
-    v10 = pSky.v_18.x + v9;
-    v39 = pSky.v_18.x + v9;
+    v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8
+    v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
+    v8 = v39 + pSky.ptr_38->field_C;//0
+
+    v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
+    v36 = v39 + pSky.ptr_38->field_18;//65536
+
+    v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;//27917
+    v10 = pSky.v_18.x + v9;//24701
+    v39 = pSky.v_18.x + v9;//24701
     if ( pSky.v_18.x + v9 > 0 )
     {
       v10 = 0;
@@ -6085,14 +6070,15 @@
     }
     //v11 = (signed __int64)array_50AC10[i].vWorldViewProjX;
     v38 = v10;
-    v12 = array_50AC10[i].vWorldViewProjY - 1.0;
+    //v12 = array_50AC10[i].vWorldViewProjY - 1.0;
     v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
     v34 = -pSky.field_24;
-    v32 = (signed __int64)v12;
+    v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0;
     v14 = v33 * (v30 - v32);
+
     while ( 1 )
     {
-      //v40 = v14;
+      v40 = v14;
       if ( !v10 )
       {
         v37 = pSky.v_18.z;
@@ -6105,13 +6091,12 @@
         break;
       }
       v37 = abs(v34 >> 14);
-      v15 = abs(v10);
-      if ( v37 <= v15 || v32 <= pViewport->uViewportTL_Y )
+      if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y )
       {
         if ( v39 <= 0 )
           break;
       }
-      //v14 = v40;
+      v14 = v40;
       v37 = pSky.v_18.z;
       v16 = (unsigned __int64)(pSky.v_18.z * v14) >> 16;
       --v32;
@@ -6121,24 +6106,25 @@
       v38 = pSky.v_18.x + v16;
       break;
     }
+
     LODWORD(v17) = v34 << 16;
     HIDWORD(v17) = v34 >> 16;
-    v18 = v17 / v38;
-    if ( v18 < 0 )
-      v18 = pOutdoorCamera->shading_dist_mist;
+    pShading = v17 / v38;
+    if ( pShading < 0 )
+      pShading = pOutdoorCamera->shading_dist_mist;
 
     v37 += ((unsigned __int64)(pSky.ptr_38->field_10 * v13) >> 16);
     v36 += ((unsigned __int64)(pSky.ptr_38->field_1C * v13) >> 16);
-    v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, v18) / 8;
-    v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, v18) / 8;
+    v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8;
+    v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, pShading) / 8;
 
     //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
-    //array_50AC10[i].vWorldPosition.x = v36 / (_this.pTexture->uTextureHeight * 65536.0);
+    //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0);
     //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16);
-    //array_50AC10[i].vWorldPosition.z = v35 / (_this.pTexture->uTextureWidth * 65536.0);
+    //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0);
     //array_50AC10[i]._rhw = 1.0f / (v18 >> 16);
-    //array_50AC10[i].u = (double)v35 / (65536.0 * _this.pTexture->uTextureWidth);
-    //array_50AC10[i].v = (double)v36 / (65536.0 * _this.pTexture->uTextureHeight);
+    //array_50AC10[i].u = (double)v35 / (65536.0 * pSky.pTexture->uTextureWidth);
+    //array_50AC10[i].v = (double)v36 / (65536.0 * pSky.pTexture->uTextureHeight);
   //-----------------------------------------------------------------------------------------
 
     array_50AC10[i]._rhw = 1.0f;