changeset 11:66319a734368

16.01.13(work)
author Ritor1
date Wed, 16 Jan 2013 17:31:56 +0600
parents 40f6ac8fbe39
children c941f63cdbfc b4982f23d2e9
files AudioPlayer.cpp GUIWindow.cpp GUIWindow.h Game.cpp mm7_1.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 9 files changed, 707 insertions(+), 668 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/AudioPlayer.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -1355,7 +1355,7 @@
 //----- (004AAFCF) --------------------------------------------------------
 void AudioPlayer::_4AAFCF()
 {
-  AudioPlayer *v1; // edi@1
+  AudioPlayer *pAudioPlayer; // edi@1
   int v2; // ebx@1
   unsigned __int8 v3; // zf@1
   int *v4; // eax@2
@@ -1416,7 +1416,7 @@
   int v59; // [sp+64h] [bp-8h]@4
   AudioPlayer *thisa; // [sp+68h] [bp-4h]@1
 
-  v1 = this;
+  pAudioPlayer = this;
   v2 = 0;
   thisa = this;
   v3 = this->bPlayerReady == 0;
@@ -1443,7 +1443,7 @@
             if ( AIL_3D_sample_status(v6->hSample) == 2 )
             {
               AIL_end_3D_sample(v6->hSample);
-              v1->_4ABF23(v6);
+              pAudioPlayer->_4ABF23(v6);
             }
             if ( AIL_3D_sample_status(v6->hSample) != 4 )
               goto LABEL_35;
@@ -1466,7 +1466,7 @@
 LABEL_35:
             ++v59;
             ++v6;
-            if ( v59 >= v1->uNum3DSamples )
+            if ( v59 >= pAudioPlayer->uNum3DSamples )
             {
               v2 = 0;
               goto LABEL_37;
@@ -1569,36 +1569,36 @@
           else
           {
             AIL_end_3D_sample(v6->hSample);
-            v1->_4ABF23(v6);
+            pAudioPlayer->_4ABF23(v6);
           }
           goto LABEL_35;
         }
       }
 LABEL_37:
-      if ( v1->uMixerChannels > v2 )
+      if ( pAudioPlayer->uMixerChannels > v2 )
       {
-        v28 = v1->pMixerChannels;
+        v28 = pAudioPlayer->pMixerChannels;
         do
         {
           if ( AIL_sample_status(v28->hSample) == 2 )
           {
             AIL_end_sample(v28->hSample);
-            v1->_4ABE55(v28);
+            pAudioPlayer->_4ABE55(v28);
           }
           ++v2;
           ++v28;
         }
-        while ( v2 < v1->uMixerChannels );
+        while ( v2 < pAudioPlayer->uMixerChannels );
         v2 = 0;
       }
       //v29 = __OFSUB__(v1->uMixerChannels, v2);
