changeset 964:d7f0572335ec

Слияние
author Ritor1
date Sat, 04 May 2013 18:19:08 +0600
parents cbf623f00e6c (current diff) 9a5db2cf999a (diff)
children a6510526f791
files mm7_4.cpp
diffstat 15 files changed, 583 insertions(+), 628 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/Actor.cpp	Sat May 04 18:19:08 2013 +0600
@@ -167,41 +167,22 @@
 //----- (00445D4A) --------------------------------------------------------
 void Actor::InitializeDialogue(int bPlayerSaysHello)
 {
-  Actor *v2; // esi@1
-  signed int v3; // ecx@1
-  NPCData *v4; // eax@1
-  NPCData *v5; // ebp@1
-  unsigned int v6; // eax@1
-  //signed int v7; // eax@3
-  //unsigned int v8; // eax@8
+  NPCData *pNPCInfo; // ebp@1
   int v9; // esi@8
-  int v10; // eax@11
-  GUIWindow *v11; // ecx@19
-  signed int v12; // eax@21
-  //int v13; // [sp-8h] [bp-44h]@34
-  //const char *v14; // [sp-4h] [bp-40h]@4
-  //int v15; // [sp-4h] [bp-40h]@34
-  signed int v16; // [sp-4h] [bp-40h]@35
-  int v17; // [sp+10h] [bp-2Ch]@1
+  int pNumberContacts; // eax@11
   char pContainer[32]; // [sp+14h] [bp-28h]@3
 
-  auto a1 = this;
-  v2 = a1;
-  v17 = bPlayerSaysHello;
   dword_A74CDC = -1;
   dword_AE336C = -1;
   pEventTimer->Pause();
   pMiscTimer->Pause();
   pAudioPlayer->StopChannels(-1, -1);
   uDialogueType = 0;
-  v3 = v2->sNPC_ID;
-  sDialogue_SpeakingActorNPC_ID = v2->sNPC_ID;
-  pDialogue_SpeakingActor = v2;
-  v4 = GetNPCData(v3);
-  v5 = v4;
-  v6 = v4->uFlags;
-  if ( (v6 & 3) != 2 )
-    v5->uFlags = v6 + 1;
+  sDialogue_SpeakingActorNPC_ID = this->sNPC_ID;
+  pDialogue_SpeakingActor = this;
+  pNPCInfo = GetNPCData(this->sNPC_ID);
+  if ( (pNPCInfo->uFlags & 3) != 2 )
+    pNPCInfo->uFlags = pNPCInfo->uFlags + 1;
 
   switch (pParty->alignment)
   {
@@ -213,69 +194,58 @@
   pDialogueNPCCount = 0;
   uNumDialogueNPCPortraits = 1;
   pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
-  sprintf(pContainer, "npc%03u", v5->uPortraitID);
+  sprintf(pContainer, "npc%03u", pNPCInfo->uPortraitID);
   v9 = 0;
   pDialogueNPCPortraits[0] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   dword_591084 = areWeLoadingTexture;
   uTextureID_right_panel_loop = uTextureID_right_panel;
-  if ( !v5->Hired() && v5->Location2D >= 0 )
+  if ( !pNPCInfo->Hired() && pNPCInfo->Location2D >= 0 )
   {
-    if ( (signed int)pParty->GetPartyFame() <= v5->fame
-      || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) )
+    if ( (signed int)pParty->GetPartyFame() <= pNPCInfo->fame
+      || (pNumberContacts = pNPCInfo->uFlags & 0xFFFFFF7F, (pNumberContacts & 0x80000000u) != 0) )
     {
       v9 = 1;
     }
 	else
 	{
-		if ( v10 > 1 )
+		if ( pNumberContacts > 1 )
 		{
-		  if ( v10 == 2 )
+		  if ( pNumberContacts == 2 )
 		  {
-			v16 = 3;
-			v9 = v16;
+			v9 = 3;
 		  }
 		  else
 		  {
-			  if ( v10 != 3 )
+			  if ( pNumberContacts != 3 )
 			  {
-				if ( v10 != 4 )
+				if ( pNumberContacts != 4 )
 				  v9 = 1;
 			  }
 			  else
 			  {
-				v16 = 2;
-				v9 = v16;
+				v9 = 2;
 			  }
 		  }
 		}
-		else if ( v5->rep )
+		else if ( pNPCInfo->rep )
 		{
-		  v16 = 2;
-		  v9 = v16;
+		  v9 = 2;
 		}
 	}
   }
   if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
-  v11 = GUIWindow::Create(0, 0, 640, 480, WINDOW_Rest, v9, 0);
-  pDialogueWindow = v11;
-  if (v5->Hired())
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Dialogue, v9, 0);//pNumberContacts = 1, v9 = 0; pNumberContacts = 2, v9 = 3;
+  if (pNPCInfo->Hired())
   {
-    if ( !v5->bHasUsedTheAbility )
+    if ( !pNPCInfo->bHasUsedTheAbility )
     {
-      v12 = v5->uProfession;
-      if ( v12 >= 10 )
+      if ( pNPCInfo->uProfession >= 10 )
       {
-        if ( v12 <= 12 || v12 > 32 && (v12 <= 34 || v12 > 38 && (v12 <= 43 || v12 == 52)) )
+        if ( pNPCInfo->uProfession <= 12 || pNPCInfo->uProfession > 32 && (pNPCInfo->uProfession <= 34 
+             || pNPCInfo->uProfession > 38 && (pNPCInfo->uProfession <= 43 || pNPCInfo->uProfession == 52)) )
         {
-          v11->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3,
-            1,
-            0,
-            UIMSG_SelectNPCDialogueOption,
-            9,
-            0,
-            "",
-            0);
+          pDialogueWindow->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3, 1, 0, UIMSG_SelectNPCDialogueOption, 9, 0, "", 0);
           pDialogueWindow->_41D08F(4, 1, 0, 1);
         }
       }
@@ -287,7 +257,7 @@
   pDialogueWindow->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
   pDialogueWindow->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
 
-  if (v17 && uActiveCharacter && !v5->Hired())
+  if (bPlayerSaysHello && uActiveCharacter && !pNPCInfo->Hired())
   {
     if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21)
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodEvening, 0);
--- a/GUIWindow.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/GUIWindow.cpp	Sat May 04 18:19:08 2013 +0600
@@ -359,7 +359,7 @@
 		}
 	case WINDOW_Book:
 		{
-		OnCloseSpellook();
+		OnCloseSpellBook();
 		break;
 		}
 	case WINDOW_ChangeLocation:
@@ -976,8 +976,8 @@
   if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])  CreateButton(400, 271, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 7, 0, aSpellSchoolNames[7], 0);
   if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])   CreateButton(400, 307, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 8, 0, aSpellSchoolNames[8], 0);
 
-                            CreateButton(476, 450, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_58,     0, 0, "", 0);
-  pBtn_InstallRemoveSpell = CreateButton(476, 450, 48,                             32,                              1, 78, UIMSG_58,     0, 0, "", pTexture_506444, 0);
+                            CreateButton(476, 450, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn,     0, 0, "", 0);
+  pBtn_InstallRemoveSpell = CreateButton(476, 450, 48,                             32,                              1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn,     0, 0, "", pTexture_506444, 0);
                             CreateButton(561, 450, ptr_506440->uTextureWidth,      ptr_506440->uTextureHeight,      1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
   pBtn_CloseBook          = CreateButton(561, 450, 48,                             32,                              1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
 }
@@ -1937,7 +1937,7 @@
     {
       pMainScreenNum = pCurrentScreen;
       pCurrentScreen = SCREEN_INPUT_BLV;
-      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_19C, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//
+      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//
       pBtn_YES        = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
                         pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0);
                         pWindow->CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, pWindow->Hint, 0);
--- a/GUIWindow.h	Sat May 04 18:18:47 2013 +0600
+++ b/GUIWindow.h	Sat May 04 18:19:08 2013 +0600
@@ -12,7 +12,7 @@
 
   UIMSG_ChangeGameState = 5,
 
-  UIMSG_A = 10,
+  UIMSG_MouseLeftClickInGame = 10,
 
   UIMSG_C = 12,
 
@@ -57,7 +57,7 @@
   UIMSG_PlayerCreationRemoveUpSkill = 74,
   UIMSG_PlayerCreationRemoveDownSkill = 75,
 
-  UIMSG_4E = 78,
+  UIMSG_HintSelectRemoveQuickSpellBtn = 78,
   UIMSG_SPellbook_ShowHightlightedSpellInfo = 79,
 
   UIMSG_BuyInShop_Identify_Repair = 81,
@@ -67,7 +67,7 @@
   UIMSG_ChangeDetaliz = 85,
   UIMSG_SelectSpell = 86,
   UIMSG_OpenSpellbookPage = 87,
-  UIMSG_58 = 88,
+  UIMSG_ClickInstallRemoveQuickSpellBtn = 88,
 
   UIMSG_OnTravelByFoot = 90,
   UIMSG_5B = 91,
