changeset 4:8e33efd39355

15.01.13(work)
author Ritor1
date Tue, 15 Jan 2013 17:44:23 +0600
parents bf31c505f4d3
children bf019a7475f3 ce7216c79fd8
files AIL.cpp AudioPlayer.cpp GUIWindow.h Game.cpp GameUIs.cpp MM7.sdf MM7.sln Render.cpp SaveLoad.cpp VideoPlayer.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp
diffstat 13 files changed, 800 insertions(+), 419 deletions(-) [+]
line wrap: on
line diff
--- a/AIL.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/AIL.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -153,7 +153,7 @@
 }
 
 // sub_4D834C: using guessed type int __stdcall AIL_waveOutOpen(_DWORD, _DWORD, _DWORD, _DWORD);
-int __stdcall AIL_waveOutOpen(HDIGDRIVER *drv, HWAVEOUT *phWaveOut, int wDeviceID, WAVEFORMAT *pFormat)
+int __stdcall AIL_waveOutOpen(_DIG_DRIVER **drv, HWAVEOUT *phWaveOut, int wDeviceID, WAVEFORMAT *pFormat)
 {
  return (mss32_AIL_waveOutOpen)(drv, phWaveOut, wDeviceID, pFormat);
 }
--- a/AudioPlayer.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/AudioPlayer.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -2091,73 +2091,73 @@
 // 4ABC9B: inconsistent function type and number of purged bytes
 
 //----- (004ABD5B) --------------------------------------------------------
-void AudioPlayer::Release()
+void AudioPlayer::Release() //Освободить
 {
-  AudioPlayer *v1; // esi@1
+  AudioPlayer *pAudioPlayer; // esi@1
   int v2; // edi@1
-  MixerChannel *v3; // ebx@3
+  MixerChannel *pMixerChannel; // ebx@3
   char v4; // dl@5
   int v5; // ebx@6
-  AudioPlayer_3DSample *v6; // edi@7
+  AudioPlayer_3DSample *p3DSample; // edi@7
   int v7; // edx@14
   int v8; // ecx@14
   void *v9; // ecx@15
 
-  v1 = this;
+  pAudioPlayer = this;
   v2 = 0;
   if ( this->bPlayerReady )
   {
     CloseHandle(pVideoPlayer->hMagicVid);
     CloseHandle(pVideoPlayer->hMightVid);
-    v1->StopChannels(-1, -1);
-    if ( v1->uMixerChannels > 0 )
+    pAudioPlayer->StopChannels(-1, -1);
+    if ( pAudioPlayer->uMixerChannels > 0 )
     {
-      v3 = v1->pMixerChannels;
+      pMixerChannel = pAudioPlayer->pMixerChannels;
       do
       {
-        AIL_release_sample_handle(v3->hSample);
+        AIL_release_sample_handle(pMixerChannel->hSample);
         ++v2;
-        ++v3;
+        ++pMixerChannel;
       }
-      while ( v2 < v1->uMixerChannels );
+      while ( v2 < pAudioPlayer->uMixerChannels );
     }
     if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
     {
       v5 = 0;
-      v1->CheckA3DSupport(v4);
-      if ( v1->uNum3DSamples > 0 )
+      pAudioPlayer->CheckA3DSupport(v4);
+      if ( pAudioPlayer->uNum3DSamples > 0 )
       {
-        v6 = v1->p3DSamples;
+        p3DSample = pAudioPlayer->p3DSamples;
         do
         {
-          if ( v6->hSample )
+          if ( p3DSample->hSample )
           {
-            AIL_release_3D_sample_handle(v6->hSample);
-            v6->hSample = 0;
+            AIL_release_3D_sample_handle(p3DSample->hSample);
+            p3DSample->hSample = 0;
           }
           ++v5;
-          ++v6;
+          ++p3DSample;
         }
-        while ( v5 < v1->uNum3DSamples );
+        while ( v5 < pAudioPlayer->uNum3DSamples );
       }
-      if ( v1->h3DSoundProvider )
+      if ( pAudioPlayer->h3DSoundProvider )
       {
-        AIL_close_3D_provider(v1->h3DSoundProvider);
-        v1->h3DSoundProvider = 0;
+        AIL_close_3D_provider(pAudioPlayer->h3DSoundProvider);
+        pAudioPlayer->h3DSoundProvider = 0;
       }
     }
-    if ( v1->hAILRedbook )
+    if ( pAudioPlayer->hAILRedbook )
     {
-      AIL_redbook_stop(v1->hAILRedbook);
+      AIL_redbook_stop(pAudioPlayer->hAILRedbook);
       AIL_redbook_set_volume((HREDBOOK)v8, v7);
-      AIL_redbook_close(v1->hAILRedbook);
+      AIL_redbook_close(pAudioPlayer->hAILRedbook);
     }
     AIL_shutdown();
     pSoundList->Release();
-    v9 = *(void **)&v1->field_C78[0];
+    v9 = *(void **)&pAudioPlayer->field_C78[0];
     if ( v9 )
       ReleaseSoundData(v9);
-    CloseHandle(v1->hAudioSnd);
+    CloseHandle(pAudioPlayer->hAudioSnd);
   }
 }
 
--- a/GUIWindow.h	Sun Jan 13 17:41:47 2013 +0600
+++ b/GUIWindow.h	Tue Jan 15 17:44:23 2013 +0600
@@ -51,6 +51,8 @@
   WINDOW_FinalWindow = 0x46,
   WINDOW_5A = 0x5A,
   WINDOW_5E = 0x5E,
+  WINDOW_5F = 0x5F,
+  WINDOW_60 = 0x60,
   WINDOW_KeyMappingOptions = 0x69,
   WINDOW_VideoOptions = 0x6A
 };
--- a/Game.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/Game.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -243,7 +243,7 @@
     dword_6BE364_game_settings_1 |= 0x80;
     dword_6BE340 = 2;
     // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
-	pCurrentScreen = 0;
+    pCurrentScreen = 0;
     if (pAsyncMouse)
       pAsyncMouse->Resume();
     if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard )
@@ -324,10 +324,10 @@
       //pAudioPlayer->_4AAFCF();Ritor1: it's temporarily
       if (uGameState == 1)
         //goto LABEL_96;
-	  {
-		bLoadinga = 1;
+      {
+        bLoadinga = 1;
         continue;
-	  }
+      }
       if (uGameState == 2)
       {
         pAudioPlayer->StopChannels(-1, -1);
@@ -337,8 +337,10 @@
       }
       if ( (signed int)uGameState <= 2 )
         //goto LABEL_85;
-		pGame->Draw();
+      {
+        pGame->Draw();
         continue;
+      }
       if ( (signed int)uGameState <= 5 || uGameState == 7 )
       {
 //LABEL_96:
@@ -357,10 +359,10 @@
         GUI_UpdateWindows();
         pRenderer->EndScene();
         //goto LABEL_89;
-		pRenderer->Present();
+        pRenderer->Present();
         continue;
       }
-      pAudioPlayer->StopChannels(-1, -1);
+      pAudioPlayer->StopChannels(-1, -1);//далее в случае смерти группы
       memset(pParty->pHirelings, 0, 0x4Cu);
       memset(&pParty->pHirelings[1], 0, 0x4Cu);
       pNewNPCsCount = 0;
--- a/GameUIs.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/GameUIs.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -99,7 +99,7 @@
       fread(&pSavegameHeader[i], 0x64, 1, v4);
     if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
       strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave"
-	v5 = pLODFile.FindContainer("image.pcx", true);
+    v5 = pLODFile.FindContainer("image.pcx", true);
     if ( !v5 )
     {
       pSavegameUsedSlots[i] = 0;
@@ -273,5 +273,4 @@
   pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "",
          (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
   v12 = -1;
-  //pBtnDownArrow = v7;
 }
\ No newline at end of file
Binary file MM7.sdf has changed
--- a/MM7.sln	Sun Jan 13 17:41:47 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-п»ї
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MM7", "MM7.vcxproj", "{4CB238C2-3039-4BF6-966A-1ED1285BE23B}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{4CB238C2-3039-4BF6-966A-1ED1285BE23B}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4CB238C2-3039-4BF6-966A-1ED1285BE23B}.Debug|Win32.Build.0 = Debug|Win32
-		{4CB238C2-3039-4BF6-966A-1ED1285BE23B}.Release|Win32.ActiveCfg = Release|Win32
-		{4CB238C2-3039-4BF6-966A-1ED1285BE23B}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
--- a/Render.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/Render.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -1840,7 +1840,7 @@
       v6 = abs(v83);//v6 = 13108
       --X;
       v93 = &stru_76E5C8[(v5 << 7) + v6];