-	  v29 = v1->uMixerChannels > v2;
-      v3 = v1->uMixerChannels == v2;
-      v5 = v1->uMixerChannels - v2 < 0;
+      v29 = pAudioPlayer->uMixerChannels > v2;
+      v3 = pAudioPlayer->uMixerChannels == v2;
+      v5 = pAudioPlayer->uMixerChannels - v2 < 0;
       v59 = v2;
       if ( !((unsigned __int8)(v5 ^ v29) | v3) )
       {
-        v30 = v1->pMixerChannels;
+        v30 = pAudioPlayer->pMixerChannels;
         while ( 1 )
         {
           v31 = v30->dword_000004;
@@ -1610,7 +1610,7 @@
               if ( !v39->uDoorID )
               {
 LABEL_61:
-                v1 = thisa;
+                pAudioPlayer = thisa;
                 goto LABEL_62;
               }
               v40 = GetSoundStrengthByDistanceFromParty(*v39->pXOffsets, *v39->pYOffsets, *v39->pZOffsets);
@@ -1665,7 +1665,7 @@
 LABEL_62:
           ++v59;
           ++v30;
-          if ( v59 >= v1->uMixerChannels )
+          if ( v59 >= pAudioPlayer->uMixerChannels )
           {
             v2 = 0;
             break;
@@ -1674,7 +1674,7 @@
       }
       if ( pCurrentScreen != v2 )
       {
-        v42 = &v1->pMixerChannels[4];
+        v42 = &pAudioPlayer->pMixerChannels[4];
         if ( AIL_sample_status(v42->hSample) == 4 )
           AIL_end_sample(v42->hSample);
         return;
--- a/GUIWindow.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/GUIWindow.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -317,7 +317,7 @@
     if ( !v5 )
     {
       pIcons_LOD->_40F9C5();
-      pCurrentScreen = dword_506978;
+      pCurrentScreen = pMainScreenNum;
       pKeyActionMap->_459ED1(3);
       goto LABEL_26;
     }
@@ -379,7 +379,7 @@
         pTexture_Dialogue_Background->Release();
         pIcons_LOD->_40F9C5();
 LABEL_19:
-        pCurrentScreen = dword_506978;
+        pCurrentScreen = pMainScreenNum;
         goto LABEL_26;
       }
       OnCloseSpellook();
@@ -1177,118 +1177,65 @@
 
 
 //----- (00411621) --------------------------------------------------------
-GUIButton *GUIWindow::_411621()
+GUIButton *GUIWindow::OpenSpellBook()
 {
-  Player *v1; // edi@1
-  GUIWindow *v2; // esi@1
+  Player *pPlayer; // edi@1
+  GUIWindow *pWindow; // esi@1
   unsigned int v3; // ebp@1
   int v4; // eax@3
   GUIButton *result; // eax@25
   int a2; // [sp+10h] [bp-8h]@1
   int v7; // [sp+14h] [bp-4h]@1
 
-  __debugbreak();
+  //__debugbreak();
 
-  v1 = pPlayers[uActiveCharacter];
-  v2 = this;
-  LoadSpellbook(v1->pNumSpellBookPage);
+  pPlayer = pPlayers[uActiveCharacter];
+  pWindow = this;
+  LoadSpellbook(pPlayer->pNumSpellBookPage);
   v3 = 0;
   a2 = 0;
-  v7 = (int)(&v1->spellbook.pFireSpellbook + v1->pNumSpellBookPage);
+  v7 = (int)(&pPlayer->spellbook.pFireSpellbook + pPlayer->pNumSpellBookPage);
   do
   {
     if ( *(char *)(v7 + v3) )
     {
-      v4 = 2 * (12 * v1->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2431[12 * v1->pNumSpellBookPage] + v3));
-      v2->CreateButton(
-        pViewport->uViewportX + dword_4E20D0[v4],
+      v4 = 2 * (12 * pPlayer->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2431[12 * pPlayer->pNumSpellBookPage] + v3));
+      pWindow->CreateButton(pViewport->uViewportX + dword_4E20D0[v4],
         pViewport->uViewportY + dword_4E20D0[v4 + 1],
         *(short *)(dword_50640C[v3] + 24),
         *(short *)(dword_50640C[v3] + 26),
-        1,
-        79,
-        0x56u,
-        v3,
-        0,
-        "",
-        0);
+        1, 79, 0x56u, v3, 0, "", 0);
       ++a2;
     }
     ++v3;
   }
   while ( (signed int)v3 < 11 );
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
+  pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
   if ( a2 )
-    v2->_41D08F(a2, 0, 0, 0);
-  if ( v1->pActiveSkills[12] )
-    v2->CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, 0x57u, 0, 0, aSpellSchoolNames[0], 0);
-  if ( v1->pActiveSkills[13] )
-    v2->CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, 0x57u, 1u, 0, aSpellSchoolNames[1], 0);
-  if ( v1->pActiveSkills[14] )
-    v2->CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, 0x57u, 2u, 0, aSpellSchoolNames[2], 0);
-  if ( v1->pActiveSkills[15] )
-    v2->CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, 0x57u, 3u, 0, aSpellSchoolNames[3], 0);
-  if ( v1->pActiveSkills[16] )
-    v2->CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, 0x57u, 4u, 0, aSpellSchoolNames[4], 0);
-  if ( v1->pActiveSkills[17] )
-    v2->CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, 0x57u, 5u, 0, aSpellSchoolNames[5], 0);
-  if ( v1->pActiveSkills[18] )
-    v2->CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, 0x57u, 6u, 0, aSpellSchoolNames[6], 0);
-  if ( v1->pActiveSkills[19] )
-    v2->CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, 0x57u, 7u, 0, aSpellSchoolNames[7], 0);
-  if ( v1->pActiveSkills[20] )
-    v2->CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, 0x57u, 8u, 0, aSpellSchoolNames[8], 0);
-  v2->CreateButton(
-    0x1DCu,
-    0x1C2u,
-    pTexture_506444->uTextureWidth,
-    pTexture_506444->uTextureHeight,
-    1,
-    78,
-    0x58u,
-    0,
-    0,
-    "",
-    0);
-  pBtn_InstallRemoveSpell = v2->CreateButton(
-                 0x1DCu,
-                 0x1C2u,
-                 0x30u,
-                 0x20u,
-                 1,
-                 78,
-                 0x58u,
-                 0,
-                 0,
-                 "",
-                 pTexture_506444,
-                 0);
-  v2->CreateButton(
-    0x231u,
-    0x1C2u,
-    ptr_506440->uTextureWidth,
-    ptr_506440->uTextureHeight,
-    1,
-    0,
-    0x71u,
-    0,
-    0,
-    pGlobalTXT_LocalizationStrings[79],
-    0);
-  result = v2->CreateButton(
-             0x231u,
-             0x1C2u,
-             0x30u,
-             0x20u,
-             1,
-             0,
-             0x71u,
-             0,
-             0,
-             pGlobalTXT_LocalizationStrings[79],
-             ptr_506440,
-             0);
-  pBtn_CloseBook = result;
+    pWindow->_41D08F(a2, 0, 0, 0);
+  if ( pPlayer->pActiveSkills[12] )
+    pWindow->CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, 0x57u, 0, 0, aSpellSchoolNames[0], 0);
+  if ( pPlayer->pActiveSkills[13] )
+    pWindow->CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, 0x57u, 1u, 0, aSpellSchoolNames[1], 0);
+  if ( pPlayer->pActiveSkills[14] )
+    pWindow->CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, 0x57u, 2u, 0, aSpellSchoolNames[2], 0);
+  if ( pPlayer->pActiveSkills[15] )
+    pWindow->CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, 0x57u, 3u, 0, aSpellSchoolNames[3], 0);
+  if ( pPlayer->pActiveSkills[16] )
+    pWindow->CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, 0x57u, 4u, 0, aSpellSchoolNames[4], 0);
+  if ( pPlayer->pActiveSkills[17] )
+    pWindow->CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, 0x57u, 5u, 0, aSpellSchoolNames[5], 0);
+  if ( pPlayer->pActiveSkills[18] )
+    pWindow->CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, 0x57u, 6u, 0, aSpellSchoolNames[6], 0);
+  if ( pPlayer->pActiveSkills[19] )
+    pWindow->CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, 0x57u, 7u, 0, aSpellSchoolNames[7], 0);
+  if ( pPlayer->pActiveSkills[20] )
+    pWindow->CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, 0x57u, 8u, 0, aSpellSchoolNames[8], 0);
+  pWindow->CreateButton(0x1DCu, 0x1C2u, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, 0x58u, 0, 0, "", 0);
+  pBtn_InstallRemoveSpell = pWindow->CreateButton(0x1DCu, 0x1C2u, 0x30u, 0x20u, 1, 78, 0x58u, 0, 0, "", pTexture_506444, 0);
+  pWindow->CreateButton(0x231u, 0x1C2u, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
+  pBtn_CloseBook = pWindow->CreateButton(0x231u, 0x1C2u, 0x30u, 0x20u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
+  result = pBtn_CloseBook;
   return result;
 }
 // 50640C: using guessed type int dword_50640C[];
@@ -2076,7 +2023,7 @@
 
 
 //----- (0041C432) --------------------------------------------------------
-GUIWindow *GUIWindow::Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, WindowType eWindowType, int a4, int a5)
+GUIWindow *GUIWindow::Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, WindowType eWindowType, int pButton, int a5)
 {
   unsigned int uNextFreeWindowID; // ebp@1
   //int *v8; // eax@1
@@ -2116,7 +2063,7 @@
   pWindow->uFrameWidth = uWidth;
   pWindow->uFrameZ = uX + uWidth - 1;
   pWindow->uFrameW = uY + uHeight - 1;
-  pWindow->ptr_1C = (void *)a4;
+  pWindow->ptr_1C = (void *)pButton;
   pWindow->Hint = (char *)a5;
   v10 = uNumVisibleWindows;
   pWindow->uFrameX = uX;
@@ -2138,21 +2085,10 @@
           pWindow->InitializeBookView();
           break;
         case WINDOW_A:
-          dword_506978 = pCurrentScreen;
+          pMainScreenNum = pCurrentScreen;
           pCurrentScreen = 4;
-          pBtn_ExitCancel = pWindow->CreateButton(
-                         0x1D7u,
-                         0x1BDu,
-                         0xA9u,
-                         0x23u,
-                         1,
-                         0,
-                         0x71u,
-                         0,
-                         0,
-                         pGlobalTXT_LocalizationStrings[79], //"Exit"
-                         (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
-                         0);
+          pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit"
+                         (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
           if ( pWindow->ptr_1C != (void *)1 )
           {
             a4a = 0;
@@ -2162,7 +2098,7 @@
             {
               if ( v12->joins )
               {
-                pWindow->CreateButton(0x1E0u, 0x82u, 0x8Cu, v11, 1, 0, 0x88u, 0xDu, 0, "", 0);
+                pWindow->CreateButton(480, 130, 140, v11, 1, 0, 0x88u, 0xDu, 0, "", 0);
                 a4a = 1;
               }
               v13 = (void *)v12->bDrawSomeAnim;
@@ -2172,18 +2108,7 @@
                 {
                   v14 = sub_4466C4(v13);
                   if ( v14 == 1 || v14 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x13u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x13u, 0, "", 0);
                 }
               }
               v15 = (void *)v12->evtb;
@@ -2193,18 +2118,7 @@
                 {
                   v16 = sub_4466C4(v15);
                   if ( v16 == 1 || v16 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x14u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x14u, 0, "", 0);
                 }
               }
               v17 = (void *)v12->evtc;
@@ -2214,18 +2128,7 @@
                 {
                   v18 = sub_4466C4(v17);
                   if ( v18 == 1 || v18 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x15u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton( 0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x15u, 0, "", 0);
                 }
               }
               v19 = (void *)v12->evtd;
@@ -2235,18 +2138,7 @@
                 {
                   v20 = sub_4466C4(v19);
                   if ( v20 == 1 || v20 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x16u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x16u, 0, "", 0);
                 }
               }
               v21 = (void *)v12->evte;
@@ -2256,18 +2148,7 @@
                 {
                   v22 = sub_4466C4(v21);
                   if ( v22 == 1 || v22 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x17u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x17u, 0, "", 0);
                 }
               }
               v23 = (void *)v12->evtf;
@@ -2277,18 +2158,7 @@
                 {
                   v24 = sub_4466C4(v23);
                   if ( v24 == 1 || v24 == 2 )
-                    pWindow->CreateButton(
-                      0x1E0u,
-                      a4a++ * v11 + 130,
-                      0x8Cu,
-                      v11,
-                      1,
-                      0,
-                      0x88u,
-                      0x18u,
-                      0,
-                      "",
-                      0);
+                    pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x18u, 0, "", 0);
                 }
               }
             }
@@ -2296,37 +2166,15 @@
             {
               if ( v12->joins )
               {
-                pWindow->CreateButton(
-                  0x1E0u,
-                  0x82u,
-                  0x8Cu,
-                  v11,
-                  1,
-                  0,
-                  0x88u,
-                  0x4Du,
-                  0,
-                  pGlobalTXT_LocalizationStrings[407],
-                  0);
+                pWindow->CreateButton(0x1E0u, 0x82u, 0x8Cu, v11, 1, 0, 0x88u, 0x4Du, 0, pGlobalTXT_LocalizationStrings[407], 0);//Подробнее
                 if ( v12->uFlags & 0x80 )
                 {
-                  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName);
+                  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName); //Отпустить
                   pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pTmpBuf, 0);
                 }
                 else
                 {
-                  pWindow->CreateButton(
-                    0x1E0u,
-                    v11 + 130,
-                    0x8Cu,
-                    v11,
-                    1,
-                    0,
-                    0x88u,
-                    0x4Cu,
-                    0,
-                    pGlobalTXT_LocalizationStrings[406],
-                    0);
+                  pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pGlobalTXT_LocalizationStrings[406], 0);//Нанять
                 }
                 a4a = 2;
               }
@@ -2334,64 +2182,29 @@
             pWindow->_41D08F(a4a, 1, 0, 1);
           }
           break;
-        case WINDOW_11:
-          dword_506978 = pCurrentScreen;
+        case WINDOW_ChangeLocation:
+          pMainScreenNum = pCurrentScreen;
           pCurrentScreen = 17;