@@ -91,10 +91,10 @@
   UIMSG_ChangeSoundVolume = 111,
   UIMSG_ChangeMusicVolume = 112,
   UIMSG_Escape = 113,
-  UIMSG_72 = 114,
-  UIMSG_73 = 115,
-  UIMSG_74 = 116,
-  UIMSG_75 = 117,
+  UIMSG_ClickSkillsBtn = 114,
+  UIMSG_ClickStatsBtn = 115,
+  UIMSG_ClickInventoryBtn = 116,
+  UIMSG_ClickAwardsBtn = 117,
   UIMSG_PlayerCreation_SelectAttribute = 118,
 
   UIMSG_InventoryLeftClick = 120,
@@ -129,7 +129,7 @@
   UIMSG_SelectLoadSlot = 165,
   UIMSG_Cancel = 166,
   UIMSG_ExitRest = 167,
-  UIMSG_A8 = 168,
+  UIMSG_ClickExitCharacterWindowBtn = 168,
   UIMSG_A9 = 169,
   UIMSG_AA = 170,
   UIMSG_PlayerCreation_FacePrev = 171,
@@ -184,8 +184,8 @@
   UIMSG_ToggleAlwaysRun = 225,
   UIMSG_ToggleFlipOnExit = 226,
 
-  UIMSG_16F = 367,
-  UIMSG_170 = 368,
+  UIMSG_ClickZoomOutBtn = 367,
+  UIMSG_ClickZoomInBtn = 368,
 
   UIMSG_Game_Action = 404,
   UIMSG_SelectShopDialogueOption = 405,
@@ -193,7 +193,7 @@
   UIMSG_RentRoom = 409,
   UIMSG_19A = 410,
   UIMSG_TransitionUI_Confirm = 411,
-  UIMSG_19C = 412,
+  UIMSG_TransitionWindowCloseBtn = 412,
 
   UIMSG_OpenKeyMappingOptions = 415,
   UIMSG_SelectKeyPage1 = 416,
@@ -260,8 +260,9 @@
   WINDOW_Options = 0x6,
   WINDOW_8 = 8,
   WINDOW_Book = 0x9,
-  WINDOW_Dialogue = 0xA,
+  WINDOW_Dialogue = 10,
   WINDOW_QuickReference = 12,
+  WINDOW_F = 15,
   WINDOW_Rest = 16,
   WINDOW_ChangeLocation = 17,
   WINDOW_SpellBook = 0x12,
@@ -271,7 +272,7 @@
   WINDOW_MainMenu_Load = 0x18,
   WINDOW_HouseInterior = 0x19,
   WINDOW_Transition = 26,
-  WINDOW_1B = 0x1B,
+  WINDOW_1B = 27,
   WINDOW_Scroll = 0x1E,
   WINDOW_CastSpell_InInventory = 31,
   WINDOW_FinalWindow = 0x46,
@@ -279,14 +280,14 @@
   WINDOW_59 = 0x59,
   WINDOW_5A = 90,
   WINDOW_5B = 91,
-  WINDOW_VoiceSwitcherButton = 0x5C,
+  WINDOW_VoiceSwitcherButton = 92,
   WINDOW_5D = 0x5D,
   WINDOW_5E = 94,
-  WINDOW_5F = 0x5F,
-  WINDOW_60 = 96,
-  WINDOW_61 = 0x61,
+  WINDOW_LoadGame_CancelBtn = 0x5F,
+  WINDOW_ExitRestWindow = 96,
+  WINDOW_ExitCharacterWindow = 97,
   WINDOW_RestWindow = 0x62,
-  WINDOW_63 = 99,
+  WINDOW_BooksWindow = 99,
   WINDOW_CharacterWindow_Stats = 0x64,
   WINDOW_CharacterWindow_Skills = 0x65,
   WINDOW_CharacterWindow_Awards = 0x66,
--- a/Time.h	Sat May 04 18:18:47 2013 +0600
+++ b/Time.h	Sat May 04 18:19:08 2013 +0600
@@ -41,9 +41,17 @@
   int dt_in_some_format;
   unsigned int uTotalGameTimeElapsed;
 };
+
 #pragma pack(pop)
 
 
 
 extern Timer *pMiscTimer;
-extern Timer *pEventTimer;
\ No newline at end of file
+extern Timer *pEventTimer;
+
+const unsigned int Minute = 256;
+const unsigned int Hour = 60 * Minute;
+const unsigned int Day = 24 * Hour;
+const unsigned int Week = 7 * Day;
+const unsigned int Month = 4 * Week;
+const unsigned int Year = 12 * Month;
\ No newline at end of file
--- a/UIBooks.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/UIBooks.cpp	Sat May 04 18:19:08 2013 +0600
@@ -137,7 +137,7 @@
 
 
 //----- (00411597) --------------------------------------------------------
-void __cdecl OnCloseSpellook()
+void __cdecl OnCloseSpellBook()
 {
   pAllocator->FreeChunk(pSpellFont);
   pSpellFont = 0;
--- a/UIMainMenu.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/UIMainMenu.cpp	Sat May 04 18:19:08 2013 +0600
@@ -151,7 +151,7 @@
     uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE);
 
     pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-    pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, UIMSG_A, 0, 0, "", 0);
+    pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, UIMSG_MouseLeftClickInGame, 0, 0, "", 0);
     pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
     pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
     pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
@@ -200,11 +200,11 @@
 
     v24 = &pIcons_LOD->pTextures[uTextureID_Btn_ZoomIn];
     v28 = pKeyActionMap->GetActionVKey(INPUT_ZoomIn);
-    pBtn_ZoomIn = pPrimaryWindow->CreateButton(574, 136, v24->uTextureWidth, v24->uTextureHeight, 2, 0, UIMSG_170, 0, v28, pGlobalTXT_LocalizationStrings[252], // Zoom In
+    pBtn_ZoomIn = pPrimaryWindow->CreateButton(574, 136, v24->uTextureWidth, v24->uTextureHeight, 2, 0, UIMSG_ClickZoomInBtn, 0, v28, pGlobalTXT_LocalizationStrings[252], // Zoom In
         v24, 0);
     v29 = &pIcons_LOD->pTextures[uTextureID_Btn_ZoomOut];
     v33 = pKeyActionMap->GetActionVKey(INPUT_ZoomOut);
-    pBtn_ZoomOut = pPrimaryWindow->CreateButton(519, 136, v29->uTextureWidth, v29->uTextureHeight, 2, 0, UIMSG_16F, 0, v33, pGlobalTXT_LocalizationStrings[251], // Zoom Out
+    pBtn_ZoomOut = pPrimaryWindow->CreateButton(519, 136, v29->uTextureWidth, v29->uTextureHeight, 2, 0, UIMSG_ClickZoomOutBtn, 0, v33, pGlobalTXT_LocalizationStrings[251], // Zoom Out
         v29, 0);
     pPrimaryWindow->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, UIMSG_0, 0, 0, "", 0);
     pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, '5', "", 0);
--- a/UIRest.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/UIRest.cpp	Sat May 04 18:19:08 2013 +0600
@@ -60,7 +60,7 @@
         }
     pEventTimer->Pause();
     if ( dword_506F14 != 2 )
-        GUIWindow::Create(518u, 450u, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0);
+        GUIWindow::Create(518u, 450u, 0, 0, WINDOW_5A, (int)pBtn_Rest, 0);
     _506F18_num_hours_to_sleep = 0;
     dword_506F14 = 0;
     uRestUI_FoodRequiredToRest = 2;
@@ -195,11 +195,7 @@
             Dst.pParent = 0;
             sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
             pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
-            pButton_RestUI_WaitUntilDawn->DrawLabel(
-                pGlobalTXT_LocalizationStrings[237],
-                pFontCreate,
-                a5,
-                *(int **)a9);
+            pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, a5, *(int **)a9);
             pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9);
             pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9);
             pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9);
@@ -226,14 +222,8 @@
                 Sleep6Hours();
             }
         else
-            {
-            GUIWindow::Create(
-                pButton_RestUI_Exit->uX,
-                pButton_RestUI_Exit->uY,
-                0,
-                0,
-                (enum WindowType)96,
-                (int)pButton_RestUI_Exit,
-                (int)pGlobalTXT_LocalizationStrings[81]);
-            }
+        {
+          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_ExitRestWindow,
+           (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);
+        }
     }
\ No newline at end of file
--- a/UiGame.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/UiGame.cpp	Sat May 04 18:19:08 2013 +0600
@@ -1231,31 +1231,31 @@
   pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
                                 pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth,
                                 pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight,
-                                1, 0, UIMSG_73, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats
+                                1, 0, UIMSG_ClickStatsBtn, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats
                                 pIcons_LOD->GetTexture(papredoll_dbrds[10]),
                                 pIcons_LOD->GetTexture(papredoll_dbrds[9]), 0);
   pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308,
                                  pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureWidth,
                                  pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureHeight,
