diff Indoor.cpp @ 2211:b4bb8296ecfa

Слияние
author Ritor1
date Wed, 12 Feb 2014 20:51:37 +0600
parents 0b2eea6f80c9
children e9625ad08541
line wrap: on
line diff
--- a/Indoor.cpp	Wed Feb 12 20:51:31 2014 +0600
+++ b/Indoor.cpp	Wed Feb 12 20:51:37 2014 +0600
@@ -3472,13 +3472,9 @@
           if ( v55 >= 50 )
             break;
           if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling )
-          {
             v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z;
-          }
           else
-          {
             v21 = fixpoint_mul(pFloor->zCalc1, x) + fixpoint_mul(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16);
-          }
           blv_floor_level[v55] = v21;
           blv_floor_id[v55] = pSector->pFloors[i];
           v55++;
@@ -3486,7 +3482,6 @@
     }
   }
 
-
   if ( pSector->field_0 & 8 )
   {
     for (uint i = 0; i < pSector->uNumPortals; ++i)
@@ -3551,6 +3546,8 @@
   if ( v55 == 1 )
   {
     *pFaceID = blv_floor_id[0];
+	if ( blv_floor_level[0] <= -29000 )
+		__debugbreak();
     return blv_floor_level[0];
   }
   if ( !v55 )
@@ -3585,12 +3582,16 @@
         if ( v38 > result && v38 <= z + 5 )
         {
           result = blv_floor_level[i];
+	if ( blv_floor_level[i] <= -29000 )
+		__debugbreak();
           *pFaceID = blv_floor_id[i];
         }
       }
       else if ( v38 < result )
       {
         result = blv_floor_level[i];
+	if ( blv_floor_level[i] <= -29000 )
+		__debugbreak();
         *pFaceID = blv_floor_id[i];
       }
   }
@@ -5981,7 +5982,7 @@
   int v80; // [sp+34h] [bp-2Ch]@1
   int v82; // [sp+3Ch] [bp-24h]@47
   int _view_angle; // [sp+40h] [bp-20h]@47
-  bool bJumping; // [sp+44h] [bp-1Ch]@1
+  bool hovering; // [sp+44h] [bp-1Ch]@1
   int new_party_y; // [sp+48h] [bp-18h]@1
   int new_party_x; // [sp+4Ch] [bp-14h]@1
   int party_z; // [sp+50h] [bp-10h]@1
@@ -5997,12 +5998,12 @@
   uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   party_running_flag = false;
   party_walking_flag = false;
-  bJumping = false;
+  hovering = false;
 
   uFaceID = -1;
-  int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
-
-  if ( pParty->bFlying )
+  int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);//  
+
+  if ( pParty->bFlying )// 
   {
     pParty->bFlying = false;
     if (pParty->FlyActive())
@@ -6043,8 +6044,8 @@
     }
   }
 
-  uint fall_start;
-  if (!pParty->FeatherFallActive())
+  int fall_start;
+  if (!pParty->FeatherFallActive())//    
   {
     bFeatherFall = false;
     if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&  // grants feather fall
@@ -6055,7 +6056,7 @@
       fall_start = pParty->uFallStartY;
     }
   }
-  else
+  else//   
   {
     fall_start = floor_level;
     bFeatherFall = true;
@@ -6063,7 +6064,7 @@
   }
 
 
-  if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1)
+  if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1)//    
   {
     assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor?
     if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
@@ -6080,40 +6081,39 @@
   }
 
   if ( party_z > floor_level + 1 )
-    bJumping = true;
-
-  bool jumping_up = false;
+    hovering = true;
+
+  bool not_high_fall = false;
 
   if ( party_z - floor_level <= 32 )
   {
     pParty->uFallStartY = party_z;
-    jumping_up = true;
+    not_high_fall = true;
   }
 
-  if (bWalkSound && pParty->walk_sound_timer)
+  if (bWalkSound && pParty->walk_sound_timer)//   
   {
     if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed)
       pParty->walk_sound_timer -= pEventTimer->uTimeElapsed;
     else pParty->walk_sound_timer = 0;
   }
 
-
-  if (party_z <= floor_level + 1)
+  if (party_z <= floor_level + 1)//    
   {
     party_z = floor_level + 1;
     pParty->uFallStartY = floor_level + 1;
 
-    if (!bJumping && pParty->floor_face_pid != uFaceID)
+    if (!hovering && pParty->floor_face_pid != uFaceID)//    
     {
       if (pIndoor->pFaces[uFaceID].uAttributes & FACE_PRESSURE_PLATE)
         uFaceEvent = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].uFaceExtraID].uEventID;
     }
   }
-  if (!bJumping)
+  if (!hovering)
     pParty->floor_face_pid = uFaceID;
 
   bool on_water = false;
-  if ( pIndoor->pFaces[uFaceID].Fluid())
+  if ( pIndoor->pFaces[uFaceID].Fluid())//  
     on_water = true;
 
   //v81 = pParty->uWalkSpeed;
@@ -6172,7 +6172,7 @@
         v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier);
         party_walking_flag = true;
         break;
-      case PARTY_RunForward:
+      case PARTY_RunForward:// 
         v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
         v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier);
         party_running_flag = true;
@@ -6204,9 +6204,9 @@
         _view_angle = 0;
         break;
       case PARTY_Jump:
-        if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 )
+        if ( (!hovering || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 )
         {
-          bJumping = true;
+          hovering = true;
           pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
         }
         break;
@@ -6216,17 +6216,16 @@
   }
   pParty->sRotationY = angle;
   pParty->sRotationX = _view_angle;