-          pBtn_ExitCancel = pWindow->CreateButton(
-                         0x236u,
-                         0x1BDu,
-                         0x4Bu,
-                         0x21u,
-                         1,
-                         0,
-                         0x5Bu,
-                         0,
-                         0x4Eu,
-                         pGlobalTXT_LocalizationStrings[156],
-                         (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
-                         0);
-          pBtn_YES = pWindow->CreateButton(
-                         0x1E6u,
-                         0x1BDu,
-                         0x4Bu,
-                         0x21u,
-                         1,
-                         0,
-                         0x5Au,
-                         0,
-                         0x59u,
-                         pWindow->Hint,
-                         (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
-                         0);
-          pWindow->CreateButton(
-            _4E5E50_transui_x,
-            _4E5EE0_transui_y,
-            0x3Fu,
-            0x49u,
-            1,
-            0,
-            0x5Au,
-            1u,
-            0x20u,
-            pWindow->Hint,
-            0,
-            0,
-            0);
+          pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Bu, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[156],//Остаться в этой области
+                         (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+          pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Au, 0, 0x59u, pWindow->Hint,
+                         (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0);
+          pWindow->CreateButton(_4E5E50_transui_x, _4E5EE0_transui_y, 0x3Fu, 0x49u, 1, 0, 0x5Au, 1u, 0x20u, pWindow->Hint, 0, 0, 0);
           pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->Hint, 0);
           break;
-        case WINDOW_12:
+        case WINDOW_SpellBook: // окно книги заклов
           InitializeBookTextures();
-          pWindow->_411621();
+          pWindow->OpenSpellBook();
           break;
-        case WINDOW_13:
-          dword_506978 = pCurrentScreen;
+        case WINDOW_GreetingNPC: // окно приветствия НПС
+          pMainScreenNum = pCurrentScreen;
           pKeyActionMap->EnterText(0, 15, pWindow);
           pCurrentScreen = 19;
           break;
       }
       return pWindow;
     }
-LABEL_62:
+//LABEL_62:
     pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
     pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
     pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
@@ -2402,19 +2215,8 @@
   if (eWindowType == WINDOW_HouseInterior)
   {
     pCurrentScreen = 13;
-    pBtn_ExitCancel = pWindow->CreateButton(
-                   0x1D7u,
-                   0x1BDu,
-                   0xA9u,
-                   0x23u,
-                   1,
-                   0,
-                   0x71u,
-                   0,
-                   0,
-                   pGlobalTXT_LocalizationStrings[80],
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
-                   0);
+    pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[80],//Выйти из здания
+                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
     v25 = uNumDialogueNPCPortraits;
     v26 = 0;
     if ( uNumDialogueNPCPortraits > 0 )
@@ -2425,7 +2227,7 @@
         if ( v26 + 1 == v25 && uHouse_ExitPic )
         {
           v30 = pMapStats->pInfos[uHouse_ExitPic].pName;
-          v29 = pGlobalTXT_LocalizationStrings[411];
+          v29 = pGlobalTXT_LocalizationStrings[411];//Войти в ^Pv[%s]
         }
         else
         {
@@ -2433,25 +2235,14 @@
             v27 = array_5913D8[v26 - (dword_591080 != 0)]->pName;
           else
             //v27 = (char *)p2DEvents_minus1_::08[13 * a4];
-            v27 = (char *)p2DEvents[a4 - 1].pProprieterName;
+            v27 = (char *)p2DEvents[pButton - 1].pProprieterName;
           v30 = v27;
-          v29 = pGlobalTXT_LocalizationStrings[435];
+          v29 = pGlobalTXT_LocalizationStrings[435];//Побеседовать с ^Pt[%s]
         }
         sprintf(&byte_591180[100 * v26], v29, v30);
-        array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(
-                                             *(&_4E5E50_transui_x + v26 + 6 * uNumDialogueNPCPortraits - 6),
+        array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(*(&_4E5E50_transui_x + v26 + 6 * uNumDialogueNPCPortraits - 6),
                                              *(&_4E5EE0_transui_y + v26 + 6 * uNumDialogueNPCPortraits - 6),
-                                             0x3Fu,
-                                             0x49u,
-                                             1,
-                                             0,
-                                             0x19Au,
-                                             v26,
-                                             0,
-                                             &byte_591180[100 * v26],
-                                             0,
-                                             0,
-                                             0);
+                                             0x3Fu, 0x49u, 1, 0, 0x19Au, v26, 0, &byte_591180[100 * v26], 0, 0, 0);
         ++v26;
         v25 = uNumDialogueNPCPortraits;
       }
@@ -2467,46 +2258,13 @@
   {
     if (eWindowType == WINDOW_1A)
     {
-      dword_506978 = pCurrentScreen;
+      pMainScreenNum = pCurrentScreen;
       pCurrentScreen = 18;
-      pBtn_ExitCancel = pWindow->CreateButton(
-                     0x236u,
-                     0x1BDu,
-                     0x4Bu,
-                     0x21u,
-                     1,
-                     0,
-                     0x19Cu,
-                     0,
-                     0x4Eu,
-                     pGlobalTXT_LocalizationStrings[34],
-                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
-                     0);
-      pBtn_YES = pWindow->CreateButton(
-                     0x1E6u,
-                     0x1BDu,
-                     0x4Bu,
-                     0x21u,
-                     1,
-                     0,
-                     0x19Bu,
-                     0,
-                     0x59u,
-                     pWindow->Hint,
-                     (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
-                     0);
-      pWindow->CreateButton(
-        _4E5E50_transui_x,
-        _4E5EE0_transui_y,
-        0x3Fu,
-        0x49u,
-        1,
-        0,
-        0x19Bu,
-        1u,
-        0x20u,
-        pWindow->Hint,
-        0);
+      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Cu, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],//Отмена
+                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+      pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Bu, 0, 0x59u, pWindow->Hint,
+                     (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0);
+      pWindow->CreateButton(_4E5E50_transui_x, _4E5EE0_transui_y, 0x3Fu, 0x49u, 1, 0, 0x19Bu, 1, 0x20u, pWindow->Hint, 0);
       pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->Hint, 0);
       return pWindow;
     }
@@ -2515,28 +2273,25 @@
       pEventTimer->Pause();
       pAudioPlayer->StopChannels(-1, -1);
       pMouse->SetCursorBitmap("MICON2");
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);//Выберите цель
       return pWindow;
     }
     if (eWindowType == WINDOW_1E)
-      goto LABEL_62;
+      //goto LABEL_62;
+    {
+      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+      pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+      return pWindow;
+    }
     if (eWindowType == WINDOW_1F)
     {
       pMouse->SetCursorBitmap("MICON2");
-      pBtn_ExitCancel = pWindow->CreateButton(
-                     0x188u,
-                     0x13Eu,
-                     0x4Bu,
-                     0x21u,
-                     1,
-                     0,
-                     0x71u,
-                     0,
-                     0,
-                     pGlobalTXT_LocalizationStrings[34],
-                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
-                     0);
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);
+      pBtn_ExitCancel = pWindow->CreateButton(0x188u, 0x13Eu, 0x4Bu, 0x21u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34],//Отмена
+                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);//Выбрать цель
       ++pIcons_LOD->uTexturePacksCount;
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
       pCurrentScreen = 23;
--- a/GUIWindow.h	Wed Jan 16 09:25:57 2013 +0600
+++ b/GUIWindow.h	Wed Jan 16 17:31:56 2013 +0600
@@ -38,9 +38,9 @@
   WINDOW_Options = 0x6,
   WINDOW_Book = 0x9,
   WINDOW_A = 10,
-  WINDOW_11 = 17,
-  WINDOW_12 = 18,
-  WINDOW_13 = 19,
+  WINDOW_ChangeLocation = 17,
+  WINDOW_SpellBook = 18,
+  WINDOW_GreetingNPC = 19,
   WINDOW_Chest = 0x14,
   WINDOW_MainMenu_Load = 0x18,
   WINDOW_HouseInterior = 0x19,
@@ -68,7 +68,7 @@
   char *DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
   char *_4B1854(__int64 a2);
   void _4B3157();
-  GUIButton *_411621();
+  GUIButton *OpenSpellBook();
   void InitializeBookView();
   void DrawMessageBox(int arg0);
   GUIButton *GetControl(unsigned int uID);
@@ -137,6 +137,7 @@
   UIMSG_ShowStatus_Player = 0x5E,
   UIMSG_ShowStatus_Food = 0x64,
   UIMSG_ShowStatus_Funds = 0x65,
+  UIMSG_QuickReference = 0x6A,
   UIMSG_6B = 0x6B,
   UIMSG_SelectCharacter = 0x6E,
   UIMSG_ChangeSoundVolume = 0x6F,
--- a/Game.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/Game.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -321,7 +321,7 @@
         v16 = 0;
         viewparams->bRedrawGameUI = true;
       }
