diff mm7_5.cpp @ 11:66319a734368

16.01.13(work)
author Ritor1
date Wed, 16 Jan 2013 17:31:56 +0600
parents 8e33efd39355
children b4982f23d2e9 2127707df23f
line wrap: on
line diff
--- a/mm7_5.cpp	Wed Jan 16 09:25:57 2013 +0600
+++ b/mm7_5.cpp	Wed Jan 16 17:31:56 2013 +0600
@@ -459,7 +459,9 @@
           v162 = 0;
           v148 = 0;
           pWindowType = (WindowType)8;
-          goto LABEL_439;
+          //goto LABEL_439;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          continue;
         case UIMSG_ArrowUp:
           --pSaveListPosition;
           if ( pSaveListPosition < 0 )
@@ -472,7 +474,9 @@
           v137 = 17;
           v133 = 17;
           v9 = 215;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_DownArrow:
           ++pSaveListPosition;
           if ( pSaveListPosition >= uMessageParam )
@@ -485,7 +489,9 @@
           v137 = 17;
           v133 = 17;
           v9 = 215;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_Cancel:
           v163 = 0;
           v8 = 302;
@@ -494,7 +500,9 @@
           pWindowType1 = (WindowType)96;
           v137 = 42;
           v133 = 106;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_LoadSlot:
           v163 = 0;
           v8 = 302;
@@ -503,7 +511,9 @@
           pWindowType1 = (WindowType)94;
           v137 = 42;
           v133 = 106;
-          goto LABEL_733;
+          //goto LABEL_733;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SelectLoadSlot:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
             pKeyActionMap->_459ED1(0);
@@ -691,7 +701,10 @@
           memset(word_506E6C, 0, 0x1Cu);
           word_506E6C[14] = 0;
           memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
-          goto LABEL_90;
+          //goto LABEL_90;
+          v1 = "";
+          v0 = 1;
+          continue;
         //default:
           //continue;
         case UIMSG_ResetKeyMapping|0x1:
@@ -808,7 +821,7 @@
           if ( uMessageParam == 4 )
           {
             --uGammaPos;
-            if ( (uGammaPos /*& 0x80000000u*/) != 0 )
+            if ( (uGammaPos & 0x80000000u) != 0 )
             {
               uGammaPos = 0;
               //goto LABEL_128;
@@ -1186,7 +1199,7 @@
 //LABEL_229:
               if ( dword_50CDC8 )
                 goto LABEL_232;
-              sub_42FC15();
+              CloseWindowBackground();
               //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
@@ -1198,13 +1211,13 @@
               //goto LABEL_229;
               if ( dword_50CDC8 )
                 goto LABEL_232;
-              sub_42FC15();
+              CloseWindowBackground();
               //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
             if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 )
             {
-              sub_42FC15();
+              CloseWindowBackground();
               dword_5C35C8 = 0;
 //LABEL_231:
               uMessageParam = v0;
@@ -1751,10 +1764,16 @@
               stru_506E40._40E55E("gamma.pcx", 0);
               continue;
             }
-            goto LABEL_333;
+            //goto LABEL_333;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           sub_41426F();
-//_continue:
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -1842,7 +1861,7 @@
             pParty->uTimePlayed += 1474560i64;
           continue;
         case 0x19C:
-          sub_42FC15();
+          CloseWindowBackground();
           pVideoPlayer->Unload();
           sub_44603D();
           dword_597F18 = 0;
@@ -1863,7 +1882,7 @@
           {
             viewparams->bRedrawGameUI = v0;
 LABEL_387:
-            sub_42FC15();
+            CloseWindowBackground();
             if ( pParty->vPosition.x < -22528 )
               pParty->vPosition.x = -22528;
             if ( pParty->vPosition.x > 22528 )
@@ -1971,15 +1990,44 @@
           if ( v45 == 3 )
           {
             v47 = pActors[v46].uAIState == Dead;
-            goto LABEL_400;
+            //goto LABEL_400;
+            if ( !v47 )
+              continue;
+            //goto LABEL_415;
+            v51 = pGUIWindow_Settings->ptr_1C;
+            *((char *)v51 + 8) &= 0xBFu;
+            *((short *)v51 + 2) = uMessageParam;
+            *((int *)v51 + 3) = v44;
+            pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+            pWindow3 = pGUIWindow_Settings;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           if ( v45 == 2 )
           {
             v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
-LABEL_400:
+//LABEL_400:
             if ( !v47 )
               continue;
-            goto LABEL_415;
+            //goto LABEL_415;
+            v51 = pGUIWindow_Settings->ptr_1C;
+            *((char *)v51 + 8) &= 0xBFu;
+            *((short *)v51 + 2) = uMessageParam;
+            *((int *)v51 + 3) = v44;
+            pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+            pWindow3 = pGUIWindow_Settings;
+            pWindow3->Release();
+            pGUIWindow_Settings = 0;
+            pMouse->SetCursorBitmap("MICON1");
+            GameUI_StatusBar_TimedStringTimeLeft = 0;
+            unk_50C9A0 = 0;
+            back_to_game();
+            continue;
           }
           if ( v45 == 5 )
           {
@@ -1995,7 +2043,20 @@
               if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
                 continue;
               v44 = uNumSeconds;
-              goto LABEL_415;
+              //goto LABEL_415;
+              v51 = pGUIWindow_Settings->ptr_1C;
+              *((char *)v51 + 8) &= 0xBFu;
+              *((short *)v51 + 2) = uMessageParam;
+              *((int *)v51 + 3) = v44;
+              pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+              pWindow3 = pGUIWindow_Settings;
+              pWindow3->Release();
+              pGUIWindow_Settings = 0;
+              pMouse->SetCursorBitmap("MICON1");
+              GameUI_StatusBar_TimedStringTimeLeft = 0;
+              unk_50C9A0 = 0;
+              back_to_game();
+              continue;
             }
             pBLVFace = &pIndoor->pFaces[v46];
             if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
@@ -2004,15 +2065,15 @@
           }
           if ( v48 )
             continue;
-LABEL_415:
+//LABEL_415:
           v51 = pGUIWindow_Settings->ptr_1C;
           *((char *)v51 + 8) &= 0xBFu;
-LABEL_416:
+//LABEL_416:
           *((short *)v51 + 2) = uMessageParam;
           *((int *)v51 + 3) = v44;
           pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
           pWindow3 = pGUIWindow_Settings;
-LABEL_333:
+//LABEL_333:
           pWindow3->Release();
           pGUIWindow_Settings = 0;
           pMouse->SetCursorBitmap("MICON1");
@@ -2068,7 +2129,7 @@
           strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename);
           dword_6BE364_game_settings_1 |= v0;
           uGameState = 2;
-		  //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
+          //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
           v53 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1]._quest_related;
           if ( v53 < 0 )
           {
@@ -2085,19 +2146,30 @@
             dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
           }
           sub_4BD8B5();