- 	  if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
+      if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
                                                                        v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
              ((a8 = v9,
                pVertices = &pVerticesSR_801A10[1] + v7,
@@ -1895,7 +1895,11 @@
           return;
         ++pOutdoorCamera->numStru148s;
         if ( !sub_481FC9(v8, a8, v101, v16) )
-          goto LABEL_126;
+          //goto LABEL_126;
+          {
+           --pOutdoorCamera->numStru148s;
+           goto LABEL_162;
+          }
         v28 = 1.0 / (a2->vWorldViewPosition.x + 0.0000001);
         memcpy(array_50AC10, a2, 0x30u);
         array_50AC10[0].flt_20 = v28;
@@ -2004,7 +2008,7 @@
           v78 = pBitmaps_LOD->pHardwareTextures[v39];
           v77 = v16;
           v76 = v16->uNumVertices;
-LABEL_161:
+//LABEL_161:
           pRenderer->DrawTerrainPolygon(v76, v77, v78, v79, v80);
           goto LABEL_162;
         }
@@ -2050,7 +2054,11 @@
       return;
     ++pOutdoorCamera->numStru148s;
     if ( !sub_481FC9(a8, pVertices, v8, v40) )
-      goto LABEL_77;
+      //goto LABEL_77;
+      {
+        --pOutdoorCamera->numStru148s;
+        goto LABEL_112;
+      }
     v51 = 1.0 / (a2->vWorldViewPosition.x + 0.0000001);
     memcpy(array_50AC10, a2, 0x30u);
     array_50AC10[0].flt_20 = v51;
@@ -2085,7 +2093,7 @@
       thisb = pGame->pIndoorCameraD3D;
       if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices )
       {
-LABEL_77:
+//LABEL_77:
         --pOutdoorCamera->numStru148s;
         goto LABEL_112;
       }
@@ -2188,7 +2196,7 @@
     ++pOutdoorCamera->numStru148s;
     if ( !sub_481FC9(v101, a2, pVertices, v59) )
     {
-LABEL_126:
+//LABEL_126:
       --pOutdoorCamera->numStru148s;
       goto LABEL_162;
     }
@@ -2225,7 +2233,11 @@
     {
       thisc = pGame->pIndoorCameraD3D;
       if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
-        goto LABEL_126;
+        //goto LABEL_126;
+        {
+         --pOutdoorCamera->numStru148s;
+         goto LABEL_162;
+        }
       thisc->ViewTransform(array_50AC10, v100);
       thisc->Project(array_50AC10, v100, 0);
     }
@@ -2244,15 +2256,7 @@
         v70 = v108 != 0 ? 5 : 0;
       static_sub_0048034E_stru_76D578._49B0C9(v99, v87);
       if ( pDecalBuilder->uNumDecals > 0 )
-        pDecalBuilder->ApplyDecals(
-          31 - v40->field_58,
-          4,
-          &static_sub_0048034E_stru_76D578,
-          v100,
-          array_50AC10,
-          0,
-          v70,
-          -1);
+        pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1);
     }
     if ( stru_F8AD28.uNumLightsApplied > 0 )
       v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
@@ -2288,7 +2292,11 @@
           v78 = pBitmaps_LOD->pHardwareTextures[v75];
           v77 = (stru148 *)v71;
           v76 = LODWORD(v71->vWorldViewPosition.z);
-          goto LABEL_161;
+          //goto LABEL_161;
+          {
+           pRenderer->DrawTerrainPolygon(v76, v77, v78, v79, v80);
+           goto LABEL_162;
+          }
         }
         v38 = (stru148 *)v71;
         goto LABEL_56;
--- a/SaveLoad.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/SaveLoad.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -670,11 +670,11 @@
 void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
     memset(pSavegameList, 0, 0x3138);
-	uNumSavegameFiles = 0;
+    uNumSavegameFiles = 0;
 
   _chdir("saves");
   {
-    if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 )
+    if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7
       strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]);
 
     for (uint i = 0; i < 40; ++i)
--- a/VideoPlayer.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/VideoPlayer.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -409,7 +409,7 @@
               TranslateMessage(&Msg);
               DispatchMessageW(&Msg);
             }
-            GUI_MainMenuMessageProc();// проверка внешних сообщений
+            GUI_MainMenuMessageProc();
             if ( !pVideoPlayer->pSmackerMovie )
               break;
             if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule )
--- a/mm7_2.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/mm7_2.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -13957,7 +13957,8 @@
   Rect.right = *(int *)(v8 + 8);
   Rect.bottom = *(int *)(v8 + 12);
   uCPUSpeed = Rect.bottom;
-  
+
+
   if (MM7_Initialize())
   {
     Log::Warning(L"MM init: ok");
@@ -14031,12 +14032,12 @@
          CreditsMenu__Loop(); // процесс воспроизведения окна Создатели
          break;
         }
-        if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LOAD) // Процес загрузки игры
+        if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LOAD) //??? неизвестно что это
         {
           uGameState = 0;
         }
-        else //???
-        __debugbreak();
+        else
+         __debugbreak();
         /*{
           if (GetCurrentMenuID() != MENU_10)
             goto LABEL_49;
--- a/mm7_4.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/mm7_4.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -5884,7 +5884,7 @@
     pAsyncMouse->Resume();
   v2 = 6;
   pGUIWindow_CurrentMenu->field_40 = 0;
-LABEL_27:
+//LABEL_27:
   SetCurrentMenuID((MENU_STATE)v2);
   while ( GetCurrentMenuID() == MENU_CREATEPARTY )
   {
@@ -5940,13 +5940,17 @@
       {
         v26 = 1;
         v2 = 0;
-        goto LABEL_27;
+        //goto LABEL_27;
+        SetCurrentMenuID((MENU_STATE)v2);
+        continue;
       }
       if ( uGameState == 6 )
       {
         uGameState = v1;
         v2 = 1;
-        goto LABEL_27;
+        //goto LABEL_27;
+        SetCurrentMenuID((MENU_STATE)v2);
+        continue;
       }
     }
   }
@@ -5990,12 +5994,12 @@
     if ( !pPlayer->uClass )
       pPlayer->sResMagicBase = 10;
     //*((short *)v10 + 400) = 0;
-	pPlayer->pPlayerBuffs[22].uExpireTime = 0;
+    pPlayer->pPlayerBuffs[22].uExpireTime = 0;
     uSpellBookPageCount = 0;
-	for ( int i = 0; i < 9; i++)
+    for ( int i = 0; i < 9; i++)
     {
       if ( pPlayer->pActiveSkills[12+i] )
-		  ++uSpellBookPageCount;
+        ++uSpellBookPageCount;
     }
     pPlayer->pNumSpellBookPage = uSpellBookPageCount;
     pItemsTable->GenerateItem(2, 40, &item);
@@ -6010,11 +6014,11 @@
         {
           case 0:
             v18 = 61;
-			pPlayer->AddItem(-1, v18);
+            pPlayer->AddItem(-1, v18);
             break;
           case 1:
             v18 = 1;
-			pPlayer->AddItem(-1, v18);
+            pPlayer->AddItem(-1, v18);
             break;
           case 2:
             v18 = 15;
@@ -6234,7 +6238,7 @@
       if ( a5 >= (signed __int16)pTexture2.uHeight )
         SetCurrentMenuID(MENU_MAIN);
       pRenderer->Present();
-      pCurrentScreen = 0;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc()
+	  pCurrentScreen = 0;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc()
       GUI_MainMenuMessageProc();
     }
   }
--- a/mm7_5.cpp	Sun Jan 13 17:41:47 2013 +0600
+++ b/mm7_5.cpp	Tue Jan 15 17:44:23 2013 +0600
@@ -315,21 +315,23 @@
       {
         case UIMSG_ChangeGameState:
           uGameState = v0;
-          goto _continue;
+          continue;
         case UIMSG_PlayArcomage:
           pVideoPlayer->_4BF5B2();
           pArcomageGame->bGameInProgress = 1;
           PrepareArcomage();
-          goto _continue;
+          continue;
         case UIMSG_StartNPCDialogue:
           if ( !uActiveCharacter )
-            goto _continue;
+            continue;
           viewparams->field_48 = v0;
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID;
           pActor = &pActors[uMessageParam];
-          goto _actor_init_dlg;
+          //goto _actor_init_dlg;
+          pActor->InitializeDialogue(v0);
+          continue;
         case UIMSG_Quit|0x2:
         case 0x87:
           if ( bNoNPCHiring != 1 && !pCurrentScreen )
@@ -375,26 +377,26 @@
               memset(&actor, 0, 0x344u);
               actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds;
               pActor = &actor;
-_actor_init_dlg:
+//_actor_init_dlg:
               pActor->InitializeDialogue(v0);
             }
           }
-          goto _continue;
+          continue;
         case 0x51:
           sub_4BDB56_buy_skill____();
-          goto _continue;
+          continue;
         case UIMSG_AF:
           sub_4B2001(uMessageParam);
-          goto _continue;
+          continue;
         case 0x195:
           sub_4BCACC_bounties(uMessageParam);
-          goto _continue;
+          continue;
         case 0x88:
           sub_4BC49B(uMessageParam);
-          goto _continue;
+          continue;
         case 0x19A:
           _4B4224_UpdateNPCTopics(uMessageParam);
-          goto _continue;
+          continue;
         case UIMSG_StartNewGame:
           if ( dword_6BE138 == 124 || uMessageParam )
           {
@@ -414,9 +416,9 @@
             pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
             dword_6BE138 = 124;
           }
-_release_tex_and_continue:
+//_release_tex_and_continue:
           stru_506E40.Release();
-          goto _continue;
+          continue;
         case UIMSG_Game_OpenLoadGameDialog:
           pIcons_LOD->_40F9C5();
           pIcons_LOD->_4114F2();
@@ -425,7 +427,7 @@
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = 12;
           GameUI_DrawLoadMenu(v0);
-          goto _continue;
+          continue;
         case UIMSG_Quit:
           if ( dword_6BE138 == 132 || uMessageParam )
           {
@@ -446,7 +448,9 @@
             pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
             dword_6BE138 = 132;
           }
-          goto _release_tex_and_continue;
+          //goto _release_tex_and_continue;
+          stru_506E40.Release();
+          continue;
         case 0x80:
           pIcons_LOD->_40F9C5();
           pIcons_LOD->_4114F2();
@@ -536,14 +540,16 @@
               strcpy((char *)pKeyActionMap->pPressedKeysBuffer, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
             pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
           }
-          goto _continue;
+          continue;
         case UIMSG_LoadGame:
           if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
           {
             LoadGame(uLoadGameUI_SelectedSlot);
             uGameState = 3;
           }
-          goto _release_tex_and_continue;
+          //goto _release_tex_and_continue;
+          stru_506E40.Release();
+          continue;
         case UIMSG_SaveGame:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
           {
@@ -553,12 +559,14 @@
               (const char *)pKeyActionMap->pPressedKeysBuffer);
           }
           DoSavegame(uLoadGameUI_SelectedSlot);
-          goto _release_tex_and_continue;
+          //goto _release_tex_and_continue;
+          stru_506E40.Release();
+          continue;
         case UIMSG_StartNewGame|0x2:
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = 11;
           GameUI_DrawSaveMenu();
-          goto _continue;
+          continue;
         case UIMSG_Game_OpenOptionsDialog:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -644,7 +652,9 @@
           v124 = 214;
           v122 = 194;
           v120 = 19;
-          goto LABEL_117;
+          //goto LABEL_117;
+          pGUIWindow_CurrentMenu->CreateButton(v120, v122, v124, v126, v129, v131, v134, v138, v143, v150, pTexture);
+          continue;
         case UIMSG_OpenKeyMappingOptions:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -682,8 +692,8 @@
           word_506E6C[14] = 0;
           memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
           goto LABEL_90;
-        default:
-          goto _continue;
+        //default:
+          //continue;
         case UIMSG_ResetKeyMapping|0x1:
           if ( dword_506E68 != -1 )
             goto LABEL_623;
@@ -692,7 +702,7 @@
             v14 = uMessageParam + 14;
           dword_506E68 = v14;
           pKeyActionMap->EnterText(0, v0, pGUIWindow_CurrentMenu);
-          goto _continue;
+          continue;
         case UIMSG_ResetKeyMapping:
           v197 = 1;
           pKeyActionMap->SetDefaultMapping();
@@ -716,7 +726,7 @@
             }
             pPrevVirtualCidesMapping[uAction] = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
             v18 = uAction++;
-            v13 = __OFSUB__(uAction, 28);
+            v13 = uAction > 28;
             v12 = uAction - 28 < 0;
             *((char *)word_506E6C + v18) = 0;
           }
@@ -732,10 +742,10 @@
           goto _play_sound_and_continue;
         case 0x1A0:
           dword_506F08 = v0;
-          goto _continue;
+          continue;
         case UIMSG_StartNPCDialogue|0x100:
           dword_506F08 = 2;
-          goto _continue;
+          continue;
         case UIMSG_OpenVideoOptions:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -789,19 +799,28 @@
               v124 = 170;
               v122 = 162;
               v120 = 42;
-LABEL_117:
+//LABEL_117:
               pGUIWindow_CurrentMenu->CreateButton(v120, v122, v124, v126, v129, v131, v134, v138, v143, v150, pTexture);
             }
           }
-          goto _continue;
+          continue;
         case UIMSG_ToggleTint|0x1:
           if ( uMessageParam == 4 )
           {
             --uGammaPos;
-            if ( (uGammaPos & 0x80000000u) != 0 )
+            if ( (uGammaPos /*& 0x80000000u*/) != 0 )
             {
               uGammaPos = 0;
-              goto LABEL_128;
+              //goto LABEL_128;
+              v165 = 0;
+              v151 = 0;
+              v144 = 0;
+              v139 = 0;
+              v135 = -1;
+              v132 = 0;
+              v130 = 0;
+              v127 = 21;
+              goto _play_sound_and_continue;
             }
             v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v19);