-      //pAudioPlayer->_4AAFCF();Ritor1: it's temporarily
+      //pAudioPlayer->_4AAFCF();//Ritor1: it's temporarily, game crash
       if (uGameState == 1)
         //goto LABEL_96;
       {
--- a/mm7_1.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_1.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -5025,7 +5025,7 @@
 
   pMouse->uPointingObjectID = 0;
   pMouse->GetClickPos(&pX, &pY);
-  if ( pX || (signed int)pX > 639 || pY || (signed int)pY > 479 )
+  if ( pX || (signed int)pX > 639 || pY || (signed int)pY > 479 )//( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 )
     return;
   if ( !pCurrentScreen )
   {
@@ -5646,7 +5646,7 @@
 GUIWindow *GameUI_InitializeCharacterWindow(unsigned int _this)
 {
   unsigned int v1; // edi@1
-  GUIWindow *v2; // edi@3
+  GUIWindow *pWindow; // edi@3
 
   ++pIcons_LOD->uTexturePacksCount;
   v1 = _this;
@@ -5657,98 +5657,47 @@
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = v1;
-  v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
-  pCharacterScreen_StatsBtn = v2->CreateButton(
-                                pViewport->uViewportX + 12,
-                                pViewport->uViewportY + 308,
+  pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
+  pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportX + 12, pViewport->uViewportY + 308,
                                 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
                                 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
-                                1,
-                                0,
-                                0x73u,
-                                0,
-                                0x53u,
-                                pGlobalTXT_LocalizationStrings[216],
+                                1, 0, 0x73u, 0, 0x53u, pGlobalTXT_LocalizationStrings[216],// Stats
                                 (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
-                                papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0,
-                                0);
-  pCharacterScreen_SkillsBtn = v2->CreateButton(
-                                 pViewport->uViewportX + 102,
-                                 pViewport->uViewportY + 308,
+                                papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0, 0);
+  pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportX + 102, pViewport->uViewportY + 308,
                                  (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
                                  (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
-                                 1,
-                                 0,
-                                 0x72u,
-                                 0,
-                                 0x4Bu,
-                                 pGlobalTXT_LocalizationStrings[205],
+                                 1, 0, 0x72u, 0, 0x4Bu, pGlobalTXT_LocalizationStrings[205],//Skills
                                  (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
-                                 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0,
-                                 0);
-  pCharacterScreen_InventoryBtn = v2->CreateButton(
-                                    pViewport->uViewportX + 192,
-                                    pViewport->uViewportY + 308,
+                                 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0, 0);
+  pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportX + 192, pViewport->uViewportY + 308,
                                     (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
                                     (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
-                                    1,
-                                    0,
-                                    0x74u,
-                                    0,
-                                    0x49u,
-                                    pGlobalTXT_LocalizationStrings[120],
+                                    1, 0, 0x74u, 0, 0x49u, pGlobalTXT_LocalizationStrings[120], //Inventory
                                     (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
-                                    papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0,
-                                    0);
-  pCharacterScreen_AwardsBtn = v2->CreateButton(
-                                 pViewport->uViewportX + 282,
-                                 pViewport->uViewportY + 308,
+                                    papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0, 0);
+  pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportX + 282, pViewport->uViewportY + 308,
                                  (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
                                  (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
-                                 1,
-                                 0,
-                                 0x75u,
-                                 0,
-                                 0x41u,
-                                 pGlobalTXT_LocalizationStrings[22],
+                                 1, 0, 0x75u, 0, 0x41u, pGlobalTXT_LocalizationStrings[22], //Awards
                                  (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
-                                 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0,
-                                 0);
-  pCharacterScreen_ExitBtn = v2->CreateButton(
-                 pViewport->uViewportX + 371,
-                 pViewport->uViewportY + 308,
+                                 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0, 0);
+  pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportX + 371, pViewport->uViewportY + 308,
                  (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
                  (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
-                 1,
-                 0,
-                 0xA8u,
-                 0,
-                 0,
-                 pGlobalTXT_LocalizationStrings[79],
+                 1, 0, 0xA8u, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
-                 0);
-  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
-  pCharacterScreen_DetalizBtn = v2->CreateButton(
-                 0x258u,
-                 0x12Cu,
-                 0x1Eu,
-                 0x1Eu,
-                 1,
-                 0,
-                 0x55u,
-                 0,
-                 0,
-                 pGlobalTXT_LocalizationStrings[64],
-                 0);
-  pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
-  v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-  v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-  v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-  v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0, 0);
+  pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
+  pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 0x1Eu, 0x1Eu, 1, 0, 0x55u, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
+  pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
+  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
   sub_419100();
-  return v2;
+  return pWindow;
 }
 
 
@@ -5923,9 +5872,15 @@
   {
     viewparams->bRedrawGameUI = 1;
     if ( uActiveCharacter != v1 )
-      goto LABEL_27;
+      //goto LABEL_27;
+    {
+      if ( pPlayers[v1]->uTimeToRecovery )
+        return;
+      uActiveCharacter = v1;
+      return;
+    }
     v5 = 7;
-LABEL_22:
+//LABEL_22:
     pGUIWindow_CurrentMenu = GameUI_InitializeCharacterWindow(v5);
     return;
   }
@@ -5933,24 +5888,28 @@
     return;
   if ( pCurrentScreen == 10 )
   {
-LABEL_23:
+//LABEL_23:
     viewparams->bRedrawGameUI = 1;
     if ( uActiveCharacter == v1 )
     {
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
       pCurrentScreen = 15;
-      goto LABEL_28;
-    }
-LABEL_27:
+      //goto LABEL_28;
+      uActiveCharacter = v1;
+      return;
+    }
+//LABEL_27:
     if ( pPlayers[v1]->uTimeToRecovery )
       return;
-    goto LABEL_28;
+    //goto LABEL_28;
+    uActiveCharacter = v1;
+    return;
   }
   if ( pCurrentScreen != 13 )
   {
     if ( pCurrentScreen == 14 )
     {
-LABEL_28:
+//LABEL_28:
       uActiveCharacter = v1;
       return;
     }
@@ -5962,18 +5921,37 @@
         sub_419100();
       return;
     }
-    goto LABEL_23;
+    //goto LABEL_23;
+    viewparams->bRedrawGameUI = 1;
+    if ( uActiveCharacter == v1 )
+    {
+      pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+      pCurrentScreen = 15;
+      //goto LABEL_28;
+      uActiveCharacter = v1;
+      return;
+    }
+//LABEL_27:
+    if ( pPlayers[v1]->uTimeToRecovery )
+      return;
+    //goto LABEL_28;
+    uActiveCharacter = v1;
+    return;
   }
   if ( ptr_507BC0->field_40 == 1 )
     return;
   viewparams->bRedrawGameUI = 1;
   if ( uActiveCharacter != v1 )
-    goto LABEL_28;
+    //goto LABEL_28;
+    uActiveCharacter = v1;
+    return;
   if ( dword_F8B19C == 2 || dword_F8B19C == 6 )
   {
     pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
     v5 = 14;
-    goto LABEL_22;
+    //goto LABEL_22;
+    pGUIWindow_CurrentMenu = GameUI_InitializeCharacterWindow(v5);
+    return;
   }
 }
 // 4E28F8: using guessed type int pCurrentScreen;
--- a/mm7_5.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_5.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -459,7 +459,9 @@
           v162 = 0;
           v148 = 0;
           pWindowType = (WindowType)8;
-          goto LABEL_439;
+          //goto LABEL_439;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          continue;
         case UIMSG_ArrowUp:
           --pSaveListPosition;
           if ( pSaveListPosition < 0 )
@@ -472,7 +474,9 @@
           v137 = 17;
           v133 = 17;
           v9 = 215;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_DownArrow:
           ++pSaveListPosition;
           if ( pSaveListPosition >= uMessageParam )
@@ -485,7 +489,9 @@
           v137 = 17;
           v133 = 17;
           v9 = 215;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_Cancel:
           v163 = 0;
           v8 = 302;
@@ -494,7 +500,9 @@
           pWindowType1 = (WindowType)96;
           v137 = 42;
           v133 = 106;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_LoadSlot:
           v163 = 0;
           v8 = 302;
@@ -503,7 +511,9 @@
           pWindowType1 = (WindowType)94;
           v137 = 42;
           v133 = 106;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SelectLoadSlot:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
             pKeyActionMap->_459ED1(0);
@@ -691,7 +701,10 @@
           memset(word_506E6C, 0, 0x1Cu);
           word_506E6C[14] = 0;
           memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
-          goto LABEL_90;
+          //goto LABEL_90;
+          v1 = "";
+          v0 = 1;
+          continue;
         //default:
           //continue;
         case UIMSG_ResetKeyMapping|0x1:
@@ -808,7 +821,7 @@
           if ( uMessageParam == 4 )
           {
             --uGammaPos;
-            if ( (uGammaPos /*& 0x80000000u*/) != 0 )
+            if ( (uGammaPos & 0x80000000u) != 0 )
             {
               uGammaPos = 0;
               //goto LABEL_128;
@@ -1186,7 +1199,7 @@
 //LABEL_229:
               if ( dword_50CDC8 )
                 goto LABEL_232;
-              sub_42FC15();
+              CloseWindowBackground();
               //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
@@ -1198,13 +1211,13 @@
               //goto LABEL_229;
               if ( dword_50CDC8 )
                 goto LABEL_232;
-              sub_42FC15();
+              CloseWindowBackground();
               //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
             if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 )
             {
-              sub_42FC15();
+              CloseWindowBackground();
               dword_5C35C8 = 0;
 //LABEL_231:
               uMessageParam = v0;
@@ -1751,10 +1764,16 @@
               stru_506E40._40E55E("gamma.pcx", 0);
               continue;
             }
-            goto LABEL_333;
+            //goto LABEL_333;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           sub_41426F();
-//_continue:
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -1842,7 +1861,7 @@
             pParty->uTimePlayed += 1474560i64;
           continue;
         case 0x19C:
-          sub_42FC15();
+          CloseWindowBackground();
           pVideoPlayer->Unload();
           sub_44603D();
           dword_597F18 = 0;
@@ -1863,7 +1882,7 @@
           {
             viewparams->bRedrawGameUI = v0;
 LABEL_387:
-            sub_42FC15();
+            CloseWindowBackground();
             if ( pParty->vPosition.x < -22528 )
               pParty->vPosition.x = -22528;
             if ( pParty->vPosition.x > 22528 )
@@ -1971,15 +1990,44 @@
           if ( v45 == 3 )
           {
             v47 = pActors[v46].uAIState == Dead;
-            goto LABEL_400;
+            //goto LABEL_400;
+            if ( !v47 )
+              continue;
+            //goto LABEL_415;
+            v51 = pGUIWindow_Settings->ptr_1C;
+            *((char *)v51 + 8) &= 0xBFu;
+            *((short *)v51 + 2) = uMessageParam;
+            *((int *)v51 + 3) = v44;
+            pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+            pWindow3 = pGUIWindow_Settings;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           if ( v45 == 2 )
           {
             v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
-LABEL_400:
+//LABEL_400:
             if ( !v47 )
               continue;
-            goto LABEL_415;
+            //goto LABEL_415;
+            v51 = pGUIWindow_Settings->ptr_1C;
+            *((char *)v51 + 8) &= 0xBFu;
+            *((short *)v51 + 2) = uMessageParam;
+            *((int *)v51 + 3) = v44;
+            pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+            pWindow3 = pGUIWindow_Settings;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           if ( v45 == 5 )
           {
@@ -1995,7 +2043,20 @@
               if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
                 continue;
               v44 = uNumSeconds;
-              goto LABEL_415;
+              //goto LABEL_415;
+              v51 = pGUIWindow_Settings->ptr_1C;
+              *((char *)v51 + 8) &= 0xBFu;
+              *((short *)v51 + 2) = uMessageParam;
+              *((int *)v51 + 3) = v44;
+              pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+              pWindow3 = pGUIWindow_Settings;
+              pWindow3->Release();
+              pGUIWindow_Settings = 0;
+              pMouse->SetCursorBitmap("MICON1");
+              GameUI_StatusBar_TimedStringTimeLeft = 0;
+              unk_50C9A0 = 0;
+              back_to_game();
+              continue;
             }
             pBLVFace = &pIndoor->pFaces[v46];
             if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
@@ -2004,15 +2065,15 @@
           }
           if ( v48 )
             continue;
-LABEL_415:
+//LABEL_415:
           v51 = pGUIWindow_Settings->ptr_1C;
           *((char *)v51 + 8) &= 0xBFu;
-LABEL_416:
+//LABEL_416:
           *((short *)v51 + 2) = uMessageParam;
           *((int *)v51 + 3) = v44;
           pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
           pWindow3 = pGUIWindow_Settings;
-LABEL_333:
+//LABEL_333:
           pWindow3->Release();
           pGUIWindow_Settings = 0;
           pMouse->SetCursorBitmap("MICON1");
@@ -2068,7 +2129,7 @@
           strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename);
           dword_6BE364_game_settings_1 |= v0;
           uGameState = 2;
-		  //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
+          //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 )
           {
@@ -2085,19 +2146,30 @@
             dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
           }
           sub_4BD8B5();
-          goto LABEL_434;
+          //goto LABEL_434;
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+          {
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+          }
+          continue;
         case UIMSG_C3:
           pAudioPlayer->StopChannels(-1, -1);
           v162 = uMessageParam;
           v148 = 195;
-          goto LABEL_438;
+          //goto LABEL_438;
+          pWindowType = (WindowType)9;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          continue;
         case UIMSG_B1:
           pAudioPlayer->StopChannels(-1, -1);
           v162 = 0;
           v148 = 177;
-LABEL_438:
+//LABEL_438:
           pWindowType = (WindowType)9;
-LABEL_439:
+//LABEL_439:
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
           continue;
         case UIMSG_B2:
@@ -2137,12 +2209,20 @@
           v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
           v158 = (unsigned int)thise;
           v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
-_sprintex_draw_status_and_continue:
+//_sprintex_draw_status_and_continue:
           sprintf(pTmpBuf, v146, v158, v174);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_B5:
           dword_50CDC8 = v0;
-          goto LABEL_453;
+          //goto LABEL_453;
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+            continue;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
         case UIMSG_B3:
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
           pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
@@ -2283,12 +2363,12 @@
                     *((int *)v67 + 17) = v0;
                   else
                     pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
-LABEL_434:
+//LABEL_434:
                   if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                   {
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
-LABEL_771:
+//LABEL_771:
                     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                     ++pMessageQueue_50CBD0->uNumMessages;
                   }
@@ -2324,9 +2404,46 @@
                 break;
               default:
                 if ( uMessageParam != 5 )
-                  goto LABEL_506;
-                v68 = 210;
-                break;
+                  //goto LABEL_506;
+                {
+                  if ( uMessageParam )
+                  {
+                    switch ( uMessageParam )
+                    {
+                    case 1:
+                      v69 = pMapStats->pInfos[4].pName;
+                      break;
+                    case 2:
+                      v69 = pMapStats->pInfos[3].pName;
+                      break;
+                    case 3:
+                      v69 = pMapStats->pInfos[10].pName;
+                      break;
+                    case 4:
+                      v69 = pMapStats->pInfos[7].pName;
+                      break;
+                    default:
+                    if ( uMessageParam != 5 )
+                    {
+                      v173 = v200;
+                      v157 = pGlobalTXT_LocalizationStrings[35];
+                      goto _sprintex_2args_draw_status_and_continue;
+                    }
+                    v69 = pMapStats->pInfos[8].pName;
+                    break;
+                  }
+                }
+                else
+                {
+                  v69 = pMapStats->pInfos[21].pName;
+                }
+                v200 = v69;
+                v173 = v200;
+                v157 = pGlobalTXT_LocalizationStrings[35];
+                goto _sprintex_2args_draw_status_and_continue;
+              }
+              v68 = 210;
+              break;
             }
           }
           else
@@ -2338,7 +2455,7 @@
             pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
             continue;
           }
-LABEL_506:
+//LABEL_506:
           if ( uMessageParam )
           {
             switch ( uMessageParam )
@@ -2397,9 +2514,9 @@
             v70 = atoi(v216.pProperties[0]);
             if ( v70 <= 0 || v70 >= 77 )
             {
-LABEL_90:
+//LABEL_90:
               v1 = "";
-LABEL_91:
+//LABEL_91:
               v0 = 1;
               continue;
             }
@@ -2435,7 +2552,12 @@
           else
           {
             if ( v216.field_0 != 3 )
-              goto LABEL_90;
+              //goto LABEL_90;
+            {
+              v1 = "";
+              v0 = 1;
+              continue;
+            }
             v74 = atoi(v216.pProperties[0]);
             thisi = atoi(v216.pProperties[1]);
             v75 = atoi(v216.pProperties[2]);
@@ -2445,12 +2567,15 @@
               if ( pIndoor->GetSector(v74, thisi, v75) )
               {
                 v77 = thisi;
-LABEL_544:
+//LABEL_544:
                 pParty->vPosition.x = v74;
                 pParty->vPosition.y = v77;
                 pParty->vPosition.z = v76;
                 pParty->uFallStartY = v76;
-                goto LABEL_90;
+                //goto LABEL_90;
+                v1 = "";
+                v0 = 1;
+                continue;
               }
             }
             else
@@ -2463,7 +2588,17 @@
                   if ( thisi > -32768 )
                   {
                     if ( thisi < 32768 && v76 >= 0 && v76 < 10000 )
-                      goto LABEL_544;
+                      //goto LABEL_544;
+                    {
+                      pParty->vPosition.x = v74;
+                      pParty->vPosition.y = v77;
+                      pParty->vPosition.z = v76;
+                      pParty->uFallStartY = v76;
+                      //goto LABEL_90;
+                      v1 = "";
+                      v0 = 1;
+                      continue;
+                    }
                   }
                 }
               }
@@ -2480,13 +2615,20 @@
           if ( bUnderwater == 1 )
             goto LABEL_682;
           if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) )
-            goto LABEL_90;
+            //goto LABEL_90;
+          {
+            v1 = "";
+            v0 = 1;
+            continue;
+          }
           v79 = pPlayer2->uQuickSpell;
           v175 = uActiveCharacter;
           v159 = 0;
           v147 = 0;
           v80 = uActiveCharacter - 1;
-          goto LABEL_679;
+          //goto LABEL_679;
+          _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
+          continue;
         case 0x46:
         case UIMSG_Quit|0x8:
           if ( pRenderer->pRenderD3D )
@@ -2521,7 +2663,18 @@
             else
               *((char *)v51 + 9) &= 0xFDu;
           }
-          goto LABEL_416;
+          //goto LABEL_416;
+          *((short *)v51 + 2) = uMessageParam;
+          *((int *)v51 + 3) = v44;
+          pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+          pWindow3 = pGUIWindow_Settings;
+          pWindow3->Release();
+          pGUIWindow_Settings = 0;
+          pMouse->SetCursorBitmap("MICON1");
+          GameUI_StatusBar_TimedStringTimeLeft = 0;
+          unk_50C9A0 = 0;
+          back_to_game();
+          continue;
         case 0x1C:
           if ( !uActiveCharacter || pCurrentScreen )
             //goto LABEL_90;
@@ -2543,7 +2696,14 @@
             continue;
           }
           if ( pParty->bTurnBasedModeOn != v0 )