-          goto LABEL_434;
+          //goto LABEL_434;
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+          {
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+          }
+          continue;
         case UIMSG_C3:
           pAudioPlayer->StopChannels(-1, -1);
           v162 = uMessageParam;
           v148 = 195;
-          goto LABEL_438;
+          //goto LABEL_438;
+          pWindowType = (WindowType)9;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          continue;
         case UIMSG_B1:
           pAudioPlayer->StopChannels(-1, -1);
           v162 = 0;
           v148 = 177;
-LABEL_438:
+//LABEL_438:
           pWindowType = (WindowType)9;
-LABEL_439:
+//LABEL_439:
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
           continue;
         case UIMSG_B2:
@@ -2137,12 +2209,20 @@
           v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
           v158 = (unsigned int)thise;
           v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
-_sprintex_draw_status_and_continue:
+//_sprintex_draw_status_and_continue:
           sprintf(pTmpBuf, v146, v158, v174);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_B5:
           dword_50CDC8 = v0;
-          goto LABEL_453;
+          //goto LABEL_453;
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+            continue;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
         case UIMSG_B3:
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
           pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
@@ -2283,12 +2363,12 @@
                     *((int *)v67 + 17) = v0;
                   else
                     pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
-LABEL_434:
+//LABEL_434:
                   if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                   {
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
-LABEL_771:
+//LABEL_771:
                     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                     ++pMessageQueue_50CBD0->uNumMessages;
                   }
@@ -2324,9 +2404,46 @@
                 break;
               default:
                 if ( uMessageParam != 5 )
-                  goto LABEL_506;
-                v68 = 210;
-                break;
+                  //goto LABEL_506;
+                {
+                  if ( uMessageParam )
+                  {
+                    switch ( uMessageParam )
+                    {
+                    case 1:
+                      v69 = pMapStats->pInfos[4].pName;
+                      break;
+                    case 2:
+                      v69 = pMapStats->pInfos[3].pName;
+                      break;
+                    case 3:
+                      v69 = pMapStats->pInfos[10].pName;
+                      break;
+                    case 4:
+                      v69 = pMapStats->pInfos[7].pName;
+                      break;
+                    default:
+                    if ( uMessageParam != 5 )
+                    {
+                      v173 = v200;
+                      v157 = pGlobalTXT_LocalizationStrings[35];
+                      goto _sprintex_2args_draw_status_and_continue;
+                    }
+                    v69 = pMapStats->pInfos[8].pName;
+                    break;
+                  }
+                }
+                else
+                {
+                  v69 = pMapStats->pInfos[21].pName;
+                }
+                v200 = v69;
+                v173 = v200;
+                v157 = pGlobalTXT_LocalizationStrings[35];
+                goto _sprintex_2args_draw_status_and_continue;
+              }
+              v68 = 210;
+              break;
             }
           }
           else