-                                 1, 0, UIMSG_72, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills
+                                 1, 0, UIMSG_ClickSkillsBtn, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills
                                  pIcons_LOD->GetTexture(papredoll_dbrds[8]),
                                  pIcons_LOD->GetTexture(papredoll_dbrds[7]), 0);
   pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308,
                                     pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureWidth,
                                     pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureHeight,
-                                    1, 0, UIMSG_74, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory
+                                    1, 0, UIMSG_ClickInventoryBtn, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory
                                     pIcons_LOD->GetTexture(papredoll_dbrds[6]),
                                     pIcons_LOD->GetTexture(papredoll_dbrds[5]), 0);
   pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308,
                                  pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureWidth,
                                  pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureHeight,
-                                 1, 0, UIMSG_75, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards
+                                 1, 0, UIMSG_ClickAwardsBtn, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards
                                  pIcons_LOD->GetTexture(papredoll_dbrds[4]),
                                  pIcons_LOD->GetTexture(papredoll_dbrds[3]), 0);
   pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308,
                  pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureWidth,
                  pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureHeight,
-                 1, 0, UIMSG_A8, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
+                 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
                  pIcons_LOD->GetTexture(papredoll_dbrds[2]),
                  pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
--- a/mm7_1.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_1.cpp	Sat May 04 18:19:08 2013 +0600
@@ -692,7 +692,7 @@
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = SCREEN_CASTING;
   v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, v1, 0);
-  pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_A8, 0, 0,
+  pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0,
                  pGlobalTXT_LocalizationStrings[79], // Close
                  pIcons_LOD->GetTexture(papredoll_dbrds[2]),
                  pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
--- a/mm7_2.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_2.cpp	Sat May 04 18:19:08 2013 +0600
@@ -6872,18 +6872,131 @@
 
         case 40006:  pParty->SetFood(pParty->uNumFoodRations + 20);   return 0;
 
-        case 40062:  pParty->alignment = PartyAlignment_Good;   return 0;
-        case 40063:  pParty->alignment = PartyAlignment_Neutral;   return 0;
-        case 40064:  pParty->alignment = PartyAlignment_Evil;   return 0;
+        case 40062:
+          pParty->alignment = PartyAlignment_Good;
+          SetUserInterface(pParty->alignment, true);
+          return 0;
+        case 40063:
+          pParty->alignment = PartyAlignment_Neutral;
+          SetUserInterface(pParty->alignment, true);
+          return 0;
+        case 40064:
+          pParty->alignment = PartyAlignment_Evil;
+          SetUserInterface(pParty->alignment, true);
+          return 0;
 
         //SubMenu "Time"
-        case 40009:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (24 * 60)) * 0.033333335);   return 0;
-        case 40010:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (7 * (24 * 60))) * 0.033333335);   return 0;
-        case 40011:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (28 * (24 * 60))) * 0.033333335);   return 0;
-        case 40012:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (12 * (28 * (24 * 60)))) * 0.033333335);   return 0;// this incorrect
+        case 40009:  pParty->uTimePlayed += Day;   return 0;
+        case 40010:  pParty->uTimePlayed += Week;   return 0;
+        case 40011:  pParty->uTimePlayed += Month;   return 0;
+        case 40012:  pParty->uTimePlayed += Year;   return 0;
 
         //SubMenu "Items"
-        case 40015:  /* generate item level 1*/;   return 0;
+        case 40015:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 1 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40016:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 2 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40017:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 3 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40018:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 4 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40019:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 5 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40020:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 6 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
+        case 40061:
+        {
+          int pItemID = rand() % 500;
+          for ( uint i = 0; i < 500; ++i )
+          {
+            if ( pItemID + i > 499 )
+              pItemID = 0;
+            if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6 )
+            {
+              pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
+              return 0;
+            }
+          }
+        }
+        return 0;
 
       }
     }
--- a/mm7_3.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_3.cpp	Sat May 04 18:19:08 2013 +0600
@@ -12928,7 +12928,7 @@
 }
 
 //----- (0044603D) --------------------------------------------------------
-void __cdecl sub_44603D()
+void __cdecl DialogueEnding()
 {
   sDialogue_SpeakingActorNPC_ID = 0;
   pDialogueWindow->Release();
--- a/mm7_4.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_4.cpp	Sat May 04 18:19:08 2013 +0600
@@ -6839,14 +6839,14 @@
 //----- (004B254D) --------------------------------------------------------
 char *__thiscall _4B254D_SkillMasteryTeacher(int _this)
 {
-  Player *v1; // esi@1
+  //Player *v1; // esi@1
   int v2; // edx@1
   int v3; // ecx@1
   int v4; // edi@1
-  int v5; // eax@7
+  int pClassType; // eax@7
   int v6; // eax@7
   int v7; // ebx@7
-  int v8; // ebx@8
+  //int v8; // ebx@8
   signed int v9; // esi@8
   int v10; // eax@8
   char *v11; // ecx@8
@@ -6854,27 +6854,26 @@
   char *v13; // edx@9
   signed int v14; // edi@10
   unsigned int v16; // eax@29
-  int v17; // eax@36
+  //int v17; // eax@36
   char v18; // cl@46
   __int16 v19; // dx@56
   int v20; // eax@60
-  char *v21; // [sp-Ch] [bp-38h]@82
-  const char *v22; // [sp-8h] [bp-34h]@21
-  unsigned int v23; // [sp-8h] [bp-34h]@38
-  char *v24; // [sp-8h] [bp-34h]@82
+  //char *v21; // [sp-Ch] [bp-38h]@82
+  //const char *v22; // [sp-8h] [bp-34h]@21
+  //unsigned int v23; // [sp-8h] [bp-34h]@38
+  //char *v24; // [sp-8h] [bp-34h]@82
   char *v25; // [sp-4h] [bp-30h]@14
-  int v26; // [sp-4h] [bp-30h]@38
-  int v27; // [sp-4h] [bp-30h]@82
+  //int v26; // [sp-4h] [bp-30h]@38
+  //int v27; // [sp-4h] [bp-30h]@82
   char v28[4]; // [sp+Ch] [bp-20h]@9
   int v29; // [sp+10h] [bp-1Ch]@13
   int v30; // [sp+14h] [bp-18h]@15
   int v31; // [sp+18h] [bp-14h]@16
   unsigned __int16 a1[2]; // [sp+1Ch] [bp-10h]@7
-  int v33; // [sp+20h] [bp-Ch]@7
+  //int v33; // [sp+20h] [bp-Ch]@7
   int v34; // [sp+24h] [bp-8h]@7
   char *v35; // [sp+28h] [bp-4h]@1
 
-  v1 = pPlayers[uActiveCharacter];
   contract_approved = 0;
   v2 = (_this - 200) % 3;
   v3 = (_this - 200) / 3;
@@ -6902,18 +6901,18 @@
     gold_transaction_amount = 2000;
     dword_F8B1B0 = 2;
   }
-  v5 = v1->classType;
-  v33 = v5;
-  v6 = byte_4ED970_skill_learn_ability_by_class_table[v5][v3];
-  *(int *)a1 = v1->pActiveSkills[v3];
+  pClassType = pPlayers[uActiveCharacter]->classType;
+  //v33 = pClassType;
+  v6 = byte_4ED970_skill_learn_ability_by_class_table[pClassType][v3];
+  *(int *)a1 = pPlayers[uActiveCharacter]->pActiveSkills[v3];
   v7 = a1[0] & 0x3F;
   v34 = v2 + 2;
   if ( v6 < v2 + 2 )
   {
-    v8 = v33;
+    //v8 = v33;
     v9 = 0;
-    v10 = v33 - v33 % 4;
-    v11 = &byte_4ED970_skill_learn_ability_by_class_table[v33 - v33 % 4][v3];
+    v10 = pClassType - pClassType % 4;
+    v11 = &byte_4ED970_skill_learn_ability_by_class_table[pClassType - pClassType % 4][v3];
     do
     {
       v12 = (unsigned __int8)*v11;
@@ -6938,11 +6937,11 @@
     }
     else
     {
-      if ( v30 == v14 )
+      if ( v30 == v14 )//crash
       {
         if ( v31 == v14 )
         {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);//    %s  %s     .
           return pTmpBuf;
         }
         v25 = pClassNames[v10 + 2];
@@ -6951,19 +6950,16 @@
       {
         if ( v31 != v14 )
         {
-          v25 = pClassNames[v8];
-          v22 = pGlobalTXT_LocalizationStrings[632];
-          goto LABEL_23;
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[632], pClassNames[pClassType]);//        %s.
+          return pTmpBuf;
         }
         v25 = pClassNames[v10 + 3];
       }
     }
-    v22 = pGlobalTXT_LocalizationStrings[633];
-LABEL_23:
-    sprintf(pTmpBuf, v22, v25);
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[633], v25);//    %s     .
     return pTmpBuf;
   }
-  if ( !v1->CanAct() )
+  if ( !pPlayers[uActiveCharacter]->CanAct() )
     return (char *)pNPCTopics[122].pText;
   if ( !v7 )
     return (char *)pNPCTopics[131].pText;