@@ -811,7 +830,18 @@
             v140 = 0;
             v136 = 0;
             v20 = 21;
-            goto LABEL_122;
+            //goto LABEL_122;
+            GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
+            //goto LABEL_128;
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = 0;
+            v127 = 21;
+            goto _play_sound_and_continue;
           }
           if ( uMessageParam == 5 )
           {
@@ -826,9 +856,18 @@
               pWindowType2 = (WindowType)90;
               v140 = 0;
               v136 = 0;
-LABEL_122:
+//LABEL_122:
               GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
-              goto LABEL_128;
+              //goto LABEL_128;
+              v165 = 0;
+              v151 = 0;
+              v144 = 0;
+              v139 = 0;
+              v135 = -1;
+              v132 = 0;
+              v130 = 0;
+              v127 = 21;
+              goto _play_sound_and_continue;
             }
             uGammaPos = 9;
           }
@@ -838,7 +877,7 @@
             v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v22);
           }
-LABEL_128:
+//LABEL_128:
           v165 = 0;
           v151 = 0;
           v144 = 0;
@@ -850,13 +889,13 @@
           goto _play_sound_and_continue;
         case UIMSG_ToggleBloodsplats:
           pGame->ToggleFlags2(0x20u);
-          goto _continue;
+          continue;
         case UIMSG_ToggleColoredLights:
           pRenderer->bUseColoredLights = pRenderer->bUseColoredLights == 0;
-          goto _continue;
+          continue;
         case UIMSG_ToggleTint:
           pRenderer->bTinting = pRenderer->bTinting == 0;
-          goto _continue;
+          continue;
         case UIMSG_ChangeMusicVolume:
           if ( uMessageParam == 4 )
           {
@@ -866,9 +905,14 @@
             v167 = v0;
             v23 = 243;
             v153 = (int)pBtn_SliderLeft;
-LABEL_136:
+//LABEL_136:
             GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
-            goto LABEL_143;
+            //goto LABEL_143;
+            if ( uMusicVolimeMultiplier )
+              pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0,
+                (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0), 0);
+            pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
+            continue;
           }
           if ( uMessageParam == 5 )
           {
@@ -878,17 +922,24 @@
             v167 = v0;
             v23 = 435;
             v153 = (int)pBtn_SliderRight;
-            goto LABEL_136;
+            //goto LABEL_136;
+            GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
+            //goto LABEL_143;
+            if ( uMusicVolimeMultiplier )
+              pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0,
+                (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0), 0);
+            pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
+            continue;
           }
           uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;
           if ( (char)uMusicVolimeMultiplier > 9 )
             uMusicVolimeMultiplier = 9;
-LABEL_143:
+//LABEL_143:
           if ( uMusicVolimeMultiplier )
             pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0,
               (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0), 0);
           pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