@@ -2338,7 +2455,7 @@
             pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
             continue;
           }
-LABEL_506:
+//LABEL_506:
           if ( uMessageParam )
           {
             switch ( uMessageParam )
@@ -2397,9 +2514,9 @@
             v70 = atoi(v216.pProperties[0]);
             if ( v70 <= 0 || v70 >= 77 )
             {
-LABEL_90:
+//LABEL_90:
               v1 = "";
-LABEL_91:
+//LABEL_91:
               v0 = 1;
               continue;
             }
@@ -2435,7 +2552,12 @@
           else
           {
             if ( v216.field_0 != 3 )
-              goto LABEL_90;
+              //goto LABEL_90;
+            {
+              v1 = "";
+              v0 = 1;
+              continue;
+            }
             v74 = atoi(v216.pProperties[0]);
             thisi = atoi(v216.pProperties[1]);
             v75 = atoi(v216.pProperties[2]);
@@ -2445,12 +2567,15 @@
               if ( pIndoor->GetSector(v74, thisi, v75) )
               {
                 v77 = thisi;
-LABEL_544:
+//LABEL_544:
                 pParty->vPosition.x = v74;
                 pParty->vPosition.y = v77;
                 pParty->vPosition.z = v76;
                 pParty->uFallStartY = v76;
-                goto LABEL_90;
+                //goto LABEL_90;
+                v1 = "";
+                v0 = 1;
+                continue;
               }
             }
             else
@@ -2463,7 +2588,17 @@
                   if ( thisi > -32768 )
                   {
                     if ( thisi < 32768 && v76 >= 0 && v76 < 10000 )
-                      goto LABEL_544;
+                      //goto LABEL_544;
+                    {
+                      pParty->vPosition.x = v74;
+                      pParty->vPosition.y = v77;
+                      pParty->vPosition.z = v76;
+                      pParty->uFallStartY = v76;
+                      //goto LABEL_90;
+                      v1 = "";
+                      v0 = 1;
+                      continue;
+                    }
                   }
                 }
               }
@@ -2480,13 +2615,20 @@
           if ( bUnderwater == 1 )
             goto LABEL_682;
           if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) )
-            goto LABEL_90;
+            //goto LABEL_90;
+          {
+            v1 = "";
+            v0 = 1;
+            continue;
+          }
           v79 = pPlayer2->uQuickSpell;
           v175 = uActiveCharacter;
           v159 = 0;
           v147 = 0;
           v80 = uActiveCharacter - 1;
-          goto LABEL_679;
+          //goto LABEL_679;
+          _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
+          continue;
         case 0x46:
         case UIMSG_Quit|0x8:
           if ( pRenderer->pRenderD3D )
@@ -2521,7 +2663,18 @@
             else
               *((char *)v51 + 9) &= 0xFDu;
           }
-          goto LABEL_416;
+          //goto LABEL_416;
+          *((short *)v51 + 2) = uMessageParam;
+          *((int *)v51 + 3) = v44;
+          pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+          pWindow3 = pGUIWindow_Settings;
+          pWindow3->Release();
+          pGUIWindow_Settings = 0;
+          pMouse->SetCursorBitmap("MICON1");
+          GameUI_StatusBar_TimedStringTimeLeft = 0;
+          unk_50C9A0 = 0;
+          back_to_game();
+          continue;
         case 0x1C:
           if ( !uActiveCharacter || pCurrentScreen )
             //goto LABEL_90;
@@ -2543,7 +2696,14 @@
             continue;
           }
           if ( pParty->bTurnBasedModeOn != v0 )
-            goto LABEL_569;
+            //goto LABEL_569;
+          {
+            if ( pActors[uMessageParam].uAIState == 5 )
+              stru_50C198.LootActor(&pActors[uMessageParam]);
+            else
+              Actor::StealFrom(uMessageParam);
+            continue;
+          }
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
           {
@@ -2553,7 +2713,7 @@
           }
           if ( !(pTurnEngine->field_18 & 2) )
           {
-LABEL_569:
+//LABEL_569:
             if ( pActors[uMessageParam].uAIState == 5 )
               stru_50C198.LootActor(&pActors[uMessageParam]);
             else
@@ -2569,7 +2729,11 @@
             continue;
           }
           if ( pParty->bTurnBasedModeOn != v0 )
-            goto LABEL_577;
+            //goto LABEL_577;
+          {
+            _42ECB5_PlayerAttacksActor();
+            continue;
+          }
           if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
             //goto LABEL_90;
           {
@@ -2578,7 +2742,7 @@
             continue;
           }
           if ( !(pTurnEngine->field_18 & 2) )
-LABEL_577:
+//LABEL_577:
             _42ECB5_PlayerAttacksActor();
           continue;
         case UIMSG_A7:
@@ -2586,10 +2750,21 @@
           pButton = pButton_RestUI_Exit;
           pButton2 = pButton_RestUI_Exit;
           pWindowType1 = (WindowType)96;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_ShowStatus_Player|0x1:
           if ( dword_506F14 == 2 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, (enum WindowType)90,
             (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
           dword_506F14 = v0;
@@ -2597,7 +2772,11 @@
           continue;
         case 0x60:
           if ( dword_506F14 == 2 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, (enum WindowType)90,
             (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
           dword_506F14 = v0;
@@ -2610,27 +2789,64 @@
           _506F18_num_hours_to_sleep = v86;
           if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
             _506F18_num_hours_to_sleep = v86 + 720;
-          goto LABEL_615;
+          //goto LABEL_615;
+          dword_506F14 = 2;
+          pParty->RestAndHeal();
+          pParty->field_764 = 0;
+          pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
+          pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
+          continue;
         case 0x68:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
             continue;
           if ( sub_42F4DA() )
-            goto LABEL_594;
+            //goto LABEL_594;
+          {
+            if ( pParty->bTurnBasedModeOn == v0 )
+            {
+              v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
+              ShowStatusBarString(v87, 2u);
+              continue;
+            }
+            v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
+            if ( pParty->uFlags & 0x88 )
+              v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
+            ShowStatusBarString(v88, 2u);
+            v89 = uActiveCharacter;
+            if ( !uActiveCharacter )
+            {
+              v1 = "";
+              v0 = 1;
+              continue;
+            }
+            v176 = 0;
+            v160 = 13;
+            goto LABEL_619;
+          }
           if ( pParty->bTurnBasedModeOn == v0 )
-            goto LABEL_595;
+            //goto LABEL_595;
+          {
+            v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
+            ShowStatusBarString(v87, 2u);
+            continue;
+          }
           if ( !(pParty->uFlags & 0x88) )
           {
             RestUI_Initialize();
             continue;
           }
-LABEL_594:
+//LABEL_594:
           if ( pParty->bTurnBasedModeOn == v0 )
           {
-LABEL_595:
+//LABEL_595:
             v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
-            goto _draw_status_string_and_continue;
+            //goto _draw_status_string_and_continue;
+            ShowStatusBarString(v87, 2u);
+            continue;
           }
           v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
           if ( pParty->uFlags & 0x88 )
@@ -2649,7 +2865,11 @@
           goto LABEL_619;
         case 0x61:
           if ( dword_506F14 )
-            goto LABEL_621;
+            //goto LABEL_621;
+          {
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
           if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest )
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
@@ -2713,7 +2933,7 @@
             }
             Party::TakeFood(uRestUI_FoodRequiredToRest);
             _506F18_num_hours_to_sleep = 480;
-LABEL_615:
+//LABEL_615:
             dword_506F14 = 2;
             pParty->RestAndHeal();
             pParty->field_764 = 0;
@@ -2726,7 +2946,7 @@
         case UIMSG_ShowStatus_Funds|0x8:
           if ( dword_506F14 == 2 )
           {
-LABEL_621:
+//LABEL_621:
             v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
             goto LABEL_622;
           }
@@ -2752,7 +2972,7 @@
               v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
             strcpy(pTmpBuf, v177);
           }
-_set_status_string_pTmpBuf_and_continue:
+//_set_status_string_pTmpBuf_and_continue:
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case 0x4F:
@@ -2774,7 +2994,9 @@
           }
           sprintf(pTmpBuf, v161, v178);
           sub_41C0B8_set_status_string(pTmpBuf);
-          goto LABEL_91;
+          //goto LABEL_91;
+          v0 = 1;
+          continue;
         case 0x58:
           GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
@@ -2824,7 +3046,17 @@
           }
           while ( v101 < 9 );
           if ( !pNPCData4 )
-            goto LABEL_662;
+          {
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = 0;
+            v127 = rand() % 2 + 204;
+            goto _play_sound_and_continue;
+          }
           if ( GetAsyncKeyState(16) )
           {
             --uAction;
@@ -2839,15 +3071,22 @@
           }
           sub_41140B();
           pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
-          goto LABEL_661;
+          pGUIWindow_CurrentMenu->OpenSpellBook();
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = 0;
+          v127 = rand() % 2 + 204;
+          goto _play_sound_and_continue;
         case UIMSG_SaveGame|0x4:
           if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
             continue;
           sub_41140B();
           pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
-LABEL_661:
-          pGUIWindow_CurrentMenu->_411621();
-LABEL_662:
+          pGUIWindow_CurrentMenu->OpenSpellBook();
           v165 = 0;
           v151 = 0;
           v144 = 0;
@@ -2896,17 +3135,21 @@
           v175 = 0;
           v159 = 0;
           v147 = 0;