-            goto LABEL_569;
+            //goto LABEL_569;
+          {
+            if ( pActors[uMessageParam].uAIState == 5 )
+              stru_50C198.LootActor(&pActors[uMessageParam]);
+            else
+              Actor::StealFrom(uMessageParam);
+            continue;
+          }
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
           {
@@ -2553,7 +2713,7 @@
           }
           if ( !(pTurnEngine->field_18 & 2) )
           {
-LABEL_569:
+//LABEL_569:
             if ( pActors[uMessageParam].uAIState == 5 )
               stru_50C198.LootActor(&pActors[uMessageParam]);
             else
@@ -2569,7 +2729,11 @@
             continue;
           }
           if ( pParty->bTurnBasedModeOn != v0 )
-            goto LABEL_577;
+            //goto LABEL_577;
+          {
+            _42ECB5_PlayerAttacksActor();
+            continue;
+          }
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
           {
@@ -2578,7 +2742,7 @@
             continue;
           }
           if ( !(pTurnEngine->field_18 & 2) )
-LABEL_577:
+//LABEL_577:
             _42ECB5_PlayerAttacksActor();
           continue;
         case UIMSG_A7:
@@ -2586,10 +2750,21 @@
           pButton = pButton_RestUI_Exit;
           pButton2 = pButton_RestUI_Exit;
           pWindowType1 = (WindowType)96;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_ShowStatus_Player|0x1:
           if ( dword_506F14 == 2 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, (enum WindowType)90,
             (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
           dword_506F14 = v0;
@@ -2597,7 +2772,11 @@
           continue;
         case 0x60:
           if ( dword_506F14 == 2 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, (enum WindowType)90,
             (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
           dword_506F14 = v0;
@@ -2610,27 +2789,64 @@
           _506F18_num_hours_to_sleep = v86;
           if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
             _506F18_num_hours_to_sleep = v86 + 720;
-          goto LABEL_615;
+          //goto LABEL_615;
+          dword_506F14 = 2;
+          pParty->RestAndHeal();
+          pParty->field_764 = 0;
+          pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
+          continue;
         case 0x68:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
             continue;
           if ( sub_42F4DA() )
-            goto LABEL_594;
+            //goto LABEL_594;
+          {
+            if ( pParty->bTurnBasedModeOn == v0 )
+            {
+              v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
+              ShowStatusBarString(v87, 2u);
+              continue;
+            }
+            v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
+            if ( pParty->uFlags & 0x88 )
+              v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
+            ShowStatusBarString(v88, 2u);
+            v89 = uActiveCharacter;
+            if ( !uActiveCharacter )
+            {
+              v1 = "";
+              v0 = 1;
+              continue;
+            }
+            v176 = 0;
+            v160 = 13;
+            goto LABEL_619;
+          }
           if ( pParty->bTurnBasedModeOn == v0 )
-            goto LABEL_595;
+            //goto LABEL_595;
+          {
+            v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
+            ShowStatusBarString(v87, 2u);
+            continue;
+          }
           if ( !(pParty->uFlags & 0x88) )
           {
             RestUI_Initialize();
             continue;
           }
-LABEL_594:
+//LABEL_594:
           if ( pParty->bTurnBasedModeOn == v0 )
           {
-LABEL_595:
+//LABEL_595:
             v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
-            goto _draw_status_string_and_continue;
+            //goto _draw_status_string_and_continue;
+            ShowStatusBarString(v87, 2u);
+            continue;
           }
           v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
           if ( pParty->uFlags & 0x88 )
@@ -2649,7 +2865,11 @@
           goto LABEL_619;
         case 0x61:
           if ( dword_506F14 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest )
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
@@ -2713,7 +2933,7 @@
             }
             Party::TakeFood(uRestUI_FoodRequiredToRest);
             _506F18_num_hours_to_sleep = 480;
-LABEL_615:
+//LABEL_615:
             dword_506F14 = 2;
             pParty->RestAndHeal();
             pParty->field_764 = 0;
@@ -2726,7 +2946,7 @@
         case UIMSG_ShowStatus_Funds|0x8:
           if ( dword_506F14 == 2 )
           {
-LABEL_621:
+//LABEL_621:
             v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
             goto LABEL_622;
           }
@@ -2752,7 +2972,7 @@
               v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
             strcpy(pTmpBuf, v177);
           }
-_set_status_string_pTmpBuf_and_continue:
+//_set_status_string_pTmpBuf_and_continue:
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case 0x4F:
@@ -2774,7 +2994,9 @@
           }
           sprintf(pTmpBuf, v161, v178);
           sub_41C0B8_set_status_string(pTmpBuf);
-          goto LABEL_91;
+          //goto LABEL_91;
+          v0 = 1;
+          continue;
         case 0x58:
           GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
@@ -2824,7 +3046,17 @@
           }
           while ( v101 < 9 );
           if ( !pNPCData4 )