-  if ( bJumping )
+  if ( hovering )//
   {
-    pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
-    if ( bJumping && pParty->uFallSpeed <= 0 )
+    pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();//   
+    if ( hovering && pParty->uFallSpeed <= 0 )
     {
       if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
       {
         for ( uint pl = 1; pl <= 4; pl++ )
         {
-          if ( !pPlayers[pl]->HasEnchantedItemEquipped(72)
-            && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
+          if ( !pPlayers[pl]->HasEnchantedItemEquipped(72) && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
              pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
         }
       }
@@ -6234,9 +6233,9 @@
     else
       pParty->uFallStartY = party_z;
   }
-  else
+  else//  
   {
-    if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 )
+    if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 0x8000 )
     {
       pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
       pParty->uFallStartY = party_z;
@@ -6284,10 +6283,10 @@
     for ( uint j = 0; j < 100; ++j )
     {
       _46E44E_collide_against_faces_and_portals(1);
-      _46E0B2_collide_against_decorations();
+      _46E0B2_collide_against_decorations();//  
       for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
-        Actor::_46DF1A_collide_against_actor(v80, 0);
-      if ( _46F04E_collide_against_portals() )
+        Actor::_46DF1A_collide_against_actor(v80, 0);//  
+      if ( _46F04E_collide_against_portals() )//  
         break;
     }
     if ( stru_721530.field_7C >= stru_721530.field_6C )
@@ -6305,7 +6304,7 @@
     v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
     if ( v42 == -30000 || v42 - new_party_z > 128 )
       return;
-    if ( stru_721530.field_7C >= stru_721530.field_6C )
+    if ( stru_721530.field_7C >= stru_721530.field_6C )//???
     {
       new_party_x = stru_721530.normal2.x;
       new_party_y = stru_721530.normal2.y;
@@ -6317,24 +6316,23 @@
     uSectorID = stru_721530.uSectorID;
     stru_721530.field_70 += stru_721530.field_7C;
     unsigned long long v87 = new_party_z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
+    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)//   
     {
-      if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0
-        && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
+      if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 )
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
       viewparams->bRedrawGameUI = true;
     }
-    else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+    else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)//   
     {
       v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
               new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
       v2 = fixpoint_mul(stru_5C6E00->Cos(v54), integer_sqrt(v2 * v2 + v1 * v1));
       v1 = fixpoint_mul(stru_5C6E00->Sin(v54), integer_sqrt(v2 * v2 + v1 * v1));
     }
-    else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
+    else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)//   bmodel
     {
       pFace = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
-      if ( pFace->uPolygonType == POLYGON_Floor )
+      if ( pFace->uPolygonType == POLYGON_Floor )//  bmodel - 
       {
         if ( pParty->uFallSpeed < 0 )
           pParty->uFallSpeed = 0;
@@ -6349,10 +6347,10 @@
         if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() )
           uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
       }
-      else
+      else//   
       {
         v46 = pParty->uFallSpeed * pFace->pFacePlane_old.vNormal.z;
-        if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall )
+        if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall )//  
         {
           v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16;
           if ((stru_721530.speed >> 3) > v80 )
@@ -6402,13 +6400,13 @@
   }
 
   //  //  /-------------------------
-  uint pX_ = pParty->vPosition.x - new_party_x;
-  uint pY_ = pParty->vPosition.y - new_party_y;
-  uint pZ_ = pParty->vPosition.z - new_party_z;
+  uint pX_ = abs(pParty->vPosition.x - new_party_x);
+  uint pY_ = abs(pParty->vPosition.y - new_party_y);
+  uint pZ_ = abs(pParty->vPosition.z - new_party_z);
   if ( bWalkSound && pParty->walk_sound_timer <= 0 )
   {
     pAudioPlayer->_4AA258(804);//stop sound
-    if ( party_running_flag && (!bJumping || jumping_up) ) // 
+    if ( party_running_flag && (!hovering || not_high_fall) ) //  (      )
     {
       if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 )
       {
@@ -6418,10 +6416,10 @@
           pAudioPlayer->PlaySound((SoundID)50, 804, 1, -1, 0, 0, 0, 0);
         else
           pAudioPlayer->PlaySound(SOUND_RunAlong3DModel, 804, 1, -1, 0, 0, 0, 0);
-        pParty->walk_sound_timer = 64;
+        pParty->walk_sound_timer = 96;//64
       }
     }
-    else if ( party_walking_flag && (!bJumping || jumping_up) )// 
+    else if ( party_walking_flag && (!hovering || not_high_fall) )//  (     )
     {
       if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 )
       {
@@ -6431,14 +6429,14 @@
           pAudioPlayer->PlaySound((SoundID)89, 804, 1, -1, 0, 0, 0, 0);
         else
           pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0);
-        pParty->walk_sound_timer = 64;
+        pParty->walk_sound_timer = 144;//64
       }
     }
   }
   if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )//     
     pAudioPlayer->_4AA258(804);
   //-------------------------------------------------------------
-  if ( !bJumping || jumping_up )
+  if ( !hovering || !not_high_fall )
     pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
   else
     pParty->uFlags |= PARTY_FLAGS_1_FALLING;
@@ -6447,7 +6445,7 @@
   pParty->vPosition.z = new_party_z;
   pParty->vPosition.y = new_party_y;
   //pParty->uFallSpeed = v89;
-  if ( !bJumping && pIndoor->pFaces[uFaceID].uAttributes & FACE_UNKNOW5 )
+  if ( !hovering && pIndoor->pFaces[uFaceID].uAttributes & FACE_UNKNOW5 )
     pParty->uFlags |= 0x200;
   if (uFaceEvent)
     EventProcessor(uFaceEvent, 0, 1);