-          goto _continue;
+          continue;
         case UIMSG_ChangeSoundVolume:
           if ( uMessageParam == 4 )
           {
@@ -898,9 +949,19 @@
             v168 = v0;
             v24 = 243;
             v154 = (int)pBtn_SliderLeft;
-LABEL_150:
+//LABEL_150:
             GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
-            goto LABEL_157;
+            //goto LABEL_157;
+            pAudioPlayer->SetMasterVolume((signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = -1;
+            v127 = 218;
+            goto _play_sound_and_continue;
           }
           if ( uMessageParam == 5 )
           {
@@ -910,12 +971,24 @@
             v168 = v0;
             v24 = 435;
             v154 = (int)pBtn_SliderRight;
-            goto LABEL_150;
+            //goto LABEL_150;
+            GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
+            //goto LABEL_157;
+            pAudioPlayer->SetMasterVolume((signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = -1;
+            v127 = 218;
+            goto _play_sound_and_continue;
           }
           uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17;
           if ( (char)uSoundVolumeMultiplier > 8 )
             uSoundVolumeMultiplier = 9;
-LABEL_157:
+//LABEL_157:
           pAudioPlayer->SetMasterVolume((signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
           v165 = 0;
           v151 = 0;
@@ -928,16 +1001,16 @@
           goto _play_sound_and_continue;
         case UIMSG_ToggleFlipOnExit:
           bFlipOnExit = bFlipOnExit == 0;
-          goto _continue;
+          continue;
         case UIMSG_ToggleAlwaysRun:
           bAlwaysRun = bAlwaysRun == 0;
-          goto _continue;
+          continue;
         case UIMSG_ToggleWalkSound:
           bWalkSound = bWalkSound == 0;
-          goto _continue;
+          continue;
         case UIMSG_ToggleShowDamage:
           bShowDamage = bShowDamage == 0;
-          goto _continue;
+          continue;
         case UIMSG_ChangeVoiceVolume:
           if ( uMessageParam == 4 )
           {
@@ -947,9 +1020,20 @@
             v169 = v0;
             v25 = 243;
             v155 = (int)pBtn_SliderLeft;
-LABEL_166:
+//LABEL_166:
             GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
-            goto LABEL_173;
+            //goto LABEL_173;
+            if ( !uVoicesVolumeMultiplier )
+              continue;
+            v165 = 0;
+            v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = -1;
+            v127 = 5788;
+            goto _play_sound_and_continue;
           }
           if ( uMessageParam == 5 )
           {
@@ -959,14 +1043,27 @@
             v169 = v0;
             v25 = 435;
             v155 = (int)pBtn_SliderRight;
-            goto LABEL_166;
+            //goto LABEL_166;
+            GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
+            //goto LABEL_173;
+            if ( !uVoicesVolumeMultiplier )
+              continue;
+            v165 = 0;
+            v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = -1;
+            v127 = 5788;
+            goto _play_sound_and_continue;
           }
           uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17;
           if ( (char)uVoicesVolumeMultiplier > 8 )
             uVoicesVolumeMultiplier = 9;
-LABEL_173:
+//LABEL_173:
           if ( !uVoicesVolumeMultiplier )
-            goto _continue;
+            continue;
           v165 = 0;
           v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
           v144 = 0;
@@ -980,14 +1077,14 @@
           if ( uMessageParam )
             pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
           uTurnSpeed = uMessageParam;
-          goto _continue;
+          continue;
         case UIMSG_SetGraphicsMode:
           if ( !bUseLoResSprites )
           {
             byte_6BE388_graphicsmode = uMessageParam;
-LABEL_184:
+//LABEL_184:
             MM7Initialization();
-            goto _continue;
+            continue;
           }
           if ( uMessageParam )
           {
@@ -998,13 +1095,15 @@
             else
             {
               if ( uMessageParam != 2 )
-                goto _continue;
+                continue;
               byte_6BE388_graphicsmode = 1;
             }
-            goto LABEL_184;
+            //goto LABEL_184;
+            MM7Initialization();
+            continue;
           }
           ModalWindow(pNPCTopics[453].pText, 0);
-          goto _continue;
+          continue;
         case UIMSG_SkillUp|0x2:
           pGUIWindow_CurrentMenu->Release();
           pEventTimer->Resume();
@@ -1019,7 +1118,7 @@
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, (enum WindowType)99, (int)pBtn_Quests, 0);
           bFlashQuestBook = 0;
-          goto _continue;
+          continue;
         case UIMSG_OpenAutonotes:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1030,7 +1129,7 @@
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, (enum WindowType)99, (int)pBtn_Autonotes, 0);
           bFlashAutonotesBook = 0;
-          goto _continue;
+          continue;
         case UIMSG_OpenMapBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1045,7 +1144,10 @@
           v28 = 546;
           v170 = 0;
           v156 = (int)pBtn_Maps;
-          goto LABEL_210;
+          //goto LABEL_210;
+          pGUIWindow_CurrentMenu = pWindow;
+          pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
+          continue;
         case UIMSG_OpenCalendar:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1058,10 +1160,10 @@
           v28 = 570;
           v170 = 0;
           v156 = (int)pBtn_Calendar;
-LABEL_210:
+//LABEL_210:
           pGUIWindow_CurrentMenu = pWindow;
           pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
-          goto _continue;
+          continue;
         case UIMSG_OpenHistoryBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1072,8 +1174,8 @@
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)pBtn_History, 0);
           bFlashHistoryBook = 0;
-          goto _continue;
-        case UIMSG_Escape:
+          continue;
+        case UIMSG_Escape:// нажатие Escape
           back_to_game();
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1081,22 +1183,30 @@
           {
             if ( pCurrentScreen >= 17 && (pCurrentScreen <= 18 || pCurrentScreen == 104) )
             {
-LABEL_229:
+//LABEL_229:
               if ( dword_50CDC8 )
                 goto LABEL_232;
               sub_42FC15();
-              goto LABEL_231;
+              //goto LABEL_231;
+              uMessageParam = v0;
+              goto LABEL_232;
             }
           }
           else
           {
             if ( pCurrentScreen >= 14 || pCurrentScreen == 4 || pCurrentScreen == 10 )
-              goto LABEL_229;
+              //goto LABEL_229;
+              if ( dword_50CDC8 )
+                goto LABEL_232;
+              sub_42FC15();
+              //goto LABEL_231;
+              uMessageParam = v0;
+              goto LABEL_232;
             if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 )
             {
               sub_42FC15();
               dword_5C35C8 = 0;
-LABEL_231:
+//LABEL_231:
               uMessageParam = v0;
               goto LABEL_232;
             }
@@ -1139,33 +1249,95 @@
                         dword_50C9A8 = 0;
                         ptr_50C9A4 = 0;
                       }
-                      goto LABEL_322;
+                      //goto LABEL_322;
+                      if ( pGUIWindow_Settings )
+                      {
+                       if ( pCurrentScreen == 7 )
+                       {
+                        pMouse->SetCursorBitmap("MICON2");
+                       }
+                       else
+                       {
+                         pGUIWindow_Settings->Release();
+                         pGUIWindow_Settings = 0;
+                         pMouse->SetCursorBitmap("MICON1");
+                         GameUI_StatusBar_TimedStringTimeLeft = 0;
+                         unk_50C9A0 = 0;
+                         back_to_game();
+                        }
+                       }
+                       if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                       uActiveCharacter = pParty->GetNextActiveCharacter();
+                       pGUIWindow_CurrentMenu->Release();
+                       if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                        ptr_507BC0 = 0;
+                       pGUIWindow_CurrentMenu = 0;
+                       pEventTimer->Resume();
+                       pCurrentScreen = 0;
+                       viewparams->bRedrawGameUI = v0;
+                       pIcons_LOD->_4355F7();
+                       continue;
                     case 3:
                       pBooksWindow->Release();
                       //crt_deconstruct_ptr_6A0118();
                       pBooksWindow = 0;
                       pEventTimer->Resume();
-                      goto LABEL_322;
+                      //goto LABEL_322;
+                      if ( pGUIWindow_Settings )
+                      {
+                        if ( pCurrentScreen == 7 )
+                        {
+                         pMouse->SetCursorBitmap("MICON2");
+                        }
+                        else
+                        {
+                         pGUIWindow_Settings->Release();
+                         pGUIWindow_Settings = 0;
+                         pMouse->SetCursorBitmap("MICON1");
+                         GameUI_StatusBar_TimedStringTimeLeft = 0;
+                         unk_50C9A0 = 0;
+                         back_to_game();
+                        }
+                      }
+                      if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                        uActiveCharacter = pParty->GetNextActiveCharacter();
+                      pGUIWindow_CurrentMenu->Release();
+                      if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                        ptr_507BC0 = 0;
+                      pGUIWindow_CurrentMenu = 0;
+                      pEventTimer->Resume();
+                      pCurrentScreen = 0;
+                      viewparams->bRedrawGameUI = v0;
+                      pIcons_LOD->_4355F7();
+                      continue;
                     case 11:
                     case 12:
                       pIcons_LOD->_4114F2();
                       //crt_deconstruct_ptr_6A0118();
-                      goto LABEL_291;
+                      //goto LABEL_291;
+                      stru_506E40.Release();
+                      break;
                     case 15:
                       pCurrentScreen = 10;
-                      goto _continue;
+                      continue;
                     case 10:
                       pWindow2 = pChestWindow;
-                      goto LABEL_249;
-                    case 25:
-                      pWindow2 = ptr_507BC8;
-LABEL_249:
+                      //goto LABEL_249;
                       pWindow2->Release();
                       pIcons_LOD->_4114F2();
                       pCurrentScreen = 0;
                       viewparams->bRedrawGameUI = v0;
                       pEventTimer->Resume();
-                      goto _continue;
+                      continue;
+                    case 25:
+                      pWindow2 = ptr_507BC8;
+//LABEL_249:
+                      pWindow2->Release();
+                      pIcons_LOD->_4114F2();
+                      pCurrentScreen = 0;
+                      viewparams->bRedrawGameUI = v0;
+                      pEventTimer->Resume();
+                      continue;
                     case 2:
                       thisa = (signed int)&uTextureID_507C60;
                       do
@@ -1188,23 +1360,37 @@
                       if ( !uTurnSpeed )
                       {
                         v171 = 3;
-                        goto LABEL_261;
+                        //goto LABEL_261;
+                        v30 = v171;
+                        //goto LABEL_262;
+                        v31 = "TurnDelta";
+                        WriteWindowsRegistryInt(v31, v30);
+                        stru_506E40.Release();
+                        break;
                       }
                       if ( uTurnSpeed == 64 )
                       {
                         v171 = 2;
-LABEL_261:
+//LABEL_261:
                         v30 = v171;
-                        goto LABEL_262;
+                        //goto LABEL_262;
+                        v31 = "TurnDelta";
+                        WriteWindowsRegistryInt(v31, v30);
+                        stru_506E40.Release();
+                        break;
                       }
                       if ( uTurnSpeed != 128 )
-                        goto LABEL_291;
+                        //goto LABEL_291;
+                        {
+                          stru_506E40.Release();
+                          break;
+                        }
                       v30 = v0;
-LABEL_262:
+//LABEL_262:
                       v31 = "TurnDelta";
-LABEL_263:
+//LABEL_263:
                       WriteWindowsRegistryInt(v31, v30);
-LABEL_291:
+//LABEL_291:
                       stru_506E40.Release();
                       break;
                     case 1:
@@ -1212,7 +1398,9 @@
                       pIcons_LOD->_4114F2();
                       pIcons_LOD->_40F9C5();
                       pIcons_LOD->_4114F2();
-                      goto LABEL_291;
+                      //goto LABEL_291;
+                      stru_506E40.Release();
+                      break;
                     case 28:
                       if ( pRenderer->pRenderD3D )
                       {
@@ -1221,10 +1409,17 @@
                         WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
                       }
                       if ( pRenderer->bWindowMode )
-                        goto LABEL_291;
+                        //goto LABEL_291;
+                        {
+                          stru_506E40.Release();
+                          break;
+                        }
                       v30 = uGammaPos;
                       v31 = "GammaPos";
-                      goto LABEL_263;
+                      //goto LABEL_263;
+                      WriteWindowsRegistryInt(v31, v30);
+                      stru_506E40.Release();
+                      break;
                     case 26:
                       v197 = 1;
                       v32 = 0;
@@ -1270,7 +1465,9 @@
                           }
                           while ( uAction < 28 );
                           pKeyActionMap->StoreMappings();