-            goto LABEL_662;
+          {
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = 0;
+            v127 = rand() % 2 + 204;
+            goto _play_sound_and_continue;
+          }
           if ( GetAsyncKeyState(16) )
           {
             --uAction;
@@ -2839,15 +3071,22 @@
           }
           sub_41140B();
           pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
-          goto LABEL_661;
+          pGUIWindow_CurrentMenu->OpenSpellBook();
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = 0;
+          v127 = rand() % 2 + 204;
+          goto _play_sound_and_continue;
         case UIMSG_SaveGame|0x4:
           if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
             continue;
           sub_41140B();
           pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
-LABEL_661:
-          pGUIWindow_CurrentMenu->_411621();
-LABEL_662:
+          pGUIWindow_CurrentMenu->OpenSpellBook();
           v165 = 0;
           v151 = 0;
           v144 = 0;
@@ -2896,17 +3135,21 @@
           v175 = 0;
           v159 = 0;
           v147 = 0;
-          goto LABEL_678;
+          //goto LABEL_678;
+          v80 = v199;
+          v79 = uMessageParam;
+          _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
+          continue;
         case 0x92:
           if ( pTurnEngine->field_4 != 3 )
           {
             v175 = 0;
             v159 = v0;
             v147 = 133;
-LABEL_678:
+//LABEL_678:
             v80 = v199;
             v79 = uMessageParam;
-LABEL_679:
+//LABEL_679:
             _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
           }
           continue;
@@ -2938,14 +3181,8 @@
             if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
             {
               if ( !pCurrentScreen )
-                goto LABEL_693;
-              if ( pCurrentScreen != 5
-                && pCurrentScreen != 7
-                && (pCurrentScreen <= 99
-                 || pCurrentScreen > 103) )
+                //goto LABEL_693;
               {
-                pGUIWindow_CurrentMenu->Release();
-LABEL_693:
                 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = 8;
                 pEventTimer->Pause();
@@ -2954,10 +3191,25 @@
                 viewparams->field_48 = v0;
                 continue;
               }
-            }
-          }
-          continue;
-        case 0x6A:
+              if ( pCurrentScreen != 5
+                && pCurrentScreen != 7
+                && (pCurrentScreen <= 99
+                 || pCurrentScreen > 103) )
+              {
+                pGUIWindow_CurrentMenu->Release();
+//LABEL_693:
+                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
+                pCurrentScreen = 8;
+                pEventTimer->Pause();
+                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;
+                continue;
+              }
+            }
+          }
+          continue;
+        case UIMSG_QuickReference:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
@@ -2965,7 +3217,7 @@
           ++pIcons_LOD->uTexturePacksCount;
           if ( !pIcons_LOD->uNumPrevLoadedFiles )
             pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-          GUIWindow::Create(0x230u, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_QuickReference, 0);
+          GUIWindow::Create(0x230u, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_QuickReference, 0);
           viewparams->bRedrawGameUI = v0;
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -2990,11 +3242,15 @@
           free((void *)uNumSeconds);
           stru_506E40._40E55E("gamma.pcx", 0);
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
-LABEL_453:
+//LABEL_453:
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-          goto LABEL_770;
+          //goto LABEL_770;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
         case UIMSG_C0:
           dword_50651C = v0;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
