diff Events.cpp @ 2268:fd788d2e9585

EventProcessor cleaned and ODM_NearClip fix
author Ritor1
date Sun, 09 Mar 2014 22:39:59 +0600
parents 01489aec3cb0
children 9551756f46c4
line wrap: on
line diff
--- a/Events.cpp	Sat Mar 08 23:53:09 2014 +0600
+++ b/Events.cpp	Sun Mar 09 22:39:59 2014 +0600
@@ -282,7 +282,6 @@
 {
   unsigned int v3; // eax@5
   signed int v4; // esi@7
-  Player *v6; // ecx@8
   int v11; // eax@14
   char *v12; // eax@15
   const char *v16; // esi@21
@@ -307,12 +306,8 @@
   int v37; // esi@62
   int v38; // eax@78
   int v39; // ecx@78
-  size_t v40; // edx@78
-  Actor *v41; // esi@79
   int v42; // eax@84
   int v43; // ecx@84
-  size_t v44; // edx@84
-  Actor *v45; // esi@85
   void *v46; // eax@91
   GUIWindow *v47; // eax@93
   GUIButton *v48; // ecx@93
@@ -347,8 +342,6 @@
   signed int v77; // ebp@186
   int v78; // edx@186
   Player *v79; // esi@187
-  //signed int v80; // ebp@200
-  //int v81; // edx@200
   Player *v82; // esi@201
   int v83; // eax@212
   int v84; // ebp@220
@@ -376,15 +369,11 @@
   int v118; // [sp-4h] [bp-4ACh]@117
   int v121; // [sp-4h] [bp-4ACh]@294
   int curr_seq_num; // [sp+10h] [bp-498h]@4
-  //char *v123; // [sp+14h] [bp-494h]@0
-  signed int v124; // [sp+18h] [bp-490h]@7
-  //signed int v125; // [sp+1Ch] [bp-48Ch]@155
   int v126; // [sp+1Ch] [bp-48Ch]@262
   int player_choose; // [sp+20h] [bp-488h]@4
   int v128; // [sp+24h] [bp-484h]@21
   int v129; // [sp+24h] [bp-484h]@262
   signed int v130; // [sp+28h] [bp-480h]@0
-  //int v131; // [sp+2Ch] [bp-47Ch]@1
   int v132; // [sp+30h] [bp-478h]@262
   signed int v133; // [sp+34h] [bp-474h]@1
   int v134; // [sp+38h] [bp-470h]@262
@@ -398,7 +387,6 @@
   char Str[120]; // [sp+ECh] [bp-3BCh]@21
   Actor Dst; // [sp+164h] [bp-344h]@53
 
-  //v131 = uEventID;
   v133 = 0;
   EvtTargetObj = targetObj;
   dword_5B65C4_cancelEventProcessing = 0;
@@ -410,79 +398,64 @@
     return;
   }	*/
   if ( !uEventID )
-    {
+  {
     if ( !GameUI_Footer_TimeLeft )
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
     return;
-    }
+  }
   player_choose = (uActiveCharacter == 0)?6:4;  //4 - active or  6 - random player if active =0
   curr_seq_num = entry_line;
 
   if ( activeLevelDecoration )
-    {
+  {
     uSomeEVT_NumEvents = uGlobalEVT_NumEvents;
     pSomeEVT = pGlobalEVT.data();
     memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts
-    }
+  }
   else
-    {
+  {
     uSomeEVT_NumEvents = uLevelEVT_NumEvents;
     pSomeEVT = pLevelEVT.data();
     memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400);
-    }
+  }
 
