changeset 2474:273279353509

Indoor.cpp goto cleaning fixed
author zipi
date Tue, 19 Aug 2014 23:25:45 +0100
parents 98eda972505f
children acac52e9e36a
files Indoor.cpp
diffstat 1 files changed, 236 insertions(+), 220 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Tue Aug 19 22:33:23 2014 +0100
+++ b/Indoor.cpp	Tue Aug 19 23:25:45 2014 +0100
@@ -1898,47 +1898,53 @@
     _a = true;
 
   //v154 = 875;
-  if (_v244)
-  {
-    memset(v203, 0, 0x36B);
-    goto LABEL_132;
-  }
-  if (_a || !dlv.uLastRepawnDay )
+  if (_v244 || (_a || !dlv.uLastRepawnDay))
   {
-    memcpy(v203, pData, 0x36B);
-LABEL_132:
-    free(pRawDLV);
-    dlv.uLastRepawnDay = a3;
-    if (_v244)
-      ++dlv.uNumRespawns;
-    //v201 = pFilename;
-    *(int *)pDest = 1;
-    File = pGames_LOD->FindContainer(pFilename, 0);
-    fread(&header, 0x10u, 1, File);
-    uint v155 = header.uCompressedSize;
-    uint Count = header.uDecompressedSize;
-    BLVFace* Src = (BLVFace *)malloc(header.uDecompressedSize);
-    pRawDLV = Src;
-    if ( v155 <= Count )
-    {
-      if ( v155 == Count )
-        fread(Src, 1, Count, File);
-      else
-      {
-        void* _uSourceLen = malloc(v155);
-        fread(_uSourceLen, v155, 1, File);
-        zlib::MemUnzip(Src, &Count, _uSourceLen, v155);
-        free(_uSourceLen);
-      }
-    }
-    else
-      MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0);
-    pData = ((char *)Src + 40);
-    //v154 = 875;
-    goto LABEL_140;
+	  if (_v244)
+	  {
+		  memset(v203, 0, 0x36B);
+	  }
+	  else if (_a || !dlv.uLastRepawnDay)
+	  {
+		  memcpy(v203, pData, 0x36B);
+	  }
+
+		  free(pRawDLV);
+		  dlv.uLastRepawnDay = a3;
+		  if (_v244)
+			  ++dlv.uNumRespawns;
+		  //v201 = pFilename;
+		  *(int *)pDest = 1;
+		  File = pGames_LOD->FindContainer(pFilename, 0);
+		  fread(&header, 0x10u, 1, File);
+		  uint v155 = header.uCompressedSize;
+		  uint Count = header.uDecompressedSize;
+		  BLVFace* Src = (BLVFace *)malloc(header.uDecompressedSize);
+		  pRawDLV = Src;
+		  if (v155 <= Count)
+		  {
+			  if (v155 == Count)
+				  fread(Src, 1, Count, File);
+			  else
+			  {
+				  void* _uSourceLen = malloc(v155);
+				  fread(_uSourceLen, v155, 1, File);
+				  zlib::MemUnzip(Src, &Count, _uSourceLen, v155);
+				  free(_uSourceLen);
+			  }
+		  }
+		  else
+			  MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0);
+		  pData = ((char *)Src + 40);
+		  //v154 = 875;
   }
-  *(int *)pDest = 0;
-LABEL_140:
+  else
+  {
+	  *(int *)pDest = 0;
+  }
+  
+
+//LABEL_140:
   //v202 = (int)".blv";
   //v156 = strlen(pFilename);
   strcpy(&pFilename[strlen(pFilename) - 4], ".blv");
@@ -2375,9 +2381,8 @@
     a3->y = 0;
     a3->z = 0xFFFF0000u;
 
-    goto LABEL_12;
   }
-  if ( this->uPolygonType == POLYGON_Floor || this->uPolygonType == POLYGON_Ceiling )
+  else if ( this->uPolygonType == POLYGON_Floor || this->uPolygonType == POLYGON_Ceiling )
   {
     a2->x = 0x10000u;
     a2->y = 0;
@@ -2387,9 +2392,8 @@
     a3->y = 0xFFFF0000u;
     a3->z = 0;
 
-    goto LABEL_12;
   }
