changeset 20:980c34defdab

Слияние
author Ritor1
date Thu, 17 Jan 2013 22:59:03 +0600
parents 2127707df23f (current diff) d5954a85577a (diff)
children 5070f4343e0e
files mm7_5.cpp
diffstat 8 files changed, 307 insertions(+), 384 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/GUIWindow.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -121,9 +121,9 @@
   {
     v9 = LODWORD(v18->uExpireTime);
     v10 = HIDWORD(v18->uExpireTime);
-    if ( (v10 & 0x80000000u) == 0 && ((signed int)v10 > 0 || v9) )
+    if ( (v10 & 0x80000000u) == 0 && ((signed int)v10 > 0 || v9) )//!!!
     {
-      v11 = __PAIR__(v10, v9) - pParty->uTimePlayed;
+      v11 = __PAIR__(v10, v9) - pParty->uTimePlayed;//!!!
       v12 = v20 * LOBYTE(v1->uFontHeight) + 40;
       v13 = *v16;
       ++v20;
@@ -950,7 +950,7 @@
                   v8 = v7 + 1;
                   if ( (signed int)v7 + 1 > 0 )
                   {
-                    memset32((void *)(4 * dword_506520 + 6043152), v24, v8);
+                    memset32((char *)&pStru179 + 4 * dword_506520 , v24, v8);
                     do
                     {
                       LODWORD(v7) = dword_506520++;
@@ -1947,66 +1947,66 @@
 //----- (0041D12F) --------------------------------------------------------
 GUIButton *GUIWindow::CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...)
 {
-  GUIButton *v12; // esi@1
+  GUIButton *pButton; // esi@1
   unsigned int v13; // eax@1
   unsigned int v14; // ebx@4
   unsigned int v15; // eax@4
-  unsigned int v16; // ebx@4
+  unsigned int pTextureNum; // ebx@4
   unsigned int v17; // eax@4
   Texture *v18; // eax@4
   Texture **v19; // ecx@5
   Texture **v20; // edx@5
   GUIButton *v21; // eax@7
 
-  v12 = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON");
-  v12->pParent = this;
-  v12->uX = uX + this->uFrameX;
+  pButton = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON");
+  pButton->pParent = this;
+  pButton->uX = uX + this->uFrameX;
   v13 = uY + this->uFrameY;
-  v12->uHeight = uHeight;
-  v12->uY = v13;
-  v12->uWidth = uWidth;
+  pButton->uHeight = uHeight;
+  pButton->uY = v13;
+  pButton->uWidth = uWidth;
   if ( a6 == 2 && !uHeight )
-    v12->uHeight = uWidth;
-  v14 = v12->uX;
-  v12->uButtonType = a6;
+    pButton->uHeight = uWidth;
+  v14 = pButton->uX;
+  pButton->uButtonType = a6;
   v15 = v14 + uWidth - 1;
-  v16 = 0;
-  v12->uZ = v15;
-  v17 = v12->uY;
-  v12->field_2C = 0;
-  v12->uW = v17 + uHeight - 1;
-  v12->field_1C = a7;
-  v12->uControlID = uControlID;
-  v12->uControlParam = uControlParam;
-  v12->uHotkey = uHotkey;
+  pTextureNum = 0;
+  pButton->uZ = v15;
+  v17 = pButton->uY;
+  pButton->field_2C = 0;
+  pButton->uW = v17 + uHeight - 1;
+  pButton->field_1C = a7;
+  pButton->uControlID = uControlID;
+  pButton->uControlParam = uControlParam;
+  pButton->uHotkey = uHotkey;
   strlen(pName);
-  strcpy(v12->pButtonName, pName);
+  strcpy(pButton->pButtonName, pName);
   v18 = pTextures;
   if ( pTextures )
   {
     v19 = &pTextures;
-    v20 = v12->pTextures;
+    v20 = pButton->pTextures;
     do
     {
       ++v19;
       *v20 = v18;
-      ++v16;
+      ++pTextureNum;
       ++v20;
       v18 = *v19;
     }
     while ( *v19 );
   }
-  v12->uNumTextures = v16;
+  pButton->uNumTextures = pTextureNum;
   v21 = this->pControlsTail;
   if ( v21 )
-    v21->pNext = v12;
+    v21->pNext = pButton;
   else
-    this->pControlsHead = v12;
-  v12->pPrev = this->pControlsTail;
-  this->pControlsTail = v12;
-  v12->pNext = 0;
+    this->pControlsHead = pButton;
+  pButton->pPrev = this->pControlsTail;
+  this->pControlsTail = pButton;
+  pButton->pNext = 0;
   ++this->uNumControls;
-  return v12;
+  return pButton;
 }
 
 //----- (00459C2B) --------------------------------------------------------
--- a/GUIWindow.h	Thu Jan 17 22:58:41 2013 +0600
+++ b/GUIWindow.h	Thu Jan 17 22:59:03 2013 +0600
@@ -34,27 +34,50 @@
 {
   WINDOW_null = 0,
   WINDOW_MainMenu = 0x1,
+  WINDOW_3 = 0x3,
   WINDOW_CharacterRecord = 0x4,
   WINDOW_Options = 0x6,
   WINDOW_Book = 0x9,
-  WINDOW_A = 10,
-  WINDOW_ChangeLocation = 17,
-  WINDOW_SpellBook = 18,
-  WINDOW_GreetingNPC = 19,
+  WINDOW_A = 0xA, //10,
+  WINDOW_C = 0xC, //12,
+  WINDOW_10 = 0x10, //16,
+  WINDOW_ChangeLocation = 0x11, //17,
+  WINDOW_SpellBook = 0x12, //18,
+  WINDOW_GreetingNPC = 0x13, //19,
   WINDOW_Chest = 0x14,
+  WINDOW_17 = 0x17,
   WINDOW_MainMenu_Load = 0x18,
   WINDOW_HouseInterior = 0x19,
-  WINDOW_1A = 26,
-  WINDOW_1B = 27,
-  WINDOW_1E = 30,
-  WINDOW_1F = 31,
+  WINDOW_1A = 0x1A, //26,
+  WINDOW_1B = 0x1B, //27,
+  WINDOW_1E = 0x1E, //30,
+  WINDOW_1F = 0x1F, //31,
   WINDOW_FinalWindow = 0x46,
+  WINDOW_50 = 0x50,
+  WINDOW_59 = 0x59,
   WINDOW_5A = 0x5A,
+  WINDOW_5B = 0x5B,
+  WINDOW_5C = 0x5C,
+  WINDOW_5D = 0x5D,
   WINDOW_5E = 0x5E,
   WINDOW_5F = 0x5F,
   WINDOW_60 = 0x60,
+  WINDOW_61 = 0x61,
+  WINDOW_RestWindow = 0x62,
+  WINDOW_63 = 0x63,
+  WINDOW_CharacterWindow_Stats = 0x64,
+  WINDOW_CharacterWindow_Skills = 0x65,
+  WINDOW_CharacterWindow_Awards = 0x66,
+  WINDOW_CharacterWindow_Inventory = 0x67,
   WINDOW_KeyMappingOptions = 0x69,
-  WINDOW_VideoOptions = 0x6A
+  WINDOW_VideoOptions = 0x6A,
+  WINDOW_Lloyd = 0xB1,
+  WINDOW_TownPortal = 0xC3,
+  WINDOW_QuestBook = 0xC8,
+  WINDOW_AutonotesBook = 0xC9,
+  WINDOW_MapsBook = 0xCA,
+  WINDOW_CalendarBook = 0xCB,
+  WINDOW_HistoryBook = 0xCC,
 };
 
 /*  155 */
--- a/LOD.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/LOD.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -1691,7 +1691,7 @@
   if ( !this->pIOBuffer || !this->uIOBufferSize )
     return 3;
   v7 = this->uNumSubIndices == 0;
-  v8 = (this->uNumSubIndices & 0x80000000u) != 0;
+  v8 = this->uNumSubIndices != 0; // v8 = (this->uNumSubIndices & 0x80000000u) != 0;
   v36 = 0;
   v34 = 0;
   if ( v8 | v7 )
@@ -1720,7 +1720,7 @@
     v35 += 32;
     ++v5;
     v11 = v5 >= v4->uNumSubIndices;
-    v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
+    v8 = (v5 - v4->uNumSubIndices) != 0;//v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
     v34 = v5;
     if ( !(v8 ^ v11) )
       goto LABEL_22;
--- a/Vis.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/Vis.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -326,7 +326,7 @@
   v10 = v9 < v5;
   v11 = 0;
   v12 = v9 == v5;
-  BYTE1(result) = HIBYTE(v8);
+  BYTE1(result) = HIBYTE(v8);//crash
   if ( v9 >= v5
     && (v14 = x - 1.0, /*UNDEF(v13),*/ v15 = v14 < a1a, v16 = 0, v17 = v14 == a1a, BYTE1(result) = HIBYTE(v13), v15 | v17)
     && (v19 = y + 1.0, /*UNDEF(v18),*/ v20 = v19 < v29, v21 = 0, v22 = v19 == v29, BYTE1(result) = HIBYTE(v18), v19 >= v29)
--- a/mm7_1.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/mm7_1.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -1237,8 +1237,8 @@
 {
   unsigned int v1; // edi@1
   unsigned int v2; // eax@6
-  Texture *v3; // ecx@6
-  GUIButton *v4; // eax@6
+  Texture *pTexture; // ecx@6
+  GUIButton *pButton; // eax@6
   unsigned int v5; // eax@7
   unsigned int v6; // eax@10
   unsigned int v7; // eax@11
@@ -1249,15 +1249,15 @@
     pRenderer->ClearZBuffer(0, 479);
     switch ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] )
     {
-      case 0x64:                                // stats
+      case WINDOW_CharacterWindow_Stats:                                // stats
         sub_4196A0();
         sub_419379();
         CharacterUI_StatsTab_Draw(v1);
         v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
-        v3 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
-        v4 = pCharacterScreen_StatsBtn;
+        pTexture = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
+        pButton = pCharacterScreen_StatsBtn;
         break;
-      case 0x65:                                // skills
+      case WINDOW_CharacterWindow_Skills:                                // skills
         if ( dword_507CC0 != uActiveCharacter )
         {
           sub_4196A0();
@@ -1266,30 +1266,30 @@
         sub_419379();
         CharacterUI_SkillsTab_Draw(v1);
         v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
-        v3 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
-        v4 = pCharacterScreen_SkillsBtn;
+        pTexture = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
+        pButton = pCharacterScreen_SkillsBtn;
         break;
-      case 0x66:                                // awards
+      case WINDOW_CharacterWindow_Awards:                                // awards
         sub_4196A0();
         sub_419379();
         sub_419220();
         CharacterUI_AwardsTab_Draw(v1);
         v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
-        v3 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
-        v4 = pCharacterScreen_AwardsBtn;
+        pTexture = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
+        pButton = pCharacterScreen_AwardsBtn;
         break;
-      default:
+      default:                                                            // inventory and other
         if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103 )
           goto LABEL_13;
         sub_4196A0();
         sub_419379();
         CharacterUI_InventoryTab_Draw(v1, 0);
         v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
-        v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
-        v4 = pCharacterScreen_InventoryBtn;
+        pTexture = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
+        pButton = pCharacterScreen_InventoryBtn;
         break;
     }
-    pRenderer->DrawTextureIndexed(v4->uX, v4->uY, v3);
+    pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
 LABEL_13:
     if ( bRingsShownInCharScreen )
       CharacterUI_DrawPaperdollWithRingOverlay(v1);
@@ -1704,7 +1704,6 @@
   //Texture *v18; // ST60_4@1
   unsigned int uTextureID_ib_td4_A; // eax@1
   Texture *v20; // ST78_4@1
-  const char *v21; // ST5C_4@1
   unsigned __int8 v22; // al@1
   //Texture *v23; // ST60_4@1
   Texture *v24; // eax@1
@@ -1773,82 +1772,31 @@
   pPrimaryWindow->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
   uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
   v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
-  v7 = pGlobalTXT_LocalizationStrings[174];
+  v7 = pGlobalTXT_LocalizationStrings[174];//Quests
   v8 = pKeyActionMap->GetActionVKey(INPUT_Quest);
-  pBtn_Quests = pPrimaryWindow->CreateButton(
-                 0x1EBu,
-                 0x161u,
-                 v6->uTextureWidth,
-                 v6->uTextureHeight,
-                 1,
-                 0,
-                 0xC8u,
-                 0,
-                 v8,
-                 v7,
-                 v6, 0);
+  pBtn_Quests = pPrimaryWindow->CreateButton(0x1EBu, 0x161u, v6->uTextureWidth, v6->uTextureHeight, 1, 0, 0xC8u, 0, v8, v7, v6, 0);
   uTextureID_ib_td2_A = pIcons_LOD->LoadTexture("ib-td2-A", TEXTURE_16BIT_PALETTE);
   v10 = (Texture *)(uTextureID_ib_td2_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0);
-  v11 = pGlobalTXT_LocalizationStrings[154];
+  v11 = pGlobalTXT_LocalizationStrings[154];//Autonotes
   v12 = pKeyActionMap->GetActionVKey(INPUT_Autonotes);
-  pBtn_Autonotes = pPrimaryWindow->CreateButton(
-                 0x20Fu,
-                 0x161u,
-                 v10->uTextureWidth,
-                 v10->uTextureHeight,
-                 1,
-                 0,
-                 0xC9u,
-                 0,
-                 v12,
-                 v11,
-                 v10);
+  pBtn_Autonotes = pPrimaryWindow->CreateButton(0x20Fu, 0x161u, v10->uTextureWidth, v10->uTextureHeight, 1, 0, 0xC9u, 0, v12, v11, v10, 0);
   v14 = pIcons_LOD->LoadTexture("ib-td3-A", TEXTURE_16BIT_PALETTE);
   v15 = (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0);
-  v16 = pGlobalTXT_LocalizationStrings[139];
+  v16 = pGlobalTXT_LocalizationStrings[139];//Maps
   v17 = pKeyActionMap->GetActionVKey(INPUT_Mapbook);
-  pBtn_Maps = pPrimaryWindow->CreateButton(
-                 0x222u,
-                 0x161u,
-                 v15->uTextureWidth,
-                 v15->uTextureHeight,
-                 1,
-                 0,
-                 0xCAu,
-                 0,
-                 v17,
-                 v16,
-                 v15);
+  pBtn_Maps = pPrimaryWindow->CreateButton(0x222u, 0x161u, v15->uTextureWidth, v15->uTextureHeight, 1, 0, 0xCAu, 0, v17, v16, v15, 0);
   uTextureID_ib_td4_A = pIcons_LOD->LoadTexture("ib-td4-A", TEXTURE_16BIT_PALETTE);
   v20 = (Texture *)(uTextureID_ib_td4_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td4_A] : 0);
-  v21 = pGlobalTXT_LocalizationStrings[78];
   v22 = pKeyActionMap->GetActionVKey(INPUT_TimeCal);
-  pBtn_Calendar = pPrimaryWindow->CreateButton(
-                   0x23Au,
-                   0x161u,
-                   v20->uTextureWidth,
-                   v20->uTextureHeight,
-                   1,
-                   0,
-                   0xCBu,
-                   0,
-                   v22,
-                   v21,
-                   v20);
+  pBtn_Calendar = pPrimaryWindow->CreateButton(0x23Au, 0x161u, v20->uTextureWidth, v20->uTextureHeight, 1, 0, 0xCBu, 0, v22,
+                                                pGlobalTXT_LocalizationStrings[78],//Calendar
+                                                 v20, 0);
   uTextureID_ib_td5_A = pIcons_LOD->LoadTexture("ib-td5-A", TEXTURE_16BIT_PALETTE);
-  pBtn_History = pPrimaryWindow->CreateButton(
-                 0x258u,
-                 0x169u,
+  pBtn_History = pPrimaryWindow->CreateButton(0x258u, 0x169u,
                  (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureWidth : 24),
                  (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureHeight : 26),
-                 1,
-                 0,
-                 0xE0u,
-                 0,
-                 0x48u,
-                 pGlobalTXT_LocalizationStrings[602],
-                 (Texture *)(uTextureID_ib_td5_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0),
-                 0);
+                 1, 0, 0xE0u, 0, 0x48u, pGlobalTXT_LocalizationStrings[602],//History
+                 (Texture *)(uTextureID_ib_td5_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0), 0);
   v24 = &pIcons_LOD->pTextures[uTextureID_507980];
   v25 = (Texture *)(uTextureID_507980 != -1 ? (int)v24 : 0);
   bFlashHistoryBook = 0;
@@ -5311,7 +5259,7 @@
   if ( uNumVisibleWindows <= 0 )
   {
 LABEL_38:
-    if ( pCurrentScreen == 10 )
+    if ( pCurrentScreen == 10 ) // ChestScreen
     {
       sub_42038D();
       //goto _return;
@@ -5326,7 +5274,7 @@
       uLastPointedObjectID = pMouse->uPointingObjectID;
       return;
     }
-    if ( pCurrentScreen == 13 )
+    if ( pCurrentScreen == 13 ) // HouseScreen
     {
       if ( dword_F8B19C != 2
         || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0)
@@ -5411,7 +5359,7 @@
             && (signed int)pY <= (signed int)pButton->uW )
           {
             pMessageType3 = (UIMessageType)pButton->field_1C;
-            if ( pMessageType3 == 0 )
+            if ( pMessageType3 == 0 ) // For books
               //goto LABEL_28;
             {
               v13 = pButton->pButtonName;
--- a/mm7_5.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/mm7_5.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -7006,8 +7006,8 @@
 {
   Player **ppPlayer; // esi@1
   Player *pPlayer; // ebx@1
-  enum CHARACTER_RACE v3; // edi@1
-  signed int v4; // eax@1
+  enum CHARACTER_RACE pRace; // edi@1
+  signed int pSex; // eax@1
   int v5; // edi@4
   unsigned int v6; // ecx@9
   int v7; // ecx@10
@@ -7242,7 +7242,7 @@
   int v236; // [sp+20h] [bp-2Ch]@260
   int v237; // [sp+20h] [bp-2Ch]@298
   int v238; // [sp+20h] [bp-2Ch]@336
-  int v239; // [sp+24h] [bp-28h]@6
+  int pBodyComplection; // [sp+24h] [bp-28h]@6
   int v240; // [sp+28h] [bp-24h]@7
   unsigned int v241; // [sp+2Ch] [bp-20h]@38
   int v242; // [sp+2Ch] [bp-20h]@197
@@ -7251,7 +7251,7 @@
   signed int v245; // [sp+34h] [bp-18h]@361
   unsigned int uPlayerID_; // [sp+38h] [bp-14h]@1
   int uPlayerID_a; // [sp+38h] [bp-14h]@9
-  signed int v248; // [sp+40h] [bp-Ch]@4
+  signed int IsDwarf; // [sp+40h] [bp-Ch]@4
   int v249; // [sp+40h] [bp-Ch]@358
   signed int v250; // [sp+44h] [bp-8h]@1
 
@@ -7260,36 +7260,33 @@
   uPlayerID_ = uPlayerID;
   v217 = *ppPlayer;
   pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
-  v3 = pPlayer->GetRace();
-  v4 = pPlayer->GetSexByVoice();
-  v250 = v4;
-  if ( v3 && v3 != 1 && v3 != 2 )
-  {
-    v248 = 1;
-    v5 = (v4 != 0) + 2;
-  }
-  else
-  {
-    v248 = 0;
-    v5 = v4 != 0;
-  }
-  v239 = v5;
+  pRace = pPlayer->GetRace();
+  pSex = pPlayer->GetSexByVoice();
+  v250 = pSex;
+  if ( pRace && pRace != 1 && pRace != 2 )
+  {
+    IsDwarf = 1;
+    v5 = (pSex != 0) + 2;
+  }
+  else
+  {
+    IsDwarf = 0;
+    v5 = pSex != 0;
+  }
+  pBodyComplection = v5;
   v244 = (*ppPlayer)->uFace;
   pRenderer->ResetClip();
-  pRenderer->DrawTextureIndexed(
-    0x1D3u,
-    0,
-    (Texture *)(uTextureID_BACKDOLL != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BACKDOLL] : 0));
+  pRenderer->DrawTextureIndexed(0x1D3u, 0, (Texture *)(uTextureID_BACKDOLL != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BACKDOLL] : 0));//
   if ( !IsPlayerWearingWatersuit[uPlayerID_] )
   {
-    v21 = pPlayer->pEquipment.uBow;
+    v21 = pPlayer->pEquipment.uBow; //  
     if ( !v21 )
       goto LABEL_59;
     v230 = pPlayer->pEquipment.uBow;
     v22 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v21 + 5];
     v23 = *(int *)v22;
-    v24 = papredoll_4E4C28 + array_4E4C30[v239].equip_x - pItemsTable->pItems[v23].uEquipX;
-    a3b = paperdoll_4E4C2C + array_4E4C30[v239].equip_y - pItemsTable->pItems[v23].uEquipY;
+    v24 = papredoll_4E4C28 + array_4E4C30[pBodyComplection].equip_x - pItemsTable->pItems[v23].uEquipX;
+    a3b = paperdoll_4E4C2C + array_4E4C30[pBodyComplection].equip_y - pItemsTable->pItems[v23].uEquipY;
     v241 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v23].pIconName, TEXTURE_16BIT_PALETTE);
     v25 = *(int *)(v22 + 20);
     if ( !(*(int *)(v22 + 20) & 0xF0) )
@@ -7318,7 +7315,7 @@
       if ( !bRingsShownInCharScreen )
         pRenderer->_4A612A(v24, a3b, v27, v230);
 LABEL_59:
-      v31 = v217->pEquipment.uCloak;
+      v31 = v217->pEquipment.uCloak;//  
       if ( !v31 )
         goto LABEL_93;
       v231 = v217->pEquipment.uCloak;
@@ -7345,7 +7342,7 @@
               if ( v33 < 0 || v33 >= 10 )
                 goto LABEL_93;
 LABEL_74:
-              v34 = v33 + 10 * v239;
+              v34 = v33 + 10 * pBodyComplection;
               v35 = paperdoll_array_511828[0][v34];
               a2c = papredoll_4E4C28 + paperdoll_array_4E5570[0][v34][0];// TODO indexing
               v36 = paperdoll_4E4C2C + paperdoll_array_4E5570[0][v34][1];
@@ -7368,11 +7365,9 @@
                   pRenderer->_4A612A(a2c, a3c, v42, v231);
 LABEL_93:
                 v240 = 4 * uPlayerID_ - 4;
-                pRenderer->DrawTextureTransparent(
-                  papredoll_4E4C28,
-                  paperdoll_4E4C2C,
+                pRenderer->DrawTextureTransparent(papredoll_4E4C28, paperdoll_4E4C2C,
                   (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
-                v43 = v217->pEquipment.uBody;
+                v43 = v217->pEquipment.uBody;//  
                 if ( !v43 )
                   goto LABEL_127;
                 v232 = v217->pEquipment.uBody;
@@ -7399,7 +7394,7 @@
                         if ( v45 < 0 || v45 >= 17 )
                           goto LABEL_127;
 LABEL_106:
-                        v46 = 17 * v239 + v45;
+                        v46 = 17 * pBodyComplection + v45;
                         a2d = papredoll_4E4C28 + paperdoll_array_4E4E30[0][v46][0];// TODO indexing
                         v47 = paperdoll_4E4C2C + paperdoll_array_4E4E30[0][v46][1];
                         v48 = paperdoll_array_511290[0][v46][0];
@@ -7440,17 +7435,17 @@
                           v58 = *(int *)v57;
                           if ( *(int *)v57 == 529 )
                           {
-                            a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][1];
-                            a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][0];
+                            a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[pBodyComplection][1];
+                            a2e = papredoll_4E4C28 + paredoll_array_4E54B8[pBodyComplection][0];
                             v59 = papredoll_flying_feet[v244];
                           }
                           else
                           {
                             if ( v58 == 512 )
                             {
-                              a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][3];
-                              a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][2];
-                              v59 = dword_511638[v239][5];
+                              a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[pBodyComplection][3];
+                              a2e = papredoll_4E4C28 + paredoll_array_4E54B8[pBodyComplection][2];
+                              v59 = dword_511638[pBodyComplection][5];
                             }
                             else
                             {
@@ -7459,14 +7454,14 @@
                               {
                                 a2e = 0;
                                 a3e = 0;
-                                v59 = dword_511638[v239][0];
+                                v59 = dword_511638[pBodyComplection][0];
                               }
                               else
                               {
-                                v61 = v60 + 7 * v239;
+                                v61 = v60 + 7 * pBodyComplection;
                                 a3e = paperdoll_4E4C2C + dword_4E5490[0][v61][1];
                                 a2e = papredoll_4E4C28 + dword_4E5490[0][v61][0];
-                                v59 = dword_511638[0][v60 + 6 * v239];
+                                v59 = dword_511638[0][v60 + 6 * pBodyComplection];
                               }
                             }
                           }
@@ -7498,14 +7493,12 @@
 LABEL_155:
                             v68 = v217;
                             v69 = v217->pEquipment.uMainHand;
-                            uPlayerID_a = 2 * v239;
-                            if ( !v69
-                              || (v70 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
+                            uPlayerID_a = 2 * pBodyComplection;
+                            if ( !v69 || (v70 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
                                   pItemsTable->pItems[v70].uEquipType != 1)
                               && (pItemsTable->pItems[v70].uSkillType != 4 || v217->pEquipment.uOffHand) )
-                              pRenderer->DrawTextureTransparent(
-                                papredoll_4E4C28 + dword_4E5AE0[2 * v239],
-                                paperdoll_4E4C2C + dword_4E5AE0[2 * v239 + 1],
+                              pRenderer->DrawTextureTransparent(papredoll_4E4C28 + dword_4E5AE0[2 * pBodyComplection],
+                                paperdoll_4E4C2C + dword_4E5AE0[2 * pBodyComplection + 1],
                                 (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
                             v71 = v217->pEquipment.uBelt;
                             if ( v71 )
@@ -7529,13 +7522,13 @@
                               if ( v73 >= 0 && v73 < 7 )
                               {
 LABEL_168:
-                                v74 = 7 * v239 + v73;
+                                v74 = 7 * pBodyComplection + v73;
                                 a2f = papredoll_4E4C28 + dword_4E57F0[0][v74][0];
                                 a3f = paperdoll_4E4C2C + dword_4E57F0[0][v74][1];
-                                if ( v248 != 1 || v73 == 5 )
+                                if ( IsDwarf != 1 || v73 == 5 )
                                   v75 = stru_511718.texids[v74];
                                 else
-                                  v75 = stru_511718.texids[v73 + 7 * (v239 - 2)];
+                                  v75 = stru_511718.texids[v73 + 7 * (pBodyComplection - 2)];
                                 v76 = *(int *)&v217->field_1F5[36 * v71 + 15];
                                 if ( !(*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) )
                                 {
@@ -7588,14 +7581,8 @@
                                       ptr_50C9A4 = 0;
                                     }
                                     v78 = (double)GetTickCount() * 0.1;
-                                    pRenderer->_4A63E6(
-                                      a2f,
-                                      a3f,
-                                      (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0),
-                                      v77,
-                                      (signed __int64)v78,
-                                      0,
-                                      255);
+                                    pRenderer->_4A63E6(a2f, a3f, (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0),
+                                      v77, (signed __int64)v78, 0, 255);
 LABEL_191:
                                     v68 = v217;
                                     goto LABEL_192;
@@ -7612,8 +7599,7 @@
                               v83 = *(int *)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v82 + 5];
                               if ( pItemsTable->pItems[v83].uEquipType == 1
                                 || pItemsTable->pItems[v83].uSkillType == 4 && !v68->pEquipment.uOffHand )
-                                pRenderer->DrawTextureTransparent(
-                                  papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
+                                pRenderer->DrawTextureTransparent(papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
                                   paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
                                   (Texture *)(*(unsigned int *)((char *)papredoll_dlaus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlaus + v240)] : 0));
                             }
@@ -7666,7 +7652,7 @@
                                               if ( v114 < 0 || v114 >= 10 )
                                                 goto LABEL_293;
 LABEL_274:
-                                              v115 = v114 + 10 * v239;
+                                              v115 = v114 + 10 * pBodyComplection;
                                               v116 = dword_511788[v115];
                                               v115 *= 8;
                                               v117 = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
@@ -7719,10 +7705,10 @@
                                                   }
                                                   v125 = v192;
 LABEL_312:
-                                                  v126 = 2 * (v125 + 16 * v239);
+                                                  v126 = 2 * (v125 + 16 * pBodyComplection);
                                                   a2j = papredoll_4E4C28 + dword_4E58D0[v126];
                                                   a3i = paperdoll_4E4C2C + dword_4E58D4[v126];
-                                                  if ( v248 != 1 || *(int *)v124 != 92 )
+                                                  if ( IsDwarf != 1 || *(int *)v124 != 92 )
                                                     v127 = stru_511698.texids[v125 + 16 * v250];
                                                   else
                                                     v127 = papredoll_dbrds[11];
@@ -7800,10 +7786,10 @@
                                                   v136 = *(int *)v135;
                                                   v137 = *(int *)v135;
                                                   a2k = papredoll_4E4C28
-                                                      + array_4E4C30[v239].field_8
+                                                      + array_4E4C30[pBodyComplection].field_8
                                                       - pItemsTable->pItems[v137].uEquipX;
                                                   a3j = paperdoll_4E4C2C
-                                                      + array_4E4C30[v239].field_C
+                                                      + array_4E4C30[pBodyComplection].field_C
                                                       - pItemsTable->pItems[v137].uEquipY;
                                                   if ( v136 == 64 )
                                                     v181 = "item64v1";
@@ -7850,10 +7836,10 @@
                                                       v245 = 0;
 LABEL_362:
                                                       v150 = papredoll_4E4C28
-                                                           + array_4E4C30[v239].field_0
+                                                           + array_4E4C30[pBodyComplection].field_0
                                                            - pItemsTable->pItems[v148].uEquipX;
                                                       a3k = paperdoll_4E4C2C
-                                                          + LODWORD(array_4E4C30[v239].field_4)
+                                                          + LODWORD(array_4E4C30[pBodyComplection].field_4)
                                                           - pItemsTable->pItems[v148].uEquipY;
                                                       goto LABEL_370;
                                                     }
@@ -7941,11 +7927,9 @@
                                                                   255);
 LABEL_391:
                                                                 if ( v245 )
-                                                                  pRenderer->DrawTextureTransparent(
-                                                                    papredoll_4E4C28
+                                                                  pRenderer->DrawTextureTransparent(papredoll_4E4C28
                                                                   + pPaperdollLeftEmptyHand[uPlayerID_a],
-                                                                    paperdoll_4E4C2C
-                                                                  + pPaperdollLeftEmptyHand[uPlayerID_a + 1],
+                                                                    paperdoll_4E4C2C + pPaperdollLeftEmptyHand[uPlayerID_a + 1],
                                                                     (Texture *)(*(unsigned int *)((char *)papredoll_dlhs
                                                                                                 + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhs + v240)] : 0));
                                                                 goto LABEL_393;
@@ -7996,14 +7980,8 @@
                                                         ptr_50C9A4 = 0;
                                                       }
                                                       v141 = (double)GetTickCount() * 0.1;
-                                                      pRenderer->_4A63E6(
-                                                        a2k,
-                                                        a3j,
-                                                        (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0),
-                                                        v140,
-                                                        (signed __int64)v141,
-                                                        0,
-                                                        255);
+                                                      pRenderer->_4A63E6(a2k, a3j, (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0),
+                                                        v140, (signed __int64)v141, 0, 255);
                                                       goto LABEL_358;
                                                     }
                                                   }