-                          goto LABEL_291;
+                          //goto LABEL_291;
+                          stru_506E40.Release();
+                          break;
                         }
                       }
                       goto LABEL_623;
@@ -1292,12 +1489,39 @@
                       _506F18_num_hours_to_sleep = 0;
                       dword_506F14 = 0;
                       dword_507B94 = v0;
-                      goto LABEL_322;
+                      //goto LABEL_322;
+                      if ( pGUIWindow_Settings )
+                      {
+                        if ( pCurrentScreen == 7 )
+                        {
+                          pMouse->SetCursorBitmap("MICON2");
+                        }
+                        else
+                        {
+                          pGUIWindow_Settings->Release();
+                          pGUIWindow_Settings = 0;
+                          pMouse->SetCursorBitmap("MICON1");
+                          GameUI_StatusBar_TimedStringTimeLeft = 0;
+                          unk_50C9A0 = 0;
+                          back_to_game();
+                         }
+                       }
+                       if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                        uActiveCharacter = pParty->GetNextActiveCharacter();
+                       pGUIWindow_CurrentMenu->Release();
+                       if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                       ptr_507BC0 = 0;
+                       pGUIWindow_CurrentMenu = 0;
+                       pEventTimer->Resume();
+                       pCurrentScreen = 0;
+                       viewparams->bRedrawGameUI = v0;
+                       pIcons_LOD->_4355F7();
+                       continue;
                     case 14:
                       pGUIWindow_CurrentMenu->Release();
                       pCurrentScreen = 13;
                       pIcons_LOD->_4114F2();
-                      goto _continue;
+                      continue;
                     case 13:
                       if ( uDialogueType )
                         uDialogueType = 0;
@@ -1309,20 +1533,56 @@
                       else
                       {
                         if ( sub_4BD8B5() )
-                          goto _continue;
+                          continue;
                       }
                       sub_4B1D27();
                       pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 814, 0, -1, 0, 0, 0, 0);
                       pVideoPlayer->Unload();
                       pGUIWindow_CurrentMenu = ptr_507BC0;
-                      goto LABEL_322;
+                      //goto LABEL_322;
+                      if ( pGUIWindow_Settings )
+                      {
+                        if ( pCurrentScreen == 7 )
+                        {
+                          pMouse->SetCursorBitmap("MICON2");
+                        }
+                        else
+                        {
+                          pGUIWindow_Settings->Release();
+                          pGUIWindow_Settings = 0;
+                          pMouse->SetCursorBitmap("MICON1");
+                          GameUI_StatusBar_TimedStringTimeLeft = 0;
+                          unk_50C9A0 = 0;
+                          back_to_game();
+                        }
+                      }
+                      if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                        uActiveCharacter = pParty->GetNextActiveCharacter();
+                      pGUIWindow_CurrentMenu->Release();
+                      if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                        ptr_507BC0 = 0;
+                      pGUIWindow_CurrentMenu = 0;
+                      pEventTimer->Resume();
+                      pCurrentScreen = 0;
+                      viewparams->bRedrawGameUI = v0;
+                      pIcons_LOD->_4355F7();
+                      continue;
                     case 18:
                       if ( uCurrentHouse_Animation == 153 )
                         HousePlaySomeSound(0x99u, 3);
                       pVideoPlayer->Unload();
-                      goto LABEL_306;
+                      //goto LABEL_306;
+                      if ( dword_5B65CC )
+                      {
+                        pParty->field_709 = 0;
+                        LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
+                        sub_44A56A();
+                        viewparams->bRedrawGameUI = v0;
+                        dword_5B65CC = 0;
+                      }
+                      goto LABEL_317;
                     case 4:
-LABEL_306:
+//LABEL_306:
                       if ( dword_5B65CC )
                       {
                         pParty->field_709 = 0;
@@ -1348,13 +1608,67 @@
                       goto LABEL_317;
                     case 16:
                       pVideoPlayer->Unload();
-                      goto _continue;
+                      continue;
                     case 7:
                       goto LABEL_319;
                     default:
-                      goto LABEL_322;
+                      //goto LABEL_322;
+                      if ( pGUIWindow_Settings )
+                      {
+                        if ( pCurrentScreen == 7 )
+                        {
+                          pMouse->SetCursorBitmap("MICON2");
+                        }
+                        else
+                        {
+                          pGUIWindow_Settings->Release();
+                          pGUIWindow_Settings = 0;
+                          pMouse->SetCursorBitmap("MICON1");
+                          GameUI_StatusBar_TimedStringTimeLeft = 0;
+                          unk_50C9A0 = 0;
+                          back_to_game();
+                        }
+                      }
+                      if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                        uActiveCharacter = pParty->GetNextActiveCharacter();
+                      pGUIWindow_CurrentMenu->Release();
+                      if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                        ptr_507BC0 = 0;
+                      pGUIWindow_CurrentMenu = 0;
+                      pEventTimer->Resume();
+                      pCurrentScreen = 0;
+                      viewparams->bRedrawGameUI = v0;
+                      pIcons_LOD->_4355F7();
+                      continue;
                   }
-                  goto LABEL_322;
+                  //goto LABEL_322;
+                  if ( pGUIWindow_Settings )
+                  {
+                    if ( pCurrentScreen == 7 )
+                    {
+                      pMouse->SetCursorBitmap("MICON2");
+                    }
+                    else
+                    {
+                      pGUIWindow_Settings->Release();
+                      pGUIWindow_Settings = 0;
+                      pMouse->SetCursorBitmap("MICON1");
+                      GameUI_StatusBar_TimedStringTimeLeft = 0;
+                      unk_50C9A0 = 0;
+                      back_to_game();
+                    }
+                  }
+                  if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                    uActiveCharacter = pParty->GetNextActiveCharacter();
+                  pGUIWindow_CurrentMenu->Release();
+                  if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                    ptr_507BC0 = 0;
+                  pGUIWindow_CurrentMenu = 0;
+                  pEventTimer->Resume();
+                  pCurrentScreen = 0;
+                  viewparams->bRedrawGameUI = v0;
+                  pIcons_LOD->_4355F7();
+                  continue;
                 }
 LABEL_319:
                 sub_4196A0();
@@ -1362,7 +1676,7 @@
 LABEL_321:
                 pIcons_LOD->_4114F2();
               }
-LABEL_322:
+//LABEL_322:
               if ( pGUIWindow_Settings )
               {
                 if ( pCurrentScreen == 7 )
@@ -1389,7 +1703,7 @@
               pCurrentScreen = 0;
               viewparams->bRedrawGameUI = v0;
               pIcons_LOD->_4355F7();
-              goto _continue;
+              continue;
             }
             pWindow3 = pGUIWindow_Settings;
             if ( !pGUIWindow_Settings )//Draw Menu
@@ -1435,12 +1749,12 @@
               pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
               free((void *)uNumSeconds);
               stru_506E40._40E55E("gamma.pcx", 0);
-              goto _continue;
+              continue;
             }
             goto LABEL_333;
           }
           sub_41426F();
-_continue:
+//_continue:
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -1465,7 +1779,7 @@
             }
           }
           DrawHiredNPCs();
-          goto _continue;
+          continue;
         case UIMSG_OpenRestUI|0x2:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1526,7 +1840,7 @@
           dword_597F18 = 0;
           if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
             pParty->uTimePlayed += 1474560i64;
-          goto _continue;
+          continue;
         case 0x19C:
           sub_42FC15();
           pVideoPlayer->Unload();
@@ -1664,7 +1978,7 @@
             v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
 LABEL_400:
             if ( !v47 )
-              goto _continue;
+              continue;
             goto LABEL_415;
           }
           if ( v45 == 5 )
@@ -1674,22 +1988,22 @@
           else
           {
             if ( v45 != 6 )
-              goto _continue;
+              continue;
             if ( uCurrentlyLoadedLevelType != v0 )
             {
               pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
               if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
-                goto _continue;
+                continue;
               v44 = uNumSeconds;
               goto LABEL_415;
             }
             pBLVFace = &pIndoor->pFaces[v46];
             if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
-              goto _continue;
+              continue;
             v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0;
           }
           if ( v48 )
-            goto _continue;
+            continue;
 LABEL_415:
           v51 = pGUIWindow_Settings->ptr_1C;
           *((char *)v51 + 8) &= 0xBFu;
@@ -1705,7 +2019,7 @@
           GameUI_StatusBar_TimedStringTimeLeft = 0;
           unk_50C9A0 = 0;
           back_to_game();
-          goto _continue;
+          continue;
         case UIMSG_ChangeGameState|0x40:
         case 0x8D:
         case 0x8F:
@@ -1746,7 +2060,7 @@
               unk_50C9A0 = 0;
             }
           }
-          goto _continue;
+          continue;
         case UIMSG_BF:
           dword_50CDC8 = v0;
           sub_42FBDD();
@@ -1756,7 +2070,7 @@
           uGameState = 2;
 		  //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
           v53 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1]._quest_related;
-		  if ( v53 < 0 )
+          if ( v53 < 0 )
           {
             v54 = abs(v53) - 1;
             _5B65B8_npcdata_hiword_house_or_other = 0;
@@ -1785,7 +2099,7 @@
           pWindowType = (WindowType)9;
 LABEL_439:
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
-          goto _continue;
+          continue;
         case UIMSG_B2:
           v165 = 0;
           v151 = 0;
@@ -1799,13 +2113,13 @@
           goto _play_sound_and_continue;
         case UIMSG_B4:
           if ( !pGUIWindow_CurrentMenu )
-            goto _continue;
+            continue;
           pPlayer = pPlayers[_506348_current_lloyd_playerid + 1];
           uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
           if ( bRecallingBeacon )
           {
             if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) )