-          goto LABEL_678;
+          //goto LABEL_678;
+          v80 = v199;
+          v79 = uMessageParam;
+          _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
+          continue;
         case 0x92:
           if ( pTurnEngine->field_4 != 3 )
           {
             v175 = 0;
             v159 = v0;
             v147 = 133;
-LABEL_678:
+//LABEL_678:
             v80 = v199;
             v79 = uMessageParam;
-LABEL_679:
+//LABEL_679:
             _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
           }
           continue;
@@ -2938,14 +3181,8 @@
             if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
             {
               if ( !pCurrentScreen )
-                goto LABEL_693;
-              if ( pCurrentScreen != 5
-                && pCurrentScreen != 7
-                && (pCurrentScreen <= 99
-                 || pCurrentScreen > 103) )
+                //goto LABEL_693;
               {
-                pGUIWindow_CurrentMenu->Release();
-LABEL_693:
                 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = 8;
                 pEventTimer->Pause();
@@ -2954,10 +3191,25 @@
                 viewparams->field_48 = v0;
                 continue;
               }
-            }
-          }
-          continue;
-        case 0x6A:
+              if ( pCurrentScreen != 5
+                && pCurrentScreen != 7
+                && (pCurrentScreen <= 99
+                 || pCurrentScreen > 103) )
+              {
+                pGUIWindow_CurrentMenu->Release();
+//LABEL_693:
+                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
+                pCurrentScreen = 8;
+                pEventTimer->Pause();
+                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
+                pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
+                viewparams->field_48 = v0;
+                continue;
+              }
+            }
+          }
+          continue;
+        case UIMSG_QuickReference:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
@@ -2965,7 +3217,7 @@
           ++pIcons_LOD->uTexturePacksCount;
           if ( !pIcons_LOD->uNumPrevLoadedFiles )
             pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-          GUIWindow::Create(0x230u, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_QuickReference, 0);
+          GUIWindow::Create(0x230u, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_QuickReference, 0);
           viewparams->bRedrawGameUI = v0;
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -2990,11 +3242,15 @@
           free((void *)uNumSeconds);
           stru_506E40._40E55E("gamma.pcx", 0);
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
-LABEL_453:
+//LABEL_453:
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-          goto LABEL_770;
+          //goto LABEL_770;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
         case UIMSG_C0:
           dword_50651C = v0;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
@@ -3002,12 +3258,12 @@
           continue;
         case UIMSG_A9:
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
-LABEL_707:
+//LABEL_707:
           dword_506548 = v0;
           continue;
         case UIMSG_AA:
           GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
-LABEL_709:
+//LABEL_709:
           dword_506544 = v0;
           continue;
         case 0x55:
@@ -3041,14 +3297,34 @@
           sub_4196A0();
           sub_419379();
           pButton = pCharacterScreen_StatsBtn;
-          goto LABEL_716;
+          //goto LABEL_716;
+          v163 = 0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)91;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_ChangeMusicVolume|0x2:
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
           sub_4196A0();
           sub_419379();
           sub_419401();
           pButton = pCharacterScreen_SkillsBtn;
-          goto LABEL_716;
+          //goto LABEL_716;
+          v163 = 0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)91;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SkillUp:
           pPlayer4 = pPlayers[uActiveCharacter];
           v105 = (int)&pPlayer4->pActiveSkills[uMessageParam];
@@ -3077,7 +3353,7 @@
             }
             v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
           }
-_draw_status_string_and_continue:
+//_draw_status_string_and_continue:
           ShowStatusBarString(v87, 2u);
           continue;
         case UIMSG_ChangeMusicVolume|0x4:
@@ -3085,17 +3361,31 @@
           sub_419379();
           sub_4196A0();
           pButton = pCharacterScreen_InventoryBtn;
-LABEL_716:
+//LABEL_716:
           v163 = 0;
           pButton2 = pButton;
           pWindowType1 = (WindowType)91;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_A8:
           pButton = pCharacterScreen_ExitBtn;
           v163 = 0;
           pButton2 = pCharacterScreen_ExitBtn;
           pWindowType1 = (WindowType)97;
-          goto LABEL_731;
+          //goto LABEL_731;
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_Escape|0x4:
           sub_419379();
           sub_4196A0();
@@ -3111,9 +3401,13 @@
             default:
               continue;
             case 11:
-              goto LABEL_707;
+              //goto LABEL_707;
+              dword_506548 = v0;
+              continue;
             case 10:
-              goto LABEL_709;
+              //goto LABEL_709;
+              dword_506544 = v0;
+              continue;
             case 0:
               pButton = pBtn_Book_1;
               dword_506544 = v0;
@@ -3158,10 +3452,14 @@
           v163 = v0;
           pButton2 = pButton;
           pWindowType1 = (WindowType)92;
-LABEL_731:
+//LABEL_731:
           v8 = pButton->uY;
           v9 = pButton->uX;