@@ -8085,7 +8063,7 @@
                                        || v68->GetEquippedItemSkillType(EQUIP_TWO_HANDED) == 4
                                        && !v68->pEquipment.uOffHand) )
                                     {
-                                      v91 = 17 * v239 + v90;
+                                      v91 = 17 * pBodyComplection + v90;
                                       v92 = v91;
                                       v223 = paperdoll_array_511290[0][v91][2];
                                       if ( v223 == pIcons_LOD->FindTextureByName("pending") )
@@ -8134,14 +8112,8 @@
                                             v174 = 0;
                                             v97 = (double)GetTickCount();
 LABEL_249:
-                                            pRenderer->_4A63E6(
-                                              a2g,
-                                              a3g,
-                                              (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0),
-                                              (Texture *)v96,
-                                              (signed __int64)(v97 * 0.1),
-                                              v174,
-                                              v187);
+                                            pRenderer->_4A63E6(a2g, a3g, (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0),
+                                              (Texture *)v96, (signed __int64)(v97 * 0.1), v174, v187);
                                             goto LABEL_258;
                                           }
                                         }
@@ -8177,7 +8149,7 @@
                                       v165 = a2g;
                                       goto LABEL_255;
                                     }
-                                    v102 = 17 * v239 + v90;
+                                    v102 = 17 * pBodyComplection + v90;
                                     v94 = paperdoll_array_511290[0][v102][1];
                                     if ( v94 == pIcons_LOD->FindTextureByName("pending") )
                                     {
@@ -8341,14 +8313,8 @@
                                   ptr_50C9A4 = 0;
                                 }
                                 v52 = (double)GetTickCount() * 0.1;