@@ -6976,11 +6972,8 @@
     {
       if ( (signed int)v16 >= 2 && v7 >= 7 )
       {
-        v17 = dword_F8B1AC_award_bit_number;
         switch ( dword_F8B1AC_award_bit_number )
         {
-          default:
-            goto LABEL_41;
           case 12:
           case 13:
           case 14:
@@ -6992,26 +6985,40 @@
             goto LABEL_42;
           case 19:
             v19 = 114;
-            goto LABEL_57;
+            if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v19) )
+              return v35;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
           case 20:
             v19 = 110;
-LABEL_57:
             if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v19) )
               return v35;
-            goto LABEL_40;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
           case 22:
-            v20 = v1->GetBaseWillpower();
-            goto LABEL_61;
+            v20 = pPlayers[uActiveCharacter]->GetBaseWillpower();
+            if ( v20 < 50 )
+              return v35;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
           case 24:
             gold_transaction_amount = 2500;
-            v20 = v1->GetBaseEndurance();
-            goto LABEL_61;
-          case 36:
-            v20 = v1->GetBaseIntelligence();
-LABEL_61:
+            v20 = pPlayers[uActiveCharacter]->GetBaseEndurance();
             if ( v20 < 50 )
               return v35;
-            goto LABEL_40;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
+          case 36:
+            v20 = pPlayers[uActiveCharacter]->GetBaseIntelligence();
+            if ( v20 < 50 )
+              return v35;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
           case 21:
           case 23:
           case 25:
@@ -7029,50 +7036,75 @@
             gold_transaction_amount = 3000;
             goto LABEL_42;
           case 7:
-            goto LABEL_67;
+            gold_transaction_amount = 0;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
+          default:
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
         }
-        goto LABEL_67;
+        gold_transaction_amount = 0;
+        if ( !gold_transaction_amount )
+          goto LABEL_79;
+        goto LABEL_42;
       }
     }
     else
     {
       if ( v34 != 4 )
       {
-LABEL_40:
-        v17 = dword_F8B1AC_award_bit_number;
-        goto LABEL_41;
+        if ( !gold_transaction_amount )
+          goto LABEL_79;
+        goto LABEL_42;
       }
       if ( (signed int)v16 >= 3 && v7 >= 10 )
       {
-        v17 = dword_F8B1AC_award_bit_number;
         switch ( dword_F8B1AC_award_bit_number )
         {
           case 19:
-            if ( v1->_49327B(0x22u, 1) == 1 )
-              goto LABEL_40;
-            v26 = 1;
-            v23 = 26;
-            goto LABEL_39;
-          default:
-            goto LABEL_41;
+            if ( pPlayers[uActiveCharacter]->_49327B(0x22u, 1) == 1 )
+            {
+              if ( !gold_transaction_amount )
+                goto LABEL_79;
+              goto LABEL_42;
+            }
+            if ( pPlayers[uActiveCharacter]->_49327B(26, 1) == 1 )
+            {
+              if ( !gold_transaction_amount )
+                goto LABEL_79;
+              goto LABEL_42;
+            }
+            return v35;
           case 20:
-            if ( v1->_49327B(0x23u, 1) == 1 )
-              goto LABEL_40;
-            v26 = 1;
-            v23 = 27;
-LABEL_39:
-            if ( v1->_49327B(v23, v26) == 1 )
-              goto LABEL_40;
+            if ( pPlayers[uActiveCharacter]->_49327B(0x23u, 1) == 1 )
+            {
+              if ( !gold_transaction_amount )
+                goto LABEL_79;
+              goto LABEL_42;
+            }
+            if ( pPlayers[uActiveCharacter]->_49327B(27, 1) == 1 )
+            {
+              if ( !gold_transaction_amount )
+                goto LABEL_79;
+              goto LABEL_42;
+            }
             return v35;
           case 30:
-            v18 = LOBYTE(v1->pActiveSkills[31]);
-            goto LABEL_47;
-          case 31:
-            v18 = LOBYTE(v1->pActiveSkills[30]);
-LABEL_47:
+            v18 = LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[31]);
             if ( (v18 & 0x3Fu) < 0xA )
               return v35;
-            goto LABEL_41;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
+          case 31:
+            v18 = LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[30]);
+            if ( (v18 & 0x3Fu) < 0xA )
+              return v35;
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
           case 21:
           case 23:
           case 24:
@@ -7092,46 +7124,66 @@
             goto LABEL_42;
           case 7:
             break;
+          default:
+            if ( !gold_transaction_amount )
+              goto LABEL_79;
+            goto LABEL_42;
         }
-LABEL_67:
         gold_transaction_amount = 0;
-        goto LABEL_41;
+        if ( !gold_transaction_amount )
+          goto LABEL_79;
+        goto LABEL_42;
       }
     }
     return v35;
   }
   if ( v7 < 4 )
     return v35;
-  v17 = dword_F8B1AC_award_bit_number;
   if ( dword_F8B1AC_award_bit_number > 27 )
   {
     if ( dword_F8B1AC_award_bit_number != 29
       && dword_F8B1AC_award_bit_number != 32
       && (dword_F8B1AC_award_bit_number <= 33 || dword_F8B1AC_award_bit_number > 35) )
     {
-LABEL_41:
       if ( !gold_transaction_amount )
         goto LABEL_79;
       goto LABEL_42;
     }
-LABEL_87:
     gold_transaction_amount = 500;
-    goto LABEL_41;
+    if ( !gold_transaction_amount )
+      goto LABEL_79;
+    goto LABEL_42;
   }
   if ( dword_F8B1AC_award_bit_number >= 23 )
-    goto LABEL_87;
+  {
+    gold_transaction_amount = 500;
+    if ( !gold_transaction_amount )
+      goto LABEL_79;
+    goto LABEL_42;
+  }
   if ( dword_F8B1AC_award_bit_number == 7 )
   {
     gold_transaction_amount = 0;
     goto LABEL_79;
   }
   if ( dword_F8B1AC_award_bit_number <= 7 )
-    goto LABEL_41;
+  {
+    if ( !gold_transaction_amount )
+      goto LABEL_79;
+    goto LABEL_42;
+  }
   if ( dword_F8B1AC_award_bit_number > 18 )
   {
     if ( dword_F8B1AC_award_bit_number != 21 )
-      goto LABEL_41;
-    goto LABEL_87;
+    {
+      if ( !gold_transaction_amount )
+        goto LABEL_79;
+      goto LABEL_42;
+    }
+    gold_transaction_amount = 500;
+    if ( !gold_transaction_amount )
+      goto LABEL_79;
+    goto LABEL_42;
   }
   gold_transaction_amount = 1000;
 LABEL_42:
@@ -7141,26 +7193,19 @@
   contract_approved = 1;
   if ( v34 == 2 )
   {
-    v27 = gold_transaction_amount;
-    v24 = pSkillNames[v17];
-    v21 = pGlobalTXT_LocalizationStrings[433];
-    goto LABEL_90;
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534],//  ^Pr[%s]   ^Pr[%s]  ^I[%lu] ^L[;;]
+              pGlobalTXT_LocalizationStrings[433], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);//
+    return pTmpBuf2;
   }
   if ( v34 == 3 )
   {
-    v27 = gold_transaction_amount;
-    v24 = pSkillNames[v17];
-    v21 = pGlobalTXT_LocalizationStrings[432];
-    goto LABEL_90;
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534],
+              pGlobalTXT_LocalizationStrings[432], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);//
+    return pTmpBuf2;
   }
   if ( v34 == 4 )
-  {
-    v27 = gold_transaction_amount;
-    v24 = pSkillNames[v17];
-    v21 = pGlobalTXT_LocalizationStrings[225];
-LABEL_90:
-    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27);
-  }
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534],
+              pGlobalTXT_LocalizationStrings[225], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);// 
   return pTmpBuf2;
 }
 
--- a/mm7_5.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_5.cpp	Sat May 04 18:19:08 2013 +0600
@@ -457,7 +457,7 @@
           GUIWindow::Create(215, 323, 17, 17, WINDOW_5A, (int)pBtnDownArrow, 0);
           continue;
         case UIMSG_Cancel:
-          GUIWindow::Create(350, 302, 106, 42, WINDOW_60, (int)pBtnCancel, 0);
+          GUIWindow::Create(350, 302, 106, 42, WINDOW_ExitRestWindow, (int)pBtnCancel, 0);
           continue;
         case UIMSG_LoadSlot:
           GUIWindow::Create(241, 302, 106, 42, WINDOW_5E, (int)pBtnLoadSlot, 0);
@@ -922,7 +922,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_63, (int)pBtn_Quests, 0);
+          pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Quests, 0);
           bFlashQuestBook = 0;
           continue;
         case UIMSG_OpenAutonotes:
@@ -933,7 +933,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_63, (int)pBtn_Autonotes, 0);
+          pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Autonotes, 0);
           bFlashAutonotesBook = 0;
           continue;
         case UIMSG_OpenMapBook:
@@ -945,8 +945,8 @@
           viewparams->sViewCenterX = pParty->vPosition.x;
           viewparams->sViewCenterY = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(546, 353, 0, 0, (enum WindowType)99, (int)pBtn_Maps, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(546, 353, 0, 0, WINDOW_BooksWindow, (int)pBtn_Maps, 0);
           continue;
         case UIMSG_OpenCalendar:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -956,7 +956,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_63, (int)pBtn_Calendar, 0);
+          pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_BooksWindow, (int)pBtn_Calendar, 0);
           continue;
         case UIMSG_OpenHistoryBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -966,7 +966,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_63, (int)pBtn_History, 0);
+          pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_BooksWindow, (int)pBtn_History, 0);
           bFlashHistoryBook = 0;
           continue;
         case UIMSG_Escape://  Escape and return to game
@@ -1551,7 +1551,7 @@
           sub_42FBDD();
           PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful);
           pVideoPlayer->Unload();
-          sub_44603D();
+          DialogueEnding();
           viewparams->bRedrawGameUI = v0;
           if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz )
           {
@@ -1605,10 +1605,10 @@
           if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
             pParty->uTimePlayed += 1474560i64;
           continue;
-        case UIMSG_19C:
+        case UIMSG_TransitionWindowCloseBtn:
           CloseWindowBackground();
           pVideoPlayer->Unload();
-          sub_44603D();
+          DialogueEnding();
           start_event_seq_number = 0;
           viewparams->bRedrawGameUI = v0;
           continue;
@@ -1639,7 +1639,7 @@
             if ( pParty->vPosition.y > 22528 )
               pParty->vPosition.y = 22528;
 LABEL_317:
-            sub_44603D();
+            DialogueEnding();
             pCurrentScreen = SCREEN_GAME;
           }
           else
@@ -1647,7 +1647,7 @@
             pParty->field_6E4 = 0;
             pParty->field_6E0 = 0;
             pCastSpellInfo->_427D48(v0);
-            sub_44603D();
+            DialogueEnding();
             pEventTimer->Pause();
             pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box);
             ++pGameLoadingUI_ProgressBar->uProgressMax;
@@ -1909,7 +1909,6 @@
         continue;
 
         case UIMSG_B2:
-			__debugbreak;//UIMSG_B2 -???
           bRecallingBeacon = uMessageParam;
           v127 = uMessageParam + 204;
           pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
@@ -1944,7 +1943,6 @@
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_B5:
-			__debugbreak;//UIMSG_B5 - ???
           dword_50CDC8 = v0;
           //goto LABEL_453;
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
@@ -2237,7 +2235,6 @@
           strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
           goto LABEL_524;
         case UIMSG_DD:
-          __debugbreak;
 LABEL_524:
           sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer);
           memcpy(&v216, txt_file_frametable_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216));
@@ -2478,7 +2475,7 @@
             _42ECB5_PlayerAttacksActor();
           continue;
         case UIMSG_ExitRest:
-          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (WindowType)96, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);// "Exit Rest"
+          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_ExitRestWindow, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);// "Exit Rest"
           continue;
         case UIMSG_Wait5Minutes:
           if ( dword_506F14 == 2 )
@@ -2651,8 +2648,7 @@
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
           continue;
-        case UIMSG_4E:
-			__debugbreak;//UIMSG_4E -???
+        case UIMSG_HintSelectRemoveQuickSpellBtn:
           if ( quick_spell_at_page && byte_506550 )
           {
             v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
@@ -2689,8 +2685,7 @@
           sub_41C0B8_set_status_string(pTmpBuf);
           v0 = 1;
           continue;
-        case UIMSG_58:
-			__debugbreak;//UIMSG_58 - ???
+        case UIMSG_ClickInstallRemoveQuickSpellBtn:
           GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_5A, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
             continue;
@@ -2710,7 +2705,6 @@
           byte_506550 = 0;
           continue;
         case UIMSG_33:
-			__debugbreak;//UIMSG_33 - ???
           if ( !uActiveCharacter )
             continue;
           pPlayer3 = pPlayers[uActiveCharacter];
@@ -2808,7 +2802,6 @@
         continue;
 
         case UIMSG_92:
-			__debugbreak;//UIMSG_92 - ???
           if ( pTurnEngine->field_4 != 3 )
             _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, v0, 0);
           continue;
@@ -2887,7 +2880,6 @@
           free((void *)uNumSeconds);
           stru_506E40._40E55E("gamma.pcx", 0);
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
-          uNumVisibleWindows = uNumVisibleWindows - 1; //Ritor1: Insert
 //LABEL_453:
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
@@ -2899,18 +2891,15 @@
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         case UIMSG_C0:
-			__debugbreak;//UIMSG_C0 - ???
           dword_50651C = v0;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
             dword_50651C = -1;
           continue;
         case UIMSG_A9:
-			__debugbreak;
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_5B, (int)pBtn_Up, 0);
           dword_506548 = v0;
           continue;
         case UIMSG_AA:
-			__debugbreak;
           GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_5B, (int)pBtn_Down, 0);
           dword_506544 = v0;
           continue;
@@ -2941,20 +2930,18 @@
         case UIMSG_ClickPaperdoll:
           OnPaperdollLeftClick();
           continue;
-        case UIMSG_73:
-			__debugbreak;
+        case UIMSG_ClickStatsBtn:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
           sub_4196A0();
           sub_419379();
-          GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_StatsBtn, 0);
-          continue;
-        case UIMSG_72:
-			__debugbreak;
+          GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, WINDOW_5B, (int)pCharacterScreen_StatsBtn, 0);
+          continue;
+        case UIMSG_ClickSkillsBtn:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
           sub_4196A0();
           sub_419379();
           CharacterUI_SkillScreen_Draw();
-          GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_SkillsBtn, 0);
+          GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, WINDOW_5B, (int)pCharacterScreen_SkillsBtn, 0);
           continue;
         case UIMSG_SkillUp:
           pPlayer4 = pPlayers[uActiveCharacter];
@@ -2979,25 +2966,21 @@
           }
           ShowStatusBarString(v87, 2);
           continue;
-        case UIMSG_74:
-			__debugbreak;
+        case UIMSG_ClickInventoryBtn:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
           sub_419379();
           sub_4196A0();
-          GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_InventoryBtn, 0);
-          continue;
-        case UIMSG_A8:
-			__debugbreak;
-          GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, (WindowType)97, (int)pCharacterScreen_ExitBtn, 0);
-          continue;
-        case UIMSG_75:
-			__debugbreak;
+          GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, WINDOW_5B, (int)pCharacterScreen_InventoryBtn, 0);
+          continue;
+        case UIMSG_ClickExitCharacterWindowBtn:
+          GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, WINDOW_ExitCharacterWindow, (int)pCharacterScreen_ExitBtn, 0);
+          continue;
+        case UIMSG_ClickAwardsBtn:
           sub_419379();
           sub_4196A0();
           sub_419220();
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102;
-          GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42),
-            (int)pCharacterScreen_AwardsBtn, 0);
+          GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, WINDOW_5B, (int)pCharacterScreen_AwardsBtn, 0);
           FillAwardsData();
           continue;
         case UIMSG_AutonotesBook:
@@ -3052,7 +3035,7 @@
               dword_50652C = v0;
               break;
           }
-          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (WindowType)92, (int)pButton, v0);
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, v0);
           continue;
         case UIMSG_SelectCharacter:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3108,7 +3091,6 @@
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_C:
-			__debugbreak;
           if ( pCurrentScreen == SCREEN_F )
           {
             sub_421EA6_OnInventoryLeftClick();
@@ -3119,8 +3101,7 @@
         case UIMSG_InventoryLeftClick:
           sub_421EA6_OnInventoryLeftClick();
           continue;
-        case UIMSG_A:
-			__debugbreak;
+        case UIMSG_MouseLeftClickInGame:
           if ( !pRenderer->pRenderD3D )
           {
             if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3170,14 +3151,12 @@
             continue;
           }*/
           continue;
-        case UIMSG_E:
-			__debugbreak;
+        case UIMSG_E://        UIMSG_MouseLeftClickInGame
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
           continue;
         case UIMSG_F:
-			__debugbreak;
           if ( pRenderer->pRenderD3D )
           {
             LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
@@ -3189,10 +3168,9 @@
             v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]];
           }
           pButton2 = (GUIButton *)(unsigned __int16)v116;
-          GUIWindow::Create(0, 0, 0, 0, (WindowType)15, (int)pButton2, 0);
+          GUIWindow::Create(0, 0, 0, 0, WINDOW_F, (int)pButton2, 0);
           continue;
         case UIMSG_54:
-			__debugbreak;
           pButton2 = (GUIButton *)uMessageParam;
           GUIWindow::Create(0, 0, 0, 0, (WindowType)22, (int)pButton2, 0);
           continue;
@@ -3201,12 +3179,11 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnPressSpace();
           continue;
-        case UIMSG_16F:
-			__debugbreak;
+        case UIMSG_ClickZoomOutBtn:
           if ( pCurrentScreen )
             continue;
           pParty->uFlags |= 2u;