-              goto _continue;
+              continue;
             v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
             v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s"
             goto _sprintex_2args_draw_status_and_continue;
@@ -1833,7 +2147,7 @@
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
           pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
           if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
-            goto _continue;
+            continue;
           byte_506360 = 1;
           pPlayer9->CanCastSpell(uRequiredMana);
           if ( pParty->bTurnBasedModeOn )
@@ -1903,18 +2217,18 @@
             LOWORD(pNPCData2->house) = LOWORD(pParty->sRotationY);
             HIWORD(pNPCData2->house) = LOWORD(pParty->sRotationX);
             if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
-              goto _continue;
+              continue;
             uAction = 0;
             while ( _strcmpi((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
             {
               ++thisg;
               uAction += 32;
               if ( thisg >= (signed int)pGames_LOD->uNumSubIndices / 2 )
-                goto _continue;
+                continue;
             }
             HIWORD(pNPCData4->uProfession) = thisg;
           }
-          goto _continue;
+          continue;
         case UIMSG_B7:
           if ( uMessageParam )
           {
@@ -1978,7 +2292,7 @@
                     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                     ++pMessageQueue_50CBD0->uNumMessages;
                   }
-                  goto _continue;
+                  continue;
                 }
                 v63 = 210;
                 break;
@@ -2022,7 +2336,7 @@
           if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v68) )
           {
             pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
-            goto _continue;
+            continue;
           }
 LABEL_506:
           if ( uMessageParam )
@@ -2044,11 +2358,11 @@
               default:
                 if ( uMessageParam != 5 )
                   //goto LABEL_519;
-				  {
-				   v173 = v200;
+                  {
+                   v173 = v200;
                    v157 = pGlobalTXT_LocalizationStrings[35];
                    goto _sprintex_2args_draw_status_and_continue;
-			      }
+                  }
                 v69 = pMapStats->pInfos[8].pName;
                 break;
             }
@@ -2068,7 +2382,7 @@
             pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team."   
           ModalWindow(pFinalMessage, 196);
           uGameState = GAME_STATE_FINAL_WINDOW;
-          goto _continue;
+          continue;
         case UIMSG_C4:
           uGameState = 0;
           strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
@@ -2087,7 +2401,7 @@
               v1 = "";
 LABEL_91:
               v0 = 1;
-              goto _continue;
+              continue;
             }
             v71 = v70;
             strcpy(Str2, pMapStats->pInfos[v70].pFilename);
@@ -2110,9 +2424,9 @@
                 uGameState = 2;
                 OnMapLeave();
                 //goto LABEL_90;
-				v1 = "";
+                v1 = "";
                 v0 = 1;
-                goto _continue;
+                continue;
               }
             }
             sprintf(Str2, "No map found for %s", pMapStats->pInfos[v71].pName);
@@ -2159,9 +2473,9 @@
           }
           ShowStatusBarString(v73, 6u);
           //goto LABEL_90;
-		  v1 = "";
+          v1 = "";
           v0 = 1;
-          goto _continue;
+          continue;
         case 0x19:
           if ( bUnderwater == 1 )
             goto LABEL_682;
@@ -2190,11 +2504,11 @@
           v84 = v83 >> 16;
           if ( (v44 & 7) != 3 || v84 >= 5120 )
             //goto LABEL_90;
-		  {
-			v1 = "";
+            {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           v51 = pGUIWindow_Settings->ptr_1C;
           if ( uMessage == 70 )
           {
@@ -2211,32 +2525,32 @@
         case 0x1C:
           if ( !uActiveCharacter || pCurrentScreen )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0);
           pCurrentScreen = 25;
           pEventTimer->Pause();
-          goto _continue;
+          continue;
         case 0x1B:
           if ( !uActiveCharacter )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           if ( pParty->bTurnBasedModeOn != v0 )
             goto LABEL_569;
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           if ( !(pTurnEngine->field_18 & 2) )
           {
 LABEL_569:
@@ -2245,28 +2559,28 @@
             else
               Actor::StealFrom(uMessageParam);
           }
-          goto _continue;
+          continue;
         case 0x17:
           if ( !uActiveCharacter )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           if ( pParty->bTurnBasedModeOn != v0 )
             goto LABEL_577;
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           if ( !(pTurnEngine->field_18 & 2) )
 LABEL_577:
             _42ECB5_PlayerAttacksActor();
-          goto _continue;
+          continue;
         case UIMSG_A7:
           v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest"
           pButton = pButton_RestUI_Exit;
@@ -2280,7 +2594,7 @@
             (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 5;
-          goto _continue;
+          continue;
         case 0x60:
           if ( dword_506F14 == 2 )
             goto LABEL_621;
@@ -2288,7 +2602,7 @@
             (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60;
-          goto _continue;
+          continue;
         case UIMSG_OpenRestUI:
           dword_506F14 = 2;
           RestUI_Initialize();
@@ -2301,7 +2615,7 @@
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
-            goto _continue;
+            continue;
           if ( sub_42F4DA() )
             goto LABEL_594;
           if ( pParty->bTurnBasedModeOn == v0 )
@@ -2309,7 +2623,7 @@
           if ( !(pParty->uFlags & 0x88) )
           {
             RestUI_Initialize();
-            goto _continue;
+            continue;
           }
 LABEL_594:
           if ( pParty->bTurnBasedModeOn == v0 )
@@ -2325,11 +2639,11 @@
           v89 = uActiveCharacter;
           if ( !uActiveCharacter )
             //goto LABEL_90;
-		  {
-			v1 = "";
+          {
+            v1 = "";
             v0 = 1;
-            goto _continue;
-		  }
+            continue;
+          }
           v176 = 0;
           v160 = 13;
           goto LABEL_619;
@@ -2408,7 +2722,7 @@
             pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
             pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
           }
-          goto _continue;
+          continue;
         case UIMSG_ShowStatus_Funds|0x8:
           if ( dword_506F14 == 2 )
           {
@@ -2421,7 +2735,7 @@
           v97 = sub_494820(pParty->uCurrentHour);
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
-          goto _continue;
+          continue;
         case 0x4E:
           if ( dword_50654C && byte_506550 )
           {
@@ -2440,12 +2754,11 @@
           }
 _set_status_string_pTmpBuf_and_continue:
           sub_41C0B8_set_status_string(pTmpBuf);
-          goto _continue;
+          continue;
         case 0x4F:
-          if ( !uActiveCharacter
-            || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
+          if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
                 !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) )
-            goto _continue;
+            continue;
           if ( sub_4637E0_is_there_popup_onscreen() )
             dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1;
           v98 = *(char *)(uNumSeconds + 6734);
@@ -2465,7 +2778,7 @@
         case 0x58:
           GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
-            goto _continue;
+            continue;
           pPlayer10 = pPlayers[uActiveCharacter];
           if ( !byte_506550 || !dword_50654C )
           {
@@ -2487,10 +2800,10 @@
           if ( uActiveCharacter )
             pPlayer10->PlaySound(12, 0);
           byte_506550 = 0;
-          goto _continue;
+          continue;
         case 0x33:
           if ( !uActiveCharacter )
-            goto _continue;
+            continue;
           pPlayer3 = pPlayers[uActiveCharacter];
           pNPCData4 = 0;
           uAction = 0;
@@ -2529,7 +2842,7 @@
           goto LABEL_661;
         case UIMSG_SaveGame|0x4:
           if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
-            goto _continue;
+            continue;
           sub_41140B();
           pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
 LABEL_661:
@@ -2576,10 +2889,10 @@
               }
             }
           }
-          goto _continue;
+          continue;
         case 0x8E:
           if ( pTurnEngine->field_4 == 3 )
-            goto _continue;
+            continue;
           v175 = 0;
           v159 = 0;
           v147 = 0;
@@ -2596,10 +2909,10 @@
 LABEL_679:
             _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
           }
-          goto _continue;
+          continue;
         case 0x69:
           if ( pTurnEngine->field_4 == 3 )
-            goto _continue;
+            continue;
           if ( bUnderwater == 1 )
           {
 LABEL_682:
@@ -2639,11 +2952,11 @@
                 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
                 viewparams->field_48 = v0;
-                goto _continue;
+                continue;
               }
             }
           }
-          goto _continue;
+          continue;
         case 0x6A:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -2662,7 +2975,7 @@
           pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, v0, 0, 0x71u, 0, 0,
                          pGlobalTXT_LocalizationStrings[79],// "Exit"
                          (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0, v179);
-          goto _continue;
+          continue;
         case 0x6B:
           if ( pCurrentScreen )
           {
@@ -2679,24 +2992,24 @@
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
 LABEL_453:
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
-            goto _continue;
+            continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
           goto LABEL_770;
         case UIMSG_C0:
           dword_50651C = v0;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
             dword_50651C = -1;
-          goto _continue;
+          continue;
         case UIMSG_A9:
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
 LABEL_707:
           dword_506548 = v0;
-          goto _continue;
+          continue;
         case UIMSG_AA:
           GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
 LABEL_709:
           dword_506544 = v0;
-          goto _continue;
+          continue;
         case 0x55:
           bRingsShownInCharScreen ^= v0;
           GUIButton::_41D0D8(pCharacterScreen_DetalizBtn);
@@ -2722,7 +3035,7 @@
           goto LABEL_422;
         case UIMSG_Quit|0x1:
           OnPaperdollLeftClick();
-          goto _continue;
+          continue;
         case UIMSG_Escape|0x2:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
           sub_4196A0();
@@ -2766,7 +3079,7 @@
           }
 _draw_status_string_and_continue:
           ShowStatusBarString(v87, 2u);