-                                pRenderer->_4A63E6(
-                                  a2d,
-                                  a3d,
-                                  (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0),
-                                  v51,
-                                  (signed __int64)v52,
-                                  0,
-                                  255);
+                                pRenderer->_4A63E6(a2d, a3d, (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0),
+                                  v51, (signed __int64)v52, 0, 255);
                                 goto LABEL_127;
                               }
 LABEL_116:
@@ -13534,7 +13500,7 @@
 // 50654C: using guessed type int dword_50654C;
 
 //----- (00412E85) --------------------------------------------------------
-char __cdecl sub_412E85()
+char __cdecl DrawBook_History()
 {
   unsigned int v0; // eax@3
   unsigned int v1; // eax@7
@@ -13641,7 +13607,7 @@
 
 
 //----- (00413126) --------------------------------------------------------
-void __cdecl DrawSpellbook_Quests()
+void __cdecl DrawBook_Quests()
 {
   unsigned int v0; // eax@3
   unsigned int v1; // eax@7
@@ -13737,7 +13703,7 @@
 
 
 //----- (0041338E) --------------------------------------------------------
-void __cdecl DrawSpellbook_Autonotes()
+void __cdecl DrawBook_Autonotes()
 {
   unsigned int v0; // eax@3
   unsigned int v1; // eax@7
@@ -14040,7 +14006,7 @@
 
 
 //----- (00413980) --------------------------------------------------------
-char *__cdecl DrawSpellbook_Map()
+char *__cdecl DrawBook_Maps()
 {
   unsigned int v0; // eax@3
   unsigned int v1; // eax@7
@@ -14186,37 +14152,34 @@
 
 
 //----- (00413CC6) --------------------------------------------------------
-void __thiscall DrawSpellbook(unsigned int uBook)
-{
-  unsigned int v1; // esi@1
-
-  v1 = uBook;
-  pRenderer->DrawTextureIndexed(
-    471u,
-    445u,
-    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
-  switch ( v1 )
-  {
-    case 0xB1u:
+void __thiscall SellectDrawBook(unsigned int uBook)
+{
+  enum WindowType pWindowType; // esi@1
+
+  pWindowType = (enum WindowType)uBook;
+  pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+  switch ( pWindowType )
+  {
+    case WINDOW_Lloyd: // 177
       DrawLloydBeaconsScreen();
       break;
-    case 0xC3u:
+    case WINDOW_TownPortal: //195
       DrawTownPortalScreen();
       break;
-    case 0xC8u:
-      DrawSpellbook_Quests();
+    case WINDOW_QuestBook: //200
+      DrawBook_Quests();
       break;
-    case 0xC9u:
-      DrawSpellbook_Autonotes();
+    case WINDOW_AutonotesBook: //201
+      DrawBook_Autonotes();
       break;
-    case 0xCAu:
-      DrawSpellbook_Map();
+    case WINDOW_MapsBook://202
+      DrawBook_Maps();
       break;
-    case 0xCBu:
-      DrawSpellbook_Calendar();
+    case WINDOW_CalendarBook://203
+      DrawBook_Calendar();
       break;
-    case 0xE0u:
-      sub_412E85();
+    case WINDOW_HistoryBook://224
+      DrawBook_History();
       break;
   }
 }
@@ -14237,7 +14200,7 @@
 }
 
 //----- (00413D6F) --------------------------------------------------------
-char __cdecl DrawSpellbook_Calendar()
+char __cdecl DrawBook_Calendar()
 {
   unsigned int v0; // esi@1
   char *v1; // eax@5
@@ -14990,7 +14953,7 @@
 
 
 //----- (004156F0) --------------------------------------------------------
-void __cdecl GUI_UpdateWindows()
+void __cdecl GUI_UpdateWindows() //     
 {
   GUIWindow *pWindow; // esi@4
   unsigned int pWindowType; // eax@4
@@ -15120,12 +15083,12 @@
                   if ( v38 == 1 )//pWindowType == 106 (0x6A) WINDOW_VideoOptions
                     GameMenuUI_DrawVideoOptions();
                 }
-                else//pWindowType == 105
+                else//pWindowType == 105 (0x69) WINDOW_KeyMappingOptions
                 {
                   GameMenuUI_DrawKeyBindings();
                 }
               }
-              else//pWindowType == 103
+              else//pWindowType == 103 (0x67) WINDOW_67
               {
                 pWindow->DrawMessageBox(0);
                 pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
@@ -15147,7 +15110,7 @@
               }
               continue;
             }
-            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99
+            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99 (0x63) WINDOW_63
             pY = pWindow->uFrameY;
             pX = pWindow->uFrameX;
 //LABEL_18:
@@ -15156,7 +15119,7 @@
             viewparams->bRedrawGameUI = 1;
             continue;
           }
-          memset(&GUIButton2, 0, 0xBCu);//pWindowType == 98
+          memset(&GUIButton2, 0, 0xBCu);//pWindowType == 98 (0x62) WINDOW_RestWindow
           GUIButton2.uZ = 197;
           GUIButton2.uW = 197;
           GUIButton2.uX = 27;
@@ -15175,7 +15138,7 @@
           pGUIWindow2->Release();
           continue;
         }
-        if ( pWindow->Hint != (char *)1 )//pWindowType == 97
+        if ( pWindow->Hint != (char *)1 )//pWindowType == 97 (0x61) WINDOW_61
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
         v32 = pWindow->ptr_1C;
         pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
@@ -15226,7 +15189,7 @@
       if ( v14 )//pWindowType > 80
       {
         v15 = v14 - 9;
-        if ( !v15 )//pWindowType == 89
+        if ( !v15 )//pWindowType == 89 (0x59) WINDOW_59
         {
           pWindow->DrawMessageBox(0);
           pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
@@ -15263,17 +15226,17 @@
           continue;
         }
         v16 = v15 - 1;
-        if ( !v16 )// pWindowType == 90
+        if ( !v16 )// pWindowType == 90 (0x5A) WINDOW_5A
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
           pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
-          if ( (pButtonPtr_1C->uX /*& 0x80000000u*/) == 0 )
+          if ( pButtonPtr_1C->uX >= 0 )//if ( (pButtonPtr_1C->uX & 0x80000000u) == 0 )
           {
             if ( (signed int)pButtonPtr_1C->uX <= 640 )
             {
               //v25 = pButtonPtr_1C->uY;
-              if ( (pButtonPtr_1C->uY /*& 0x80000000u*/) == 0 )
+              if ( pButtonPtr_1C->uY >= 0 ) //if ( (pButtonPtr_1C->uY & 0x80000000u) == 0 )
               {
                 if ( (signed int)pButtonPtr_1C->uY <= 480 )
                 {
@@ -15314,7 +15277,7 @@
           continue;
         }
         v17 = v16 - 1;
-        if ( !v17 )//pWindowType == 91
+        if ( !v17 )//pWindowType == 91 (0x5B) WINDOW_5B
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -15339,7 +15302,7 @@
           continue;
         }
         v18 = v17 - 1;
-        if ( !v18 )//pWindowType == 92
+        if ( !v18 )//pWindowType == 92 (0x5C) WINDOW_5C
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -15359,7 +15322,7 @@
           continue;
         }
         v19 = v18 - 1;
-        if ( !v19 )//pWindowType == 93
+        if ( !v19 )//pWindowType == 93 (0x5D) WINDOW_5D
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -15372,7 +15335,7 @@
           continue;
         }
       }
-      else//pWindowType == 80
+      else//pWindowType == 80 (0x50) WINDOW_50
       {
         v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
         if ( ptr_507BD0->field_40 == 1 )
@@ -15415,7 +15378,7 @@
     }
     else
     {
-      if ( pWindowType == 70 )
+      if ( pWindowType == 70 ) // 0x46 WINDOW_FinalWindow
       {
         sub_41420D_press_esc();
         continue;
@@ -15430,7 +15393,7 @@
             v13 = v12 - 4;
             if ( v13 )//pWindowType > 30
             {
-              if ( v13 == 1 ) //pWindowType == 31
+              if ( v13 == 1 ) //pWindowType == 31 (0x1F) WINDOW_1F
               {
                 pRenderer->ClearZBuffer(0, 479);
                 draw_leather();
@@ -15440,12 +15403,12 @@
                   (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
               }
             }
-            else// pWindowType == 30
+            else// pWindowType == 30 (0x1E) WINDOW_1E
             {
               sub_467FB6();
             }
           }
-          else //pWindowType == 26
+          else //pWindowType == 26 (0x1A) WINDOW_1A
           {
             TransitionUI_Draw();
           }
@@ -15462,15 +15425,15 @@
               v9 = v8 - 3;
               if ( v9 )//pWindowType > 23
               {
-                //if ( v9 == 1 ) //pWindowType == 24
+                //if ( v9 == 1 ) //pWindowType == 24 (0x18) WINDOW_MainMenu_Load
                 //  sub_4606F7();
               }
-              else//pWindowType == 23
+              else//pWindowType == 23 (0x17) WINDOW_17
               {
                 sub_4606FE();
               }
             }
-            else//pWindowType == 20
+            else//pWindowType == 20 (0x14) WINDOW_Chest
             {
               if ( pCurrentScreen == 10 )
               {
@@ -15489,7 +15452,7 @@
               }
             }
           }
-          else//pWindowType == 19
+          else//pWindowType == 19 (0x13) WINDOW_GreetingNPC
           {
             DrawBranchlessDialogueUI();
           }
@@ -15526,7 +15489,7 @@
         }
         continue;
       }
-      if ( pWindowType == 18 )
+      if ( pWindowType == 18 ) //(0x12) WINDOW_SpellBook
       {
         sub_412B58();
       }
@@ -15540,15 +15503,15 @@
             v6 = v5 - 4;
             if ( v6 )//pWindowType > 16
             {
-              if ( v6 == 1 )//pWindowType == 17
+              if ( v6 == 1 )//pWindowType == 17 (0x11) WINDOW_ChangeLocation
                 TravelUI_Draw();
             }
-            else//pWindowType == 16
+            else//pWindowType == 16 (0x10) WINDOW_10
             {
               RestUI_Draw();
             }
           }