-          GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)pBtn_ZoomOut, 0);
+          GUIWindow::Create(0x207u, 0x88u, 0, 0, WINDOW_5A, (int)pBtn_ZoomOut, 0);
           uNumSeconds = 131072;
           v118 = 2 * viewparams->uMinimapZoom;
           ++viewparams->field_28;
@@ -3222,15 +3199,21 @@
           }
           v119 = 2048;
           if ( (signed int)v118 <= 2048 )
-            goto LABEL_789;
+          {
+            dword_576E2C = v118;
+            dword_576E28 = viewparams->field_28;
+            break;
+          }
           viewparams->field_28 = 11;
-          goto LABEL_788;
-        case UIMSG_170:
-			__debugbreak;
+          viewparams->uMinimapZoom = v119;
+          dword_576E2C = v119;
+          dword_576E28 = viewparams->field_28;
+          break;
+        case UIMSG_ClickZoomInBtn:
           if ( pCurrentScreen )
             continue;
           pParty->uFlags |= 2u;
-          GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)pBtn_ZoomIn, 0);
+          GUIWindow::Create(0x23Eu, 0x88u, 0, 0, WINDOW_5A, (int)pBtn_ZoomIn, 0);
           uNumSeconds = 32768;
           v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
           --viewparams->field_28;
@@ -3241,11 +3224,9 @@
             if ( (signed int)v118 < 512 )
             {
               viewparams->field_28 = 9;
-LABEL_788:
               v118 = v119;
               viewparams->uMinimapZoom = v119;
             }
-LABEL_789:
             dword_576E2C = v118;
             dword_576E28 = viewparams->field_28;
           }
@@ -3364,146 +3345,170 @@
 
   if ( pMessageQueue_50CBD0->uNumMessages )
   {
-    //v0 = pAudioPlayer;
-    //pPlayer1 = pParty->pPlayers;
     pPlayer = pParty->pPlayers;
     do
     {
       int param2;
       pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &param2);
+      auto player = &pParty->pPlayers[uNum];
+      auto sex = player->GetSexByVoice();
 
       switch (pUIMessageType) // For buttons of window MainMenu
       {
         case UIMSG_MainMenu_ShowPartyCreationWnd:
-        {
           GUIWindow::Create(495, 172, 0, 0, WINDOW_5A, (int)pMainMenu_BtnNew, 0);
           SetCurrentMenuID(MENU_NEWGAME);
-        }
-        continue;
+          break;
         case UIMSG_MainMenu_ShowLoadWindow:
-        {
           GUIWindow::Create(495, 227, 0, 0, WINDOW_5A, (int)pMainMenu_BtnLoad, 0);
           SetCurrentMenuID(MENU_SAVELOAD);
-        }
-        continue;
+          break;
         case UIMSG_ShowCredits:
-        {
           GUIWindow::Create(495, 282, 0, 0, WINDOW_5A, (int)pMainMenu_BtnCredits, 0);
           SetCurrentMenuID(MENU_CREDITS);
-        }
-        continue;
+          break;
         case UIMSG_ExitToWindows:
-        {
           GUIWindow::Create(495, 337, 0, 0, WINDOW_5A, (int)pMainMenu_BtnExit, 0);
           SetCurrentMenuID(MENU_FINISHED);
-        }
-        continue;
-      }
-
-      
-      switch (pUIMessageType) // For buttons of Party Creation Window
-      {
+          break;
         case UIMSG_PlayerCreation_SelectAttribute:
-        {
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = uNum;
-            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-        }
-        continue;
-
+          pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                    % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+          uPlayerCreationUI_SelectedCharacter = uNum;
+          pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+          break;
         case UIMSG_PlayerCreation_VoicePrev:
-        {
-            auto player = &pParty->pPlayers[uNum];
-            auto sex = player->GetSexByVoice();
-            do
-            {
-              if (player->uVoiceID == 0)
-                player->uVoiceID = 19;
-              else --player->uVoiceID;
-            }
-            while (player->GetSexByVoice() != sex);
-
-            pButton = pCreationUI_BtnPressLeft2[uNum];
-            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
-            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-            player->PlaySound(SPEECH_PickMe, 0);
-        }
-        continue;
-
+          do
+          {
+            if (player->uVoiceID == 0)
+              player->uVoiceID = 19;
+            else --player->uVoiceID;
+          }
+          while (player->GetSexByVoice() != sex);
+          pButton = pCreationUI_BtnPressLeft2[uNum];
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
+          pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+          player->PlaySound(SPEECH_PickMe, 0);
+          break;
         case UIMSG_PlayerCreation_VoiceNext:
-        {
-            auto player = &pParty->pPlayers[uNum];
-            auto sex = player->GetSexByVoice();
+          {
+            //auto player = &pParty->pPlayers[uNum];
+            //auto sex = player->GetSexByVoice();
             do
             {
               player->uVoiceID = (player->uVoiceID + 1) % 20;
             }
             while (player->GetSexByVoice() != sex);
-
             pButton = pCreationUI_BtnPressRight2[uNum];
             GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
             pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
             player->PlaySound(SPEECH_PickMe, 0);
-        }
-        continue;
-
+            break;
+          }
         case UIMSG_PlayerCreation_FacePrev:
-        {
-            pPlayer = &pParty->pPlayers[uNum];
-            if (!pPlayer->uFace)
-              pPlayer->uFace = 19;
-            else
-              pPlayer->uFace -= 1;
-            pPlayer->uVoiceID = pPlayer->uFace;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v25 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v25;
-            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressLeft[v25], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0);
-            pPlayer->PlaySound(SPEECH_PickMe, 0);
-            //v1 = (char *)pParty->pPlayers;
-        }
-        continue;
-
+          pPlayer = &pParty->pPlayers[uNum];
+          if (!pPlayer->uFace)
+            pPlayer->uFace = 19;
+          else
+            pPlayer->uFace -= 1;
+          pPlayer->uVoiceID = pPlayer->uFace;
+          pPlayer->SetInitialStats();
+          pPlayer->SetSexByVoice();
+          pPlayer->RandomizeName();
+          v25 = uNum;
+          pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                    % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+          uPlayerCreationUI_SelectedCharacter = v25;
+          GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressLeft[v25], 1);
+          //v0 = pAudioPlayer;
+          pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0);
+          pPlayer->PlaySound(SPEECH_PickMe, 0);
+          //v1 = (char *)pParty->pPlayers;
+          break;
         case UIMSG_PlayerCreation_FaceNext:
-        {
-            pPlayer = &pParty->pPlayers[uNum];
-            v20 = (char)((int)pPlayer->uFace + 1) % 20;
-            pPlayer->uFace = v20;
-            pPlayer->uVoiceID = v20;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v21 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v21;
-            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressRight[v21], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-            pPlayer->PlaySound(SPEECH_PickMe, 0);
-            //v1 = (char *)pParty->pPlayers;
-        }
-        continue;
-      }
-
-      switch (pUIMessageType) // For buttons of window LoadGame
-      {
+          pPlayer = &pParty->pPlayers[uNum];
+          v20 = (char)((int)pPlayer->uFace + 1) % 20;
+          pPlayer->uFace = v20;
+          pPlayer->uVoiceID = v20;
+          pPlayer->SetInitialStats();
+          pPlayer->SetSexByVoice();
+          pPlayer->RandomizeName();
+          v21 = uNum;
+          pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                    % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+          uPlayerCreationUI_SelectedCharacter = v21;
+          GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressRight[v21], 1);
+          //v0 = pAudioPlayer;
+          pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+          pPlayer->PlaySound(SPEECH_PickMe, 0);
+          //v1 = (char *)pParty->pPlayers;
+          break;
+        case UIMSG_PlayerCreationClickPlus:
+          GUIWindow::Create(613, 393, 0, 0, WINDOW_5A, (int)pPlayerCreationUI_BtnPlus, 1);
+          pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
+          pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0);
+          break;
+        case UIMSG_PlayerCreationClickMinus:
+          GUIWindow::Create(523, 393, 0, 0, WINDOW_5A, (int)pPlayerCreationUI_BtnMinus, 1);
+          pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
+          pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0);
+          break;
+        case UIMSG_PlayerCreationSelectActiveSkill:
+          {
+            auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
+            v6 = _t->GetSkillIdxByOrder(uNum + 4);
+            if ( _t->GetSkillIdxByOrder(3) == 37 )
+              pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
+            pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
+            break;
+          }
+        case UIMSG_PlayerCreationSelectClass:
+          pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)uNum);
+          pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+          break;
+        case UIMSG_PlayerCreationClickOK:
+          GUIWindow::Create(580, 431, 0, 0, WINDOW_5A, (int)pPlayerCreationUI_BtnOK, 0);
+          if ( PlayerCreation_ComputeAttributeBonus() || !PlayerCreation_Chose4Skills() )
+            GameUI_Footer_TimeLeft = GetTickCount() + 4000;
+          else
+            uGameState = 6;
+          break;
+        case UIMSG_PlayerCreationClickReset:
+          GUIWindow::Create(527, 431, 0, 0, WINDOW_5A, (int)pPlayerCreationUI_BtnReset, 0);
+          pParty->Reset();
+          break;
+        case UIMSG_PlayerCreationRemoveUpSkill:
+          uPlayerCreationUI_SelectedCharacter = uNum;
+          v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+          //int pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+          v41 = 2;
+          v5 = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+          pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
+          pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
+                                         + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
+          break;
+        case UIMSG_PlayerCreationChangeName:
+          pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
+          v3 = (void *)uNum;
+          uPlayerCreationUI_SelectedCharacter = uNum;
+          pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu);
+          pGUIWindow_CurrentMenu->ptr_1C = v3;
+          break;
+        case UIMSG_ChangeGameState:
+          uGameState = 1;
+          break;
+        case UIMSG_11:
+          pMouse->SetCursorBitmap("MICON2");
+          break;
+        case UIMSG_3A:
+          SetCurrentMenuID(MENU_10);
+          break;
         case UIMSG_LoadGame:
-        {
           if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot])
-            continue;
+            break;
           SetCurrentMenuID(MENU_LOADINGPROC);
-          continue;
-        }
+          break;
         case UIMSG_SelectLoadSlot:
-        {
             //main menu save/load wnd   clicking on savegame lines
           if (pGUIWindow_CurrentMenu->field_40 == 1)
             pKeyActionMap->_459ED1(0);
@@ -3526,89 +3531,45 @@
               strcpy((char *)pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
               pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
           }
-          continue;
-        }
+          break;
         case UIMSG_LoadSlot:
-        {
           GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_5E, (int)pBtnLoadSlot, 0);
-        continue;
-        }
+          break;
         case UIMSG_DownArrow:
-        {
           ++pSaveListPosition;
           if ( pSaveListPosition >= uNum )
             pSaveListPosition = uNum - 1;
           if ( pSaveListPosition < 1 )
             pSaveListPosition = 0;
           pWindow = pGUIWindow_CurrentMenu;
-          GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (WindowType)90, (int)pBtnDownArrow, 0);
-          continue;
-        }
+          GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, WINDOW_5A, (int)pBtnDownArrow, 0);
+          break;
         case UIMSG_Cancel:
-        {
-          GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (WindowType)95, (int)pBtnCancel, 0);
-          continue;
-        }
+          GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_LoadGame_CancelBtn, (int)pBtnCancel, 0);
+          break;
         case UIMSG_ArrowUp:
-        {
           --pSaveListPosition;
           if ( pSaveListPosition < 0 )
             pSaveListPosition = 0;
           pWindow = pGUIWindow_CurrentMenu;
-          GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (WindowType)90, (int)pBtnArrowUp, 0);
-          continue;
-        }
-      }
-
-      if ( (signed int)pUIMessageType > UIMSG_PlayerCreationRemoveDownSkill )// For button of window PlayerCreation
-      {
-        if ( pUIMessageType > UIMSG_DownArrow )
-        {
-          if ( pUIMessageType == UIMSG_AD )//unknow
-          {
-            __debugbreak();
-            GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
-            SetCurrentMenuID(MENU_LOADINGPROC);
-            continue;
-          }
-          if ( pUIMessageType != UIMSG_AE )//unknow
-          {
-            __debugbreak();
-            continue;
-          }
-          GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
+          GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, WINDOW_5A, (int)pBtnArrowUp, 0);
+          break;
+        case UIMSG_AD:
+          GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, WINDOW_5A, (int)pMainMenu_BtnNew, 0);
+          SetCurrentMenuID(MENU_LOADINGPROC);
+          break;
+        case UIMSG_AE:
+          GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, WINDOW_5A, (int)pMainMenu_BtnExit, 0);
           SetCurrentMenuID(MENU_10);
-          continue;
-        }
-        if ( pUIMessageType == UIMSG_GameMenuButton )//unknow
-        {
-          __debugbreak();
-          if ( pCurrentScreen )
-          {
-            pGUIWindow_CurrentMenu->Release();
-            pEventTimer->Resume();
-            pCurrentScreen = SCREEN_GAME;
-            viewparams->bRedrawGameUI = 1;
-          }
-          GUIWindow::Create(602, 450, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
-          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
-            continue;
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;*/
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-          continue;
-        }
-        if ( pUIMessageType == UIMSG_Escape )
-        {
+          break;
+        case UIMSG_Escape:
           if ( ptr_507BDC )
           {
             sub_41426F();
-            continue;
+            break;
           }
           if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x40) )
-            continue;
+            break;
           v15 = 1;
           pVideoPlayer->bStopBeforeSchedule = 1;
           viewparams->bRedrawGameUI = 1;
@@ -3621,12 +3582,12 @@
             if (GetCurrentMenuID() == MENU_NAMEPANELESC)
             {
               SetCurrentMenuID(MENU_CREATEPARTY);
-              continue;
+              break;
             }
             if (GetCurrentMenuID() == MENU_CREDITSPROC)
             {
               SetCurrentMenuID(MENU_CREDITSCLOSE);
-              continue;
+              break;
             }
             /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
             {
@@ -3638,7 +3599,7 @@
               continue;
             }*/
             pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0);
-            continue;
+            break;
           }
           v16 = GetCurrentMenuID() == 8;
           if ( v16 && !pCurrentScreen )
@@ -3658,7 +3619,7 @@
             pEventTimer->Resume();
             pCurrentScreen = SCREEN_GAME;
             viewparams->bRedrawGameUI = v15;
-            continue;
+            break;
           }
           if ( pCurrentScreen == SCREEN_VIDEO )
           {
@@ -3675,16 +3636,12 @@
               pEventTimer->Resume();
               pCurrentScreen = SCREEN_GAME;
               viewparams->bRedrawGameUI = v15;
-              continue;
+              break;
             }
             //VideoPlayer::dtor();
           }
-        }
-      }
-      else
-      {
-        if ( pUIMessageType == UIMSG_PlayerCreationRemoveDownSkill )
-        {
+          break;
+        case UIMSG_PlayerCreationRemoveDownSkill:
           uPlayerCreationUI_SelectedCharacter = uNum;
           //v41 = 3;
           //v1 = (char *)pParty->pPlayers;
@@ -3692,93 +3649,9 @@
              + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
           pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3)
                                              + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
-          continue;
-        }
-        if ( (signed int)pUIMessageType > UIMSG_PlayerCreationChangeName )
-        {
-          if ( pUIMessageType == UIMSG_PlayerCreationClickPlus )
-          {
-            GUIWindow::Create(613, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
-            pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
-            pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationClickMinus )
-          {
-            GUIWindow::Create(523, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
-            pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
-            pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationSelectActiveSkill )
-          {
-            auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
-            v6 = _t->GetSkillIdxByOrder(uNum + 4);
-            if ( _t->GetSkillIdxByOrder(3) == 37 )
-              pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
-            pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
-          {
-            pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)uNum);
-            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
-          {
-            GUIWindow::Create(580, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
-            if ( PlayerCreation_ComputeAttributeBonus() || !PlayerCreation_Chose4Skills() )
-              GameUI_Footer_TimeLeft = GetTickCount() + 4000;
-            else
-              uGameState = 6;
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationClickReset ) 
-          {
-            GUIWindow::Create(527, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
-            pParty->Reset();
-          }
-          else
-          {
-            if ( pUIMessageType == UIMSG_PlayerCreationRemoveUpSkill )
-            {
-              uPlayerCreationUI_SelectedCharacter = uNum;
-              v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
-              int pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
-              v41 = 2;
-              v5 = v4 % 7 + pSex + 7 * uNum;
-              pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
-              pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
-                                             + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
-              continue;
-            }
-          }
-        }
-        else
-        {
-          switch ( pUIMessageType )
-          {
-            case UIMSG_PlayerCreationChangeName:
-              pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
-              v3 = (void *)uNum;
-              uPlayerCreationUI_SelectedCharacter = uNum;
-              pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu);
-              pGUIWindow_CurrentMenu->ptr_1C = v3;
-              break;
-            case UIMSG_ChangeGameState:
-              uGameState = 1;
-              break;
-            case UIMSG_11://unknow
-              __debugbreak();
-              pMouse->SetCursorBitmap("MICON2");
-              break;
-            case UIMSG_3A://unknow
-              __debugbreak();
-              SetCurrentMenuID(MENU_10);
-              break;
-          }
-        }
+          break;
+        default:
+          break;
       }
     }
     while ( pMessageQueue_50CBD0->uNumMessages );
@@ -10404,7 +10277,7 @@
   unsigned int v29; // eax@111
   GUIFont *pGUIFont; // ST1C_4@115
   int v31; // eax@115
-  void *v32; // ebp@118
+  GUIButton *pButton; // ebp@118
   int v33; // eax@119
   int v34; // eax@120
   int v35; // eax@121
@@ -10569,7 +10442,7 @@
 			pGUIWindow2->Release();
 			break;
 			}