-  v4 = 0;
-  v124 = 0;
-  //for (uint i = 0; i < uSomeEVT_NumEvents; ++i)
-  //  {
-    //v6 = v123;
-    //v7 = "";
-    while ( 1 )
-    {
+  for ( v4 = 0; v4 < uSomeEVT_NumEvents; ++v4 )
+  {
     if ( dword_5B65C4_cancelEventProcessing )
     {
       if ( v133 == 1 )
         OnMapLeave();
       return;
     }
-    //v8 = v4;
     if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num )
       {
-      //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT;
-      //v10 = (ByteArray *)&v5[v9];
       _evt_raw * _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT);
 
       switch (_evt->_e_type)
-        {
+      {
       case EVENT_CheckSeason:
-        //
         if ( !sub_4465DF_check_season(_evt->v5) )
-                {
+        {
           ++curr_seq_num;
-          v4 = v124;
+          //v4 = v124;
           break;
-                }
-        v124 = -1;
+        }
+        v4 = -1;
         curr_seq_num = _evt->v6 - 1;
           ++curr_seq_num;
         break;
       case EVENT_ShowMovie:
-        {
+      {
         strcpy(Source, (char *)&_evt->v7);
         v12 = (char *)&item.uExpireTime + strlen(Source) + 7;
         if ( *v12 == 32 )
           *v12 = 0;
-		if (pVideoPlayer->bBufferLoaded)
+        if (pVideoPlayer->bBufferLoaded)
           pVideoPlayer->Unload();
         pVideoPlayer->bStopBeforeSchedule = 0;
         pVideoPlayer->pResetflag = 0;
 
         v128 = pCurrentScreen;
-        //v13 = &pSomeEVT[v9];
-        //v14 = (unsigned __int8)v13[5];
-        //v15 = (unsigned __int8)v13[6];
-        //v14 = _evt->v5;
-        //v15 = _evt->v6;
         strcpy(Str, Source);
         v16 = RemoveQuotes(Str);
 		pVideoPlayer->MovieLoop(v16, 0, _evt->v5, 1);
@@ -493,66 +466,52 @@
           LOBYTE(v17) = 1;
           SetUserInterface(PartyAlignment_Good, v17);
           if ( !_evt->v6 || v128 == 3 )
-            {
+          {
             pCurrentScreen = v128;
             if ( v128 == 3 )
               pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
             if ( v128 == 13 )
               pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);
-            }
-
+          }
           ++curr_seq_num;
-          v4 = v124;
-
-          //v6 = v123;
-          //v7 = "";
           break;
-          }
+        }
         if ( !_stricmp(v16, "arbiter evil") )
-          {
+        {
           v18 = 2;
           pParty->alignment = PartyAlignment_Evil;
           LOBYTE(v17) = 1;
           SetUserInterface(PartyAlignment_Evil, v17);
           if ( !_evt->v6 || v128 == 3 )
-            {
+          {
             pCurrentScreen = v128;
             if ( v128 == 3 )
               pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
             if ( v128 == 13 )
               pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);
-            }
+          }
           ++curr_seq_num;
-          v4 = v124;
-
-          //v6 = v123;
-          //v7 = "";
-
           break;
-          }
+        }
         if ( !_stricmp(v16, "pcout01") )    // moving to harmondale from emerald isle
-                {
+        {
           Rest(0x2760u);
           pParty->RestAndHeal();
           pParty->days_played_without_rest = 0;
-                }
+        }
         if ( !_evt->v6 || v128 == 3 )
-          {
+        {
           pCurrentScreen = v128;
           if ( v128 == 3 )
             pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
           if ( v128 == 13 )
             pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1);
-          }
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         }
         break;
       case EVENT_CheckSkill:
-        {
+      {
         v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8);
         if ( player_choose < 0 )
           goto LABEL_47;
@@ -581,17 +540,11 @@
                 if ( v20 >= 4 )
                   {
                   ++curr_seq_num;
-                  v4 = v124;
-
-                  //v6 = v123;
-                  //v7 = "";
                   break;
                   }
                 }
-              //v11 = _evt->v11;
               curr_seq_num = _evt->v11 - 1;
               ++curr_seq_num;
-              v4 = v124;
               break;
               }
 LABEL_47:
@@ -607,14 +560,9 @@
           {
               curr_seq_num = _evt->v11 - 1;
               ++curr_seq_num;
-              v4 = v124;
               break;
           }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         }
         break;
 
@@ -630,23 +578,17 @@
         else
           bDialogueUI_InitializeActor_NPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ChangeEvent:
-        //v25 = EVT_DWORD(_evt->v5);
         if ( EVT_DWORD(_evt->v5) )
           stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124;
         else
-          {
+        {
           v26 = (LevelDecoration *)activeLevelDecoration;
           stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0;
           v26->uFlags |= LEVEL_DECORATION_INVISIBLE;
-          }
+        }
         ++curr_seq_num;