-          else// pWindowType == 12
+          else// pWindowType == 12 (0xC) WINDOW_C
           {
             QuickRefDraw();
           }
@@ -15565,21 +15528,21 @@
               v4 = v3 - 2;
               if ( v4 )//pWindowType > 6
               {
-                if ( v4 == 3 )//pWindowType == 9
-                  DrawSpellbook((unsigned int)pWindow->ptr_1C);
+                if ( v4 == 3 )//pWindowType == 9 (0x9) WINDOW_Book
+                  SellectDrawBook((unsigned int)pWindow->ptr_1C);
               }
-              else//pWindowType == 6
+              else//pWindowType == 6 (0x6) WINDOW_Options
               {
                 sub_414F82_DrawGameOptions();
               }
             }
-            else//pWindowType == 4
+            else//pWindowType == 4 (0x4) WINDOW_CharacterRecord
             {
               CharacterUI_CharacterScreen_Draw(uActiveCharacter);
             }
             continue;
           }
-          pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);//pWindowType == 3
+          pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);//pWindowType == 3 (0x3)
           pY = pViewport->uViewportY;
           pX = pViewport->uViewportX;
           //goto LABEL_18;
@@ -17839,7 +17802,7 @@
 void __cdecl sub_419401()
 {
   unsigned int v0; // ecx@3
-  GUIButton *i; // eax@3
+  GUIButton *pButton; // eax@3
   GUIFont *v2; // eax@8
   unsigned int v3; // esi@8
   int v4; // eax@10
@@ -17864,18 +17827,18 @@
     sub_4196A0();
   v0 = uActiveCharacter;
   dword_507CC0 = uActiveCharacter;
-  for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
-  {
-    if ( i->uControlID == 120 )
-    {
-      dword_50698C = i->uX;
-      dword_506988 = i->uY;
-      dword_506984 = i->uZ;
-      dword_506980 = i->uW;
-      i->uW = 0;
-      i->uZ = 0;
-      i->uY = 0;
-      i->uX = 0;
+  for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext )
+  {
+    if ( pButton->uControlID == 120 )
+    {
+      dword_50698C = pButton->uX;
+      dword_506988 = pButton->uY;
+      dword_506984 = pButton->uZ;
+      dword_506980 = pButton->uW;
+      pButton->uW = 0;
+      pButton->uZ = 0;
+      pButton->uY = 0;
+      pButton->uX = 0;
       v0 = uActiveCharacter;
     }
   }
@@ -17887,24 +17850,13 @@
   v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
   do
   {
-    if ( v18[2 * *v14 + 264] & 0x3F )
+    if ( v18[2 * *v14 + 264] & 0x3F )//crash
     {
       v4 = LOBYTE(v2->uFontHeight);
       v3 = v3 + v4 - 3;
       ++a2;
       ++v12;
-      pGUIWindow_CurrentMenu->CreateButton(
-        0x18u,
-        v3,
-        0xCCu,
-        v4 - 3,
-        3,
-        *v14 | 0x8000,
-        0x79u,
-        *v14,
-        0,
-        "",
-        0);
+      pGUIWindow_CurrentMenu->CreateButton(0x18u, v3, 0xCCu, v4 - 3, 3, *v14 | 0x8000, 0x79u, *v14, 0, "", 0, 0);
       v2 = pFontLucida;
     }
     ++v14;
@@ -17921,18 +17873,7 @@
       v6 = LOBYTE(v2->uFontHeight);
       v5 = v5 + v6 - 3;
       ++a2;
-      pGUIWindow_CurrentMenu->CreateButton(
-        0x18u,
-        v5,
-        0xCCu,
-        v6 - 3,
-        3,
-        *v15 | 0x8000,
-        0x79u,
-        *v15,
-        0,
-        "",
-        0);
+      pGUIWindow_CurrentMenu->CreateButton(0x18u, v5, 0xCCu, v6 - 3, 3, *v15 | 0x8000, 0x79u, *v15, 0, "", 0, 0);
       v2 = pFontLucida;
     }
     ++v15;
@@ -17949,18 +17890,7 @@
       v7 = v7 + v8 - 3;
       ++a2;
       ++v13;
-      pGUIWindow_CurrentMenu->CreateButton(
-        0xF6u,
-        v7,
-        0xCCu,
-        v8 - 3,
-        3,
-        *v16 | 0x8000,
-        0x79u,
-        *v16,
-        0,
-        "",
-        0);
+      pGUIWindow_CurrentMenu->CreateButton(0xF6u, v7, 0xCCu, v8 - 3, 3, *v16 | 0x8000, 0x79u, *v16, 0, "", 0, 0);
       v2 = pFontLucida;
     }
     ++v16;
@@ -17977,18 +17907,7 @@
       v10 = LOBYTE(v2->uFontHeight);
       v9 = v9 + v10 - 3;
       ++a2;
-      pGUIWindow_CurrentMenu->CreateButton(
-        0xF6u,
-        v9,
-        0xCCu,
-        v10 - 3,
-        3,
-        *v17 | 0x8000,
-        0x79u,
-        *v17,
-        0,
-        "",
-        0);
+      pGUIWindow_CurrentMenu->CreateButton(0xF6u, v9, 0xCCu, v10 - 3, 3, *v17 | 0x8000, 0x79u, *v17, 0, "", 0, 0);
       v2 = pFontLucida;
     }
     ++v17;