-		case WINDOW_60:
+		case WINDOW_ExitRestWindow:
 			{
 			if ( pWindow->Hint != (char *)1 )
 				pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
@@ -10583,27 +10456,27 @@
 			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
 			break;
 			}
-		case WINDOW_61:
+		case WINDOW_ExitCharacterWindow:
 			{
-			if ( pWindow->Hint != (char *)1 )//pWindowType == WINDOW_61
+			if ( pWindow->Hint != (char *)1 )
 				pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-			v32 = pWindow->ptr_1C;
-			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
+			pButton = (GUIButton *)pWindow->ptr_1C;
+			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
 			pHint = pWindow->Hint;
 			viewparams->bRedrawGameUI = 1;
 			if ( pHint && pHint != (char *)1 )
-				((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
+				pButton->DrawLabel(pHint, pFontCreate, 0, 0);
 			pWindow->Release();
 			pNumMessages = pMessageQueue_50CBD0->uNumMessages;
 			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
 			break;
 			}
-		case WINDOW_63:
+		case WINDOW_BooksWindow:
 			{
-			pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99 (0x63) WINDOW_63
+			pButton = (GUIButton *)pWindow->ptr_1C;
             pY = pWindow->uFrameY;
             pX = pWindow->uFrameX;
-            pRenderer->DrawTextureIndexed(pX, pY, pTexture);
+			pRenderer->DrawTextureIndexed(pX, pY, pButton->pTextures[0]);
             viewparams->bRedrawGameUI = 1;
             break;
 			}
@@ -11644,7 +11517,7 @@
 //----- (00419379) --------------------------------------------------------
 void __cdecl sub_419379()
 {
-  GUIButton *i; // esi@2
+  GUIButton *pButton; // esi@2
 
   if ( dword_507CBC )
   {
@@ -11654,14 +11527,14 @@
     pBtn_Down->Release();
     pBtn_Down = 0;
     pBtn_Up = 0;
-    for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
-    {
-      if ( i->msg == UIMSG_InventoryLeftClick )
-      {
-        i->uX = dword_50698C;
-        i->uY = dword_506988;
-        i->uZ = dword_506984;
-        i->uW = dword_506980;
+    for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext )
+    {
+      if ( pButton->msg == UIMSG_InventoryLeftClick )
+      {
+        pButton->uX = dword_50698C;
+        pButton->uY = dword_506988;
+        pButton->uZ = dword_506984;
+        pButton->uW = dword_506980;
         pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
       }
     }
--- a/mm7_6.cpp	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_6.cpp	Sat May 04 18:19:08 2013 +0600
@@ -1196,74 +1196,37 @@
 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
 
 //----- (004269A2) --------------------------------------------------------
-int __fastcall GivePartyExp(unsigned int a1)
+void __fastcall GivePartyExp(unsigned int pEXPNum)
 {
-  //unsigned __int64 v1; // qax@1
-  Player *v1;
-  int v1b;
-  signed int v2; // ecx@1
-  int *v3; // esi@1
-  bool v4; // edi@6
-  int *v5; // edi@10
-  Player *v6; // esi@10
-  int v7; // eax@13
-  unsigned __int8 v8; // cf@13
-  int v10[4]; // [sp+Ch] [bp-14h]@1
-  int v11; // [sp+1Ch] [bp-4h]@10
-
-  //v1 = __PAIR__((int)((char *)&pParty + 2620), a1);
-  v1 = pParty->pPlayers;
-  v1b = a1;
-  v2 = 0;
-  v3 = v10;
-  do
+  signed int pActivePlayerCount; // ecx@1
+  int pLearningPercent; // eax@13
+
+  pActivePlayerCount = 0;
+  for ( uint i = 0; i < 4; ++i )
+  {
+    if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] )
+      pActivePlayerCount ++;
+  }
+  if ( pActivePlayerCount )
   {
-    /*v4 = !(*(int *)(HIDWORD(v1) - 4) | *(int *)(HIDWORD(v1) - 8))
-      && !*(int *)HIDWORD(v1)
-      && !*(_QWORD *)(HIDWORD(v1) + 8)
-      && !*(_QWORD *)(HIDWORD(v1) + 16);*/
-	v4 = !(HIDWORD(v1->pConditions[13]) | LODWORD(v1->pConditions[13]))
-	  && !v1->pConditions[14]
-	  && !v1->pConditions[15]
-	  && !v1->pConditions[16];
-    *v3 = v4;
-    //HIDWORD(v1) += 6972;
-	++v1;
-    v2 += v4;
-    ++v3;
-  }
-  while ( v1 <= &pParty->pPlayers[3] );
-  if ( v2 )
-  {
-    v1b = v1b / v2;
-    v5 = v10;
-    v6 = pParty->pPlayers;//[0].uExperience;
-    v11 = v1b;
-    do
+    pEXPNum = pEXPNum / pActivePlayerCount;
+    for ( uint i = 0; i < 4; ++i )
     {
-      if ( *v5 )
+      if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] )
       {
-        if ( v11 )
+        if ( pEXPNum )
         {
-          LOBYTE(v7) = v6->GetLearningPercent();
-          v1b = v11 + v11 * (char)v7 / 100;
-          //v8 = __CFADD__((int)v1, LODWORD(v6->uExperience));
-		  //need review
-          LODWORD(v6->uExperience) += v1b;
-          //HIDWORD(v6->uExperience) += HIDWORD(v1) + v8;
-          if ( v6->uExperience > 4000000000i64 )
+          pLearningPercent = pParty->pPlayers[i].GetLearningPercent();
+          pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100;
+          pParty->pPlayers[i].uExperience += pEXPNum;
+          if ( pParty->pPlayers[i].uExperience > 4000000000i64 )
           {
-            HIDWORD(v6->uExperience) = 0;
-            LODWORD(v6->uExperience) = -294967296;
+            pParty->pPlayers[i].uExperience = 0;
           }
         }
       }
-      ++v6;
-      ++v5;
     }
-	while ( v6 <= &pParty->pPlayers[3] );
   }
-  return v1b;
 }
 
 //----- (00426A5A) --------------------------------------------------------
@@ -2283,7 +2246,7 @@
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_1B, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 0, 0x31u, "", 0);
         pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 1u, 0x32u, "", 0);
         pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 2u, 0x33u, "", 0);
@@ -2296,7 +2259,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_1B, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_46, 0, 0, "", 0);
         sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -2306,7 +2269,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_1B, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_BE, 0, 0, "", 0);
         sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -2328,7 +2291,7 @@
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_1B, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 0, 0x31u, "", 0);
         pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 1, 0x32u, "", 0);
         pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 2, 0x33u, "", 0);
@@ -2338,24 +2301,16 @@
       }
       if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings )
       {
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_1B, (int)&pCastSpellInfo[result], 0);
         pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
-                       1,
-                       0,
-                       UIMSG_ScrollNPCPanel, 0,
-                       0,
-                       "",
+                       1, 0, UIMSG_ScrollNPCPanel, 0, 0, "",
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
         pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight,
-                       1,
-                       0,
-                       UIMSG_ScrollNPCPanel, 1,
-                       0,
-                       "",
+                       1, 0, UIMSG_ScrollNPCPanel, 1, 0, "",
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
         pGUIWindow_Settings->CreateButton(0x1EBu, 149, 64, 74, 1, 0, UIMSG_8F, 4, 0x35u, "", 0);
         pGUIWindow_Settings->CreateButton(0x231u, 149, 64, 74, 1, 0, UIMSG_8F, 5, 0x36u, "", 0);
--- a/mm7_data.h	Sat May 04 18:18:47 2013 +0600
+++ b/mm7_data.h	Sat May 04 18:19:08 2013 +0600
@@ -1557,7 +1557,7 @@
 void LoadSpellbook(unsigned int uID); // idb
 struct GUIWindow *__cdecl sub_41140B();
 void __cdecl sub_411473();
-void __cdecl OnCloseSpellook();
+void __cdecl OnCloseSpellBook();
 void __cdecl InitializeBookTextures();
 void __cdecl InitializeBookFonts();
 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
@@ -1653,7 +1653,7 @@
 int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor); // idb
 int __fastcall _42690D_colors_cvt(unsigned int a1);
 void __cdecl sub_426947();
-int __fastcall GivePartyExp(unsigned int a1);
+void __fastcall GivePartyExp(unsigned int pEXPNum);
 bool __fastcall sub_427769_spell(unsigned int uSpellID);
 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);
 int __fastcall sub_42EBBE(int, int); // weak
@@ -1743,7 +1743,7 @@
 struct NPCData *__fastcall GetNPCData(signed int npcid);
 struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);
 int __fastcall GetGreetType(signed int SpeakingNPC_ID);
-void __cdecl sub_44603D();
+void __cdecl DialogueEnding();
 void PrepareHouse(enum HOUSE_ID house); // idb
 bool  EnterHouse(enum HOUSE_ID uHouseID);
 int sub_4465DF_check_season(int a1);