-  if ( this->uPolygonType == POLYGON_InBetweenFloorAndWall || this->uPolygonType == POLYGON_InBetweenCeilingAndWall )
+  else if ( this->uPolygonType == POLYGON_InBetweenFloorAndWall || this->uPolygonType == POLYGON_InBetweenCeilingAndWall )
   {
     if ( abs(this->pFacePlane_old.vNormal.z) < 46441 )
     {
@@ -2406,19 +2410,20 @@
       a3->z = 0xFFFF0000u;
       a3->x = 0;
 
-      goto LABEL_12;
     }
-    a2->x = 0x10000u;
-    a2->y = 0;
-    a2->z = 0;
-
-    a3->x = 0;
-    a3->y = 0xFFFF0000u;
-    a3->z = 0;
-
-    goto LABEL_12;
+	else
+	{
+		a2->x = 0x10000u;
+		a2->y = 0;
+		a2->z = 0;
+
+		a3->x = 0;
+		a3->y = 0xFFFF0000u;
+		a3->z = 0;
+	}
+
   }
-LABEL_12:
+//LABEL_12:
   if ( this->uAttributes & 0x800000 )
   {
     a2->x = -a2->x;
@@ -2521,8 +2526,10 @@
         door->uState = BLVDoor::Open;
         if ( !(door->uAttributes & 6) && door->uNumVertices != 0)
           pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0);
-        goto LABEL_18;
+        //goto LABEL_18;
       }
+	  else if (!(door->uAttributes & 6) && door->uNumVertices)
+		  pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor, i), 1, -1, 0, 0, 0, 0);
     }
     else
     {
@@ -2533,13 +2540,17 @@
         door->uState = BLVDoor::Closed;
         if ( !(door->uAttributes & 6) && door->uNumVertices != 0)
           pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0);
-        goto LABEL_18;
+        //goto LABEL_18;
       }
-      v89 = door->uMoveLength - v5;
+	  else
+	  {
+		  v89 = door->uMoveLength - v5;
+		  if (!(door->uAttributes & 6) && door->uNumVertices)
+			  pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor, i), 1, -1, 0, 0, 0, 0);
+	  }
     }