--- a/mm7_6.cpp	Thu Jan 17 22:58:41 2013 +0600
+++ b/mm7_6.cpp	Thu Jan 17 22:59:03 2013 +0600
@@ -8939,15 +8939,23 @@
             }
             break;
           case INPUT_MoveBackwards:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (!pParty->bTurnBasedModeOn)
-              goto _do_move_backwards;
+              //goto _do_move_backwards;
+            {
+              v5 = pActionQueue;
+              if ( pParty->uFlags2 & 2 )
+                partyAction = PARTY_RunBackward;
+              else
+                partyAction = PARTY_WalkBackward;
+              goto _add_action_and_continue;
+            }
             if ( pTurnEngine->field_4 != 1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
             {
               pTurnEngine->uActionPointsLeft -= 26;
-_do_move_backwards:
+//_do_move_backwards:
               v5 = pActionQueue;
               if ( pParty->uFlags2 & 2 )
                 partyAction = PARTY_RunBackward;
@@ -8957,27 +8965,35 @@
             }
             break;
           case INPUT_StrafeLeft:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (!pParty->bTurnBasedModeOn)
-              goto _do_strafe_left;
+              //goto _do_strafe_left;
+            {
+              partyAction = PARTY_StrafeLeft;
+              goto _add_action_and_continue_;
+            }
             if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
               break;
             pTurnEngine->uActionPointsLeft -= 26;
-_do_strafe_left:
+//_do_strafe_left:
             partyAction = PARTY_StrafeLeft;
             goto _add_action_and_continue_;
           case INPUT_StrafeRight:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (!pParty->bTurnBasedModeOn)
-              goto _do_strafe_right;
+              //goto _do_strafe_right;
+            {
+              partyAction = PARTY_StrafeRight;
+              goto _add_action_and_continue_;
+            }
             if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
               break;
             pTurnEngine->uActionPointsLeft -= 26;
-_do_strafe_right:
+//_do_strafe_right:
             partyAction = PARTY_StrafeRight;
             goto _add_action_and_continue_;
           case INPUT_TurnLeft:
@@ -9036,14 +9052,14 @@
             }
             break;
           case INPUT_Jump:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen
               || pParty->bTurnBasedModeOn)
               break;
             partyAction = (PartyAction)12;
             goto _add_action_and_continue_;
           case INPUT_Yell:
-            __debugbreak();
+            //__debugbreak();
             if ( !pCurrentScreen
               && uActiveCharacter )
             {
@@ -9052,11 +9068,15 @@
             }
             break;
           case INPUT_Pass:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
-              goto LABEL_118;
+              //goto LABEL_118;
+            {
+              pTurnEngine->field_18 |= 8u;
+              break;
+            }
             if ( uActiveCharacter )
             {
               v6 = pPlayers[uActiveCharacter];
@@ -9072,7 +9092,7 @@
             }
             break;
           case INPUT_Combat:
-            __debugbreak();
+            //__debugbreak();
             if ( !pCurrentScreen )
             {
               if (pParty->bTurnBasedModeOn)
@@ -9091,11 +9111,15 @@
             }
             break;
           case INPUT_CastReady:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
-              goto LABEL_118;
+              //goto LABEL_118;
+            {
+              pTurnEngine->field_18 |= 8u;
+              break;
+            }
             if ( !uActiveCharacter )
               break;
             v7 = pPlayers[uActiveCharacter];
@@ -9125,16 +9149,13 @@
               }
             }
             break;
-          default:
-            __debugbreak();
-            break;
           case INPUT_Attack:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen )
               break;
             if (!pParty->bTurnBasedModeOn || pTurnEngine->field_4 != 3)
               goto LABEL_120;