-        v4 = v124;
 
         break;
       case EVENT_SetNPCGreeting:
@@ -654,10 +596,6 @@
         pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
         pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
             case EVENT_SetNPCTopic:
             {
@@ -700,79 +638,48 @@
               }
               ++curr_seq_num;
             }
-            v4 = v124;
             break;
       case EVENT_NPCSetItem:
         sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
-
         break;
       case EVENT_SetActorItem:
         Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_SetNPCGroupNews:
         pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_SetActorGroup:
         __debugbreak();
         *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_ChangeGroup:
         v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
         v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
-        v40 = uNumActors;
         __debugbreak();
-        if ( (signed int)uNumActors > 0 )
-          {
-          v41 = pActors.data();//[0].uGroup;
-          do
-            {
-            if ( v41->uGroup == v38 )
-              v41->uGroup = v39;
-            ++v41;
-            --v40;
-            }
-            while ( v40 );
-          }
+        for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ )
+        {
+          if ( pActors[actor_id].uGroup == v38 )
+            pActors[actor_id].uGroup = v39;
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ChangeGroupAlly:
         v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
         v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
-        v44 = uNumActors;
         __debugbreak();
-        if ( (signed int)uNumActors > 0 )
-          {
-          v45 = pActors.data();//[0].uAlly;
-          do
-            {
-            if ( v45->uGroup == v42 )
-              v45->uAlly = v43;
-            ++v45;
-            --v44;
-            }
-            while ( v44 );
-          }
+        for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ )
+        {
+          if ( pActors[actor_id].uGroup == v42 )
+            pActors[actor_id].uAlly = v43;
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_MoveNPC:
         {
-
         pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9);
         if ( window_SpeakInHouse )
           {
@@ -812,9 +719,7 @@
           }
 
         }
-                ++curr_seq_num;
-        v4 = v124;
-
+        ++curr_seq_num;
         break;
       case EVENT_Jmp:
         curr_seq_num = _evt->v5 - 1;
@@ -835,26 +740,22 @@
         else  //random player
           pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
           ++curr_seq_num;
-          v4 = v124;
           break;
       case EVENT_CharacterAnimation:
-        if ( _evt->v5 <= 3u ) //someone
+        if ( _evt->v5 <= 3 ) //someone
           pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0);
         else if ( _evt->v5 == 4 ) //active
           pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0);
         else if ( _evt->v5 == 5 ) //all
-          for(int i=0; i<4; ++i)
+          for(int i = 0; i < 4; ++i)
             pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0);
         else  //random
           pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0);
         ++curr_seq_num;
-        v4 = v124;
-
         break;
       case EVENT_ForPartyMember:
         player_choose = _evt->v5;
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_SummonItem:
         sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
@@ -864,10 +765,6 @@
           _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8),
           _evt->v25, _evt->v26, 0, 0);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_Compare:
         pValue = EVT_DWORD(_evt->v7);
@@ -875,7 +772,7 @@
         {
           if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
           {
-            v124 = -1;
+           // v124 = -1;
             curr_seq_num = _evt->v11 - 1;
           }
         }
@@ -885,7 +782,7 @@
           {
             if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
             {
-              v124 = -1;
+             // v124 = -1;
               curr_seq_num = _evt->v11 - 1;
             }
           }
@@ -897,7 +794,7 @@
           {
             if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
             {
-              v124 = -1;
+             // v124 = -1;
               curr_seq_num = _evt->v11 - 1;
               break;
             }
@@ -908,21 +805,21 @@
         {
           if ( pPlayers[rand() % 4 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
           {
-            v124 = -1;
+           // v124 = -1;
             curr_seq_num = _evt->v11 - 1;
           }
         }
         ++curr_seq_num;
-        v4 = v124;
+        v4 = -1;
         break;
       case EVENT_IsActorAlive:
          if  (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10)))
-           {
-           v124 = -1;
+         {
+           //v124 = -1;
            curr_seq_num = _evt->v11 - 1;
-           }
+         }
          ++curr_seq_num;
-         v4 = v124;
+         v4 = -1;
          break;
       case EVENT_Substract:
         pValue = EVT_DWORD(_evt->v7);
@@ -1010,7 +907,6 @@
         else if ( player_choose == 6 ) //random
           pParty->pPlayers[rand() % 4].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_Set:
         pValue = EVT_DWORD(_evt->v7);
@@ -1023,14 +919,13 @@
         }
         else if ( player_choose == 5 )//all
         {
-                  //recheck v130
+          //recheck v130
           for ( int i = 1; i < 5; ++i )
             pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
         }
         else if ( player_choose == 6 ) //random
           pParty->pPlayers[rand() % 4].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_Add:
         pValue = EVT_DWORD(_evt->v7);