-    if ( !(door->uAttributes & 6) && door->uNumVertices)
-      pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0);
-LABEL_18:
+
+//LABEL_18:
     for (uint j = 0; j < door->uNumVertices; ++j)
     {
       pIndoor->pVertices[door->pVertexIDs[j]].x = fixpoint_mul(door->vDirection.x, v89) + door->pXOffsets[j];
@@ -2797,7 +2808,7 @@
        + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y
        + pActors[actor_id].vVelocity.z * pActors[actor_id].vVelocity.z >= 400 )
     {
-      stru_721530.field_84 = -1;
+      stru_721530.field_84 = -1; 
       stru_721530.field_70 = 0;
       stru_721530.field_0 = 1;
       stru_721530.field_8_radius = pActors[actor_id].uActorRadius;
@@ -2869,176 +2880,181 @@
               continue;
             if ( pActors[actor_id].uCurrentActionAnimation != 1 || v33 >= pActors[actor_id].vPosition.z - 100 || v59 || v62 )
             {
-              if ( stru_721530.field_7C >= stru_721530.field_6C )
-              {
-                pActors[actor_id].vPosition.x = LOWORD(stru_721530.normal2.x);
-                pActors[actor_id].vPosition.y = LOWORD(stru_721530.normal2.y);
-                pActors[actor_id].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
-                pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
-                goto LABEL_123;
-              }
-              pActors[actor_id].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
-              pActors[actor_id].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
-              pActors[actor_id].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-              pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
-              stru_721530.field_70 += stru_721530.field_7C;
-              v37 = PID_ID(stru_721530.uFaceID);
-              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
-              {
-                if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->turn_stage == TE_MOVEMENT) )
-                {
-                  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                  v22 = 0;
-                  continue;
-                }
-                if ( pActors[actor_id].pMonsterInfo.uHostilityType )
-                {
-                  if ( !v56 )
-                  {
-                    Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
-                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                    v22 = 0;
-                    continue;
-                  }
-                }
-                else
-                {
-                  if ( !v56 )
-                  {
-                    if ( !pActors[v37].pMonsterInfo.uHostilityType )
-                    {
-                      Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
-                      pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                      pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                      pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                      v22 = 0;
-                      continue;
-                    }
-                    Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
-                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                    v22 = 0;
-                    continue;
-                  }
-                }
-                Actor::AI_StandOrBored(actor_id, 4, v22, &v53);
-                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                v22 = 0;
-                continue;
-              }
-              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Player)
+              if ( stru_721530.field_7C < stru_721530.field_6C )
               {
-                if ( pActors[actor_id].GetActorsRelation(0) )
-                {
-                  //v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22);
-                  //v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22;
-                  //v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0;
-                  pActors[actor_id].vVelocity.y = v22;
-                  pActors[actor_id].vVelocity.x = v22;
-                  if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > v22 )
-                    pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
-                  viewparams->bRedrawGameUI = 1;
-                  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                  v22 = 0;
-                  continue;
-                }
-                Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
-                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                v22 = 0;
-                continue;
-              }
-              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
-              {
-                _this = integer_sqrt(pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y);
-                v45 = stru_5C6E00->Atan2(pActors[actor_id].vPosition.x - pLevelDecorations[v37].vPosition.x,
-                        pActors[actor_id].vPosition.y - pLevelDecorations[v37].vPosition.y);
-                pActors[actor_id].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v45), _this);
-                pActors[actor_id].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v45), _this);
-                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                v22 = 0;
-                continue;
+				  pActors[actor_id].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
+				  pActors[actor_id].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
+				  pActors[actor_id].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
+				  pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
+				  stru_721530.field_70 += stru_721530.field_7C;
+				  v37 = PID_ID(stru_721530.uFaceID);
+				  if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
+				  {
+					  if (pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->turn_stage == TE_MOVEMENT))
+					  {
+						  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+						  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+						  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+						  v22 = 0;
+						  continue;
+					  }
+					  if (pActors[actor_id].pMonsterInfo.uHostilityType)
+					  {
+						  if (!v56)
+						  {
+							  Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+							  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+							  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+							  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+							  v22 = 0;
+							  continue;
+						  }
+					  }
+					  else
+					  {
+						  if (!v56)
+						  {
+							  if (!pActors[v37].pMonsterInfo.uHostilityType)
+							  {
+								  Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+								  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+								  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+								  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+								  v22 = 0;
+								  continue;
+							  }
+							  Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+							  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+							  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+							  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+							  v22 = 0;
+							  continue;
+						  }
+					  }
+					  Actor::AI_StandOrBored(actor_id, 4, v22, &v53);
+					  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+					  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+					  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+					  v22 = 0;
+					  continue;
+				  }
+				  if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Player)
+				  {
+					  if (pActors[actor_id].GetActorsRelation(0))
+					  {
+						  //v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22);
+						  //v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22;
+						  //v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0;
+						  pActors[actor_id].vVelocity.y = v22;
+						  pActors[actor_id].vVelocity.x = v22;
+						  if (pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > v22)
+							  pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
+						  viewparams->bRedrawGameUI = 1;
+						  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+						  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+						  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+						  v22 = 0;
+						  continue;
+					  }
+					  Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+					  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+					  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+					  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+					  v22 = 0;
+					  continue;
+				  }
+				  if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+				  {
+					  _this = integer_sqrt(pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y);
+					  v45 = stru_5C6E00->Atan2(pActors[actor_id].vPosition.x - pLevelDecorations[v37].vPosition.x,
+						  pActors[actor_id].vPosition.y - pLevelDecorations[v37].vPosition.y);
+					  pActors[actor_id].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v45), _this);
+					  pActors[actor_id].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v45), _this);
+					  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+					  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+					  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+					  v22 = 0;
+					  continue;
+				  }
+				  if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
+				  {
+					  stru_721530.field_84 = stru_721530.uFaceID >> 3;
+					  if (pIndoor->pFaces[v37].uPolygonType == 3)
+					  {
+						  pActors[actor_id].vVelocity.z = 0;
+						  pActors[actor_id].vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v37].pVertexIDs].z + 1;
+						  if (pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x
+							  + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y < 400)
+						  {
+							  pActors[actor_id].vVelocity.y = 0;
+							  pActors[actor_id].vVelocity.x = 0;
+							  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+							  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+							  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+							  v22 = 0;
+							  continue;
+						  }
+					  }
+					  else
+					  {
+						  v61 = abs(pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vVelocity.x + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y
+							  * pActors[actor_id].vVelocity.y
+							  + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z
+							  * pActors[actor_id].vVelocity.z) >> 16;
+						  if ((stru_721530.speed >> 3) > v61)
+							  v61 = stru_721530.speed >> 3;
+						  pActors[actor_id].vVelocity.x += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
+						  pActors[actor_id].vVelocity.y += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
+						  pActors[actor_id].vVelocity.z += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
+						  if (pIndoor->pFaces[v37].uPolygonType != 4 && pIndoor->pFaces[v37].uPolygonType != 3)
+						  {
+							  v44 = stru_721530.prolly_normal_d
+								  - ((pIndoor->pFaces[v37].pFacePlane_old.dist
+								  + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z * pActors[actor_id].vPosition.z
+								  + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y * pActors[actor_id].vPosition.y
+								  + pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vPosition.x) >> 16);
+							  if (v44 > 0)
+							  {
+								  pActors[actor_id].vPosition.x += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
+								  pActors[actor_id].vPosition.y += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
+								  pActors[actor_id].vPosition.z += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
+							  }
+							  pActors[actor_id].uYawAngle = stru_5C6E00->Atan2(pActors[actor_id].vVelocity.x, pActors[actor_id].vVelocity.y);
+						  }
+					  }
+					  if (pIndoor->pFaces[v37].uAttributes & 0x8000000)
+						  EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v37].uFaceExtraID].uEventID, 0, 1);
+				  }
+				  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+				  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+				  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+				  v22 = 0;
+				  continue;
               }