-          goto LABEL_732;
+          //goto LABEL_732;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case UIMSG_SelectCharacter:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -3171,7 +3469,10 @@
           v174 = (char *)pParty->uNumGoldInBank;
           v158 = pParty->uNumGold + pParty->uNumGoldInBank;
           v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
-          goto _sprintex_draw_status_and_continue;
+          //goto _sprintex_draw_status_and_continue;
+          sprintf(pTmpBuf, v146, v158, v174);
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_ShowStatus_DateTime:
           pNPCData4 = (NPCData *)pParty->uCurrentHour;
           if ( (signed int)pParty->uCurrentHour <= 12 )
@@ -3187,7 +3488,8 @@
             uNumSeconds = 0;
           sprintf(pTmpBuf, "%d:%02d%s %s %d %s %d", pNPCData4, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7],
             7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_ShowStatus_Food:
           v173 = (char *)pParty->uNumFoodRations;
           v157 = pGlobalTXT_LocalizationStrings[501];// You have %lu food"
@@ -3211,40 +3513,71 @@
           v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
           v114 = v110->GetMaxHealth();
           sprintf(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
-          goto _set_status_string_pTmpBuf_and_continue;
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case 0xC:
           if ( pCurrentScreen == 15 )
-            goto LABEL_762;
+          {
+            sub_421EA6_OnInventoryLeftClick();
+            continue;
+          }
           sub_420E01();
           continue;
         case UIMSG_ChangeMusicVolume|0x8:
-LABEL_762:
           sub_421EA6_OnInventoryLeftClick();
           continue;
         case 0xA:
           if ( !pRenderer->pRenderD3D )
-            goto LABEL_772;
+            //goto LABEL_772;
+          {
+            if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            OnGameViewportClick();
+            continue;
+          }
           v115 = pMessageQueue_50CBD0->uNumMessages;
           if ( !pMessageQueue_50CBD0->uNumMessages )
-            goto LABEL_768;
+            //goto LABEL_768;
+          {
+            if ( (signed int)v115 < 40 )
+            //goto LABEL_769;
+            {
+              pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
+              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+              ++pMessageQueue_50CBD0->uNumMessages;
+              continue;
+            }
+            continue;
+          }
           if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
           {
             v115 = v0;
             pMessageQueue_50CBD0->uNumMessages = v0;
-LABEL_769:
+//LABEL_769:
             pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
-LABEL_770:
+//LABEL_770:
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-            goto LABEL_771;
+            //goto LABEL_771;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+            continue;
           }
           v115 = 0;
           pMessageQueue_50CBD0->uNumMessages = 0;
-LABEL_768:
+//LABEL_768:
           if ( (signed int)v115 < 40 )
-            goto LABEL_769;
+            //goto LABEL_769;
+          {
+            pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+            continue;
+          }
           continue;
         case 0xE:
-LABEL_772:
+//LABEL_772:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
@@ -3263,18 +3596,24 @@
           v163 = 0;
           pButton2 = (GUIButton *)(unsigned __int16)v116;
           pWindowType1 = (WindowType)15;
-          goto LABEL_779;
+          //goto LABEL_779;
+          v8 = 0;
+          v9 = 0;
+          v137 = 0;
+          v133 = 0;
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          continue;
         case 0x54:
           v163 = 0;
           pButton2 = (GUIButton *)uMessageParam;
           pWindowType1 = (WindowType)22;
-LABEL_779:
+//LABEL_779:
           v8 = 0;
           v9 = 0;
-LABEL_732:
+//LABEL_732:
           v137 = 0;
           v133 = 0;
-LABEL_733:
+//LABEL_733:
           GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
           continue;
         case 0x194:
@@ -6114,19 +6453,19 @@
 int __cdecl CharacterUI_LoadPaperdollTextures()
 {
   int v0; // edi@7
-  enum CHARACTER_RACE v1; // ebx@7
-  signed int v2; // eax@7
+  enum CHARACTER_RACE pRace; // ebx@7
+  signed int pSex; // eax@7
   int v3; // ebx@10
-  Player *v4; // edi@12
+  Player *pPlayer; // edi@12
   unsigned __int8 v5; // cl@12
   int v6; // edi@16
   unsigned int v7; // eax@16
-  Player *v8; // ebx@16
+  Player *pPlayer2; // ebx@16
   char *v9; // ebx@16
   char v10; // al@16
   signed int v11; // edi@21
-  Player *v12; // ebx@23
-  Player *v13; // edi@29
+  Player *pPlayer3; // ebx@23
+  Player *pPlayer4; // edi@29
   int v14; // ebp@29
   stru331 *v15; // edi@65
   signed int v16; // ebx@66
@@ -6172,55 +6511,43 @@
     if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v30 + 1) )
     {
       v0 = v30;
-      v1 = pPlayers[v30 + 1]->GetRace();
-      v2 = pPlayers[v30 + 1]->GetSexByVoice();
-      if ( v1 && v1 != 1 && v1 != 2 )
-        v3 = (v2 != 0) + 3;
+      pRace = pPlayers[v30 + 1]->GetRace();
+      pSex = pPlayers[v30 + 1]->GetSexByVoice();
+      if ( pRace && pRace != 1 && pRace != 2 )//race == 3
+        v3 = (pSex != 0) + 3;
       else
-        v3 = (v2 != 0) + 1;
+        v3 = (pSex != 0) + 1;
       wsprintfA(pContainer, "pc23v%dBod", v3);
-      papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Body texture
       wsprintfA(pContainer, "pc23v%dlad", v3);
-      papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand
       wsprintfA(pContainer, "pc23v%dlau", v3);
-      papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand2
       wsprintfA(pContainer, "pc23v%drh", v3);
-      papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Right Hand
       wsprintfA(pContainer, "pc23v%dlh", v3);
-      papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Fist
       wsprintfA(pContainer, "pc23v%dlhu", v3);
-      papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      v4 = pPlayers[v0 + 1];
-      v5 = v4->uFace;
+      papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); // Left Fist 2
+      pPlayer = pPlayers[v0 + 1];
+      v5 = pPlayer->uFace;
       if ( v5 == 12 || v5 == 13 )
         papredoll_dbrds[(char)v5] = 0;