@@ -1059,34 +954,25 @@
           viewparams->bRedrawGameUI = true;
         }
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_InputString:
         if ( !entry_line )
-          {
+        {
           strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]);
-          //v105 = curr_seq_num;
-          //v121 = 26;
           sub_4451A8_press_any_key(uEventID, curr_seq_num, 26);
           if ( v133 == 1 )
             OnMapLeave();
           return;
-          }
+        }
         v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
         if ( !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]])
           || !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[v84]]) )
-          {
+        {
           v11 = _evt->v17;
-//LABEL_130:
-          //v124 = -1;
-//LABEL_131:
           curr_seq_num = v11 - 1;
-          }
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
+        v4 = -1;
         break;
       case EVENT_RandomGoTo:
         //v124 = -1;
@@ -1094,105 +980,65 @@
           + (_evt->v10 != 0)));
                 curr_seq_num = v11 - 1;
                 ++curr_seq_num;
-                v4 = v124;
+                v4 = -1;
                 break;
       case EVENT_ReceiveDamage:
         if ( (unsigned __int8)_evt->v5 <= 3 )
-          {
-          //v119 = _evt->v6;
-          //v115 = EVT_DWORD(_evt->v7 );
+        {
           pParty->pPlayers[(unsigned __int8)_evt->v5].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6);
           ++curr_seq_num;
-          v4 = v124;
           break;
-          }
+        }
         if ( _evt->v5 == 4 )
-          {
+        {
           if ( !uActiveCharacter )
-            {
+          {
             ++curr_seq_num;
-            v4 = v124;
-
-            //v6 = v123;
-            //v7 = "";
             break;
-            }
+          }
           pPlayers[uActiveCharacter]->ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6);
           ++curr_seq_num;
-          v4 = v124;
           break;
-          }
+        }
         if ( _evt->v5 != 5 )
-          {
+        {
           pParty->pPlayers[rand() % 4].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6);
           ++curr_seq_num;
-          v4 = v124;
-
-          //v6 = v123;
-          //v7 = "";
           break;
-          }
+        }
         for ( uint pl_id = 0;pl_id < 4; pl_id++ )
           pParty->pPlayers[pl_id].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6);
           ++curr_seq_num;
-          v4 = v124;
-
-          //v6 = v123;
-          //v7 = "";
           break;
       case EVENT_ToggleIndoorLight:
         pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_SetFacesBit:
         sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ToggleChestFlag:
         Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ToggleActorFlag:
         Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ToggleActorGroupFlag:
         ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ),  EVT_DWORD(_evt->v9 ), _evt->v13);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_SetSnow:
         if ( !_evt->v5 )
           pWeather->bRenderSnow = _evt->v6 != 0;
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_StatusText:
         v90 = EVT_DWORD(_evt->v5 );
         if ( activeLevelDecoration )
-          {
+        {
           if ( activeLevelDecoration == (LevelDecoration*)1 )
             current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
           if ( canShowMessages == 1 )
@@ -1201,96 +1047,64 @@
             //LABEL_248:
             ShowStatusBarString(v91, 2);
             }
-          }
+        }
         else
+        {
+          if ( canShowMessages == 1 )
           {
-          if ( canShowMessages == 1 )
-            {
             v91 = &pLevelStr[pLevelStrOffsets[v90]];
-            ShowStatusBarString(v91, 2u);
-            }
+            ShowStatusBarString(v91, 2);
           }
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ShowMessage:
-        //v92 = EVT_DWORD(_evt->v5 );
         if ( activeLevelDecoration )
-          {
+        {
           current_npc_text = pNPCTopics[EVT_DWORD(_evt->v5 )-1].pText;//(&dword_721664)[8 * v92];
           byte_5B0938[0] = 0;
-          //current_npc_text = v93;
-          }
+        }
         else
           strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_CastSpell:
               EventCastSpell(_evt->v5, _evt->v6, _evt->v7, EVT_DWORD(_evt->v8 ),
                     EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ),
                     EVT_DWORD(_evt->v24 ), EVT_DWORD(_evt->v28 ));
               ++curr_seq_num;