-              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
-              {
-                stru_721530.field_84 = stru_721530.uFaceID >> 3;
-                if ( pIndoor->pFaces[v37].uPolygonType == 3 )
-                {
-                  pActors[actor_id].vVelocity.z = 0;
-                  pActors[actor_id].vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v37].pVertexIDs].z + 1;
-                  if ( pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x
-                     + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y < 400 )
-                  {
-                    pActors[actor_id].vVelocity.y = 0;
-                    pActors[actor_id].vVelocity.x = 0;
-                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-                    v22 = 0;
-                    continue;
-                  }
-                }
-                else
-                {
-                  v61 = abs(pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vVelocity.x + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y
-                                                                            * pActors[actor_id].vVelocity.y
-                                                                            + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z
-                                                                            * pActors[actor_id].vVelocity.z) >> 16;
-                  if ( (stru_721530.speed >> 3) > v61 )
-                    v61 = stru_721530.speed >> 3;
-                  pActors[actor_id].vVelocity.x += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
-                  pActors[actor_id].vVelocity.y += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
-                  pActors[actor_id].vVelocity.z += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
-                  if ( pIndoor->pFaces[v37].uPolygonType != 4 && pIndoor->pFaces[v37].uPolygonType != 3 )
-                  {
-                    v44 = stru_721530.prolly_normal_d
-                        - ((pIndoor->pFaces[v37].pFacePlane_old.dist
-                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z * pActors[actor_id].vPosition.z
-                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y * pActors[actor_id].vPosition.y
-                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vPosition.x) >> 16);
-                    if ( v44 > 0 )
-                    {
-                      pActors[actor_id].vPosition.x += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
-                      pActors[actor_id].vPosition.y += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
-                      pActors[actor_id].vPosition.z += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
-                    }
-                    pActors[actor_id].uYawAngle = stru_5C6E00->Atan2(pActors[actor_id].vVelocity.x, pActors[actor_id].vVelocity.y);
-                  }
-                }
-                if ( pIndoor->pFaces[v37].uAttributes & 0x8000000 )
-                  EventProcessor(pIndoor->pFaceExtras[ pIndoor->pFaces[v37].uFaceExtraID].uEventID, 0, 1);
-              }
-              pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
-              pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
-              pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
-              v22 = 0;
-              continue;
+			  else
+			  {
+				  pActors[actor_id].vPosition.x = LOWORD(stru_721530.normal2.x);
+				  pActors[actor_id].vPosition.y = LOWORD(stru_721530.normal2.y);
+				  pActors[actor_id].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
+				  pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
+				  //goto LABEL_123;
+				  break;
+			  }
+
             }
-            if ( pActors[actor_id].vPosition.x & 1 )
+			else if ( pActors[actor_id].vPosition.x & 1 )
               pActors[actor_id].uYawAngle += 100;
             else
               pActors[actor_id].uYawAngle -= 100;
           }
           else
           {
-            if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->turn_stage == TE_MOVEMENT) )
-              goto LABEL_123;
+			if (pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->turn_stage == TE_MOVEMENT))
+				  continue;
             if ( !pActors[actor_id].pMonsterInfo.uHostilityType || v56 != v22 )
             {
               Actor::AI_StandOrBored(actor_id, 4, v22, &v52);
-              goto LABEL_123;
+			  continue;
             }
           }
         }
@@ -3055,7 +3071,7 @@
           pActors[actor_id].uAIState = Removed;
       }
     }
-LABEL_123:
+//LABEL_123:
     ;
   }
 }