@@ -3002,12 +3258,12 @@
           continue;
         case UIMSG_A9:
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
-LABEL_707:
+//LABEL_707:
           dword_506548 = v0;
           continue;
         case UIMSG_AA:
           GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
-LABEL_709:
+//LABEL_709:
           dword_506544 = v0;
           continue;
         case 0x55:
@@ -3041,14 +3297,34 @@
           sub_4196A0();
           sub_419379();
           pButton = pCharacterScreen_StatsBtn;
-          goto LABEL_716;
+          //goto LABEL_716;
+          v163 = 0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)91;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_ChangeMusicVolume|0x2:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
           sub_4196A0();
           sub_419379();
           sub_419401();
           pButton = pCharacterScreen_SkillsBtn;
-          goto LABEL_716;
+          //goto LABEL_716;
+          v163 = 0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)91;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SkillUp:
           pPlayer4 = pPlayers[uActiveCharacter];
           v105 = (int)&pPlayer4->pActiveSkills[uMessageParam];
@@ -3077,7 +3353,7 @@
             }
             v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
           }
-_draw_status_string_and_continue:
+//_draw_status_string_and_continue:
           ShowStatusBarString(v87, 2u);
           continue;
         case UIMSG_ChangeMusicVolume|0x4:
@@ -3085,17 +3361,31 @@
           sub_419379();
           sub_4196A0();
           pButton = pCharacterScreen_InventoryBtn;
-LABEL_716:
+//LABEL_716:
           v163 = 0;
           pButton2 = pButton;
           pWindowType1 = (WindowType)91;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_A8:
           pButton = pCharacterScreen_ExitBtn;
           v163 = 0;
           pButton2 = pCharacterScreen_ExitBtn;
           pWindowType1 = (WindowType)97;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_Escape|0x4:
           sub_419379();
           sub_4196A0();
@@ -3111,9 +3401,13 @@
             default:
               continue;
             case 11:
-              goto LABEL_707;
+              //goto LABEL_707;
+              dword_506548 = v0;
+              continue;
             case 10:
-              goto LABEL_709;
+              //goto LABEL_709;
+              dword_506544 = v0;
+              continue;
             case 0:
               pButton = pBtn_Book_1;
               dword_506544 = v0;
@@ -3158,10 +3452,14 @@
           v163 = v0;
           pButton2 = pButton;
           pWindowType1 = (WindowType)92;
-LABEL_731:
+//LABEL_731:
           v8 = pButton->uY;
           v9 = pButton->uX;
-          goto LABEL_732;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SelectCharacter:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -3171,7 +3469,10 @@
           v174 = (char *)pParty->uNumGoldInBank;
           v158 = pParty->uNumGold + pParty->uNumGoldInBank;
           v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
-          goto _sprintex_draw_status_and_continue;
+          //goto _sprintex_draw_status_and_continue;
+          sprintf(pTmpBuf, v146, v158, v174);
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_ShowStatus_DateTime:
           pNPCData4 = (NPCData *)pParty->uCurrentHour;
           if ( (signed int)pParty->uCurrentHour <= 12 )
@@ -3187,7 +3488,8 @@
             uNumSeconds = 0;
           sprintf(pTmpBuf, "%d:%02d%s %s %d %s %d", pNPCData4, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7],
             7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_ShowStatus_Food:
           v173 = (char *)pParty->uNumFoodRations;
           v157 = pGlobalTXT_LocalizationStrings[501];// You have %lu food"
@@ -3211,40 +3513,71 @@
           v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
           v114 = v110->GetMaxHealth();
           sprintf(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case 0xC:
           if ( pCurrentScreen == 15 )
-            goto LABEL_762;
+          {
+            sub_421EA6_OnInventoryLeftClick();
+            continue;
+          }
           sub_420E01();
           continue;
         case UIMSG_ChangeMusicVolume|0x8:
-LABEL_762:
           sub_421EA6_OnInventoryLeftClick();
           continue;
         case 0xA:
           if ( !pRenderer->pRenderD3D )
-            goto LABEL_772;
+            //goto LABEL_772;
+          {
+            if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            OnGameViewportClick();
+            continue;
+          }
           v115 = pMessageQueue_50CBD0->uNumMessages;
           if ( !pMessageQueue_50CBD0->uNumMessages )
-            goto LABEL_768;
+            //goto LABEL_768;
+          {
+            if ( (signed int)v115 < 40 )
+            //goto LABEL_769;
+            {
+              pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
+              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+              ++pMessageQueue_50CBD0->uNumMessages;
+              continue;
+            }
+            continue;
+          }
           if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
           {
             v115 = v0;
             pMessageQueue_50CBD0->uNumMessages = v0;
-LABEL_769:
+//LABEL_769:
             pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
-LABEL_770:
+//LABEL_770:
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-            goto LABEL_771;
+            //goto LABEL_771;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+            continue;
           }
           v115 = 0;
           pMessageQueue_50CBD0->uNumMessages = 0;
-LABEL_768:
+//LABEL_768:
           if ( (signed int)v115 < 40 )
-            goto LABEL_769;
+            //goto LABEL_769;
+          {
+            pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+            continue;
+          }
           continue;
         case 0xE:
-LABEL_772:
+//LABEL_772:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
@@ -3263,18 +3596,24 @@
           v163 = 0;
           pButton2 = (GUIButton *)(unsigned __int16)v116;
           pWindowType1 = (WindowType)15;
-          goto LABEL_779;
+          //goto LABEL_779;
+          v8 = 0;
+          v9 = 0;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case 0x54:
           v163 = 0;
           pButton2 = (GUIButton *)uMessageParam;
           pWindowType1 = (WindowType)22;
-LABEL_779:
+//LABEL_779:
           v8 = 0;
           v9 = 0;
-LABEL_732:
+//LABEL_732:
           v137 = 0;
           v133 = 0;
-LABEL_733:
+//LABEL_733:
           GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
           continue;
         case 0x194:
@@ -6114,19 +6453,19 @@
 int __cdecl CharacterUI_LoadPaperdollTextures()
 {
   int v0; // edi@7
-  enum CHARACTER_RACE v1; // ebx@7
-  signed int v2; // eax@7
+  enum CHARACTER_RACE pRace; // ebx@7
+  signed int pSex; // eax@7
   int v3; // ebx@10
-  Player *v4; // edi@12
+  Player *pPlayer; // edi@12
   unsigned __int8 v5; // cl@12
   int v6; // edi@16
   unsigned int v7; // eax@16
-  Player *v8; // ebx@16
+  Player *pPlayer2; // ebx@16
   char *v9; // ebx@16
   char v10; // al@16
   signed int v11; // edi@21
-  Player *v12; // ebx@23
-  Player *v13; // edi@29
+  Player *pPlayer3; // ebx@23
+  Player *pPlayer4; // edi@29
   int v14; // ebp@29
   stru331 *v15; // edi@65
   signed int v16; // ebx@66
@@ -6172,55 +6511,43 @@
     if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v30 + 1) )
     {
       v0 = v30;
-      v1 = pPlayers[v30 + 1]->GetRace();
-      v2 = pPlayers[v30 + 1]->GetSexByVoice();
-      if ( v1 && v1 != 1 && v1 != 2 )
-        v3 = (v2 != 0) + 3;
+      pRace = pPlayers[v30 + 1]->GetRace();
+      pSex = pPlayers[v30 + 1]->GetSexByVoice();
+      if ( pRace && pRace != 1 && pRace != 2 )//race == 3
+        v3 = (pSex != 0) + 3;
       else
-        v3 = (v2 != 0) + 1;
+        v3 = (pSex != 0) + 1;
       wsprintfA(pContainer, "pc23v%dBod", v3);
-      papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Body texture
       wsprintfA(pContainer, "pc23v%dlad", v3);
-      papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand
       wsprintfA(pContainer, "pc23v%dlau", v3);
-      papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand2
       wsprintfA(pContainer, "pc23v%drh", v3);
-      papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Right Hand
       wsprintfA(pContainer, "pc23v%dlh", v3);
-      papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Fist
       wsprintfA(pContainer, "pc23v%dlhu", v3);
-      papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      v4 = pPlayers[v0 + 1];
-      v5 = v4->uFace;
+      papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); // Left Fist 2
+      pPlayer = pPlayers[v0 + 1];
+      v5 = pPlayer->uFace;
       if ( v5 == 12 || v5 == 13 )
         papredoll_dbrds[(char)v5] = 0;