-          goto _continue;
+          continue;
         case UIMSG_ChangeMusicVolume|0x4:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
           sub_419379();
@@ -2791,12 +3104,12 @@
           GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42),
             (int)pCharacterScreen_AwardsBtn, 0);
           sub_419100();
-          goto _continue;
+          continue;
         case 71://0x47:
           switch ( uMessageParam )
           {
             default:
-              goto _continue;
+              continue;
             case 11:
               goto LABEL_707;
             case 10:
@@ -2812,25 +3125,25 @@
             case 2:
               dword_506540 = v0;
               if ( dword_506364 )
-                goto _continue;
+                continue;
               pButton = pBtn_Book_3;
               break;
             case 3:
               dword_50653C = v0;
               if ( dword_506364 )
-                goto _continue;
+                continue;
               pButton = pBtn_Book_4;
               break;
             case 4:
               dword_506538 = v0;
               if ( dword_506364 )
-                goto _continue;
+                continue;
               pButton = pBtn_Book_5;
               break;
             case 5:
               dword_506534 = v0;
               if ( dword_506364 )
-                goto _continue;
+                continue;
               pButton = pBtn_Book_6;
               break;
             case 6:
@@ -2853,7 +3166,7 @@
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           GameUI_OnPlayerPortraitLeftClick(uMessageParam);
-          goto _continue;
+          continue;
         case UIMSG_ShowStatus_Funds:
           v174 = (char *)pParty->uNumGoldInBank;
           v158 = pParty->uNumGold + pParty->uNumGoldInBank;
@@ -2889,7 +3202,7 @@
           v108 = 8 * uMessageParam - 8;
           LOBYTE(v108) = v108 | 4;
           pMouse->uPointingObjectID = v108;
-          goto _continue;
+          continue;
         case UIMSG_ShowStatus_ManaHP:
           v109 = pGlobalTXT_LocalizationStrings[212];// "Spell Points"
           v110 = pPlayers[uMessageParam];
@@ -2903,11 +3216,11 @@
           if ( pCurrentScreen == 15 )
             goto LABEL_762;
           sub_420E01();
-          goto _continue;
+          continue;
         case UIMSG_ChangeMusicVolume|0x8:
 LABEL_762:
           sub_421EA6_OnInventoryLeftClick();
-          goto _continue;
+          continue;
         case 0xA:
           if ( !pRenderer->pRenderD3D )
             goto LABEL_772;
@@ -2929,13 +3242,13 @@
 LABEL_768:
           if ( (signed int)v115 < 40 )
             goto LABEL_769;
-          goto _continue;
+          continue;
         case 0xE:
 LABEL_772:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
-          goto _continue;
+          continue;
         case 0xF:
           if ( pRenderer->pRenderD3D )
           {
@@ -2963,15 +3276,15 @@
           v133 = 0;
 LABEL_733:
           GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
-          goto _continue;
+          continue;
         case 0x194:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnPressSpace();
-          goto _continue;
+          continue;
         case UIMSG_ChangeSoundVolume|0x100:
           if ( pCurrentScreen )
-            goto _continue;
+            continue;
           pParty->uFlags |= 2u;
           GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A14, 0);
           uNumSeconds = 131072;
@@ -2985,7 +3298,7 @@
               viewparams->uMinimapZoom = 4096;
               viewparams->field_28 = 12;
             }
-            goto _continue;
+            continue;
           }
           v119 = 2048;
           if ( (signed int)v118 <= 2048 )
@@ -2994,7 +3307,7 @@
           goto LABEL_788;
         case UIMSG_ChangeMusicVolume|0x100:
           if ( pCurrentScreen )
-            goto _continue;
+            continue;
           pParty->uFlags |= 2u;
           GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A18, 0);
           uNumSeconds = 32768;
@@ -3023,7 +3336,8 @@
               viewparams->field_28 = 8;
             }
           }
-          goto _continue;
+        default:
+          continue;
       }
     }
   }
@@ -8351,47 +8665,64 @@
 // A750D8: using guessed type __int64 qword_A750D8;
 
 //----- (0043EDB9) --------------------------------------------------------
-bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this)
-{
-  unsigned int v1; // ebp@1
-  Player **v2; // ebx@1
-  Player *v3; // esi@2
-  enum CHARACTER_RACE v4; // edi@2
-  bool result; // eax@2
+bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1)
+{
+  unsigned int pNum; // ebp@1
+  Player **pPlayer; // ebx@1
+  Player *pPlayer2; // esi@2
+  enum CHARACTER_RACE pRace; // edi@2
+  bool pSex; // eax@2
   char v6; // zf@7
 
-  v1 = _this;
-  v2 = &pPlayers[1];
+//pPlayer = &pPlayers[1];
+  /*pNum = a1;
+  
   while ( 1 )
   {
-    v3 = *v2;
-    v4 = v3->GetRace();
-    result = v3->GetSexByVoice();
-    if ( !v4 )
+    pPlayer2 = *pPlayer;
+    pRace = pPlayer2->GetRace();
+    pSex = pPlayer2->GetSexByVoice();
+    if ( !pRace )
+      break;
+    if ( pRace == 1 || pRace == 2 )
       break;
-    if ( v4 == 1 || v4 == 2 )
-      break;
-    if ( !result && v1 == 2 )
-      goto LABEL_15;
-    v6 = v1 == 3;
+    if ( !pSex && pNum == 2 )//
+      //goto LABEL_15;
+    {
+      pSex = 1;
+      return pSex;
+    }
+    v6 = pNum == 3;//
 LABEL_11:
     if ( v6 )
-      goto LABEL_15;
-    ++v2;
-    if ( (signed int)v2 >= (signed int)&qword_A750D8 )
-    {
-      LOBYTE(result) = 0;
-      return result;
-    }
-  }
-  if ( result || v1 )
-  {
-    v6 = v1 == 1;
+      //goto LABEL_15;
+    {
+      pSex = 1;
+      return pSex;
+    }
+    ++pPlayer;
+    if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )//
+    {
+      pSex = 0;
+      return pSex;
+    }
+  }
+  if ( pSex || pNum )
+  {
+    v6 = pNum == 1;
     goto LABEL_11;
   }
-LABEL_15:
-  LOBYTE(result) = 1;
-  return result;
+//LABEL_15:
+  pSex = 1;
+  return pSex;*/
+  for (int i = 1; i <= 4; &pPlayers[i]) 
+    {
+      pRace = pPlayers[i]->GetRace();
+      pSex = pPlayers[i]->GetSexByVoice();
+      if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 )
+        return 1;
+    }
+ return 0;
 }
 // A750D8: using guessed type __int64 qword_A750D8;
 
@@ -14397,7 +14728,7 @@
   void *v20; // ebp@66
   char *pHint; // edx@66
   GUIButton *pButtonPtr_1C; // ebp@79
-  char *v23; // edx@80
+  char *pHint1; // edx@80
   char v24; // zf@81
   //unsigned int v25; // eax@91
   int v26; // eax@98
@@ -14462,7 +14793,7 @@
       if ( (signed int)pWindowType > 95 )
       {
         v33 = pWindowType - 96;
-        if ( !v33 )
+        if ( pWindowType == WINDOW_60 )//96
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -14485,29 +14816,29 @@
           continue;
         }
         v34 = v33 - 1;
-        if ( v34 )
+        if ( v34 )//pWindowType > 97
         {
           v35 = v34 - 1;
-          if ( v35 )
+          if ( v35 )//pWindowType > 98
           {
             v36 = v35 - 1;
-            if ( v36 )
+            if ( v36 )//pWindowType > 99
             {
               v37 = v36 - 4;
-              if ( v37 )
+              if ( v37 )//pWindowType > 103
               {
                 v38 = v37 - 2;
-                if ( v38 )
+                if ( v38 )//pWindowType > 105
                 {
-                  if ( v38 == 1 )
+                  if ( v38 == 1 )//pWindowType == 106
                     GameMenuUI_DrawVideoOptions();
                 }
-                else
+                else//pWindowType == 105
                 {
                   GameMenuUI_DrawKeyBindings();
                 }
               }
-              else
+              else//pWindowType == 103
               {
                 pWindow->DrawMessageBox(0);
                 pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
@@ -14529,7 +14860,7 @@
               }
               continue;
             }
-            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);
+            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99
             pY = pWindow->uFrameY;
             pX = pWindow->uFrameX;
 //LABEL_18:
@@ -14538,7 +14869,7 @@
             viewparams->bRedrawGameUI = 1;
             continue;
           }
-          memset(&GUIButton2, 0, 0xBCu);
+          memset(&GUIButton2, 0, 0xBCu);//pWindowType == 98
           GUIButton2.uZ = 197;
           GUIButton2.uW = 197;
           GUIButton2.uX = 27;
@@ -14552,47 +14883,63 @@
           GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Отдых и лечение 8 часов
           GUIButton2.pParent = 0;
           //goto LABEL_134;
-		  pGUIWindow2 = pWindow;
+          pGUIWindow2 = pWindow;
           //goto LABEL_110;