-      papredoll_flying_feet[v4->uFace] = 0;
+      papredoll_flying_feet[pPlayer->uFace] = 0;
       IsPlayerWearingWatersuit[v30 + 1] = 1;
     }
     else
     {
       v6 = v30;
-      papredoll_dbods[v30] = pIcons_LOD->LoadTexture(
-                               dbod_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_dlads[v30] = pIcons_LOD->LoadTexture(
-                               dlad_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(
-                               dlau_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                               TEXTURE_16BIT_PALETTE);
-      papredoll_drhs[v30] = pIcons_LOD->LoadTexture(
-                              drh_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                              TEXTURE_16BIT_PALETTE);
-      papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(
-                              dlh_texnames_by_face[pPlayers[v30 + 1]->uFace],
-                              TEXTURE_16BIT_PALETTE);
-      v7 = pIcons_LOD->LoadTexture(
-             dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace],
-             TEXTURE_16BIT_PALETTE);
-      v8 = pPlayers[v30 + 1];
+      papredoll_dbods[v30] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlads[v30] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_drhs[v30] = pIcons_LOD->LoadTexture(drh_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      v7 = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace], TEXTURE_16BIT_PALETTE);
+      pPlayer2 = pPlayers[v30 + 1];
       papredoll_dlhus[v30] = v7;
-      v9 = (char *)&v8->uFace;
+      v9 = (char *)&pPlayer2->uFace;
       v10 = *v9;
       if ( *v9 == 12 || v10 == 13 )
       {
@@ -6250,11 +6577,11 @@
     byte_5111C0[v11] = 0;
     if ( pParty->pPickedItem.uItemID != v11 + 66 )
     {
-      v12 = pParty->pPlayers;
-      while ( !sub_43EE15_player_has_item(v11 + 66, v12, 0) )
-      {
-        ++v12;
-        if ( (signed int)v12 >= (signed int)pParty->pHirelings )
+      pPlayer3 = pParty->pPlayers;
+      while ( !sub_43EE15_player_has_item(v11 + 66, pPlayer3, 0) )
+      {
+        ++pPlayer3;
+        if ( (signed int)pPlayer3 >= (signed int)pParty->pHirelings )
           goto LABEL_28;
       }
     }
@@ -6268,47 +6595,47 @@
   *(int *)&byte_5111F6[8] = 0;
   *(int *)&byte_5111F6[12] = 0;
   *(int *)&byte_5111F6[16] = 0;
-  v13 = pParty->pPlayers;
+  pPlayer4 = pParty->pPlayers;
   v14 = 1;
   do
   {
-    if ( sub_43EE15_player_has_item(0x204u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x204u, pPlayer4, 1) )
       byte_5111F6[2] = 1;
-    if ( sub_43EE15_player_has_item(0x1F8u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x1F8u, pPlayer4, 1) )
       byte_5111F6[0] = 1;
-    if ( sub_43EE15_player_has_item(0x1F9u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x1F9u, pPlayer4, 1) )
       byte_5111F6[1] = 1;
-    if ( sub_43EE15_player_has_item(0x215u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x215u, pPlayer4, 1) )
       byte_5111F6[16] = 1;
-    if ( sub_43EE15_player_has_item(0x200u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x200u, pPlayer4, 1) )
       byte_5111F6[3] = 1;
-    if ( sub_43EE15_player_has_item(0x209u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x209u, pPlayer4, 1) )
       byte_5111F6[4] = 1;
-    if ( sub_43EE15_player_has_item(0x20Au, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Au, pPlayer4, 1) )
       byte_5111F6[5] = 1;
-    if ( sub_43EE15_player_has_item(0x20Bu, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Bu, pPlayer4, 1) )
       byte_5111F6[6] = 1;
-    if ( sub_43EE15_player_has_item(0x214u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x214u, pPlayer4, 1) )
       byte_5111F6[7] = 1;
-    if ( sub_43EE15_player_has_item(0x220u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x220u, pPlayer4, 1) )
       byte_5111F6[8] = 1;
-    if ( sub_43EE15_player_has_item(0x20Cu, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Cu, pPlayer4, 1) )
       byte_5111F6[9] = 1;
-    if ( sub_43EE15_player_has_item(0x217u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x217u, pPlayer4, 1) )
       byte_5111F6[10] = 1;
-    if ( sub_43EE15_player_has_item(0x20Du, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x20Du, pPlayer4, 1) )
       byte_5111F6[11] = 1;
-    if ( sub_43EE15_player_has_item(0x212u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x212u, pPlayer4, 1) )
       byte_5111F6[12] = 1;
-    if ( sub_43EE15_player_has_item(0x223u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x223u, pPlayer4, 1) )
       byte_5111F6[13] = 1;
-    if ( sub_43EE15_player_has_item(0x224u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x224u, pPlayer4, 1) )
       byte_5111F6[14] = 1;
-    if ( sub_43EE15_player_has_item(0x226u, v13, 1) )
+    if ( sub_43EE15_player_has_item(0x226u, pPlayer4, 1) )
       byte_5111F6[15] = 1;
-    ++v13;
-  }
-  while ( (signed int)v13 < (signed int)pParty->pHirelings );
+    ++pPlayer4;
+  }
+  while ( (signed int)pPlayer4 < (signed int)pParty->pHirelings );
   v15 = &stru_511698.field_2C;
   v35 = (char *)&stru_511718.field_18;
   do
@@ -6424,9 +6751,7 @@
       do
       {
         _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
-        *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(
-                                                           pContainer,
-                                                           TEXTURE_16BIT_PALETTE);
+        *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1);
         v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v28 = v34;
@@ -6436,45 +6761,25 @@
       }
       while ( v38 - 105 < 5 );
       _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0);