-              v4 = v124;
               break;
       case EVENT_SetTexture:
         sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_SetSprite:
         SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10);
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_SummonMonsters:
         sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ),
                     EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ),
                     EVT_DWORD(_evt->v24 ));
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_MouseOver:
       case EVENT_LocationName:
         --curr_seq_num;
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_ChangeDoorState:
         Door_switch_animation(_evt->v5, _evt->v6);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_OpenChest:
         if ( !Chest::Open(_evt->v5) )
-		{
+        {
           if ( v133 == 1 )
             OnMapLeave();
           return;
-		}
+        }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_MoveToMap:
         v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
@@ -1318,10 +1132,10 @@
         if ( v129 == -1 )
           v98 = _5B65B4_npcdata_loword_house_or_other;
         else
-          {
+        {
           v98 = v129 & stru_5C6E00->uDoublePiMask;
           _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask;
-          }
+        }
         v99 = (char *)&_evt->v31;
         _5B65B8_npcdata_hiword_house_or_other = v95;
         dword_5B65BC = v97;
@@ -1381,10 +1195,6 @@
             }
           }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_PlaySound:
         v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
@@ -1392,20 +1202,15 @@
         v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
         pAudioPlayer->PlaySound((SoundID)v106, 0, 0, v109, v110, 0, 0, 0);
         ++curr_seq_num;
-        v4 = v124;
         break;
       case EVENT_GiveItem:
         item.Reset();
-        //v101 = &pSomeEVT[v9];
         v102 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
         pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item);
         if ( v102 )
           item.uItemID = v102;
         pParty->SetHoldingItem(&item);
         ++curr_seq_num;
-        v4 = v124;
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_SpeakInHouse:
         if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5)))
@@ -1424,14 +1229,8 @@
           window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, '\t', "", 0);
           }
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_PressAnyKey:
-        //v121 = 33;
-        //v105 = curr_seq_num + 1;
         sub_4451A8_press_any_key(uEventID, curr_seq_num + 1, 33);
         if ( v133 == 1 )
           OnMapLeave();
@@ -1442,22 +1241,13 @@
         return;
       default:
         ++curr_seq_num;
-        v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
         }
       }
-    ++v4;
-    v124 = v4;
-    if ( v4 >= uSomeEVT_NumEvents )
-    {
-      if ( v133 == 1 )
-        OnMapLeave();
-      return;
     }
-    }
+    if ( v133 == 1 )
+      OnMapLeave();
+    return;
   }
 
 //----- (00444732) --------------------------------------------------------
@@ -1480,8 +1270,8 @@
     {
       if ( pLevelEVT_Index[event_index].uEventID == uEventID )
       {
-    test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT];
-    last_evt=test_evt;
+        test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT];
+        last_evt=test_evt;
         event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT;
         if ( test_evt->_e_type == EVENT_MouseOver )
           break;
@@ -1490,7 +1280,7 @@
       if ( event_index >= uLevelEVT_NumEvents )
        return NULL;
     }
-  test_evt=(_evt_raw*)&pLevelEVT[event_pos];
+    test_evt=(_evt_raw*)&pLevelEVT[event_pos];
     if ( test_evt->_e_type== EVENT_SpeakInHouse )
     {
       str_index = EVT_DWORD(test_evt->v5);
@@ -1498,10 +1288,10 @@
     }
     else
     {
-      for ( i = event_index+1; pLevelEVT_Index[i].uEventID  == uEventID; ++i )
+      for ( i = event_index + 1; pLevelEVT_Index[i].uEventID  == uEventID; ++i )
       {
         event_pos = pLevelEVT_Index[i].uEventOffsetInEVT;
-    test_evt=(_evt_raw*)&pLevelEVT[event_pos];
+        test_evt=(_evt_raw*)&pLevelEVT[event_pos];
         if ( test_evt->_e_type == EVENT_SpeakInHouse )
         {
           str_index = EVT_DWORD(test_evt->v5);