-		  pGUIWindow2->Release();
-          continue;
-        }
-        if ( pWindow->Hint != (char *)1 )
+          pGUIWindow2->Release();
+          continue;
+        }
+        if ( pWindow->Hint != (char *)1 )//pWindowType == 97
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
         v32 = pWindow->ptr_1C;
         pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
-        goto LABEL_138;
-      }
-      if ( pWindowType == 95 )
+        //goto LABEL_138;
+        pHint = pWindow->Hint;
+        viewparams->bRedrawGameUI = 1;
+        if ( pHint && pHint != (char *)1 )
+          ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
+        pWindow->Release();
+        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        {
+         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
+         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+         ++pMessageQueue_50CBD0->uNumMessages;
+         continue;
+        }
+        continue;
+      }
+
+      if ( pWindowType == WINDOW_5F )
       {
         if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
         v32 = pWindow->ptr_1C;
         pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15));
-LABEL_138:
+//LABEL_138:
         pHint = pWindow->Hint;
         viewparams->bRedrawGameUI = 1;
         if ( pHint && pHint != (char *)1 )
           ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
-LABEL_142:
+//LABEL_142:
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
         if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           //goto LABEL_151;
-		{
-		  pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
-          continue;
-		}
+        {
+         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
+         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+         ++pMessageQueue_50CBD0->uNumMessages;
+         continue;
+        }
         continue;
       }
       v14 = pWindowType - 80;
-      if ( v14 )
+      if ( v14 )//pWindowType > 80
       {
         v15 = v14 - 9;
-        if ( !v15 )
+        if ( !v15 )//pWindowType == 89
         {
           pWindow->DrawMessageBox(0);
           pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
@@ -14629,7 +14976,7 @@
           continue;
         }
         v16 = v15 - 1;
-        if ( !v16 )
+        if ( !v16 )// pWindowType == 90
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -14644,73 +14991,101 @@
                 if ( (signed int)pButtonPtr_1C->uY <= 480 )
                 {
                   pTexture2 = pButtonPtr_1C->pTextures[0];
-                  goto LABEL_94;
+                  //goto LABEL_94;
+                 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
+                 pHint1 = pWindow->Hint;
+                 viewparams->bRedrawGameUI = 1;
+                if ( pHint1 )
+                {
+                  v24 = pHint1 == (char *)1;
+                  if ( !v24 )
+                    pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
+                }
+                pGUIWindow2 = pWindow;
+                pGUIWindow2->Release();
+                continue;
                 }
               }
             }
           }
-          v23 = pWindow->Hint;
+          pHint1 = pWindow->Hint;
           viewparams->bRedrawGameUI = 1;
-          if ( v23 )
-          {
-            v24 = v23 == (char *)1;
-            goto LABEL_82;
+          if ( pHint1 )
+          {
+            v24 = pHint1 == (char *)1;
+            //goto LABEL_82;
+            if ( !v24 )
+              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
+            pGUIWindow2 = pWindow;
+            pGUIWindow2->Release();
+            continue;
           }
 //LABEL_134:
           pGUIWindow2 = pWindow;
           //goto LABEL_110;
-		  pGUIWindow2->Release();
+          pGUIWindow2->Release();
           continue;
         }
         v17 = v16 - 1;
-        if ( !v17 )
+        if ( !v17 )//pWindowType == 91
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
           pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
           pTexture2 = pButtonPtr_1C->pTextures[1];
-LABEL_94:
+//LABEL_94:
           pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
-LABEL_80:
-          v23 = pWindow->Hint;
+//LABEL_80:
+          pHint1 = pWindow->Hint;
           viewparams->bRedrawGameUI = 1;
-          if ( v23 )
-          {
-            v24 = v23 == (char *)1;
-LABEL_82:
+          if ( pHint1 )
+          {
+            v24 = pHint1 == (char *)1;
+//LABEL_82:
             if ( !v24 )
-              pButtonPtr_1C->DrawLabel(v23, pFontCreate, 0, 0);
+              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
           }
           //goto LABEL_134;
-		  pGUIWindow2 = pWindow;
+          pGUIWindow2 = pWindow;
           //goto LABEL_110;
-		  pGUIWindow2->Release();
+          pGUIWindow2->Release();
           continue;
         }
         v18 = v17 - 1;
-        if ( !v18 )
+        if ( !v18 )//pWindowType == 92
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
           pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
           pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButtonPtr_1C->pTextures[0]);
-          goto LABEL_80;
+          //goto LABEL_80;
+          pHint1 = pWindow->Hint;
+          viewparams->bRedrawGameUI = 1;
+          if ( pHint1 )
+          {
+            v24 = pHint1 == (char *)1;
+            if ( !v24 )
+              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
+          }
+          pGUIWindow2 = pWindow;
+          pGUIWindow2->Release();
+          continue;
         }
         v19 = v18 - 1;
-        if ( !v19 )
+        if ( !v19 )//pWindowType == 93
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
           pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16));
           viewparams->bRedrawGameUI = 1;
           //goto LABEL_134;
-		  pGUIWindow2 = pWindow;
+          pGUIWindow2 = pWindow;
           //goto LABEL_110;
-		  pGUIWindow2->Release();
-          continue;
-        }
-      }
-      else
+          pGUIWindow2->Release();
+          continue;
+        }
+      }
+      else//pWindowType == 80
       {
         v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
         if ( ptr_507BD0->field_40 == 1 )
@@ -14737,7 +15112,7 @@
           ptr_507BD0->Release();
           pCurrentScreen = 0;
           //goto LABEL_114;
-		  viewparams->bRedrawGameUI = 1;
+          viewparams->bRedrawGameUI = 1;
           continue;
         }
         if ( ptr_507BD0->field_40 == 3 )
@@ -14763,12 +15138,12 @@
         if ( (signed int)pWindowType > 25 )
         {
           v12 = pWindowType - 26;
-          if ( v12 )
+          if ( v12 )// pWindowType > 26
           {
             v13 = v12 - 4;
-            if ( v13 )
-            {
-              if ( v13 == 1 )
+            if ( v13 )//pWindowType > 30
+            {
+              if ( v13 == 1 ) //pWindowType == 31
               {
                 pRenderer->ClearZBuffer(0, 479);
                 draw_leather();
@@ -14778,12 +15153,12 @@
                   (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
               }
             }
-            else
+            else// pWindowType == 30
             {
               sub_467FB6();
             }
           }
-          else
+          else //pWindowType == 26
           {
             TransitionUI_Draw();
           }
@@ -14792,23 +15167,23 @@
         if ( pWindowType != 25 )
         {
           v7 = pWindowType - 19;
-          if ( v7 )
+          if ( v7 )// pWindowType > 19
           {
             v8 = v7 - 1;
-            if ( v8 )
+            if ( v8 )// pWindowType > 20
             {
               v9 = v8 - 3;
-              if ( v9 )
+              if ( v9 )//pWindowType > 23
               {
-                //if ( v9 == 1 )
+                //if ( v9 == 1 ) //pWindowType == 24
                 //  sub_4606F7();
               }
-              else
+              else//pWindowType == 23
               {
                 sub_4606FE();
               }
             }
-            else
+            else//pWindowType == 20
             {
               if ( pCurrentScreen == 10 )
               {
@@ -14827,7 +15202,7 @@
               }
             }
           }
-          else
+          else//pWindowType == 19
           {
             DrawBranchlessDialogueUI();
           }
@@ -14852,7 +15227,17 @@
           }
           continue;
         }
-        goto LABEL_142;
+        //goto LABEL_142;
+        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        {
+         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
+         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+         ++pMessageQueue_50CBD0->uNumMessages;
+         continue;
+        }
+        continue;
       }
       if ( pWindowType == 18 )
       {
@@ -14863,20 +15248,20 @@
         if ( (signed int)pWindowType > 10 )
         {
           v5 = pWindowType - 12;
-          if ( v5 )
+          if ( v5 )//pWindowType >12
           {
             v6 = v5 - 4;
-            if ( v6 )
-            {
-              if ( v6 == 1 )
+            if ( v6 )//pWindowType > 16
+            {
+              if ( v6 == 1 )//pWindowType == 17
                 TravelUI_Draw();
             }
-            else
+            else//pWindowType == 16
             {
               RestUI_Draw();
             }
           }
-          else
+          else// pWindowType == 12
           {
             QuickRefDraw();
           }
@@ -14885,33 +15270,33 @@
         if ( pWindowType != 10 )
         {
           v2 = pWindowType - 3;
-          if ( v2 )
+          if ( v2 )//pWindowType > 3
           {
             v3 = v2 - 1;
-            if ( v3 )
+            if ( v3 )// pWindowType > 4
             {
               v4 = v3 - 2;
-              if ( v4 )
+              if ( v4 )//pWindowType > 6
               {
-                if ( v4 == 3 )
+                if ( v4 == 3 )//pWindowType == 9
                   DrawSpellbook((unsigned int)pWindow->ptr_1C);
               }
-              else
+              else//pWindowType == 6
               {
                 sub_414F82_DrawGameOptions();
               }
             }
-            else
+            else//pWindowType == 4
             {
               CharacterUI_CharacterScreen_Draw(uActiveCharacter);
             }
             continue;
           }
-          pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);
+          pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);//pWindowType == 3
           pY = pViewport->uViewportY;
           pX = pViewport->uViewportX;
           //goto LABEL_18;
-		  pRenderer->DrawTextureIndexed(pX, pY, pTexture);
+          pRenderer->DrawTextureIndexed(pX, pY, pTexture);
           viewparams->bRedrawGameUI = 1;
           continue;
         }