-      *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(
-                                                                pContainer,
-                                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
-      *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1);
-      *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
-      *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1);
-      *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
-      *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(
-                                                pContainer,
-                                                TEXTURE_16BIT_PALETTE);
+      *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     }
     else
     {
@@ -12932,7 +13237,7 @@
       dword_5063D8[v12] = result;
     }
     v4 = v12 + 1;
-    v9 = __OFSUB__(v12 + 1, 12);
+    v9 = v12++ > 12;//v9 = __OFSUB__(v12 + 1, 12);
     v8 = v12++ - 11 < 0;
   }
   while ( v8 ^ v9 );
@@ -14830,7 +15135,7 @@
                 v38 = v37 - 2;
                 if ( v38 )//pWindowType > 105
                 {
-                  if ( v38 == 1 )//pWindowType == 106
+                  if ( v38 == 1 )//pWindowType == 106 (0x6A) WINDOW_VideoOptions
                     GameMenuUI_DrawVideoOptions();
                 }
                 else//pWindowType == 105
@@ -17372,7 +17677,7 @@
 //----- (00419100) --------------------------------------------------------
 int __cdecl sub_419100()
 {
-  Player *v0; // esi@1
+  Player *pPlayer; // esi@1
   int v1; // ebx@1
   unsigned __int8 *v2; // esi@1
   int v3; // eax@4
@@ -17389,7 +17694,7 @@
   signed int v14; // [sp+Ch] [bp-8h]@9
   int i; // [sp+10h] [bp-4h]@10
 
-  v0 = pPlayers[uActiveCharacter];
+  pPlayer = pPlayers[uActiveCharacter];
   memset(&pStru179, 0, 0xFA0u);
   memset(pTmpBuf2, 0, 0x7D0u);
   v1 = 0;
@@ -17398,7 +17703,7 @@
   dword_506520 = 0;
   dword_50651C = 0;
   dword_506528 = 0;
-  v2 = (unsigned __int8 *)v0->field_152;
+  v2 = (unsigned __int8 *)pPlayer->field_152;
   do
   {
     v13 = dword_723E80_award_related[2 * v1];
@@ -17423,7 +17728,7 @@
       v8 = rand() % 16;
       result = dword_506524;
       v9 = dword_506524 + v5++;
-      v10 = __OFSUB__(v5, dword_506524);
+      v10 = v5 > dword_506524;//__OFSUB__(v5, dword_506524);
       v7 = v5 - dword_506524 < 0;
       pStru179->field_0[v9] = v8;
     }