-LABEL_118:
+//LABEL_118:
             pTurnEngine->field_18 |= 8u;
             break;
           case INPUT_EventTrigger:
@@ -9170,46 +9191,46 @@
             }
             break;
           case INPUT_CharCycle:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen == 8
               || dword_50C9E8 >= 40 )
               break;
             dword_50C9EC[3 * dword_50C9E8] = 176;
             goto LABEL_155;
           case INPUT_LookUp:
-            __debugbreak();
+            //__debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)7;
             goto _add_action_and_continue_;
           case INPUT_CenterView:
-            __debugbreak();
+            //__debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)9;
             goto _add_action_and_continue_;
           case INPUT_LookDown:
-            __debugbreak();
+            //__debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)8;
             goto _add_action_and_continue_;
           case INPUT_FlyUp:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen
               || pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)13;
             goto _add_action_and_continue_;
           case INPUT_Land:
-            __debugbreak();
+            //__debugbreak();
             if ( pCurrentScreen
               || pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)15;
             goto _add_action_and_continue_;
           case INPUT_FlyDown:
-            __debugbreak();
+            //__debugbreak();
             if ( !pCurrentScreen
               && !pEventTimer->bPaused )
             {
@@ -9221,13 +9242,13 @@
             }
             break;
           case INPUT_ZoomIn:
-            __debugbreak();
+            //__debugbreak();
             if ( dword_50C9E8 >= 40 )
               break;
             dword_50C9EC[3 * dword_50C9E8] = 367;
             goto LABEL_155;
           case INPUT_ZoomOut:
-            __debugbreak();
+            //__debugbreak();
             if ( dword_50C9E8 < 40 )
             {
               dword_50C9EC[3 * dword_50C9E8] = 368;
@@ -9240,6 +9261,9 @@
           case INPUT_AlwaysRun:
             bAlwaysRun = bAlwaysRun == 0;
             break;
+          default:
+            //__debugbreak();
+            break;
         }
       }
       inputAction = (InputAction)((int)inputAction + 1);
@@ -9263,7 +9287,11 @@
         if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
           goto LABEL_175;
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404;
-        goto LABEL_174;
+        //goto LABEL_174;
+        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+        *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+        ++pMessageQueue_50CBD0->uNumMessages;
+        goto LABEL_175;
       }
       if ( pCurrentScreen == 4
         || pCurrentScreen == 19 )
@@ -9276,15 +9304,20 @@
           {
             v15 = 1;
             pMessageQueue_50CBD0->uNumMessages = 1;
-            goto LABEL_173;
+            //goto LABEL_173;
+            pMessageQueue_50CBD0->pMessages[v15].eType = (UIMessageType)113;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+            goto LABEL_175;
           }
           pMessageQueue_50CBD0->uNumMessages = 0;
         }
         if ( (signed int)v15 >= 40 )
           goto LABEL_175;
-LABEL_173:
+//LABEL_173:
         pMessageQueue_50CBD0->pMessages[v15].eType = (UIMessageType)113;
-LABEL_174:
+//LABEL_174:
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
         ++pMessageQueue_50CBD0->uNumMessages;
--- a/mm7_data.h	Thu Jan 17 22:58:41 2013 +0600
+++ b/mm7_data.h	Thu Jan 17 22:59:03 2013 +0600
@@ -1823,13 +1823,13 @@
 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
 void __cdecl sub_412AF9();
 void __cdecl sub_412B58();
-char __cdecl sub_412E85();
-void __cdecl DrawSpellbook_Quests();
-void __cdecl DrawSpellbook_Autonotes();
-char *__cdecl DrawSpellbook_Map();
-void __thiscall DrawSpellbook(unsigned int uBook); // idb
+char __cdecl DrawBook_History();
+void __cdecl DrawBook_Quests();
+void __cdecl DrawBook_Autonotes();
+char *__cdecl DrawBook_Maps();
+void __thiscall SellectDrawBook(unsigned int uBook); // idb
 char *__cdecl GetDayPart();
-char __cdecl DrawSpellbook_Calendar();
+char __cdecl DrawBook_Calendar();
 void __cdecl SetAttributeNames();
 void __cdecl uGameUIFontMain_initialize();
 void __cdecl uGameUIFontShadow_initialize();