-      papredoll_flying_feet[v4->uFace] = 0;
+      papredoll_flying_feet[pPlayer->uFace] = 0;
       IsPlayerWearingWatersuit[v30 + 1] = 1;
     }
     else
     {
       v6 = v30;
-      papredoll_dbods[v30] = pIcons_LOD->LoadTexture(
-                               dbod_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_dlads[v30] = pIcons_LOD->LoadTexture(
-                               dlad_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(
-                               dlau_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_drhs[v30] = pIcons_LOD->LoadTexture(
-                              drh_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                              TEXTURE_16BIT_PALETTE);
-      papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(
-                              dlh_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                              TEXTURE_16BIT_PALETTE);
-      v7 = pIcons_LOD->LoadTexture(
-             dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace],
-             TEXTURE_16BIT_PALETTE);
-      v8 = pPlayers[v30 + 1];
+      papredoll_dbods[v30] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlads[v30] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_drhs[v30] = pIcons_LOD->LoadTexture(drh_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      v7 = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      pPlayer2 = pPlayers[v30 + 1];
       papredoll_dlhus[v30] = v7;
-      v9 = (char *)&v8->uFace;
+      v9 = (char *)&pPlayer2->uFace;
       v10 = *v9;
       if ( *v9 == 12 || v10 == 13 )
       {
@@ -6250,11 +6577,11 @@
     byte_5111C0[v11] = 0;
     if ( pParty->pPickedItem.uItemID != v11 + 66 )
     {
-      v12 = pParty->pPlayers;
-      while ( !sub_43EE15_player_has_item(v11 + 66, v12, 0) )
-      {
-        ++v12;
-        if ( (signed int)v12 >= (signed int)pParty->pHirelings )
+      pPlayer3 = pParty->pPlayers;
+      while ( !sub_43EE15_player_has_item(v11 + 66, pPlayer3, 0) )
+      {
+        ++pPlayer3;
+        if ( (signed int)pPlayer3 >= (signed int)pParty->pHirelings )
           goto LABEL_28;
       }
     }
@@ -6268,47 +6595,47 @@
   *(int *)&byte_5111F6[8] = 0;
   *(int *)&byte_5111F6[12] = 0;
   *(int *)&byte_5111F6[16] = 0;
-  v13 = pParty->pPlayers;
+  pPlayer4 = pParty->pPlayers;
   v14 = 1;
   do
   {
-    if ( sub_43EE15_player_has_item(0x204u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x204u, pPlayer4, 1) )
       byte_5111F6[2] = 1;
-    if ( sub_43EE15_player_has_item(0x1F8u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x1F8u, pPlayer4, 1) )
       byte_5111F6[0] = 1;
-    if ( sub_43EE15_player_has_item(0x1F9u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x1F9u, pPlayer4, 1) )
       byte_5111F6[1] = 1;
-    if ( sub_43EE15_player_has_item(0x215u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x215u, pPlayer4, 1) )
       byte_5111F6[16] = 1;
-    if ( sub_43EE15_player_has_item(0x200u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x200u, pPlayer4, 1) )
       byte_5111F6[3] = 1;
-    if ( sub_43EE15_player_has_item(0x209u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x209u, pPlayer4, 1) )
       byte_5111F6[4] = 1;
-    if ( sub_43EE15_player_has_item(0x20Au, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Au, pPlayer4, 1) )
       byte_5111F6[5] = 1;
-    if ( sub_43EE15_player_has_item(0x20Bu, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Bu, pPlayer4, 1) )
       byte_5111F6[6] = 1;
-    if ( sub_43EE15_player_has_item(0x214u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x214u, pPlayer4, 1) )
       byte_5111F6[7] = 1;
-    if ( sub_43EE15_player_has_item(0x220u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x220u, pPlayer4, 1) )
       byte_5111F6[8] = 1;
-    if ( sub_43EE15_player_has_item(0x20Cu, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Cu, pPlayer4, 1) )
       byte_5111F6[9] = 1;
-    if ( sub_43EE15_player_has_item(0x217u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x217u, pPlayer4, 1) )
       byte_5111F6[10] = 1;
-    if ( sub_43EE15_player_has_item(0x20Du, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Du, pPlayer4, 1) )
       byte_5111F6[11] = 1;
-    if ( sub_43EE15_player_has_item(0x212u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x212u, pPlayer4, 1) )
       byte_5111F6[12] = 1;
-    if ( sub_43EE15_player_has_item(0x223u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x223u, pPlayer4, 1) )
       byte_5111F6[13] = 1;
-    if ( sub_43EE15_player_has_item(0x224u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x224u, pPlayer4, 1) )
       byte_5111F6[14] = 1;
-    if ( sub_43EE15_player_has_item(0x226u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x226u, pPlayer4, 1) )
       byte_5111F6[15] = 1;
-    ++v13;
-  }
-  while ( (signed int)v13 < (signed int)pParty->pHirelings );
+    ++pPlayer4;
+  }
+  while ( (signed int)pPlayer4 < (signed int)pParty->pHirelings );
   v15 = &stru_511698.field_2C;
   v35 = (char *)&stru_511718.field_18;
   do
@@ -6424,9 +6751,7 @@
       do
       {
         _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
-        *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(
-                                                           pContainer,
-                                                           TEXTURE_16BIT_PALETTE);
+        *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1);
         v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v28 = v34;
@@ -6436,45 +6761,25 @@
       }
       while ( v38 - 105 < 5 );
       _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
-      *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1);
-      *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
-      *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1);
-      *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
-      *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     }
     else
     {
@@ -12932,7 +13237,7 @@
       dword_5063D8[v12] = result;
     }
     v4 = v12 + 1;
-    v9 = __OFSUB__(v12 + 1, 12);
+    v9 = v12++ > 12;//v9 = __OFSUB__(v12 + 1, 12);
     v8 = v12++ - 11 < 0;
   }
   while ( v8 ^ v9 );
@@ -14830,7 +15135,7 @@
                 v38 = v37 - 2;
                 if ( v38 )//pWindowType > 105
                 {
-                  if ( v38 == 1 )//pWindowType == 106
+                  if ( v38 == 1 )//pWindowType == 106 (0x6A) WINDOW_VideoOptions
                     GameMenuUI_DrawVideoOptions();
                 }
                 else//pWindowType == 105
@@ -17372,7 +17677,7 @@
 //----- (00419100) --------------------------------------------------------
 int __cdecl sub_419100()
 {
-  Player *v0; // esi@1
+  Player *pPlayer; // esi@1
   int v1; // ebx@1
   unsigned __int8 *v2; // esi@1
   int v3; // eax@4
@@ -17389,7 +17694,7 @@
   signed int v14; // [sp+Ch] [bp-8h]@9
   int i; // [sp+10h] [bp-4h]@10
 
-  v0 = pPlayers[uActiveCharacter];
+  pPlayer = pPlayers[uActiveCharacter];
   memset(&pStru179, 0, 0xFA0u);
   memset(pTmpBuf2, 0, 0x7D0u);
   v1 = 0;
@@ -17398,7 +17703,7 @@
   dword_506520 = 0;
   dword_50651C = 0;
   dword_506528 = 0;
-  v2 = (unsigned __int8 *)v0->field_152;
+  v2 = (unsigned __int8 *)pPlayer->field_152;
   do
   {
     v13 = dword_723E80_award_related[2 * v1];
@@ -17423,7 +17728,7 @@
       v8 = rand() % 16;
       result = dword_506524;
       v9 = dword_506524 + v5++;
-      v10 = __OFSUB__(v5, dword_506524);
+      v10 = v5 > dword_506524;//__OFSUB__(v5, dword_506524);
       v7 = v5 - dword_506524 < 0;
       pStru179->field_0[v9] = v8;
     }
--- a/mm7_6.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_6.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -8852,7 +8852,7 @@
 }
 
 //----- (0042FC15) --------------------------------------------------------
-void __cdecl sub_42FC15()
+void __cdecl CloseWindowBackground()
 {
   pAudioPlayer->PlaySound((SoundID)75, -2, 0, -1, 0, 0, 0, 0);
   pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]);
--- a/mm7_data.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_data.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -1286,7 +1286,7 @@
 int uLastPointedObjectID; // weak
 //unsigned __int8 bMonsterInfoUI_bDollInitialized;
 char *aSpellNames[44];
-int dword_506978; // weak
+int pMainScreenNum; // weak
 char byte_50697C; // weak
 int dword_506980; // weak
 int dword_506984; // weak
--- a/mm7_data.h	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_data.h	Wed Jan 16 17:31:56 2013 +0600
@@ -1178,7 +1178,7 @@
 extern int uLastPointedObjectID; // weak
 //extern unsigned __int8 bMonsterInfoUI_bDollInitialized;
 extern char *aSpellNames[44];
-extern int dword_506978; // weak
+extern int pMainScreenNum; // weak
 extern char byte_50697C; // weak
 extern int dword_506980; // weak
 extern int dword_506984; // weak
@@ -1933,7 +1933,7 @@
 // int __cdecl crt_sub_42FBB7();
 // void __cdecl crt_construct_50CDB4();
 void __cdecl sub_42FBDD();
-void __cdecl sub_42FC15();
+void __cdecl CloseWindowBackground();
 void __cdecl ProcessInputActions();
 void __cdecl GameUI_MsgProc();
 void __cdecl back_to_game();