diff mm7_5.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 98b091cbabf7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mm7_5.cpp	Sat Jan 12 09:45:18 2013 +0600
@@ -0,0 +1,17304 @@
+#include "mm7.h"
+
+#include "MapInfo.h"
+#include "Game.h"
+#include "GUIWindow.h"
+#include "GUIFont.h"
+#include "GUIButton.h"
+#include "GUIProgressBar.h"
+#include "Party.h"
+#include "AudioPlayer.h"
+#include "Outdoor.h"
+#include "IndoorCamera.h"
+#include "Overlays.h"
+#include "Monsters.h"
+#include "Arcomage.h"
+#include "LOD.h"
+#include "Actor.h"
+#include "Allocator.h"
+#include "Events.h"
+#include "Viewport.h"
+#include "FrameTableInc.h"
+#include "Math.h"
+#include "LayingItem.h"
+#include "ObjectList.h"
+#include "Chest.h"
+#include "PaletteManager.h"
+#include "DecorationList.h"
+#include "SaveLoad.h"
+#include "stru123.h"
+#include "Time.h"
+#include "IconFrameTable.h"
+#include "stru179.h"
+#include "Awards.h"
+#include "Autonotes.h"
+#include "stru160.h"
+#include "stru279.h"
+#include "TurnEngine.h"
+#include "stru277.h"
+#include "Weather.h"
+#include "stru272.h"
+#include "stru298.h"
+#include "StorylineTextTable.h"
+#include "Events2D.h"
+#include "Log.h"
+
+#include "mm7_data.h"
+
+
+
+
+
+
+
+
+
+
+
+
+static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually
+
+
+
+//----- (004304E7) --------------------------------------------------------
+void __cdecl GameUI_MsgProc()
+{
+  signed int v0; // edi@6
+  char *v1; // esi@6
+  unsigned int v2; // edx@7
+  Actor *pActor; // ecx@13
+  int v4; // ecx@18
+  NPCData *pNPCData; // eax@18
+  int v6; // edx@20
+  int v7; // ecx@29
+  unsigned int v8; // edx@59
+  unsigned int v9; // ecx@60
+  unsigned int v10; // ecx@73
+  unsigned int v11; // eax@75
+  unsigned __int8 v12; // sf@75
+  unsigned __int8 v13; // of@75
+  int v14; // eax@98
+  unsigned int v15; // eax@102
+  unsigned __int8 v16; // al@104
+  unsigned __int8 v17; // al@105
+  int v18; // eax@106
+  float v19; // ST64_4@121
+  unsigned int v20; // ecx@121
+  float v21; // ST64_4@126
+  float v22; // ST64_4@127
+  unsigned int v23; // ecx@135
+  unsigned int v24; // ecx@149
+  unsigned int v25; // ecx@165
+  GUIWindow *pWindow; // eax@204
+  unsigned int v27; // edx@204
+  unsigned int v28; // ecx@204
+  GUIWindow *pWindow2; // ecx@248
+  int v30; // edx@258
+  const char *v31; // ecx@262
+  signed int v32; // eax@269
+  unsigned int v33; // eax@277
+  unsigned __int8 v34; // al@279
+  unsigned __int8 v35; // al@280
+  GUIWindow *pWindow3; // ecx@332
+  int v37; // eax@341
+  int v38; // eax@358
+  SHORT v39; // ax@365
+  signed int v40; // eax@365
+  char *v41; // eax@380
+  int v42; // eax@396
+  POINT *pPoint; // eax@397
+  signed int v44; // eax@398
+  int v45; // edx@398
+  signed int v46; // ecx@398
+  char v47; // zf@399
+  char v48; // zf@405
+  BLVFace *pBLVFace; // ecx@410
+  ODMFace *pODMFace; // ecx@412
+  void *v51; // ecx@415
+  void *v52; // eax@424
+  __int16 v53; // ax@431
+  int v54; // eax@432
+  int v55; // ecx@432
+  int v56; // edx@432
+  int v57; // eax@432
+  Player *pPlayer; // edx@442
+  unsigned int v59; // eax@445
+  signed int v60; // ST64_4@459
+  NPCData *pNPCData2; // eax@467
+  unsigned __int64 v62; // kr00_8@467
+  __int16 v63; // dx@479
+  unsigned int v64; // eax@486
+  int v65; // ecx@486
+  int v66; // eax@488
+  char *v67; // eax@489
+  __int16 v68; // dx@498
+  char *v69; // eax@512
+  int v70; // eax@525
+  int v71; // edi@527
+  NPCData *pNPCData3; // esi@527
+  char *v73; // ecx@533
+  signed int v74; // edi@535
+  int v75; // eax@535
+  int v76; // esi@535
+  int v77; // eax@537
+  Player *pPlayer2; // ecx@549
+  int v79; // ecx@550
+  unsigned int v80; // edx@550
+  signed int v81; // eax@552
+  POINT *pPoint2; // eax@553
+  signed int v83; // ecx@554
+  signed int v84; // ecx@554
+  GUIButton *pButton; // eax@578
+  unsigned int v86; // eax@583
+  const char *v87; // ecx@595
+  const char *v88; // ecx@596
+  unsigned int v89; // eax@598
+  unsigned int v90; // eax@602
+  int v91; // edx@605
+  int v92; // eax@605
+  int v93; // edx@605
+  int pPlayerNum; // edx@611
+  int v95; // eax@611
+  const char *v96; // ecx@621
+  unsigned int v97; // eax@624
+  int v98; // eax@636
+  unsigned __int8 v99; // al@643
+  Player *pPlayer3; // eax@648
+  int v101; // ecx@648
+  int v102; // edx@652
+  int v103; // eax@671
+  Player *pPlayer4; // ecx@718
+  int v105; // eax@718
+  Player *pPlayer5; // ST78_4@758
+  unsigned int v107; // eax@758
+  unsigned int v108; // eax@758
+  char *v109; // ST64_4@759
+  Player *v110; // ST78_4@759
+  int v111; // ST60_4@759
+  int v112; // ST5C_4@759
+  char *v113; // ST58_4@759
+  signed int v114; // eax@759
+  unsigned int v115; // eax@764
+  int v116; // eax@776
+  POINT *pPoint3; // eax@777
+  unsigned int v118; // eax@785
+  unsigned int v119; // ecx@786
+  unsigned int v120; // [sp-28h] [bp-624h]@86
+  unsigned int v121; // [sp-28h] [bp-624h]@711
+  unsigned int v122; // [sp-24h] [bp-620h]@86
+  unsigned int v123; // [sp-24h] [bp-620h]@711
+  unsigned int v124; // [sp-20h] [bp-61Ch]@86
+  unsigned int v125; // [sp-20h] [bp-61Ch]@711
+  unsigned int v126; // [sp-1Ch] [bp-618h]@86
+  int v127; // [sp-1Ch] [bp-618h]@107
+  unsigned int v128; // [sp-1Ch] [bp-618h]@711
+  int v129; // [sp-18h] [bp-614h]@86
+  signed int v130; // [sp-18h] [bp-614h]@107
+  int v131; // [sp-14h] [bp-610h]@86
+  unsigned int v132; // [sp-14h] [bp-610h]@107
+  unsigned int v133; // [sp-10h] [bp-60Ch]@60
+  unsigned int v134; // [sp-10h] [bp-60Ch]@86
+  signed int v135; // [sp-10h] [bp-60Ch]@107
+  unsigned int v136; // [sp-10h] [bp-60Ch]@121
+  unsigned int v137; // [sp-Ch] [bp-608h]@60
+  unsigned int v138; // [sp-Ch] [bp-608h]@86
+  signed int v139; // [sp-Ch] [bp-608h]@107
+  unsigned int v140; // [sp-Ch] [bp-608h]@121
+  enum WindowType pWindowType; // [sp-8h] [bp-604h]@56
+  enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60
+  unsigned __int8 v143; // [sp-8h] [bp-604h]@86
+  int v144; // [sp-8h] [bp-604h]@107
+  enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121
+  const char *v146; // [sp-8h] [bp-604h]@449
+  unsigned int v147; // [sp-8h] [bp-604h]@550
+  int v148; // [sp-4h] [bp-600h]@56
+  GUIButton *pButton2; // [sp-4h] [bp-600h]@59
+  const char *v150; // [sp-4h] [bp-600h]@86
+  unsigned int v151; // [sp-4h] [bp-600h]@107
+  int v152; // [sp-4h] [bp-600h]@121
+  int v153; // [sp-4h] [bp-600h]@135
+  int v154; // [sp-4h] [bp-600h]@149
+  int v155; // [sp-4h] [bp-600h]@165
+  int v156; // [sp-4h] [bp-600h]@204
+  const char *v157; // [sp-4h] [bp-600h]@444
+  unsigned int v158; // [sp-4h] [bp-600h]@449
+  __int16 v159; // [sp-4h] [bp-600h]@550
+  int v160; // [sp-4h] [bp-600h]@599
+  const char *v161; // [sp-4h] [bp-600h]@637
+  int v162; // [sp+0h] [bp-5FCh]@56
+  int v163; // [sp+0h] [bp-5FCh]@59
+  Texture *pTexture; // [sp+0h] [bp-5FCh]@86
+  int v165; // [sp+0h] [bp-5FCh]@107
+  int v166; // [sp+0h] [bp-5FCh]@121
+  int v167; // [sp+0h] [bp-5FCh]@135
+  int v168; // [sp+0h] [bp-5FCh]@149
+  int v169; // [sp+0h] [bp-5FCh]@165
+  int v170; // [sp+0h] [bp-5FCh]@204
+  signed int v171; // [sp+0h] [bp-5FCh]@259
+  KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287
+  char *v173; // [sp+0h] [bp-5FCh]@444
+  char *v174; // [sp+0h] [bp-5FCh]@449
+  int v175; // [sp+0h] [bp-5FCh]@550
+  int v176; // [sp+0h] [bp-5FCh]@599
+  const char *v177; // [sp+0h] [bp-5FCh]@629
+  char *v178; // [sp+0h] [bp-5FCh]@637
+  int v179; // [sp+4h] [bp-5F8h]@0
+  signed int _this; // [sp+14h] [bp-5E8h]@22
+  signed int thisa; // [sp+14h] [bp-5E8h]@251
+  signed int thisb; // [sp+14h] [bp-5E8h]@272
+  Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
+  Player *pPlayer8; // [sp+14h] [bp-5E8h]@377
+  char *thise; // [sp+14h] [bp-5E8h]@445
+  Player *pPlayer9; // [sp+14h] [bp-5E8h]@455
+  int thisg; // [sp+14h] [bp-5E8h]@467
+  int thish; // [sp+14h] [bp-5E8h]@528
+  signed int thisi; // [sp+14h] [bp-5E8h]@535
+  MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604
+  Player *pPlayer10; // [sp+14h] [bp-5E8h]@641
+  int thisl; // [sp+14h] [bp-5E8h]@648
+  int uMessageParam; // [sp+18h] [bp-5E4h]@7
+  int uAction; // [sp+1Ch] [bp-5E0h]@18
+  NPCData *pNPCData4; // [sp+20h] [bp-5DCh]@23
+  unsigned int uNumSeconds; // [sp+24h] [bp-5D8h]@18
+  char v197; // [sp+2Bh] [bp-5D1h]@101
+  enum UIMessageType uMessage; // [sp+2Ch] [bp-5D0h]@7
+  unsigned int v199; // [sp+30h] [bp-5CCh]@7
+  char *v200; // [sp+34h] [bp-5C8h]@518
+  POINT v201; // [sp+38h] [bp-5C4h]@553
+  POINT v202; // [sp+40h] [bp-5BCh]@141
+  POINT a2; // [sp+48h] [bp-5B4h]@127
+  POINT v204; // [sp+50h] [bp-5ACh]@777
+  POINT v205; // [sp+58h] [bp-5A4h]@171
+  POINT v206; // [sp+60h] [bp-59Ch]@553
+  POINT v207; // [sp+68h] [bp-594h]@155
+  POINT v208; // [sp+70h] [bp-58Ch]@397
+  POINT v209; // [sp+78h] [bp-584h]@777
+  POINT v210; // [sp+80h] [bp-57Ch]@397
+  POINT v211; // [sp+88h] [bp-574h]@704
+  __int64 v212; // [sp+90h] [bp-56Ch]@467
+  char v213; // [sp+98h] [bp-564h]@385
+  char pLevelName; // [sp+9Ch] [bp-560h]@380
+  char pOut; // [sp+BCh] [bp-540h]@370
+  FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524
+  int v217[9]; // [sp+158h] [bp-4A4h]@652
+  FrameTableTxtLine v218; // [sp+17Ch] [bp-480h]@524
+  char a1[64]; // [sp+1F8h] [bp-404h]@467
+  char Str2[128]; // [sp+238h] [bp-3C4h]@527
+  Actor actor; // [sp+2B8h] [bp-344h]@4
+
+  dword_50CDC8 = 0;
+  if ( !pEventTimer->bPaused )
+  {
+    pParty->sEyelevel = pParty->uDefaultEyelevel;
+    pParty->uPartyHeight = pParty->uDefaultPartyHeight;
+  }
+  if ( bDialogueUI_InitializeActor_NPC_ID )
+  {
+    //Actor::Actor(&actor);
+    memset(&actor, 0, 0x344u);
+    dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID;
+    actor.uNPC_ID = bDialogueUI_InitializeActor_NPC_ID;
+    actor.InitializeDialogue(0);
+    bDialogueUI_InitializeActor_NPC_ID = 0;
+  }
+  if ( pMessageQueue_50CBD0->uNumMessages )
+  {
+    v0 = 1;
+    v1 = "";
+    while ( 2 )
+    {
+      if ( !pMessageQueue_50CBD0->uNumMessages )
+        break;
+
+      pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199);
+      switch ( uMessage )
+      {
+        case UIMSG_ChangeGameState:
+          uGameState = v0;
+          goto _continue;
+        case UIMSG_PlayArcomage:
+          pVideoPlayer->_4BF5B2();
+          pArcomageGame->bGameInProgress = 1;
+          PrepareArcomage();
+          goto _continue;
+        case UIMSG_StartNPCDialogue:
+          if ( !uActiveCharacter )
+            goto _continue;
+          viewparams->field_48 = v0;
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID;
+          pActor = &pActors[uMessageParam];
+          goto _actor_init_dlg;
+        case UIMSG_Quit|0x2:
+        case 0x87:
+          if ( bNoNPCHiring != 1 && !pCurrentScreen )
+          {
+            if ( pMessageQueue_50CBD0->uNumMessages )
+              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            uAction = 0;
+            uNumSeconds = uMessage - 134;
+            v4 = 0;
+            pNPCData = pParty->pHirelings;
+            do
+            {
+              if ( pNPCData->pName )
+              {
+                v6 = uAction++;
+                pTmpBuf[v6] = v4;
+              }
+              ++pNPCData;
+              ++v4;
+            }
+            while ( (signed int)pNPCData < (signed int)&pParty->pPickedItem );
+            _this = 0;
+            if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+            {
+              pNPCData4 = pNPCStats->pNewNPCData;
+              do
+              {
+                if ( pNPCData4->uFlags & 0x80
+                  && (!pParty->pHirelings[0].pName || strcmp(pNPCData4->pName, pParty->pHirelings[0].pName))
+                  && (!pParty->pHirelings[1].pName || strcmp(pNPCData4->pName, pParty->pHirelings[1].pName)) )
+                {
+                  v7 = uAction++;
+                  pTmpBuf[v7] = _this + 2;
+                }
+                ++_this;
+                ++pNPCData4;
+              }
+              while ( _this < (signed int)pNPCStats->uNumNewNPCs );
+            }
+            if ( (signed int)(uNumSeconds + (unsigned __int8)pParty->field_709) < uAction )
+            {
+              //Actor::Actor(&actor);
+              memset(&actor, 0, 0x344u);
+              actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds;
+              pActor = &actor;
+_actor_init_dlg:
+              pActor->InitializeDialogue(v0);
+            }
+          }
+          goto _continue;
+        case 0x51:
+          sub_4BDB56_buy_skill____();
+          goto _continue;
+        case UIMSG_AF:
+          sub_4B2001(uMessageParam);
+          goto _continue;
+        case 0x195:
+          sub_4BCACC_bounties(uMessageParam);
+          goto _continue;
+        case 0x88:
+          sub_4BC49B(uMessageParam);
+          goto _continue;
+        case 0x19A:
+          _4B4224_UpdateNPCTopics(uMessageParam);
+          goto _continue;
+        case UIMSG_StartNewGame:
+          if ( dword_6BE138 == 124 || uMessageParam )
+          {
+            pIcons_LOD->_40F9C5();
+            pIcons_LOD->_4114F2();
+            if ( pMessageQueue_50CBD0->uNumMessages )
+              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            pGUIWindow_CurrentMenu->Release();
+            uGameState = 4;
+LABEL_188:
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = v0;
+          }
+          else
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2u);// "Are you sure?  Click again to start a New Game"
+            pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
+            dword_6BE138 = 124;
+          }
+_release_tex_and_continue:
+          stru_506E40.Release();
+          goto _continue;
+        case UIMSG_Game_OpenLoadGameDialog:
+          pIcons_LOD->_40F9C5();
+          pIcons_LOD->_4114F2();
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          pGUIWindow_CurrentMenu->Release();
+          pCurrentScreen = 12;
+          GameUI_DrawLoadMenu(v0);
+          goto _continue;
+        case UIMSG_Quit:
+          if ( dword_6BE138 == 132 || uMessageParam )
+          {
+            pIcons_LOD->_40F9C5();
+            pIcons_LOD->_4114F2();
+            if ( pMessageQueue_50CBD0->uNumMessages )
+              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            pGUIWindow_CurrentMenu->Release();
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = v0;
+            if ( !uMessageParam )
+              pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
+            uGameState = 7;
+          }
+          else
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2u);// "Are you sure?  Click again to quit"
+            pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
+            dword_6BE138 = 132;
+          }
+          goto _release_tex_and_continue;
+        case 0x80:
+          pIcons_LOD->_40F9C5();
+          pIcons_LOD->_4114F2();
+          pGUIWindow_CurrentMenu->Release();
+          pCurrentScreen = 2;
+          v162 = 0;
+          v148 = 0;
+          pWindowType = (WindowType)8;
+          goto LABEL_439;
+        case UIMSG_A2:
+          --dword_6A0C9C;
+          if ( dword_6A0C9C < 0 )
+            dword_6A0C9C = 0;
+          v163 = 0;
+          v8 = 199;
+          pButton2 = ptr_69BD5C;
+          //goto LABEL_60;
+		  pWindowType1 = (WindowType)90;
+          v137 = 17;
+          v133 = 17;
+          v9 = 215;
+          goto LABEL_733;
+        case UIMSG_A3:
+          ++dword_6A0C9C;
+          if ( dword_6A0C9C >= uMessageParam )
+            dword_6A0C9C = uMessageParam - 1;
+          v163 = 0;
+          v8 = 323;
+          pButton2 = ptr_69BD58;
+//LABEL_60:
+          pWindowType1 = (WindowType)90;
+          v137 = 17;
+          v133 = 17;
+          v9 = 215;
+          goto LABEL_733;
+        case UIMSG_A6:
+          v163 = 0;
+          v8 = 302;
+          pButton2 = ptr_69BD60;
+          v9 = 350;
+          pWindowType1 = (WindowType)96;
+          v137 = 42;
+          v133 = 106;
+          goto LABEL_733;
+        case UIMSG_A4:
+          v163 = 0;
+          v8 = 302;
+          pButton2 = ptr_69BD64;
+          v9 = 241;
+          pWindowType1 = (WindowType)94;
+          v137 = 42;
+          v133 = 106;
+          goto LABEL_733;
+        case UIMSG_A5:
+          if ( pGUIWindow_CurrentMenu->field_40 == v0 )
+            pKeyActionMap->_459ED1(0);
+          if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != dword_6A0C9C + uMessageParam )
+          {
+            v10 = dword_6A0C9C + uMessageParam;
+            if ( dword_6BE138 == dword_6A0C9C + uMessageParam )
+            {
+              if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+              {
+                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)164;
+                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+                *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+                v11 = pMessageQueue_50CBD0->uNumMessages + 1;
+                v13 = __OFSUB__(pMessageQueue_50CBD0->uNumMessages + 1, 40);
+                v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
+                ++pMessageQueue_50CBD0->uNumMessages;
+                if ( v12 ^ v13 )
+                {
+                  pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)82;
+                  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+                  *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+                  ++pMessageQueue_50CBD0->uNumMessages;
+                }
+              }
+            }
+            uLoadGameUI_SelectedSlot = v10;
+            dword_6BE138 = v10;
+          }
+          else
+          {
+            pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
+            if ( strcmp((const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, pGlobalTXT_LocalizationStrings[72]) )// "Empty"
+              strcpy((char *)pKeyActionMap->pPressedKeysBuffer, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
+            pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
+          }
+          goto _continue;
+        case UIMSG_LoadGame:
+          if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
+          {
+            LoadGame(uLoadGameUI_SelectedSlot);
+            uGameState = 3;
+          }
+          goto _release_tex_and_continue;
+        case UIMSG_SaveGame:
+          if ( pGUIWindow_CurrentMenu->field_40 == v0 )
+          {
+            pKeyActionMap->_459ED1(0);
+            strcpy(
+              (char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot,
+              (const char *)pKeyActionMap->pPressedKeysBuffer);
+          }
+          DoSavegame(uLoadGameUI_SelectedSlot);
+          goto _release_tex_and_continue;
+        case UIMSG_StartNewGame|0x2:
+          pGUIWindow_CurrentMenu->Release();
+          pCurrentScreen = 11;
+          GameUI_DrawSaveMenu();
+          goto _continue;
+        case UIMSG_Game_OpenOptionsDialog:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          pGUIWindow_CurrentMenu->Release();
+          viewparams->field_48 = v0;
+          pCurrentScreen = 2;
+          uTextureID_507C60 = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C6C = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C68 = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C70 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C74 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C64[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C84 = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
+          uTextureID_507CB0 = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
+          uTextureID_507CB8 = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
+          uTextureID_507CB4 = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x16u, 0x10Eu,
+            (uTextureID_507C6C != -1 ? pIcons_LOD->pTextures[uTextureID_507C6C].uTextureWidth : 24),
+            (uTextureID_507C6C != -1 ? pIcons_LOD->pTextures[uTextureID_507C6C].uTextureHeight : 26),
+            v0, 0, 0xB8u, 0x80u, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x5Du, 0x10Eu,
+            (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureWidth : 24),
+            (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureHeight : 26),
+            v0, 0, 0xB8u, 0x40u, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xA4u, 0x10Eu,
+            (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureWidth : 24),
+            (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureHeight : 26),
+            v0, 0, 0xB8u, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x12Fu,
+            (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureWidth : 24),
+            (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureHeight : 26),
+            v0, 0, 0xB9u, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x12Fu,
+            (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureWidth : 24),
+            (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureHeight : 26),
+            v0, 0, 0xBBu, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x145u,
+            (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureWidth : 24),
+            (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureHeight : 26),
+            v0, 0, 0xE1u, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x145u,
+            (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureWidth : 24),
+            (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureHeight : 26),
+            v0, 0, 0xE2u, 0, 0, v1, 0);
+          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, 111, 4, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C70], 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xA2u, 0x10u, 0x10u, v0, 0, 0x6Fu, 5, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C74], 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, 0x6Fu, 0, 0, v1, 0);
+          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 4, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C70], 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 5, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C74], 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, 0x70u, 0, 0, v1, 0);
+          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 4, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C70], 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 5u, 0, v1,
+                         &pIcons_LOD->pTextures[uTextureID_507C74], 0);
+          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, 0xBAu, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0,
+            pGlobalTXT_LocalizationStrings[619],// "Return to Game"
+            0);
+          pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, 0x19Fu, 0, 0x4Bu, v1, 0);
+          pTexture = 0;
+          v150 = v1;
+          v143 = 86;
+          v138 = 0;
+          v134 = 421;
+          v131 = 0;
+          v129 = v0;
+          v126 = 40;
+          v124 = 214;
+          v122 = 194;
+          v120 = 19;
+          goto LABEL_117;
+        case UIMSG_OpenKeyMappingOptions:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          pGUIWindow_CurrentMenu->Release();
+          viewparams->field_48 = 1;
+          pCurrentScreen = 26;
+          uTextureID_507BF4 = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
+          uTextureID_507BF8 = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
+          uTextureID_507BFC = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C00 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C04 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_KeyMappingOptions, 0, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, "", 0);
+          dword_506E68 = -1;
+          dword_506F08 = 1;
+          memset(word_506E6C, 0, 0x1Cu);
+          word_506E6C[14] = 0;
+          memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
+          goto LABEL_90;
+        default:
+          goto _continue;
+        case UIMSG_ResetKeyMapping|0x1:
+          if ( dword_506E68 != -1 )
+            goto LABEL_623;
+          v14 = uMessageParam;
+          if ( dword_506F08 != v0 )
+            v14 = uMessageParam + 14;
+          dword_506E68 = v14;
+          pKeyActionMap->_459E5A(0, v0, pGUIWindow_CurrentMenu);
+          goto _continue;
+        case UIMSG_ResetKeyMapping:
+          v197 = 1;
+          pKeyActionMap->SetDefaultMapping();
+          uAction = 0;
+          do
+          {
+            v15 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+            if ( v15 != pPrevVirtualCidesMapping[uAction] )
+            {
+              if ( v197 )
+              {
+                v16 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+                GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v16, v0);
+                v197 = 0;
+              }
+              else
+              {
+                v17 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+                GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v17, 0);
+              }
+            }
+            pPrevVirtualCidesMapping[uAction] = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+            v18 = uAction++;
+            v13 = __OFSUB__(uAction, 28);
+            v12 = uAction - 28 < 0;
+            *((char *)word_506E6C + v18) = 0;
+          }
+          while ( v12 ^ v13 );
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = 0;
+          v127 = 219;
+          goto _play_sound_and_continue;
+        case 0x1A0:
+          dword_506F08 = v0;
+          goto _continue;
+        case UIMSG_StartNPCDialogue|0x100:
+          dword_506F08 = 2;
+          goto _continue;
+        case UIMSG_OpenVideoOptions:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          pGUIWindow_CurrentMenu->Release();
+          viewparams->field_48 = v0;
+          pCurrentScreen = 28;
+          uTextureID_507C10 = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C14 = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C18 = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C1C = pIcons_LOD->LoadTexture("opvdH-tn", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C20 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C24 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
+          pTextureIDs_GammaPositions[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C50 = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C54 = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE);
+          uTextureID_507C58 = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_VideoOptions, 0, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0, v1, 0);
+          if ( pRenderer->pRenderD3D )
+          {
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, v0, 0, 0x1A6u, 0, 0, v1, 0);
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, v0, 0, 0x1A7u, 0, 0, v1, 0);
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, v0, 0, 0x1A8u, 0, 0, v1, 0);
+          }
+          if ( !pRenderer->bWindowMode )
+          {
+            v0 = 1;
+            if ( GammaController::IsGammaSupported() )
+            {
+              pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, 0x1A9u, 4u, 0, v1,
+                             &pIcons_LOD->pTextures[uTextureID_507C20], 0);
+              pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, 0x1A9u, 5u, 0, v1,
+                             &pIcons_LOD->pTextures[uTextureID_507C24], 0);
+              pTexture = 0;
+              v150 = v1;
+              v143 = 0;
+              v138 = 0;
+              v134 = 425;
+              v131 = 0;
+              v129 = 1;
+              v126 = 18;
+              v124 = 170;
+              v122 = 162;
+              v120 = 42;
+LABEL_117:
+              pGUIWindow_CurrentMenu->CreateButton(v120, v122, v124, v126, v129, v131, v134, v138, v143, v150, pTexture);
+            }
+          }
+          goto _continue;
+        case UIMSG_ToggleTint|0x1:
+          if ( uMessageParam == 4 )
+          {
+            --uGammaPos;
+            if ( (uGammaPos & 0x80000000u) != 0 )
+            {
+              uGammaPos = 0;
+              goto LABEL_128;
+            }
+            v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
+            pGame->pGammaController->Initialize(v19);
+            v166 = v0;
+            v152 = (int)pBtn_SliderLeft;
+            pWindowType2 = (WindowType)90;
+            v140 = 0;
+            v136 = 0;
+            v20 = 21;
+            goto LABEL_122;
+          }
+          if ( uMessageParam == 5 )
+          {
+            ++uGammaPos;
+            if ( (signed int)uGammaPos <= 9 )
+            {
+              v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
+              pGame->pGammaController->Initialize(v21);
+              v20 = 213;
+              v166 = v0;
+              v152 = (int)pBtn_SliderRight;
+              pWindowType2 = (WindowType)90;
+              v140 = 0;
+              v136 = 0;
+LABEL_122:
+              GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
+              goto LABEL_128;
+            }
+            uGammaPos = 9;
+          }
+          else
+          {
+            uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17;
+            v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
+            pGame->pGammaController->Initialize(v22);
+          }
+LABEL_128:
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = 0;
+          v127 = 21;
+          goto _play_sound_and_continue;
+        case UIMSG_ToggleBloodsplats:
+          pGame->ToggleFlags2(0x20u);
+          goto _continue;
+        case UIMSG_ToggleColoredLights:
+          pRenderer->bUseColoredLights = pRenderer->bUseColoredLights == 0;
+          goto _continue;
+        case UIMSG_ToggleTint:
+          pRenderer->bTinting = pRenderer->bTinting == 0;
+          goto _continue;
+        case UIMSG_ChangeMusicVolume:
+          if ( uMessageParam == 4 )
+          {
+            --uMusicVolimeMultiplier;
+            if ( (char)uMusicVolimeMultiplier < 1 )
+              uMusicVolimeMultiplier = 0;
+            v167 = v0;
+            v23 = 243;
+            v153 = (int)pBtn_SliderLeft;
+LABEL_136:
+            GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
+            goto LABEL_143;
+          }
+          if ( uMessageParam == 5 )
+          {
+            ++uMusicVolimeMultiplier;
+            if ( (char)uMusicVolimeMultiplier > 9 )
+              uMusicVolimeMultiplier = 9;
+            v167 = v0;
+            v23 = 435;
+            v153 = (int)pBtn_SliderRight;
+            goto LABEL_136;
+          }
+          uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;
+          if ( (char)uMusicVolimeMultiplier > 9 )
+            uMusicVolimeMultiplier = 9;
+LABEL_143:
+          if ( uMusicVolimeMultiplier )
+            pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0,
+              (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0), 0);
+          pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
+          goto _continue;
+        case UIMSG_ChangeSoundVolume:
+          if ( uMessageParam == 4 )
+          {
+            --uSoundVolumeMultiplier;
+            if ( (char)uSoundVolumeMultiplier < 1 )
+              uSoundVolumeMultiplier = 0;
+            v168 = v0;
+            v24 = 243;
+            v154 = (int)pBtn_SliderLeft;
+LABEL_150:
+            GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
+            goto LABEL_157;
+          }
+          if ( uMessageParam == 5 )
+          {
+            ++uSoundVolumeMultiplier;
+            if ( (char)uSoundVolumeMultiplier > 8 )
+              uSoundVolumeMultiplier = 9;
+            v168 = v0;
+            v24 = 435;
+            v154 = (int)pBtn_SliderRight;
+            goto LABEL_150;
+          }
+          uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17;
+          if ( (char)uSoundVolumeMultiplier > 8 )
+            uSoundVolumeMultiplier = 9;
+LABEL_157:
+          pAudioPlayer->SetMasterVolume((signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = -1;
+          v127 = 218;
+          goto _play_sound_and_continue;
+        case UIMSG_ToggleFlipOnExit:
+          bFlipOnExit = bFlipOnExit == 0;
+          goto _continue;
+        case UIMSG_ToggleAlwaysRun:
+          bAlwaysRun = bAlwaysRun == 0;
+          goto _continue;
+        case UIMSG_ToggleWalkSound:
+          bWalkSound = bWalkSound == 0;
+          goto _continue;
+        case UIMSG_ToggleShowDamage:
+          bShowDamage = bShowDamage == 0;
+          goto _continue;
+        case UIMSG_ChangeVoiceVolume:
+          if ( uMessageParam == 4 )
+          {
+            --uVoicesVolumeMultiplier;
+            if ( (char)uVoicesVolumeMultiplier < 1 )
+              uVoicesVolumeMultiplier = 0;
+            v169 = v0;
+            v25 = 243;
+            v155 = (int)pBtn_SliderLeft;
+LABEL_166:
+            GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
+            goto LABEL_173;
+          }
+          if ( uMessageParam == 5 )
+          {
+            ++uVoicesVolumeMultiplier;
+            if ( (char)uVoicesVolumeMultiplier > 8 )
+              uVoicesVolumeMultiplier = 9;
+            v169 = v0;
+            v25 = 435;
+            v155 = (int)pBtn_SliderRight;
+            goto LABEL_166;
+          }
+          uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17;
+          if ( (char)uVoicesVolumeMultiplier > 8 )
+            uVoicesVolumeMultiplier = 9;
+LABEL_173:
+          if ( !uVoicesVolumeMultiplier )
+            goto _continue;
+          v165 = 0;
+          v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
+          v144 = 0;
+          v139 = 0;
+          v135 = -1;
+          v132 = 0;
+          v130 = -1;
+          v127 = 5788;
+          goto _play_sound_and_continue;
+        case UIMSG_SetTurnSpeed:
+          if ( uMessageParam )
+            pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
+          uTurnSpeed = uMessageParam;
+          goto _continue;
+        case UIMSG_SetGraphicsMode:
+          if ( !bUseLoResSprites )
+          {
+            byte_6BE388_graphicsmode = uMessageParam;
+LABEL_184:
+            MM7Initialization();
+            goto _continue;
+          }
+          if ( uMessageParam )
+          {
+            if ( uMessageParam == 1 )
+            {
+              byte_6BE388_graphicsmode = 0;
+            }
+            else
+            {
+              if ( uMessageParam != 2 )
+                goto _continue;
+              byte_6BE388_graphicsmode = 1;
+            }
+            goto LABEL_184;
+          }
+          ModalWindow(pNPCTopics[453].pText, 0);
+          goto _continue;
+        case UIMSG_SkillUp|0x2:
+          pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Resume();
+          goto LABEL_188;
+        case UIMSG_OpenQuestBook:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Pause();
+          pAudioPlayer->StopChannels(-1, -1);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, (enum WindowType)99, (int)pBtn_Quests, 0);
+          bFlashQuestBook = 0;
+          goto _continue;
+        case UIMSG_OpenAutonotes:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Pause();
+          pAudioPlayer->StopChannels(-1, -1);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, (enum WindowType)99, (int)pBtn_Autonotes, 0);
+          bFlashAutonotesBook = 0;
+          goto _continue;
+        case UIMSG_OpenMapBook:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Pause();
+          viewparams->sPartyPosX = pParty->vPosition.x;
+          viewparams->sPartyPosZ = pParty->vPosition.y;
+          pAudioPlayer->StopChannels(-1, -1);
+          pWindow = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          v27 = 353;
+          v28 = 546;
+          v170 = 0;
+          v156 = (int)pBtn_Maps;
+          goto LABEL_210;
+        case UIMSG_OpenCalendar:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Pause();
+          pAudioPlayer->StopChannels(-1, -1);
+          pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          v27 = 354;
+          v28 = 570;
+          v170 = 0;
+          v156 = (int)pBtn_Calendar;
+LABEL_210:
+          pGUIWindow_CurrentMenu = pWindow;
+          pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
+          goto _continue;
+        case UIMSG_OpenHistoryBook:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          pEventTimer->Pause();
+          pAudioPlayer->StopChannels(-1, -1);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)pBtn_History, 0);
+          bFlashHistoryBook = 0;
+          goto _continue;
+        case UIMSG_CloseBook:
+          back_to_game();
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen > 15 )
+          {
+            if ( pCurrentScreen >= 17 && (pCurrentScreen <= 18 || pCurrentScreen == 104) )
+            {
+LABEL_229:
+              if ( dword_50CDC8 )
+                goto LABEL_232;
+              sub_42FC15();
+              goto LABEL_231;
+            }
+          }
+          else
+          {
+            if ( pCurrentScreen >= 14 || pCurrentScreen == 4 || pCurrentScreen == 10 )
+              goto LABEL_229;
+            if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 )
+            {
+              sub_42FC15();
+              dword_5C35C8 = 0;
+LABEL_231:
+              uMessageParam = v0;
+              goto LABEL_232;
+            }
+          }
+LABEL_232:
+          if ( !ptr_507BDC )
+          {
+            pRenderer->ClearZBuffer(0, 479);
+            viewparams->bRedrawGameUI = v0;
+            viewparams->field_48 = v0;
+            if ( pCurrentScreen )
+            {
+              if ( pCurrentScreen > 103 )
+              {
+                if ( pCurrentScreen == 104 )
+                  goto LABEL_321;
+              }
+              else
+              {
+                if ( pCurrentScreen < 100 )
+                {
+                  switch ( pCurrentScreen )
+                  {
+                    case 23:
+                      pIcons_LOD->_4114F2();
+                      if ( some_active_character )
+                      {
+                        uActiveCharacter = some_active_character;
+                        uActiveCharacter = pParty->GetNextActiveCharacter();
+                        some_active_character = 0;
+                        if ( pParty->bTurnBasedModeOn )
+                          pTurnEngine->_40471C();
+                        dword_50C9D0 = 0;
+                        dword_50C9D4 = 0;
+                        dword_50C9D8 = 0;
+                      }
+                      if ( ptr_50C9A4 && ptr_50C9A4->uItemID )
+                      {
+                        LOBYTE(ptr_50C9A4->uAttributes) &= 0xFu;
+                        dword_50C9A8 = 0;
+                        ptr_50C9A4 = 0;
+                      }
+                      goto LABEL_322;
+                    case 3:
+                      pBooksWindow->Release();
+                      //crt_deconstruct_ptr_6A0118();
+                      pBooksWindow = 0;
+                      pEventTimer->Resume();
+                      goto LABEL_322;
+                    case 11:
+                    case 12:
+                      pIcons_LOD->_4114F2();
+                      //crt_deconstruct_ptr_6A0118();
+                      goto LABEL_291;
+                    case 15:
+                      pCurrentScreen = 10;
+                      goto _continue;
+                    case 10:
+                      pWindow2 = pChestWindow;
+                      goto LABEL_249;
+                    case 25:
+                      pWindow2 = ptr_507BC8;
+LABEL_249:
+                      pWindow2->Release();
+                      pIcons_LOD->_4114F2();
+                      pCurrentScreen = 0;
+                      viewparams->bRedrawGameUI = v0;
+                      pEventTimer->Resume();
+                      goto _continue;
+                    case 2:
+                      thisa = (signed int)&uTextureID_507C60;
+                      do
+                      {
+                        if ( *(int *)thisa )
+                          pIcons_LOD->pTextures[*(int *)thisa].Release();
+                        thisa += 4;
+                      }
+                      while ( thisa < (signed int)&dword_507CBC );
+                      memset(&uTextureID_507C60, 0, 0x5Cu);
+                      pIcons_LOD->_40F9C5();
+                      WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
+                      WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
+                      WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier);
+                      WriteWindowsRegistryInt("WalkSound", bWalkSound);
+                      WriteWindowsRegistryInt("ShowDamage", bShowDamage);
+                      WriteWindowsRegistryInt("graphicsmode", (unsigned __int8)byte_6BE388_graphicsmode);
+                      WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun);
+                      WriteWindowsRegistryInt("FlipOnExit", bFlipOnExit);
+                      if ( !uTurnSpeed )
+                      {
+                        v171 = 3;
+                        goto LABEL_261;
+                      }
+                      if ( uTurnSpeed == 64 )
+                      {
+                        v171 = 2;
+LABEL_261:
+                        v30 = v171;
+                        goto LABEL_262;
+                      }
+                      if ( uTurnSpeed != 128 )
+                        goto LABEL_291;
+                      v30 = v0;
+LABEL_262:
+                      v31 = "TurnDelta";
+LABEL_263:
+                      WriteWindowsRegistryInt(v31, v30);
+LABEL_291:
+                      stru_506E40.Release();
+                      break;
+                    case 1:
+                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->_4114F2();
+                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->_4114F2();
+                      goto LABEL_291;
+                    case 28:
+                      if ( pRenderer->pRenderD3D )
+                      {
+                        WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights);
+                        WriteWindowsRegistryInt("Tinting", pRenderer->bTinting);
+                        WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
+                      }
+                      if ( pRenderer->bWindowMode )
+                        goto LABEL_291;
+                      v30 = uGammaPos;
+                      v31 = "GammaPos";
+                      goto LABEL_263;
+                    case 26:
+                      v197 = 1;
+                      v32 = 0;
+                      while ( *((char *)word_506E6C + v32) != 1 )
+                      {
+                        ++v32;
+                        if ( v32 >= 28 )
+                        {
+                          thisb = (signed int)&uTextureID_507BF4;
+                          do
+                          {
+                            if ( *(int *)thisb )
+                              pIcons_LOD->pTextures[*(int *)thisb].Release();
+                            thisb += 4;
+                          }
+                          while ( thisb < (signed int)&dword_507C08 );
+                          memset(&uTextureID_507BF4, 0, 0x14u);
+                          pIcons_LOD->_40F9C5();
+                          uAction = 0;
+                          do
+                          {
+                            v33 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+                            if ( v33 != pPrevVirtualCidesMapping[uAction] )
+                            {
+                              if ( v197 )
+                              {
+                                v34 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+                                GUI_ReplaceHotkey(v34, LOBYTE(pPrevVirtualCidesMapping[uAction]), v0);
+                                v197 = 0;
+                              }
+                              else
+                              {
+                                v35 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
+                                GUI_ReplaceHotkey(v35, LOBYTE(pPrevVirtualCidesMapping[uAction]), 0);
+                              }
+                            }
+                            if ( uAction && uAction != 2 && uAction != 3 && uAction != v0 && uAction != 25 && uAction != 26 )
+                              pKeyToggleType = (KeyToggleType)v0;
+                            else
+                              pKeyToggleType = (KeyToggleType)0;
+                            pKeyActionMap->SetKeyMapping(uAction, pPrevVirtualCidesMapping[uAction], pKeyToggleType);
+                            ++uAction;
+                          }
+                          while ( uAction < 28 );
+                          pKeyActionMap->StoreMappings();
+                          goto LABEL_291;
+                        }
+                      }
+                      goto LABEL_623;
+                    case 5:
+                      if ( dword_506F14 )
+                      {
+                        Rest(_506F18_num_hours_to_sleep);
+                        pParty->pPlayers[3].pConditions[2] = 0i64;
+                        pParty->pPlayers[2].pConditions[2] = 0i64;
+                        pParty->pPlayers[1].pConditions[2] = 0i64;
+                        pParty->pPlayers[0].pConditions[2] = 0i64;
+                      }
+                      pTexture_RestUI_CurrentSkyFrame->Release();
+                      pTexture_RestUI_CurrentHourglassFrame->Release();
+                      pTexture_RestUI_CurrentHourglassFrame = 0;
+                      pTexture_RestUI_CurrentSkyFrame = 0;
+                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->_4114F2();
+                      _506F18_num_hours_to_sleep = 0;
+                      dword_506F14 = 0;
+                      dword_507B94 = v0;
+                      goto LABEL_322;
+                    case 14:
+                      pGUIWindow_CurrentMenu->Release();
+                      pCurrentScreen = 13;
+                      pIcons_LOD->_4114F2();
+                      goto _continue;
+                    case 13:
+                      if ( uDialogueType )
+                        uDialogueType = 0;
+                      if ( uGameState == 2 )
+                      {
+                        while ( sub_4BD8B5() )
+                          ;
+                      }
+                      else
+                      {
+                        if ( sub_4BD8B5() )
+                          goto _continue;
+                      }
+                      sub_4B1D27();
+                      pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 814, 0, -1, 0, 0, 0, 0);
+                      pVideoPlayer->Unload();
+                      pGUIWindow_CurrentMenu = ptr_507BC0;
+                      goto LABEL_322;
+                    case 18:
+                      if ( uCurrentHouse_Animation == 153 )
+                        HousePlaySomeSound(0x99u, 3);
+                      pVideoPlayer->Unload();
+                      goto LABEL_306;
+                    case 4:
+LABEL_306:
+                      if ( dword_5B65CC )
+                      {
+                        pParty->field_709 = 0;
+                        LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
+                        sub_44A56A();
+                        viewparams->bRedrawGameUI = v0;
+                        dword_5B65CC = 0;
+                      }
+                      goto LABEL_317;
+                    case 19:
+                      memset(GameUI_StatusBar_TimedString, 0, 0xC8u);
+                      sub_4452BB();
+                      goto LABEL_317;
+                    case 17:
+                      if ( pParty->vPosition.x < -22528 )
+                        pParty->vPosition.x = -22528;
+                      if ( pParty->vPosition.x > 22528 )
+                        pParty->vPosition.x = 22528;
+                      if ( pParty->vPosition.y < -22528 )
+                        pParty->vPosition.y = -22528;
+                      if ( pParty->vPosition.y > 22528 )
+                        pParty->vPosition.y = 22528;
+                      goto LABEL_317;
+                    case 16:
+                      pVideoPlayer->Unload();
+                      goto _continue;
+                    case 7:
+                      goto LABEL_319;
+                    default:
+                      goto LABEL_322;
+                  }
+                  goto LABEL_322;
+                }
+LABEL_319:
+                sub_4196A0();
+                sub_419379();
+LABEL_321:
+                pIcons_LOD->_4114F2();
+              }
+LABEL_322:
+              if ( pGUIWindow_Settings )
+              {
+                if ( pCurrentScreen == 7 )
+                {
+                  pMouse->SetCursorBitmap("MICON2");
+                }
+                else
+                {
+                  pGUIWindow_Settings->Release();
+                  pGUIWindow_Settings = 0;
+                  pMouse->SetCursorBitmap("MICON1");
+                  GameUI_StatusBar_TimedStringTimeLeft = 0;
+                  unk_50C9A0 = 0;
+                  back_to_game();
+                }
+              }
+              if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
+                uActiveCharacter = pParty->GetNextActiveCharacter();
+              pGUIWindow_CurrentMenu->Release();
+              if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
+                ptr_507BC0 = 0;
+              pGUIWindow_CurrentMenu = 0;
+              pEventTimer->Resume();
+              pCurrentScreen = 0;
+              viewparams->bRedrawGameUI = v0;
+              pIcons_LOD->_4355F7();
+              goto _continue;
+            }
+            pWindow3 = pGUIWindow_Settings;
+            if ( !pGUIWindow_Settings )//Draw Menu
+            {
+              dword_6BE138 = -1;
+              GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_GameSettings, v0);
+              pEventTimer->Pause();
+              pAudioPlayer->StopChannels(-1, -1);
+              ++pIcons_LOD->uTexturePacksCount;
+              pCurrentScreen = v0;
+              if ( !pIcons_LOD->uNumPrevLoadedFiles )
+                pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+              pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)3, 0, 0);
+              uTextureID_507944 = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
+              uTextureID_507940 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
+              uTextureID_50793C = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
+              uTextureID_507938 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE);
+              uTextureID_507934 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE);
+              uTextureID_507930 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
+              uTextureID_50792C = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
+              pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, v0, 0, 0x7Cu, 0, 0x4Eu,
+                             pGlobalTXT_LocalizationStrings[614],// "New Game"
+                             (Texture *)(uTextureID_507940 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507940] : 0), 0);
+              pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, v0, 0, 0x7Eu, 0, 0x53u,
+                             pGlobalTXT_LocalizationStrings[615],// "Save Game"
+                             (Texture *)(uTextureID_507938 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507938] : 0), 0);
+              pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, v0, 0, 0x7Du, 0, 0x4Cu,
+                             pGlobalTXT_LocalizationStrings[616],// "Load Game"
+                             (Texture *)(uTextureID_50793C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50793C] : 0), 0);
+              pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, v0, 0, 0x7Fu, 0, 0x43u,
+                             pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
+                             (Texture *)(uTextureID_507934 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507934] : 0), 0);
+              pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, v0, 0, 0x84u, 0, 0x51u,
+                             pGlobalTXT_LocalizationStrings[618],// "Quit"
+                             (Texture *)(uTextureID_50792C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50792C] : 0), 0);
+              pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, v0, 0, 0x7Bu, 0, 0x52u,
+                             pGlobalTXT_LocalizationStrings[619],// "Return to Game"
+                             (Texture *)(uTextureID_507930 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507930] : 0), 0);
+              pGUIWindow_CurrentMenu->_41D08F(6, v0, 0, 0);
+              viewparams->field_48 = v0;
+              stru_506E40.Release();
+              uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
+              pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
+              free((void *)uNumSeconds);
+              stru_506E40._40E55E("gamma.pcx", 0);
+              goto _continue;
+            }
+            goto LABEL_333;
+          }
+          sub_41426F();
+_continue:
+          continue;
+        case UIMSG_BC:
+          if ( uMessageParam )
+          {
+            GUIWindow::Create(0x272u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCRight, 0);
+            v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2;
+            if ( (unsigned __int8)pParty->field_709 < v37 )
+            {
+              ++pParty->field_709;
+              if ( (unsigned __int8)pParty->field_709 >= v37 )
+                pParty->field_709 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + pParty->field_70A - 2;
+            }
+          }
+          else
+          {
+            GUIWindow::Create(0x1D5u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCLeft, 0);
+            if ( pParty->field_709 )
+            {
+              --pParty->field_709;
+              if ( pParty->field_709 < 1 )
+                pParty->field_709 = 0;
+            }
+          }
+          DrawHiredNPCs();
+          goto _continue;
+        case UIMSG_OpenRestUI|0x2:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          dword_50CDC8 = v0;
+          sub_42FBDD();
+          HousePlaySomeSound(uCurrentHouse_Animation, 2);
+          pVideoPlayer->Unload();
+          sub_44603D();
+          viewparams->bRedrawGameUI = v0;
+          if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz )
+          {
+            if ( dword_59117C_teleportx )
+            {
+              pParty->vPosition.x = dword_59117C_teleportx;
+              _5B65A8_npcdata_uflags_or_other = dword_59117C_teleportx;
+            }
+            if ( dword_591178_teleporty )
+            {
+              pParty->vPosition.y = dword_591178_teleporty;
+              _5B65AC_npcdata_fame_or_other = dword_591178_teleporty;
+            }
+            if ( dword_591174_teleportz )
+            {
+              pParty->vPosition.z = dword_591174_teleportz;
+              _5B65B0_npcdata_rep_or_other = dword_591174_teleportz;
+              pParty->uFallStartY = dword_591174_teleportz;
+            }
+            if ( dword_591170_teleport_directiony )
+            {
+              pParty->sRotationY = dword_591170_teleport_directiony;
+              _5B65B4_npcdata_loword_house_or_other = dword_591170_teleport_directiony;
+            }
+            if ( dword_59116C_teleport_directionx )
+            {
+              pParty->sRotationX = dword_59116C_teleport_directionx;
+              _5B65B8_npcdata_hiword_house_or_other = dword_59116C_teleport_directionx;
+              v38 = dword_591168_teleport_speedz;
+              pParty->uFallSpeed = dword_591168_teleport_speedz;
+              dword_5B65BC = dword_591168_teleport_speedz;
+            }
+            else
+            {
+              v38 = dword_5B65BC;
+            }
+            if ( *dword_591164_teleport_map_name != 48 )
+            {
+              pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2;
+              dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38;
+              OnMapLeave();
+              sub_44987B(dword_591164_teleport_map_name, 0);
+            }
+          }
+          else
+          {
+            dword_597F18 = dword_5C341C;
+            EventProcessor(dword_5C3418, 0, v0);
+          }
+          dword_597F18 = 0;
+          if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
+            pParty->uTimePlayed += 1474560i64;
+          goto _continue;
+        case 0x19C:
+          sub_42FC15();
+          pVideoPlayer->Unload();
+          sub_44603D();
+          dword_597F18 = 0;
+          goto LABEL_422;
+        case UIMSG_CycleCharacters:
+          v39 = GetAsyncKeyState(VK_SHIFT);
+          v40 = CycleCharacter(v39);
+          goto LABEL_421;
+        case UIMSG_LoadGame|0x8:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          dword_50CDC8 = v0;
+          sub_42FBDD();
+          pNPCData4 = (NPCData *)GetTravelTime();
+          strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
+          if ( bUnderwater != 1 && pParty->bFlying
+            || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, &pOut, 20) != v0 )
+          {
+            viewparams->bRedrawGameUI = v0;
+LABEL_387:
+            sub_42FC15();
+            if ( pParty->vPosition.x < -22528 )
+              pParty->vPosition.x = -22528;
+            if ( pParty->vPosition.x > 22528 )
+              pParty->vPosition.x = 22528;
+            if ( pParty->vPosition.y < -22528 )
+              pParty->vPosition.y = -22528;
+            if ( pParty->vPosition.y > 22528 )
+              pParty->vPosition.y = 22528;
+LABEL_317:
+            sub_44603D();
+            pCurrentScreen = 0;
+          }
+          else
+          {
+            pParty->field_6E4 = 0;
+            pParty->field_6E0 = 0;
+            pStru277->_427D48(v0);
+            sub_44603D();
+            pEventTimer->Pause();
+            pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)2);
+            ++pGameLoadingUI_ProgressBar->uProgressMax;
+            SaveGame(v0, 0);
+            pGameLoadingUI_ProgressBar->Progress();
+            RestAndHeal(1440 * (signed int)pNPCData4);
+            if ( pParty->uNumFoodRations )
+            {
+              pParty->RestAndHeal();
+              if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 )
+              {
+                pPlayer7 = pParty->pPlayers;
+                do
+                {
+                  pPlayer7->SetCondition(v0, 0);
+                  ++pPlayer7;
+                }
+                while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
+                ++pParty->field_764;
+              }
+              Party::TakeFood((unsigned int)pNPCData4);
+            }
+            else
+            {
+              pPlayer8 = pParty->pPlayers;
+              do
+              {
+                pPlayer8->SetCondition(v0, 0);
+                ++pPlayer8;
+              }
+              while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings );
+              ++pParty->field_764;
+            }
+            pPaletteManager->ResetNonLocked();
+            pSpriteFrameTable->ResetSomeSpriteFlags();
+            strcpy(pCurrentMapName, &pOut);
+            strcpy(&pLevelName, pCurrentMapName);
+            v41 = strtok(&pLevelName, ".");
+            strcpy(&pLevelName, v41);
+            Level_LoadEvtAndStr(&pLevelName);
+            pDecalBuilder->Reset( 0);
+            LoadLevel_InitializeLevelEvt();
+            uLevelMapStatsID = pMapStats->GetMapInfo(pCurrentMapName);
+            bUnderwater = 0;
+            bNoNPCHiring = 0;
+            pGame->uFlags2 &= 0xFFFFFFF7u;
+            if ( Is_out15odm_underwater() )
+            {
+              bUnderwater = 1;
+              pGame->uFlags2 |= 8u;
+            }
+            if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d47.blv") )
+              bNoNPCHiring = 1;
+            v0 = 1;
+            PrepareToLoadODM(1u, (OutdoorCamera *)1);
+            pAudioPlayer->SetMapEAX();
+            bDialogueUI_InitializeActor_NPC_ID = 0;
+            OnMapLoad();
+            pOutdoor->SetFog();
+            TeleportToStartingPoint(uLevel_StartingPointType);
+            pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, (int *)&v213, 0);
+            pParty->uFallStartY = pParty->vPosition.z;
+            sub_461103();
+            pEventTimer->Resume();
+            viewparams->bRedrawGameUI = 1;
+            pCurrentScreen = 0;
+            pGameLoadingUI_ProgressBar->Release();
+          }
+          goto LABEL_422;
+        case UIMSG_SaveGame|0x8:
+          goto LABEL_387;
+        case UIMSG_BE:
+          if ( pRenderer->pRenderD3D )
+          {
+            LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val();
+          }
+          else
+          {
+            uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210);
+            pPoint = pMouse->GetCursorPos(&v208);
+            v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]];
+          }
+          v44 = (unsigned __int16)v42;
+          v45 = v44 & 7;
+          uNumSeconds = v44;
+          v46 = v44 >> 3;
+          if ( v45 == 3 )
+          {
+            v47 = pActors[v46].uAIState == Dead;
+            goto LABEL_400;
+          }
+          if ( v45 == 2 )
+          {
+            v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
+LABEL_400:
+            if ( !v47 )
+              goto _continue;
+            goto LABEL_415;
+          }
+          if ( v45 == 5 )
+          {
+            v48 = pLevelDecorations[v46].field_16_event_id == 0;
+          }
+          else
+          {
+            if ( v45 != 6 )
+              goto _continue;
+            if ( uCurrentlyLoadedLevelType != v0 )
+            {
+              pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
+              if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
+                goto _continue;
+              v44 = uNumSeconds;
+              goto LABEL_415;
+            }
+            pBLVFace = &pIndoor->pFaces[v46];
+            if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
+              goto _continue;
+            v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0;
+          }
+          if ( v48 )
+            goto _continue;
+LABEL_415:
+          v51 = pGUIWindow_Settings->ptr_1C;
+          *((char *)v51 + 8) &= 0xBFu;
+LABEL_416:
+          *((short *)v51 + 2) = uMessageParam;
+          *((int *)v51 + 3) = v44;
+          pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
+          pWindow3 = pGUIWindow_Settings;
+LABEL_333:
+          pWindow3->Release();
+          pGUIWindow_Settings = 0;
+          pMouse->SetCursorBitmap("MICON1");
+          GameUI_StatusBar_TimedStringTimeLeft = 0;
+          unk_50C9A0 = 0;
+          back_to_game();
+          goto _continue;
+        case UIMSG_ChangeGameState|0x40:
+        case 0x8D:
+        case 0x8F:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( unk_50C9A0 )
+          {
+            v40 = uMessageParam;
+LABEL_421:
+            uActiveCharacter = v40;
+LABEL_422:
+            viewparams->bRedrawGameUI = v0;
+          }
+          else
+          {
+            if ( pGUIWindow_Settings )
+            {
+              v52 = pGUIWindow_Settings->ptr_1C;
+              switch ( uMessage )
+              {
+                case 69:
+                  *((char *)v52 + 8) &= 0xFDu;
+                  break;
+                case 141:
+                  *((char *)v52 + 9) &= 0xFEu;
+                  break;
+                case 143:
+                  *((char *)v52 + 9) &= 0xFDu;
+                  break;
+              }
+              *((short *)v52 + 2) = uMessageParam;
+              pParty->pPlayers[*((short *)v52 + 1)].SetRecoveryTime(300);
+              pGUIWindow_Settings->Release();
+              pGUIWindow_Settings = 0;
+              pEventTimer->Resume();
+              pMouse->SetCursorBitmap("MICON1");
+              GameUI_StatusBar_TimedStringTimeLeft = 0;
+              unk_50C9A0 = 0;
+            }
+          }
+          goto _continue;
+        case UIMSG_BF:
+          dword_50CDC8 = v0;
+          sub_42FBDD();
+          SaveGame(v0, 0);
+          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[(unsigned int)ptr_507BC0->ptr_1C - 1]._quest_related;
+		  if ( v53 < 0 )
+          {
+            v54 = abs(v53) - 1;
+            _5B65B8_npcdata_hiword_house_or_other = 0;
+            dword_5B65BC = 0;
+            v55 = dword_4E4560[v54];
+            _5B65AC_npcdata_fame_or_other = dword_4E4578[v54];
+            v56 = dword_4E4590[v54];
+            v57 = dword_4E45A8[v54];
+            _5B65A8_npcdata_uflags_or_other = v55;
+            _5B65B4_npcdata_loword_house_or_other = v57;
+            _5B65B0_npcdata_rep_or_other = v56;
+            dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
+          }
+          sub_4BD8B5();
+          goto LABEL_434;
+        case UIMSG_C3:
+          pAudioPlayer->StopChannels(-1, -1);
+          v162 = uMessageParam;
+          v148 = 195;
+          goto LABEL_438;
+        case UIMSG_B1:
+          pAudioPlayer->StopChannels(-1, -1);
+          v162 = 0;
+          v148 = 177;
+LABEL_438:
+          pWindowType = (WindowType)9;
+LABEL_439:
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          goto _continue;
+        case UIMSG_B2:
+          v165 = 0;
+          v151 = 0;
+          v144 = 0;
+          v139 = 0;
+          bRecallingBeacon = uMessageParam;
+          v135 = -1;
+          v132 = 0;
+          v130 = 0;
+          v127 = uMessageParam + 204;
+          goto _play_sound_and_continue;
+        case UIMSG_B4:
+          if ( !pGUIWindow_CurrentMenu )
+            goto _continue;
+          pPlayer = pPlayers[_506348_current_lloyd_playerid + 1];
+          uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
+          if ( bRecallingBeacon )
+          {
+            if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) )
+              goto _continue;
+            v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
+            v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s"
+            goto _sprintex_2args_draw_status_and_continue;
+          }
+          v59 = pMapStats->GetMapInfo(pCurrentMapName);
+          thise = "Not in Map Stats";
+          if ( v59 )
+            thise = pMapStats->pInfos[v59].pName;
+          if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) || !v59 )
+          {
+            v173 = thise;
+            v157 = pGlobalTXT_LocalizationStrings[476];// "Set to %s"
+            goto _sprintex_2args_draw_status_and_continue;
+          }
+          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:
+          sprintf(pTmpBuf, v146, v158, v174);
+          goto _set_status_string_pTmpBuf_and_continue;
+        case UIMSG_B5:
+          dword_50CDC8 = v0;
+          goto LABEL_453;
+        case UIMSG_B3:
+          pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
+          pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
+          if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
+            goto _continue;
+          byte_506360 = 1;
+          pPlayer9->CanCastSpell(uRequiredMana);
+          if ( pParty->bTurnBasedModeOn )
+          {
+            v60 = sRecoveryTime;
+            pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime;
+            pPlayer9->SetRecoveryTime(v60);
+            pTurnEngine->_40471C();
+          }
+          else
+          {
+            pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
+          }
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
+          if ( bRecallingBeacon )
+          {
+            if ( _strcmpi(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
+            {
+              SaveGame(v0, 0);
+              OnMapLeave();
+              strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]);
+              dword_6BE364_game_settings_1 |= v0;
+              uGameState = 2;
+              _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags;
+              _5B65AC_npcdata_fame_or_other = pNPCData4->fame;
+              _5B65B0_npcdata_rep_or_other = pNPCData4->rep;
+              _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->house);
+              _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->house);
+              dword_5B65C0 = v0;
+            }
+            else
+            {
+              pParty->vPosition.x = pNPCData4->uFlags;
+              pParty->vPosition.y = pNPCData4->fame;
+              pParty->vPosition.z = pNPCData4->rep;
+              pParty->uFallStartY = pParty->vPosition.z;
+              pParty->sRotationY = LOWORD(pNPCData4->house);
+              pParty->sRotationX = HIWORD(pNPCData4->house);
+            }
+            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;
+            }
+            //crt_deconstruct_ptr_6A0118();
+            pBooksWindow->Release();
+            pGUIWindow_CurrentMenu->Release();
+            pBooksWindow = 0;
+            pGUIWindow_CurrentMenu = 0;
+          }
+          else
+          {
+            sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
+            SaveScreenshot(a1);
+            LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
+            v212 = qword_506350 << 7;
+            pNPCData2 = pNPCData4;
+            thisg = 0;
+            v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
+            pNPCData4->pName = (char *)v62;
+            pNPCData2->uPortraitID = HIDWORD(v62);
+            pNPCData2->uFlags = pParty->vPosition.x;
+            pNPCData2->fame = pParty->vPosition.y;
+            pNPCData2->rep = pParty->vPosition.z;
+            LOWORD(pNPCData2->house) = LOWORD(pParty->sRotationY);
+            HIWORD(pNPCData2->house) = LOWORD(pParty->sRotationX);
+            if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
+              goto _continue;
+            uAction = 0;
+            while ( _strcmpi((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
+            {
+              ++thisg;
+              uAction += 32;
+              if ( thisg >= (signed int)pGames_LOD->uNumSubIndices / 2 )
+                goto _continue;
+            }
+            HIWORD(pNPCData4->uProfession) = thisg;
+          }
+          goto _continue;
+        case UIMSG_B7:
+          if ( uMessageParam )
+          {
+            switch ( uMessageParam )
+            {
+              case 1:
+                v63 = 208;
+                break;
+              case 2:
+                v63 = 207;
+                break;
+              case 3:
+                v63 = 211;
+                break;
+              case 4:
+                v63 = 209;
+                break;
+              default:
+                if ( uMessageParam != 5 )
+                {
+LABEL_486:
+                  SaveGame(v0, 0);
+                  v64 = pMapStats->GetMapInfo(pCurrentMapName);
+                  v65 = uMessageParam;
+                  if ( v64 == stru_4ECBB8[uMessageParam].uMapInfoID )
+                  {
+                    pParty->vPosition.x = stru_4ECBB8[v65].pos.x;
+                    pParty->vPosition.y = stru_4ECBB8[v65].pos.y;
+                    pParty->vPosition.z = stru_4ECBB8[v65].pos.z;
+                    pParty->uFallStartY = pParty->vPosition.z;
+                    pParty->sRotationY = stru_4ECBB8[v65].rot_y;
+                    pParty->sRotationX = stru_4ECBB8[v65].rot_x;
+                  }
+                  else
+                  {
+                    SaveGame(v0, 0);
+                    OnMapLeave();
+                    dword_6BE364_game_settings_1 |= v0;
+                    uGameState = 2;
+                    strcpy(pCurrentMapName, pMapStats->pInfos[stru_4ECBB8[uMessageParam].uMapInfoID].pFilename);
+                    dword_5B65C0 = v0;
+                    _5B65A8_npcdata_uflags_or_other = stru_4ECBB8[uMessageParam].pos.x;
+                    _5B65AC_npcdata_fame_or_other = stru_4ECBB8[uMessageParam].pos.y;
+                    _5B65B0_npcdata_rep_or_other = stru_4ECBB8[uMessageParam].pos.z;
+                    v66 = stru_4ECBB8[uMessageParam].rot_x;
+                    _5B65B4_npcdata_loword_house_or_other = stru_4ECBB8[uMessageParam].rot_y;
+                    _5B65B8_npcdata_hiword_house_or_other = v66;
+                    InitializeActors();
+                  }
+                  v67 = pGUIWindow_CurrentMenu->Hint;
+                  if ( v67 )
+                    *((int *)v67 + 17) = v0;
+                  else
+                    pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
+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:
+                    *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+                    ++pMessageQueue_50CBD0->uNumMessages;
+                  }
+                  goto _continue;
+                }
+                v63 = 210;
+                break;
+            }
+          }
+          else
+          {
+            v63 = 206;
+          }
+          if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v63) )
+            return;
+          goto LABEL_486;
+        case UIMSG_B6:
+          if ( uMessageParam )
+          {
+            switch ( uMessageParam )
+            {
+              case 1:
+                v68 = 208;
+                break;
+              case 2:
+                v68 = 207;
+                break;
+              case 3:
+                v68 = 211;
+                break;
+              case 4:
+                v68 = 209;
+                break;
+              default:
+                if ( uMessageParam != 5 )
+                  goto LABEL_506;
+                v68 = 210;
+                break;
+            }
+          }
+          else
+          {
+            v68 = 206;
+          }
+          if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v68) )
+          {
+            pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
+            goto _continue;
+          }
+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 )
+                  //goto LABEL_519;
+				  {
+				   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;
+//LABEL_519:
+          v173 = v200;
+          v157 = pGlobalTXT_LocalizationStrings[35];
+          goto _sprintex_2args_draw_status_and_continue;
+        case UIMSG_ShowFinalWindow:
+          sprintf(pFinalMessage, "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer."
+            pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment."
+            pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team."   
+          ModalWindow(pFinalMessage, 196);
+          uGameState = GAME_STATE_FINAL_WINDOW;
+          goto _continue;
+        case UIMSG_C4:
+          uGameState = 0;
+          strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
+          goto LABEL_524;
+        case UIMSG_D5|0x8:
+LABEL_524:
+          sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer);
+          memcpy(&v216, texture_frame_table_txt_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216));
+          if ( v216.field_0 == 1 )
+          {
+            pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubIndices / 2);
+            v70 = atoi(v216.pProperties[0]);
+            if ( v70 <= 0 || v70 >= 77 )
+            {
+LABEL_90:
+              v1 = "";
+LABEL_91:
+              v0 = 1;
+              goto _continue;
+            }
+            v71 = v70;
+            strcpy(Str2, pMapStats->pInfos[v70].pFilename);
+            pNPCData3 = 0;
+            if ( (signed int)pNPCData4 > 0 )
+            {
+              thish = 0;
+              do
+              {
+                if ( !_strcmpi((const char *)&pGames_LOD->pSubIndices[thish], Str2) )
+                  break;
+                ++thish;
+                pNPCData3 = (NPCData *)((char *)pNPCData3 + 1);
+              }
+              while ( (signed int)pNPCData3 < (signed int)pNPCData4 );
+              if ( (signed int)pNPCData3 < (signed int)pNPCData4 )
+              {
+                strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[(int)pNPCData3]);
+                dword_6BE364_game_settings_1 |= 1u;
+                uGameState = 2;
+                OnMapLeave();
+                //goto LABEL_90;
+				v1 = "";
+                v0 = 1;
+                goto _continue;
+              }
+            }
+            sprintf(Str2, "No map found for %s", pMapStats->pInfos[v71].pName);
+            v73 = Str2;
+          }
+          else
+          {
+            if ( v216.field_0 != 3 )
+              goto LABEL_90;
+            v74 = atoi(v216.pProperties[0]);
+            thisi = atoi(v216.pProperties[1]);
+            v75 = atoi(v216.pProperties[2]);
+            v76 = v75;
+            if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+            {
+              if ( pIndoor->GetSector(v74, thisi, v75) )
+              {
+                v77 = thisi;
+LABEL_544:
+                pParty->vPosition.x = v74;
+                pParty->vPosition.y = v77;
+                pParty->vPosition.z = v76;
+                pParty->uFallStartY = v76;
+                goto LABEL_90;
+              }
+            }
+            else
+            {
+              if ( v74 > -32768 )
+              {
+                if ( v74 < 32768 )
+                {
+                  v77 = thisi;
+                  if ( thisi > -32768 )
+                  {
+                    if ( thisi < 32768 && v76 >= 0 && v76 < 10000 )
+                      goto LABEL_544;
+                  }
+                }
+              }
+            }
+            pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+            v73 = "Can't jump to that location!";
+          }
+          ShowStatusBarString(v73, 6u);
+          //goto LABEL_90;
+		  v1 = "";
+          v0 = 1;
+          goto _continue;
+        case 0x19:
+          if ( bUnderwater == 1 )
+            goto LABEL_682;
+          if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) )
+            goto LABEL_90;
+          v79 = pPlayer2->uQuickSpell;
+          v175 = uActiveCharacter;
+          v159 = 0;
+          v147 = 0;
+          v80 = uActiveCharacter - 1;
+          goto LABEL_679;
+        case 0x46:
+        case UIMSG_Quit|0x8:
+          if ( pRenderer->pRenderD3D )
+          {
+            v81 = pGame->pVisInstance->get_picked_object_zbuf_val();
+          }
+          else
+          {
+            uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206);
+            pPoint2 = pMouse->GetCursorPos(&v201);
+            v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint2->y]];
+          }
+          v83 = v81;
+          v44 = (unsigned __int16)v81;
+          v84 = v83 >> 16;
+          if ( (v44 & 7) != 3 || v84 >= 5120 )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          v51 = pGUIWindow_Settings->ptr_1C;
+          if ( uMessage == 70 )
+          {
+            *((char *)v51 + 8) &= 0xF7u;
+          }
+          else
+          {
+            if ( uMessage == 140 )
+              *((char *)v51 + 9) &= 0xFEu;
+            else
+              *((char *)v51 + 9) &= 0xFDu;
+          }
+          goto LABEL_416;
+        case 0x1C:
+          if ( !uActiveCharacter || pCurrentScreen )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0);
+          pCurrentScreen = 25;
+          pEventTimer->Pause();
+          goto _continue;
+        case 0x1B:
+          if ( !uActiveCharacter )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          if ( pParty->bTurnBasedModeOn != v0 )
+            goto LABEL_569;
+          if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          if ( !(pTurnEngine->field_18 & 2) )
+          {
+LABEL_569:
+            if ( pActors[uMessageParam].uAIState == 5 )
+              stru_50C198.LootActor(&pActors[uMessageParam]);
+            else
+              Actor::StealFrom(uMessageParam);
+          }
+          goto _continue;
+        case 0x17:
+          if ( !uActiveCharacter )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          if ( pParty->bTurnBasedModeOn != v0 )
+            goto LABEL_577;
+          if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          if ( !(pTurnEngine->field_18 & 2) )
+LABEL_577:
+            _42ECB5_PlayerAttacksActor();
+          goto _continue;
+        case UIMSG_A7:
+          v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest"
+          pButton = pButton_RestUI_Exit;
+          pButton2 = pButton_RestUI_Exit;
+          pWindowType1 = (WindowType)96;
+          goto LABEL_731;
+        case UIMSG_ShowStatus_Player|0x1:
+          if ( dword_506F14 == 2 )
+            goto LABEL_621;
+          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;
+          _506F18_num_hours_to_sleep = 5;
+          goto _continue;
+        case 0x60:
+          if ( dword_506F14 == 2 )
+            goto LABEL_621;
+          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;
+          _506F18_num_hours_to_sleep = 60;
+          goto _continue;
+        case UIMSG_OpenRestUI:
+          dword_506F14 = 2;
+          RestUI_Initialize();
+          v86 = 60 * (sub_494820(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
+          _506F18_num_hours_to_sleep = v86;
+          if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
+            _506F18_num_hours_to_sleep = v86 + 720;
+          goto LABEL_615;
+        case 0x68:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            goto _continue;
+          if ( sub_42F4DA() )
+            goto LABEL_594;
+          if ( pParty->bTurnBasedModeOn == v0 )
+            goto LABEL_595;
+          if ( !(pParty->uFlags & 0x88) )
+          {
+            RestUI_Initialize();
+            goto _continue;
+          }
+LABEL_594:
+          if ( pParty->bTurnBasedModeOn == v0 )
+          {
+LABEL_595:
+            v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
+            goto _draw_status_string_and_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 )
+            //goto LABEL_90;
+		  {
+			v1 = "";
+            v0 = 1;
+            goto _continue;
+		  }
+          v176 = 0;
+          v160 = 13;
+          goto LABEL_619;
+        case 0x61:
+          if ( dword_506F14 )
+            goto LABEL_621;
+          if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest )
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
+            if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() )
+            {
+              v89 = uActiveCharacter;
+              v176 = 0;
+              v160 = 108;
+LABEL_619:
+              pPlayers[v89]->PlaySound(v160, v176);
+            }
+          }
+          else
+          {
+            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;
+            v90 = pMapStats->GetMapInfo(pCurrentMapName);
+            if ( !v90 )
+              v90 = rand() % (signed int)pMapStats->uNumMaps + 1;
+            pMapInfo = &pMapStats->pInfos[v90];
+            if ( rand() % 100 + 1 <= pMapInfo->field_30 )
+            {
+              v91 = rand() % 100;
+              v92 = pMapInfo->field_31;
+              v93 = v91 + 1;
+              if ( v93 > v92 )
+                pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->field_32) + 2);
+              else
+                pNPCData4 = (NPCData *)v0;
+              if ( !sub_45063B(pMapInfo, (int)pNPCData4) )
+                pNPCData4 = 0;
+              if ( pNPCData4 )
+              {
+                pPlayerNum = rand() % 4;
+                LODWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
+                HIDWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
+                v95 = rand();
+                Rest(v95 % 6 + 60);
+                _506F18_num_hours_to_sleep = 0;
+                dword_506F14 = 0;
+                if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+                {
+                  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;
+                }
+                ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!"
+                v165 = 0;
+                v151 = 0;
+                v144 = 0;
+                v139 = 0;
+                v135 = -1;
+                v132 = 0;
+                v130 = 0;
+                v127 = 227;
+                goto _play_sound_and_continue;
+              }
+            }
+            Party::TakeFood(uRestUI_FoodRequiredToRest);
+            _506F18_num_hours_to_sleep = 480;
+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;
+          }
+          goto _continue;
+        case UIMSG_ShowStatus_Funds|0x8:
+          if ( dword_506F14 == 2 )
+          {
+LABEL_621:
+            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
+            goto LABEL_622;
+          }
+          GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, (enum WindowType)90,
+            (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
+          v97 = sub_494820(pParty->uCurrentHour);
+          dword_506F14 = v0;
+          _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
+          goto _continue;
+        case 0x4E:
+          if ( dword_50654C && byte_506550 )
+          {
+            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName;
+            v157 = pGlobalTXT_LocalizationStrings[483];
+_sprintex_2args_draw_status_and_continue:
+            sprintf(pTmpBuf, v157, v173);
+          }
+          else
+          {
+            if ( pPlayers[uActiveCharacter]->uQuickSpell )
+              v177 = pGlobalTXT_LocalizationStrings[584];// "Click here to remove your Quick Spell"
+            else
+              v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
+            strcpy(pTmpBuf, v177);
+          }
+_set_status_string_pTmpBuf_and_continue:
+          sub_41C0B8_set_status_string(pTmpBuf);
+          goto _continue;
+        case 0x4F:
+          if ( !uActiveCharacter
+            || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
+                !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) )
+            goto _continue;
+          if ( sub_4637E0_is_there_popup_onscreen() )
+            dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1;
+          v98 = *(char *)(uNumSeconds + 6734);
+          if ( dword_50654C - 1 == uMessageParam )
+          {
+            v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
+            v161 = pGlobalTXT_LocalizationStrings[485];
+          }
+          else
+          {
+            v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
+            v161 = pGlobalTXT_LocalizationStrings[486];
+          }
+          sprintf(pTmpBuf, v161, v178);
+          sub_41C0B8_set_status_string(pTmpBuf);
+          goto LABEL_91;
+        case 0x58:
+          GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
+          if ( !uActiveCharacter )
+            goto _continue;
+          pPlayer10 = pPlayers[uActiveCharacter];
+          if ( !byte_506550 || !dword_50654C )
+          {
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            pPlayer10->uQuickSpell = 0;
+            v130 = 0;
+            dword_50654C = 0;
+            v127 = 203;
+            goto _play_sound_and_continue;
+          }
+          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage;
+          pPlayers[uActiveCharacter]->uQuickSpell = v99;
+          stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
+          if ( uActiveCharacter )
+            pPlayer10->PlaySound(12, 0);
+          byte_506550 = 0;
+          goto _continue;
+        case 0x33:
+          if ( !uActiveCharacter )
+            goto _continue;
+          pPlayer3 = pPlayers[uActiveCharacter];
+          pNPCData4 = 0;
+          uAction = 0;
+          v101 = 0;
+          thisl = (int)&pPlayer3->pActiveSkills[12];
+          do
+          {
+            if ( *(short *)thisl )
+            {
+              if ( pPlayer3->pNumSpellBookPage == v101 )
+                uAction = (int)pNPCData4;
+              v102 = (int)pNPCData4;
+              pNPCData4 = (NPCData *)((char *)pNPCData4 + 1);
+              v217[v102] = v101;
+            }
+            thisl += 2;
+            ++v101;
+          }
+          while ( v101 < 9 );
+          if ( !pNPCData4 )
+            goto LABEL_662;
+          if ( GetAsyncKeyState(16) )
+          {
+            --uAction;
+            if ( uAction < 0 )
+              uAction = (int)((char *)pNPCData4 - 1);
+          }
+          else
+          {
+            ++uAction;
+            if ( uAction >= (signed int)pNPCData4 )
+              uAction = 0;
+          }
+          sub_41140B();
+          pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
+          goto LABEL_661;
+        case UIMSG_SaveGame|0x4:
+          if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
+            goto _continue;
+          sub_41140B();
+          pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
+LABEL_661:
+          pGUIWindow_CurrentMenu->_411621();
+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;
+        case UIMSG_LoadGame|0x4:
+          if ( pTurnEngine->field_4 != 3 )
+          {
+            if ( uActiveCharacter )
+            {
+              uNumSeconds = (unsigned int)pPlayers[uActiveCharacter];
+              if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402) )
+              {
+                if ( dword_50654C - 1 == uMessageParam )
+                {
+                  pGUIWindow_CurrentMenu->Release();
+                  pEventTimer->Resume();
+                  viewparams->bRedrawGameUI = v0;
+                  pCurrentScreen = 0;
+                  pIcons_LOD->_4114F2();
+                  v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734);
+                  if ( dword_50C9E8 < 40 )
+                  {
+                    dword_50C9EC[3 * dword_50C9E8] = 142;
+                    dword_50C9F0[3 * dword_50C9E8] = v103;
+                    *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = uActiveCharacter - 1;
+                    ++dword_50C9E8;
+                  }
+                }
+                else
+                {
+                  byte_506550 = 1;
+                  dword_50654C = uMessageParam + 1;
+                }
+              }
+            }
+          }
+          goto _continue;
+        case 0x8E:
+          if ( pTurnEngine->field_4 == 3 )
+            goto _continue;
+          v175 = 0;
+          v159 = 0;
+          v147 = 0;
+          goto LABEL_678;
+        case 0x92:
+          if ( pTurnEngine->field_4 != 3 )
+          {
+            v175 = 0;
+            v159 = v0;
+            v147 = 133;
+LABEL_678:
+            v80 = v199;
+            v79 = uMessageParam;
+LABEL_679:
+            _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
+          }
+          goto _continue;
+        case 0x69:
+          if ( pTurnEngine->field_4 == 3 )
+            goto _continue;
+          if ( bUnderwater == 1 )
+          {
+LABEL_682:
+            v96 = pGlobalTXT_LocalizationStrings[652];// "You can not do that while you are underwater!"
+LABEL_622:
+            ShowStatusBarString(v96, 2u);
+LABEL_623:
+            v165 = 0;
+            v151 = 0;
+            v144 = 0;
+            v139 = 0;
+            v135 = -1;
+            v132 = 0;
+            v130 = 0;
+            v127 = 27;
+_play_sound_and_continue:
+            pAudioPlayer->PlaySound((SoundID)v127, v130, v132, v135, v139, v144, v151, v165);
+          }
+          else
+          {
+            if ( pMessageQueue_50CBD0->uNumMessages )
+              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
+            {
+              if ( !pCurrentScreen )
+                goto LABEL_693;
+              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;
+                goto _continue;
+              }
+            }
+          }
+          goto _continue;
+        case 0x6A:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          if ( pCurrentScreen )
+            pGUIWindow_CurrentMenu->Release();
+          ++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);
+          viewparams->bRedrawGameUI = v0;
+          pEventTimer->Pause();
+          pAudioPlayer->StopChannels(-1, -1);
+          pCurrentScreen = 104;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)12, 5, 0);
+          papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
+          pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, v0, 0, 0x71u, 0, 0,
+                         pGlobalTXT_LocalizationStrings[79],// "Exit"
+                         (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0, v179);
+          goto _continue;
+        case 0x6B:
+          if ( pCurrentScreen )
+          {
+            pGUIWindow_CurrentMenu->Release();
+            pEventTimer->Resume();
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = v0;
+          }
+          stru_506E40.Release();
+          uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
+          pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
+          free((void *)uNumSeconds);
+          stru_506E40._40E55E("gamma.pcx", 0);
+          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+LABEL_453:
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+            goto _continue;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+          goto LABEL_770;
+        case UIMSG_C0:
+          dword_50651C = v0;
+          if ( pMouse->GetCursorPos(&v211)->y > 178 )
+            dword_50651C = -1;
+          goto _continue;
+        case UIMSG_A9:
+          GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
+LABEL_707:
+          dword_506548 = v0;
+          goto _continue;
+        case UIMSG_AA:
+          GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
+LABEL_709:
+          dword_506544 = v0;
+          goto _continue;
+        case 0x55:
+          bRingsShownInCharScreen ^= v0;
+          GUIButton::_41D0D8(pCharacterScreen_DetalizBtn);
+          GUIButton::_41D0D8(pCharacterScreen_DollBtn);
+          if ( bRingsShownInCharScreen )
+          {
+            v128 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureHeight : 26);
+            v125 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureWidth : 24);
+            v123 = 445;
+            v121 = 470;
+          }
+          else
+          {
+            v128 = 30;
+            v125 = 30;
+            v123 = 300;
+            v121 = 600;
+          }
+          pCharacterScreen_DetalizBtn = pGUIWindow_CurrentMenu->CreateButton(v121, v123, v125, v128, v0, 0, 0x55u, 0, 0,
+                         pGlobalTXT_LocalizationStrings[64],// "Detail Toggle"
+                         0);
+          pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, v0, 0, 0x85u, 0, 0, v1, 0);
+          goto LABEL_422;
+        case UIMSG_Quit|0x1:
+          OnPaperdollLeftClick();
+          goto _continue;
+        case UIMSG_CloseBook|0x2:
+          pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
+          sub_4196A0();
+          sub_419379();
+          pButton = pCharacterScreen_StatsBtn;
+          goto LABEL_716;
+        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;
+        case UIMSG_SkillUp:
+          pPlayer4 = pPlayers[uActiveCharacter];
+          v105 = (int)&pPlayer4->pActiveSkills[uMessageParam];
+          LOWORD(v2) = *(short *)v105;
+          uNumSeconds = v2;
+          if ( pPlayer4->uSkillPoints < (v2 & 0x3F) + 1 )
+          {
+            v87 = pGlobalTXT_LocalizationStrings[488];// "You don't have enough skill points!"
+          }
+          else
+          {
+            if ( (uNumSeconds & 0x3F) < 0x3C )
+            {
+              *(short *)v105 = uNumSeconds + 1;
+              pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F;
+              pPlayer4->PlaySound(14, 0);
+              v165 = 0;
+              v151 = 0;
+              v144 = 0;
+              v139 = 0;
+              v135 = -1;
+              v132 = 0;
+              v130 = 0;
+              v127 = 20001;
+              goto _play_sound_and_continue;
+            }
+            v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
+          }
+_draw_status_string_and_continue:
+          ShowStatusBarString(v87, 2u);
+          goto _continue;
+        case UIMSG_ChangeMusicVolume|0x4:
+          pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+          sub_419379();
+          sub_4196A0();
+          pButton = pCharacterScreen_InventoryBtn;
+LABEL_716:
+          v163 = 0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)91;
+          goto LABEL_731;
+        case UIMSG_A8:
+          pButton = pCharacterScreen_ExitBtn;
+          v163 = 0;
+          pButton2 = pCharacterScreen_ExitBtn;
+          pWindowType1 = (WindowType)97;
+          goto LABEL_731;
+        case UIMSG_CloseBook|0x4:
+          sub_419379();
+          sub_4196A0();
+          sub_419220();
+          pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102;
+          GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42),
+            (int)pCharacterScreen_AwardsBtn, 0);
+          sub_419100();
+          goto _continue;
+		case 71://0x47:
+          switch ( uMessageParam )
+          {
+            default:
+              goto _continue;
+            case 11:
+              goto LABEL_707;
+            case 10:
+              goto LABEL_709;
+            case 0:
+              pButton = pBtn_Book_1;
+              dword_506544 = v0;
+              break;
+            case 1:
+              pButton = pBtn_Book_2;
+              dword_506548 = v0;
+              break;
+            case 2:
+              dword_506540 = v0;
+              if ( dword_506364 )
+                goto _continue;
+              pButton = pBtn_Book_3;
+              break;
+            case 3:
+              dword_50653C = v0;
+              if ( dword_506364 )
+                goto _continue;
+              pButton = pBtn_Book_4;
+              break;
+            case 4:
+              dword_506538 = v0;
+              if ( dword_506364 )
+                goto _continue;
+              pButton = pBtn_Book_5;
+              break;
+            case 5:
+              dword_506534 = v0;
+              if ( dword_506364 )
+                goto _continue;
+              pButton = pBtn_Book_6;
+              break;
+            case 6:
+              pButton = pBtn_Autonotes_Misc;
+              dword_506530 = v0;
+              break;
+            case 7:
+              pButton = pBtn_Autonotes_Instructors;
+              dword_50652C = v0;
+              break;
+          }
+          v163 = v0;
+          pButton2 = pButton;
+          pWindowType1 = (WindowType)92;
+LABEL_731:
+          v8 = pButton->uY;
+          v9 = pButton->uX;
+          goto LABEL_732;
+        case UIMSG_SelectCharacter:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          GameUI_OnPlayerPortraitLeftClick(uMessageParam);
+          goto _continue;
+        case UIMSG_ShowStatus_Funds:
+          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;
+        case UIMSG_ShowStatus_DateTime:
+          pNPCData4 = (NPCData *)pParty->uCurrentHour;
+          if ( (signed int)pParty->uCurrentHour <= 12 )
+          {
+            if ( !pNPCData4 )
+              pNPCData4 = (NPCData *)12;
+          }
+          else
+          {
+            pNPCData4 = (NPCData *)((char *)pNPCData4 - 12);
+          }
+          if ( pParty->uCurrentHour < 0xC || (uNumSeconds = v0, pParty->uCurrentHour >= 0x18) )
+            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;
+        case UIMSG_ShowStatus_Food:
+          v173 = (char *)pParty->uNumFoodRations;
+          v157 = pGlobalTXT_LocalizationStrings[501];// You have %lu food"
+          goto _sprintex_2args_draw_status_and_continue;
+        case UIMSG_ShowStatus_Player:
+          pPlayer5 = pPlayers[uMessageParam];
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->uClass]);// "%s the %s"
+          strcat(pTmpBuf, ": ");
+          v107 = pPlayer5->GetMajorConditionIdx();
+          strcat(pTmpBuf, aCharacterConditionNames[v107]);
+          sub_41C0B8_set_status_string(pTmpBuf);
+          v108 = 8 * uMessageParam - 8;
+          LOBYTE(v108) = v108 | 4;
+          pMouse->uPointingObjectID = v108;
+          goto _continue;
+        case UIMSG_ShowStatus_ManaHP:
+          v109 = pGlobalTXT_LocalizationStrings[212];// "Spell Points"
+          v110 = pPlayers[uMessageParam];
+          v111 = v110->GetMaxMana();
+          v112 = v110->sMana;
+          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;
+        case 0xC:
+          if ( pCurrentScreen == 15 )
+            goto LABEL_762;
+          sub_420E01();
+          goto _continue;
+        case UIMSG_ChangeMusicVolume|0x8:
+LABEL_762:
+          sub_421EA6_OnInventoryLeftClick();
+          goto _continue;
+        case 0xA:
+          if ( !pRenderer->pRenderD3D )
+            goto LABEL_772;
+          v115 = pMessageQueue_50CBD0->uNumMessages;
+          if ( !pMessageQueue_50CBD0->uNumMessages )
+            goto LABEL_768;
+          if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
+          {
+            v115 = v0;
+            pMessageQueue_50CBD0->uNumMessages = v0;
+LABEL_769:
+            pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
+LABEL_770:
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+            goto LABEL_771;
+          }
+          v115 = 0;
+          pMessageQueue_50CBD0->uNumMessages = 0;
+LABEL_768:
+          if ( (signed int)v115 < 40 )
+            goto LABEL_769;
+          goto _continue;
+        case 0xE:
+LABEL_772:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          OnGameViewportClick();
+          goto _continue;
+        case 0xF:
+          if ( pRenderer->pRenderD3D )
+          {
+            LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
+          }
+          else
+          {
+            uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209);
+            pPoint3 = pMouse->GetCursorPos(&v204);
+            v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]];
+          }
+          v163 = 0;
+          pButton2 = (GUIButton *)(unsigned __int16)v116;
+          pWindowType1 = (WindowType)15;
+          goto LABEL_779;
+        case 0x54:
+          v163 = 0;
+          pButton2 = (GUIButton *)uMessageParam;
+          pWindowType1 = (WindowType)22;
+LABEL_779:
+          v8 = 0;
+          v9 = 0;
+LABEL_732:
+          v137 = 0;
+          v133 = 0;
+LABEL_733:
+          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          goto _continue;
+        case 0x194:
+          if ( pMessageQueue_50CBD0->uNumMessages )
+            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+          OnPressSpace();
+          goto _continue;
+        case UIMSG_ChangeSoundVolume|0x100:
+          if ( pCurrentScreen )
+            goto _continue;
+          pParty->uFlags |= 2u;
+          GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A14, 0);
+          uNumSeconds = 131072;
+          v118 = 2 * viewparams->uMinimapZoom;
+          ++viewparams->field_28;
+          viewparams->uMinimapZoom *= 2;
+          if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
+          {
+            if ( (signed int)v118 > 4096 )
+            {
+              viewparams->uMinimapZoom = 4096;
+              viewparams->field_28 = 12;
+            }
+            goto _continue;
+          }
+          v119 = 2048;
+          if ( (signed int)v118 <= 2048 )
+            goto LABEL_789;
+          viewparams->field_28 = 11;
+          goto LABEL_788;
+        case UIMSG_ChangeMusicVolume|0x100:
+          if ( pCurrentScreen )
+            goto _continue;
+          pParty->uFlags |= 2u;
+          GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A18, 0);
+          uNumSeconds = 32768;
+          v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
+          --viewparams->field_28;
+          viewparams->uMinimapZoom = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
+          if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+          {
+            v119 = 512;
+            if ( (signed int)v118 < 512 )
+            {
+              viewparams->field_28 = 9;
+LABEL_788:
+              v118 = v119;
+              viewparams->uMinimapZoom = v119;
+            }
+LABEL_789:
+            dword_576E2C = v118;
+            dword_576E28 = viewparams->field_28;
+          }
+          else
+          {
+            if ( (signed int)v118 < 256 )
+            {
+              viewparams->uMinimapZoom = 256;
+              viewparams->field_28 = 8;
+            }
+          }
+          goto _continue;
+      }
+    }
+  }
+  pMessageQueue_50CBD0->uNumMessages = dword_50C9E8;
+  memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
+  dword_50C9E8 = 0;
+  if ( dword_50C9DC )
+  {
+    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    {
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC;
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0;
+      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+      ++pMessageQueue_50CBD0->uNumMessages;
+    }
+    dword_50C9DC = 0;
+  }
+  else
+  {
+    if ( dword_50C9D0 > 0 )
+    {
+      dword_50C9D8 -= pEventTimer->uTimeElapsed;
+      if ( dword_50C9D8 <= 0 )
+      {
+        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        {
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+        }
+        dword_50C9D0 = 0;
+        dword_50C9D4 = 0;
+        dword_50C9D8 = 0;
+      }
+    }
+  }
+  pStru277->_427E01_cast_spell();
+}
+
+
+//----- (004356FF) --------------------------------------------------------
+void __cdecl back_to_game()
+{
+  dword_507BF0_is_there_popup_onscreen = 0;
+  dword_4E455C = 1;
+  dword_50CDCC = 0;
+  if ( pGUIWindow_ScrollWindow )
+    free_book_subwindow();
+  if ( !pCurrentScreen && !pGUIWindow_Settings )
+    pEventTimer->Resume();
+  viewparams->bRedrawGameUI = 1;
+}
+//----- (00435748) --------------------------------------------------------
+void __cdecl GUI_MainMenuMessageProc()
+{
+  //AudioPlayer *v0; // ebp@2
+  char *v1; // ebx@2
+  unsigned int v2; // ecx@18
+  void *v3; // edi@21
+  signed int v4; // eax@29
+  int v5; // ecx@29
+  enum PLAYER_SKILL_TYPE v6; // edi@37
+  GUIWindow *pWindow; // eax@56
+  unsigned int v8; // edx@56
+  Player *pCurrentPlayer; // edi@57
+  signed int v10; // eax@58
+  GUIButton *pButton; // eax@59
+  unsigned __int8 v12; // sf@62
+  signed int v13; // eax@64
+  unsigned int v14; // eax@66
+  int v15; // edi@70
+  char v16; // zf@73
+  int v17; // eax@73
+  int v19; // edi@116
+  char v20; // dl@116
+  unsigned int v21; // eax@116
+  Player *v22; // ecx@116
+  char *v23; // ebx@118
+  int v24; // eax@118
+  unsigned int v25; // eax@120
+  unsigned int v26; // ecx@127
+  unsigned int v27; // eax@129
+  unsigned __int8 v28; // of@129
+  SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36
+  signed int v30; // [sp-28h] [bp-38h]@36
+  unsigned int v31; // [sp-24h] [bp-34h]@36
+  signed int v32; // [sp-20h] [bp-30h]@36
+  signed int v34; // [sp-1Ch] [bp-2Ch]@36
+  int v36; // [sp-18h] [bp-28h]@36
+  unsigned int v38; // [sp-14h] [bp-24h]@36
+  int v39; // [sp-14h] [bp-24h]@56
+  signed int v40; // [sp-10h] [bp-20h]@15
+  signed int v41; // [sp-10h] [bp-20h]@29
+  int v42; // [sp-10h] [bp-20h]@36
+  int v43; // [sp-10h] [bp-20h]@56
+  int uNum; // [sp+4h] [bp-Ch]@3
+  UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
+  int pSex; // [sp+Ch] [bp-4h]@3
+  Player *pPlayer;
+
+  if ( pMessageQueue_50CBD0->uNumMessages )
+  {
+    //v0 = pAudioPlayer;
+    v1 = (char *)pParty->pPlayers;
+	pPlayer = pParty->pPlayers;
+    do
+    {
+      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &pSex);
+      switch (pUIMessageType)
+      {
+        case UIMSG_MainMenu_ShowPartyCreationWnd:
+        {
+          GUIWindow::Create(495, 172, 0, 0, WINDOW_5A, (int)pMainMenu_BtnNew, 0);
+          SetCurrentMenuID(MENU_NEWGAME);
+        }
+        continue;
+        case UIMSG_MainMenu_ShowLoadWindow:
+        {
+          GUIWindow::Create(495, 227, 0, 0, WINDOW_5A, (int)pMainMenu_BtnLoad, 0);
+          SetCurrentMenuID(MENU_SAVELOAD);
+        }
+        continue;
+        case UIMSG_ShowCredits:
+        {
+          GUIWindow::Create(495, 282, 0, 0, WINDOW_5A, (int)pMainMenu_BtnCredits, 0);
+          SetCurrentMenuID(MENU_CREDITS);
+        }
+        continue;
+        case UIMSG_ExitToWindows:
+        {
+          GUIWindow::Create(495, 337, 0, 0, WINDOW_5A, (int)pMainMenu_BtnExit, 0);
+          SetCurrentMenuID(MENU_FINISHED);
+        }
+        continue;
+        case UIMSG_LoadGame:
+        {
+          if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot])
+            continue;
+          SetCurrentMenuID(MENU_LOAD);
+        }
+        continue;
+      }
+      switch (pUIMessageType)
+      {
+        case UIMSG_A5:   // WINDOW_5A
+        {
+            //main menu save/load wnd   clicking on savegame lines
+          if (pGUIWindow_CurrentMenu->field_40 == 1)
+            pKeyActionMap->_459ED1(0);
+          if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != uNum + dword_6A0C9C )
+          {
+            //load clicked line
+              v26 = uNum + dword_6A0C9C;
+              if ( dword_6BE138 == uNum + dword_6A0C9C )
+              {
+                pMessageQueue_50CBD0->SendMessage(UIMSG_A4, 0, 0);
+                pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
+              }
+              uLoadGameUI_SelectedSlot = v26;
+              dword_6BE138 = v26;
+          }
+          else
+          {
+            //typing in the line
+              pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
+              strcpy((char *)pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
+              pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
+          }
+        }
+        continue;
+        case UIMSG_A4:
+        {
+          GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_5E, (int)ptr_69BD64, 0);
+        }
+        continue;
+      }
+      if ( (signed int)pUIMessageType > UIMSG_PlayerCreationRemoveDownSkill )
+      {
+        if ( pUIMessageType > UIMSG_A3 )
+        {
+          if ( pUIMessageType == UIMSG_A6 )
+          {
+            GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (WindowType)95, (int)ptr_69BD60, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
+          {
+            pPlayer = &pParty->pPlayers[uNum];
+            v12 = (char)((int)pPlayer->uFace - 1) < 0;
+            --pPlayer->uFace;
+            if ( v12 )
+              pPlayer->uFace = 19;
+            pPlayer->uVoiceID = pPlayer->uFace;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v25 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v25;
+            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0,
+              (enum WindowType)92, (int)pCreationUI_BtnPressLeft[v25], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0.0, 0);
+            v22 = pPlayer;
+            v22->PlaySound(102, 0);
+            v1 = (char *)pParty->pPlayers;
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_SelectFacePlayerForward )
+          {
+            pPlayer = &pParty->pPlayers[uNum];
+			v20 = (char)((int)pPlayer->uFace + 1) % 20;
+            pPlayer->uFace = v20;
+            pPlayer->uVoiceID = v20;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v21 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v21;
+            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (enum WindowType)92,
+			  (int)pCreationUI_BtnPressRight[v21], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            v22 = pPlayer;
+            v22->PlaySound(102, 0);
+            v1 = (char *)pParty->pPlayers;
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_AD )
+          {
+            GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
+          SetCurrentMenuID(MENU_LOAD);
+          continue;
+          }
+          if ( pUIMessageType != UIMSG_AE )
+            continue;
+          GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
+LABEL_114:
+          v40 = 10;
+LABEL_89:
+          v2 = v40;
+          SetCurrentMenuID((MENU_STATE)v2);
+          continue;
+        }
+        if ( pUIMessageType == UIMSG_A3 )
+        {
+          ++dword_6A0C9C;
+          if ( dword_6A0C9C >= uNum )
+            dword_6A0C9C = uNum - 1;
+          if ( dword_6A0C9C < 1 )
+            dword_6A0C9C = 0;
+          pWindow = pGUIWindow_CurrentMenu;
+          v43 = 0;
+          v39 = (int)ptr_69BD58;
+          v8 = pGUIWindow_CurrentMenu->uFrameY + 323;
+          goto LABEL_105;
+        }
+        if ( pUIMessageType == UIMSG_6B )
+        {
+          if ( pCurrentScreen )
+          {
+            pGUIWindow_CurrentMenu->Release();
+            pEventTimer->Resume();
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = 1;
+          }
+          GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+            continue;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseBook;
+          goto LABEL_93;
+        }
+        if ( pUIMessageType == UIMSG_CloseBook )
+        {
+          if ( ptr_507BDC )
+          {
+            sub_41426F();
+            continue;
+          }
+          if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x40) )
+            continue;
+          v15 = 1;
+          pVideoPlayer->bStopBeforeSchedule = 1;
+          viewparams->bRedrawGameUI = 1;
+          viewparams->field_48 = 1;
+          if ( !GetCurrentMenuID() || GetCurrentMenuID() == 6 || GetCurrentMenuID() == 7 )
+          {
+            v17 = pCurrentScreen;
+LABEL_83:
+            if ( v17 == 16 )
+              pVideoPlayer->FastForwardToFrame(pVideoPlayer->field_40);
+            if (GetCurrentMenuID() == MENU_7)
+            {
+              v40 = 6;
+              goto LABEL_89;
+            }
+            if (GetCurrentMenuID() == MENU_Credits)
+            {
+              v40 = 11;
+              goto LABEL_89;
+            }
+            if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+            {
+              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)5;
+LABEL_93:
+              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+              ++pMessageQueue_50CBD0->uNumMessages;
+              continue;
+            }
+            continue;
+          }
+          v16 = GetCurrentMenuID() == 8;
+          v17 = pCurrentScreen;
+          if ( v16 && !pCurrentScreen )
+            goto LABEL_83;
+          if ( pCurrentScreen == 12 )
+          {
+            pIcons_LOD->_4114F2();
+            //crt_deconstruct_ptr_6A0118();
+            pTexture_PCX.Release();
+            pTexture_PCX.Load("title.pcx", 0);
+            SetCurrentMenuID(MENU_MAIN);
+            v15 = 1;
+LABEL_81:
+            pGUIWindow_CurrentMenu->Release();
+            pGUIWindow2->Release();
+            pGUIWindow2 = 0;
+            pEventTimer->Resume();
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = v15;
+            continue;
+          }
+          if ( pCurrentScreen == 16 )
+          {
+            pVideoPlayer->Unload();
+          }
+          else
+          {
+            if ( pCurrentScreen != 27 )
+              goto LABEL_81;
+            //VideoPlayer::dtor();
+          }
+        }
+        else
+        {
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectQuality )
+          {
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = uNum;
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )
+          {
+            pCurrentPlayer = &pPlayer[uNum];
+            pSex = pCurrentPlayer->GetSexByVoice();
+            do
+            {
+              v12 = (/*(*/pCurrentPlayer->uVoiceID-- - 1/*) & 0x80000000u */) != 0;
+              if ( v12 )
+                pCurrentPlayer->uVoiceID = 19;
+              v13 = pCurrentPlayer->GetSexByVoice();
+            }
+            while ( v13 != pSex );
+            pButton = pCreationUI_BtnPressLeft2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            pCurrentPlayer->PlaySound(102, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
+          {
+            pCurrentPlayer = &pPlayer[uNum];
+            pSex = pCurrentPlayer->GetSexByVoice();
+            do
+            {
+              pCurrentPlayer->uVoiceID = (signed int)(pCurrentPlayer->uVoiceID + 1) % 20;
+              v10 = pCurrentPlayer->GetSexByVoice();
+            }
+            while ( v10 != pSex );
+            pButton = pCreationUI_BtnPressRight2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            pCurrentPlayer->PlaySound(102, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_A2 )
+          {
+            --dword_6A0C9C;
+            if ( dword_6A0C9C < 0 )
+              dword_6A0C9C = 0;
+            pWindow = pGUIWindow_CurrentMenu;
+            v43 = 0;
+            v39 = (int)ptr_69BD5C;
+            v8 = pGUIWindow_CurrentMenu->uFrameY + 197;
+LABEL_105:
+            GUIWindow::Create(pWindow->uFrameX + 215, v8, 0, 0, (WindowType)90, v39, v43);
+            continue;
+          }
+        }
+      }
+      else
+      {
+        if ( pUIMessageType == UIMSG_PlayerCreationRemoveDownSkill )
+        {
+          uPlayerCreationUI_SelectedCharacter = uNum;
+          v41 = 3;
+          v1 = (char *)pParty->pPlayers;
+          v5 = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7
+             + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+          pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
+          pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
+                                             + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
+          continue;
+        }
+        if ( (signed int)pUIMessageType > UIMSG_3C )
+        {
+          if ( pUIMessageType == UIMSG_PlayerCreationClickPlus )
+          {
+            GUIWindow::Create(613, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
+            (&pPlayer[uPlayerCreationUI_SelectedCharacter])->IncreaseAttribute(
+              (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
+            pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationClickMinus )
+          {
+            GUIWindow::Create(523, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
+            (&pPlayer[uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
+              (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
+            pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectActiveSkill )
+          {
+            auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
+            v6 = _t->GetSkillIdxByOrder(uNum + 4);
+            if ( _t->GetSkillIdxByOrder(3) == 37 )
+              pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
+            pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
+          {
+            (&pPlayer[uPlayerCreationUI_SelectedCharacter])->Reset(uNum);
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
+          {
+            GUIWindow::Create(580, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
+            if ( PlayerCreation_ComputeAttributeBonus() || !sub_4908DE() )
+              GameUI_StatusBar_TimedStringTimeLeft = GetTickCount() + 4000;
+            else
+              uGameState = 6;
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_PlayerCreationClickReset ) 
+          {
+            GUIWindow::Create(527, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
+            pParty->Reset();
+          }
+          else
+          {
+            if ( pUIMessageType == UIMSG_PlayerCreationRemoveUpSkill )
+            {
+              uPlayerCreationUI_SelectedCharacter = uNum;
+              v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+              pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+              v41 = 2;
+              v5 = v4 % 7 + pSex + 7 * uNum;
+              pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
+              pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
+                                             + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
+              continue;
+            }
+          }
+        }
+        else
+        {
+          switch ( pUIMessageType )
+          {
+            case 60:
+              pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
+              v3 = (void *)uNum;
+              uPlayerCreationUI_SelectedCharacter = uNum;
+              pKeyActionMap->_459E5A(0, 15, pGUIWindow_CurrentMenu);
+              pGUIWindow_CurrentMenu->ptr_1C = v3;
+              break;
+            case 5:
+              uGameState = 1;
+              break;
+            case 17:
+              pMouse->SetCursorBitmap("MICON2");
+              break;
+            default:
+              if ( pUIMessageType == 58 )
+                goto LABEL_114;
+              break;
+          }
+        }
+      }
+    }
+    while ( pMessageQueue_50CBD0->uNumMessages );
+  }
+}
+
+//----- (00436427) --------------------------------------------------------
+double __cdecl get_shading_dist_mist()
+{
+  double result; // st7@2
+
+  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    result = (double)pOutdoorCamera->shading_dist_mist;
+  else
+    result = 16192.0;
+  return result;
+}
+
+//----- (0043643E) --------------------------------------------------------
+double __cdecl GetPickDepth()
+{
+  double result; // st7@2
+
+  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    result = (double)pOutdoorCamera->uPickDepth;
+  else
+    result = 16192.0;
+  return result;
+}
+
+//----- (0043648F) --------------------------------------------------------
+void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
+{
+  _this->flt_2C = 0.0;
+
+  _this->vWorldPosition.x = a2->x;
+  _this->vWorldPosition.y = a2->y;
+  _this->vWorldPosition.z = a2->z;
+}
+
+//----- (004369DB) --------------------------------------------------------
+void Vec3_float_::Normalize()
+{
+  Vec3_float_ *v1; // esi@1
+  double v2; // st7@1
+
+  auto a1 = this;
+  v1 = a1;
+  v2 = 1.0 / sqrt(a1->x * a1->x + a1->y * a1->y + a1->z * a1->z);
+  v1->x = v2 * v1->x;
+  v1->y = v2 * v1->y;
+  v1->z = v2 * v1->z;
+}
+
+
+
+
+
+
+
+//----- (004382BC) --------------------------------------------------------
+__int16 __thiscall sub_4382BC(int _this)
+{
+  LOG_DECOMPILATION_WARNING();
+  return 0;
+  /*__int16 result; // ax@4
+  __int16 v14; // sp@11
+  int v15; // [sp-4h] [bp-Ch]@0
+  signed __int16 v16; // [sp+4h] [bp-4h]@1
+  __int16 v17; // [sp+4h] [bp-4h]@8
+  __int16 v18; // [sp+4h] [bp-4h]@11
+
+  v16 = 1;
+  __asm { pushf }
+  if ( v15 == (v15 ^ 0x200000) )
+    v16 = 0;
+  if ( v16 )
+  {
+    result = sub_43847A();
+  }
+  else
+  {
+    //UNDEF(_ZF);
+    //UNDEF(_SF);
+    //UNDEF(_OF);
+    _CF = 0;
+    if ( !_ZF )
+      _CF = 1;
+    __asm { pushfw }
+    bProcessorIsNotIntel = (BYTE2(v15) & 1 ^ 1) & 1;
+    _CF = 0;
+    _OF = 0;
+    _ZF = 0;
+    _SF = 1;
+    __asm { pushfw }
+    v17 = 2;
+    if ( (HIWORD(v15) | 0xF000) & 0xF000 )
+      v17 = -1;
+    __asm { popfw }
+    result = v17;
+    if ( v17 != 2 )
+    {
+      _CF = 0;
+      _OF = 0;
+      _ZF = v14 == 0;
+      _SF = v14 < 0;
+      __asm { pushf }
+      v18 = 3;
+      if ( v15 != (v15 ^ 0x40000) )
+        v18 = -1;
+      __asm { popf }
+      result = v18;
+      if ( v18 != 3 )
+        result = 4;
+    }
+  }
+  if ( bProcessorIsNotIntel )
+    HIBYTE(result) |= 0x80u;
+  return result;*/
+}
+
+//----- (004383ED) --------------------------------------------------------
+int __cdecl sub_4383ED()
+{
+  LOG_DECOMPILATION_WARNING();
+  return 0;
+  /*signed int v9; // eax@4
+  int v16; // [sp-4h] [bp-38h]@0
+  int v17[3]; // [sp+Ch] [bp-28h]@1
+  char v18; // [sp+18h] [bp-1Ch]@1
+  char v19; // [sp+19h] [bp-1Bh]@1
+  int v20[4]; // [sp+1Ch] [bp-18h]@1
+  int v21; // [sp+2Ch] [bp-8h]@1
+  int v22; // [sp+30h] [bp-4h]@1
+
+  v17[0] = *(int *)"------------";
+  v17[1] = *(int *)"--------";
+  v17[2] = *(int *)"----";
+  v18 = asc_4E4938[12];
+  v19 = 0;
+  v22 = 0;
+  v20[0] = *(int *)"GenuineIntel";
+  v20[1] = *(int *)"ineIntel";
+  v20[2] = *(int *)"ntel";
+  LOBYTE(v20[3]) = aGenuineintel[12];
+  _CF = 0;
+  _OF = 0;
+  _ZF = 0;
+  _SF = 0;
+  v21 = 1;
+  __asm { pushf }
+  if ( v16 == (v16 ^ 0x200000) )
+    v21 = 0;
+  if ( (short)v21 )
+  {
+    _EAX = 0;
+    __asm { cpuid }
+    v17[0] = _EBX;
+    v17[1] = _EDX;
+    v17[2] = _ECX;
+    v9 = 0;
+    do
+    {
+      if ( *((char *)v17 + v9) != *((char *)v20 + v9) )
+        bProcessorIsNotIntel = 1;
+      ++v9;
+    }
+    while ( v9 < 12 );
+    if ( v9 >= 1 )
+    {
+      _EAX = 1;
+      __asm { cpuid }
+      v22 = _EDX;
+    }
+  }
+  return v22;*/
+}
+
+//----- (0043847A) --------------------------------------------------------
+__int16 __cdecl sub_43847A()
+{
+  __debugbreak();
+  return 0;
+  /*signed int v5; // eax@1
+  char v12[12]; // [sp+Ch] [bp-28h]@1
+  char v13; // [sp+18h] [bp-1Ch]@1
+  char v14; // [sp+19h] [bp-1Bh]@1
+  int v15[4]; // [sp+1Ch] [bp-18h]@1
+  int v16; // [sp+2Eh] [bp-6h]@1
+  char v17; // [sp+32h] [bp-2h]@6
+  char v18; // [sp+33h] [bp-1h]@1
+
+  *(int *)v12 = *(int *)"------------";
+  *(int *)&v12[4] = *(int *)"--------";
+  *(int *)&v12[8] = *(int *)"----";
+  v13 = asc_4E4938[12];
+  v14 = 0;
+  v18 = 0;
+  v15[0] = *(int *)"GenuineIntel";
+  v15[1] = *(int *)"ineIntel";
+  v15[2] = *(int *)"ntel";
+  v16 = 65535;
+  LOBYTE(v15[3]) = aGenuineintel[12];
+  _EAX = 0;
+  __asm { cpuid }
+  *(int *)v12 = _EBX;
+  *(int *)&v12[4] = _EDX;
+  *(int *)&v12[8] = _ECX;
+  v5 = 0;
+  do
+  {
+    if ( v12[v5] != *((char *)v15 + v5) )
+      bProcessorIsNotIntel = 1;
+    ++v5;
+  }
+  while ( v5 < 12 );
+  if ( v5 >= 1 )
+  {
+    _EAX = 1;
+    __asm { cpuid }
+    v18 = _EAX & 0xF;
+    LOBYTE(_EAX) = (unsigned __int8)(_EAX & 0xF0) >> 4;
+    v17 = _EAX;
+    LOWORD(v16) = ((_EAX & 0xF00u) >> 8) & 0xF;
+  }
+  return v16;*/
+}
+
+
+
+//----- (004385B5) --------------------------------------------------------
+void stru11::CheckCPU()
+{
+  LOG_DECOMPILATION_WARNING();
+  /*
+  int v5; // [sp-4h] [bp-10h]@0
+  signed int v6; // [sp+4h] [bp-8h]@1
+  signed int v7; // [sp+8h] [bp-4h]@1
+
+  _CF = 0;
+  _OF = 0;
+  _ZF = 1;
+  _SF = 0;
+  v7 = 0;
+  __asm { pushf }
+  v6 = 3;
+  if ( v5 != (v5 ^ 0x40000) )
+  {
+    __asm { popf }
+    v6 = 4;
+    __asm { pushf }
+    if ( v5 != (v5 ^ 0x200000) )
+    {
+      v7 = 1;
+      v6 = 0;
+    }
+  }
+  if ( v6 == 3 )
+  {
+    this->field_AC = 1;
+  }
+  else
+  {
+    if ( v6 == 4 )
+    {
+      this->field_AC = 2;
+    }
+    else
+    {
+      if ( v7 )
+      {
+        this->field_AC = 2;
+        RunCPUID();
+      }
+      else
+      {
+        this->field_AC = 0;
+      }
+    }
+  }*/
+}
+
+//----- (00438659) --------------------------------------------------------
+void stru11::RunCPUID()
+{
+  __debugbreak();
+  /*stru11 *v6; // esi@1
+  unsigned int uNumOps; // edi@1
+  int uNumExtOps; // edi@16
+  char pCyrixString[16]; // [sp+Ch] [bp-60h]@1
+  char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1
+  char pAMDString[16]; // [sp+2Ch] [bp-40h]@1
+  char pIntelString[16]; // [sp+3Ch] [bp-30h]@1
+  char pCPUString[16]; // [sp+4Ch] [bp-20h]@1
+  stru11 *thisa; // [sp+5Ch] [bp-10h]@1
+  char *v35; // [sp+60h] [bp-Ch]@1
+  int v36; // [sp+64h] [bp-8h]@1
+  int v37; // [sp+68h] [bp-4h]@1
+
+  thisa = this;
+  *(int *)pIntelString = *(int *)"GenuineIntel";
+  *(int *)&pIntelString[4] = *(int *)"ineIntel";
+  *(int *)&pIntelString[8] = *(int *)"ntel";
+  pIntelString[12] = aGenuineintel[12];
+  *(int *)pAMDString = *(int *)"AuthenticAMD";
+  *(int *)&pAMDString[4] = *(int *)"enticAMD";
+  *(int *)&pAMDString[8] = *(int *)"cAMD";
+  pAMDString[12] = aAuthenticamd[12];
+  *(int *)pCyrixString = *(int *)"CyrixInstead";
+  *(int *)&pCyrixString[4] = *(int *)"xInstead";
+  *(int *)&pCyrixString[8] = *(int *)"tead";
+  pCyrixString[12] = aCyrixinstead[12];
+  *(int *)pCentaurString = *(int *)"CentaurHauls";
+  *(int *)&pCentaurString[4] = *(int *)"aurHauls";
+  *(int *)&pCentaurString[8] = *(int *)"auls";
+  v37 = 0;
+  v36 = 0;
+  pCentaurString[12] = aCentaurhauls[12];
+  v35 = pCPUString;
+  pCPUString[12] = 0;
+  _EAX = 0;
+  __asm { cpuid }
+  v37 = _EAX;
+  *(int *)pCPUString = _EBX;
+  *(int *)&pCPUString[4] = _EDX;
+  *(int *)&pCPUString[8] = _ECX;
+  v6 = thisa;
+  uNumOps = _EAX;
+  thisa->cpuid_00000000_ebx_vendorstr1 = _EBX;
+  v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4];
+  v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8];
+  v6->cpuid_00000000_eax_numops = _EAX;
+  strcpy(v6->pCPUString, pCPUString);
+  if ( strcmp(pIntelString, pCPUString) )
+  {
+    if ( strcmp(pAMDString, pCPUString) )
+    {
+      if ( strcmp(pCyrixString, pCPUString) )
+      {
+        if ( strcmp(pCentaurString, pCPUString) )
+          v6->uProcessorManufacturer = 0;
+        else
+          v6->uProcessorManufacturer = 4;
+      }
+      else
+      {
+        v6->uProcessorManufacturer = 3;
+      }
+    }
+    else
+    {
+      v6->uProcessorManufacturer = 2;
+    }
+  }
+  else
+  {
+    v6->uProcessorManufacturer = 1;
+  }
+  if ( uNumOps >= 1 )
+    RunCPUID_op1();
+  if ( uNumOps >= 2 )
+    RunCPUID_op2();
+  _EAX = 0x80000000u;
+  __asm { cpuid }
+  if ( !(_EAX & 0x80000000) )
+    _EAX = 0x80000000u;
+  v36 = _EAX;
+  v6->cpuid_80000000_edx = _EAX;
+  uNumExtOps = _EAX ^ 0x80000000;
+  if ( (_EAX ^ 0x80000000u) >= 1 )
+  {
+    _EAX = 0x80000001u;
+    __asm { cpuid }
+    thisa = (stru11 *)_EAX;
+    v35 = (char *)_EDX;
+    v6->cpuid_80000001_eax = _EAX;
+    v6->cpuid_80000001_edx = (int)v35;
+  }
+  if ( (unsigned int)uNumExtOps >= 4 )
+    RunCPUID_ext2_3_4();
+  if ( (unsigned int)uNumExtOps >= 5 )
+  {
+    _EAX = 0x80000005u;
+    __asm { cpuid }
+    thisa = (stru11 *)_EBX;
+    v35 = (char *)_ECX;
+    v36 = _EDX;
+    v6->cpuid_80000005_ebx = _EBX;
+    v6->cpuid_80000005_ecx = (int)v35;
+    v6->cpuid_80000005_edx = v36;
+  }
+  if ( (unsigned int)uNumExtOps >= 6 )
+  {
+    _EAX = 0x80000006u;
+    __asm { cpuid }
+    v6->cpuid_80000006_ecx = _ECX;
+  }*/
+}
+
+//----- (00438821) --------------------------------------------------------
+void stru11::RunCPUID_op1()
+{
+  __debugbreak();
+  /*stru11 *v1; // esi@1
+  unsigned int v7; // ecx@1
+  int v8; // eax@3
+  int v9; // eax@10
+  signed int v10; // eax@11
+  int v11; // ecx@11
+  int v12; // eax@15
+  signed int v13; // eax@19
+  int v14; // ecx@19
+  signed int v15; // eax@25
+  int v16; // ecx@25
+  signed int v17; // eax@34
+  int v18; // ecx@34
+
+  v1 = this;
+  _EAX = 1;
+  __asm { cpuid }
+  v7 = _EAX;
+  v1->cpuid_00000001_edx = _EDX;
+  v1->cpuid_00000001_eax = _EAX;
+  if ( (_EAX & 0x3000) == 8192 )
+  {
+    LOBYTE(v1->cpuid_80000002_registers2[0]) = 1;
+    v7 = 0;
+  }
+  v8 = (v7 >> 8) & 0xF;
+  switch ( v8 )
+  {
+    case 4:
+      v1->field_AC = 2;
+      break;
+    case 5:
+      v1->field_AC = 15;
+      break;
+    case 6:
+      v1->field_AC = 36;
+      break;
+    default:
+      v1->field_AC = 49;
+      break;
+  }
+  v9 = v1->uProcessorManufacturer;
+  if ( v9 == 1 )
+  {
+    v10 = 0;
+    v11 = v7 & 0x3FF0;
+    while ( v11 != dword_4E4948[2 * v10] )
+    {
+      ++v10;
+      if ( v10 >= 17 )
+        return;
+    }
+    v12 = dword_4E494C[2 * v10];
+    goto LABEL_39;
+  }
+  if ( v9 == 2 )
+  {
+    if ( (v7 & 0xF00) == dword_4E49D0[0] )
+    {
+      v12 = dword_4E49D4[0];
+    }
+    else
+    {
+      v13 = 1;
+      v14 = v7 & 0x3FF0;
+      while ( v14 != dword_4E49D0[2 * v13] )
+      {
+        ++v13;
+        if ( v13 >= 9 )
+          return;
+      }
+      v12 = dword_4E49D4[2 * v13];
+    }
+    goto LABEL_39;
+  }
+  if ( v9 != 3 )
+  {
+    if ( v9 != 4 )
+      return;
+    v17 = 0;
+    v18 = v7 & 0x3FF0;
+    while ( v18 != dword_4E4A40[2 * v17] )
+    {
+      ++v17;
+      if ( v17 >= 2 )
+        return;
+    }
+    v12 = dword_4E4A44[2 * v17];
+    goto LABEL_39;
+  }
+  v15 = 1;
+  v16 = v7 & 0x3FF0;
+  while ( v16 != dword_4E4A18[2 * v15] )
+  {
+    ++v15;
+    if ( v15 >= 5 )
+      goto LABEL_30;
+  }
+  v1->field_AC = dword_4E4A1C[2 * v15];
+LABEL_30:
+  v12 = 24;
+  if ( v1->field_AC == 24 )
+  {
+    if ( _EDX != 1 )
+      v12 = (((_EDX != 261) - 1) & 0xA) + 15;
+LABEL_39:
+    v1->field_AC = v12;
+  }*/
+}
+
+//----- (00438992) --------------------------------------------------------
+void stru11::RunCPUID_op2()
+{
+  __debugbreak();
+  /*
+  stru11 *v1; // edi@1
+  int v7; // eax@1
+  signed int v8; // ecx@2
+  unsigned __int8 v9; // al@3
+  signed int v10; // ecx@14
+  unsigned __int8 v11; // al@15
+  int v12; // [sp+Ch] [bp-14h]@1
+  int v13; // [sp+10h] [bp-10h]@1
+  int v14; // [sp+14h] [bp-Ch]@1
+  int v15; // [sp+18h] [bp-8h]@1
+  int *v16; // [sp+1Ch] [bp-4h]@1
+
+  v1 = this;
+  v16 = &v12;
+  _EAX = 2;
+  __asm { cpuid }
+  v12 = _EAX;
+  v13 = _EBX;
+  v14 = _ECX;
+  v15 = _EDX;
+  v1->cpuid_00000002_eax = _EAX;
+  v1->cpuid_00000002_ebx = v13;
+  v1->cpuid_00000002_ecx = v14;
+  v1->cpuid_00000002_edx = v15;
+  v7 = v1->field_AC;
+  if ( v7 == 40 )
+  {
+    v8 = 0;
+    while ( 1 )
+    {
+      v9 = *((char *)&v12 + v8);
+      if ( v9 == 64 )
+      {
+        v1->field_AC = 43;
+        return;
+      }
+      if ( v9 >= 0x41u && v9 <= 0x43u )
+      {
+        v1->field_AC = 41;
+        return;
+      }
+      if ( v9 >= 0x44u && v9 <= 0x45u )
+        break;
+      ++v8;
+      if ( v8 >= 16 )
+        return;
+    }
+    v1->field_AC = 42;
+  }
+  else
+  {
+    if ( v7 == 45 )
+    {
+      v10 = 0;
+      while ( 1 )
+      {
+        v11 = *((char *)&v12 + v10);
+        if ( v11 >= 0x40u && v11 <= 0x43u )
+        {
+          v1->field_AC = 46;
+          return;
+        }
+        if ( v11 >= 0x44u && v11 <= 0x45u )
+          break;
+        ++v10;
+        if ( v10 >= 16 )
+          return;
+      }
+      v1->field_AC = 47;
+    }
+  }*/
+}
+
+//----- (00438A67) --------------------------------------------------------
+void stru11::RunCPUID_ext2_3_4()
+{
+  __debugbreak();
+  /*stru11 *v1; // edi@1
+  stru11 *v17; // eax@1
+  int v18[3][4]; // [sp+Ch] [bp-38h]@1
+  stru11 *v19; // [sp+3Ch] [bp-8h]@1
+
+  v1 = this;
+  v19 = this;
+  _EAX = 0x80000002u;
+  __asm { cpuid }
+  v18[0][0] = _EAX;
+  *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX);
+  v18[0][3] = _EDX;
+  _EAX = 0x80000003u;
+  __asm { cpuid }
+  v18[1][0] = _EAX;
+  *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX);
+  v18[1][3] = _EDX;
+  _EAX = 0x80000004u;
+  __asm { cpuid }
+  v18[2][0] = _EAX;
+  *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX);
+  v18[2][3] = _EDX;
+  v17 = v19;
+  memcpy(v1->cpuid_80000002_registers, v18, 0x30u);
+  memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/
+}
+
+
+
+//----- (00438BDF) --------------------------------------------------------
+bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype)
+{
+  unsigned __int8 v2; // zf@15
+  char v3; // sf@15
+  unsigned __int8 v4; // of@15
+  bool result; // eax@33
+
+  switch ( eSupertype )
+  {
+    case MONSTER_SUPERTYPE_UNDEAD:
+      if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3
+        || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3
+        || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3
+        || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3
+        || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3
+        || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 )
+        goto ret_true;
+      if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3);
+      v2 = uMonsterInfoID == MONSTER_GHOUL_3;
+      v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_KREEGAN:
+      if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3);
+      v2 = uMonsterInfoID == MONSTER_DEVIL_3;
+      v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_ELF:
+      if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1
+        && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3
+        || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 )
+        goto ret_true;
+      if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3);
+      v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3;
+      v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_DRAGON:
+      if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3);
+      v2 = uMonsterInfoID == MONSTER_DRAGON_3;
+      v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_WATER_ELEMENTAL:
+      if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3);
+      v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3;
+      v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_TREANT:
+      if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3);
+      v2 = uMonsterInfoID == MONSTER_TREANT_3;
+      v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0;
+      goto false_if_outside;
+    case MONSTER_SUPERTYPE_TITAN:
+      if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 )
+        goto ret_false;
+      v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3);
+      v2 = uMonsterInfoID == MONSTER_TITAN_3;
+      v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0;
+false_if_outside:
+      if ( !((unsigned __int8)(v3 ^ v4) | v2) )
+        goto ret_false;
+ret_true:
+      result = 1;
+      break;
+    default:
+ret_false:
+      result = 0;
+      break;
+  }
+  return result;
+}
+
+
+//----- (00438F8F) --------------------------------------------------------
+void __cdecl _438F8F_area_of_effect__damage_evaluate()
+{
+  int v0; // edx@1
+  char *v1; // esi@2
+  int v2; // ecx@3
+  signed int v3; // eax@3
+  LayingItem *v4; // eax@4
+  signed int v5; // eax@4
+  signed int v6; // eax@6
+  unsigned int v7; // edi@6
+  int v8; // eax@6
+  __int16 v9; // bx@8
+  int v10; // edi@8
+  Vec3_int_ v11; // ST04_12@9
+  int v12; // ST0C_4@10
+  Actor *v13; // edi@11
+  int v14; // edx@15
+  int v15; // edx@15
+  int v16; // ebx@15
+  signed int v17; // eax@15
+  int v18; // edi@15
+  int v19; // edi@15
+  Vec3_int_ v20; // ST04_12@16
+  Vec3_int_ *v21; // eax@17
+  unsigned int v22; // edx@17
+  int v23; // edx@18
+  int v24; // eax@18
+  Vec3_int_ v25; // ST04_12@19
+  unsigned int v26; // ebx@20
+  char *v27; // edi@20
+  char *v28; // edi@27
+  int v29; // ebx@29
+  int v30; // eax@29
+  int v31; // edx@29
+  int v32; // eax@29
+  int v33; // ST24_4@29
+  Vec3_int_ v34; // ST04_12@30
+  Vec3_int_ *v35; // eax@31
+  LayingItem *v36; // [sp+0h] [bp-28h]@0
+  signed int v37; // [sp+4h] [bp-24h]@5
+  int v38; // [sp+4h] [bp-24h]@15
+  signed int v39; // [sp+8h] [bp-20h]@3
+  int v40; // [sp+8h] [bp-20h]@15
+  int v41; // [sp+Ch] [bp-1Ch]@5
+  int v42; // [sp+Ch] [bp-1Ch]@15
+  int v43; // [sp+10h] [bp-18h]@1
+  int v44; // [sp+14h] [bp-14h]@15
+  unsigned int uActorID; // [sp+18h] [bp-10h]@6
+  Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2
+  int a1; // [sp+20h] [bp-8h]@8
+  int v48; // [sp+24h] [bp-4h]@8
+
+  v0 = 0;
+  v43 = 0;
+  if ( stru_50FE08.count > 0 )
+  {
+    pVelocity = &stru_50FE08.vec_4B4;
+    v1 = (char *)stru_50FE08.pZs;
+    do
+    {
+      v2 = *((short *)v1 - 300) & 7;
+      v3 = (signed int)*((short *)v1 - 300) >> 3;
+      v39 = (signed int)*((short *)v1 - 300) >> 3;
+      if ( v2 == 2 )
+      {
+        v4 = &pLayingItems[v3];
+        v36 = v4;
+        v5 = v4->field_58;
+        v2 = v5 & 7;
+        v3 = v5 >> 3;
+      }
+      v41 = v2;
+      v37 = v3;
+      if ( stru_50FE08.field_3EC[v0] & 1 )
+      {
+        v6 = dword_4F6E08[v3];
+        v7 = v6 >> 3;
+        v8 = (v6 & 7) - 3;
+        uActorID = v7;
+        if ( v8 )
+        {
+          if ( v8 == 1 )
+          {
+            v9 = *(short *)v1;
+            v10 = pParty->vPosition.y - *((short *)v1 - 100);
+            a1 = pParty->vPosition.x - *((short *)v1 - 200);
+            v48 = v10;
+            if ( a1 * a1
+               + v10 * v10
+               + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9))
+               * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+            {
+              v11.z = *(short *)v1;
+              v11.y = *((short *)v1 - 100);
+              v11.x = *((short *)v1 - 200);
+              if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v11) )
+              {
+                v12 = stru_50C198.which_player_would_attack(&pActors[v39]);
+                DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
+              }
+            }
+          }
+        }
+        else
+        {
+          v13 = &pActors[v7];
+          if ( SHIDWORD(v13->pActorBuffs[6].uExpireTime) > 0
+            || SHIDWORD(v13->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(v13->pActorBuffs[6].uExpireTime)
+            || v13->CanAct() )
+          {
+            v14 = v13->vPosition.y;
+            v40 = v13->vPosition.x;
+            v38 = v14;
+            v15 = v14 - *((short *)v1 - 100);
+            v16 = *(short *)v1;
+            v42 = v13->vPosition.z;
+            a1 = v40 - *((short *)v1 - 200);
+            v17 = v13->uActorHeight;
+            v18 = v13->uActorRadius;
+            v44 = v42;
+            v19 = *((short *)v1 + 100) + v18;
+            v48 = v15;
+            if ( a1 * a1 + v15 * v15 + (v42 + (v17 >> 1) - v16) * (v42 + (v17 >> 1) - v16) < (unsigned int)(v19 * v19) )
+            {
+              v20.z = *(short *)v1;
+              v20.y = *((short *)v1 - 100);
+              v20.x = *((short *)v1 - 200);
+              if ( sub_407A1C(v40, v38, v42 + 50, v20) )
+              {
+                Vec3_int_::Normalize(&a1, &v48, &v44);
+                v21 = pVelocity;
+                v22 = uActorID;
+                pVelocity->x = a1;
+                v21->y = v48;
+                v21->z = v44;
+                sub_43B1B0(*((short *)v1 - 300), v22, v21, stru_50FE08.field_450[v43]);
+              }
+            }
+          }
+        }
+      }
+      else
+      {
+        v23 = pParty->vPosition.y - *((short *)v1 - 100);
+        v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
+        a1 = pParty->vPosition.x - *((short *)v1 - 200);
+        v48 = v23;
+        if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+        {
+          v25.z = *(short *)v1;
+          v25.y = *((short *)v1 - 100);
+          v25.x = *((short *)v1 - 200);
+          if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v25) )
+          {
+            v26 = 0;
+            v27 = (char *)&pParty->pPlayers[0].pConditions[15];
+            do
+            {
+              if ( !(*((int *)v27 - 1) | *((int *)v27 - 2)) && !*(_QWORD *)v27 && !*((_QWORD *)v27 + 1) )
+                DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v26);
+              v27 += 6972;
+              ++v26;
+            }
+            while ( (signed int)v27 < (signed int)&pParty->pHirelings[1].evtb );
+          }
+        }
+        uActorID = 0;
+        if ( (signed int)uNumActors > 0 )
+        {
+          v28 = (char *)&pActors[0].vPosition.z;
+          do
+          {
+            if ( ((Actor *)(v28 - 146))->CanAct() )
+            {
+              v29 = *(short *)v1;
+              v30 = *((short *)v28 - 1) - *((short *)v1 - 100);
+              a1 = *((short *)v28 - 2) - *((short *)v1 - 200);
+              v31 = *(short *)v28;
+              v48 = v30;
+              v44 = v31;
+              v32 = ((signed int)*((short *)v28 - 4) >> 1) - v29;
+              v33 = *((short *)v28 - 5) + *((short *)v1 + 100);
+              if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) )
+              {
+                v34.z = *(short *)v1;
+                v34.y = *((short *)v1 - 100);
+                v34.x = *((short *)v1 - 200);
+                if ( sub_407A1C(*((short *)v28 - 2), *((short *)v28 - 1), *(short *)v28 + 50, v34) )
+                {
+                  Vec3_int_::Normalize(&a1, &v48, &v44);
+                  v35 = pVelocity;
+                  pVelocity->x = a1;
+                  v35->y = v48;
+                  v35->z = v44;
+                  switch ( v41 )
+                  {
+                    case 4:
+                      DamageMonsterFromParty(*((short *)v1 - 300), uActorID, v35);
+                      break;
+                    case 3:
+                      if ( v36 && pActors[v37].GetActorsRelation((Actor *)(v28 - 146)) )
+                        sub_43B1B0(*((short *)v1 - 300), uActorID, pVelocity, v36->field_61);
+                      break;
+                    case 2:
+                      sub_43B057(*((short *)v1 - 300), uActorID, v35);
+                      break;
+                  }
+                }
+              }
+            }
+            ++uActorID;
+            v28 += 836;
+          }
+          while ( (signed int)uActorID < (signed int)uNumActors );
+        }
+      }
+      ++pVelocity;
+      v0 = v43 + 1;
+      v1 += 2;
+      ++v43;
+    }
+    while ( v43 < stru_50FE08.count );
+  }
+  stru_50FE08.count = 0;
+}
+// 50FE08: using guessed type stru298 stru_50FE08;
+
+//----- (00439474) --------------------------------------------------------
+bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
+{
+  signed int v3; // eax@1
+  LayingItem *v4; // ebx@1
+  int v5; // edx@3
+  bool uPlayerID; // eax@3
+  Player *pPlayer; // edi@4
+  Actor *pMonster; // esi@7
+  LayingItem *v9; // ebx@12
+  int v10; // eax@12
+  int v11; // ebx@12
+  unsigned int v12; // ecx@12
+  int v13; // edx@15
+  int v14; // edx@17
+  int v15; // eax@24
+  unsigned __int16 v16; // cx@25
+  int v17; // eax@29
+  int v18; // eax@38
+  unsigned __int8 v19; // zf@38
+  unsigned __int8 v20; // sf@38
+  int v21; // edx@44
+  int v22; // eax@44
+  unsigned __int8 v23; // zf@44
+  unsigned __int8 v24; // sf@44
+  int v25; // edx@51
+  int v26; // ecx@51
+  signed int v27; // eax@51
+  int v28; // eax@53
+  signed int v29; // eax@76
+  signed int v30; // eax@84
+  signed int v31; // eax@92
+  int v32; // eax@94
+  int v33; // eax@100
+  int v34; // eax@104
+  signed int v35; // eax@104
+  double v36; // st7@104
+  float v37; // ST08_4@104
+  float v38; // ST04_4@104
+  float v39; // ST00_4@104
+  int v40; // ebx@107
+  unsigned int v41; // ebx@109
+  signed __int64 v42; // qax@125
+  unsigned __int16 v43; // ax@132
+  char v44; // bl@132
+  unsigned __int16 v45; // ax@132
+  unsigned __int64 v46; // [sp+Ch] [bp-60h]@6
+  const char *v47; // [sp+14h] [bp-58h]@104
+  char *pPlayerName; // [sp+18h] [bp-54h]@12
+  char *pMonsterName; // [sp+1Ch] [bp-50h]@6
+  int v50; // [sp+20h] [bp-4Ch]@6
+  unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6
+  int v52; // [sp+34h] [bp-38h]@12
+  int v53; // [sp+38h] [bp-34h]@10
+  int v54; // [sp+3Ch] [bp-30h]@1
+  int v55; // [sp+40h] [bp-2Ch]@12
+  signed int a4; // [sp+44h] [bp-28h]@1
+  PlayerEquipment *v57; // [sp+48h] [bp-24h]@10
+  int v58; // [sp+4Ch] [bp-20h]@10
+  int v59; // [sp+50h] [bp-1Ch]@1
+  unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
+  int v61; // [sp+58h] [bp-14h]@1
+  int v62; // [sp+5Ch] [bp-10h]@1
+  int uDamageAmount; // [sp+60h] [bp-Ch]@1
+  int a2; // [sp+64h] [bp-8h]@27
+  int a3; // [sp+6Bh] [bp-1h]@6
+
+  v3 = a1;
+  v4 = 0;
+  uActorID_Monster_ = uActorID_Monster;
+  v54 = a1;
+  uDamageAmount = 0;
+  a4 = 0;
+  v61 = 0;
+  v59 = 0;
+  v62 = 0;
+  if ( (a1 & 7) == 2 )
+  {
+    v4 = &pLayingItems[a1 >> 3];
+    uDamageAmount = (int)v4;
+    v61 = v4->field_60_distance_related_prolly_lod;
+    v3 = v4->field_58;
+    v54 = v4->field_58;
+  }
+  v5 = v3 & 7;
+  uPlayerID = v3 >> 3;
+  if ( v5 != 4 )
+    return uPlayerID;
+  pPlayer = &pParty->pPlayers[uPlayerID];
+  if ( uPlayerID < 0 && uPlayerID > 3 )
+  {
+    MessageBoxW(nullptr, L"Invalid player in damageMonsterFromParty!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Damage.cpp:457", 0);
+  }
+  pMonster = &pActors[uActorID_Monster_];
+  uPlayerID = pMonster->IsAlive();
+  if ( uPlayerID )
+    return uPlayerID;
+  BYTE1(pMonster->uAttributes) |= 0xC0u;
+  if ( pMonster->uAIState == Fleeing )
+    pMonster->uAttributes |= 0x20000u;
+  v58 = 0;
+  v53 = 0;
+  v57 = 0;
+  if ( !v4 )
+  {
+    v51 = (unsigned __int64 *)pPlayer->pEquipment.uMainHand;
+    v59 = 1;
+    if ( pPlayer->HasItemEquipped(EQUIP_TWO_HANDED) )
+    {
+      v55 = pItemsTable->pItems[*(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)v51 + 5]].uSkillType;
+      v28 = SkillToMastery(pPlayer->pActiveSkills[v55]);
+      uDamageAmount = v28;
+      if ( v55 )
+      {
+        if ( v55 == 6 )
+        {
+          if ( v28 >= 3 )
+          {
+            LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
+            v51 = (unsigned __int64 *)(unsigned __int8)v51;
+            if ( rand() % 100 < (unsigned __int8)v51 )
+              v58 = 1;
+          }
+          if ( uDamageAmount >= 4 )
+          {
+            LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
+            v51 = (unsigned __int64 *)(unsigned __int8)v51;
+            if ( rand() % 100 < (unsigned __int8)v51 )
+              v53 = 1;
+          }
+        }
+      }
+      else
+      {
+        if ( uDamageAmount >= 3 )
+        {
+          LOBYTE(v51) = pPlayer->GetActualSkillLevel((PLAYER_SKILL_TYPE)0) & 0x3F;
+          v51 = (unsigned __int64 *)(unsigned __int8)v51;
+          if ( rand() % 100 < (unsigned __int8)v51 )
+            v58 = 1;
+        }
+      }
+    }
+    v50 = pMonster->pMonsterInfo.uID;
+    a2 = 4;
+    v27 = pPlayer->CalculateMeleeDamageTo(0, 0, v50);
+    goto LABEL_65;
+  }
+  v19 = v4->field_48 == 99;
+  v61 = v4->field_60_distance_related_prolly_lod;
+  if ( !v19 )
+  {
+    v9 = (LayingItem *)uDamageAmount;
+    v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4);
+    v55 = abs(v50);
+    pMonsterName = (char *)(pParty->vPosition.y - v9->vPosition.y);
+    v51 = (unsigned __int64 *)abs((int)pMonsterName);
+    pPlayerName = (char *)(pParty->vPosition.z - v9->vPosition.z);
+    v52 = abs((int)pPlayerName);
+    v61 = v55;
+    v10 = v55;
+    v11 = (int)v51;
+    v12 = v52;
+    if ( v55 < (signed int)v51 )
+    {
+      v10 = (int)v51;
+      v11 = v55;
+    }
+    if ( v10 < v52 )
+    {
+      v13 = v10;
+      v10 = v52;
+      v12 = v13;
+    }
+    if ( v11 < (signed int)v12 )
+    {
+      v14 = v12;
+      v12 = v11;
+      v11 = v14;
+    }
+    uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
+    v61 = uPlayerID;
+    if ( uPlayerID >= 2560 )
+    {
+      if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
+        return uPlayerID;
+      v61 = 2;
+    }
+    else
+    {
+      v61 = 1;
+    }
+    v4 = (LayingItem *)uDamageAmount;
+  }
+  v15 = v4->field_48;
+  if ( v15 == 102 )
+  {
+    v16 = pPlayer->pActiveSkills[7];
+    v61 = 1;
+    if ( (signed int)SkillToMastery(v16) >= 3 )
+      a4 = pPlayer->pActiveSkills[7] & 0x3F;
+    a2 = 4;
+    uDamageAmount = pPlayer->CalculateMeleeDamageTo(1, 1, 0);
+    goto LABEL_67;
+  }
+  if ( v15 != 100 )
+  {
+    if ( v15 == 101 )
+    {
+      a2 = 0;
+      v18 = pPlayer->CalculateRangedDamageTo(0);
+      v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
+      v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
+      uDamageAmount = v18;
+      if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
+        uDamageAmount >>= 1;
+      v59 = 1;
+      goto LABEL_67;
+    }
+    if ( v15 == 39 )
+    {
+      a4 = 5 * v4->field_4C;
+      a2 = pPlayer->GetSpellSchool(0x27u);
+      v21 = v4->field_4C;
+      v50 = pMonster->sCurrentHP;
+      pMonsterName = (char *)v4->field_50;
+      v22 = _43AFE3_calc_spell_damage(39, v21, (signed int)pMonsterName, v50);
+      v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
+      v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
+      uDamageAmount = v22;
+      if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
+        uDamageAmount >>= 1;
+      v59 = 0;
+LABEL_67:
+      if ( !stru_50C198.PlayerHitOrMiss(pPlayer, pMonster, v61, a4) )
+      {
+LABEL_68:
+        LOWORD(uPlayerID) = pPlayer->PlaySound(52, 0);
+        return uPlayerID;
+      }
+      goto LABEL_69;
+    }
+    if ( v15 == 34 )
+    {
+      uDamageAmount = 0;
+      a2 = 4;
+      v58 = 1;
+      goto LABEL_67;
+    }
+    v50 = v4->field_48;
+    a2 = pPlayer->GetSpellSchool(v50);
+    v25 = v4->field_4C;
+    v26 = v4->field_48;
+    v50 = pMonster->sCurrentHP;
+    pMonsterName = (char *)v4->field_50;
+    v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50);
+    v59 = 0;
+    v57 = (PlayerEquipment *)1;
+LABEL_65:
+    uDamageAmount = v27;
+    goto LABEL_66;
+  }
+  v50 = pMonster->word_000086_some_monster_id;
+  a2 = 4;
+  v17 = pPlayer->CalculateRangedDamageTo(v50);
+  v19 = v4->stru_24.uItemID == 0;
+  uDamageAmount = v17;
+  if ( !v19 && v4->stru_24.uAdditionalValue == 3 )
+  {
+    a2 = 0;
+    v57 = (PlayerEquipment *)1;
+  }
+  if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0
+    && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
+    uDamageAmount >>= 1;
+  v59 = 1;
+LABEL_66:
+  if ( !v57 )
+    goto LABEL_67;
+LABEL_69:
+  if ( pPlayer->pConditions[1] )
+    uDamageAmount >>= 1;
+  if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
+    uDamageAmount = 0;
+  v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount);
+  if ( !v4 && pPlayer->IsUnarmed() && (signed __int64)pPlayer->pPlayerBuffs[6].uExpireTime > 0 )
+  {
+    v50 = pPlayer->pPlayerBuffs[6].uPower;
+    v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50);
+    v61 += v29;
+  }
+  uDamageAmount = v61;
+  if ( v59 )
+  {
+    if ( v4 )
+    {
+      a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62);
+      if ( v62 && pMonster->sCurrentHP > 0 )
+      {
+        pPlayer->sHealth += v61 / 5;
+        if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
+          pPlayer->sHealth = pPlayer->GetMaxHealth();
+        v62 = 0;
+      }
+      v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
+      uDamageAmount = v61 + v30;
+    }
+    else
+    {
+      v59 = 0;
+      v57 = &pPlayer->pEquipment;
+      do
+      {
+        if ( pPlayer->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
+        {
+          auto _s = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v57->uOffHand + 5];
+          a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
+          if ( v62 && pMonster->sCurrentHP > 0 )
+          {
+            pPlayer->sHealth += v61 / 5;
+            if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
+              pPlayer->sHealth = pPlayer->GetMaxHealth();
+            v62 = 0;
+          }
+          v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
+          uDamageAmount += v31;
+        }
+        ++v59;
+        v57 = (PlayerEquipment *)((char *)v57 + 4);
+      }
+      while ( v59 <= 1 );
+    }
+  }
+  v32 = uDamageAmount;
+  pMonster->sCurrentHP -= uDamageAmount;
+  if ( !v32 && !v58 )
+    goto LABEL_68;
+  if ( pMonster->sCurrentHP > 0 )
+  {
+    Actor::_4030AD(uActorID_Monster_, v54, 0);
+    Actor::_43AC45(uActorID_Monster_, 1);
+    if ( bShowDamage )
+    {
+      v50 = uDamageAmount;
+      pMonsterName = (char *)pMonster;
+      pPlayerName = pPlayer->pName;
+      if ( v4 )
+        v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points"
+      else
+        v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage"
+      sprintf(pTmpBuf, v47, pPlayerName, pMonsterName, v50);
+      ShowStatusBarString(pTmpBuf, 2u);
+    }
+    v41 = 0;
+  }
+  else
+  {
+    if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 )
+    {
+      v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius;
+      v55 = v33;
+      if ( pRenderer->pRenderD3D )
+      {
+        if ( pGame->uFlags2 & 0x20 )
+        {
+          v50 = 0;
+          pMonsterName = 0;
+          v34 = pMonster->vPosition.z;
+          *(float *)&pPlayerName = (double)v55;
+          v51 = (unsigned __int64 *)v34;
+          *(float *)&v47 = 0.0;
+          v35 = pMonster->vPosition.y;
+          *((float *)&v46 + 1) = 0.0;
+          *(float *)&v46 = 1.0;
+          v36 = (double)(signed int)v51;
+          v51 = (unsigned __int64 *)v35;
+          v37 = v36;
+          v51 = (unsigned __int64 *)pMonster->vPosition.x;
+          v38 = (double)v35;
+          v39 = (double)(signed int)v51;
+          pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0);
+        }
+      }
+    }
+    Actor::Die(uActorID_Monster_);
+    Actor::_438CF3(uActorID_Monster_);
+    Actor::_43AC45(uActorID_Monster_, 1);
+    if ( pMonster->pMonsterInfo.uExp )
+      sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
+    v40 = 51;
+    if ( rand() % 100 < 20 )
+      v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
+    pPlayer->PlaySound(v40, 0);
+    v41 = 0;
+    if ( bShowDamage )
+    {
+      v50 = (int)pMonster;
+      pMonsterName = (char *)uDamageAmount;
+      pPlayerName = pPlayer->pName;             // "%s inflicts %lu points killing %s"
+      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[175], pPlayer->pName, uDamageAmount, pMonster);
+      ShowStatusBarString(pTmpBuf, 2u);
+    }
+  }
+  if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41
+    && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41
+     || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41)
+    && uDamageAmount != v41 )
+    pPlayer->ReceiveDamage(uDamageAmount, a2);
+  v50 = 24;
+  v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP;
+  if ( (pPlayer->_48EA46_calc_special_bonus_by_items(24) || v58 != v41)
+    && stru_50C198.GetMagicalResistance(pMonster, 3u) )
+  {
+    LODWORD(v42) = 20;
+    v59 = 10;
+    if ( pParty->bTurnBasedModeOn == v41 )
+      v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666);
+    pMonster->pMonsterInfo.uRecoveryTime += v42;
+    if ( bShowDamage != v41 )
+    {
+      v50 = (int)pMonster;
+      pMonsterName = pPlayer->pName;            // "%s stuns %s"
+      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[635], pPlayer->pName, pMonster);
+      ShowStatusBarString(pTmpBuf, 2u);
+    }
+  }
+  if ( v53 != v41 )
+  {
+    if ( pMonster->CanAct() )
+    {
+      if ( stru_50C198.GetMagicalResistance(pMonster, 3u) )
+      {
+        LOBYTE(v43) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE);
+        v44 = v43;
+        v45 = SkillToMastery(v43);
+        v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F));
+        v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v51 * 0.033333335);
+        pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0);
+        if ( bShowDamage )
+        {
+          v50 = (int)pMonster;
+          pMonsterName = pPlayer->pName;        // "%s paralyzes %s"
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[636], pPlayer->pName, pMonster);
+          ShowStatusBarString(pTmpBuf, 2u);
+        }
+      }
+    }
+  }
+  if ( v59 > 10 )
+    v59 = 10;
+  if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+  {
+    pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16;
+    pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16;
+    pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16;
+    pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x);
+    pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
+    pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
+  }
+  return Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
+}
+// 4D864C: using guessed type char byte_4D864C;
+
+
+//----- (00439FCB) --------------------------------------------------------
+void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4)
+{
+  signed int v4; // esi@1
+  unsigned int v5; // ecx@1
+  Player *v6; // ebx@3
+  Actor *v7; // esi@3
+  unsigned int v8; // eax@4
+  char *v9; // eax@5
+  signed int v10; // eax@6
+  int v11; // edx@8
+  int v12; // edx@9
+  int v13; // edx@10
+  int v14; // edx@16
+  int v15; // edx@17
+  int v16; // edx@18
+  enum SoundID v17; // eax@24
+  int v18; // eax@26
+  unsigned __int8 v19; // zf@26
+  unsigned __int8 v20; // sf@26
+  unsigned __int16 v21; // ax@29
+  signed int v22; // edi@36
+  int v23; // eax@38
+  signed int v24; // eax@44
+  unsigned __int16 v25; // cx@47
+  signed int v26; // eax@49
+  int v27; // eax@54
+  float v28; // ST18_4@58
+  double v29; // st7@58
+  float v30; // ST08_4@58
+  double v31; // st7@58
+  float v32; // ST04_4@58
+  float v33; // ST00_4@58
+  int v34; // edi@61
+  int v35; // eax@70
+  double v36; // st7@70
+  LayingItem *v37; // ebx@77
+  int v38; // edi@77
+  int v39; // esi@77
+  int v40; // eax@77
+  int v41; // eax@77
+  int v42; // eax@78
+  char *v43; // eax@81
+  Actor *v44; // esi@82
+  char *v45; // edi@84
+  unsigned __int16 v46; // ax@84
+  int v47; // ebx@105
+  int v48; // eax@107
+  unsigned __int16 v49; // ax@116
+  int v50; // ebx@123
+  unsigned __int16 v51; // ax@124
+  char v52; // bl@124
+  int v53; // eax@128
+  signed int v54; // eax@134
+  unsigned __int16 v55; // cx@137
+  signed int v56; // eax@139
+  int v57; // eax@144
+  float v58; // ST18_4@148
+  double v59; // st7@148
+  float v60; // ST08_4@148
+  double v61; // st7@148
+  float v62; // ST04_4@148
+  float v63; // ST00_4@148
+  int v64; // ebx@151
+  int v65; // eax@161
+  double v66; // st7@161
+  signed int v67; // ecx@164
+  signed int v68; // eax@170
+  int v69; // ecx@170
+  int v70; // eax@171
+  enum SoundID v71; // [sp+20h] [bp-34h]@12
+  int v72; // [sp+30h] [bp-24h]@164
+  double v73; // [sp+40h] [bp-14h]@72
+  signed int v74; // [sp+44h] [bp-10h]@1
+  unsigned int v75; // [sp+48h] [bp-Ch]@3
+  unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
+  int v77; // [sp+50h] [bp-4h]@26
+  signed int a4a; // [sp+60h] [bp+Ch]@162
+  Player *a4b; // [sp+60h] [bp+Ch]@168
+
+  v4 = (signed int)uObjID >> 3;
+  v5 = (uObjID & 7) - 2;
+  v74 = a2;
+  uActorID = v4;
+  if ( v5 )
+  {
+    if ( v5 != 1
+      || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4],
+                                     v75 = v6->sHealth,
+                                     !stru_50C198.ActorHitOrMiss(v7, v6)) )
+      return;
+    v8 = v6->pEquipment.uBody;
+    if ( !v8
+      || (v9 = (char *)v6 + 36 * v8, v9[516] & 2)
+      || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10)
+      || v10 > 11 )
+    {
+      v14 = rand() % 4;
+      if ( !v14 )
+      {
+        v71 = (SoundID)108;
+        goto LABEL_24;
+      }
+      v15 = v14 - 1;
+      if ( !v15 )
+      {
+        v71 = (SoundID)109;
+        goto LABEL_24;
+      }
+      v16 = v15 - 1;
+      if ( !v16 )
+      {
+        v71 = (SoundID)110;
+        goto LABEL_24;
+      }
+      if ( v16 == 1 )
+      {
+        v71 = (SoundID)44;
+        goto LABEL_24;
+      }
+    }
+    else
+    {
+      v11 = rand() % 4;
+      if ( !v11 )
+      {
+        v71 = (SoundID)105;
+        goto LABEL_24;
+      }
+      v12 = v11 - 1;
+      if ( !v12 )
+      {
+        v71 = (SoundID)106;
+        goto LABEL_24;
+      }
+      v13 = v12 - 1;
+      if ( !v13 )
+      {
+        v71 = (SoundID)107;
+        goto LABEL_24;
+      }
+      if ( v13 == 1 )
+      {
+        v71 = (SoundID)45;
+LABEL_24:
+        v17 = v71;
+        goto LABEL_26;
+      }
+    }
+    v17 = (SoundID)a4;
+LABEL_26:
+    pAudioPlayer->PlaySound(v17, (8 * a4 + 80) | 4, 0, -1, 0, 0, 0, 0);
+    v18 = Actor::_43B3E0_CalcDamage(v7, v74);
+    v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0;
+    v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0;
+    v77 = v18;
+    if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) )
+    {
+      v21 = v7->pActorBuffs[3].uPower;
+      if ( v21 )
+        v77 /= (signed int)v21;
+    }
+    if ( v74 )
+    {
+      if ( v74 == 1 )
+      {
+        v22 = v7->pMonsterInfo.uAttack2Type;
+      }
+      else
+      {
+        if ( v74 == 2 )
+        {
+          v23 = v7->pMonsterInfo.uSpell1ID;
+        }
+        else
+        {
+          if ( v74 != 3 )
+          {
+            if ( v74 == 4 )
+              v22 = v7->pMonsterInfo.field_3C_some_special_attack;
+            else
+              v22 = 4;
+            goto LABEL_43;
+          }
+          v23 = v7->pMonsterInfo.uSpell2ID;
+        }
+        v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool);
+      }
+    }
+    else
+    {
+      v22 = v7->pMonsterInfo.uAttack1Type;
+    }
+LABEL_43:
+    if ( !(dword_6BE368_debug_settings_2 & 0x10) )
+    {
+      v24 = v6->ReceiveDamage(v77, v22);
+      if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0
+        && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) )
+      {
+        v25 = v7->uAIState;
+        if ( v25 != 5 )
+        {
+          if ( v25 != 4 )
+          {
+            v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24);
+            v7->sCurrentHP -= v26;
+            if ( v26 )
+            {
+              if ( v7->sCurrentHP >= 1 )
+              {
+                Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
+                Actor::_43AC45(uActorID, 1);
+              }
+              else
+              {
+                if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 )
+                {
+                  v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius;
+                  v74 = v27;
+                  if ( pRenderer->pRenderD3D )
+                  {
+                    if ( pGame->uFlags2 & 0x20 )
+                    {
+                      v28 = (double)v74;
+                      v74 = v7->vPosition.z;
+                      v29 = (double)v74;
+                      v74 = v7->vPosition.y;
+                      v30 = v29;
+                      v31 = (double)v74;
+                      v74 = v7->vPosition.x;
+                      v32 = v31;
+                      v33 = (double)v74;
+                      pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0);
+                    }
+                  }
+                }
+                Actor::Die(uActorID);
+                Actor::_438CF3(uActorID);
+                Actor::_43AC45(uActorID, 1);
+                if ( v7->pMonsterInfo.uExp )
+                  sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
+                v34 = 51;
+                if ( rand() % 100 < 20 )
+                  v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
+                v6->PlaySound(v34, 0);
+              }
+            }
+          }
+        }
+      }
+      if ( !(dword_6BE368_debug_settings_2 & 0x10)
+        && v7->pMonsterInfo.uSpecialAttack
+        && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType )
+        v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7);
+    }
+    if ( !pParty->bTurnBasedModeOn )
+    {
+      v35 = v6->GetActualEndurance();
+      v36 = (double)(20 - v6->_48EA1B_get_static_effect(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
+      v6->SetRecoveryTime((signed __int64)v36);
+    }
+    if ( v77 )
+    {
+      v73 = (double)(signed int)v75;
+      if ( (double)v6->GetMaxHealth() * 0.25 < v73 )
+      {
+        if ( v6->sHealth > 0 )
+        {
+          if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
+            v6->PlaySound(48, 0);
+        }
+      }
+    }
+    viewparams->bRedrawGameUI = 1;
+    return;
+  }
+  v37 = &pLayingItems[uActorID];
+  v38 = v37->field_58 & 7;
+  v39 = v37->field_58 >> 3;
+  v40 = v37->field_58 & 7;
+  uActorID = v37->field_58 >> 3;
+  v41 = v40 - 2;
+  if ( !v41 )
+    goto LABEL_80;
+  v42 = v41 - 1;
+  if ( !v42 )
+  {
+    v44 = &pActors[v39];
+    if ( a4 == -1 )
+      a4 = stru_50C198.which_player_would_attack(v44);
+    v45 = (char *)&pParty->pPlayers[a4];
+    v77 = Actor::_43B3E0_CalcDamage(v44, v74);
+    v46 = v37->uItemType;
+    if ( v37->uItemType == 545 )
+    {
+      LOBYTE(v51) = ((Player *)v45)->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+      v52 = v51;
+      if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) )
+      {
+        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[637], v45 + 168);
+        ShowStatusBarString(pTmpBuf, 2u);
+        ((Player *)v45)->PlaySound(6, 0);
+        return;
+      }
+    }
+    else
+    {
+      if ( v46 != 555
+        && v46 != 510
+        && v46 != 500
+        && v46 != 515
+        && v46 != 505
+        && v46 != 530
+        && v46 != 525
+        && v46 != 520
+        && v46 != 535
+        && v46 != 540 )
+        goto LABEL_115;
+    }
+    if ( !stru_50C198.ActorHitOrMiss(v44, (Player *)v45) )
+      return;
+    if ( *((_QWORD *)v45 + 782) > 0i64 )
+      v77 >>= 1;
+    if ( ((Player *)v45)->HasEnchantedItemEquipped(36) )
+      v77 >>= 1;
+    if ( ((Player *)v45)->HasEnchantedItemEquipped(69) )
+      v77 >>= 1;
+    if ( ((Player *)v45)->HasItemEquipped(EQUIP_ARMOUR)
+      && *(int *)&v45[36 * *((int *)v45 + 1621) + 496] == 504 )
+      v77 >>= 1;
+    v75 = 0;
+    v47 = (int)(v45 + 6472);
+    do
+    {
+      if ( ((Player *)v45)->HasItemEquipped((ITEM_EQUIP_TYPE)v75) )
+      {
+        v48 = *(int *)&v45[36 * *(int *)v47 + 496];
+        if ( v48 == 520 )
+          v77 >>= 1;
+        if ( v48 == 531 )
+          v77 >>= 1;
+        if ( ((Player *)v45)->GetEquippedItemEquipType(v75) == 4 && SkillToMastery(*((short *)v45 + 140)) == 4 )
+          v77 >>= 1;
+      }
+      ++v75;
+      v47 += 4;
+    }
+    while ( (signed int)v75 <= 1 );
+LABEL_115:
+    if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 )
+    {
+      v49 = v44->pActorBuffs[3].uPower;
+      if ( v49 )
+        v77 /= (signed int)v49;
+    }
+    if ( !v74 )
+    {
+      v50 = v44->pMonsterInfo.uAttack1Type;
+      goto LABEL_133;
+    }
+    if ( v74 == 1 )
+    {
+      v50 = v44->pMonsterInfo.uAttack2Type;
+      goto LABEL_133;
+    }
+    if ( v74 == 2 )
+    {
+      v53 = v44->pMonsterInfo.uSpell1ID;
+    }
+    else
+    {
+      if ( v74 != 3 )
+      {
+        if ( v74 == 4 )
+          v50 = v44->pMonsterInfo.field_3C_some_special_attack;
+        else
+          v50 = 4;
+LABEL_133:
+        if ( !(dword_6BE368_debug_settings_2 & 0x10) )
+        {
+          v54 = ((Player *)v45)->ReceiveDamage(v77, v50);
+          if ( *((int *)v45 + 1553) >= 0 )
+          {
+            if ( *((int *)v45 + 1553) > 0 || *((int *)v45 + 1552) )
+            {
+              v55 = v44->uAIState;
+              if ( v55 != 5 )
+              {
+                if ( v55 != 4 )
+                {
+                  v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54);
+                  v44->sCurrentHP -= v56;
+                  if ( v56 )
+                  {
+                    if ( v44->sCurrentHP >= 1 )
+                    {
+                      Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
+                      Actor::_43AC45(uActorID, 1);
+                    }
+                    else
+                    {
+                      if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 )
+                      {
+                        v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius;
+                        v75 = v57;
+                        if ( pRenderer->pRenderD3D )
+                        {
+                          if ( pGame->uFlags2 & 0x20 )
+                          {
+                            v58 = (double)(signed int)v75;
+                            v75 = v44->vPosition.z;
+                            v59 = (double)(signed int)v75;
+                            v75 = v44->vPosition.y;
+                            v60 = v59;
+                            v61 = (double)(signed int)v75;
+                            v75 = v44->vPosition.x;
+                            v62 = v61;
+                            v63 = (double)(signed int)v75;
+                            pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0);
+                          }
+                        }
+                      }
+                      Actor::Die(uActorID);
+                      Actor::_438CF3(uActorID);
+                      Actor::_43AC45(uActorID, 1);
+                      if ( v44->pMonsterInfo.uExp )
+                        sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
+                      v64 = 51;
+                      if ( rand() % 100 < 20 )
+                        v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
+                      ((Player *)v45)->PlaySound(v64, 0);
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+        if ( !v74
+          && !(dword_6BE368_debug_settings_2 & 0x10)
+          && v44->pMonsterInfo.uSpecialAttack
+          && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType )
+          ((Player *)v45)->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44);
+        if ( !pParty->bTurnBasedModeOn )
+        {
+          v65 = ((Player *)v45)->GetActualEndurance();
+          v66 = (double)(20 - ((Player *)v45)->_48EA1B_get_static_effect(v65))
+              * flt_6BE3A4_debug_recmod1
+              * 2.133333333333333;
+          ((Player *)v45)->SetRecoveryTime((signed __int64)v66);
+        }
+        return;
+      }
+      v53 = v44->pMonsterInfo.uSpell2ID;
+    }
+    v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool);
+    goto LABEL_133;
+  }
+  if ( v42 != 1 )
+    return;
+LABEL_80:
+  if ( a4 != -1 )
+  {
+    v43 = (char *)&pParty->pPlayers[a4];
+LABEL_168:
+    a4b = (Player *)v43;
+    if ( v38 != 4 || v37->field_48 != 100 )
+    {
+      v70 = ((Player *)v43)->GetMaxHealth();
+      v68 = _43AFE3_calc_spell_damage(v37->field_48, v37->field_4C, v37->field_50, v70);
+      v69 = LOBYTE(pSpellStats->pInfos[v37->field_48].uSchool);
+    }
+    else
+    {
+      v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
+      v69 = 0;
+    }
+    a4b->ReceiveDamage(v68, v69);
+    if ( v38 == 4 && !qword_A750D8 )
+    {
+      qword_A750D8 = 256i64;
+      word_A750E0 = 44;
+      word_A750E2 = uActorID + 1;
+    }
+    return;
+  }
+  v74 = 0;
+  a4a = 1;
+  do
+  {
+    if ( pPlayers[a4a]->CanAct() )
+    {
+      v67 = v74++;
+      *(&v72 + v67) = a4a;
+    }
+    ++a4a;
+  }
+  while ( a4a <= 4 );
+  if ( v74 )
+  {
+    v43 = &stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
+    goto LABEL_168;
+  }
+}
+
+
+//----- (0043A97E) --------------------------------------------------------
+void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
+{
+  unsigned int v2; // esi@1
+  unsigned int v3; // ebx@1
+  int v4; // edi@1
+  int v5; // edx@1
+  unsigned int v6; // [sp+10h] [bp-4h]@1
+
+  v6 = uLayingItemID;
+  v2 = uLayingItemID;
+  v3 = a2 >> 3;
+  v4 = pLayingItems[uLayingItemID].field_58 & 7;
+  v5 = (a2 & 7) - 3;
+  if ( v5 )
+  {
+    if ( v5 == 1 )
+    {
+      layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
+      layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
+      layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
+      Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
+      DamagePlayerFromMonster(8 * v6 | 2, pLayingItems[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu);
+    }
+  }
+  else
+  {
+    layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
+    layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
+    layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
+    Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
+    switch ( v4 )
+    {
+      case OBJECT_Actor:
+        sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pLayingItems[v2].field_61);
+        break;
+      case OBJECT_Player:
+        DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
+        break;
+      case OBJECT_Item:
+        sub_43B057(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
+        break;
+    }
+  }
+}
+
+//----- (0043AA99) --------------------------------------------------------
+void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz)
+{
+  int v7; // ebx@1
+  int v8; // ST14_4@1
+  int v9; // edi@1
+  int anglea; // [sp+20h] [bp+8h]@1
+
+  v7 = sRotX;
+  v8 = sDepth;
+  v9 = sRotY;
+  anglea = (unsigned __int64)(stru_5C6E00->SinCos(sRotX) * (signed __int64)sDepth) >> 16;
+  *outx = v.x + ((unsigned __int64)(stru_5C6E00->SinCos(v9) * (signed __int64)anglea) >> 16);
+  *outy = v.y
+        + ((unsigned __int64)(stru_5C6E00->SinCos(v9 - stru_5C6E00->uIntegerHalfPi)
+                            * (signed __int64)anglea) >> 16);
+  *outz = v.z
+        + ((unsigned __int64)(stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v8) >> 16);
+}
+
+//----- (0043AB61) --------------------------------------------------------
+void Vec3_int_::Normalize(int *x, int *y, int *z)
+{
+  int *v3; // edi@1
+  int *v4; // esi@1
+  signed int v5; // eax@1
+
+  v3 = x;
+  v4 = y;
+  v5 = sub_452A9E(*y * *y + *z * *z + *x * *x);
+  *v3 *= 65536 / (v5 | 1);
+  *v4 *= 65536 / (v5 | 1);
+  *z *= 65536 / (v5 | 1);
+}
+
+
+
+
+//----- (0043AE12) --------------------------------------------------------
+double __fastcall sub_43AE12(signed int a1)
+{
+  signed int v1; // ST00_4@1
+  signed int v2; // ecx@1
+  double v3; // st7@1
+  double result; // st7@6
+
+  v1 = a1;
+  v2 = 0;
+  v3 = (double)v1;
+  do
+  {
+    if ( v3 < flt_4E4A80[v2 + 5] )
+      break;
+    ++v2;
+  }
+  while ( v2 < 5 );
+  if ( v2 <= 0 || v2 >= 5 )
+  {
+    if ( v2 )
+      result = flt_4E4A80[4];
+    else
+      result = flt_4E4A80[0];
+  }
+  else
+  {
+    result = (flt_4E4A80[v2] - *(float *)&aAuthenticamd[4 * v2 + 12])
+           * (v3 - flt_4E4A80[v2 + 4])
+           / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4])
+           + flt_4E4A80[v2];
+  }
+  return result;
+}
+
+//----- (0043AFE3) --------------------------------------------------------
+int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4)
+{
+  int result; // eax@1
+  unsigned int v5; // [sp-4h] [bp-8h]@9
+
+  result = 0;
+  if ( a1 == 7 )
+  {
+    if ( a3 <= 0 )
+      return result;
+    if ( a3 <= 2 )
+    {
+      v5 = 6;
+    }
+    else
+    {
+      if ( a3 == 3 )
+      {
+        v5 = 8;
+      }
+      else
+      {
+        if ( a3 != 4 )
+          return result;
+        v5 = 10;
+      }
+    }
+    result = GetDiceResult(a2, v5);
+  }
+  else
+  {
+    if ( a1 == 44 )
+      result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100;
+    else
+      result = *((char *)&pSpellDatas[0].field_10 + 20 * a1)
+             + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1));
+  }
+  return result;
+}
+
+//----- (0043B057) --------------------------------------------------------
+void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity)
+{
+  Actor *pActor; // esi@1
+  LayingItem *v4; // eax@3
+  int v5; // ecx@3
+  int v6; // eax@4
+  int v7; // edi@4
+  unsigned int uActorIDa; // [sp+8h] [bp-8h]@1
+  unsigned int a2; // [sp+Ch] [bp-4h]@1
+  int a2a; // [sp+Ch] [bp-4h]@8
+
+  uActorIDa = uActorID;
+  pActor = &pActors[uActorID];
+  a2 = uObjID;
+  if ( !pActors[uActorID].IsAlive() )
+  {
+    if ( (a2 & 7) == 2 )
+    {
+      v4 = &pLayingItems[(signed int)a2 >> 3];
+      v5 = v4->field_48;
+      if ( v5 )
+      {
+        v6 = _43AFE3_calc_spell_damage(v5, v4->field_4C, v4->field_50, pActor->sCurrentHP);
+        v7 = stru_50C198.CalcMagicalDamageToActor(pActor, 0, v6);
+        pActor->sCurrentHP -= v7;
+        if ( v7 )
+        {
+          if ( pActor->sCurrentHP > 0 )
+            Actor::_4030AD(uActorIDa, a2, 0);
+          else
+            Actor::Die(uActorIDa);
+          a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP;
+          if ( 20 * v7 / (signed int)pActor->pMonsterInfo.uHP > 10 )
+            a2a = 10;
+          if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+          {
+            pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16;
+            pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16;
+            pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16;
+            pActor->vVelocity.x = 50 * LOWORD(pVelocity->x);
+            pActor->vVelocity.y = 50 * LOWORD(pVelocity->y);
+            pActor->vVelocity.z = 50 * LOWORD(pVelocity->z);
+          }
+          Actor::AddBloodsplatOnDamageOverlay(uActorIDa, 1, v7);
+        }
+        else
+        {
+          Actor::_4030AD(uActorIDa, a2, 0);
+        }
+      }
+    }
+  }
+}
+
+//----- (0043B1B0) --------------------------------------------------------
+__int16 __fastcall sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4)
+{
+  int v4; // ebx@1
+  LayingItem *v5; // eax@2
+  bool v6; // eax@3
+  Actor *v7; // esi@4
+  Actor *v8; // edi@4
+  char v9; // zf@5
+  __int64 v10; // qax@8
+  signed __int16 v11; // cx@9
+  signed int v12; // ecx@20
+  int v13; // ecx@22
+  int v14; // edi@30
+  unsigned int uActorID; // [sp+Ch] [bp-8h]@1
+  signed int v17; // [sp+10h] [bp-4h]@1
+  int v18; // [sp+20h] [bp+Ch]@34
+
+  v4 = 0;
+  uActorID = a2;
+  v17 = a1;
+  if ( (a1 & 7) == 2 )
+  {
+    v5 = &pLayingItems[a1 >> 3];
+    v4 = v5->field_60_distance_related_prolly_lod;
+    v17 = v5->field_58;
+  }
+  LOWORD(v6) = v17 & 7;
+  if ( v6 == 3 )
+  {
+    v7 = &pActors[a2];
+    v8 = &pActors[v17 >> 3];
+    v6 = pActors[a2].IsAlive();
+    if ( !v6 )
+    {
+      v9 = v7->uAIState == 7;
+      v7->uLastCharacterIDToHit = v17;
+      if ( v9 )
+        BYTE2(v7->uAttributes) |= 2u;
+      v6 = stru_50C198._4273BB(v8, v7, v4, 0);
+      if ( v6 )
+      {
+        v10 = (unsigned int)Actor::_43B3E0_CalcDamage(v8, a4);
+        if ( (signed __int64)v8->pActorBuffs[3].uExpireTime > 0 )
+        {
+          v11 = v8->pActorBuffs[3].uPower;
+          if ( v11 )
+            v10 = (signed int)v10 / (unsigned __int16)v11;
+        }
+        if ( SHIDWORD(v7->pActorBuffs[5].uExpireTime) >= SHIDWORD(v10)
+          && (SHIDWORD(v7->pActorBuffs[5].uExpireTime) > SHIDWORD(v10)
+           || LODWORD(v7->pActorBuffs[5].uExpireTime) > HIDWORD(v10)) )
+          LODWORD(v10) = 0;
+        if ( a4 != HIDWORD(v10) )
+        {
+          if ( a4 - HIDWORD(v10) == 1 )
+          {
+            v12 = v8->pMonsterInfo.uAttack2Type;
+            if ( SHIDWORD(v7->pActorBuffs[15].uExpireTime) >= SHIDWORD(v10)
+              && (SHIDWORD(v7->pActorBuffs[15].uExpireTime) > SHIDWORD(v10)
+               || LODWORD(v7->pActorBuffs[15].uExpireTime) > HIDWORD(v10)) )
+              LODWORD(v10) = (signed int)v10 >> 1;
+            goto LABEL_30;
+          }
+          if ( a4 - HIDWORD(v10) == 2 )
+          {
+            v13 = v7->pMonsterInfo.uSpell1ID;
+          }
+          else
+          {
+            if ( a4 - HIDWORD(v10) != 3 )
+            {
+              if ( a4 - HIDWORD(v10) == 4 )
+                v12 = v8->pMonsterInfo.field_3C_some_special_attack;
+              else
+                v12 = 4;
+LABEL_30:
+              v14 = stru_50C198.CalcMagicalDamageToActor(v7, v12, v10);
+              v7->sCurrentHP -= v14;
+              if ( v14 )
+              {
+                if ( v7->sCurrentHP > 0 )
+                  Actor::_4030AD(uActorID, v17, 0);
+                else
+                  Actor::Die(uActorID);
+                Actor::_43AC45(uActorID, 0);
+                v18 = 20 * v14 / (signed int)v7->pMonsterInfo.uHP;
+                if ( 20 * v14 / (signed int)v7->pMonsterInfo.uHP > 10 )
+                  v18 = 10;
+                if ( !MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+                {
+                  pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16;
+                  pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16;
+                  pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16;
+                  v7->vVelocity.x = 50 * LOWORD(pVelocity->x);
+                  v7->vVelocity.y = 50 * LOWORD(pVelocity->y);
+                  v7->vVelocity.z = 50 * LOWORD(pVelocity->z);
+                }
+                LOWORD(v6) = Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14);
+              }
+              else
+              {
+                LOWORD(v6) = Actor::_4030AD(uActorID, v17, 0);
+              }
+              return v6;
+            }
+            v13 = v7->pMonsterInfo.uSpell2ID;
+          }
+          v12 = LOBYTE(pSpellStats->pInfos[v13].uSchool);
+          goto LABEL_30;
+        }
+        v12 = v8->pMonsterInfo.uAttack1Type;
+        goto LABEL_30;
+      }
+    }
+  }
+  return v6;
+}
+
+
+//----- (0043BCA7) --------------------------------------------------------
+int __cdecl CharacterUI_LoadPaperdollTextures()
+{
+  int v0; // edi@7
+  enum CHARACTER_RACE v1; // ebx@7
+  signed int v2; // eax@7
+  int v3; // ebx@10
+  Player *v4; // edi@12
+  unsigned __int8 v5; // cl@12
+  int v6; // edi@16
+  unsigned int v7; // eax@16
+  Player *v8; // ebx@16
+  char *v9; // ebx@16
+  char v10; // al@16
+  signed int v11; // edi@21
+  Player *v12; // ebx@23
+  Player *v13; // edi@29
+  int v14; // ebp@29
+  stru331 *v15; // edi@65
+  signed int v16; // ebx@66
+  unsigned int v17; // eax@67
+  unsigned int *v18; // ecx@67
+  unsigned int *v19; // ebx@68
+  int v20; // edi@73
+  int v21; // ebp@73
+  unsigned int v22; // eax@76
+  int v23; // ecx@76
+  unsigned int v24; // eax@78
+  int v25; // ecx@78
+  int v26; // ebx@79
+  unsigned int v27; // eax@80
+  int v28; // ecx@80
+  int result; // eax@83
+  int v30; // [sp+10h] [bp-28h]@5
+  signed int v31; // [sp+10h] [bp-28h]@68
+  signed int v32; // [sp+10h] [bp-28h]@75
+  signed int v33; // [sp+10h] [bp-28h]@77
+  int v34; // [sp+10h] [bp-28h]@79
+  char *v35; // [sp+14h] [bp-24h]@65
+  int v36; // [sp+14h] [bp-24h]@75
+  int v37; // [sp+14h] [bp-24h]@77
+  signed int v38; // [sp+14h] [bp-24h]@79
+  unsigned int *v39; // [sp+18h] [bp-20h]@66
+  int *v40; // [sp+18h] [bp-20h]@73
+  unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73
+  int v42; // [sp+20h] [bp-18h]@6
+  int v43; // [sp+20h] [bp-18h]@73
+  char pContainer[128]; // [sp+24h] [bp-14h]@12
+
+  uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
+  if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
+    uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
+  uTextureID_507B04 = uTextureID_right_panel;
+  v30 = 0;
+  uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
+  uTextureID_5118C8 = uTextureID_506438;
+  do
+  {
+    v42 = v30 + 1;
+    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;
+      else
+        v3 = (v2 != 0) + 1;
+      wsprintfA(pContainer, "pc23v%dBod", v3);
+      papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "pc23v%dlad", v3);
+      papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "pc23v%dlau", v3);
+      papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "pc23v%drh", v3);
+      papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "pc23v%dlh", v3);
+      papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "pc23v%dlhu", v3);
+      papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      v4 = pPlayers[v0 + 1];
+      v5 = v4->uFace;
+      if ( v5 == 12 || v5 == 13 )
+        papredoll_dbrds[(char)v5] = 0;
+      papredoll_flying_feet[v4->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_dlhus[v30] = v7;
+      v9 = (char *)&v8->uFace;
+      v10 = *v9;
+      if ( *v9 == 12 || v10 == 13 )
+      {
+        wsprintfA(pContainer, "pc%02dbrd", v10 + 1);
+        v9 = (char *)&pPlayers[v6 + 1]->uFace;
+        papredoll_dbrds[*v9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      }
+      wsprintfA(pContainer, "item281pc%02d", *v9 + 1);
+      papredoll_flying_feet[pPlayers[v6 + 1]->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      IsPlayerWearingWatersuit[v30 + 1] = 0;
+    }
+    ++v30;
+  }
+  while ( v42 < 4 );
+  uTextureID_ar_up_up = pIcons_LOD->LoadTexture("ar_up_up", TEXTURE_16BIT_PALETTE);
+  uTextureID_ar_up_dn = pIcons_LOD->LoadTexture("ar_up_dn", TEXTURE_16BIT_PALETTE);
+  uTextureID_ar_dn_up = pIcons_LOD->LoadTexture("ar_dn_up", TEXTURE_16BIT_PALETTE);
+  uTextureID_ar_dn_dn = pIcons_LOD->LoadTexture("ar_dn_dn", TEXTURE_16BIT_PALETTE);
+  papredoll_dbrds[9] = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
+  papredoll_dbrds[7] = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
+  papredoll_dbrds[5] = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
+  papredoll_dbrds[3] = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
+  papredoll_dbrds[1] = pIcons_LOD->LoadTexture("ib-cd5-d", TEXTURE_16BIT_PALETTE);
+  v11 = 0;
+  do
+  {
+    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 )
+          goto LABEL_28;
+      }
+    }
+    byte_5111C0[v11] = 1;
+LABEL_28:
+    ++v11;
+  }
+  while ( v11 < 54 );
+  *(int *)byte_5111F6 = 0;
+  *(int *)&byte_5111F6[4] = 0;
+  *(int *)&byte_5111F6[8] = 0;
+  *(int *)&byte_5111F6[12] = 0;
+  *(int *)&byte_5111F6[16] = 0;
+  v13 = pParty->pPlayers;
+  v14 = 1;
+  do
+  {
+    if ( sub_43EE15_player_has_item(0x204u, v13, 1) )
+      byte_5111F6[2] = 1;
+    if ( sub_43EE15_player_has_item(0x1F8u, v13, 1) )
+      byte_5111F6[0] = 1;
+    if ( sub_43EE15_player_has_item(0x1F9u, v13, 1) )
+      byte_5111F6[1] = 1;
+    if ( sub_43EE15_player_has_item(0x215u, v13, 1) )
+      byte_5111F6[16] = 1;
+    if ( sub_43EE15_player_has_item(0x200u, v13, 1) )
+      byte_5111F6[3] = 1;
+    if ( sub_43EE15_player_has_item(0x209u, v13, 1) )
+      byte_5111F6[4] = 1;
+    if ( sub_43EE15_player_has_item(0x20Au, v13, 1) )
+      byte_5111F6[5] = 1;
+    if ( sub_43EE15_player_has_item(0x20Bu, v13, 1) )
+      byte_5111F6[6] = 1;
+    if ( sub_43EE15_player_has_item(0x214u, v13, 1) )
+      byte_5111F6[7] = 1;
+    if ( sub_43EE15_player_has_item(0x220u, v13, 1) )
+      byte_5111F6[8] = 1;
+    if ( sub_43EE15_player_has_item(0x20Cu, v13, 1) )
+      byte_5111F6[9] = 1;
+    if ( sub_43EE15_player_has_item(0x217u, v13, 1) )
+      byte_5111F6[10] = 1;
+    if ( sub_43EE15_player_has_item(0x20Du, v13, 1) )
+      byte_5111F6[11] = 1;
+    if ( sub_43EE15_player_has_item(0x212u, v13, 1) )
+      byte_5111F6[12] = 1;
+    if ( sub_43EE15_player_has_item(0x223u, v13, 1) )
+      byte_5111F6[13] = 1;
+    if ( sub_43EE15_player_has_item(0x224u, v13, 1) )
+      byte_5111F6[14] = 1;
+    if ( sub_43EE15_player_has_item(0x226u, v13, 1) )
+      byte_5111F6[15] = 1;
+    ++v13;
+  }
+  while ( (signed int)v13 < (signed int)pParty->pHirelings );
+  v15 = &stru_511698.field_2C;
+  v35 = (char *)&stru_511718.field_18;
+  do
+  {
+    v16 = 0;
+    v39 = (unsigned int *)(v35 - 24);
+    do
+    {
+      _43C91D_FormItemTextureFilename(pContainer, v16 + 100, v14, 0);
+      v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      ++v16;
+      v18 = v39;
+      ++v39;
+      *v18 = v17;
+    }
+    while ( v16 < 5 );
+    _43C91D_FormItemTextureFilename(pContainer, 535, v14, 0);
+    v31 = 0;
+    v19 = (unsigned int *)((char *)v15 - 44);
+    *(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    do
+    {
+      _43C91D_FormItemTextureFilename(pContainer, v31++ + 89, v14, 0);
+      *v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      ++v19;
+    }
+    while ( v31 < 11 );
+    _43C91D_FormItemTextureFilename(pContainer, 521, v14, 0);
+    v15->field_0 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 522, v14, 0);
+    v15->field_4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 523, v14, 0);
+    v15->field_8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 532, v14, 0);
+    v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0);
+    v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    if ( _43ED6F_check_party_races(true) )
+      papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE);
+    v35 += 28;
+    ++v14;
+    ++v15;
+  }
+  while ( v14 - 1 < 2 );
+  v43 = 0;
+  v20 = 1;
+  v40 = &dword_511638[0][5];
+  v21 = (int)paperdoll_array_511290[0][13];
+  v41 = (unsigned int *)&stru_511718.texid1;
+  do
+  {
+    if ( sub_43EDB9_get_some_race_sex_relation_2(v20 - 1) )
+    {
+      _43C91D_FormItemTextureFilename(pContainer, 524, v20, 0);
+      v32 = 66;
+      *v41 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      v36 = v21 - 152;
+      do
+      {
+        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 0);
+        *(int *)(v36 - 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 1);
+        *(int *)v36 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 2);
+        v22 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        v23 = v36;
+        v36 += 12;
+        ++v32;
+        *(int *)(v23 + 4) = v22;
+      }
+      while ( v32 - 66 < 13 );
+      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 0);
+      *(int *)v21 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 1);
+      *(int *)(v21 + 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 2);
+      *(int *)(v21 + 8) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 0);
+      *(int *)(v21 + 12) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 1);
+      *(int *)(v21 + 16) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 2);
+      *(int *)(v21 + 20) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 0);
+      *(int *)(v21 + 24) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 1);
+      *(int *)(v21 + 28) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 2);
+      *(int *)(v21 + 32) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 0);
+      *(int *)(v21 + 36) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 1);
+      *(int *)(v21 + 40) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 2);
+      *(int *)(v21 + 44) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      v33 = 0;
+      v37 = (int)(v40 - 5);
+      do
+      {
+        _43C91D_FormItemTextureFilename(pContainer, v33 + 115, v20, 0);
+        v24 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        ++v33;
+        v25 = v37;
+        v37 += 4;
+        *(int *)v25 = v24;
+      }
+      while ( v33 < 5 );
+      _43C91D_FormItemTextureFilename(pContainer, 512, v20, 0);
+      v26 = v43;
+      v38 = 105;
+      v34 = v43;
+      *v40 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      do
+      {
+        _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
+        *(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;
+        v34 += 4;
+        ++v38;
+        *(int *)((char *)dword_511788 + v28) = v27;
+      }
+      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);
+      _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
+      *(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);
+      _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
+      *(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);
+      _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
+      *(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);
+      _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
+      *(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);
+      _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
+      *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(
+                                                pContainer,
+                                                TEXTURE_16BIT_PALETTE);
+    }
+    else
+    {
+      v26 = v43;
+    }
+    v41 += 7;
+    v40 += 6;
+    v21 += 204;
+    ++v20;
+    result = v20 - 1;
+    v43 = v26 + 40;
+  }
+  while ( v20 - 1 < 4 );
+  return result;
+}
+
+
+
+//----- (0043C91D) --------------------------------------------------------
+int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4)
+{
+  int result; // eax@2
+  char v5; // zf@3
+  const char *v6; // [sp-Ch] [bp-18h]@88
+  signed int v7; // [sp-8h] [bp-14h]@61
+  int v8; // [sp-4h] [bp-10h]@61
+  signed int v9; // [sp-4h] [bp-10h]@69
+
+  result = 0; //BUG   fn is void
+  if ( a2 <= 500 )
+  {
+    //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
+    v5 = byte_5111C0[(a2 - 100) + 32 + 2] == 0;
+LABEL_21:
+    if ( v5 )
+      return result;
+    result = 516;
+    if ( a2 < 66 || a2 > 78 )
+    {
+      if ( a2 == 516 )
+        goto LABEL_79;
+      if ( a2 != 504 && a2 != 505 && a2 != 533 )
+      {
+        if ( (a2 < 100 || a2 > 104) && a2 != 524 && a2 != 535 )
+        {
+          if ( a2 >= 115 && a2 <= 119 || a2 == 512 )
+          {
+            if ( a2 == 512 )
+              a2 = 312;
+            goto LABEL_87;
+          }
+          if ( (a2 < 89 || a2 > 99) && a2 != 521 && a2 != 522 && a2 != 523 && a2 != 532 && a2 != 544 )
+          {
+            result = 525;
+            if ( (a2 < 105 || a2 > 109) && a2 != 525 && a2 != 530 && a2 != 547 && a2 != 548 && a2 != 550 )
+              return result;
+            switch ( a2 )
+            {
+              case 525:
+                a2 = 325;
+                break;
+              case 530:
+                a2 = 330;
+                break;
+              case 547:
+                a2 = 347;
+                break;
+              case 548:
+                a2 = 348;
+                break;
+              case 550:
+                a2 = 350;
+                break;
+            }
+            v8 = a3;
+            v7 = a2;
+            if ( !a4 )
+              goto LABEL_88;
+LABEL_91:
+            v6 = "item%3.3dv%da1";
+            return sprintf(a1, v6, v7, v8);
+          }
+          if ( a2 == 521 )
+          {
+            a2 = 239;
+            goto LABEL_87;
+          }
+          if ( a2 == 522 )
+          {
+            a2 = 240;
+            goto LABEL_87;
+          }
+          if ( a2 == 523 )
+          {
+            a2 = 241;
+            goto LABEL_87;
+          }
+          if ( a2 != 532 )
+          {
+            if ( a2 == 544 )
+              a2 = 344;
+            goto LABEL_87;
+          }
+          v9 = 93;
+          goto LABEL_70;
+        }
+        if ( a2 == 524 )
+        {
+          a2 = 324;
+          goto LABEL_87;
+        }
+        if ( a2 == 535 )
+        {
+          v9 = 104;
+LABEL_70:
+          a2 = v9;
+        }
+LABEL_87:
+        v8 = a3;
+        v7 = a2;
+LABEL_88:
+        v6 = "item%3.3dv%d";
+        return sprintf(a1, v6, v7, v8);
+      }
+    }
+    if ( a2 != 516 )
+    {
+      switch ( a2 )
+      {
+        case 504:
+          a2 = 235;
+          break;
+        case 505:
+          a2 = 236;
+          break;
+        case 533:
+          a2 = 73;
+          break;
+      }
+LABEL_86:
+      if ( a4 )
+      {
+        if ( a4 != 1 )
+        {
+          if ( a4 != 2 )
+            return result;
+          v8 = a3;
+          v7 = a2;
+          v6 = "item%3.3dv%da2";
+          return sprintf(a1, v6, v7, v8);
+        }
+        v8 = a3;
+        v7 = a2;
+        goto LABEL_91;
+      }
+      goto LABEL_87;
+    }
+LABEL_79:
+    a2 = 234;
+    goto LABEL_86;
+  }
+  result = a2 - 504;
+  switch ( a2 )
+  {
+    case 516:
+      v5 = byte_5111F6[2] == 0;
+      goto LABEL_21;
+    case 505:
+      v5 = byte_5111F6[1] == 0;
+      goto LABEL_21;
+    case 504:
+      v5 = byte_5111F6[0] == 0;
+      goto LABEL_21;
+    case 533:
+      v5 = byte_5111F6[16] == 0;
+      goto LABEL_21;
+    case 512:
+      v5 = byte_5111F6[3] == 0;
+      goto LABEL_21;
+    case 521:
+      v5 = byte_5111F6[4] == 0;
+      goto LABEL_21;
+    case 522:
+      v5 = byte_5111F6[5] == 0;
+      goto LABEL_21;
+    case 523:
+      v5 = byte_5111F6[6] == 0;
+      goto LABEL_21;
+    case 532:
+      v5 = byte_5111F6[7] == 0;
+      goto LABEL_21;
+    case 544:
+      v5 = byte_5111F6[8] == 0;
+      goto LABEL_21;
+    case 524:
+      v5 = byte_5111F6[9] == 0;
+      goto LABEL_21;
+    case 535:
+      v5 = byte_5111F6[10] == 0;
+      goto LABEL_21;
+    case 525:
+      v5 = byte_5111F6[11] == 0;
+      goto LABEL_21;
+    case 530:
+      v5 = byte_5111F6[12] == 0;
+      goto LABEL_21;
+    case 547:
+      v5 = byte_5111F6[13] == 0;
+      goto LABEL_21;
+    case 548:
+      v5 = byte_5111F6[14] == 0;
+      goto LABEL_21;
+    case 550:
+      v5 = byte_5111F6[15] == 0;
+      goto LABEL_21;
+    default:
+      return result;
+  }
+  return result;
+}
+
+//----- (0043CC7C) --------------------------------------------------------
+void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID)
+{
+  Player **ppPlayer; // esi@1
+  Player *pPlayer; // ebx@1
+  enum CHARACTER_RACE v3; // edi@1
+  signed int v4; // eax@1
+  int v5; // edi@4
+  unsigned int v6; // ecx@9
+  int v7; // ecx@10
+  unsigned int v8; // eax@14
+  int v9; // eax@15
+  int v10; // edx@15
+  int v11; // ecx@15
+  int v12; // eax@15
+  unsigned int v13; // edi@15
+  unsigned int v14; // ebx@18
+  int v15; // ecx@18
+  Texture *v16; // ebp@27
+  double v17; // st7@29
+  int v18; // edi@30
+  char *v19; // eax@30
+  Texture *v20; // edi@31
+  unsigned int v21; // eax@37
+  int v22; // edi@38
+  int v23; // eax@38
+  int v24; // ebx@38
+  int v25; // eax@38
+  LODFile_IconsBitmaps *v26; // ecx@42
+  Texture *v27; // edi@51
+  double v28; // st7@51
+  char v29; // zf@54
+  char *v30; // eax@54
+  unsigned int v31; // eax@59
+  int v32; // edx@60
+  int v33; // eax@65
+  int v34; // eax@74
+  int v35; // ebx@74
+  unsigned int v36; // ecx@74
+  int v37; // eax@74
+  LODFile_IconsBitmaps *v38; // ecx@78
+  Texture *v39; // edi@85
+  double v40; // st7@87
+  int v41; // edi@88
+  Texture *v42; // edi@89
+  unsigned int v43; // eax@93
+  int v44; // edx@94
+  int v45; // eax@98
+  int v46; // eax@106
+  int v47; // ecx@106
+  int v48; // ebx@106
+  int v49; // eax@106
+  LODFile_IconsBitmaps *v50; // ecx@110
+  Texture *v51; // edi@117
+  double v52; // st7@119
+  int v53; // edi@120
+  Texture *v54; // edi@121
+  char *v55; // eax@122
+  unsigned int v56; // eax@127
+  int v57; // edi@128
+  int v58; // ecx@128
+  int v59; // ebx@129
+  int v60; // ecx@132
+  int v61; // eax@134
+  int v62; // ecx@136
+  Texture *v63; // edi@145
+  double v64; // st7@147
+  int v65; // edi@148
+  char *v66; // eax@148
+  Texture *v67; // edi@149
+  Player *v68; // ebx@155
+  unsigned int v69; // edx@155
+  int v70; // edx@156
+  unsigned int v71; // eax@160
+  int v72; // edi@161
+  int v73; // edx@163
+  int v74; // ecx@168
+  unsigned int v75; // ebx@170
+  int v76; // ecx@172
+  Texture *v77; // edi@181
+  double v78; // st7@183
+  int v79; // edi@184
+  char *v80; // eax@184
+  Texture *v81; // edi@185
+  unsigned int v82; // eax@192
+  int v83; // eax@193
+  int v84; // eax@197
+  int v85; // eax@197
+  int v86; // ecx@197
+  int v87; // eax@197
+  int v88; // eax@198
+  int v89; // eax@199
+  int v90; // edi@201
+  int v91; // edi@213
+  int v92; // ebx@213
+  int v93; // edi@214
+  int v94; // ebx@214
+  int v95; // eax@214
+  char *v96; // edi@226
+  double v97; // st7@228
+  int v98; // edi@229
+  char *v99; // eax@229
+  Render *v100; // ecx@229
+  Texture *v101; // edi@230
+  int v102; // edi@236
+  int v103; // eax@237
+  int v104; // ecx@237
+  int v105; // edx@237
+  int v106; // edx@238
+  int v107; // edx@239
+  int v108; // edx@240
+  int v109; // edi@250
+  char *v110; // edx@250
+  unsigned int v111; // eax@259
+  int v112; // eax@260
+  int v113; // eax@260
+  int v114; // eax@265
+  int v115; // eax@274
+  int v116; // ebx@274
+  unsigned int v117; // edi@274
+  double v118; // st7@286
+  int v119; // edi@287
+  char *v120; // eax@287
+  Texture *v121; // edi@288
+  unsigned int v122; // edi@295
+  int v123; // ebx@297
+  int v124; // edi@298
+  int v125; // ecx@303
+  int v126; // eax@312
+  unsigned int v127; // ebx@314
+  int v128; // ecx@316
+  Texture *v129; // edi@325
+  double v130; // st7@327
+  int v131; // edi@328
+  char *v132; // eax@328
+  Texture *v133; // edi@329
+  unsigned int v134; // eax@335
+  int v135; // eax@336
+  int v136; // edx@336
+  int v137; // eax@336
+  unsigned int v138; // ebx@339
+  int v139; // ecx@339
+  Texture *v140; // edi@348
+  double v141; // st7@350
+  int v142; // edi@351
+  char *v143; // eax@351
+  Texture *v144; // edi@352
+  unsigned int v145; // eax@358
+  int v146; // eax@359
+  int v147; // ecx@359
+  int v148; // eax@359
+  int v149; // edx@359
+  int v150; // ebx@362
+  int v151; // ecx@363
+  int v152; // ecx@364
+  unsigned int v153; // eax@370
+  unsigned int v154; // edi@370
+  int v155; // eax@370
+  LODFile_IconsBitmaps *v156; // ecx@374
+  Texture *v157; // ebp@381
+  double v158; // st7@383
+  Texture *v159; // edi@385
+  char *v160; // eax@386
+  unsigned int v161; // eax@393
+  int v162; // eax@394
+  unsigned int v163; // [sp-Ch] [bp-58h]@230
+  unsigned int v164; // [sp-Ch] [bp-58h]@233
+  signed int v165; // [sp-Ch] [bp-58h]@235
+  char *v166; // [sp-8h] [bp-54h]@16
+  const char *v167; // [sp-8h] [bp-54h]@23
+  const char *v168; // [sp-8h] [bp-54h]@43
+  const char *v169; // [sp-8h] [bp-54h]@79
+  const char *v170; // [sp-8h] [bp-54h]@111
+  const char *v171; // [sp-8h] [bp-54h]@141
+  const char *v172; // [sp-8h] [bp-54h]@177
+  const char *v173; // [sp-8h] [bp-54h]@222
+  int v174; // [sp-8h] [bp-54h]@228
+  unsigned int v175; // [sp-8h] [bp-54h]@230
+  unsigned int v176; // [sp-8h] [bp-54h]@233
+  signed int v177; // [sp-8h] [bp-54h]@235
+  const char *v178; // [sp-8h] [bp-54h]@242
+  const char *v179; // [sp-8h] [bp-54h]@280
+  const char *v180; // [sp-8h] [bp-54h]@321
+  char *v181; // [sp-8h] [bp-54h]@337
+  const char *v182; // [sp-8h] [bp-54h]@344
+  const char *v183; // [sp-8h] [bp-54h]@375
+  signed int v184; // [sp-4h] [bp-50h]@66
+  signed int v185; // [sp-4h] [bp-50h]@99
+  signed int v186; // [sp-4h] [bp-50h]@202
+  int v187; // [sp-4h] [bp-50h]@228
+  Texture *v188; // [sp-4h] [bp-50h]@230
+  Texture *v189; // [sp-4h] [bp-50h]@233
+  Texture *v190; // [sp-4h] [bp-50h]@235
+  signed int v191; // [sp-4h] [bp-50h]@266
+  signed int v192; // [sp-4h] [bp-50h]@304
+  unsigned int a3; // [sp+10h] [bp-3Ch]@7
+  int a3a; // [sp+10h] [bp-3Ch]@15
+  int a3b; // [sp+10h] [bp-3Ch]@38
+  unsigned int a3c; // [sp+10h] [bp-3Ch]@74
+  unsigned int a3d; // [sp+10h] [bp-3Ch]@106
+  int a3e; // [sp+10h] [bp-3Ch]@129
+  int a3f; // [sp+10h] [bp-3Ch]@168
+  unsigned int a3g; // [sp+10h] [bp-3Ch]@216
+  unsigned int a3h; // [sp+10h] [bp-3Ch]@274
+  int a3i; // [sp+10h] [bp-3Ch]@312
+  int a3j; // [sp+10h] [bp-3Ch]@336
+  int a3k; // [sp+10h] [bp-3Ch]@362
+  signed int a2; // [sp+14h] [bp-38h]@7
+  unsigned int a2a; // [sp+14h] [bp-38h]@15
+  Texture *a2b; // [sp+14h] [bp-38h]@49
+  int a2c; // [sp+14h] [bp-38h]@74
+  int a2d; // [sp+14h] [bp-38h]@106
+  int a2e; // [sp+14h] [bp-38h]@129
+  int a2f; // [sp+14h] [bp-38h]@168
+  int a2g; // [sp+14h] [bp-38h]@214
+  int a2h; // [sp+14h] [bp-38h]@274
+  Texture *a2i; // [sp+14h] [bp-38h]@284
+  int a2j; // [sp+14h] [bp-38h]@312
+  int a2k; // [sp+14h] [bp-38h]@336
+  Player *v217; // [sp+18h] [bp-34h]@1
+  int v218; // [sp+1Ch] [bp-30h]@15
+  int v219; // [sp+1Ch] [bp-30h]@60
+  int v220; // [sp+1Ch] [bp-30h]@94
+  int v221; // [sp+1Ch] [bp-30h]@128
+  int v222; // [sp+1Ch] [bp-30h]@161
+  int v223; // [sp+1Ch] [bp-30h]@213
+  char v224; // [sp+1Ch] [bp-30h]@237
+  int v225; // [sp+1Ch] [bp-30h]@260
+  int v226; // [sp+1Ch] [bp-30h]@298
+  int v227; // [sp+1Ch] [bp-30h]@336
+  int v228; // [sp+1Ch] [bp-30h]@359
+  int v229; // [sp+20h] [bp-2Ch]@15
+  int v230; // [sp+20h] [bp-2Ch]@38
+  int v231; // [sp+20h] [bp-2Ch]@60
+  int v232; // [sp+20h] [bp-2Ch]@94
+  int v233; // [sp+20h] [bp-2Ch]@128
+  int v234; // [sp+20h] [bp-2Ch]@161
+  int v235; // [sp+20h] [bp-2Ch]@197
+  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 v240; // [sp+28h] [bp-24h]@7
+  unsigned int v241; // [sp+2Ch] [bp-20h]@38
+  int v242; // [sp+2Ch] [bp-20h]@197
+  unsigned int v243; // [sp+2Ch] [bp-20h]@370
+  int v244; // [sp+34h] [bp-18h]@6
+  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
+  int v249; // [sp+40h] [bp-Ch]@358
+  signed int v250; // [sp+44h] [bp-8h]@1
+
+  ppPlayer = &pPlayers[uPlayerID];
+  pPlayer = *ppPlayer;
+  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;
+  v244 = (*ppPlayer)->uFace;
+  pRenderer->ResetClip();
+  pRenderer->DrawTextureIndexed(
+    0x1D3u,
+    0,
+    (Texture *)(uTextureID_BACKDOLL != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BACKDOLL] : 0));
+  if ( !IsPlayerWearingWatersuit[uPlayerID_] )
+  {
+    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;
+    v241 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v23].pIconName, TEXTURE_16BIT_PALETTE);
+    v25 = *(int *)(v22 + 20);
+    if ( !(*(int *)(v22 + 20) & 0xF0) )
+    {
+      if ( v25 & 2 )
+      {
+        v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
+        pRenderer->_4A6776(v24, a3b, v27);
+      }
+      else
+      {
+        v29 = (v25 & 1) == 0;
+        v30 = (char *)&pIcons_LOD->pTextures[v241];
+        if ( v29 )
+        {
+          v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
+          pRenderer->DrawTransparentGreenShade(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
+        }
+        else
+        {
+          v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
+          pRenderer->DrawTextureTransparent(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
+        }
+      }
+LABEL_57:
+      if ( !bRingsShownInCharScreen )
+        pRenderer->_4A612A(v24, a3b, v27, v230);
+LABEL_59:
+      v31 = v217->pEquipment.uCloak;
+      if ( !v31 )
+        goto LABEL_93;
+      v231 = v217->pEquipment.uCloak;
+      v32 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v31 + 5];
+      v219 = v32;
+      if ( *(int *)v32 != 525 )
+      {
+        switch ( *(int *)v32 )
+        {
+          case 0x212:
+            v184 = 6;
+            break;
+          case 0x223:
+            v184 = 7;
+            break;
+          case 0x224:
+            v184 = 8;
+            break;
+          default:
+            if ( *(int *)v32 != 550 )
+            {
+              v33 = *(int *)v32 - 105;
+LABEL_72:
+              if ( v33 < 0 || v33 >= 10 )
+                goto LABEL_93;
+LABEL_74:
+              v34 = v33 + 10 * v239;
+              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];
+              v37 = *(int *)(v32 + 20);
+              a3c = v36;
+              if ( !(v37 & 0xF0) )
+              {
+                v41 = v35 + 1;
+                if ( v37 & 2 )
+                {
+                  v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
+                  pRenderer->_4A6776(a2c, v36, v42);
+                }
+                else
+                {
+                  v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
+                  pRenderer->DrawTextureTransparent(a2c, v36, v42);
+                }
+                if ( !bRingsShownInCharScreen )
+                  pRenderer->_4A612A(a2c, a3c, v42, v231);
+LABEL_93:
+                v240 = 4 * uPlayerID_ - 4;
+                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;
+                if ( !v43 )
+                  goto LABEL_127;
+                v232 = v217->pEquipment.uBody;
+                v44 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v43 + 5];
+                v220 = v44;
+                if ( *(int *)v44 != 504 )
+                {
+                  if ( *(int *)v44 == 505 )
+                  {
+                    v185 = 14;
+                  }
+                  else
+                  {
+                    if ( *(int *)v44 == 516 )
+                    {
+                      v185 = 13;
+                    }
+                    else
+                    {
+                      if ( *(int *)v44 != 533 )
+                      {
+                        v45 = *(int *)v44 - 66;
+LABEL_104:
+                        if ( v45 < 0 || v45 >= 17 )
+                          goto LABEL_127;
+LABEL_106:
+                        v46 = 17 * v239 + 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];
+                        v49 = *(int *)(v44 + 20);
+                        a3d = v47;
+                        if ( !(v49 & 0xF0) )
+                        {
+                          v53 = v48 + 1;
+                          if ( v49 & 2 )
+                          {
+                            v54 = (Texture *)(v53 != 0 ? (int)&pIcons_LOD->pTextures[v48] : 0);
+                            pRenderer->_4A6776(a2d, v47, v54);
+                          }
+                          else
+                          {
+                            v29 = (v49 & 1) == 0;
+                            v55 = (char *)&pIcons_LOD->pTextures[v48];
+                            if ( v29 )
+                            {
+                              v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
+                              pRenderer->DrawTransparentGreenShade(a2d, v47, v54);
+                            }
+                            else
+                            {
+                              v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
+                              pRenderer->DrawTextureTransparent(a2d, v47, v54);
+                            }
+                          }
+                          if ( !bRingsShownInCharScreen )
+                            pRenderer->_4A612A(a2d, a3d, v54, v232);
+LABEL_127:
+                          v56 = v217->pEquipment.field_20;
+                          if ( !v56 )
+                            goto LABEL_155;
+                          v233 = v217->pEquipment.field_20;
+                          v57 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v56 + 5];
+                          v221 = v57;
+                          v58 = *(int *)v57;
+                          if ( *(int *)v57 == 529 )
+                          {
+                            a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][1];
+                            a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][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];
+                            }
+                            else
+                            {
+                              v60 = v58 - 115;
+                              if ( v60 < 0 || v60 >= 5 )
+                              {
+                                a2e = 0;
+                                a3e = 0;
+                                v59 = dword_511638[v239][0];
+                              }
+                              else
+                              {
+                                v61 = v60 + 7 * v239;
+                                a3e = paperdoll_4E4C2C + dword_4E5490[0][v61][1];
+                                a2e = papredoll_4E4C28 + dword_4E5490[0][v61][0];
+                                v59 = dword_511638[0][v60 + 6 * v239];
+                              }
+                            }
+                          }
+                          v62 = *(int *)(v57 + 20);
+                          if ( !(*(int *)(v57 + 20) & 0xF0) )
+                          {
+                            v65 = v59 + 1;
+                            v66 = (char *)&pIcons_LOD->pTextures[v59];
+                            if ( v62 & 2 )
+                            {
+                              v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
+                              pRenderer->_4A6776(a2e, a3e, v67);
+                            }
+                            else
+                            {
+                              if ( v62 & 1 )
+                              {
+                                v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
+                                pRenderer->DrawTextureTransparent(a2e, a3e, v67);
+                              }
+                              else
+                              {
+                                v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
+                                pRenderer->DrawTransparentGreenShade(a2e, a3e, v67);
+                              }
+                            }
+                            if ( !bRingsShownInCharScreen )
+                              pRenderer->_4A612A(a2e, a3e, v67, v233);
+LABEL_155:
+                            v68 = v217;
+                            v69 = v217->pEquipment.uMainHand;
+                            uPlayerID_a = 2 * v239;
+                            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],
+                                (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 )
+                            {
+                              v234 = v217->pEquipment.uBelt;
+                              v72 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v71 + 5];
+                              v222 = v72;
+                              if ( *(int *)v72 == 524 )
+                              {
+                                v73 = 5;
+                              }
+                              else
+                              {
+                                if ( *(int *)v72 == 535 )
+                                {
+                                  v73 = 6;
+                                  goto LABEL_168;
+                                }
+                                v73 = *(int *)v72 - 100;
+                              }
+                              if ( v73 >= 0 && v73 < 7 )
+                              {
+LABEL_168:
+                                v74 = 7 * v239 + v73;
+                                a2f = papredoll_4E4C28 + dword_4E57F0[0][v74][0];
+                                a3f = paperdoll_4E4C2C + dword_4E57F0[0][v74][1];
+                                if ( v248 != 1 || v73 == 5 )
+                                  v75 = stru_511718.texids[v74];
+                                else
+                                  v75 = stru_511718.texids[v73 + 7 * (v239 - 2)];
+                                v76 = *(int *)&v217->field_1F5[36 * v71 + 15];
+                                if ( !(*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) )
+                                {
+                                  v79 = v75 + 1;
+                                  v80 = (char *)&pIcons_LOD->pTextures[v75];
+                                  if ( v76 & 2 )
+                                  {
+                                    v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
+                                    pRenderer->_4A6776(a2f, a3f, v81);
+                                  }
+                                  else
+                                  {
+                                    if ( v76 & 1 )
+                                    {
+                                      v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
+                                      pRenderer->DrawTextureTransparent(a2f, a3f, v81);
+                                    }
+                                    else
+                                    {
+                                      v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
+                                      pRenderer->DrawTransparentGreenShade(a2f, a3f, v81);
+                                    }
+                                  }
+                                  if ( !bRingsShownInCharScreen )
+                                    pRenderer->_4A612A(a2f, a3f, v81, v234);
+                                  goto LABEL_191;
+                                }
+                                if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) != 16 )
+                                {
+                                  if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 32 )
+                                  {
+                                    v172 = "sp28a";
+                                    goto LABEL_181;
+                                  }
+                                  if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 64 )
+                                  {
+                                    v172 = "sp30a";
+                                    goto LABEL_181;
+                                  }
+                                  if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 128 )
+                                  {
+                                    v172 = "sp91a";
+LABEL_181:
+                                    v77 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v172, TEXTURE_16BIT_PALETTE)];
+                                    dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                    if ( dword_50C9A8 <= 0 )
+                                    {
+                                      dword_50C9A8 = 0;
+                                      *(char *)(v222 + 20) &= 0xFu;
+                                      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);
+LABEL_191:
+                                    v68 = v217;
+                                    goto LABEL_192;
+                                  }
+                                }
+                                v172 = "sptext01";
+                                goto LABEL_181;
+                              }
+                            }
+LABEL_192:
+                            v82 = v68->pEquipment.uMainHand;
+                            if ( v82 )
+                            {
+                              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],
+                                  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));
+                            }
+                            v84 = v68->pEquipment.uBody;
+                            v235 = v84;
+                            v85 = (int)((char *)v68 + 36 * v84);
+                            v242 = v85;
+                            v86 = *(int *)(v85 + 496);
+                            v87 = *(int *)(v85 + 496) - 504;
+                            if ( v87 )
+                            {
+                              v88 = v87 - 1;
+                              if ( v88 )
+                              {
+                                v89 = v88 - 11;
+                                if ( v89 )
+                                {
+                                  if ( v89 != 17 )
+                                  {
+                                    v90 = v86 - 66;
+LABEL_207:
+                                    if ( v90 < 0 || v90 > 17 )
+                                    {
+LABEL_259:
+                                      v111 = v68->pEquipment.uCloak;
+                                      if ( !v111 )
+                                        goto LABEL_293;
+                                      v236 = v68->pEquipment.uCloak;
+                                      v112 = (int)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v111 + 5];
+                                      v225 = v112;
+                                      v113 = *(int *)v112;
+                                      if ( v113 != 525 )
+                                      {
+                                        switch ( v113 )
+                                        {
+                                          case 530:
+                                            v191 = 6;
+                                            break;
+                                          case 547:
+                                            v191 = 7;
+                                            break;
+                                          case 548:
+                                            v191 = 8;
+                                            break;
+                                          default:
+                                            if ( v113 != 550 )
+                                            {
+                                              v114 = v113 - 105;
+LABEL_272:
+                                              if ( v114 < 0 || v114 >= 10 )
+                                                goto LABEL_293;
+LABEL_274:
+                                              v115 = v114 + 10 * v239;
+                                              v116 = dword_511788[v115];
+                                              v115 *= 8;
+                                              v117 = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
+                                              a2h = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
+                                              a3h = paperdoll_4E4C2C + *(int *)((char *)&dword_4E56B4 + v115);
+                                              if ( v116 == pIcons_LOD->FindTextureByName("pending") )
+                                              {
+LABEL_292:
+                                                v68 = v217;
+LABEL_293:
+                                                if ( v244 == 12 || v244 == 13 )
+                                                {
+                                                  v122 = papredoll_dbrds[v244];
+                                                  if ( v122 != pIcons_LOD->FindTextureByName("Pending") )
+                                                    pRenderer->DrawTextureTransparent(
+                                                      papredoll_4E4C28 + dword_4E5AD0[2 * v244 - 24],
+                                                      paperdoll_4E4C2C + dword_4E5AD4[2 * v244 - 24],
+                                                      (Texture *)(v122 != -1 ? (int)&pIcons_LOD->pTextures[v122] : 0));
+                                                }
+                                                v123 = v68->pEquipment.uHelm;
+                                                if ( !v123 )
+                                                  goto LABEL_335;
+                                                v237 = v123;
+                                                v124 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v123 + 5];
+                                                v226 = v124;
+                                                if ( *(int *)v124 != 521 )
+                                                {
+                                                  switch ( *(int *)v124 )
+                                                  {
+                                                    case 0x20A:
+                                                      v192 = 12;
+                                                      break;
+                                                    case 0x20B:
+                                                      v192 = 13;
+                                                      break;
+                                                    case 0x214:
+                                                      v192 = 14;
+                                                      break;
+                                                    default:
+                                                      if ( *(int *)v124 != 544 )
+                                                      {
+                                                        v125 = *(int *)v124 - 89;
+LABEL_310:
+                                                        if ( v125 < 0 || v125 >= 16 )
+                                                          goto LABEL_335;
+                                                        goto LABEL_312;
+                                                      }
+                                                      v192 = 15;
+                                                      break;
+                                                  }
+                                                  v125 = v192;
+LABEL_312:
+                                                  v126 = 2 * (v125 + 16 * v239);
+                                                  a2j = papredoll_4E4C28 + dword_4E58D0[v126];
+                                                  a3i = paperdoll_4E4C2C + dword_4E58D4[v126];
+                                                  if ( v248 != 1 || *(int *)v124 != 92 )
+                                                    v127 = stru_511698.texids[v125 + 16 * v250];
+                                                  else
+                                                    v127 = papredoll_dbrds[11];
+                                                  v128 = *(int *)(v124 + 20);
+                                                  if ( *(int *)(v124 + 20) & 0xF0 )
+                                                  {
+                                                    if ( (*(int *)(v124 + 20) & 0xF0) != 16 )
+                                                    {
+                                                      if ( (*(int *)(v124 + 20) & 0xF0) == 32 )
+                                                      {
+                                                        v180 = "sp28a";
+                                                        goto LABEL_325;
+                                                      }
+                                                      if ( (*(int *)(v124 + 20) & 0xF0) == 64 )
+                                                      {
+                                                        v180 = "sp30a";
+                                                        goto LABEL_325;
+                                                      }
+                                                      if ( (*(int *)(v124 + 20) & 0xF0) == 128 )
+                                                      {
+                                                        v180 = "sp91a";
+LABEL_325:
+                                                        v129 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v180, TEXTURE_16BIT_PALETTE)];
+                                                        dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                                        if ( dword_50C9A8 <= 0 )
+                                                        {
+                                                          dword_50C9A8 = 0;
+                                                          *(char *)(v226 + 20) &= 0xFu;
+                                                          ptr_50C9A4 = 0;
+                                                        }
+                                                        v130 = (double)GetTickCount() * 0.1;
+                                                        pRenderer->_4A63E6(
+                                                          a2j,
+                                                          a3i,
+                                                          (Texture *)(v127 != -1 ? (int)&pIcons_LOD->pTextures[v127] : 0),
+                                                          v129,
+                                                          (signed __int64)v130,
+                                                          0,
+                                                          255);
+                                                        goto LABEL_335;
+                                                      }
+                                                    }
+                                                    v180 = "sptext01";
+                                                    goto LABEL_325;
+                                                  }
+                                                  v131 = v127 + 1;
+                                                  v132 = (char *)&pIcons_LOD->pTextures[v127];
+                                                  if ( v128 & 2 )
+                                                  {
+                                                    v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
+                                                    pRenderer->_4A6776(a2j, a3i, v133);
+                                                  }
+                                                  else
+                                                  {
+                                                    if ( v128 & 1 )
+                                                    {
+                                                      v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
+                                                      pRenderer->DrawTextureTransparent(a2j, a3i, v133);
+                                                    }
+                                                    else
+                                                    {
+                                                      v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
+                                                      pRenderer->DrawTransparentGreenShade(a2j, a3i, v133);
+                                                    }
+                                                  }
+                                                  if ( !bRingsShownInCharScreen )
+                                                    pRenderer->_4A612A(a2j, a3i, v133, v237);
+LABEL_335:
+                                                  v134 = v217->pEquipment.uMainHand;
+                                                  if ( !v134 )
+                                                    goto LABEL_358;
+                                                  v238 = v217->pEquipment.uMainHand;
+                                                  v135 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v134 + 5];
+                                                  v227 = v135;
+                                                  v136 = *(int *)v135;
+                                                  v137 = *(int *)v135;
+                                                  a2k = papredoll_4E4C28
+                                                      + array_4E4C30[v239].field_8
+                                                      - pItemsTable->pItems[v137].uEquipX;
+                                                  a3j = paperdoll_4E4C2C
+                                                      + array_4E4C30[v239].field_C
+                                                      - pItemsTable->pItems[v137].uEquipY;
+                                                  if ( v136 == 64 )
+                                                    v181 = "item64v1";
+                                                  else
+                                                    v181 = pItemsTable->pItems[v137].pIconName;
+                                                  v138 = pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE);
+                                                  v139 = *(int *)(v227 + 20);
+                                                  if ( !(*(int *)(v227 + 20) & 0xF0) )
+                                                  {
+                                                    v142 = v138 + 1;
+                                                    v143 = (char *)&pIcons_LOD->pTextures[v138];
+                                                    if ( v139 & 2 )
+                                                    {
+                                                      v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
+                                                      pRenderer->_4A6776(a2k, a3j, v144);
+                                                    }
+                                                    else
+                                                    {
+                                                      if ( v139 & 1 )
+                                                      {
+                                                        v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
+                                                        pRenderer->DrawTextureTransparent(a2k, a3j, v144);
+                                                      }
+                                                      else
+                                                      {
+                                                        v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
+                                                        pRenderer->DrawTransparentGreenShade(a2k, a3j, v144);
+                                                      }
+                                                    }
+                                                    if ( !bRingsShownInCharScreen )
+                                                      pRenderer->_4A612A(a2k, a3j, v144, v238);
+LABEL_358:
+                                                    v145 = v217->pEquipment.uOffHand;
+                                                    v249 = v217->pEquipment.uOffHand;
+                                                    if ( !v145 )
+                                                      goto LABEL_393;
+                                                    v146 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v145 + 5];
+                                                    v228 = v146;
+                                                    v147 = *(int *)v146;
+                                                    v148 = *(int *)v146;
+                                                    v149 = pItemsTable->pItems[v148].uSkillType;
+                                                    if ( v149 != 2 && v149 != 1 )
+                                                    {
+                                                      v245 = 0;
+LABEL_362:
+                                                      v150 = papredoll_4E4C28
+                                                           + array_4E4C30[v239].field_0
+                                                           - pItemsTable->pItems[v148].uEquipX;
+                                                      a3k = paperdoll_4E4C2C
+                                                          + LODWORD(array_4E4C30[v239].field_4)
+                                                          - pItemsTable->pItems[v148].uEquipY;
+                                                      goto LABEL_370;
+                                                    }
+                                                    v151 = v147 - 400;
+                                                    v245 = 1;
+                                                    if ( v151 )
+                                                    {
+                                                      v152 = v151 - 3;
+                                                      if ( v152 )
+                                                      {
+                                                        if ( v152 != 12 )
+                                                          goto LABEL_362;
+                                                        v150 = 595;
+                                                        a3k = 33;
+LABEL_370:
+                                                        v153 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v148].pIconName, TEXTURE_16BIT_PALETTE);
+                                                        v154 = v153;
+                                                        v243 = v153;
+                                                        v155 = *(int *)(v228 + 20);
+                                                        if ( !(*(int *)(v228 + 20) & 0xF0) )
+                                                        {
+                                                          if ( v155 & 2 )
+                                                          {
+                                                            v159 = (Texture *)(v243 != -1 ? (int)&pIcons_LOD->pTextures[v243] : 0);
+                                                            pRenderer->_4A6776(v150, a3k, v159);
+                                                          }
+                                                          else
+                                                          {
+                                                            v29 = (v155 & 1) == 0;
+                                                            v160 = (char *)&pIcons_LOD->pTextures[v243];
+                                                            if ( v29 )
+                                                            {
+                                                              v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
+                                                              pRenderer->DrawTransparentGreenShade(
+                                                                v150,
+                                                                a3k,
+                                                                (Texture *)(v243 != -1 ? (int)v160 : 0));
+                                                            }
+                                                            else
+                                                            {
+                                                              v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
+                                                              pRenderer->DrawTextureTransparent(
+                                                                v150,
+                                                                a3k,
+                                                                (Texture *)(v243 != -1 ? (int)v160 : 0));
+                                                            }
+                                                          }
+                                                          if ( !bRingsShownInCharScreen )
+                                                            pRenderer->_4A612A(v150, a3k, v159, v249);
+                                                          goto LABEL_391;
+                                                        }
+                                                        if ( (*(int *)(v228 + 20) & 0xF0) != 16 )
+                                                        {
+                                                          if ( (*(int *)(v228 + 20) & 0xF0) == 32 )
+                                                          {
+                                                            v183 = "sp28a";
+                                                          }
+                                                          else
+                                                          {
+                                                            if ( (*(int *)(v228 + 20) & 0xF0) != 64 )
+                                                            {
+                                                              v156 = pIcons_LOD;
+                                                              if ( (*(int *)(v228 + 20) & 0xF0) == 128 )
+                                                              {
+                                                                v183 = "sp91a";
+LABEL_381:
+                                                                v157 = &pIcons_LOD->pTextures[v156->LoadTexture(
+                                                                                               v183,
+                                                                                               TEXTURE_16BIT_PALETTE)];
+                                                                dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                                                if ( dword_50C9A8 <= 0 )
+                                                                {
+                                                                  dword_50C9A8 = 0;
+                                                                  *(char *)(v228 + 20) &= 0xFu;
+                                                                  ptr_50C9A4 = 0;
+                                                                }
+                                                                v158 = (double)GetTickCount() * 0.1;
+                                                                pRenderer->_4A63E6(
+                                                                  v150,
+                                                                  a3k,
+                                                                  (Texture *)(v154 != -1 ? (int)&pIcons_LOD->pTextures[v154] : 0),
+                                                                  v157,
+                                                                  (signed __int64)v158,
+                                                                  0,
+                                                                  255);
+LABEL_391:
+                                                                if ( v245 )
+                                                                  pRenderer->DrawTextureTransparent(
+                                                                    papredoll_4E4C28
+                                                                  + pPaperdollLeftEmptyHand[uPlayerID_a],
+                                                                    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;
+                                                              }
+LABEL_380:
+                                                              v183 = "sptext01";
+                                                              goto LABEL_381;
+                                                            }
+                                                            v183 = "sp30a";
+                                                          }
+                                                          v156 = pIcons_LOD;
+                                                          goto LABEL_381;
+                                                        }
+                                                        v156 = pIcons_LOD;
+                                                        goto LABEL_380;
+                                                      }
+                                                      a3k = 28;
+                                                    }
+                                                    else
+                                                    {
+                                                      a3k = 86;
+                                                    }
+                                                    v150 = 596;
+                                                    goto LABEL_370;
+                                                  }
+                                                  if ( (*(int *)(v227 + 20) & 0xF0) != 16 )
+                                                  {
+                                                    if ( (*(int *)(v227 + 20) & 0xF0) == 32 )
+                                                    {
+                                                      v182 = "sp28a";
+                                                      goto LABEL_348;
+                                                    }
+                                                    if ( (*(int *)(v227 + 20) & 0xF0) == 64 )
+                                                    {
+                                                      v182 = "sp30a";
+                                                      goto LABEL_348;
+                                                    }
+                                                    if ( (*(int *)(v227 + 20) & 0xF0) == 128 )
+                                                    {
+                                                      v182 = "sp91a";
+LABEL_348:
+                                                      v140 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v182, TEXTURE_16BIT_PALETTE)];
+                                                      dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                                      if ( dword_50C9A8 <= 0 )
+                                                      {
+                                                        dword_50C9A8 = 0;
+                                                        *(char *)(v227 + 20) &= 0xFu;
+                                                        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);
+                                                      goto LABEL_358;
+                                                    }
+                                                  }
+                                                  v182 = "sptext01";
+                                                  goto LABEL_348;
+                                                }
+                                                v125 = 11;
+                                                goto LABEL_310;
+                                              }
+                                              if ( !(*(int *)(v225 + 20) & 0xF0) )
+                                              {
+                                                v119 = v116 + 1;
+                                                v120 = (char *)&pIcons_LOD->pTextures[v116];
+                                                if ( *(int *)(v225 + 20) & 2 )
+                                                {
+                                                  v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
+                                                  pRenderer->_4A6776(a2h, a3h, v121);
+                                                }
+                                                else
+                                                {
+                                                  v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
+                                                  pRenderer->DrawTextureTransparent(a2h, a3h, v121);
+                                                }
+                                                if ( !bRingsShownInCharScreen )
+                                                  pRenderer->_4A612A(a2h, a3h, v121, v236);
+                                                goto LABEL_292;
+                                              }
+                                              if ( (*(int *)(v225 + 20) & 0xF0) != 16 )
+                                              {
+                                                if ( (*(int *)(v225 + 20) & 0xF0) == 32 )
+                                                {
+                                                  v179 = "sp28a";
+                                                  goto LABEL_284;
+                                                }
+                                                if ( (*(int *)(v225 + 20) & 0xF0) == 64 )
+                                                {
+                                                  v179 = "sp30a";
+                                                  goto LABEL_284;
+                                                }
+                                                if ( (*(int *)(v225 + 20) & 0xF0) == 128 )
+                                                {
+                                                  v179 = "sp91a";
+LABEL_284:
+                                                  a2i = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v179, TEXTURE_16BIT_PALETTE)];
+                                                  dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                                  if ( dword_50C9A8 <= 0 )
+                                                  {
+                                                    dword_50C9A8 = 0;
+                                                    *(char *)(v225 + 20) &= 0xFu;
+                                                    ptr_50C9A4 = 0;
+                                                  }
+                                                  v118 = (double)GetTickCount() * 0.1;
+                                                  pRenderer->_4A63E6(
+                                                    v117,
+                                                    a3h,
+                                                    (Texture *)(v116 != -1 ? (int)&pIcons_LOD->pTextures[v116] : 0),
+                                                    a2i,
+                                                    (signed __int64)v118,
+                                                    0,
+                                                    255);
+                                                  goto LABEL_292;
+                                                }
+                                              }
+                                              v179 = "sptext01";
+                                              goto LABEL_284;
+                                            }
+                                            v191 = 9;
+                                            break;
+                                        }
+                                        v114 = v191;
+                                        goto LABEL_274;
+                                      }
+                                      v114 = 5;
+                                      goto LABEL_272;
+                                    }
+LABEL_209:
+                                    if ( v68->pEquipment.uMainHand
+                                      && (v68->GetEquippedItemEquipType(1u) == 1
+                                       || v68->GetEquippedItemSkillType(EQUIP_TWO_HANDED) == 4
+                                       && !v68->pEquipment.uOffHand) )
+                                    {
+                                      v91 = 17 * v239 + v90;
+                                      v92 = v91;
+                                      v223 = paperdoll_array_511290[0][v91][2];
+                                      if ( v223 == pIcons_LOD->FindTextureByName("pending") )
+                                      {
+                                        v93 = 2 * v91;
+                                        v94 = paperdoll_array_511290[0][v92][1];
+                                        a2g = papredoll_4E4C28 + dword_4E5050[v93];
+                                        v95 = dword_4E5050[v93 + 1];
+                                      }
+                                      else
+                                      {
+                                        v94 = v223;
+                                        a2g = papredoll_4E4C28 + dword_4E5270[2 * v91];
+                                        v95 = dword_4E5270[2 * v91 + 1];
+                                      }
+                                      a3g = paperdoll_4E4C2C + v95;
+                                      if ( v94 == pIcons_LOD->FindTextureByName("pending") )
+                                        goto LABEL_258;
+                                      if ( *(int *)(v242 + 516) & 0xF0 )
+                                      {
+                                        if ( (*(int *)(v242 + 516) & 0xF0) != 16 )
+                                        {
+                                          if ( (*(int *)(v242 + 516) & 0xF0) == 32 )
+                                          {
+                                            v173 = "sp28a";
+                                            goto LABEL_226;
+                                          }
+                                          if ( (*(int *)(v242 + 516) & 0xF0) == 64 )
+                                          {
+                                            v173 = "sp30a";
+                                            goto LABEL_226;
+                                          }
+                                          if ( (*(int *)(v242 + 516) & 0xF0) == 128 )
+                                          {
+                                            v173 = "sp91a";
+LABEL_226:
+                                            v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v173, TEXTURE_16BIT_PALETTE)];
+                                            dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                            if ( dword_50C9A8 <= 0 )
+                                            {
+                                              dword_50C9A8 = 0;
+                                              *(char *)(v242 + 516) &= 0xFu;
+                                              ptr_50C9A4 = 0;
+                                            }
+                                            v187 = 255;
+                                            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);
+                                            goto LABEL_258;
+                                          }
+                                        }
+                                        v173 = "sptext01";
+                                        goto LABEL_226;
+                                      }
+                                      v98 = v94 + 1;
+                                      v99 = (char *)&pIcons_LOD->pTextures[v94];
+                                      v100 = pRenderer;
+                                      if ( *(int *)(v242 + 516) & 2 )
+                                      {
+                                        v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
+                                        v188 = v101;
+                                        v175 = a3g;
+                                        v163 = a2g;
+LABEL_231:
+                                        v100->_4A6776(v163, v175, v188);
+                                        goto LABEL_256;
+                                      }
+                                      if ( *(char *)(v242 + 516) & 1 )
+                                      {
+                                        v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
+                                        v189 = v101;
+                                        v176 = a3g;
+                                        v164 = a2g;
+LABEL_234:
+                                        pRenderer->DrawTextureTransparent(v164, v176, v189);
+                                        goto LABEL_256;
+                                      }
+                                      v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
+                                      v190 = v101;
+                                      v177 = a3g;
+                                      v165 = a2g;
+                                      goto LABEL_255;
+                                    }
+                                    v102 = 17 * v239 + v90;
+                                    v94 = paperdoll_array_511290[0][v102][1];
+                                    if ( v94 == pIcons_LOD->FindTextureByName("pending") )
+                                    {
+LABEL_258:
+                                      v68 = v217;
+                                      goto LABEL_259;
+                                    }
+                                    v103 = papredoll_4E4C28 + dword_4E5050[2 * v102];
+                                    v104 = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
+                                    v224 = *(int *)(v242 + 516);
+                                    v105 = *(int *)(v242 + 516) & 0xF0;
+                                    a2g = papredoll_4E4C28 + dword_4E5050[2 * v102];
+                                    a3g = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
+                                    if ( !v105 )
+                                    {
+                                      v109 = v94 + 1;
+                                      v110 = (char *)&pIcons_LOD->pTextures[v94];
+                                      if ( v224 & 2 )
+                                      {
+                                        v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
+                                        v188 = v101;
+                                        v175 = v104;
+                                        v163 = v103;
+                                        v100 = pRenderer;
+                                        goto LABEL_231;
+                                      }
+                                      if ( v224 & 1 )
+                                      {
+                                        v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
+                                        v189 = v101;
+                                        v176 = v104;
+                                        v164 = v103;
+                                        v100 = pRenderer;
+                                        goto LABEL_234;
+                                      }
+                                      v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
+                                      v190 = v101;
+                                      v177 = v104;
+                                      v165 = v103;
+                                      v100 = pRenderer;
+LABEL_255:
+                                      pRenderer->DrawTransparentGreenShade(v165, v177, v190);
+LABEL_256:
+                                      if ( !bRingsShownInCharScreen )
+                                        pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                      goto LABEL_258;
+                                    }
+                                    v106 = v105 - 16;
+                                    if ( v106 )
+                                    {
+                                      v107 = v106 - 16;
+                                      if ( !v107 )
+                                      {
+                                        v178 = "sp28a";
+                                        goto LABEL_246;
+                                      }
+                                      v108 = v107 - 32;
+                                      if ( !v108 )
+                                      {
+                                        v178 = "sp30a";
+                                        goto LABEL_246;
+                                      }
+                                      if ( v108 == 64 )
+                                      {
+                                        v178 = "sp91a";
+LABEL_246:
+                                        v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v178, TEXTURE_16BIT_PALETTE)];
+                                        dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                        if ( dword_50C9A8 <= 0 )
+                                        {
+                                          dword_50C9A8 = 0;
+                                          *(char *)(v242 + 516) &= 0xFu;
+                                          ptr_50C9A4 = 0;
+                                        }
+                                        v187 = 255;
+                                        v174 = 0;
+                                        v97 = (double)GetTickCount();
+                                        goto LABEL_249;
+                                      }
+                                    }
+                                    v178 = "sptext01";
+                                    goto LABEL_246;
+                                  }
+                                  v186 = 16;
+                                }
+                                else
+                                {
+                                  v186 = 13;
+                                }
+                              }
+                              else
+                              {
+                                v186 = 14;
+                              }
+                              v90 = v186;
+                              goto LABEL_209;
+                            }
+                            v90 = 15;
+                            goto LABEL_207;
+                          }
+                          if ( (*(int *)(v57 + 20) & 0xF0) != 16 )
+                          {
+                            if ( (*(int *)(v57 + 20) & 0xF0) == 32 )
+                            {
+                              v171 = "sp28a";
+                              goto LABEL_145;
+                            }
+                            if ( (*(int *)(v57 + 20) & 0xF0) == 64 )
+                            {
+                              v171 = "sp30a";
+                              goto LABEL_145;
+                            }
+                            if ( (*(int *)(v57 + 20) & 0xF0) == 128 )
+                            {
+                              v171 = "sp91a";
+LABEL_145:
+                              v63 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v171, TEXTURE_16BIT_PALETTE)];
+                              dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                              if ( dword_50C9A8 <= 0 )
+                              {
+                                dword_50C9A8 = 0;
+                                *(char *)(v221 + 20) &= 0xFu;
+                                ptr_50C9A4 = 0;
+                              }
+                              v64 = (double)GetTickCount() * 0.1;
+                              pRenderer->_4A63E6(
+                                a2e,
+                                a3e,
+                                (Texture *)(v59 != -1 ? (int)&pIcons_LOD->pTextures[v59] : 0),
+                                v63,
+                                (signed __int64)v64,
+                                0,
+                                255);
+                              goto LABEL_155;
+                            }
+                          }
+                          v171 = "sptext01";
+                          goto LABEL_145;
+                        }
+                        if ( (*(int *)(v44 + 20) & 0xF0) != 16 )
+                        {
+                          if ( (*(int *)(v44 + 20) & 0xF0) == 32 )
+                          {
+                            v170 = "sp28a";
+                          }
+                          else
+                          {
+                            if ( (*(int *)(v44 + 20) & 0xF0) != 64 )
+                            {
+                              v50 = pIcons_LOD;
+                              if ( (*(int *)(v44 + 20) & 0xF0) == 128 )
+                              {
+                                v170 = "sp91a";
+LABEL_117:
+                                v51 = &pIcons_LOD->pTextures[v50->LoadTexture(v170, TEXTURE_16BIT_PALETTE)];
+                                dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                                if ( dword_50C9A8 <= 0 )
+                                {
+                                  dword_50C9A8 = 0;
+                                  *(char *)(v220 + 20) &= 0xFu;
+                                  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);
+                                goto LABEL_127;
+                              }
+LABEL_116:
+                              v170 = "sptext01";
+                              goto LABEL_117;
+                            }
+                            v170 = "sp30a";
+                          }
+                          v50 = pIcons_LOD;
+                          goto LABEL_117;
+                        }
+                        v50 = pIcons_LOD;
+                        goto LABEL_116;
+                      }
+                      v185 = 16;
+                    }
+                  }
+                  v45 = v185;
+                  goto LABEL_106;
+                }
+                v45 = 15;
+                goto LABEL_104;
+              }
+              if ( (*(int *)(v32 + 20) & 0xF0) != 16 )
+              {
+                if ( (*(int *)(v32 + 20) & 0xF0) == 32 )
+                {
+                  v169 = "sp28a";
+                }
+                else
+                {
+                  if ( (*(int *)(v32 + 20) & 0xF0) != 64 )
+                  {
+                    v38 = pIcons_LOD;
+                    if ( (*(int *)(v32 + 20) & 0xF0) == 128 )
+                    {
+                      v169 = "sp91a";
+LABEL_85:
+                      v39 = &pIcons_LOD->pTextures[v38->LoadTexture(v169, TEXTURE_16BIT_PALETTE)];
+                      dword_50C9A8 -= pEventTimer->uTimeElapsed;
+                      if ( dword_50C9A8 <= 0 )
+                      {
+                        dword_50C9A8 = 0;
+                        *(char *)(v219 + 20) &= 0xFu;
+                        ptr_50C9A4 = 0;
+                      }
+                      v40 = (double)GetTickCount() * 0.1;
+                      pRenderer->_4A63E6(
+                        a2c,
+                        a3c,
+                        (Texture *)(v35 != -1 ? (int)&pIcons_LOD->pTextures[v35] : 0),
+                        v39,
+                        (signed __int64)v40,
+                        0,
+                        255);
+                      goto LABEL_93;
+                    }
+LABEL_84:
+                    v169 = "sptext01";
+                    goto LABEL_85;
+                  }
+                  v169 = "sp30a";
+                }
+                v38 = pIcons_LOD;
+                goto LABEL_85;
+              }
+              v38 = pIcons_LOD;
+              goto LABEL_84;
+            }
+            v184 = 9;
+            break;
+        }
+        v33 = v184;
+        goto LABEL_74;
+      }
+      v33 = 5;
+      goto LABEL_72;
+    }
+    if ( (*(int *)(v22 + 20) & 0xF0) != 16 )
+    {
+      if ( (*(int *)(v22 + 20) & 0xF0) == 32 )
+      {
+        v168 = "sp28a";
+      }
+      else
+      {
+        if ( (*(int *)(v22 + 20) & 0xF0) != 64 )
+        {
+          v26 = pIcons_LOD;
+          if ( (*(int *)(v22 + 20) & 0xF0) == 128 )
+          {
+            v168 = "sp91a";
+LABEL_49:
+            a2b = &pIcons_LOD->pTextures[v26->LoadTexture(v168, TEXTURE_16BIT_PALETTE)];
+            dword_50C9A8 -= pEventTimer->uTimeElapsed;
+            if ( dword_50C9A8 <= 0 )
+            {
+              dword_50C9A8 = 0;
+              *(char *)(v22 + 20) &= 0xFu;
+              ptr_50C9A4 = 0;
+            }
+            v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
+            v28 = (double)GetTickCount() * 0.1;
+            pRenderer->_4A63E6(v24, a3b, v27, a2b, (signed __int64)v28, 0, 255);
+            goto LABEL_57;
+          }
+LABEL_48:
+          v168 = "sptext01";
+          goto LABEL_49;
+        }
+        v168 = "sp30a";
+      }
+      v26 = pIcons_LOD;
+      goto LABEL_49;
+    }
+    v26 = pIcons_LOD;
+    goto LABEL_48;
+  }
+  a3 = paperdoll_4E4C2C;
+  a2 = papredoll_4E4C28;
+  v240 = 4 * uPlayerID_ - 4;
+  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));
+    //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
+    //                                                                    * *(unsigned int *)((char *)papredoll_dbods
+    //                                                                                      + v240)
+    //                                                                    + 7145548 : 0));
+  if ( !bRingsShownInCharScreen )
+    pRenderer->_4A612A(
+      a2,
+      a3,
+      //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
+      //                                                                    * *(unsigned int *)((char *)papredoll_dbods
+      //                                                                                      + v240)
+      //                                                                    + 7145548 : 0),
+      (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0),
+      pPlayer->pEquipment.uBody);
+  uPlayerID_a = 2 * v5;
+  v6 = pPlayer->pEquipment.uMainHand;
+  if ( !v6
+    || (v7 = *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5], pItemsTable->pItems[v7].uEquipType != 1)
+    && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayer->pEquipment.uOffHand) )
+    pRenderer->DrawTextureTransparent(
+      papredoll_4E4C28 + dword_4E5AE0[2 * v5],
+      paperdoll_4E4C2C + dword_4E5AE0[2 * v5 + 1],
+      (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
+      //(Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? 72
+      //                                                                    * *(unsigned int *)((char *)papredoll_dlads
+      //                                                                                      + v240)
+      //                                                                    + 7145548 : 0));
+  v8 = pPlayer->pEquipment.uMainHand;
+  if ( v8 )
+  {
+    v229 = pPlayer->pEquipment.uMainHand;
+    v9 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v10 = v5 << 7;
+    v218 = v9;
+    v11 = *(int *)v9;
+    v12 = *(int *)v9;
+    v13 = papredoll_4E4C28 + array_4E4C30[v5].field_8 - pItemsTable->pItems[v12].uEquipX;
+    a2a = v13;
+    a3a = paperdoll_4E4C2C + *(int *)((char *)&array_4E4C30[0].field_C + v10) - pItemsTable->pItems[v12].uEquipY;
+    if ( v11 == 64 )
+      v166 = "item64v1";
+    else
+      v166 = pItemsTable->pItems[v12].pIconName;
+    v14 = pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE);
+    v15 = *(int *)(v218 + 20);
+    if ( *(int *)(v218 + 20) & 0xF0 )
+    {
+      if ( (*(int *)(v218 + 20) & 0xF0) != 16 )
+      {
+        if ( (*(int *)(v218 + 20) & 0xF0) == 32 )
+        {
+          v167 = "sp28a";
+          goto LABEL_27;
+        }
+        if ( (*(int *)(v218 + 20) & 0xF0) == 64 )
+        {
+          v167 = "sp30a";
+          goto LABEL_27;
+        }
+        if ( (*(int *)(v218 + 20) & 0xF0) == 128 )
+        {
+          v167 = "sp91a";
+LABEL_27:
+          //v16 = (Texture *)(72 * pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE) + 7145548);
+          v16 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE)];
+
+          dword_50C9A8 -= pEventTimer->uTimeElapsed;
+          if ( dword_50C9A8 <= 0 )
+          {
+            dword_50C9A8 = 0;
+            *(char *)(v218 + 20) &= 0xFu;
+            ptr_50C9A4 = 0;
+          }
+          v17 = (double)GetTickCount() * 0.1;
+          pRenderer->_4A63E6(
+            v13,
+            a3a,
+            (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0),
+            v16,
+            (signed __int64)v17,
+            0,
+            255);
+          goto LABEL_393;
+        }
+      }
+      v167 = "sptext01";
+      goto LABEL_27;
+    }
+    v18 = v14 + 1;
+    v19 = (char *)&pIcons_LOD->pTextures[v14];
+    if ( v15 & 2 )
+    {
+      v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
+      pRenderer->_4A6776(a2a, a3a, v20);
+    }
+    else
+    {
+      if ( v15 & 1 )
+      {
+        v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
+        pRenderer->DrawTextureTransparent(a2a, a3a, v20);
+      }
+      else
+      {
+        v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
+        pRenderer->DrawTransparentGreenShade(a2a, a3a, v20);
+      }
+    }
+    if ( !bRingsShownInCharScreen )
+      pRenderer->_4A612A(a2a, a3a, v20, v229);
+  }
+LABEL_393:
+  pRenderer->DrawTextureTransparent(
+    papredoll_4E4C28 + pPaperdollRightHand[uPlayerID_a],
+    paperdoll_4E4C2C + pPaperdollRightHand[uPlayerID_a + 1],
+    (Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_drhs + v240)] : 0));
+    //(Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? 72
+    //                                                                   * *(unsigned int *)((char *)papredoll_drhs + v240)
+    //                                                                   + 7145548 : 0));
+  v161 = v217->pEquipment.uMainHand;
+  if ( v161 )
+  {
+    v162 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v161 + 5];
+    if ( pItemsTable->pItems[v162].uEquipType == 1
+      || pItemsTable->pItems[v162].uSkillType == 4 && !v217->pEquipment.uOffHand )
+      pRenderer->DrawTextureTransparent(
+        papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
+        paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
+        (Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhus + v240)] : 0));
+        //(Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? 72
+        //                                                                    * *(unsigned int *)((char *)papredoll_dlhus
+        //                                                                                      + v240)
+        //                                                                    + 7145548 : 0));
+  }
+  if ( !bRingsShownInCharScreen )
+    pRenderer->DrawTextureTransparent(
+      0x25Bu,
+      0x12Bu,
+      (Texture *)(uTextureID_MAGNIF_B != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_MAGNIF_B] : 0));
+  pRenderer->DrawTextureTransparent(
+    0x1D4u,
+    0,
+    (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
+}
+
+
+//----- (0043E825) --------------------------------------------------------
+void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID)
+{
+  unsigned int v1; // ebx@1
+  Player *pPlayer; // edi@1
+  int v3; // ecx@1
+  int v4; // edi@3
+  unsigned int v5; // ebx@3
+  int v6; // eax@3
+  LODFile_IconsBitmaps *v7; // ecx@7
+  double v8; // st7@16
+  int v9; // edi@17
+  Texture *v10; // edi@18
+  unsigned __int8 v11; // zf@19
+  Texture *v12; // eax@19
+  char v13; // sf@24
+  unsigned __int8 v14; // of@24
+  unsigned int v15; // eax@25
+  unsigned int v16; // ebx@26
+  int v17; // eax@26
+  LODFile_IconsBitmaps *v18; // ecx@30
+  double v19; // st7@39
+  int v20; // edi@40
+  int v21; // eax@41
+  signed int v22; // ebx@41
+  Texture *v23; // edi@41
+  int v24; // eax@42
+  char *v25; // eax@42
+  unsigned int v26; // eax@46
+  int v27; // edi@47
+  unsigned int v28; // ebx@47
+  int v29; // eax@47
+  LODFile_IconsBitmaps *v30; // ecx@51
+  Texture *v31; // esi@58
+  double v32; // st7@60
+  int v33; // esi@61
+  int v34; // esi@62
+  Texture *v35; // eax@63
+  const char *v36; // [sp-8h] [bp-38h]@8
+  const char *v37; // [sp-8h] [bp-38h]@31
+  const char *v38; // [sp-8h] [bp-38h]@52
+  int v39; // [sp+10h] [bp-20h]@3
+  Texture *v40; // [sp+10h] [bp-20h]@14
+  int v41; // [sp+10h] [bp-20h]@26
+  Texture *v42; // [sp+10h] [bp-20h]@37
+  int v43; // [sp+10h] [bp-20h]@47
+  unsigned int a3; // [sp+14h] [bp-1Ch]@3
+  unsigned int a2; // [sp+18h] [bp-18h]@3
+  int v46; // [sp+1Ch] [bp-14h]@1
+  Player *v47; // [sp+20h] [bp-10h]@1
+  int v48; // [sp+24h] [bp-Ch]@1
+  int v49; // [sp+24h] [bp-Ch]@26
+
+  v1 = uPlayerID;
+  pPlayer = pPlayers[uPlayerID];
+  v47 = pPlayers[uPlayerID];
+  pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
+  CharacterUI_DrawPaperdoll(v1);
+  pRenderer->DrawTextureTransparent(
+    0x1D9u,
+    0,
+    (Texture *)(uTextureID_BACKHAND != -1 ? &pIcons_LOD->pTextures[uTextureID_BACKHAND] : 0));
+  pRenderer->DrawTextureTransparent(
+    0x1D4u,
+    0,
+    (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0));
+  pRenderer->DrawTextureIndexed(
+    pCharacterScreen_DetalizBtn->uX,
+    pCharacterScreen_DetalizBtn->uY,
+    (Texture *)(uTextureID_5118C8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5118C8] : 0));
+  v3 = 0;
+  v46 = (int)&pPlayer->pEquipment.field_28;
+  v48 = 0;
+  do
+  {
+    if ( !*(int *)v46 )
+      goto LABEL_24;
+    v39 = *(int *)v46;
+    v4 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v46 + 5];
+    a3 = *(int *)((char *)dword_4E5C34 + v3);
+    a2 = *(int *)((char *)dword_4E5C1C + v3);
+    v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v4].pIconName, TEXTURE_16BIT_PALETTE);
+    v6 = *(int *)(v4 + 20);
+    if ( *(int *)(v4 + 20) & 0xF0 )
+    {
+      if ( (*(int *)(v4 + 20) & 0xF0) != 16 )
+      {
+        if ( (*(int *)(v4 + 20) & 0xF0) == 32 )
+        {
+          v36 = "sp28a";
+        }
+        else
+        {
+          if ( (*(int *)(v4 + 20) & 0xF0) != 64 )
+          {
+            v7 = pIcons_LOD;
+            if ( (*(int *)(v4 + 20) & 0xF0) == 128 )
+            {
+              v36 = "sp91a";
+LABEL_14:
+              v40 = &pIcons_LOD->pTextures[v7->LoadTexture(v36, TEXTURE_16BIT_PALETTE)];
+              dword_50C9A8 -= pEventTimer->uTimeElapsed;
+              if ( dword_50C9A8 <= 0 )
+              {
+                dword_50C9A8 = 0;
+                *(char *)(v4 + 20) &= 0xFu;
+                ptr_50C9A4 = 0;
+              }
+              v8 = (double)GetTickCount() * 0.1;
+              pRenderer->_4A63E6(
+                a2,
+                a3,
+                (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0),
+                v40,
+                (signed __int64)v8,
+                0,
+                255);
+              goto LABEL_23;
+            }
+LABEL_13:
+            v36 = "sptext01";
+            goto LABEL_14;
+          }
+          v36 = "sp30a";
+        }
+        v7 = pIcons_LOD;
+        goto LABEL_14;
+      }
+      v7 = pIcons_LOD;
+      goto LABEL_13;
+    }
+    v9 = v5 + 1;
+    if ( v6 & 2 )
+    {
+      v10 = (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[v5] : 0);
+      pRenderer->_4A6776(a2, a3, v10);
+    }
+    else
+    {
+      v11 = (v6 & 1) == 0;
+      v12 = &pIcons_LOD->pTextures[v5];
+      if ( v11 )
+      {
+        v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
+        pRenderer->DrawTransparentGreenShade(a2, a3, v10);
+      }
+      else
+      {
+        v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
+        pRenderer->DrawTextureTransparent(a2, a3, v10);
+      }
+    }
+    pRenderer->_4A601E(a2, a3, v10, v39);
+LABEL_23:
+    pPlayer = v47;
+LABEL_24:
+    v46 += 4;
+    v3 = v48 + 4;
+    v14 = __OFSUB__(v48 + 4, 20);
+    v11 = v48 == 16;
+    v13 = v48 - 16 < 0;
+    v48 += 4;
+  }
+  while ( (unsigned __int8)(v13 ^ v14) | v11 );
+  v15 = pPlayer->pEquipment.field_24;
+  if ( !v15 )
+    goto LABEL_46;
+  v41 = pPlayer->pEquipment.field_24;
+  v49 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5];
+  v16 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v49].pIconName, TEXTURE_16BIT_PALETTE);
+  v17 = *(int *)(v49 + 20);
+  if ( !(*(int *)(v49 + 20) & 0xF0) )
+  {
+    v20 = v16 + 1;
+    if ( v17 & 2 )
+    {
+      v21 = 9 * v16;
+      v22 = 493;
+      v23 = (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0);
+      pRenderer->_4A6776(0x1EDu, 0x5Bu, v23);
+    }
+    else
+    {
+      v11 = (v17 & 1) == 0;
+      v24 = 9 * v16;
+      v22 = 493;
+      v25 = (char *)&pIcons_LOD->pTextures[8 * v24 / 0x48u];
+      if ( v11 )
+      {
+        v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
+        pRenderer->DrawTransparentGreenShade(493, 91, v23);
+      }
+      else
+      {
+        v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
+        pRenderer->DrawTextureTransparent(0x1EDu, 0x5Bu, v23);
+      }
+    }
+    pRenderer->_4A601E(v22, 91, v23, v41);
+    pPlayer = v47;
+    goto LABEL_46;
+  }
+  if ( (*(int *)(v49 + 20) & 0xF0) == 16 )
+  {
+    v18 = pIcons_LOD;
+    goto LABEL_36;
+  }
+  if ( (*(int *)(v49 + 20) & 0xF0) == 32 )
+  {
+    v37 = "sp28a";
+    goto LABEL_34;
+  }
+  if ( (*(int *)(v49 + 20) & 0xF0) == 64 )
+  {
+    v37 = "sp30a";
+LABEL_34:
+    v18 = pIcons_LOD;
+    goto LABEL_37;
+  }
+  v18 = pIcons_LOD;
+  if ( (*(int *)(v49 + 20) & 0xF0) == 128 )
+  {
+    v37 = "sp91a";
+    goto LABEL_37;
+  }
+LABEL_36:
+  v37 = "sptext01";
+LABEL_37:
+  v42 = &pIcons_LOD->pTextures[v18->LoadTexture(v37, TEXTURE_16BIT_PALETTE)];
+  dword_50C9A8 -= pEventTimer->uTimeElapsed;
+  if ( dword_50C9A8 <= 0 )
+  {
+    dword_50C9A8 = 0;
+    *(char *)(v49 + 20) &= 0xFu;
+    ptr_50C9A4 = 0;
+  }
+  v19 = (double)GetTickCount() * 0.1;
+  pRenderer->_4A63E6(
+    0x1EDu,
+    0x5Bu,
+    (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0),
+    v42,
+    (signed __int64)v19,
+    0,
+    255);
+LABEL_46:
+  v26 = pPlayer->pEquipment.field_1C;
+  if ( !v26 )
+    return;
+  v43 = pPlayer->pEquipment.field_1C;
+  v27 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v26 + 5];
+  v28 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v27].pIconName, TEXTURE_16BIT_PALETTE);
+  v29 = *(int *)(v27 + 20);
+  if ( !(*(int *)(v27 + 20) & 0xF0) )
+  {
+    v33 = v28 + 1;
+    if ( v29 & 2 )
+    {
+      v34 = v33 != 0 ? (int)&pIcons_LOD->pTextures[v28] : 0;
+      pRenderer->_4A6776(0x24Au, 0x58u, (Texture *)v34);
+    }
+    else
+    {
+      v11 = (v29 & 1) == 0;
+      v35 = &pIcons_LOD->pTextures[v28];
+      if ( v11 )
+      {
+        v34 = v33 != 0 ? (int)v35 : 0;
+        pRenderer->DrawTransparentGreenShade(586, 88, (Texture *)v34);
+      }
+      else
+      {
+        v34 = v33 != 0 ? (int)v35 : 0;
+        pRenderer->DrawTextureTransparent(0x24Au, 0x58u, (Texture *)v34);
+      }
+    }
+    pRenderer->_4A601E(586, 88, (Texture *)v34, v43);
+    return;
+  }
+  if ( (*(int *)(v27 + 20) & 0xF0) == 16 )
+  {
+    v30 = pIcons_LOD;
+    goto LABEL_57;
+  }
+  if ( (*(int *)(v27 + 20) & 0xF0) == 32 )
+  {
+    v38 = "sp28a";
+    goto LABEL_55;
+  }
+  if ( (*(int *)(v27 + 20) & 0xF0) == 64 )
+  {
+    v38 = "sp30a";
+LABEL_55:
+    v30 = pIcons_LOD;
+    goto LABEL_58;
+  }
+  v30 = pIcons_LOD;
+  if ( (*(int *)(v27 + 20) & 0xF0) == 128 )
+  {
+    v38 = "sp91a";
+    goto LABEL_58;
+  }
+LABEL_57:
+  v38 = "sptext01";
+LABEL_58:
+  v31 = &pIcons_LOD->pTextures[v30->LoadTexture(v38, TEXTURE_16BIT_PALETTE)];
+  dword_50C9A8 -= pEventTimer->uTimeElapsed;
+  if ( dword_50C9A8 <= 0 )
+  {
+    dword_50C9A8 = 0;
+    *(char *)(v27 + 20) &= 0xFu;
+    ptr_50C9A4 = 0;
+  }
+  v32 = (double)GetTickCount() * 0.1;
+  pRenderer->_4A63E6(
+    0x24Au,
+    0x58u,
+    (Texture *)(v28 != -1 ? (int)&pIcons_LOD->pTextures[v28] : 0),
+    v31,
+    (signed __int64)v32,
+    0,
+    255);
+}
+
+
+//----- (0043ED6F) --------------------------------------------------------
+bool _43ED6F_check_party_races(bool a1)
+{
+  bool v6; // zf@5
+
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto player = pParty->pPlayers + i;
+    auto race = player->GetRace();
+
+    if (race != CHARACTER_RACE_HUMAN &&
+        race != CHARACTER_RACE_ELF &&
+        race != CHARACTER_RACE_GOBLIN)
+      v6 = a1 == 1;
+    else
+      v6 = !a1;
+
+    if (v6)
+      return true;
+  }
+  return false;
+}
+// A750D8: using guessed type __int64 qword_A750D8;
+
+//----- (0043EDB9) --------------------------------------------------------
+bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this)
+{
+  unsigned int v1; // ebp@1
+  Player **v2; // ebx@1
+  Player *v3; // esi@2
+  enum CHARACTER_RACE v4; // edi@2
+  bool result; // eax@2
+  char v6; // zf@7
+
+  v1 = _this;
+  v2 = &pPlayers[1];
+  while ( 1 )
+  {
+    v3 = *v2;
+    v4 = v3->GetRace();
+    result = v3->GetSexByVoice();
+    if ( !v4 )
+      break;
+    if ( v4 == 1 || v4 == 2 )
+      break;
+    if ( !result && v1 == 2 )
+      goto LABEL_15;
+    v6 = v1 == 3;
+LABEL_11:
+    if ( v6 )
+      goto LABEL_15;
+    ++v2;
+    if ( (signed int)v2 >= (signed int)&qword_A750D8 )
+    {
+      LOBYTE(result) = 0;
+      return result;
+    }
+  }
+  if ( result || v1 )
+  {
+    v6 = v1 == 1;
+    goto LABEL_11;
+  }
+LABEL_15:
+  LOBYTE(result) = 1;
+  return result;
+}
+// A750D8: using guessed type __int64 qword_A750D8;
+
+//----- (0043EE15) --------------------------------------------------------
+bool __fastcall sub_43EE15_player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
+{
+  bool result; // eax@0
+  signed int v4; // edi@3
+  int *v5; // esi@3
+  signed int v6; // edi@7
+  bool *v7; // esi@7
+
+  if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
+  {
+    v4 = 0;
+    v5 = pPlayer->pInventoryIndices;
+    while ( 1 )
+    {
+      if ( *v5 )
+      {
+        result = 9 * *v5;
+        if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v5 + 5] == uItemID )
+          break;
+      }
+      ++v4;
+      ++v5;
+      if ( v4 >= 126 )
+      {
+        v6 = 0;
+        v7 = (bool *)&pPlayer->pEquipment;
+        while ( 1 )
+        {
+          result = *v7;
+          if ( *v7 )
+          {
+            result *= 9;
+            if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] == uItemID )
+              break;
+          }
+          ++v6;
+          ++v7;
+          if ( v6 >= 16 )
+          {
+            LOBYTE(result) = 0;
+            return result;
+          }
+        }
+        break;
+      }
+    }
+  }
+  LOBYTE(result) = 1;
+  return result;
+}
+
+//----- (0043EE77) --------------------------------------------------------
+bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
+{
+  bool result; // eax@0
+  Player *v2; // edx@3
+  int v3; // ecx@3
+  Player **pPlayers; // esi@8
+  unsigned int v5; // ecx@8
+  Player *v6; // edx@9
+
+  if ( a1 < 1 || a1 > 4 )
+  {
+    if ( !a1 )
+    {
+      pPlayers = &::pPlayers[1];
+      v5 = 604;
+      while ( 1 )
+      {
+        result = sub_43EE15_player_has_item(v5, *pPlayers, 0);
+        if ( !result )
+          break;
+        result = v6->pEquipment.uBody;
+        if ( !result )
+          break;
+        result *= 9;
+        if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
+          break;
+        ++pPlayers;
+        if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
+          goto LABEL_13;
+      }
+    }
+    goto LABEL_6;
+  }
+  result = sub_43EE15_player_has_item(604u, ::pPlayers[a1], 0);
+  if ( !result
+    || (result = v2->pEquipment.uBody) == 0
+    || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
+  {
+LABEL_6:
+    LOBYTE(result) = 0;
+    return result;
+  }
+LABEL_13:
+  LOBYTE(result) = 1;
+  return result;
+}
+// A750D8: using guessed type __int64 qword_A750D8;
+
+//----- (0043EF2B) --------------------------------------------------------
+void __fastcall WetsuitOn(unsigned int uPlayerID)
+{
+  unsigned int v1; // ebx@1
+  Player **v2; // esi@2
+  enum CHARACTER_RACE v3; // edi@2
+  signed int v4; // eax@2
+  int v5; // ecx@5
+  unsigned __int8 v6; // al@7
+  char pContainer[20]; // [sp+4h] [bp-1Ch]@7
+  unsigned int v8; // [sp+18h] [bp-8h]@1
+  int v9; // [sp+1Ch] [bp-4h]@7
+
+  v1 = uPlayerID - 1;
+  v8 = uPlayerID;
+  if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
+  {
+    v2 = &pPlayers[uPlayerID];
+    v3 = (*v2)->GetRace();
+    v4 = (*v2)->GetSexByVoice();
+    if ( v3 && v3 != 1 && v3 != 2 )
+      v5 = (v4 != 0) + 3;
+    else
+      v5 = (v4 != 0) + 1;
+    v9 = v5;
+    wsprintfA(pContainer, "pc23v%dBod", v5);
+    papredoll_dbods[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    wsprintfA(pContainer, "pc23v%dlad", v9);
+    papredoll_dlads[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    wsprintfA(pContainer, "pc23v%dlau", v9);
+    papredoll_dlaus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    wsprintfA(pContainer, "pc23v%drh", v9);
+    papredoll_drhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    wsprintfA(pContainer, "pc23v%dlh", v9);
+    papredoll_dlhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    wsprintfA(pContainer, "pc23v%dlhu", v9);
+    papredoll_dlhus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    v6 = pPlayers[v1 + 1]->uFace;
+    if ( v6 == 12 || v6 == 13 )
+      papredoll_dbrds[pPlayers[v8]->uFace] = 0;
+    papredoll_flying_feet[pPlayers[v8]->uFace] = 0;
+    IsPlayerWearingWatersuit[v8] = 1;
+  }
+}
+
+//----- (0043F0BD) --------------------------------------------------------
+unsigned int __fastcall WetsuitOff(unsigned int uPlayerID)
+{
+  unsigned int result; // eax@1
+  Player **v2; // edi@2
+  unsigned int v3; // ebx@2
+  int v4; // ebx@2
+  char v5; // al@2
+  char pContainer[20]; // [sp+0h] [bp-18h]@4
+  unsigned int v7; // [sp+14h] [bp-4h]@1
+
+  result = uPlayerID - 1;
+  v7 = uPlayerID;
+  if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
+  {
+    v2 = &pPlayers[uPlayerID];
+    v3 = uPlayerID - 1;
+    papredoll_dbods[v3] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlads[v3] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlaus[v3] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    papredoll_drhs[v3] = pIcons_LOD->LoadTexture(drh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlhs[v3] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlhus[v3] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
+    v4 = (int)&(*v2)->uFace;
+    v5 = *(char *)v4;
+    if ( *(char *)v4 == 12 || v5 == 13 )
+    {
+      wsprintfA(pContainer, "pc%02dbrd", v5 + 1);
+      v4 = (int)&(*v2)->uFace;
+      papredoll_dbrds[*(char *)v4] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    }
+    wsprintfA(pContainer, "item281pc%02d", *(char *)v4 + 1);
+    papredoll_flying_feet[(*v2)->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    result = v7;
+    IsPlayerWearingWatersuit[v7] = 0;
+  }
+  return result;
+}
+
+
+//----- (0043F333) --------------------------------------------------------
+void BspRenderer::MakeVisibleSectorList()
+{
+  int v6; // ebx@3
+
+  uNumVisibleNotEmptySectors = 0;
+  for (uint i = 0; i < std__vector_000FA8; ++i)
+  {
+      v6 = 0;
+      if (!uNumVisibleNotEmptySectors)
+      {
+LABEL_7:
+        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
+      }
+      else
+      {
+        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
+        {
+          ++v6;
+          if ( v6 >= uNumVisibleNotEmptySectors)
+          {
+            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
+            continue;
+          }
+        }
+      }
+  }
+}
+
+
+//----- (0043F515) --------------------------------------------------------
+void MessWithBillboards_BLV()
+{
+  for (uint i = 0; i < uNumBillboardsToDraw; ++i)
+  {
+    auto p = pBillboardRenderList + i;
+
+    if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
+      p->uPaletteSubindex = 0;
+    else
+      p->uPaletteSubindex = _43F55F_get_billboard_light_level(p, -1);
+  }
+}
+
+//----- (0043F55F) --------------------------------------------------------
+int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
+{
+  signed int v3; // ecx@2
+
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  {
+    v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
+  }
+  else
+  {
+    if ( uBaseLightLevel == -1 )
+      v3 = a1->uPaletteSubindex;
+    else
+      v3 = uBaseLightLevel;
+  }
+  return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->some_x, a1->some_y, a1->some_z);
+}
+
+//----- (0043F5C8) --------------------------------------------------------
+int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
+{
+  int v5; // esi@1
+  signed int v6; // edi@1
+  int v8; // eax@6
+  int v9; // ebx@6
+  unsigned int v10; // ecx@6
+  unsigned int v11; // edx@9
+  unsigned int v12; // edx@11
+  signed int v13; // ecx@12
+  BLVLightMM7 *v16; // esi@20
+  int v17; // ebx@21
+  int v18; // eax@24
+  int v19; // ebx@24
+  unsigned int v20; // ecx@24
+  int v21; // edx@25
+  unsigned int v22; // edx@27
+  unsigned int v23; // edx@29
+  signed int v24; // ecx@30
+  int v26; // ebx@35
+  int v27; // eax@38
+  int v28; // ebx@38
+  unsigned int v29; // ecx@38
+  int v30; // edx@39
+  unsigned int v31; // edx@41
+  unsigned int v32; // edx@43
+  signed int v33; // ecx@44
+  int v37; // [sp+Ch] [bp-18h]@37
+  int v38; // [sp+10h] [bp-14h]@5
+  int v39; // [sp+10h] [bp-14h]@23
+  int v40; // [sp+10h] [bp-14h]@36
+  int v42; // [sp+14h] [bp-10h]@22
+  unsigned int v43; // [sp+18h] [bp-Ch]@12
+  unsigned int v44; // [sp+18h] [bp-Ch]@30
+  unsigned int v45; // [sp+18h] [bp-Ch]@44
+
+  v6 = uBaseLightLevel;
+  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pMobileLightsStack->pLights + i;
+
+      auto distX = abs(p->vPosition.x - x);
+      if ( distX <= p->uRadius)
+      {
+        auto distY = abs(p->vPosition.y - y);
+        if ( distY <= p->uRadius)
+        {
+          auto distZ = abs(p->vPosition.z - z);
+          if ( distZ <= p->uRadius)
+          {
+            v8 = distX;
+            v9 = distY;
+            v10 = distZ;
+            if (distX < distY)
+            {
+              v8 = distY;
+              v9 = distX;
+            }
+            if ( v8 < distZ )
+            {
+              v11 = v8;
+              v8 = distZ;
+              v10 = v11;
+            }
+            if ( v9 < (signed int)v10 )
+            {
+              v12 = v10;
+              v10 = v9;
+              v9 = v12;
+            }
+            v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
+            v13 = p->uRadius;
+            if ( (signed int)v43 < v13 )
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
+          }
+        }
+      }
+  }
+
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+  {
+    auto pSector = pIndoor->pSectors + uSectorID;
+
+    for (uint i = 0; i < pSector->uNumLights; ++i)
+    {
+        v16 = pIndoor->pLights + pSector->pLights[i];
+        if (~v16->uAtributes & 8)
+        {
+          v17 = abs(v16->vPosition.x - x);
+          if ( v17 <= v16->uRadius )
+          {
+            v42 = abs(v16->vPosition.y - y);
+            if ( v42 <= v16->uRadius )
+            {
+              v39 = abs(v16->vPosition.z - z);
+              if ( v39 <= v16->uRadius )
+              {
+                v18 = v17;
+                v19 = v42;
+                v20 = v39;
+                if ( v18 < v42 )
+                {
+                  v21 = v18;
+                  v18 = v42;
+                  v19 = v21;
+                }
+                if ( v18 < v39 )
+                {
+                  v22 = v18;
+                  v18 = v39;
+                  v20 = v22;
+                }
+                if ( v19 < (signed int)v20 )
+                {
+                  v23 = v20;
+                  v20 = v19;
+                  v19 = v23;
+                }
+                v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
+                v24 = v16->uRadius;
+                if ( (signed int)v44 < v24 )
+                  v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
+              }
+            }
+          }
+        }
+    }
+  }
+
+  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pStationaryLightsStack->pLights + i;
+      v26 = abs(p->vPosition.x - x);
+      if ( v26 <= p->uRadius)
+      {
+        v40 = abs(p->vPosition.y - y);
+        if ( v40 <= p->uRadius)
+        {
+          v37 = abs(p->vPosition.z - z);
+          if ( v37 <= p->uRadius)
+          {
+            v27 = v26;
+            v28 = v40;
+            v29 = v37;
+            if ( v27 < v40 )
+            {
+              v30 = v27;
+              v27 = v40;
+              v28 = v30;
+            }
+            if ( v27 < v37 )
+            {
+              v31 = v27;
+              v27 = v37;
+              v29 = v31;
+            }
+            if ( v28 < (signed int)v29 )
+            {
+              v32 = v29;
+              v29 = v28;
+              v28 = v32;
+            }
+            v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
+            v33 = p->uRadius;
+            if ( (signed int)v45 < v33 )
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
+          }
+        }
+      }
+  }
+
+  if ( v6 <= 31 )
+  {
+    if ( v6 < 0 )
+      v6 = 0;
+  }
+  else
+  {
+    v6 = 31;
+  }
+  return v6;
+}
+
+//----- (00406051) --------------------------------------------------------
+__int16 stru262_TurnBased::StartTurn()
+{
+  stru262_TurnBased *v1; // esi@1
+  int v2; // ecx@1
+  int v3; // ebx@1
+  char *v4; // edi@1
+  int v5; // eax@4
+  int v6; // eax@12
+  char *v7; // eax@15
+  TurnBased_QueueElem *v8; // edi@17
+  unsigned int v9; // edx@23
+  char *v10; // eax@26
+  int v11; // eax@30
+  int v12; // ebx@30
+  char *v13; // edi@31
+  int v15; // [sp+Ch] [bp-10h]@5
+  TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3
+  int v17; // [sp+14h] [bp-8h]@2
+  int v18; // [sp+14h] [bp-8h]@16
+  signed int v19; // [sp+18h] [bp-4h]@1
+  int v20; // [sp+18h] [bp-4h]@14
+
+  v1 = this;
+  v2 = 0;
+  v19 = 0;
+  v3 = v1->uActorQueueSize;
+  v1->field_1C = 0;
+  v4 = (char *)&v1->pQueue[v3].field_4;
+  do
+  {
+    v17 = v2;
+    if ( v1->uActorQueueSize <= v2 )
+      goto LABEL_11;
+    v16 = v1->pQueue;
+    while ( 1 )
+    {
+      v5 = v16->uPackedID;
+      if ( (v16->uPackedID & 7) == 4 )
+        break;
+LABEL_8:
+      ++v17;
+      ++v16;
+      if ( v17 >= v1->uActorQueueSize )
+        goto LABEL_11;
+    }
+    v15 = v5 >> 3;
+    if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 )
+    {
+      v2 = 0;
+      goto LABEL_8;
+    }
+    v2 = 0;
+LABEL_11:
+    if ( v17 == v1->uActorQueueSize )
+    {
+      *(int *)v4 = 100;
+      v6 = 8 * v19;
+      LOBYTE(v6) = 8 * v19 | 4;
+      *((int *)v4 + 2) = v2;
+      *((int *)v4 - 1) = v6;
+      *((int *)v4 + 1) = v2;
+      ++v3;
+      v4 += 16;
+    }
+    ++v19;
+  }
+  while ( v19 < 4 );
+  v1->uActorQueueSize = v3;
+  v20 = v2;
+  if ( ai_arrays_size > v2 )
+  {
+    v7 = (char *)&v1->pQueue[v3].field_4;
+    do
+    {
+      v18 = v2;
+      if ( v1->uActorQueueSize > v2 )
+      {
+        v8 = v1->pQueue;
+        do
+        {
+          if ( (v8->uPackedID & 7) == 3 && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 )
+            break;
+          ++v18;
+          ++v8;
+        }
+        while ( v18 < v1->uActorQueueSize );
+        v2 = 0;
+      }
+      if ( v18 == v1->uActorQueueSize )
+      {
+        v9 = ai_array_4F7DB0_actor_ids[v20];
+        *(int *)v7 = 1;
+        *((int *)v7 + 2) = v2;
+        *((int *)v7 - 1) = 8 * v9 | 3;
+        *((int *)v7 + 1) = v2;
+        ++v3;
+        v7 += 16;
+      }
+      ++v20;
+    }
+    while ( v20 < ai_arrays_size );
+  }
+  ++v1->field_0;
+  v1->uActorQueueSize = v3;
+  v1->field_10 = 100;
+  if ( v3 > 0 )
+  {
+    v10 = (char *)&v1->pQueue[0].field_4;
+    do
+    {
+      if ( *(int *)v10 <= 0 )
+        *(int *)v10 = 100;
+      ++v2;
+      v10 += 16;
+    }
+    while ( v2 < v1->uActorQueueSize );
+  }
+  LOWORD(v11) = v1->_4063A1();
+  v12 = 0;
+  if ( v1->uActorQueueSize > 0 )
+  {
+    v13 = (char *)&v1->pQueue[0].field_4;
+    do
+    {
+      v11 = *((int *)v13 - 1) & 7;
+      if ( (char)v11 == 4 )
+        break;
+      if ( *(int *)v13 > 0 )
+        break;
+      LOWORD(v11) = v1->_40680F(v12++);
+      v13 += 16;
+    }
+    while ( v12 < v1->uActorQueueSize );
+  }
+  return v11;
+}
+// 4F75D8: using guessed type int ai_arrays_size;
+
+//----- (004061CA) --------------------------------------------------------
+void stru262_TurnBased::NextTurn()
+{
+  stru262_TurnBased *v1; // esi@1
+  TurnBased_QueueElem *v2; // ebp@1
+  int v3; // ebx@1
+  int v4; // edi@7
+  Actor *v5; // eax@9
+  int v6; // ecx@9
+  signed int v7; // ebx@17
+  int v8; // ebp@27
+  TurnBased_QueueElem *v9; // edi@28
+  int v10; // ecx@30
+  unsigned __int16 v11; // ax@30
+  signed int v12; // edx@35
+  signed int v13; // [sp+10h] [bp-4h]@7
+
+  v1 = this;
+  _404544();
+  v2 = v1->pQueue;
+  v3 = 0;
+  if ( (v1->pQueue[0].uPackedID & 7) == 4 )
+    uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1;
+  else
+    uActiveCharacter = 0;
+  viewparams->bRedrawGameUI = 1;
+  if ( v1->field_1C )
+  {
+    pTurnEngine->field_18 |= 2u;
+    return;
+  }
+  pTurnEngine->field_18 &= 0xFFFFFFFDu;
+  if ( v1->pQueue[0].field_4 <= 0 )
+    return;
+  v4 = 0;
+  v13 = 0;
+  if ( v1->uActorQueueSize <= 0 )
+    goto LABEL_27;
+  do
+  {
+    if ( (v2->uPackedID & 7) != 4 )
+    {
+      v5 = &pActors[v2->uPackedID >> 3];
+      LOWORD(v6) = v5->uAIState;
+      if ( (short)v6 == 4
+        || (short)v6 == 8
+        || (short)v6 == 2
+        || (short)v6 == 3
+        || (short)v6 == 12
+        || (short)v6 == 13
+        || (short)v6 == 18
+        || (short)v6 == 17 )
+      {
+        v7 = v5->uCurrentActionLength;
+        v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
+        if ( (signed int)v5->uCurrentActionTime < v7 )
+        {
+          v13 = 1;
+LABEL_19:
+          v3 = 0;
+          goto LABEL_20;
+        }
+        v6 = (signed __int16)v6;
+        if ( (signed __int16)v6 == 4 )
+        {
+          v3 = 0;
+          v5->uAIState = Dead;
+          v5->uCurrentActionTime = 0;
+          v5->uCurrentActionLength = 0;
+          v5->UpdateAnimation();
+        }
+        else
+        {
+          if ( v6 != 8 )
+            goto LABEL_19;
+          v3 = 0;
+          Actor::_403F58(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0);
+        }
+      }
+    }
+LABEL_20:
+    ++v4;
+    ++v2;
+  }
+  while ( v4 < v1->uActorQueueSize );
+  if ( v13 != v3 )
+  {
+    v1->field_18 |= 1u;
+    return;
+  }
+LABEL_27:
+  v1->field_18 &= 0xFFFFFFFEu;
+  v8 = 0;
+  if ( v1->uActorQueueSize > v3 )
+  {
+    v9 = v1->pQueue;
+    do
+    {
+      if ( (v9->uPackedID & 7) != 4 )
+      {
+        v10 = v9->uPackedID >> 3;
+        v11 = pActors[v10].uAIState;
+        if ( v11 != 5 )
+        {
+          if ( v11 != 4 && v11 != 11 && v11 != 19 )
+          {
+            if ( v11 != 17 )
+            {
+              v12 = dword_4F6E08[v10];
+              v9->uActionLength = v3;
+              Actor::_403F58(v10, v12, 32, (AIDirection *)v3);
+            }
+          }
+        }
+      }
+      ++v8;
+      ++v9;
+    }
+    while ( v8 < v1->uActorQueueSize );
+  }
+  v1->field_4 = 3;
+  pParty->uTimePlayed += __PAIR__(v3, 213);
+  _494035_timed_effects__water_walking_damage__etc();
+  v1->uActionPointsLeft = 130;
+}
+
+//----- (004063A1) --------------------------------------------------------
+int stru262_TurnBased::_4063A1()
+{
+  stru262_TurnBased *v1; // esi@1
+  int v2; // ebp@1
+  signed int result; // eax@1
+  int v4; // edx@1
+  int v5; // edx@3
+  int v6; // edi@4
+  int v7; // ecx@5
+  Actor *v8; // ecx@11
+  unsigned __int16 v9; // dx@12
+  int v10; // edi@16
+  int v11; // edx@17
+  char v12; // zf@18
+
+  v1 = this;
+  _404544();
+  v2 = (int)&v1->pQueue[0].field_4;
+  result = 1;
+  viewparams->bRedrawGameUI = 1;
+  v4 = v1->pQueue[0].field_4;
+  if ( v4 )
+  {
+    if ( (v1->pQueue[0].uPackedID & 7) == 4 )
+    {
+      v5 = v1->uActorQueueSize;
+      while ( 1 )
+      {
+        v6 = 0;
+        if ( v5 > 0 )
+        {
+          v7 = (int)&v1->pQueue[0].field_4;
+          do
+          {
+            --*(int *)v7;
+            v5 = v1->uActorQueueSize;
+            ++v6;
+            v7 += 16;
+          }
+          while ( v6 < v5 );
+        }
+        --v1->field_10;
+        if ( v1->field_10 <= 0 )
+          break;
+        if ( !*(int *)v2 )
+          goto LABEL_9;
+      }
+LABEL_24:
+      result = 1;
+    }
+    else
+    {
+      v8 = &pActors[v1->pQueue[0].uPackedID >> 3];
+      if ( v4 > 0 )
+      {
+        do
+        {
+          v9 = v8->uAIState;
+          if ( v9 == 5 )
+            break;
+          if ( v9 == 4 || v9 == 19 || v9 == 11 )
+            break;
+          v10 = 0;
+          if ( v1->uActorQueueSize > 0 )
+          {
+            v11 = (int)&v1->pQueue[0].field_4;
+            do
+            {
+              v12 = (*(int *)v11)-- == 1;
+              if ( v12 )
+                *(int *)(v11 + 4) = 0;
+              ++v10;
+              v11 += 16;
+            }
+            while ( v10 < v1->uActorQueueSize );
+          }
+          --v1->field_10;
+          if ( v1->field_10 <= 0 )
+            goto LABEL_24;
+        }
+        while ( *(int *)v2 > 0 );
+      }
+LABEL_9:
+      result = 0;
+    }
+  }
+  return result;
+}
+
+//----- (00406457) --------------------------------------------------------
+int stru262_TurnBased::_406457(int a2)
+{
+  stru262_TurnBased *v2; // esi@1
+  signed int v3; // eax@1
+  signed int v4; // ecx@2
+  char *v5; // edx@2
+  signed int v6; // eax@2
+  int result; // eax@11
+  int v8; // edx@13
+  int v9; // ecx@14
+  char v10; // zf@15
+
+  v2 = this;
+  v3 = *(&this->field_0 + 4 * (a2 + 2));
+  if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == 4 )
+  {
+    v4 = v3 >> 3;
+    v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3];
+    v6 = *(int *)v5;
+    if ( *(int *)v5 )
+      *(int *)v5 = 0;
+    else
+      v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
+    if ( v6 < 30 )
+      v6 = 30;
+  }
+  else
+  {
+    v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime;
+  }
+  v2->pQueue[a2].field_4 = v6;
+  v2->_404544();
+  if ( (v2->pQueue[0].uPackedID & 7) == 4 )
+    uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1;
+  else
+    uActiveCharacter = 0;
+  result = (int)&v2->pQueue[0].field_4;
+  viewparams->bRedrawGameUI = 1;
+  while ( *(int *)result > 0 )
+  {
+    if ( v2->field_10 <= 0 )
+      break;
+    v8 = 0;
+    if ( v2->uActorQueueSize > 0 )
+    {
+      v9 = (int)&v2->pQueue[0].field_4;
+      do
+      {
+        v10 = (*(int *)v9)-- == 1;
+        if ( v10 )
+          *(int *)(v9 + 4) = 0;
+        ++v8;
+        v9 += 16;
+      }
+      while ( v8 < v2->uActorQueueSize );
+    }
+    --v2->field_10;
+    if ( v2->field_10 <= 0 )
+      break;
+  }
+  return result;
+}
+
+//----- (0040652A) --------------------------------------------------------
+void stru262_TurnBased::_40652A()
+{
+  char *v1; // edx@2
+  Actor *v2; // eax@5
+  unsigned __int16 v3; // si@5
+  unsigned int v4; // esi@8
+  int v5; // [sp+Ch] [bp-4h]@1
+
+  v5 = 0;
+  if ( this->uActorQueueSize > 0 )
+  {
+    v1 = (char *)&this->pQueue[0].field_4;
+    do
+    {
+      if ( !*(int *)v1 )
+      {
+        if ( (*(v1 - 4) & 7) == 4 )
+          return;
+        v2 = &pActors[*((int *)v1 - 1) >> 3];
+        v3 = v2->uAIState;
+        if ( !v3 || v3 == 9 || v3 == 7 )
+        {
+          v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime;
+          *(int *)v1 = v4;
+          if ( (signed __int64)v2->pActorBuffs[7].uExpireTime > 0 )
+            *(int *)v1 = 2 * v4;
+        }
+      }
+      ++v5;
+      v1 += 16;
+    }
+    while ( v5 < this->uActorQueueSize );
+  }
+}
+
+//----- (004065B0) --------------------------------------------------------
+__int16 stru262_TurnBased::_4065B0()
+{
+  stru262_TurnBased *v1; // esi@1
+  signed int v2; // eax@1
+  int v3; // ebx@6
+  int v4; // edi@7
+  unsigned int v5; // edi@14
+
+  v1 = this;
+  LOWORD(v2) = _404544();
+  if ( v1->pQueue[0].field_4 <= 0
+    || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != 4) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2),
+        viewparams->bRedrawGameUI = 1,
+        v1->pQueue[0].field_4 <= 0) )
+  {
+    v3 = 0;
+    if ( v1->uActorQueueSize > 0 )
+    {
+      v4 = (int)v1->pQueue;
+      do
+      {
+        v2 = *(int *)v4;
+        if ( (*(char *)v4 & 7) == 4 || *(int *)(v4 + 4) > 0 )
+          break;
+        if ( *(int *)(v4 + 8) <= 0 )
+        {
+          LOWORD(v2) = v2 & 3;
+          if ( (char)v2 == 3 )
+            LOWORD(v2) = v1->_40680F(v3);
+        }
+        ++v3;
+        v4 += 16;
+      }
+      while ( v3 < v1->uActorQueueSize );
+    }
+  }
+  v5 = 0;
+  if ( v1->uActorQueueSize > 0 )
+  {
+    do
+      LOWORD(v2) = v1->_406648(v5++);
+    while ( (signed int)v5 < v1->uActorQueueSize );
+  }
+  return v2;
+}
+
+//----- (00406648) --------------------------------------------------------
+__int16 stru262_TurnBased::_406648(unsigned int a2)
+{
+  TurnBased_QueueElem *v1; // ecx@1
+  int v3; // eax@1
+  unsigned int v4; // ebx@2
+  Actor *v5; // esi@2
+  signed int v6; // edi@5
+  int v7; // ecx@6
+  int v8; // eax@6
+  int v9; // eax@7
+  int v10; // eax@8
+  int v11; // eax@9
+  int v12; // eax@10
+  int v13; // eax@11
+  int v14; // eax@14
+  unsigned int v15; // ecx@14
+  unsigned int v16; // edx@14
+  int v17; // eax@17
+  int v18; // eax@20
+  char v19; // al@24
+  unsigned int v21; // [sp-8h] [bp-50h]@16
+  int v22; // [sp-8h] [bp-50h]@17
+  AIDirection *v23; // [sp-4h] [bp-4Ch]@14
+  unsigned int v24; // [sp-4h] [bp-4Ch]@17
+  char v25; // [sp-4h] [bp-4Ch]@20
+  AIDirection a3; // [sp+Ch] [bp-3Ch]@2
+  AIDirection a4; // [sp+28h] [bp-20h]@2
+  TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
+  unsigned int a2a; // [sp+50h] [bp+8h]@2
+
+  v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
+  v28 = v1;
+  v3 = v1->uPackedID;
+  if ( (v1->uPackedID & 7) != 4 )
+  {
+    v4 = v3 >> 3;                               // turn based only stuff
+    a2a = dword_4F6E08[v3 >> 3];
+    memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3));
+    memcpy(&a4, &a3, sizeof(a4));
+    v5 = &pActors[v3 >> 3];
+    LOWORD(v3) = v5->uAIState;
+    if ( (short)v3 != Dead )
+    {
+      if ( (short)v3 != Disabled )
+      {
+        if ( (short)v3 != Removed )
+        {
+          v6 = v5->uCurrentActionLength;
+          v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
+          if ( (signed int)v5->uCurrentActionTime >= v6 )
+          {
+            v7 = (signed __int16)v3;
+            v8 = (signed __int16)v3 - 2;
+            if ( !v8 )
+            {
+              v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
+              stru_50FE08.Add(
+                v28->uPackedID,
+                5120,
+                v5->vPosition.x,
+                v5->vPosition.y,
+                v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
+                v19,
+                1);
+              goto LABEL_25;
+            }
+            v9 = v8 - 1;
+            if ( v9 )
+            {
+              v10 = v9 - 1;
+              if ( !v10 )
+                goto LABEL_21;
+              v11 = v10 - 4;
+              if ( !v11 )
+                goto LABEL_25;
+              v12 = v11 - 4;
+              if ( v12 )
+              {
+                v13 = v12 - 1;
+                if ( v13 )
+                {
+                  if ( v13 != Dead )
+                  {
+                    if ( v7 != 4 )
+                    {
+                      v14 = rand();
+                      v15 = v4;
+                      v23 = &a4;
+                      v16 = a2a;
+                      if ( !(v14 % 2) )
+                      {
+                        LOWORD(v3) = Actor::_402F87(v4, a2a, &a4);
+                        return v3;
+                      }
+                      v21 = 64;
+LABEL_26:
+                      LOWORD(v3) = Actor::_403EB6(v15, v16, v21, v23);
+                      return v3;
+                    }
+LABEL_21:
+                    v5->uCurrentActionTime = 0;
+                    v5->uCurrentActionLength = 0;
+                    v5->uAIState = Dead;
+                    return pActors[v4].UpdateAnimation();
+                  }
+                  v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
+                  v22 = 3;
+                  v17 = v5->pMonsterInfo.uSpell2ID;
+                }
+                else
+                {
+                  v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
+                  v22 = 2;
+                  v17 = v5->pMonsterInfo.uSpell1ID;
+                }
+                Actor::_404AC7(v4, &a4, v17, v22, v24);
+LABEL_25:
+                v16 = a2a;
+                v23 = &a4;
+                v21 = 0;
+                v15 = v4;
+                goto LABEL_26;
+              }
+              v18 = v5->pMonsterInfo.uMissleAttack2Type;
+              v25 = 1;
+            }
+            else
+            {
+              v18 = v5->pMonsterInfo.uMissleAttack1Type;
+              v25 = 0;
+            }
+            Actor::_404874(v4, &a4, v18, v25);
+            goto LABEL_25;
+          }
+        }
+      }
+    }
+  }
+  return v3;
+}
+// 50FE08: using guessed type stru298 stru_50FE08;
+
+//----- (0040680F) --------------------------------------------------------
+__int16 stru262_TurnBased::_40680F(int a2)
+{
+  TurnBased_QueueElem *v2; // eax@1
+  TurnBased_QueueElem *v3; // eax@1
+  TurnBased_QueueElem *v4; // edi@2
+  Actor *v5; // ebx@2
+  unsigned int *v6; // esi@7
+  AIDirection *v7; // esi@10
+  int v8; // eax@10
+  unsigned int v9; // ecx@10
+  signed int v10; // eax@13
+  unsigned __int8 v11; // sf@19
+  unsigned __int8 v12; // of@19
+  int v13; // esi@29
+  bool v14; // eax@29
+  unsigned __int8 v15; // cl@33
+  AIDirection a3; // [sp+Ch] [bp-44h]@10
+  AIDirection v18; // [sp+28h] [bp-28h]@10
+  int a2a; // [sp+44h] [bp-Ch]@2
+  unsigned int v20; // [sp+48h] [bp-8h]@10
+  TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
+  signed int v22; // [sp+58h] [bp+8h]@10
+
+  v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
+  v21 = v2;
+  v2->uActionLength = 0;
+  v3 = (TurnBased_QueueElem *)v2->uPackedID;
+  if ( (unsigned __int8)v3 & 3 )
+  {
+    v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3);
+    v4 = v3;
+    a2a = (int)v3;
+    v5 = &pActors[(int)v3];
+    LOWORD(v3) = v5->uAIState;
+    if ( (short)v3 != 5 )
+    {
+      if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
+      {
+        v6 = (unsigned int *)&dword_4F6E08[(int)v4];
+        Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u);
+        if ( v5->pMonsterInfo.uHostilityType && !*v6 )
+          v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+        v22 = *v6;
+        v7 = Actor::GetDirectionInfo(8 * (int)v4 | 3, *v6, &a3, 0);
+        v8 = v5->uActorRadius;
+        memcpy(&a3, v7, sizeof(a3));
+        memcpy(&v18, &a3, sizeof(v18));
+        v9 = a3.uDistance - v8;
+        v20 = a3.uDistance - v8;
+        if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
+        {
+          v9 = 0;
+          v20 = 0;
+        }
+        if ( (v22 & 7) == 3 )
+          v10 = (unsigned __int8)*(&byte_5C8D1A[89
+                                              * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1)
+                                              / 3]
+                                 + (v5->pMonsterInfo.uID - 1) / 3);
+        else
+          v10 = 4;
+        if ( v10 == 1 )
+        {
+          if ( (double)(signed int)v20 < 307.2 )
+            goto LABEL_25;
+        }
+        else
+        {
+          if ( v10 == 2 )
+          {
+            v12 = __OFSUB__(v9, 1024);
+            v11 = ((v9 - 1024) & 0x80000000u) != 0;
+          }
+          else
+          {
+            if ( v10 == 3 )
+            {
+              v12 = __OFSUB__(v9, 2560);
+              v11 = ((v9 - 2560) & 0x80000000u) != 0;
+            }
+            else
+            {
+              if ( v10 != 4 )
+                goto LABEL_26;
+              v12 = __OFSUB__(v9, 5120);
+              v11 = ((v9 - 5120) & 0x80000000u) != 0;
+            }
+          }
+          if ( v11 ^ v12 )
+          {
+LABEL_25:
+            v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+            goto LABEL_26;
+          }
+        }
+LABEL_26:
+        if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
+        {
+          v13 = a2a;
+          goto LABEL_47;
+        }
+        v13 = a2a;
+        v14 = stru_50C198.special_ability_use_check(v5, a2a);
+        if ( v14 == 1 )
+        {
+          if ( v5->pMonsterInfo.uMissleAttack2Type )
+          {
+            Actor::_40368B(v13, v22, &v18);
+            goto LABEL_43;
+          }
+        }
+        else
+        {
+          if ( v14 > 1 && v14 <= 3 )
+          {
+            if ( v14 == 2 )
+              v15 = v5->pMonsterInfo.uSpell1ID;
+            else
+              v15 = v5->pMonsterInfo.uSpell2ID;
+            if ( v15 )
+            {
+              if ( v14 == 2 )
+                Actor::_403854(v13, v22, &v18);
+              else
+                Actor::_403A60(v13, v22, &v18);
+              goto LABEL_43;
+            }
+            goto LABEL_44;
+          }
+          if ( v5->pMonsterInfo.uMissleAttack1Type )
+          {
+            Actor::_403476(v13, v22, &v18);
+LABEL_43:
+            v3 = v21;
+            v21->field_C = 1;
+LABEL_48:
+            v3->uActionLength = v5->uCurrentActionLength;
+            return (signed __int16)v3;
+          }
+        }
+LABEL_44:
+        if ( (double)(signed int)v20 < 307.2 )
+        {
+          Actor::_403C6C(v13, v22, &v18);
+          v3 = v21;
+          v21->field_C = 3;
+          goto LABEL_48;
+        }
+LABEL_47:
+        Actor::_403EB6(v13, v22, 0x40u, &v18);
+        v3 = v21;
+        v21->field_C = 0;
+        goto LABEL_48;
+      }
+    }
+  }
+  return (signed __int16)v3;
+}
+
+//----- (00406A63) --------------------------------------------------------
+void stru262_TurnBased::_406A63()
+{
+  stru262_TurnBased *v1; // ebx@1
+  int v2; // esi@1
+  unsigned __int8 v3; // zf@1
+  unsigned __int8 v4; // sf@1
+  signed int v5; // ecx@4
+  AIDirection a3; // [sp+8h] [bp-44h]@5
+  AIDirection v7; // [sp+24h] [bp-28h]@5
+  unsigned int v8; // [sp+40h] [bp-Ch]@5
+  signed int a2; // [sp+44h] [bp-8h]@1
+  TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
+
+  v1 = this;
+  v2 = 0;
+  this->field_8 = 64;
+  dword_50C994 = 0;
+  uActiveCharacter = 0;
+  v3 = this->uActorQueueSize == 0;
+  v4 = this->uActorQueueSize < 0;
+  a2 = 0;
+  if ( !(v4 | v3) )
+  {
+    v10 = this->pQueue;
+    while ( 1 )
+    {
+      v5 = v10->uPackedID;
+      if ( (v10->uPackedID & 7) == 3 )
+      {
+        v8 = dword_4F6E08[v5 >> 3];
+        memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
+        if ( !v1->_406D10(a2) )
+          Actor::_403EB6(v10->uPackedID >> 3, v8, 0x20u, &v7);
+      }
+      ++a2;
+      ++v10;
+      if ( a2 >= v1->uActorQueueSize )
+        break;
+      v2 = 0;
+    }
+  }
+}
+// 50C994: using guessed type int dword_50C994;
+
+//----- (00406AFE) --------------------------------------------------------
+void stru262_TurnBased::_406AFE()
+{
+  stru262_TurnBased *v1; // edi@1
+  TurnBased_QueueElem *v2; // ebx@2
+  int v3; // esi@4
+  int v4; // ecx@5
+  AIDirection a3; // [sp+4h] [bp-48h]@5
+  AIDirection v6; // [sp+20h] [bp-2Ch]@5
+  stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1
+  unsigned int v8; // [sp+40h] [bp-Ch]@4
+  unsigned int v9; // [sp+44h] [bp-8h]@5
+  int v10; // [sp+48h] [bp-4h]@1
+
+  v10 = 0;
+  v1 = this;
+  v7 = this;
+  if ( this->uActorQueueSize > 0 )
+  {
+    v2 = this->pQueue;
+    do
+    {
+      if ( (v2->uPackedID & 7) == 3 )
+      {
+        v3 = v2->uPackedID >> 3;
+        v8 = v3;
+        if ( pActors[v3].CanAct() )
+        {
+          v4 = v2->uPackedID;
+          v9 = dword_4F6E08[v3];
+          memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
+          Actor::_403EB6(v8, v9, 0x20u, &v6);
+          v2->field_C = 0;
+          v2->uActionLength = 0;
+          v1 = v7;
+        }
+      }
+      ++v10;
+      ++v2;
+    }
+    while ( v10 < v1->uActorQueueSize );
+  }
+  v1->field_4 = 2;
+  v1->field_8 = 100;
+}
+
+//----- (00406B9F) --------------------------------------------------------
+int stru262_TurnBased::_406B9F()
+{
+  signed int result; // eax@1
+  unsigned __int8 v2; // zf@1
+  unsigned __int8 v3; // sf@1
+  int v4; // esi@4
+  unsigned int v5; // esi@5
+  Actor *v6; // ebx@5
+  unsigned __int16 v7; // cx@15
+  AIDirection a3; // [sp+0h] [bp-50h]@15
+  AIDirection v9; // [sp+1Ch] [bp-34h]@15
+  signed int a1; // [sp+38h] [bp-18h]@4
+  stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
+  unsigned int v12; // [sp+40h] [bp-10h]@5
+  unsigned int v13; // [sp+44h] [bp-Ch]@8
+  TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
+  signed int a2; // [sp+4Ch] [bp-4h]@1
+
+  result = 0;
+  thisa = this;
+  v2 = this->uActorQueueSize == 0;
+  v3 = this->uActorQueueSize < 0;
+  a2 = 0;
+  if ( !(v3 | v2) )
+  {
+    v14 = this->pQueue;
+    while ( 1 )
+    {
+      v4 = v14->uPackedID;
+      a1 = v14->uPackedID;
+      if ( (a1 & 7) != 4 )
+      {
+        v5 = v4 >> 3;
+        v12 = v5;
+        v6 = &pActors[v5];
+        if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
+          || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
+          v13 = result;
+        else
+          v13 = 1;
+        if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
+          && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
+          result = 1;
+        if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) )
+        {
+          v13 = dword_4F6E08[v5];
+          memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
+          v7 = v6->uAIState;
+          if ( v7 == 6 || v7 == 1 )
+          {
+            if ( (double)(signed int)v9.uDistance < 307.2 )
+              goto LABEL_26;
+          }
+          v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
+          if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
+          {
+            if ( v7 == 4 )
+            {
+              v6->uCurrentActionTime = 0;
+              v6->uCurrentActionLength = 0;
+              v6->uAIState = Dead;
+              v6->UpdateAnimation();
+            }
+            if ( !thisa->_406D10(a2) )
+LABEL_26:
+              Actor::_403EB6(v12, v13, 0x20u, &v9);
+          }
+        }
+      }
+      ++a2;
+      result = (signed int)thisa;
+      ++v14;
+      if ( a2 >= thisa->uActorQueueSize )
+        break;
+      result = 0;
+    }
+  }
+  return result;
+}
+
+//----- (00406D10) --------------------------------------------------------
+bool stru262_TurnBased::_406D10(signed int a2)
+{
+  int v2; // ecx@1
+  int v3; // ecx@2
+  Actor *v4; // ebx@2
+  unsigned __int16 v5; // dx@2
+  int *v6; // esi@7
+  TurnBased_QueueElem *v7; // edi@7
+  int v8; // eax@7
+  AIDirection *v9; // esi@10
+  int v10; // eax@10
+  unsigned int v11; // ecx@10
+  unsigned __int8 v12; // al@12
+  unsigned __int8 v13; // sf@16
+  unsigned __int8 v14; // of@16
+  unsigned int v15; // edx@22
+  unsigned int v16; // ecx@23
+  TurnBased_QueueElem *v17; // eax@25
+  double v18; // st7@33
+  double v19; // st6@33
+  int v21; // [sp-8h] [bp-5Ch]@23
+  int v22; // [sp-8h] [bp-5Ch]@26
+  AIDirection *v23; // [sp-4h] [bp-58h]@23
+  int v24; // [sp-4h] [bp-58h]@26
+  AIDirection a3; // [sp+Ch] [bp-48h]@10
+  AIDirection pDir; // [sp+28h] [bp-2Ch]@10
+  int v27; // [sp+44h] [bp-10h]@33
+  unsigned int v28; // [sp+48h] [bp-Ch]@10
+  TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
+  unsigned int uActorID; // [sp+50h] [bp-4h]@2
+  unsigned int a2a; // [sp+5Ch] [bp+8h]@7
+
+  v2 = *(&this->field_0 + 4 * (a2 + 2));
+  if ( (v2 & 7) == 4 )
+    return 0;
+  v3 = v2 >> 3;
+  uActorID = v3;
+  v4 = &pActors[v3];
+  v5 = v4->uAIState;
+  if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 )
+    return 1;
+  v6 = &dword_4F6E08[v3];
+  v7 = &pTurnEngine->pQueue[a2];
+  v8 = *v6;
+  v29 = &pTurnEngine->pQueue[a2];
+  a2a = v8;
+  Actor::_401221(v3, &dword_4F6E08[v3], 1u);
+  if ( v4->pMonsterInfo.uHostilityType && !*v6 )
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+  v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
+  v10 = v4->uActorRadius;
+  memcpy(&a3, v9, sizeof(a3));
+  memcpy(&pDir, &a3, sizeof(pDir));
+  v11 = a3.uDistance - v10;
+  v28 = a3.uDistance - v10;
+  if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
+  {
+    v11 = 0;
+    v28 = 0;
+  }
+  v12 = v4->pMonsterInfo.uHostilityType;
+  if ( v12 == 1 )
+  {
+    if ( (double)(signed int)v28 >= 307.2 )
+      goto LABEL_21;
+LABEL_20:
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+    goto LABEL_21;
+  }
+  if ( v12 == 2 )
+  {
+    v14 = __OFSUB__(v11, 1024);
+    v13 = ((v11 - 1024) & 0x80000000u) != 0;
+  }
+  else
+  {
+    if ( v12 != 3 )
+      goto LABEL_21;
+    v14 = __OFSUB__(v11, 2560);
+    v13 = ((v11 - 2560) & 0x80000000u) != 0;
+  }
+  if ( v13 ^ v14 )
+    goto LABEL_20;
+LABEL_21:
+  if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
+  {
+    v15 = a2a;
+    if ( (signed int)v11 < 10240 )
+    {
+      v23 = &pDir;
+      v16 = uActorID;
+      v21 = 0;
+      goto LABEL_24;
+    }
+    v24 = 0;
+    v22 = 1024;
+    goto LABEL_58;
+  }
+  if ( v4->pMonsterInfo.uHostilityType != 4 )
+    goto LABEL_46;
+  if ( !(v4->uAttributes & 0x020000) || v4->pMonsterInfo.uAIType == 1 )
+  {
+    if ( v4->pMonsterInfo.uAIType == 1 )
+      goto LABEL_36;
+    if ( v4->pMonsterInfo.uAIType == 2 )
+    {
+      v27 = v4->sCurrentHP;
+      v18 = (double)v27;
+      v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.2;
+      goto LABEL_34;
+    }
+    if ( v4->pMonsterInfo.uAIType == 3 )
+    {
+      v27 = v4->sCurrentHP;
+      v18 = (double)v27;
+      v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.1;
+LABEL_34:
+      if ( v19 > v18 && (signed int)v11 < 10240 )
+      {
+LABEL_36:
+        v16 = uActorID;
+        v15 = a2a;
+        v23 = 0;
+        v21 = 32;
+        if ( v4->pMonsterInfo.uMovementType == 5 )
+        {
+          Actor::_403EB6(uActorID, a2a, 0x20u, 0);
+          goto LABEL_25;
+        }
+LABEL_24:
+        Actor::_402968(v16, v15, v21, v23);
+LABEL_25:
+        v17 = v29;
+        v29->field_C = 4;
+LABEL_60:
+        v17->uActionLength = v4->uCurrentActionLength;
+        return 1;
+      }
+      goto LABEL_39;
+    }
+  }
+LABEL_39:
+  if ( (double)(signed int)v28 < 307.2 )
+    return 0;
+  if ( (signed int)v11 < 5120 )
+  {
+    if ( v4->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
+      Actor::_402AD7(uActorID, a2a, uActorID, 32, &pDir);
+    else
+      Actor::_40281C(uActorID, a2a, 32, &pDir, 307);
+    goto LABEL_59;
+  }
+LABEL_46:
+  if ( !v4->pMonsterInfo.uMovementType )
+  {
+    v24 = 32;
+    v22 = 1024;
+    goto LABEL_57;
+  }
+  if ( v4->pMonsterInfo.uMovementType == 1 )
+  {
+    v24 = 32;
+    v22 = 2560;
+    goto LABEL_57;
+  }
+  if ( v4->pMonsterInfo.uMovementType == 2 )
+  {
+    v24 = 32;
+    v22 = 5120;
+LABEL_57:
+    v15 = a2a;
+LABEL_58:
+    Actor::_4032B2(uActorID, v15, v22, v24);
+LABEL_59:
+    v17 = v29;
+    v29->field_C = 2;
+    goto LABEL_60;
+  }
+  if ( v4->pMonsterInfo.uMovementType == 4 )
+  {
+    Actor::_4032B2(uActorID, a2a, 10240, 32);
+    goto LABEL_53;
+  }
+  if ( v4->pMonsterInfo.uMovementType == 5 )
+  {
+    Actor::_403EB6(uActorID, a2a, 0x20u, 0);
+LABEL_53:
+    v17 = v29;
+    v29->field_C = 2;
+    goto LABEL_60;
+  }
+  return 1;
+}
+
+//----- (00406FA8) --------------------------------------------------------
+void stru262_TurnBased::_406FA8()
+{
+  unsigned __int8 v1; // zf@1
+  unsigned __int8 v2; // sf@1
+  TurnBased_QueueElem *v3; // edi@2
+  int v4; // eax@4
+  Actor *v5; // ebx@4
+  unsigned __int16 v6; // cx@4
+  unsigned int *v7; // edx@8
+  unsigned int v8; // esi@8
+  unsigned __int8 v9; // of@13
+  AIDirection a3; // [sp+Ch] [bp-6Ch]@8
+  AIDirection v11; // [sp+28h] [bp-50h]@8
+  AIDirection a4; // [sp+44h] [bp-34h]@8
+  stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
+  TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
+  int uActorID; // [sp+68h] [bp-10h]@4
+  unsigned int a2; // [sp+6Ch] [bp-Ch]@8
+  int v17; // [sp+70h] [bp-8h]@1
+  unsigned int v18; // [sp+74h] [bp-4h]@2
+
+  v17 = 0;
+  v1 = this->uActorQueueSize == 0;
+  v2 = this->uActorQueueSize < 0;
+  v13 = this;
+  if ( !(v2 | v1) )
+  {
+    v3 = this->pQueue;
+    v18 = (char *)&pTurnEngine - (char *)this;
+    v14 = this->pQueue;
+    do
+    {
+      if ( (v3->uPackedID & 7) != 4 )
+      {
+        v4 = v3->uPackedID >> 3;
+        uActorID = v4;
+        v5 = &pActors[v4];
+        v6 = v5->uAIState;
+        if ( v6 != 5 )
+        {
+          if ( v6 != 11 )
+          {
+            if ( v6 != 19 )
+            {
+              if ( v6 != 17 )
+              {
+                v7 = (unsigned int *)&dword_4F6E08[v4];
+                a2 = *v7;
+                v8 = a2;
+                Actor::_401221(v4, (int *)v7, 1u);
+                memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
+                memcpy(&a4, &v11, sizeof(a4));
+                v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+                if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
+                {
+                  if (v5->uAIState == Dying)
+                  {
+                    v5->uCurrentActionTime = 0;
+                    v5->uCurrentActionLength = 0;
+                    v5->uAIState = Dead;
+                    v5->UpdateAnimation();
+                    return;
+                  }
+                  if ( rand() % 2 )
+                    Actor::_403EB6(uActorID, a2, 0x40u, &a4);
+                  else
+                    Actor::_402F87(uActorID, a2, &a4);
+                }
+              }
+            }
+          }
+        }
+      }
+      ++v17;
+      v3 = v14 + 1;
+      v9 = __OFSUB__(v17, v13->uActorQueueSize);
+      v2 = v17 - v13->uActorQueueSize < 0;
+      ++v14;
+    }
+    while ( v2 ^ v9 );
+  }
+}
+
+//----- (004070EF) --------------------------------------------------------
+bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID)
+{
+  signed int v2; // eax@1
+  unsigned int v3; // ecx@1
+  signed int v4; // esi@1
+  int v5; // ecx@2
+  signed int v6; // eax@4
+  int v7; // eax@4
+  float v8; // ST24_4@5
+  double v9; // ST18_8@5
+  signed int v10; // eax@6
+  int v11; // ecx@6
+  signed int v12; // eax@7
+  int v13; // esi@7
+  int v14; // esi@8
+  int v15; // esi@9
+  signed int v16; // eax@11
+  int v17; // edi@11
+  int v18; // esi@11
+  int v19; // eax@13
+  float v20; // ST24_4@14
+  double v21; // ST18_8@14
+  signed int v22; // eax@15
+  int v23; // ebx@16
+  signed int v24; // ecx@16
+  int v25; // eax@18
+  int v26; // eax@28
+  BLVSector *v27; // edx@31
+  int v28; // ecx@31
+  BLVFace *v29; // ebx@32
+  Vec3_short_ *v30; // esi@32
+  int v31; // eax@32
+  int v32; // ST50_4@44
+  int v33; // ST54_4@44
+  int v34; // eax@44
+  char v35; // zf@44
+  int v36; // edi@44
+  int v37; // eax@45
+  signed int v38; // esi@45
+  int v39; // ST4C_4@49
+  signed __int64 v40; // qtt@50
+  __int16 v42; // bx@58
+  int v43; // [sp-8h] [bp-70h]@11
+  int v44; // [sp-4h] [bp-6Ch]@11
+  int v45; // [sp+Ch] [bp-5Ch]@32
+  __int16 v46; // [sp+10h] [bp-58h]@32
+  int v47; // [sp+18h] [bp-50h]@20
+  int v48; // [sp+1Ch] [bp-4Ch]@20
+  int v49; // [sp+20h] [bp-48h]@20
+  int v50; // [sp+24h] [bp-44h]@16
+  signed int v51; // [sp+24h] [bp-44h]@27
+  signed int v52; // [sp+28h] [bp-40h]@26
+  signed int v53; // [sp+2Ch] [bp-3Ch]@23
+  signed int v54; // [sp+30h] [bp-38h]@22
+  signed int v55; // [sp+34h] [bp-34h]@21
+  signed int v56; // [sp+38h] [bp-30h]@20
+  signed int v57; // [sp+3Ch] [bp-2Ch]@28
+  int v58; // [sp+44h] [bp-24h]@50
+  int v59; // [sp+48h] [bp-20h]@44
+  int v60; // [sp+50h] [bp-18h]@11
+  signed int v61; // [sp+50h] [bp-18h]@31
+  int v62; // [sp+54h] [bp-14h]@16
+  int v63; // [sp+58h] [bp-10h]@4
+  int v64; // [sp+5Ch] [bp-Ch]@4
+  int v65; // [sp+60h] [bp-8h]@4
+  int v66; // [sp+64h] [bp-4h]@7
+
+  v2 = (signed int)uObjID >> 3;
+  v3 = (uObjID & 7) - 2;
+  v4 = uObj2ID;
+  if ( v3 )
+  {
+    v5 = v3 - 1;
+    if ( v5 )
+    {
+      if ( v5 != 2 )
+        return 0;
+      v6 = v2;
+      v63 = pLevelDecorations[v6].vPosition.x;
+      v64 = pLevelDecorations[v6].vPosition.y;
+      v65 = pLevelDecorations[v6].vPosition.z;
+      v7 = pIndoor->GetSector(v63, v64, v65);
+    }
+    else
+    {
+      v63 = pActors[v2].vPosition.x;
+      v64 = pActors[v2].vPosition.y;
+      v8 = (double)pActors[v2].uActorHeight * 0.69999999;
+      v9 = v8 + 6.7553994e15;
+      v65 = LODWORD(v9) + pActors[v2].vPosition.z;
+      v7 = pActors[v2].uSectorID;
+    }
+  }
+  else
+  {
+    v10 = v2;
+    v63 = pLayingItems[v10].vPosition.x;
+    v64 = pLayingItems[v10].vPosition.y;
+    v11 = pLayingItems[v10].vPosition.z;
+    v7 = pLayingItems[v10].uSectorID;
+    v65 = v11;
+  }
+  v66 = v7;
+  v12 = v4 >> 3;
+  v13 = (v4 & 7) - 2;
+  if ( v13 )
+  {
+    v14 = v13 - 1;
+    if ( v14 )
+    {
+      v15 = v14 - 1;
+      if ( v15 )
+      {
+        if ( v15 != 1 )
+          return 0;
+        v16 = v12;
+        v17 = pLevelDecorations[v16].vPosition.z;
+        v18 = pLevelDecorations[v16].vPosition.x;
+        v44 = pLevelDecorations[v16].vPosition.z;
+        v60 = pLevelDecorations[v16].vPosition.y;
+        v43 = pLevelDecorations[v16].vPosition.y;
+      }
+      else
+      {
+        v18 = pParty->vPosition.x;
+        v17 = pParty->sEyelevel + pParty->vPosition.z;
+        v60 = pParty->vPosition.y;
+        v44 = pParty->sEyelevel + pParty->vPosition.z;
+        v43 = pParty->vPosition.y;
+      }
+      v19 = pIndoor->GetSector(v18, v43, v44);
+    }
+    else
+    {
+      v60 = pActors[v12].vPosition.y;
+      v18 = pActors[v12].vPosition.x;
+      v20 = (double)pActors[v12].uActorHeight * 0.69999999;
+      v21 = v20 + 6.7553994e15;
+      v17 = LODWORD(v21) + pActors[v12].vPosition.z;
+      v19 = pActors[v12].uSectorID;
+    }
+  }
+  else
+  {
+    v22 = v12;
+    v18 = pLayingItems[v22].vPosition.x;
+    v17 = pLayingItems[v22].vPosition.z;
+    v60 = pLayingItems[v22].vPosition.y;
+    v19 = pLayingItems[v22].uSectorID;
+  }
+  v62 = v19;
+  v23 = v18 - v63;
+  v50 = v17 - v65;
+  v24 = sub_452A9E(v23 * v23 + (v60 - v64) * (v60 - v64) + v50 * v50);
+  if ( v24 > 5120 )
+    return 0;
+  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    return 1;
+  v25 = 65536;
+  if ( v24 )
+    v25 = 65536 / v24;
+  v49 = v23 * v25;
+  v47 = v50 * v25;
+  v48 = (v60 - v64) * v25;
+  v56 = v63;
+  if ( v63 < v18 )
+  {
+    v55 = v18;
+  }
+  else
+  {
+    v56 = v18;
+    v55 = v63;
+  }
+  v54 = v64;
+  if ( v64 < v60 )
+  {
+    v53 = v60;
+  }
+  else
+  {
+    v54 = v60;
+    v53 = v64;
+  }
+  v52 = v65;
+  if ( v65 < v17 )
+  {
+    v51 = v17;
+  }
+  else
+  {
+    v52 = v17;
+    v51 = v65;
+  }
+  v57 = 0;
+  v26 = v66;
+  while ( 2 )
+  {
+    if ( v26 == v62 )
+      return 1;
+    if ( v57 >= 30 || (v27 = pIndoor->pSectors, v28 = v66, v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) )
+      break;
+    while ( 1 )
+    {
+      v29 = &pIndoor->pFaces[v27[v28].pPortals[v61]];
+      v30 = &pIndoor->pVertices[*v29->pVertexIDs];
+      v45 = *(int *)&v30->x;
+      v46 = v30->z;
+      v31 = v29->pFacePlane_old.vNormal.z * (v46 - v65)
+          + v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - v64)
+          + v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - v63);
+      if ( v66 != v29->uSectorID )
+        v31 = -v31;
+      if ( v31 >= 0 && (signed __int16)v45 != v63 && SHIWORD(v45) != v64 && v46 != v65
+        || v56 > v29->pBounding.x2
+        || v55 < v29->pBounding.x1
+        || v54 > v29->pBounding.y2
+        || v53 < v29->pBounding.y1
+        || v52 > v29->pBounding.z2
+        || v51 < v29->pBounding.z1 )
+        goto LABEL_54;
+      v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16;
+      v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16;
+      v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16;
+      v35 = v32 + v33 + v34 == 0;
+      v36 = v32 + v33 + v34;
+      v59 = v32 + v33 + v34;
+      if ( v35 )
+        goto LABEL_53;
+      v37 = v65 * v29->pFacePlane_old.vNormal.z;
+      v38 = -(v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y);
+      if ( v36 <= 0 )
+        break;
+      if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y <= 0 )
+        goto LABEL_49;
+LABEL_53:
+      v27 = pIndoor->pSectors;
+LABEL_54:
+      ++v61;
+      if ( v61 >= v27[v28].uNumPortals )
+        goto LABEL_55;
+    }
+    if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y < 0 )
+      goto LABEL_53;
+LABEL_49:
+    v39 = abs(-(v29->pFacePlane_old.dist
+              + v37
+              + v63 * v29->pFacePlane_old.vNormal.x
+              + v64 * v29->pFacePlane_old.vNormal.y)) >> 14;
+    if ( v39 > abs(v36)
+      || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0)
+      || !sub_4075DB(
+            v63 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16),
+            v64 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16),
+            v65 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16),
+            v29) )
+    {
+      v28 = v66;
+      goto LABEL_53;
+    }
+    if ( v29->uSectorID == v66 )
+      v42 = v29->uBackSectorID;
+    else
+      v42 = v29->uSectorID;
+    v26 = v42;
+    if ( v42 != v66 )
+    {
+      ++v57;
+      v66 = v42;
+      continue;
+    }
+    break;
+  }
+LABEL_55:
+  if ( v66 != v62 )
+    return 0;
+  return 1;
+}
+
+//----- (004075DB) --------------------------------------------------------
+bool __fastcall sub_4075DB(int a1, int a2, int a3, BLVFace *a4)
+{
+  BLVFace *v4; // eax@1
+  unsigned int v5; // esi@1
+  signed int v6; // esi@2
+  char v7; // zf@2
+  int v8; // edi@2
+  Vec3_short_ *v9; // ecx@3
+  int v10; // edx@4
+  signed int v11; // esi@7
+  Vec3_short_ *v12; // ecx@8
+  int v13; // edx@9
+  signed int v14; // esi@11
+  Vec3_short_ *v15; // ecx@12
+  int v16; // edx@13
+  int v17; // eax@14
+  bool v18; // esi@14
+  int v19; // ecx@14
+  int v20; // ecx@16
+  int v21; // edx@16
+  int v22; // eax@17
+  signed int v23; // ebx@18
+  int v24; // esi@20
+  signed int v25; // eax@22
+  signed __int64 v26; // qtt@22
+  bool result; // eax@25
+  int v28; // [sp+8h] [bp-14h]@14
+  int v29; // [sp+10h] [bp-Ch]@14
+  signed int a3a; // [sp+24h] [bp+8h]@14
+  int a4a; // [sp+28h] [bp+Ch]@2
+
+  v4 = a4;
+  v5 = a4->uAttributes;
+  if ( v5 & 0x100 )
+  {
+    v6 = 0;
+    v7 = a4->uNumVertices == 0;
+    a4a = a1;
+    v8 = a2;
+    if ( !v7 )
+    {
+      v9 = pIndoor->pVertices;
+      do
+      {
+        dword_4F5D98_xs[v6] = v9[v4->pVertexIDs[v6]].x;
+        v10 = v4->pVertexIDs[v6++];
+        dword_4F5CC4_ys[v6] = v9[v10].y;
+      }
+      while ( v6 < v4->uNumVertices );
+    }
+  }
+  else
+  {
+    v8 = a3;
+    if ( v5 & 0x200 )
+    {
+      v11 = 0;
+      v7 = a4->uNumVertices == 0;
+      a4a = a1;
+      if ( !v7 )
+      {
+        v12 = pIndoor->pVertices;
+        do
+        {
+          dword_4F5D98_xs[v11] = v12[v4->pVertexIDs[v11]].x;
+          v13 = v4->pVertexIDs[v11++];
+          dword_4F5CC4_ys[v11] = v12[v13].z;
+        }
+        while ( v11 < v4->uNumVertices );
+      }
+    }
+    else
+    {
+      v14 = 0;
+      v7 = a4->uNumVertices == 0;
+      a4a = a2;
+      if ( !v7 )
+      {
+        v15 = pIndoor->pVertices;
+        do
+        {
+          dword_4F5D98_xs[v14] = v15[v4->pVertexIDs[v14]].y;
+          v16 = v4->pVertexIDs[v14++];
+          dword_4F5CC4_ys[v14] = v15[v16].z;
+        }
+        while ( v14 < v4->uNumVertices );
+      }
+    }
+  }
+  v17 = v4->uNumVertices;
+  a3a = 0;
+  dword_4F5D98_xs[v17] = dword_4F5D98_xs[0];
+  dword_4F5CC4_ys[v17 + 1] = dword_4F5CC4_ys[1];
+  v28 = v17;
+  v18 = dword_4F5CC4_ys[1] >= v8;
+  v19 = 0;
+  v29 = 0;
+  if ( v17 <= 0 )
+    goto LABEL_29;
+  do
+  {
+    if ( a3a >= 2 )
+      break;
+    v20 = v19;
+    v21 = dword_4F5CC4_ys[v20 + 2];
+    if ( v18 ^ v21 >= v8 )
+    {
+      v22 = dword_4F5D98_xs[v20 + 1];
+      if ( v22 >= a4a )
+        v23 = 0;
+      else
+        v23 = 2;
+      v24 = v23 | dword_4F5D98_xs[v20] < a4a;
+      if ( v24 != 3 )
+      {
+        if ( !v24
+          || (v25 = v22 - dword_4F5D98_xs[v20],
+              LODWORD(v26) = v25 << 16,
+              HIDWORD(v26) = v25 >> 16,
+              dword_4F5D98_xs[v20]
+            + ((signed int)(((unsigned __int64)(v26
+                                              / (v21 - dword_4F5CC4_ys[v20 + 1])
+                                              * ((v8 - dword_4F5CC4_ys[v20 + 1]) << 16)) >> 16)
+                          + 32768) >> 16) >= a4a) )
+          ++a3a;
+      }
+    }
+    v18 = v21 >= v8;
+    v19 = v29++ + 1;
+  }
+  while ( v29 < v28 );
+  result = 1;
+  if ( a3a != 1 )
+LABEL_29:
+    result = 0;
+  return result;
+}
+
+//----- (004077F1) --------------------------------------------------------
+bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *a4, BSPVertexBuffer *a5)
+{
+  ODMFace *v5; // eax@1
+  unsigned int v6; // esi@1
+  signed int v7; // edi@1
+  char v8; // zf@2
+  unsigned __int16 *v9; // edx@3
+  int v10; // ecx@4
+  unsigned __int16 *v11; // edx@8
+  int v12; // ecx@9
+  int v13; // edx@12
+  int v14; // ecx@13
+  int v15; // esi@14
+  bool v16; // edi@14
+  int v17; // ecx@16
+  int v18; // edx@16
+  int v19; // eax@17
+  signed int v20; // ebx@18
+  int v21; // edi@20
+  signed int v22; // eax@22
+  signed __int64 v23; // qtt@22
+  bool result; // eax@25
+  int v25; // [sp+14h] [bp-8h]@14
+  int a4a; // [sp+28h] [bp+Ch]@2
+  signed int a5a; // [sp+2Ch] [bp+10h]@14
+
+  v5 = a4;
+  v6 = a4->uAttributes;
+  v7 = 0;
+  if ( v6 & 0x100 )
+  {
+    v8 = a4->uNumVertices == 0;
+    a4a = a1;
+    a3 = a2;
+    if ( !v8 )
+    {
+      v9 = v5->pVertexIDs;
+      do
+      {
+        ++v7;
+        dword_4F5BF4_xs[v7] = a5->pVertices[*v9].x;
+        v10 = *v9;
+        ++v9;
+        dword_4F5B24_ys[v7] = a5->pVertices[v10].y;
+      }
+      while ( v7 < v5->uNumVertices );
+    }
+  }
+  else
+  {
+    if ( v6 & 0x200 )
+    {
+      v8 = a4->uNumVertices == 0;
+      a4a = a1;
+      if ( !v8 )
+      {
+        v11 = v5->pVertexIDs;
+        do
+        {
+          ++v7;
+          dword_4F5BF4_xs[v7] = a5->pVertices[*v11].x;
+          v12 = *v11;
+          ++v11;
+          dword_4F5B24_ys[v7] = a5->pVertices[v12].z;
+        }
+        while ( v7 < v5->uNumVertices );
+      }
+    }
+    else
+    {
+      v8 = a4->uNumVertices == 0;
+      a4a = a2;
+      if ( !v8 )
+      {
+        v13 = (int)v5->pVertexIDs;
+        do
+        {
+          ++v7;
+          dword_4F5BF4_xs[v7] = a5->pVertices[*(short *)v13].y;
+          v14 = *(short *)v13;
+          v13 += 2;
+          dword_4F5B24_ys[v7] = a5->pVertices[v14].z;
+        }
+        while ( v7 < v5->uNumVertices );
+      }
+    }
+  }
+  v15 = v5->uNumVertices;
+  a5a = 0;
+  dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1];
+  dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1];
+  v25 = 0;
+  v16 = dword_4F5B24_ys[1] >= a3;
+  if ( v15 <= 0 )
+    goto LABEL_29;
+  do
+  {
+    if ( a5a >= 2 )
+      break;
+    v17 = v25;
+    v18 = dword_4F5B24_ys[v25 + 2];
+    if ( v16 ^ v18 >= a3 )
+    {
+      v19 = dword_4F5BF4_xs[v17 + 2];
+      if ( v19 >= a4a )
+        v20 = 0;
+      else
+        v20 = 2;
+      v21 = v20 | dword_4F5BF4_xs[v17 + 1] < a4a;
+      if ( v21 != 3 )
+      {
+        if ( !v21
+          || (v22 = v19 - dword_4F5BF4_xs[v17 + 1],
+              LODWORD(v23) = v22 << 16,
+              HIDWORD(v23) = v22 >> 16,
+              dword_4F5BF4_xs[v17 + 1]
+            + ((signed int)(((unsigned __int64)(v23
+                                              / (v18 - dword_4F5B24_ys[v17 + 1])
+                                              * ((a3 - dword_4F5B24_ys[v17 + 1]) << 16)) >> 16)
+                          + 32768) >> 16) >= a4a) )
+          ++a5a;
+      }
+    }
+    ++v25;
+    v16 = v18 >= a3;
+  }
+  while ( v25 < v15 );
+  result = 1;
+  if ( a5a != 1 )
+LABEL_29:
+    result = 0;
+  return result;
+}
+
+//----- (00407A1C) --------------------------------------------------------
+bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
+{
+  unsigned int v4; // esi@1
+  Vec3_int_ v5; // ST08_12@2
+  int v6; // edi@2
+  int v7; // ebx@2
+  int v8; // esi@2
+  signed int v9; // ecx@2
+  int v10; // eax@2
+  int v11; // ecx@4
+  int v12; // eax@4
+  int v13; // ebx@4
+  int v14; // edx@6
+  char *v15; // edi@16
+  ODMFace *v16; // esi@19
+  int v17; // ST34_4@25
+  int v18; // ST38_4@25
+  int v19; // eax@25
+  char v20; // zf@25
+  int v21; // ebx@25
+  int v22; // eax@26
+  signed int v23; // edi@26
+  int v24; // ST34_4@30
+  signed __int64 v25; // qtt@31
+  int v26; // eax@31
+  Vec3_int_ v27; // ST08_12@37
+  Vec3_int_ v28; // ST08_12@37
+  int v29; // edi@37
+  int v30; // ebx@37
+  int v31; // esi@37
+  signed int v32; // ecx@37
+  int v33; // eax@37
+  int v34; // ecx@39
+  int v35; // eax@39
+  int v36; // ebx@39
+  int v37; // edx@41
+  char *v38; // edi@51
+  ODMFace *v39; // esi@54
+  int v40; // ebx@60
+  int v41; // eax@61
+  signed int v42; // edi@61
+  signed __int64 v43; // qtt@66
+  int v44; // eax@66
+  Vec3_int_ v45; // ST08_12@73
+  int v46; // edi@73
+  int v47; // ebx@73
+  int v48; // esi@73
+  signed int v49; // ecx@73
+  int v50; // eax@73
+  int v51; // edx@75
+  int v52; // ecx@75
+  int v53; // eax@75
+  int v54; // ebx@75
+  int v55; // edi@77
+  int v56; // ecx@77
+  int v57; // eax@81
+  int v58; // esi@81
+  int v59; // eax@90
+  BLVSector *v60; // edx@90
+  int v61; // ecx@90
+  BLVFace *v62; // esi@91
+  int v63; // ST34_4@98
+  int v64; // ST30_4@98
+  int v65; // eax@98
+  int v66; // ebx@98
+  int v67; // eax@99
+  signed int v68; // edi@99
+  int v69; // ST2C_4@103
+  signed __int64 v70; // qtt@104
+  int v71; // eax@104
+  Vec3_int_ v72; // ST08_12@111
+  Vec3_int_ v73; // ST08_12@111
+  int v74; // edi@111
+  int v75; // ebx@111
+  int v76; // esi@111
+  signed int v77; // ecx@111
+  int v78; // eax@111
+  int v79; // edx@113
+  int v80; // ecx@113
+  int v81; // eax@113
+  int v82; // ebx@113
+  int v83; // edi@115
+  int v84; // ecx@115
+  int v85; // eax@119
+  int v86; // esi@119
+  int v87; // ecx@128
+  BLVSector *v88; // eax@128
+  int v89; // ecx@128
+  BLVFace *v90; // esi@129
+  int v91; // ebx@136
+  int v92; // eax@137
+  signed int v93; // edi@137
+  signed __int64 v94; // qtt@142
+  int v95; // eax@142
+  Vec3_int_ v97; // [sp-18h] [bp-94h]@1
+  int v98; // [sp-Ch] [bp-88h]@88
+  int v99; // [sp-Ch] [bp-88h]@126
+  int v100; // [sp-8h] [bp-84h]@88
+  int v101; // [sp-8h] [bp-84h]@126
+  int v102; // [sp-4h] [bp-80h]@88
+  int v103; // [sp-4h] [bp-80h]@126
+  int v104; // [sp+Ch] [bp-70h]@13
+  int v105; // [sp+Ch] [bp-70h]@48
+  int v106; // [sp+10h] [bp-6Ch]@18
+  int v107; // [sp+10h] [bp-6Ch]@98
+  int v108; // [sp+10h] [bp-6Ch]@104
+  int v109; // [sp+18h] [bp-64h]@25
+  int v110; // [sp+18h] [bp-64h]@31
+  int i; // [sp+18h] [bp-64h]@90
+  int v112; // [sp+18h] [bp-64h]@128
+  signed int v113; // [sp+20h] [bp-5Ch]@1
+  signed int v114; // [sp+24h] [bp-58h]@1
+  unsigned __int64 a4; // [sp+28h] [bp-54h]@1
+  unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
+  int v117; // [sp+34h] [bp-48h]@4
+  int v118; // [sp+34h] [bp-48h]@39
+  int v119; // [sp+34h] [bp-48h]@75
+  int v120; // [sp+34h] [bp-48h]@113
+  int v121; // [sp+38h] [bp-44h]@4
+  int v122; // [sp+38h] [bp-44h]@39
+  int v123; // [sp+38h] [bp-44h]@76
+  int v124; // [sp+38h] [bp-44h]@114
+  int v125; // [sp+3Ch] [bp-40h]@4
+  int v126; // [sp+3Ch] [bp-40h]@39
+  int v127; // [sp+3Ch] [bp-40h]@77
+  int v128; // [sp+3Ch] [bp-40h]@115
+  int v129; // [sp+40h] [bp-3Ch]@11
+  int v130; // [sp+40h] [bp-3Ch]@46
+  int v131; // [sp+40h] [bp-3Ch]@78
+  int v132; // [sp+40h] [bp-3Ch]@116
+  int v133; // [sp+44h] [bp-38h]@10
+  int v134; // [sp+44h] [bp-38h]@45
+  int v135; // [sp+44h] [bp-38h]@81
+  int v136; // [sp+44h] [bp-38h]@119
+  int v137; // [sp+48h] [bp-34h]@7
+  int v138; // [sp+48h] [bp-34h]@42
+  int v139; // [sp+48h] [bp-34h]@82
+  int v140; // [sp+48h] [bp-34h]@120
+  int v141; // [sp+4Ch] [bp-30h]@6
+  int v142; // [sp+4Ch] [bp-30h]@41
+  int v143; // [sp+4Ch] [bp-30h]@75
+  int v144; // [sp+4Ch] [bp-30h]@113
+  int v145; // [sp+50h] [bp-2Ch]@5
+  int v146; // [sp+50h] [bp-2Ch]@40
+  int v147; // [sp+50h] [bp-2Ch]@75
+  int v148; // [sp+50h] [bp-2Ch]@113
+  int v149; // [sp+54h] [bp-28h]@4
+  int v150; // [sp+54h] [bp-28h]@39
+  int v151; // [sp+54h] [bp-28h]@75
+  int v152; // [sp+54h] [bp-28h]@113
+  int sDepth; // [sp+58h] [bp-24h]@17
+  int sDeptha; // [sp+58h] [bp-24h]@52
+  int sDepthb; // [sp+58h] [bp-24h]@90
+  char *a5; // [sp+5Ch] [bp-20h]@16
+  char *a5a; // [sp+5Ch] [bp-20h]@51
+  signed int a5b; // [sp+5Ch] [bp-20h]@83
+  signed int a5c; // [sp+5Ch] [bp-20h]@121
+  signed int v160; // [sp+60h] [bp-1Ch]@12
+  signed int v161; // [sp+60h] [bp-1Ch]@47
+  int v162; // [sp+60h] [bp-1Ch]@128
+  int v163; // [sp+64h] [bp-18h]@2
+  int outx; // [sp+68h] [bp-14h]@2
+  int outy; // [sp+6Ch] [bp-10h]@2
+  int outz; // [sp+70h] [bp-Ch]@2
+  Vec3_int_ pOut; // [sp+74h] [bp-8h]@2
+  int ya; // [sp+84h] [bp+8h]@60
+  int yb; // [sp+84h] [bp+8h]@136
+  int ve; // [sp+88h] [bp+Ch]@60
+  int va; // [sp+88h] [bp+Ch]@60
+  int vb; // [sp+88h] [bp+Ch]@66
+  int vf; // [sp+88h] [bp+Ch]@136
+  int vc; // [sp+88h] [bp+Ch]@136
+  int vd; // [sp+88h] [bp+Ch]@142
+  int v_4; // [sp+8Ch] [bp+10h]@60
+  int v_4a; // [sp+8Ch] [bp+10h]@65
+  int v_4b; // [sp+8Ch] [bp+10h]@136
+  int v_4c; // [sp+8Ch] [bp+10h]@141
+  int v_8; // [sp+90h] [bp+14h]@53
+
+  a4 = __PAIR__(z, x);
+  v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
+  v114 = 0;
+  v97.z = y;
+  v113 = 0;
+  a4_8 = v4;
+  *(_QWORD *)&v97.x = a4;
+  if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
+  {
+    Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
+    v45.z = v.z;
+    *(_QWORD *)&v45.x = *(_QWORD *)&v;
+    Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163);
+    v46 = outy - pOut.y;
+    v47 = v163 - outz;
+    v48 = outx - pOut.x;
+    v49 = sub_452A9E(v48 * v48 + v46 * v46 + v47 * v47);
+    v50 = 65536;
+    if ( v49 )
+      v50 = 65536 / v49;
+    v51 = outx;
+    v143 = v48 * v50;
+    v52 = v46 * v50;
+    v53 = v47 * v50;
+    v54 = pOut.x;
+    v147 = v52;
+    v151 = v53;
+    v119 = pOut.x;
+    if ( pOut.x < outx )
+    {
+      v123 = outx;
+    }
+    else
+    {
+      v119 = outx;
+      v123 = pOut.x;
+    }
+    v55 = pOut.y;
+    v56 = outy;
+    v127 = pOut.y;
+    if ( pOut.y < outy )
+    {
+      v131 = outy;
+    }
+    else
+    {
+      v127 = outy;
+      v131 = pOut.y;
+    }
+    v57 = v163;
+    v58 = outz;
+    v135 = outz;
+    if ( outz < v163 )
+    {
+      v139 = v163;
+    }
+    else
+    {
+      v135 = v163;
+      v139 = outz;
+    }
+    a5b = 0;
+    while ( !v114 )
+    {
+      if ( a5b )
+      {
+        v102 = v58;
+        v100 = v55;
+        v98 = v54;
+      }
+      else
+      {
+        v102 = v57;
+        v100 = v56;
+        v98 = v51;
+      }
+      v59 = pIndoor->GetSector(v98, v100, v102);
+      v60 = pIndoor->pSectors;
+      v61 = 116 * v59;
+      sDepthb = 0;
+      for ( i = 116 * v59;
+            sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
+                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
+            ++sDepthb )
+      {
+        v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
+        if ( v62->uAttributes & 1
+          || v119 > v62->pBounding.x2
+          || v123 < v62->pBounding.x1
+          || v127 > v62->pBounding.y2
+          || v131 < v62->pBounding.y1
+          || v135 > v62->pBounding.z2
+          || v139 < v62->pBounding.z1
+          || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16,
+              v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16,
+              v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16,
+              v20 = v63 + v64 + v65 == 0,
+              v66 = v63 + v64 + v65,
+              v107 = v63 + v64 + v65,
+              v20) )
+          goto LABEL_107;
+        v67 = outz * v62->pFacePlane_old.vNormal.z;
+        v68 = -(v62->pFacePlane_old.dist
+              + v67
+              + pOut.y * v62->pFacePlane_old.vNormal.y
+              + pOut.x * v62->pFacePlane_old.vNormal.x);
+        if ( v66 <= 0 )
+        {
+          if ( v62->pFacePlane_old.dist
+             + v67
+             + pOut.y * v62->pFacePlane_old.vNormal.y
+             + pOut.x * v62->pFacePlane_old.vNormal.x < 0 )
+            goto LABEL_107;
+        }
+        else
+        {
+          if ( v62->pFacePlane_old.dist
+             + v67
+             + pOut.y * v62->pFacePlane_old.vNormal.y
+             + pOut.x * v62->pFacePlane_old.vNormal.x > 0 )
+            goto LABEL_107;
+        }
+        v69 = abs(-(v62->pFacePlane_old.dist
+                  + v67
+                  + pOut.y * v62->pFacePlane_old.vNormal.y
+                  + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14;
+        if ( v69 <= abs(v66) )
+        {
+          LODWORD(v70) = v68 << 16;
+          HIDWORD(v70) = v68 >> 16;
+          v71 = v70 / v107;
+          v108 = v70 / v107;
+          if ( v71 >= 0 )
+          {
+            if ( sub_4075DB(
+                   pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16),
+                   pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16),
+                   outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16),
+                   v62) )
+            {
+              v114 = 1;
+              break;
+            }
+          }
+        }
+        v61 = i;
+LABEL_107:
+        v60 = pIndoor->pSectors;
+      }
+      ++a5b;
+      if ( a5b >= 2 )
+        break;
+      v57 = v163;
+      v56 = outy;
+      v51 = outx;
+      v58 = outz;
+      v55 = pOut.y;
+      v54 = pOut.x;
+    }
+    v72.z = y;
+    *(_QWORD *)&v72.x = a4;
+    Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
+    v73.z = v.z;
+    *(_QWORD *)&v73.x = *(_QWORD *)&v;
+    Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
+    v74 = outy - pOut.y;
+    v75 = v163 - outz;
+    v76 = outx - pOut.x;
+    v77 = sub_452A9E(v76 * v76 + v74 * v74 + v75 * v75);
+    v78 = 65536;
+    if ( v77 )
+      v78 = 65536 / v77;
+    v79 = outx;
+    v144 = v76 * v78;
+    v80 = v74 * v78;
+    v81 = v75 * v78;
+    v82 = pOut.x;
+    v148 = v80;
+    v152 = v81;
+    v120 = pOut.x;
+    if ( pOut.x < outx )
+    {
+      v124 = outx;
+    }
+    else
+    {
+      v120 = outx;
+      v124 = pOut.x;
+    }
+    v83 = pOut.y;
+    v84 = outy;
+    v128 = pOut.y;
+    if ( pOut.y < outy )
+    {
+      v132 = outy;
+    }
+    else
+    {
+      v128 = outy;
+      v132 = pOut.y;
+    }
+    v85 = v163;
+    v86 = outz;
+    v136 = outz;
+    if ( outz < v163 )
+    {
+      v140 = v163;
+    }
+    else
+    {
+      v136 = v163;
+      v140 = outz;
+    }
+    a5c = 0;
+    while ( 1 )
+    {
+      if ( v113 )
+        return !v114 || !v113;
+      if ( a5c )
+      {
+        v103 = v86;
+        v101 = v83;
+        v99 = v82;
+      }
+      else
+      {
+        v103 = v85;
+        v101 = v84;
+        v99 = v79;
+      }
+      v87 = pIndoor->GetSector(v99, v101, v103);
+      v88 = pIndoor->pSectors;
+      v89 = 116 * v87;
+      v162 = 0;
+      v112 = v89;
+      if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
+         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
+        break;
+LABEL_148:
+      ++a5c;
+      if ( a5c >= 2 )
+        return !v114 || !v113;
+      v85 = v163;
+      v84 = outy;
+      v79 = outx;
+      v86 = outz;
+      v83 = pOut.y;
+      v82 = pOut.x;
+    }
+    while ( 1 )
+    {
+      v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
+      if ( v90->uAttributes & 1
+        || v120 > v90->pBounding.x2
+        || v124 < v90->pBounding.x1
+        || v128 > v90->pBounding.y2
+        || v132 < v90->pBounding.y1
+        || v136 > v90->pBounding.z2
+        || v140 < v90->pBounding.z1
+        || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16,
+            v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16,
+            vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16,
+            v20 = yb + vf + v_4b == 0,
+            v91 = yb + vf + v_4b,
+            vc = yb + vf + v_4b,
+            v20) )
+        goto LABEL_145;
+      v92 = outz * v90->pFacePlane_old.vNormal.z;
+      v93 = -(v90->pFacePlane_old.dist
+            + v92
+            + pOut.y * v90->pFacePlane_old.vNormal.y
+            + pOut.x * v90->pFacePlane_old.vNormal.x);
+      if ( v91 <= 0 )
+      {
+        if ( v90->pFacePlane_old.dist
+           + v92
+           + pOut.y * v90->pFacePlane_old.vNormal.y
+           + pOut.x * v90->pFacePlane_old.vNormal.x < 0 )
+          goto LABEL_145;
+      }
+      else
+      {
+        if ( v90->pFacePlane_old.dist
+           + v92
+           + pOut.y * v90->pFacePlane_old.vNormal.y
+           + pOut.x * v90->pFacePlane_old.vNormal.x > 0 )
+          goto LABEL_145;
+      }
+      v_4c = abs(-(v90->pFacePlane_old.dist
+                 + v92
+                 + pOut.y * v90->pFacePlane_old.vNormal.y
+                 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14;
+      if ( v_4c <= abs(v91) )
+      {
+        LODWORD(v94) = v93 << 16;
+        HIDWORD(v94) = v93 >> 16;
+        v95 = v94 / vc;
+        vd = v94 / vc;
+        if ( v95 >= 0 )
+        {
+          if ( sub_4075DB(
+                 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16),
+                 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16),
+                 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16),
+                 v90) )
+          {
+            v113 = 1;
+            goto LABEL_148;
+          }
+        }
+      }
+      v89 = v112;
+LABEL_145:
+      v88 = pIndoor->pSectors;
+      ++v162;
+      if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
+                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
+        goto LABEL_148;
+    }
+  }
+  Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
+  v5.z = v.z;
+  *(_QWORD *)&v5.x = *(_QWORD *)&v;
+  Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163);
+  v6 = outy - pOut.y;
+  v7 = v163 - outz;
+  v8 = outx - pOut.x;
+  v9 = sub_452A9E(v8 * v8 + v6 * v6 + v7 * v7);
+  v10 = 65536;
+  if ( v9 )
+    v10 = 65536 / v9;
+  v125 = v8 * v10;
+  v11 = v10;
+  v12 = v7 * v10;
+  v13 = pOut.x;
+  v117 = v12;
+  v121 = v6 * v11;
+  v149 = pOut.x;
+  if ( pOut.x < outx )
+  {
+    v145 = outx;
+  }
+  else
+  {
+    v149 = outx;
+    v145 = pOut.x;
+  }
+  v14 = outy;
+  v141 = pOut.y;
+  if ( pOut.y < outy )
+  {
+    v137 = outy;
+  }
+  else
+  {
+    v141 = outy;
+    v137 = pOut.y;
+  }
+  v133 = outz;
+  if ( outz < v163 )
+  {
+    v129 = v163;
+  }
+  else
+  {
+    v133 = v163;
+    v129 = outz;
+  }
+  v160 = 0;
+  if ( (signed int)pOutdoor->uNumBModels > 0 )
+  {
+    v104 = 0;
+    while ( 1 )
+    {
+      v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
+      a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
+      if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
+      {
+        sDepth = 0;
+        if ( *((int *)v15 + 2) > 0 )
+          break;
+      }
+LABEL_36:
+      ++v160;
+      ++v104;
+      if ( v160 >= (signed int)pOutdoor->uNumBModels )
+        goto LABEL_37;
+      v14 = outy;
+      v13 = pOut.x;
+    }
+    v106 = 0;
+    while ( 1 )
+    {
+      v16 = (ODMFace *)(v106 + *((int *)a5 + 4));
+      if ( v149 > v16->pBoundingBox.x2
+        || v145 < v16->pBoundingBox.x1
+        || v141 > v16->pBoundingBox.y2
+        || v137 < v16->pBoundingBox.y1
+        || v133 > v16->pBoundingBox.z2
+        || v129 < v16->pBoundingBox.z1
+        || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16,
+            v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16,
+            v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16,
+            v20 = v17 + v18 + v19 == 0,
+            v21 = v17 + v18 + v19,
+            v109 = v17 + v18 + v19,
+            v20) )
+        goto LABEL_33;
+      v22 = pOut.y * v16->pFacePlane.vNormal.y;
+      v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x);
+      if ( v21 <= 0 )
+      {
+        if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 )
+          goto LABEL_33;
+      }
+      else
+      {
+        if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 )
+          goto LABEL_33;
+      }
+      v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14;
+      if ( v24 <= abs(v21) )
+      {
+        LODWORD(v25) = v23 << 16;
+        HIDWORD(v25) = v23 >> 16;
+        v26 = v25 / v109;
+        v110 = v25 / v109;
+        if ( v26 >= 0 )
+        {
+          if ( sub_4077F1(
+                 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16),
+                 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16),
+                 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16),
+                 v16,
+                 (BSPVertexBuffer *)a5) )
+          {
+            v114 = 1;
+            goto LABEL_36;
+          }
+        }
+      }
+LABEL_33:
+      ++sDepth;
+      v106 += 308;
+      if ( sDepth >= *((int *)a5 + 2) )
+        goto LABEL_36;
+    }
+  }
+LABEL_37:
+  v27.z = y;
+  *(_QWORD *)&v27.x = a4;
+  Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
+  v28.z = v.z;
+  *(_QWORD *)&v28.x = *(_QWORD *)&v;
+  Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
+  v29 = outy - pOut.y;
+  v30 = v163 - outz;
+  v31 = outx - pOut.x;
+  v32 = sub_452A9E(v31 * v31 + v29 * v29 + v30 * v30);
+  v33 = 65536;
+  if ( v32 )
+    v33 = 65536 / v32;
+  v126 = v31 * v33;
+  v34 = v33;
+  v35 = v30 * v33;
+  v36 = pOut.x;
+  v118 = v35;
+  v122 = v29 * v34;
+  v150 = pOut.x;
+  if ( pOut.x < outx )
+  {
+    v146 = outx;
+  }
+  else
+  {
+    v150 = outx;
+    v146 = pOut.x;
+  }
+  v37 = outy;
+  v142 = pOut.y;
+  if ( pOut.y < outy )
+  {
+    v138 = outy;
+  }
+  else
+  {
+    v142 = outy;
+    v138 = pOut.y;
+  }
+  v134 = outz;
+  if ( outz < v163 )
+  {
+    v130 = v163;
+  }
+  else
+  {
+    v134 = v163;
+    v130 = outz;
+  }
+  v161 = 0;
+  if ( (signed int)pOutdoor->uNumBModels > 0 )
+  {
+    v105 = 0;
+    while ( 1 )
+    {
+      v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
+      a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
+      if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
+      {
+        sDeptha = 0;
+        if ( *((int *)v38 + 2) > 0 )
+          break;
+      }
+LABEL_71:
+      ++v161;
+      ++v105;
+      if ( v161 >= (signed int)pOutdoor->uNumBModels )
+        return !v114 || !v113;
+      v37 = outy;
+      v36 = pOut.x;
+    }
+    v_8 = 0;
+    while ( 1 )
+    {
+      v39 = (ODMFace *)(v_8 + *((int *)a5a + 4));
+      if ( v150 > v39->pBoundingBox.x2
+        || v146 < v39->pBoundingBox.x1
+        || v142 > v39->pBoundingBox.y2
+        || v138 < v39->pBoundingBox.y1
+        || v134 > v39->pBoundingBox.z2
+        || v130 < v39->pBoundingBox.z1
+        || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16,
+            ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16,
+            v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16,
+            v20 = ya + ve + v_4 == 0,
+            v40 = ya + ve + v_4,
+            va = ya + ve + v_4,
+            v20) )
+        goto LABEL_68;
+      v41 = pOut.y * v39->pFacePlane.vNormal.y;
+      v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x);
+      if ( v40 <= 0 )
+      {
+        if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 )
+          goto LABEL_68;
+      }
+      else
+      {
+        if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 )
+          goto LABEL_68;
+      }
+      v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14;
+      if ( v_4a <= abs(v40) )
+      {
+        LODWORD(v43) = v42 << 16;
+        HIDWORD(v43) = v42 >> 16;
+        v44 = v43 / va;
+        vb = v43 / va;
+        if ( v44 >= 0 )
+        {
+          if ( sub_4077F1(
+                 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16),
+                 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16),
+                 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16),
+                 v39,
+                 (BSPVertexBuffer *)a5a) )
+          {
+            v113 = 1;
+            goto LABEL_71;
+          }
+        }
+      }
+LABEL_68:
+      ++sDeptha;
+      v_8 += 308;
+      if ( sDeptha >= *((int *)a5a + 2) )
+        goto LABEL_71;
+    }
+  }
+  return !v114 || !v113;
+}
+
+
+//----- (00408768) --------------------------------------------------------
+void InitializeActors()
+{
+  signed int v5; // [sp+Ch] [bp-10h]@1
+  signed int v6; // [sp+10h] [bp-Ch]@1
+  signed int v7; // [sp+14h] [bp-8h]@1
+  signed int v8; // [sp+18h] [bp-4h]@1
+
+  v8 = 0;
+  v6 = 0;
+  v7 = 0;
+  v5 = 0;
+  if ( !_strcmpi(pCurrentMapName, "d25.blv") )
+    v8 = 1;
+  if ( !_strcmpi(pCurrentMapName, "d26.blv") )
+    v6 = 1;
+  if (_449B57_test_bit(pParty->_award_bits, 99))
+    v7 = 1;
+  if (_449B57_test_bit(pParty->_award_bits, 100))
+    v5 = 1;
+  for (uint i = 0; i < uNumActors; ++i)
+  {
+    auto actor = pActors + i;
+
+    if (actor->CanAct() || actor->uAIState == Disabled)
+    {
+      actor->vPosition.x = actor->vInitialPosition.x;
+      actor->vPosition.y = actor->vInitialPosition.y;
+      actor->vPosition.z = actor->vInitialPosition.z;
+      actor->sCurrentHP = actor->pMonsterInfo.uHP;
+      if (actor->uAIState != Disabled)
+        Actor::_403EB6(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0);
+    }
+
+    actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+
+    if (!v8 || v7)
+      if (!v6 || v5)
+        if (actor->_438B9B())
+          BYTE2(actor->uAttributes) &= 0xF7u;
+
+    BYTE2(actor->uAttributes) &= 0x7Fu;
+    if (BYTE2(actor->uAttributes) & 0x40)
+        Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1);
+  }
+}
+
+//----- (00408896) --------------------------------------------------------
+void InitializeLayingItems()
+{
+  for (uint i = 0; i < uNumLayingItems; ++i)
+  {
+    auto item = pLayingItems + i;
+
+    if (item->uItemType &&
+        (item->uSoundID & 8 || pObjectList->pObjects[item->uItemType].uFlags & 0x10))
+      LayingItem::_42F933(i);
+  }
+
+  for (uint i = 0; i < 100; ++i)
+    array_5118E8.pElements[i].field_C_time_left = 0;
+}
+
+//----- (004088E9) --------------------------------------------------------
+signed int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6)
+{
+  int v6; // esi@1
+  int v7; // edi@1
+  int v8; // eax@1
+  signed int result; // eax@1
+  int v10; // [sp+Ch] [bp-4h]@1
+  int v11; // [sp+18h] [bp+8h]@1
+
+  v6 = a1;
+  v10 = a2;
+  v7 = a3 - a1;
+  v11 = abs(a3 - a1);
+  v8 = abs(a4 - v10);
+  result = sub_452A9E(v11 * v11 + v8 * v8);
+  if ( result )
+    result = abs((v7 * (v10 - a6) - (a4 - v10) * (v6 - a5)) / result);
+  return result;
+}
+
+
+//----- (00408A27) --------------------------------------------------------
+unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors)
+{
+  unsigned int *v1; // esi@1
+  int v2; // eax@1
+  unsigned int v3; // ebp@1
+  signed int v4; // ebx@1
+  Actor *v5; // edi@2
+  unsigned int v6; // eax@3
+  int v8; // [sp+Ch] [bp-4h]@1
+
+  v1 = pTotalActors;
+  v2 = GetAlertStatus();
+  v3 = 0;
+  v4 = 0;
+  *v1 = 0;
+  v8 = v2;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v5 = pActors;
+    do
+    {
+      v6 = v5->uAttributes;
+      if ( (v6 & 0x100000) == v8 )
+      {
+        ++*v1;
+        if ( v5->IsAlive() == 1 )
+          ++v3;
+      }
+      ++v4;
+      ++v5;
+    }
+    while ( v4 < (signed int)uNumActors );
+  }
+  return v3;
+}
+
+//----- (00408A7E) --------------------------------------------------------
+unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
+{
+  unsigned int *v2; // esi@1
+  signed int v3; // ebx@1
+  char *v4; // edi@2
+  int v5; // eax@3
+  int v7; // [sp+8h] [bp-Ch]@1
+  int v8; // [sp+Ch] [bp-8h]@1
+  unsigned int v9; // [sp+10h] [bp-4h]@1
+
+  v7 = uMonsterID;
+  v2 = pTotalActors;
+  v3 = 0;
+  v8 = GetAlertStatus();
+  *v2 = 0;
+  v9 = 0;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v4 = (char *)&pActors[0].pMonsterInfo.uID;
+    do
+    {
+      v5 = *((int *)v4 - 15);                // actor::attributes
+      if ( (v5 & 0x100000) == v8 )
+      {
+        if ( *(short *)v4 - 1 == v7 )
+        {
+          ++*v2;
+          if ( ((Actor *)(v4 - 96))->IsAlive() == 1 )
+            ++v9;
+        }
+      }
+      ++v3;
+      v4 += 836;
+    }
+    while ( v3 < (signed int)uNumActors );
+  }
+  return v9;
+}
+
+//----- (00408AE7) --------------------------------------------------------
+unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup)
+{
+  unsigned int *v2; // esi@1
+  signed int v3; // ebx@1
+  char *v4; // edi@2
+  int v5; // eax@3
+  unsigned int v7; // [sp+8h] [bp-Ch]@1
+  int v8; // [sp+Ch] [bp-8h]@1
+  unsigned int v9; // [sp+10h] [bp-4h]@1
+
+  v7 = uGroup;
+  v2 = pTotalActors;
+  v3 = 0;
+  v8 = GetAlertStatus();
+  *v2 = 0;
+  v9 = 0;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v4 = (char *)&pActors[0].uGroup;
+    do
+    {
+      v5 = *((int *)v4 - 168);
+      if ( (v5 & 0x100000) == v8 )
+      {
+        if ( *(int *)v4 == v7 )
+        {
+          ++*v2;
+          if ( ((Actor *)(v4 - 708))->IsAlive() == 1 )
+            ++v9;
+        }
+      }
+      ++v3;
+      v4 += 836;
+    }
+    while ( v3 < (signed int)uNumActors );
+  }
+  return v9;
+}
+
+//----- (00408B54) --------------------------------------------------------
+unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
+{
+  unsigned int v2; // edi@1
+  unsigned int *v3; // esi@1
+  int v4; // eax@1
+  unsigned int v5; // ebx@1
+  unsigned int v6; // edx@1
+
+  v2 = a2;
+  v3 = pTotalActors;
+  v4 = GetAlertStatus();
+  v5 = 0;
+  *v3 = 0;
+  v6 = pActors[v2].uAttributes;
+  if ( (v6 & 0x100000) == v4 )
+  {
+    *v3 = 1;
+    if ( pActors[v2].IsAlive() == 1 )
+      v5 = 1;
+  }
+  return v5;
+}
+
+
+//----- (00409BE8) --------------------------------------------------------
+void __cdecl sub_409BE8()
+{
+  void *v0; // eax@1
+  stru348 *v1; // eax@1
+  int v2; // ecx@1
+  int v3; // eax@1
+
+  v0 = ptr_507BC0->ptr_1C;
+  dword_4E1874 = 5;
+  v1 = &stru_4E1890[(int)((char *)v0 - 108)];
+  amuint_4E1860 = v1->field_4;
+  amuint_4E1864 = v1->field_6;
+  amuint_4E1868 = v1->field_8 - 1;
+  amuint_4E186C = v1->field_A - 1;
+  amuint_4E1870 = v1->field_C - 1;
+  amuint_505884 = v1->field_E;
+  amuint_505888 = v1->field_10;
+  amuint_50588C = v1->field_12;
+  dword_4E1878 = 1;
+  dword_4E187C = 1;
+  dword_4E1880 = 1;
+  dword_4E1884 = v1->field_0;
+  v2 = v1->field_2;
+  v3 = v1->field_14;
+  dword_4E1888 = v2;
+  dword_4DF3A4 = v3;
+}
+// 4DF3A4: using guessed type int dword_4DF3A4;
+// 4E1860: using guessed type int amuint_4E1860;
+// 4E1864: using guessed type int amuint_4E1864;
+// 4E1868: using guessed type int amuint_4E1868;
+// 4E186C: using guessed type int amuint_4E186C;
+// 4E1870: using guessed type int amuint_4E1870;
+// 4E1874: using guessed type int dword_4E1874;
+// 4E1878: using guessed type int dword_4E1878;
+// 4E187C: using guessed type int dword_4E187C;
+// 4E1880: using guessed type int dword_4E1880;
+// 4E1884: using guessed type int dword_4E1884;
+// 4E1888: using guessed type int dword_4E1888;
+// 505884: using guessed type int amuint_505884;
+// 505888: using guessed type int amuint_505888;
+// 50588C: using guessed type int amuint_50588C;
+
+
+
+
+
+
+
+//----- (0040D75D) --------------------------------------------------------
+char __fastcall pPrimaryWindow_draws_text(int a1, const char *pText, int *pXY)
+{
+  const char *v3; // ST0C_4@1
+  __int64 v4; // qax@1
+
+  v3 = pText;
+  v4 = LOBYTE(pFontComic->uFontHeight) - 3;
+  return pPrimaryWindow->DrawText(
+           pFontComic,
+           *pXY,
+           pXY[1] - (((signed int)v4 - HIDWORD(v4)) >> 1) + 3,
+           0,
+           v3,
+           0,
+           0,
+           0);
+}
+
+
+
+//----- (0040DB27) --------------------------------------------------------
+void __fastcall DrawRect(Vec4_int_ *pXYZW, unsigned __int16 uColor, char bSolidFill)
+{
+  Vec4_int_ *v3; // esi@1
+  unsigned __int16 v4; // bp@1
+  unsigned int i; // ebx@3
+
+  v3 = pXYZW;
+  v4 = uColor;
+  pRenderer->BeginScene();
+  pRenderer->Clip_v2(0, 0, 639u, 479u);
+  if ( bSolidFill )
+  {
+    for ( i = v3->y; (signed int)i <= v3->w; ++i )
+      pRenderer->Line2D(v3->x, i, v3->z, i, v4);
+  }
+  else
+  {
+    pRenderer->Line2D(v3->x, v3->y, v3->z, v3->y, v4);
+    pRenderer->Line2D(v3->z, v3->y, v3->z, v3->w, v4);
+    pRenderer->Line2D(v3->z, v3->w, v3->x, v3->w, v4);
+    pRenderer->Line2D(v3->x, v3->w, v3->x, v3->y, v4);
+  }
+  pRenderer->EndScene();
+}
+
+
+
+
+//----- (0040DDB1) --------------------------------------------------------
+int __fastcall rand_interval(int a, int b)
+{
+  return a + rand() % (b - a + 1);
+}
+
+//----- (0040DEB4) --------------------------------------------------------
+char *__fastcall inv_strcat(const char *Source, char *Dest)
+{
+  return strcat(Dest, Source);
+}
+
+//----- (0040DEBE) --------------------------------------------------------
+char *__fastcall inv_strcpy(const char *Source, char *Dest)
+{
+  return strcpy(Dest, Source);
+}
+
+//----- (0040DEC8) --------------------------------------------------------
+void __fastcall intToString(int val, char *pOut)
+{
+  sprintf(pOut, "%d", val);
+}
+
+//----- (0040DEDB) --------------------------------------------------------
+unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
+{
+  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
+}
+
+//----- (0040DEF3) --------------------------------------------------------
+unsigned int __fastcall GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b)
+{
+  return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
+}
+
+//----- (0040DF3D) --------------------------------------------------------
+void __cdecl CallRenderPresent()
+{
+  pRenderer->Present();
+}
+
+
+//----- (0040DFA7) --------------------------------------------------------
+int __stdcall retzero_sub_40DFA7(int a1)
+{
+  return 0;
+}
+// 40DFA7: using guessed type int __stdcall retzero_sub_40DFA7(int);
+
+//----- (0040DFD1) --------------------------------------------------------
+void stru272::_40DFD1()
+{
+  stru272 *v1; // esi@1
+  stru272_stru0 *v2; // eax@1
+
+  v1 = this;
+  v2 = (stru272_stru0 *)malloc(0x5Cu);
+  v1->ptr_0 = v2;
+  v2->field_0 = 0x67707274u;
+  v1->ptr_0->field_8 = 0;
+  v1->ptr_0->field_30 = 0.0;
+  v1->ptr_0->field_58 = 0;
+  v1->ptr_0->field_59 = 0;
+}
+
+//----- (0040DFFE) --------------------------------------------------------
+int stru272_stru0::_40DFFE()
+{
+  signed int result; // eax@2
+
+  if ( this->field_0 == 0x67707274 )
+  {
+    this->field_0 = 0x78787878u;
+    free(this);
+    result = 0;
+  }
+  else
+  {
+    result = 2;
+  }
+  return result;
+}
+
+//----- (0040E01A) --------------------------------------------------------
+int stru272_stru0::_40E01A(int a2)
+{
+  signed int result; // eax@2
+
+  auto a1 = this;
+  if ( a1->field_0 == 0x67707274 )
+  {
+    a1->field_4 = *(int *)(a2 + 32);
+    a1->field_C = *(int *)a2 << 16;
+    a1->field_10 = *(int *)(a2 + 4) << 16;
+    a1->field_14 = *(int *)(a2 + 8) << 16;
+    a1->field_18 = *(int *)(a2 + 12) << 16;
+    a1->field_1C = *(int *)(a2 + 16);
+    a1->field_20 = *(int *)(a2 + 20);
+    a1->field_24 = *(int *)(a2 + 24);
+    a1->field_28 = *(float *)(a2 + 28) * 65536.0;
+    LODWORD(a1->field_2C) = *(int *)(a2 + 36);
+    a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0);
+    a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0);
+    a1->field_3C = *(int *)(a2 + 48);
+    a1->field_40 = *(int *)(a2 + 52);
+    a1->field_54 = *(int *)(a2 + 56);
+    a1->field_59 = 1;
+    result = 0;
+  }
+  else
+  {
+    result = 2;
+  }
+  return result;
+}
+
+//----- (0040E0F5) --------------------------------------------------------
+int stru272_stru0::_40E0F5(char a2, char a3)
+{
+  signed int result; // eax@2
+  int v4; // edx@7
+  int v5; // eax@7
+
+  auto a1 = this;
+  if ( a1->field_0 == 0x67707274 )
+  {
+    if ( a2 )
+    {
+      a1->field_8 = 0;
+      a1->field_30 = 0.0;
+    }
+    if ( a1->field_59 && a3 )
+    {
+      v4 = a1->field_4;
+      v5 = a1->field_54;
+      do
+      {
+        *(int *)v5 = 0;
+        v5 += 28;
+        --v4;
+      }
+      while ( v4 );
+      a1->field_58 = 0;
+    }
+    result = 0;
+  }
+  else
+  {
+    result = 2;
+  }
+  return result;
+}
+
+//----- (0040E133) --------------------------------------------------------
+int stru272_stru0::_40E133()
+{
+  stru272_stru0 *v1; // edi@1
+  int v3; // ST18_4@3
+  double v4; // st7@3
+  double v5; // st6@4
+  char v6; // bl@8
+  int v7; // esi@8
+  int v8; // ecx@10
+  signed int v9; // eax@10
+  int v10; // ecx@10
+  signed int v11; // eax@10
+  signed int v12; // edx@12
+  signed int v13; // edx@12
+  int v14; // [sp+8h] [bp-10h]@8
+  int v15; // [sp+Ch] [bp-Ch]@8
+  float v16; // [sp+14h] [bp-4h]@3
+
+  v1 = this;
+  if ( this->field_0 != 0x67707274 )
+    return 2;
+  v3 = this->field_8;
+  v16 = this->field_30;
+  v4 = (double)v3;
+  if ( v3 > 0 )
+  {
+    v5 = v16 + this->field_2C;
+    v16 = v5;
+    if ( v5 > v4 )
+      v16 = v4;
+  }
+  if ( v16 >= 1.0 || this->field_58 )
+  {
+    v6 = 0;
+    v7 = this->field_54;
+    v14 = (signed __int64)this->field_28;
+    v15 = this->field_4;
+    while ( *(int *)v7 <= 0 )
+    {
+      if ( v16 >= 1.0 )
+      {
+        *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1);
+        *(int *)(v7 + 20) = (rand() % 17 - 8) << 16;
+        *(int *)(v7 + 24) = (rand() % 17 - 8) << 16;
+        v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1);
+        *(int *)(v7 + 12) = v12;
+        *(int *)(v7 + 4) = v12 >> 16;
+        v16 = v16 - 1.0;
+        v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1);
+        *(int *)(v7 + 16) = v13;
+        *(int *)(v7 + 8) = v13 >> 16;
+        --v1->field_8;
+        goto LABEL_13;
+      }
+LABEL_14:
+      v7 += 28;
+      --v15;
+      if ( !v15 )
+      {
+        v1->field_58 = v6;
+        v1->field_30 = v16;
+        return 0;
+      }
+    }
+    v8 = *(int *)(v7 + 20);
+    --*(int *)v7;
+    v9 = v8 + *(int *)(v7 + 12);
+    v10 = v14 + *(int *)(v7 + 24);
+    *(int *)(v7 + 12) = v9;
+    *(int *)(v7 + 4) = v9 >> 16;
+    v11 = v10 + *(int *)(v7 + 16);
+    *(int *)(v7 + 24) = v10;
+    *(int *)(v7 + 16) = v11;
+    *(int *)(v7 + 8) = v11 >> 16;
+LABEL_13:
+    v6 = 1;
+    goto LABEL_14;
+  }
+  return 0;
+}
+
+//----- (0040E2A7) --------------------------------------------------------
+int stru272_stru0::_40E2A7()
+{
+  int result; // eax@2
+
+  if ( this->field_0 == 0x67707274 )
+  {
+    if ( this->field_8 <= 0 )
+      result = this->field_58 != 0 ? 2 : 0;
+    else
+      result = 1;
+  }
+  else
+  {
+    result = 3;
+  }
+  return result;
+}
+
+
+
+
+
+
+
+//----- (0040F82D) --------------------------------------------------------
+void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue)
+{
+  ZBuffer_DoFill(pZBuffer, (Texture *)(uTextureId != -1 ? 72 * uTextureId + 0x6D084C : 0), iZValue);
+}
+
+//----- (0040F845) --------------------------------------------------------
+__int16 __fastcall sub_40F845(int a1, int a2, int a3, int a4, int a5, __int16 a6, int a7)
+{
+  int v7; // edi@1
+  int v8; // esi@1
+  int v9; // ecx@2
+  int v10; // eax@3
+
+  v7 = a1;
+  v8 = a2;
+  do
+  {
+    v9 = a3;
+    do
+    {
+      v10 = *(char *)v8++;
+      if ( (char)v10 )
+      {
+        if ( (char)v10 == 1 )
+        {
+          LOWORD(v10) = *(short *)(a5 + 2 * v10);
+          *(short *)v7 = v10;
+        }
+        else
+        {
+          LOWORD(v10) = a6;
+          *(short *)v7 = a6;
+        }
+      }
+      v7 += 2;
+      --v9;
+    }
+    while ( v9 );
+    v7 = a7 + v7 - a3 - a3;
+    --a4;
+  }
+  while ( a4 );
+  return v10;
+}
+
+//----- (0040F89C) --------------------------------------------------------
+void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue)
+{
+  void *v3; // eax@3
+  void *v4; // esi@5
+  int *v5; // edi@5
+  int v6; // eax@5
+  int v7; // ecx@6
+  Texture *v8; // [sp+Ch] [bp-14h]@1
+  int *v9; // [sp+10h] [bp-10h]@1
+  int v10; // [sp+14h] [bp-Ch]@1
+  int v11; // [sp+18h] [bp-8h]@1
+  void *v12; // [sp+1Ch] [bp-4h]@5
+
+  v10 = pTex->uTextureWidth;
+  v8 = pTex;
+  v9 = pZBuffer;
+  v11 = pTex->uTextureHeight;
+  if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize )
+    v3 = pTex->UnzipPalette();
+  else
+    v3 = pTex->pLevelOfDetail0;
+  v12 = v3;
+  v4 = v3;
+  v5 = v9;
+  v6 = 0;
+  do
+  {
+    v7 = v10;
+    do
+    {
+      LOBYTE(v6) = *(char *)v4;
+      v4 = (char *)v4 + 1;
+      if ( v6 )
+        *v5 = uZValue;
+      ++v5;
+      --v7;
+    }
+    while ( v7 );
+    v5 += 640 - v10;
+    --v11;
+  }
+  while ( v11 );
+  if ( pIcons_LOD->dword_011BA4 )
+  {
+    if ( v8->uDecompressedSize )
+      free(v12);
+  }
+}
+
+
+//----- (0040F92A) --------------------------------------------------------
+void __fastcall sub_40F92A(int *pZBuffer, Texture *a2, int a3)
+{
+  Texture *v3; // esi@1
+  void *v4; // eax@3
+  int *v5; // edi@5
+  int v6; // ecx@6
+  int *v7; // [sp+Ch] [bp-10h]@1
+  int v8; // [sp+10h] [bp-Ch]@1
+  int v9; // [sp+18h] [bp-4h]@1
+
+  v3 = a2;
+  v7 = pZBuffer;
+  v8 = a2->uTextureWidth;
+  v9 = a2->uTextureHeight;
+  if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize )
+    v4 = a2->UnzipPalette();
+  else
+    v4 = a2->pLevelOfDetail0;
+  v5 = v7;
+  do
+  {
+    v6 = v8;
+    do
+    {
+      *v5 = a3;
+      ++v5;
+      --v6;
+    }
+    while ( v6 );
+    v5 += 640 - v8;
+    --v9;
+  }
+  while ( v9 );
+  if ( pIcons_LOD->dword_011BA4 )
+  {
+    if ( v3->uDecompressedSize )
+      free(v4);
+  }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//----- (00410AF5) --------------------------------------------------------
+void __cdecl SetMoonPhaseNames()
+{
+  aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
+  aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
+  aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
+  aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
+  aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
+}
+
+//----- (00410B28) --------------------------------------------------------
+void __thiscall DrawSpellDescriptionPopup(void *_this)
+{
+  Player *v1; // edi@1
+  SpellInfo *v2; // esi@1
+  unsigned int v3; // eax@2
+  int v4; // eax@4
+  LONG v5; // ecx@4
+  int v6; // eax@10
+  char *v7; // ST44_4@12
+  unsigned __int16 v8; // ax@12
+  GUIWindow a1; // [sp+Ch] [bp-68h]@4
+  void *v10; // [sp+60h] [bp-14h]@1
+  POINT a2; // [sp+64h] [bp-10h]@1
+  int v12; // [sp+6Ch] [bp-8h]@4
+  int v13; // [sp+70h] [bp-4h]@4
+
+  v1 = pPlayers[uActiveCharacter];
+  v10 = _this;
+  v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->pNumSpellBookPage) + 1];
+  if ( pMouse->GetCursorPos(&a2)->y <= 250 )
+    v3 = pMouse->GetCursorPos(&a2)->y + 30;
+  else
+    v3 = 30;
+  a1.uFrameY = v3;
+  a1.uFrameWidth = 328;
+  a1.uFrameHeight = 68;
+  a1.uFrameX = 90;
+  a1.uFrameZ = 417;
+  a1.uFrameW = v3 + 67;
+  a1.Hint = 0;
+  a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);
+  v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);
+  v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);
+  v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);
+  v5 = a2.y;
+  if ( v13 > a2.y )
+    v5 = v13;
+  if ( v12 > v5 )
+    v5 = v12;
+  if ( v4 > v5 )
+    v5 = v4;
+  sprintf(
+    pTmpBuf2,
+    "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s",
+    v2->pDescription,
+    pGlobalTXT_LocalizationStrings[431],
+    v5 + 3,
+    v5 + 10,
+    v2->pBasicSkillDesc,
+    pGlobalTXT_LocalizationStrings[433],
+    v5 + 3,
+    v5 + 10,
+    v2->pExpertSkillDesc,
+    pGlobalTXT_LocalizationStrings[432],
+    v5 + 3,
+    v5 + 10,
+    v2->pMasterSkillDesc,
+    pGlobalTXT_LocalizationStrings[96],
+    v5 + 3,
+    v5 + 10,
+    v2->pGrandmasterSkillDesc);
+  v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0);
+  a1.uFrameHeight += v6;
+  if ( (signed int)a1.uFrameHeight < 150 )
+    a1.uFrameHeight = 150;
+  a1.uFrameWidth = 460;
+  a1.DrawMessageBox(0);
+  a1.uFrameWidth -= 12;
+  a1.uFrameHeight -= 12;
+  v7 = v2->pName;
+  a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
+  a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
+  v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
+  a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
+  a1.uFrameWidth = 108;
+  a1.uFrameZ = a1.uFrameX + 107;
+  a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->pNumSpellBookPage + 12], 3u);
+  sprintf(
+    pTmpBuf,
+    "%s\n%d",
+    pGlobalTXT_LocalizationStrings[522],
+    *(&pSpellDatas[0].field_14
+    + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->pNumSpellBookPage + 12]) >> 6)
+    + 10 * (int)((char *)v10 + 11 * v1->pNumSpellBookPage)));
+  a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
+  dword_507B00_spell_info_to_draw_in_popup = 0;
+}
+// 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup;
+
+//----- (00410D99) --------------------------------------------------------
+signed int __fastcall sub_410D99_get_map_index(int a1)
+{
+  int v1; // edi@1
+  signed int v2; // ebp@1
+  const char **v3; // esi@2
+  char *v4; // ebx@2
+
+  v1 = a1;
+  v2 = 1;
+  if ( _strcmpi(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
+  {
+    v3 = (const char **)&pMapStats->pInfos[1].pFilename;
+    v4 = (char *)&pMapStats->pInfos[1].pFilename;
+    do
+    {
+      if ( !*(int *)v4 )
+        break;
+      v3 += 17;
+      ++v2;
+      v4 = (char *)v3;
+    }
+    while ( _strcmpi(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
+  }
+  return v2;
+}
+
+//----- (00410DEC) --------------------------------------------------------
+unsigned int __cdecl DrawLloydBeaconsScreen()
+{
+  Player *v0; // esi@1
+  char *v1; // eax@1
+  unsigned __int16 v2; // ax@6
+  unsigned int result; // eax@11
+  unsigned int v4; // esi@13
+  unsigned int v5; // ecx@13
+  char v6; // zf@13
+  LloydBeacon *v7; // esi@14
+  int v8; // eax@14
+  unsigned __int64 v9; // kr08_8@14
+  unsigned int v10; // esi@14
+  unsigned int v11; // eax@14
+  char *v12; // eax@19
+  char *v13; // ecx@22
+  int v14; // eax@27
+  unsigned int v15; // [sp-10h] [bp-98h]@25
+  unsigned __int16 v16; // [sp-Ch] [bp-94h]@25
+  int v17; // [sp-8h] [bp-90h]@21
+  char *v18; // [sp-8h] [bp-90h]@25
+  Texture *v19; // [sp-4h] [bp-8Ch]@4
+  char *v20; // [sp-4h] [bp-8Ch]@21
+  unsigned int v21; // [sp-4h] [bp-8Ch]@25
+  GUIWindow v22; // [sp+Ch] [bp-7Ch]@1
+  unsigned int v23; // [sp+64h] [bp-24h]@14
+  __int64 v24; // [sp+68h] [bp-20h]@14
+  unsigned int v25; // [sp+70h] [bp-18h]@13
+  char *Str; // [sp+74h] [bp-14h]@14
+  int v27; // [sp+78h] [bp-10h]@11
+  LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
+  RGBTexture *v29; // [sp+80h] [bp-8h]@12
+  int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
+
+  v0 = &pParty->pPlayers[_506348_current_lloyd_playerid];
+  pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
+  v1 = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
+  v22.uFrameX = 8;
+  v22.uFrameY = 8;
+  v22.uFrameWidth = 428;
+  v22.uFrameHeight = 344;
+  v22.uFrameZ = 435;
+  v22.uFrameW = 351;
+  if ( !bRecallingBeacon )
+    v1 = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
+  sprintf(pTmpBuf, "%s", v1);
+  v22.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf, 3u);
+  if ( bRecallingBeacon )
+  {
+    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
+    v19 = pTex_tab_an_6a__zoom_off;
+  }
+  else
+  {
+    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
+    v19 = pTex_tab_an_6b__zoom_on;
+  }
+  pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
+  v2 = v0->pActiveSkills[14];
+  uNumMaxBeacons = 1;
+  if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
+  {
+    uNumMaxBeacons = 5;
+  }
+  else
+  {
+    if ( v2 & 0x40 )
+      uNumMaxBeacons = 3;
+  }
+  result = 0;
+  v27 = 0;
+  if ( uNumMaxBeacons > 0 )
+  {
+    v29 = pSavegameThumbnails;
+    v28 = v0->pInstalledBeacons;
+    while ( 1 )
+    {
+      v22.uFrameWidth = 92;
+      v4 = result;
+      v22.uFrameHeight = 68;
+      v5 = pLloydsBeaconsPreviewXs[result];
+      v22.uFrameY = pLloydsBeaconsPreviewYs[result];
+      v25 = v22.uFrameY;
+      v22.uFrameX = v5;
+      v22.uFrameW = v22.uFrameY + 67;
+      v6 = v29->pPixels == 0;
+      v22.uFrameZ = v5 + 91;
+      if ( !v6 )
+        break;
+      if ( !bRecallingBeacon )
+      {
+        pRenderer->DrawTextureTransparent(
+          pLloydsBeacons_SomeXs[v4],
+          pLloydsBeacons_SomeYs[v4],
+          pTexture_CurrentBook);
+        v21 = 3;
+        v18 = pGlobalTXT_LocalizationStrings[19];
+        v16 = 1;
+        v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &v22, 0, 0);
+        v15 = (signed int)v22.uFrameHeight / 2 - v14 / 2;
+        goto LABEL_28;
+      }
+LABEL_29:
+      ++v29;
+      ++v28;
+      result = v27++ + 1;
+      if ( v27 >= uNumMaxBeacons )
+        goto LABEL_30;
+    }
+    pRenderer->DrawTextureTransparent(
+      pLloydsBeacons_SomeXs[v4],
+      pLloydsBeacons_SomeYs[v4],
+      pTexture_CurrentBook);
+    pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
+    v7 = v28;
+    Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
+    v8 = pSpellFont->CalcTextHeight(Str, &v22, 0, 0);
+    v22.uFrameY += -6 - v8;
+    v22.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
+    v9 = v7->uBeaconTime - pParty->uTimePlayed;
+    LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
+    HIDWORD(v24) = HIDWORD(v9);
+    v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
+    v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
+    v11 = v10 / 0x18;
+    if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
+    {
+      v13 = pGlobalTXT_LocalizationStrings[57]; // Days
+      if ( v11 > 1 )
+      {
+LABEL_24:
+        v20 = v13;
+        v17 = v11 + 1;
+LABEL_25:
+        sprintf(pTmpBuf, "%lu %s", v17, v20);
+        v21 = 3;
+        v18 = pTmpBuf;
+        v16 = 1;
+        v22.uFrameY = v25 + v22.uFrameHeight + 4;
+        v15 = 0;
+LABEL_28:
+        v22.DrawTitleText(pSpellFont, 0, v15, v16, v18, v21);
+        goto LABEL_29;
+      }
+    }
+    else
+    {
+      if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
+      {
+        if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
+          v12 = pGlobalTXT_LocalizationStrings[109];// Hour
+        else
+          v12 = pGlobalTXT_LocalizationStrings[110];// Hours
+        v20 = v12;
+        v17 = v10 + 1;
+        goto LABEL_25;
+      }
+    }
+    v13 = pGlobalTXT_LocalizationStrings[56];   // Day
+    goto LABEL_24;
+  }
+LABEL_30:
+  if ( byte_506360 )
+  {
+    result = pMessageQueue_50CBD0->uNumMessages;
+    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    {
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)181;
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+      result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
+      *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
+      ++pMessageQueue_50CBD0->uNumMessages;
+    }
+  }
+  return result;
+}
+
+
+//----- (00411150) --------------------------------------------------------
+char *__cdecl DrawTownPortalScreen()
+{
+  signed int v0; // edi@1
+  __int16 v1; // dx@8
+  POINT *v2; // edi@17
+  int v3; // edi@17
+  __int16 v4; // dx@24
+  GUIWindow v6; // [sp+Ch] [bp-64h]@1
+  POINT v7; // [sp+60h] [bp-10h]@17
+  POINT a2; // [sp+68h] [bp-8h]@17
+
+  pRenderer->ClearZBuffer(0, 479);
+  pRenderer->DrawTextureTransparent(8u, 8u, pTexture_CurrentBook);
+  pRenderer->DrawTextureTransparent(
+    0x1D7u,
+    0x1BDu,
+    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+  v6.uFrameX = 8;
+  v6.uFrameY = 8;
+  v6.uFrameWidth = 460;
+  v6.uFrameHeight = 344;
+  v6.uFrameZ = 467;
+  v6.uFrameW = 351;
+  v0 = 0;
+  do
+  {
+    if ( !v0 )
+    {
+      v1 = 206;
+LABEL_14:
+      if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v1) )
+        goto LABEL_16;
+      goto LABEL_15;
+    }
+    if ( v0 == 1 )
+    {
+      v1 = 208;
+      goto LABEL_14;
+    }
+    if ( v0 == 2 )
+    {
+      v1 = 207;
+      goto LABEL_14;
+    }
+    if ( v0 == 3 )
+    {
+      v1 = 211;
+      goto LABEL_14;
+    }
+    if ( v0 == 4 )
+    {
+      v1 = 209;
+      goto LABEL_14;
+    }
+    if ( v0 == 5 )
+    {
+      v1 = 210;
+      goto LABEL_14;
+    }
+LABEL_15:
+    pRenderer->_4A612A(
+      pTownPortalBook_xs[v0],
+      pTownPortalBook_ys[v0],
+      *(&pTexture_TownPortalHarmn + v0),
+      v0 + 1);
+LABEL_16:
+    ++v0;
+  }
+  while ( v0 < 6 );
+  v2 = pMouse->GetCursorPos(&a2);
+  v3 = pRenderer->pActiveZBuffer[v2->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF;
+  if ( !v3 )                                    // Town Portal
+    return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+  if ( v3 == 1 )
+  {
+    v4 = 206;
+LABEL_30:
+    if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, v4) )
+      goto LABEL_31;
+    return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+  }
+  if ( v3 == 2 )
+  {
+    v4 = 208;
+    goto LABEL_30;
+  }
+  if ( v3 == 3 )
+  {
+    v4 = 207;
+    goto LABEL_30;
+  }
+  if ( v3 == 4 )
+  {
+    v4 = 211;
+    goto LABEL_30;
+  }
+  if ( v3 == 5 )
+  {
+    v4 = 209;
+    goto LABEL_30;
+  }
+  if ( v3 == 6 )
+  {
+    v4 = 210;
+    goto LABEL_30;
+  }
+LABEL_31:
+  pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3));
+  return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+}
+// 4E1D3A: using guessed type __int16 word_4E1D3A[];
+
+//----- (00411300) --------------------------------------------------------
+Texture *__fastcall LoadSpellbook(unsigned int uID)
+{
+  unsigned int v1; // esi@1
+  Player *pPlayer; // ecx@1
+  char v3; // al@1
+  int v4; // edi@5
+  Texture *result; // eax@6
+  char *v6; // edi@7
+  unsigned int v7; // eax@7
+  unsigned __int8 v8; // sf@8
+  unsigned __int8 v9; // of@8
+  char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
+  Texture *v11; // [sp+20h] [bp-8h]@5
+  int v12; // [sp+24h] [bp-4h]@5
+
+  byte_506550 = 0;
+  v1 = uID;
+  pPlayer = pPlayers[uActiveCharacter];
+  v3 = pPlayer->uQuickSpell;
+  if ( v3 && (unsigned __int8)v3 / 11 == v1 )
+    dword_50654C = (unsigned __int8)v3 - 11 * v1;
+  else
+    dword_50654C = 0;
+  v4 = 1;
+  v12 = 1;
+  v11 = (Texture *)&pPlayer->field_152[11 * v1 + 63];
+  do
+  {
+    result = v11;
+    if ( v11->pName[v4] )
+    {
+      v6 = &byte_4E2430[12 * v1] + v4;
+      sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
+      v7 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      dword_506408[v12] = 72 * v7 + 7145548;
+      sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
+      result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
+      dword_5063D8[v12] = result;
+    }
+    v4 = v12 + 1;
+    v9 = __OFSUB__(v12 + 1, 12);
+    v8 = v12++ - 11 < 0;
+  }
+  while ( v8 ^ v9 );
+  return result;
+}
+// 4E1D18: using guessed type char *spellbook_texture_filename_suffices[8];
+// 506408: using guessed type int dword_506408[];
+// 50654C: using guessed type int dword_50654C;
+// 506550: using guessed type char byte_506550;
+
+//----- (0041140B) --------------------------------------------------------
+GUIWindow *__cdecl sub_41140B()
+{
+  signed int v0; // esi@1
+  GUIButton *v1; // eax@3
+  GUIButton *v2; // esi@4
+  GUIWindow *result; // eax@5
+
+  v0 = 0;
+  do
+  {
+    dword_506404[v0]->Release();
+    dword_506434[v0]->Release();
+    --v0;
+  }
+  while ( v0 >= -11 );
+  pIcons_LOD->_40F9C5();
+  v1 = pGUIWindow_CurrentMenu->pControlsHead;
+  if ( v1 )
+  {
+    do
+    {
+      v2 = v1->pNext;
+      pAllocator->FreeChunk(v1);
+      v1 = v2;
+    }
+    while ( v2 );
+  }
+  pGUIWindow_CurrentMenu->pControlsHead = 0;
+  pGUIWindow_CurrentMenu->pControlsTail = 0;
+  result = pGUIWindow_CurrentMenu;
+  pGUIWindow_CurrentMenu->uNumControls = 0;
+  return result;
+}
+
+//----- (00411473) --------------------------------------------------------
+void __cdecl sub_411473()
+{
+  Texture **v0; // esi@1
+  Texture **v1; // edi@1
+  Texture *v2; // ecx@2
+  Texture *v3; // ecx@2
+
+  pTexture_pagemask->Release();
+  pTexture_506448->Release();
+  pTexture_50643C->Release();
+  v0 = &pTextures_tabs[0][1];
+  v1 = pTextures_5064A0;
+  do
+  {
+    (*v1)->Release();
+    v2 = (Texture *)*((int *)v0 - 1);
+    *v1 = 0;
+    v2->Release();
+    v3 = *(Texture **)v0;
+    *((int *)v0 - 1) = 0;
+    v3->Release();
+    *(int *)v0 = 0;
+    ++v1;
+    v0 += 8;
+  }
+  while ( (signed int)v1 < (signed int)&pTextures_5064A0[9] );
+  pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
+  pIcons_LOD->_4114F2();
+}
+
+
+//----- (00411597) --------------------------------------------------------
+void __cdecl OnCloseSpellook()
+{
+  pAllocator->FreeChunk(pSpellFont);
+  pSpellFont = 0;
+  pAllocator->FreeChunk(pBookFont);
+  pBookFont = 0;
+  pAllocator->FreeChunk(pBook2Font);
+  pBook2Font = 0;
+  pAllocator->FreeChunk(pAutonoteFont);
+  pAutonoteFont = 0;
+  pTexture_mapbordr->Release();
+  pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
+  pIcons_LOD->_4114F2();
+  dword_506364 = 0;
+}
+// 506364: using guessed type int dword_506364;
+
+
+
+
+
+
+
+//----- (00412AF9) --------------------------------------------------------
+void __cdecl sub_412AF9()
+{
+  int v0; // ecx@1
+
+  v0 = 0;
+  if ( uActiveCharacter )
+    v0 = *((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
+  pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
+  pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
+  pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
+}
+
+//----- (00412B58) --------------------------------------------------------
+void __cdecl sub_412B58()
+{
+  Player *v0; // ebx@1
+  int v1; // ebp@1
+  unsigned int v2; // eax@1
+  Texture *v3; // edi@1
+  int v4; // esi@1
+  Texture *v5; // eax@3
+  Texture *v6; // edx@5
+  int v7; // eax@8
+  int v8; // eax@11
+  POINT *v9; // esi@13
+  int v10; // eax@13
+  Texture *v11; // edx@14
+  int v12; // eax@15
+  signed int v13; // ecx@18
+  unsigned int v14; // esi@18
+  unsigned int v15; // edi@18
+  Texture *v16; // eax@21
+  unsigned int v17; // [sp-Ch] [bp-2Ch]@8
+  unsigned int v18; // [sp-Ch] [bp-2Ch]@15
+  unsigned int v19; // [sp-8h] [bp-28h]@8
+  unsigned int v20; // [sp-8h] [bp-28h]@15
+  Texture *v21; // [sp-4h] [bp-24h]@15
+  signed int v22; // [sp-4h] [bp-24h]@22
+  int v23[2]; // [sp+10h] [bp-10h]@5
+  POINT a2; // [sp+18h] [bp-8h]@13
+
+  sub_412AF9();
+  v0 = pPlayers[uActiveCharacter];
+  v1 = 11 * v0->pNumSpellBookPage;
+  v2 = pIcons_LOD->FindTextureByName("Pending");
+  v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
+  pRenderer->ClearZBuffer(0, 479);
+  v4 = 1;
+  if ( __OFSUB__(v1, v1 + 11) ^ 1 )
+  {
+    do
+    {
+      if ( *(&v0->field_152[v1 + 63] + v4) )
+      {
+        v5 = (Texture *)dword_506408[v4];
+        if ( v5 != v3 )
+        {
+          if ( dword_50654C == v4 )
+          {
+            v6 = dword_5063D8[v4];
+            v23[0] = (int)dword_5063D8[v4];
+          }
+          else
+          {
+            v23[0] = dword_506408[v4];
+            v6 = v5;
+          }
+          if ( v6->pLevelOfDetail0 )
+          {
+            v7 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage + v4]));
+            v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
+            v17 = pViewport->uViewportX + dword_4E20D0[v7];
+            if ( BYTE1(v6->pBits) & 2 )
+              pRenderer->DrawTextureTransparent(v17, v19, v6);
+            else
+              pRenderer->DrawTextureIndexed(v17, v19, v6);
+            v8 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v4));
+            pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], (Texture *)v23[0], v4);
+          }
+        }
+      }
+      ++v4;
+    }
+    while ( v4 + v1 - 1 < v1 + 11 );
+  }
+  v9 = pMouse->GetCursorPos(&a2);
+  v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)v23)->y]] & 0xFFFF;
+  if ( v10 )
+  {
+    v11 = dword_5063D8[v10];
+    if ( v11->pLevelOfDetail0 )
+    {
+      v21 = dword_5063D8[v10];
+      v12 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v10));
+      v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
+      v18 = pViewport->uViewportX + dword_4E20D0[v12];
+      if ( BYTE1(v11->pBits) & 2 )
+        pRenderer->DrawTextureTransparent(v18, v20, v21);
+      else
+        pRenderer->DrawTextureIndexed(v18, v20, v21);
+    }
+  }
+  v13 = 0;
+  a2.x = (LONG)&v0->pActiveSkills[12];
+  v14 = (unsigned int)&v0->pActiveSkills[12];
+  v15 = (unsigned int)&v0->pActiveSkills[12];
+  v23[0] = 0;
+  do
+  {
+    if ( *(short *)a2.x )
+    {
+      if ( v0->pNumSpellBookPage == v13 )
+      {
+        v16 = pTextures_tabs[v13][1];
+        switch ( v13 )
+        {
+          case 0:
+            v14 = 406;
+            v22 = 9;
+            goto LABEL_27;
+          case 1:
+            v14 = 406;
+            goto LABEL_38;
+          case 2:
+            v14 = 406;
+            v22 = 84;
+            goto LABEL_27;
+          case 3:
+            v14 = 406;
+            goto LABEL_26;
+          case 4:
+            v14 = 407;
+            goto LABEL_29;
+          case 5:
+            v15 = 196;
+            goto LABEL_34;
+          case 6:
+            v15 = 234;
+            goto LABEL_34;
+          case 7:
+            v15 = 272;
+            goto LABEL_34;
+          case 8:
+            v15 = 309;
+LABEL_34:
+            v14 = 405;
+            break;
+          default:
+            break;
+        }
+      }
+      else
+      {
+        v16 = pTextures_tabs[v13][0];
+        switch ( v13 )
+        {
+          case 0:
+            v14 = 415;
+            v22 = 10;
+            goto LABEL_27;
+          case 1:
+            v14 = 415;
+LABEL_38:
+            v22 = 46;
+            goto LABEL_27;
+          case 2:
+            v14 = 415;
+            v22 = 83;
+            goto LABEL_27;
+          case 3:
+            v14 = 415;
+LABEL_26:
+            v22 = 121;
+LABEL_27:
+            v15 = v22;
+            break;
+          case 4:
+            v14 = 415;
+LABEL_29:
+            v15 = 158;
+            break;
+          case 5:
+            v15 = 196;
+            goto LABEL_46;
+          case 6:
+            v15 = 234;
+            goto LABEL_46;
+          case 7:
+            v15 = 271;
+            goto LABEL_46;
+          case 8:
+            v15 = 307;
+LABEL_46:
+            v14 = 416;
+            break;
+          default:
+            break;
+        }
+      }
+      pRenderer->DrawTextureTransparent(v14, v15, v16);
+      v13 = v23[0];
+    }
+    a2.x += 2;
+    ++v13;
+    v23[0] = v13;
+  }
+  while ( v13 < 9 );
+}
+// 506408: using guessed type int dword_506408[];
+// 50654C: using guessed type int dword_50654C;
+
+//----- (00412E85) --------------------------------------------------------
+char __cdecl sub_412E85()
+{
+  unsigned int v0; // eax@3
+  unsigned int v1; // eax@7
+  int v2; // eax@10
+  const char *v3; // eax@10
+  signed int v4; // ecx@12
+  int v5; // ecx@14
+  int v6; // eax@21
+  int v7; // esi@21
+  char *v8; // eax@21
+  int v9; // eax@22
+  unsigned int v11; // [sp-8h] [bp-64h]@3
+  unsigned int v12; // [sp-8h] [bp-64h]@7
+  Texture *v13; // [sp-4h] [bp-60h]@3
+  Texture *v14; // [sp-4h] [bp-60h]@7
+  GUIWindow a1; // [sp+8h] [bp-54h]@10
+
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[11]);
+  if ( dword_506548 || !dword_506528 )
+  {
+    v13 = pTex_tab_an_6a__zoom_off;
+    v11 = pViewport->uViewportY + 2;
+    v0 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v13 = pTex_tab_an_6b__zoom_on;
+    v11 = pViewport->uViewportY + 1;
+    v0 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v0, v11, v13);
+  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  {
+    v14 = pTex_tab_an_7a__zoot_off;
+    v12 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v14 = pTex_tab_an_7b__zoot_on;
+    v12 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v1, v12, v14);
+  if ( !byte_5C6D50[dword_506528] )
+  {
+    v2 = pStru179->field_0[dword_506528];
+    a1.uFrameWidth = 460;
+    a1.uFrameX = 8;
+    a1.uFrameY = 8;
+    a1.uFrameHeight = 344;
+    v3 = (const char *)pStorylineText->field_4[3 * v2];
+    a1.uFrameZ = 467;
+    a1.uFrameW = 351;
+    if ( v3 )
+      a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, v3, 3u);
+  }
+  a1.uFrameX = 48;
+  a1.uFrameY = 70;
+  a1.uFrameWidth = 360;
+  a1.uFrameHeight = 264;
+  v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
+  a1.uFrameZ = 407;
+  a1.uFrameHeight = v4 * 264 / v4;
+  a1.uFrameW = a1.uFrameHeight + 69;
+  if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
+  {
+    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    v5 = dword_50651C++;
+    dword_506528 += dword_506520;
+    byte_506130[v5] = dword_506520;
+  }
+  if ( dword_506548 && dword_50651C )
+  {
+    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    --dword_50651C;
+    dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
+  }
+  if ( !dword_506520 || dword_506528 < 1 )
+  {
+    dword_506528 = 0;
+    dword_50651C = 0;
+  }
+  dword_506544 = 0;
+  v6 = pStru179->field_0[dword_506528];
+  dword_506548 = 0;
+  dword_506520 = 0;
+  v7 = *(&pStorylineText->field_0 + 3 * v6);
+  v8 = sub_495461(
+         *((char **)&pStorylineText->field_0 + 3 * v6),
+         uActiveCharacter - 1,
+         0,
+         0,
+         0,
+         (__int64 *)&pParty->field_3C.field_440[2 * v6 + 42]);
+  if ( v7 )
+  {
+    v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
+    LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
+    ++dword_506520;
+  }
+  return (char)v8;
+}
+
+
+//----- (00413126) --------------------------------------------------------
+void __cdecl DrawSpellbook_Quests()
+{
+  unsigned int v0; // eax@3
+  unsigned int v1; // eax@7
+  int v2; // ecx@11
+  int v3; // ebx@16
+  int v4; // eax@19
+  const char *v5; // edi@19
+  int v6; // eax@19
+  unsigned int v7; // edi@19
+  unsigned int v8; // [sp-8h] [bp-68h]@3
+  unsigned int v9; // [sp-8h] [bp-68h]@7
+  Texture *v10; // [sp-4h] [bp-64h]@3
+  Texture *v11; // [sp-4h] [bp-64h]@7
+  GUIWindow a1; // [sp+Ch] [bp-54h]@9
+
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_CurrentBook);
+  if ( dword_506548 || !dword_506528 )
+  {
+    v10 = pTex_tab_an_6a__zoom_off;
+    v8 = pViewport->uViewportY + 2;
+    v0 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v10 = pTex_tab_an_6b__zoom_on;
+    v8 = pViewport->uViewportY + 1;
+    v0 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v0, v8, v10);
+  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  {
+    v11 = pTex_tab_an_7a__zoot_off;
+    v9 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v11 = pTex_tab_an_7b__zoot_on;
+    v9 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v1, v9, v11);
+  a1.uFrameWidth = 460;
+  a1.uFrameHeight = 344;
+  a1.uFrameX = 8;
+  a1.uFrameY = 8;
+  a1.uFrameZ = 467;
+  a1.uFrameW = 351;
+  a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[174], 3u);
+  a1.uFrameX = 48;
+  a1.uFrameY = 70;
+  a1.uFrameWidth = 360;
+  a1.uFrameHeight = 264;
+  a1.uFrameZ = 407;
+  a1.uFrameW = 333;
+  if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
+  {
+    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    v2 = dword_50651C++;
+    dword_506528 += dword_506520;
+    byte_506130[v2] = dword_506520;
+  }
+  if ( dword_506548 && dword_50651C )
+  {
+    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    --dword_50651C;
+    dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
+  }
+  if ( !dword_506520 || (v3 = dword_506528, dword_506528 < 1) )
+  {
+    v3 = 0;
+    dword_50651C = 0;
+    dword_506528 = 0;
+  }
+  dword_506544 = 0;
+  dword_506548 = 0;
+  dword_506520 = 0;
+  while ( v3 < dword_506524 )
+  {
+    v4 = pStru179->field_0[v3];
+    ++dword_506520;
+    v5 = (&dword_722F10)[4 * v4];
+    a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_722F10)[4 * v4], 0, 0, 0);
+    v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
+    v7 = a1.uFrameY + v6;
+    if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight )
+      break;
+    pRenderer->DrawTextureTransparent(0x64u, v7 + 12, pTextures_5064A0[10]);
+    ++v3;
+    a1.uFrameY = v7 + 24;
+  }
+}
+
+
+//----- (0041338E) --------------------------------------------------------
+void __cdecl DrawSpellbook_Autonotes()
+{
+  unsigned int v0; // eax@3
+  unsigned int v1; // eax@7
+  signed int v2; // ebp@11
+  unsigned int v3; // eax@18
+  unsigned int v4; // eax@24
+  unsigned int v5; // eax@30
+  unsigned int v6; // eax@36
+  unsigned int v7; // eax@42
+  signed int v8; // ebp@47
+  int v9; // eax@52
+  int v10; // eax@56
+  int v11; // edx@57
+  int v12; // ebp@64
+  int v13; // eax@65
+  const char *v14; // edi@65
+  int v15; // eax@65
+  unsigned int v16; // edi@65
+  unsigned int v17; // [sp-8h] [bp-70h]@3
+  unsigned int v18; // [sp-8h] [bp-70h]@7
+  unsigned int v19; // [sp-8h] [bp-70h]@18
+  unsigned int v20; // [sp-8h] [bp-70h]@24
+  unsigned int v21; // [sp-8h] [bp-70h]@30
+  unsigned int v22; // [sp-8h] [bp-70h]@36
+  unsigned int v23; // [sp-8h] [bp-70h]@42
+  Texture *v24; // [sp-4h] [bp-6Ch]@3
+  Texture *v25; // [sp-4h] [bp-6Ch]@7
+  Texture *v26; // [sp-4h] [bp-6Ch]@18
+  Texture *v27; // [sp-4h] [bp-6Ch]@24
+  Texture *v28; // [sp-4h] [bp-6Ch]@30
+  Texture *v29; // [sp-4h] [bp-6Ch]@36
+  Texture *v30; // [sp-4h] [bp-6Ch]@42
+  signed __int16 v31; // [sp+10h] [bp-58h]@1
+  char *v32; // [sp+10h] [bp-58h]@49
+  GUIWindow a1; // [sp+14h] [bp-54h]@46
+
+  v31 = 0;
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_AutonotesBook);
+  if ( dword_506548 || !dword_506528 )
+  {
+    v24 = pTex_tab_an_6a__zoom_off;
+    v17 = pViewport->uViewportY + 2;
+    v0 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v24 = pTex_tab_an_6b__zoom_on;
+    v17 = pViewport->uViewportY + 1;
+    v0 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v0, v17, v24);
+  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  {
+    v25 = pTex_tab_an_7a__zoot_off;
+    v18 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 407;
+  }
+  else
+  {
+    v25 = pTex_tab_an_7b__zoot_on;
+    v18 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v1, v18, v25);
+  if ( !dword_506540 )
+  {
+    if ( dword_506568 )
+    {
+      pRenderer->DrawTextureTransparent(
+        pViewport->uViewportX + 408,
+        pViewport->uViewportY + 113,
+        pTexture_506390);
+      v2 = 1;
+      goto LABEL_16;
+    }
+    goto LABEL_14;
+  }
+  if ( !dword_506568 )
+  {
+LABEL_14:
+    v2 = 1;
+    goto LABEL_15;
+  }
+  v2 = 1;
+  v31 = 1;
+  pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+LABEL_15:
+  dword_506568 = 0;
+  pRenderer->DrawTextureTransparent(pViewport->uViewportX + 398, pViewport->uViewportY + 113, pTexture_506394);
+LABEL_16:
+  if ( dword_50653C )
+  {
+    if ( dword_506568 != v2 )
+    {
+      v31 = v2;
+      pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( dword_506568 != v2 )
+    {
+      v26 = pTexture_506388;
+      v19 = pViewport->uViewportY + 150;
+      v3 = pViewport->uViewportX + 408;
+      goto LABEL_22;
+    }
+  }
+  v26 = pTexture_50638C;
+  dword_506568 = v2;
+  v19 = pViewport->uViewportY + 150;
+  v3 = pViewport->uViewportX + 399;
+LABEL_22:
+  pRenderer->DrawTextureTransparent(v3, v19, v26);
+  if ( dword_506538 )
+  {
+    if ( dword_506568 != 2 )
+    {
+      v31 = v2;
+      pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( dword_506568 != 2 )
+    {
+      v27 = pTexture_506380;
+      v20 = pViewport->uViewportY + 188;
+      v4 = pViewport->uViewportX + 408;
+      goto LABEL_28;
+    }
+  }
+  v27 = pTexture_506384;
+  dword_506568 = 2;
+  v20 = pViewport->uViewportY + 188;
+  v4 = pViewport->uViewportX + 397;
+LABEL_28:
+  pRenderer->DrawTextureTransparent(v4, v20, v27);
+  if ( dword_506534 )
+  {
+    if ( dword_506568 != 3 )
+    {
+      v31 = v2;
+      pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( dword_506568 != 3 )
+    {
+      v28 = pTexture_506378;
+      v21 = pViewport->uViewportY + 226;
+      v5 = pViewport->uViewportX + 408;
+      goto LABEL_34;
+    }
+  }
+  v28 = pTexture_50637C;
+  dword_506568 = 3;
+  v21 = pViewport->uViewportY + 226;
+  v5 = pViewport->uViewportX + 397;
+LABEL_34:
+  pRenderer->DrawTextureTransparent(v5, v21, v28);
+  if ( dword_506530 )
+  {
+    if ( dword_506568 != 4 )
+    {
+      v31 = v2;
+      pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( dword_506568 != 4 )
+    {
+      v29 = pTexture_506370;
+      v22 = pViewport->uViewportY + 263;
+      v6 = pViewport->uViewportX + 408;
+      goto LABEL_40;
+    }
+  }
+  v29 = pTexture_506374;
+  dword_506568 = 4;
+  v22 = pViewport->uViewportY + 264;
+  v6 = pViewport->uViewportX + 397;
+LABEL_40:
+  pRenderer->DrawTextureTransparent(v6, v22, v29);
+  if ( dword_50652C )
+  {
+    if ( dword_506568 != 5 )
+    {
+      v31 = v2;
+      pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( dword_506568 != 5 )
+    {
+      v30 = pTexture_506368;
+      v23 = pViewport->uViewportY + 302;
+      v7 = pViewport->uViewportX + 408;
+      goto LABEL_46;
+    }
+  }
+  v30 = pTexture_50636C;
+  dword_506568 = 5;
+  v23 = pViewport->uViewportY + 302;
+  v7 = pViewport->uViewportX + 397;
+LABEL_46:
+  pRenderer->DrawTextureTransparent(v7, v23, v30);
+  a1.uFrameWidth = 460;
+  a1.uFrameHeight = 344;
+  a1.uFrameX = 8;
+  a1.uFrameY = 8;
+  a1.uFrameZ = 467;
+  a1.uFrameW = 467;
+  a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[154], 3u);
+  a1.uFrameX = 48;
+  a1.uFrameY = 70;
+  a1.uFrameWidth = 360;
+  a1.uFrameHeight = 264;
+  a1.uFrameZ = 407;
+  a1.uFrameW = 333;
+  if ( v31 )
+  {
+    dword_506524 = 0;
+    dword_506528 = 0;
+    dword_50651C = 0;
+    dword_506520 = 0;
+    v8 = 0;
+    do
+    {
+      if ( dword_72371C[2 * v8] == dword_506568 )
+      {
+        v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8];
+        if ( (short)v8 )
+        {
+          if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
+          {
+            v9 = dword_506520++;
+            pStru179->field_0[v9] = (signed __int16)v8;
+          }
+        }
+      }
+      ++v8;
+    }
+    while ( v8 < 196 );
+    dword_506524 = dword_506520;
+  }
+  else
+  {
+    if ( dword_506544 )
+    {
+      v10 = dword_506520 + dword_506528;
+      if ( dword_506520 + dword_506528 < dword_506524 )
+      {
+        v11 = dword_50651C++;
+        byte_506130[v11] = dword_506520;
+        dword_506528 = v10;
+        pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+      }
+    }
+    if ( dword_506548 && dword_50651C )
+    {
+      --dword_50651C;
+      dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
+      pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    }
+    if ( !dword_506520 || dword_506528 < 1 )
+    {
+      dword_506528 = 0;
+      dword_50651C = 0;
+    }
+  }
+  v12 = dword_506528;
+  dword_50652C = 0;
+  dword_506544 = 0;
+  dword_506548 = 0;
+  dword_506520 = 0;
+  dword_506530 = 0;
+  dword_506534 = 0;
+  dword_506538 = 0;
+  dword_50653C = 0;
+  dword_506540 = 0;
+  while ( v12 < dword_506524 )
+  {
+    v13 = pStru179->field_0[v12];
+    ++dword_506520;
+    v14 = (&dword_723718_autonote_related)[8 * v13];
+    a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
+    v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0);
+    v16 = a1.uFrameY + v15;
+    if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight )
+      break;
+    pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pTextures_5064A0[10]);
+    ++v12;
+    a1.uFrameY = v16 + 24;
+  }
+}
+
+
+//----- (00413980) --------------------------------------------------------
+char *__cdecl DrawSpellbook_Map()
+{
+  unsigned int v0; // eax@3
+  unsigned int v1; // eax@7
+  unsigned int v2; // eax@10
+  unsigned int v3; // eax@13
+  unsigned int v4; // eax@16
+  unsigned int v5; // eax@19
+  int v6; // eax@31
+  unsigned int v7; // eax@35
+  unsigned int v9; // [sp-8h] [bp-E0h]@3
+  unsigned int v10; // [sp-8h] [bp-E0h]@7
+  unsigned int v11; // [sp-8h] [bp-E0h]@10
+  unsigned int v12; // [sp-8h] [bp-E0h]@13
+  unsigned int v13; // [sp-8h] [bp-E0h]@16
+  unsigned int v14; // [sp-8h] [bp-E0h]@19
+  Texture *v15; // [sp-4h] [bp-DCh]@3
+  Texture *v16; // [sp-4h] [bp-DCh]@7
+  Texture *v17; // [sp-4h] [bp-DCh]@10
+  Texture *v18; // [sp-4h] [bp-DCh]@13
+  Texture *v19; // [sp-4h] [bp-DCh]@16
+  Texture *v20; // [sp-4h] [bp-DCh]@19
+  char Str[120]; // [sp+Ch] [bp-CCh]@37
+  GUIWindow v22; // [sp+84h] [bp-54h]@35
+
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[12]);
+  if ( dword_506548 || viewparams->field_2C / 128 >= 12 )
+  {
+    v15 = pTex_tab_an_6a__zoom_off;
+    v9 = pViewport->uViewportY + 2;
+    v0 = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    v15 = pTex_tab_an_6b__zoom_on;
+    v9 = pViewport->uViewportY + 1;
+    v0 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v0, v9, v15);
+  if ( dword_506544 || viewparams->field_2C / 128 <= 3 )
+  {
+    v16 = pTex_tab_an_7a__zoot_off;
+    v10 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    v16 = pTex_tab_an_7b__zoot_on;
+    v10 = pViewport->uViewportY + 38;
+    v1 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v1, v10, v16);
+  if ( dword_506540 )
+  {
+    v17 = pTexture_506390;
+    v11 = pViewport->uViewportY + 113;
+    v2 = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    v17 = pTexture_506394;
+    v11 = pViewport->uViewportY + 113;
+    v2 = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(v2, v11, v17);
+  if ( dword_50653C )
+  {
+    v18 = pTexture_506388;
+    v12 = pViewport->uViewportX + 150;
+    v3 = pViewport->uViewportY + 408;
+  }
+  else
+  {
+    v18 = pTexture_50638C;
+    v12 = pViewport->uViewportX + 150;
+    v3 = pViewport->uViewportY + 399;
+  }
+  pRenderer->DrawTextureTransparent(v3, v12, v18);
+  if ( dword_506538 )
+  {
+    v19 = pTexture_506380;
+    v13 = pViewport->uViewportY + 188;
+    v4 = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    v19 = pTexture_506384;
+    v13 = pViewport->uViewportY + 188;
+    v4 = pViewport->uViewportX + 397;
+  }
+  pRenderer->DrawTextureTransparent(v4, v13, v19);
+  if ( dword_506534 )
+  {
+    v20 = pTexture_506378;
+    v14 = pViewport->uViewportY + 226;
+    v5 = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    v20 = pTexture_50637C;
+    v14 = pViewport->uViewportY + 226;
+    v5 = pViewport->uViewportX + 397;
+  }
+  pRenderer->DrawTextureTransparent(v5, v14, v20);
+  if ( dword_506544 )
+    viewparams->_443291();
+  if ( dword_506548 )
+    viewparams->_443249();
+  if ( dword_506540 )
+    viewparams->_443219();
+  if ( dword_50653C )
+    viewparams->_443231();
+  if ( dword_506538 )
+    viewparams->_44323D();
+  v6 = dword_506534;
+  if ( dword_506534 )
+  {
+    viewparams->_443225();
+    v6 = dword_506534;
+  }
+  if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | v6 )
+    pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+  dword_506548 = 0;
+  dword_506544 = 0;
+  dword_506534 = 0;
+  dword_506538 = 0;
+  dword_50653C = 0;
+  dword_506540 = 0;
+  DrawSpellbook_Map_sub(0x61u, 0x31u, 0x169u, 313, 0);
+  pRenderer->DrawTextureTransparent(0x4Bu, 0x16u, pTexture_mapbordr);
+  v22.uFrameWidth = 460;
+  v22.uFrameHeight = 344;
+  v22.uFrameX = 8;
+  v22.uFrameY = 8;
+  v22.uFrameZ = 467;
+  v22.uFrameW = 467;
+  v7 = pMapStats->GetMapInfo(pCurrentMapName);
+  if ( v7 )
+    v22.DrawTitleText(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
+  v22.uFrameX = 0;
+  sprintf(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y);
+  return v22.DrawTitleText(pFontComic, 0, 0x140u, 0, Str, 0);
+}
+
+
+//----- (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:
+      DrawLloydBeaconsScreen();
+      break;
+    case 0xC3u:
+      DrawTownPortalScreen();
+      break;
+    case 0xC8u:
+      DrawSpellbook_Quests();
+      break;
+    case 0xC9u:
+      DrawSpellbook_Autonotes();
+      break;
+    case 0xCAu:
+      DrawSpellbook_Map();
+      break;
+    case 0xCBu:
+      DrawSpellbook_Calendar();
+      break;
+    case 0xE0u:
+      sub_412E85();
+      break;
+  }
+}
+
+//----- (00413D3C) --------------------------------------------------------
+char *__cdecl GetDayPart()
+{
+  if ( pParty->uCurrentHour > 4 )
+  {
+    if ( pParty->uCurrentHour == 5 )
+      return pGlobalTXT_LocalizationStrings[55];
+    if ( pParty->uCurrentHour == 20 )
+      return pGlobalTXT_LocalizationStrings[566];
+    if ( pParty->uCurrentHour <= 0x14 || pParty->uCurrentHour > 0x17 )
+      return pGlobalTXT_LocalizationStrings[56];
+  }
+  return pGlobalTXT_LocalizationStrings[567];
+}
+
+//----- (00413D6F) --------------------------------------------------------
+char __cdecl DrawSpellbook_Calendar()
+{
+  unsigned int v0; // esi@1
+  char *v1; // eax@5
+  int v2; // ecx@5
+  char *v3; // eax@6
+  GUIWindow a1; // [sp+Ch] [bp-60h]@5
+  unsigned int v6; // [sp+60h] [bp-Ch]@1
+  int v7; // [sp+64h] [bp-8h]@1
+  int a5; // [sp+68h] [bp-4h]@1
+
+  v0 = pParty->uCurrentHour;
+  v6 = pMapStats->GetMapInfo(pCurrentMapName);
+  a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[13]);
+  v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
+  if ( (signed int)v0 <= 12 )
+  {
+    if ( !v0 )
+      v0 = 12;
+  }
+  else
+  {
+    v0 -= 12;
+  }
+  a1.uFrameX = 8;
+  a1.uFrameY = 8;
+  a1.uFrameWidth = 460;
+  a1.uFrameHeight = 344;
+  a1.uFrameZ = 467;
+  a1.uFrameW = 467;
+  a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[186], 3u);
+  v1 = GetDayPart();
+  sprintf(
+    pTmpBuf,
+    "%s\t100:\t110%d:%02d %s - %s",
+    pGlobalTXT_LocalizationStrings[526],
+    v0,
+    pParty->uCurrentMinute,
+    aAMPMNames[v2],
+    v1);
+  a1.DrawText(pBookFont, 70, 55, a5, pTmpBuf, 0, 0, 0);
+  sprintf(
+    pTmpBuf,
+    "%s\t100:\t110%d - %s",
+    pGlobalTXT_LocalizationStrings[56],
+    pParty->uDaysPlayed + 1,
+    aDayNames[pParty->uDaysPlayed % 7]);
+  a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, a5, pTmpBuf, 0, 0, 0);
+  sprintf(
+    pTmpBuf,
+    "%s\t100:\t110%d - %s",
+    pGlobalTXT_LocalizationStrings[146],
+    pParty->uCurrentMonth + 1,
+    aMonthNames[pParty->uCurrentMonth]);
+  a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, a5, pTmpBuf, 0, 0, 0);
+  sprintf(pTmpBuf, "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
+  a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, a5, pTmpBuf, 0, 0, 0);
+  sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[v7]);
+  a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, a5, pTmpBuf, 0, 0, 0);
+  if ( v6 )
+    v3 = pMapStats->pInfos[v6].pName;
+  else
+    v3 = "Unknown";
+  sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3);
+  return a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, a5, pTmpBuf, 0, 0, 0);
+}
+
+//----- (00413FF1) --------------------------------------------------------
+void __cdecl SetMonthNames()
+{
+  aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
+  aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
+  aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
+  aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
+  aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
+  aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
+  aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
+  aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
+  aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
+  aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
+  aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
+  aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
+}
+
+//----- (0041406F) --------------------------------------------------------
+void __cdecl SetDayNames()
+{
+  aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
+  aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
+  aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
+  aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
+  aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
+  aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
+  aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
+}
+
+//----- (004140BB) --------------------------------------------------------
+void __cdecl SetSpellSchoolNames()
+{
+  aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
+  aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
+  aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
+  aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
+  aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
+  aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
+  aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
+  aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
+  aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
+}
+
+//----- (0041411B) --------------------------------------------------------
+void __cdecl SetAttributeNames()
+{
+  aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
+  aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
+  aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
+  aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
+  aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
+  aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
+  aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
+}
+
+//----- (00414162) --------------------------------------------------------
+void __cdecl uGameUIFontMain_initialize()
+{
+  uGameUIFontMain = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
+}
+
+//----- (00414174) --------------------------------------------------------
+void __cdecl uGameUIFontShadow_initialize()
+{
+  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 214u, 193u);
+}
+
+
+
+
+
+//----- (004141CA) --------------------------------------------------------
+GUIWindow *__fastcall ModalWindow(const char *pStr, int a4)
+{
+  const char *v2; // edi@1
+  int v3; // esi@1
+  GUIWindow *result; // eax@1
+
+  v2 = pStr;
+  v3 = a4;
+  pEventTimer->Pause();
+  dword_506F0C[0] = pCurrentScreen;
+  result = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, v3, (int)v2);
+  ptr_507BDC = result;
+  pCurrentScreen = 22;
+  return result;
+}
+// 4E28F8: using guessed type int pCurrentScreen;
+
+//----- (0041420D) --------------------------------------------------------
+void __cdecl sub_41420D_press_esc()
+{
+  GUIWindow v0; // [sp+4h] [bp-54h]@1
+
+  sprintf(pTmpBuf2, "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape
+  v0.Hint = pTmpBuf2;
+  v0.uFrameWidth = 400;
+  v0.uFrameHeight = 100;
+  v0.uFrameX = 120;
+  v0.uFrameY = 140;
+  v0.uFrameZ = 519;
+  v0.uFrameW = 239;
+  v0.DrawMessageBox(0);
+}
+
+//----- (0041426F) --------------------------------------------------------
+void __cdecl sub_41426F()
+{
+  GUIWindow *v0; // ecx@1
+
+  v0 = ptr_507BDC;
+  if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+  {
+    pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C;
+    pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+    *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+    ++pMessageQueue_50CBD0->uNumMessages;
+  }
+  v0->Release();
+  ptr_507BDC = 0;
+  pCurrentScreen = dword_506F0C[0];
+  pEventTimer->Resume();
+}
+// 4E28F8: using guessed type int pCurrentScreen;
+
+//----- (004142D3) --------------------------------------------------------
+char __cdecl GameMenuUI_DrawKeyBindings()
+{
+  unsigned int v0; // ebp@1
+  int v1; // ecx@2
+  unsigned int v2; // eax@6
+  GUIWindow *v3; // edx@6
+  signed int v4; // ecx@7
+  signed int v5; // eax@8
+  const char *v6; // ST0C_4@16
+  unsigned int v7; // eax@16
+  const char *v8; // ST0C_4@16
+  unsigned int v9; // eax@16
+  const char *v10; // ST0C_4@16
+  unsigned int v11; // eax@16
+  const char *v12; // ST0C_4@16
+  unsigned int v13; // eax@16
+  const char *v14; // ST0C_4@16
+  unsigned int v15; // eax@16
+  const char *v16; // ST0C_4@16
+  unsigned int v17; // eax@16
+  const char *v18; // ST0C_4@16
+  unsigned int v19; // eax@16
+  const char *v20; // ST0C_4@16
+  unsigned int v21; // eax@16
+  signed int v22; // ebp@16
+  const char *v23; // ST0C_4@16
+  unsigned int v24; // eax@16
+  const char *v25; // ST0C_4@16
+  unsigned int v26; // eax@16
+  const char *v27; // ST0C_4@16
+  unsigned int v28; // eax@16
+  const char *v29; // ST0C_4@16
+  unsigned int v30; // eax@16
+  const char *v31; // ST0C_4@16
+  unsigned int v32; // eax@16
+  const char *v33; // ST0C_4@17
+  unsigned int v34; // eax@17
+  const char *v35; // ST0C_4@17
+  unsigned int v36; // eax@17
+  const char *v37; // ST0C_4@17
+  unsigned int v38; // eax@17
+  const char *v39; // ST0C_4@17
+  unsigned int v40; // eax@17
+  const char *v41; // ST0C_4@17
+  unsigned int v42; // eax@17
+  const char *v43; // ST0C_4@17
+  unsigned int v44; // eax@17
+  const char *v45; // ST0C_4@17
+  unsigned int v46; // eax@17
+  const char *v47; // ST0C_4@17
+  unsigned int v48; // eax@17
+  const char *v49; // ST0C_4@17
+  unsigned int v50; // eax@17
+  const char *v51; // ST0C_4@17
+  unsigned int v52; // eax@17
+  const char *v53; // ST0C_4@17
+  unsigned int v54; // eax@17
+  const char *v55; // ST0C_4@17
+  unsigned int v56; // eax@17
+  const char *v57; // ST0C_4@17
+  unsigned int v58; // eax@17
+  unsigned int v59; // eax@18
+  int v61; // [sp-14h] [bp-28h]@16
+  const char *v62; // [sp-10h] [bp-24h]@16
+  int v63; // [sp-Ch] [bp-20h]@16
+  int v64; // [sp-8h] [bp-1Ch]@16
+  unsigned int v65; // [sp-4h] [bp-18h]@16
+  unsigned int a5; // [sp+10h] [bp-4h]@1
+
+  v0 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  a5 = v0;
+  if ( byte_4E28FC )
+  {
+    v1 = dword_507C0C + 15;
+    dword_507C0C = v1;
+    if ( v1 == 255 )
+      byte_4E28FC = 0;
+  }
+  else
+  {
+    v1 = dword_507C0C - 15;
+    dword_507C0C = v1;
+    if ( v1 == 15 )
+      byte_4E28FC = 1;
+  }
+  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, 0, 0);
+  v3 = pGUIWindow_CurrentMenu;
+  dword_507C08 = v2;
+  if ( pGUIWindow_CurrentMenu->field_40 == 2 )
+  {
+    pPrevVirtualCidesMapping[dword_506E68] = pKeyActionMap->pPressedKeysBuffer[0];
+    memset(word_506E6C, 0, 0x1Cu);
+    v4 = 0;
+    do
+    {
+      v5 = 0;
+      do
+      {
+        if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] )
+        {
+          *((char *)word_506E6C + v4) = 1;
+          *((char *)word_506E6C + v5) = 1;
+        }
+        ++v5;
+      }
+      while ( v5 < 28 );
+      ++v4;
+    }
+    while ( v4 < 28 );
+    dword_506E68 = -1;
+    v3->field_40 = 0;
+  }
+  pRenderer->DrawTextureIndexed(
+    8u,
+    8u,
+    (Texture *)(uTextureID_507BF4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507BF4] : 0));
+  if ( dword_506F08 == 1 )
+  {
+    pRenderer->DrawTextureIndexed(
+      0x13u,
+      0x12Eu,
+      (Texture *)(uTextureID_507C00 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C00] : 0));
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
+    v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
+    v7 = sub_414D24(0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v7, v6, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2D50, 0, 0, 0);
+    v8 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]);
+    v9 = sub_414D24(1);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v9, v8, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2D48, 0, 0, 0);
+    v10 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]);
+    v11 = sub_414D24(2);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v11, v10, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2D40, 0, 0, 0);
+    v12 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]);
+    v13 = sub_414D24(3);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v13, v12, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2D38, 0, 0, 0);
+    v14 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]);
+    v15 = sub_414D24(4);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v15, v14, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2D30, 0, 0, 0);
+    v16 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]);
+    v17 = sub_414D24(5);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v17, v16, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2D28, 0, 0, 0);
+    v18 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]);
+    v19 = sub_414D24(6);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v19, v18, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2D1C, 0, 0, 0);
+    v20 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]);
+    v21 = sub_414D24(7);
+    v22 = 350;
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v21, v20, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2D14, 0, 0, 0);
+    v23 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]);
+    v24 = sub_414D24(8);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v24, v23, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2D0C, 0, 0, 0);
+    v25 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]);
+    v26 = sub_414D24(9);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v26, v25, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2D04, 0, 0, 0);
+    v27 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]);
+    v28 = sub_414D24(10);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v28, v27, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2CFC, 0, 0, 0);
+    v29 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]);
+    v30 = sub_414D24(11);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v30, v29, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2CF0, 0, 0, 0);
+    v31 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]);
+    v32 = sub_414D24(12);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v32, v31, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2CE8, 0, 0, 0);
+    v65 = 0;
+    v64 = 0;
+    v63 = 0;
+    v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
+    v61 = 13;
+  }
+  else
+  {
+    pRenderer->DrawTextureIndexed(
+      0x7Fu,
+      0x12Eu,
+      (Texture *)(uTextureID_507C04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C04] : 0));
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
+    v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
+    v34 = sub_414D24(14);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v34, v33, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2CD4, 0, 0, 0);
+    v35 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]);
+    v36 = sub_414D24(15);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v36, v35, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2CC8, 0, 0, 0);
+    v37 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]);
+    v38 = sub_414D24(16);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v38, v37, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2CBC, 0, 0, 0);
+    v39 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]);
+    v40 = sub_414D24(17);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v40, v39, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2CB0, 0, 0, 0);
+    v41 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]);
+    v42 = sub_414D24(18);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v42, v41, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2CA4, 0, 0, 0);
+    v43 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]);
+    v44 = sub_414D24(19);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v44, v43, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2C9C, 0, 0, 0);
+    v45 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]);
+    v46 = sub_414D24(20);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v46, v45, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2C90, 0, 0, 0);
+    v47 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]);
+    v48 = sub_414D24(21);
+    v22 = 350;
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v48, v47, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2C84, 0, 0, 0);
+    v49 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]);
+    v50 = sub_414D24(22);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v50, v49, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2C7C, 0, 0, 0);
+    v51 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]);
+    v52 = sub_414D24(23);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v52, v51, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2C70, 0, 0, 0);
+    v53 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]);
+    v54 = sub_414D24(24);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v54, v53, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2C68, 0, 0, 0);
+    v55 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]);
+    v56 = sub_414D24(25);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v56, v55, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2C5C, 0, 0, 0);
+    v57 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]);
+    v58 = sub_414D24(26);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v58, v57, 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2C54, 0, 0, 0);
+    v65 = 0;
+    v64 = 0;
+    v63 = 0;
+    v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
+    v61 = 27;
+  }
+  v59 = sub_414D24(v61);
+  return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, v63, v64, v65);
+}
+
+
+//----- (00414D24) --------------------------------------------------------
+unsigned int __thiscall sub_414D24(int _this)
+{
+  int v1; // esi@1
+  unsigned int v2; // edi@1
+  unsigned int v3; // ebx@1
+  unsigned int result; // eax@1
+
+  v1 = _this;
+  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFu, 0, 0);
+  result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  if ( dword_506E68 == v1 )
+  {
+    if ( GetTickCount() % 0x3E8 <= 0x1F4 )
+      result = v3;
+    else
+      result = v2;
+  }
+  else
+  {
+    if ( *((char *)word_506E6C + v1) )
+      result = dword_507C08;
+  }
+  return result;
+}
+// 506E68: using guessed type int dword_506E68;
+// 506E6C: using guessed type __int16 word_506E6C[18];
+// 507C08: using guessed type int dword_507C08;
+
+//----- (00414D9A) --------------------------------------------------------
+void __cdecl GameMenuUI_DrawVideoOptions()
+{
+  const char *v0; // ST0C_4@3
+  unsigned __int16 v1; // ax@3
+  int v2; // eax@10
+  GUIWindow v3; // [sp+8h] [bp-54h]@3
+
+  pRenderer->DrawTextureIndexed(
+    8u,
+    8u,
+    (Texture *)(uTextureID_507C10 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C10] : 0));
+  if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
+  {
+    pRenderer->DrawTextureIndexed(
+      17 * uGammaPos + 42,
+      162u,
+      (Texture *)(pTextureIDs_GammaPositions[uGammaPos] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_GammaPositions[uGammaPos]] : 0));
+    pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
+    v3.uFrameX = 22;
+    v0 = pGlobalTXT_LocalizationStrings[226];
+    v3.uFrameY = 190;
+    v3.uFrameWidth = 211;
+    v3.uFrameHeight = 79;
+    v3.uFrameZ = 232;
+    v3.uFrameW = 268;
+    v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    v3.DrawTitleText(pFontSmallnum, 0, 0, v1, v0, 3u);
+  }
+  if ( !pRenderer->pRenderD3D )
+  {
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x119u,
+      (Texture *)(uTextureID_507C50 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C50] : 0));
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x12Fu,
+      (Texture *)(uTextureID_507C54 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C54] : 0));
+    v2 = uTextureID_507C58;
+    goto LABEL_12;
+  }
+  if ( pGame->uFlags2 & 0x20 )
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x119u,
+      (Texture *)(uTextureID_507C14 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C14] : 0));
+  if ( pRenderer->bUseColoredLights )
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x12Fu,
+      (Texture *)(uTextureID_507C18 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C18] : 0));
+  if ( pRenderer->bTinting )
+  {
+    v2 = uTextureID_507C1C;
+LABEL_12:
+    pRenderer->DrawTextureIndexed(0x14u, 0x145u, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
+  }
+}
+
+
+
+//----- (00414F82) --------------------------------------------------------
+void __cdecl sub_414F82_DrawGameOptions()
+{
+  signed int v0; // eax@1
+
+  pRenderer->DrawTextureIndexed(
+    8u,
+    8u,
+    (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0));
+  pRenderer->DrawTextureIndexed(
+    8u,
+    0x84u,
+    (Texture *)(uTextureID_507C60 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C60] : 0));
+  v0 = 0;
+  if ( uTurnSpeed == 128 )
+  {
+    v0 = 2;
+  }
+  else
+  {
+    if ( uTurnSpeed == 64 )
+      v0 = 1;
+  }
+  pRenderer->DrawTextureIndexed(
+    dword_4E2910[v0],
+    0x10Eu,
+    (Texture *)(uTextureID_507C64[v0] != -1 ? &pIcons_LOD->pTextures[uTextureID_507C64[v0]] : 0));
+  if ( bWalkSound )
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x12Fu,
+      (Texture *)(uTextureID_507CB4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB4] : 0));
+  if ( bShowDamage )
+    pRenderer->DrawTextureIndexed(
+      0x80u,
+      0x12Fu,
+      (Texture *)(uTextureID_507CB8 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB8] : 0));
+  if ( bFlipOnExit )
+    pRenderer->DrawTextureIndexed(
+      0x80u,
+      0x145u,
+      (Texture *)(uTextureID_507C84 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C84] : 0));
+  if ( bAlwaysRun )
+    pRenderer->DrawTextureIndexed(
+      0x14u,
+      0x145u,
+      (Texture *)(uTextureID_507CB0 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB0] : 0));
+  pRenderer->DrawTextureIndexed(
+    17 * (char)uSoundVolumeMultiplier + 265,
+    0xA2u,
+    (Texture *)(pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier]] : 0));
+  pRenderer->DrawTextureIndexed(
+    17 * (char)uMusicVolimeMultiplier + 265,
+    0xD8u,
+    (Texture *)(pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier]] : 0));
+  pRenderer->DrawTextureIndexed(
+    17 * (char)uVoicesVolumeMultiplier + 265,
+    0x10Eu,
+    (Texture *)(pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier]] : 0));
+}
+
+
+
+
+//----- (004151D9) --------------------------------------------------------
+void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
+{
+  unsigned int v4; // ebx@1
+  Texture *v5; // edi@1
+  signed int uTileWidth; // ecx@1
+  int v7; // eax@5
+  int v8; // ecx@10
+  unsigned int v9; // ebx@14
+  int v10; // [sp+10h] [bp-28h]@5
+  signed int uTileHeight; // [sp+18h] [bp-20h]@1
+  int v12; // [sp+1Ch] [bp-1Ch]@7
+  int v13; // [sp+20h] [bp-18h]@1
+  int a5; // [sp+24h] [bp-14h]@5
+  unsigned int a5a; // [sp+24h] [bp-14h]@11
+  unsigned int a4; // [sp+28h] [bp-10h]@1
+  int uNumXTiles; // [sp+2Ch] [bp-Ch]@3
+  unsigned int uNumXTilesa; // [sp+2Ch] [bp-Ch]@6
+  unsigned int uNumXTilesb; // [sp+2Ch] [bp-Ch]@11
+  unsigned int a2a; // [sp+30h] [bp-8h]@1
+  unsigned int v21; // [sp+34h] [bp-4h]@5
+  unsigned int v22; // [sp+34h] [bp-4h]@11
+
+  v4 = uY;
+  a2a = uX;
+  a4 = uX + uWidth;
+  pRenderer->Clip(uX, v4, uX + uWidth, v4 + uHeight);
+  v5 = (Texture *)(uTextureID_Parchment != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Parchment] : 0);
+  uTileWidth = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
+  v13 = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
+  uTileHeight = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26);
+  if ( (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24)
+    && (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26) )
+  {
+    uNumXTiles = (signed int)uWidth / uTileWidth;
+    if ( (signed int)uWidth % uTileWidth )
+      ++uNumXTiles;
+    a5 = 0;
+    v21 = v4;
+    v7 = uNumXTiles + 1;
+    v10 = uNumXTiles + 1;
+    do
+    {
+      uNumXTilesa = a2a - v13;
+      if ( v7 > 0 )
+      {
+        v12 = v7;
+        do
+        {
+          uNumXTilesa += v13;
+          pRenderer->DrawTextureIndexed(uNumXTilesa, v21, v5);
+          --v12;
+        }
+        while ( v12 );
+        v7 = v10;
+      }
+      v21 += uTileHeight;
+      v8 = a5++;
+    }
+    while ( v8 < (signed int)uHeight / uTileHeight );
+    a5a = v4 + uHeight - 32;
+    pRenderer->DrawTextureTransparent(
+      a2a,
+      v4,
+      (Texture *)(uTextureID_5076AC != -1 ? &pIcons_LOD->pTextures[uTextureID_5076AC] : 0));
+    pRenderer->DrawTextureTransparent(
+      a2a,
+      a5a,
+      (Texture *)(uTextureID_5076B4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076B4] : 0));
+    pRenderer->DrawTextureTransparent(
+      a4 - 32,
+      v4,
+      (Texture *)(uTextureID_5076A8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A8] : 0));
+    pRenderer->DrawTextureTransparent(
+      a4 - 32,
+      a5a,
+      (Texture *)(uTextureID_5076B0 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_5076B0] : 0));
+    uNumXTilesb = a2a + 32;
+    v22 = v4 + uHeight - 10;
+    if ( (signed int)uWidth > 64 )
+    {
+      pRenderer->Clip(a2a + 32, v4, a4 - 32, v4 + uHeight);
+      pRenderer->DrawTextureTransparent(
+        uNumXTilesb,
+        v4,
+        (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
+      pRenderer->DrawTextureTransparent(
+        uNumXTilesb,
+        v22,
+        (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+      if ( (signed int)uWidth > 512 )
+      {
+        pRenderer->DrawTextureTransparent(
+          a2a + 544,
+          v4,
+          (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
+        pRenderer->DrawTextureTransparent(
+          a2a + 544,
+          v22,
+          (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+      }
+    }
+    v9 = v4 + 32;
+    if ( (signed int)uHeight > 64 )
+    {
+      pRenderer->Clip(a2a, v9, a4, a5a);
+      pRenderer->DrawTextureTransparent(
+        a2a,
+        v9,
+        (Texture *)(uTextureID_5076A0 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A0] : 0));
+      pRenderer->DrawTextureTransparent(
+        a4 - 10,
+        v9,
+        (Texture *)(uTextureID_50769C != -1 ? &pIcons_LOD->pTextures[uTextureID_50769C] : 0));
+    }
+    pRenderer->ResetClip();
+  }
+}
+
+
+//----- (00415485) --------------------------------------------------------
+char *__cdecl DrawCopyrightWindow()
+{
+  GUIWindow Dst; // [sp+8h] [bp-54h]@1
+
+  memset(&Dst, 0, 0x54u);
+  Dst.uFrameWidth = 624;
+  Dst.uFrameHeight = 256;
+  Dst.uFrameX = 8;
+  Dst.uFrameY = 30;                             // c 1999 The 3DO Company.
+  Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
+                   + 2 * LOBYTE(pFontSmallnum->uFontHeight)
+                   + 24;
+  Dst.uFrameY = 470 - Dst.uFrameHeight;
+  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+  Dst.uFrameW = 469;
+  Dst.DrawMessageBox(0);
+  Dst.uFrameWidth -= 24;
+  Dst.uFrameX += 12;
+  Dst.uFrameY += 12;
+  Dst.uFrameHeight -= 12;
+  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+  Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
+  return Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[157], 3u);
+}
+
+
+
+
+//----- (004156F0) --------------------------------------------------------
+void __cdecl GUI_UpdateWindows()
+{
+  GUIWindow *pWindow; // esi@4
+  unsigned int pWindowType; // eax@4
+  int v2; // eax@10
+  int v3; // eax@11
+  int v4; // eax@12
+  int v5; // eax@20
+  int v6; // eax@21
+  int v7; // eax@29
+  int v8; // eax@30
+  int v9; // eax@31
+  void *v10; // eax@41
+  int v11; // ecx@42
+  int v12; // eax@48
+  int v13; // eax@49
+  int v14; // eax@57
+  int v15; // eax@58
+  int v16; // eax@59
+  int v17; // eax@60
+  int v18; // eax@61
+  int v19; // eax@62
+  void *v20; // ebp@66
+  char *pHint; // edx@66
+  GUIButton *pButtonPtr_1C; // ebp@79
+  char *v23; // edx@80
+  char v24; // zf@81
+  //unsigned int v25; // eax@91
+  int v26; // eax@98
+  unsigned int v27; // ebp@106
+  GUIWindow *pGUIWindow2; // ecx@109
+  unsigned int v29; // eax@111
+  GUIFont *pGUIFont; // ST1C_4@115
+  int v31; // eax@115
+  void *v32; // ebp@118
+  int v33; // eax@119
+  int v34; // eax@120
+  int v35; // eax@121
+  int v36; // eax@122
+  int v37; // eax@123
+  int v38; // eax@124
+  int v39; // eax@129
+  //char *v40; // edx@138
+  unsigned int pNumMessages; // eax@142
+  GUIButton *pGUIButton; // ebp@146
+  //char *v43; // edx@146
+  unsigned int pX; // [sp-1Ch] [bp-124h]@17
+  unsigned int pY; // [sp-18h] [bp-120h]@17
+  Texture *pTexture; // [sp-14h] [bp-11Ch]@17
+  Texture *pTexture2; // [sp-14h] [bp-11Ch]@86
+  int i; // [sp+0h] [bp-108h]@3
+  ItemGen pItemGen; // [sp+4h] [bp-104h]@98
+  GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133
+  ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129
+
+  if (GetCurrentMenuID() != MENU_CREATEPARTY)
+    sub_41CD4F(34);
+  for ( i = 1; i <= uNumVisibleWindows; ++i )
+  {
+    //v0 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[i]];
+    pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
+    pWindowType = pWindow->eWindowType;
+    switch (pWindow->eWindowType)
+    {
+      case WINDOW_MainMenu_Load:
+        GameUI_MainMenu_DrawLoad();
+        continue;
+      case WINDOW_5E: // window that initiates savegame loading
+      {
+        if (pWindow->Hint != (char *)1)
+          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+        auto pGUIButton3 = (GUIButton *)pWindow->ptr_1C;
+        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton3->pTextures[0]);
+        pHint = pWindow->Hint;
+        viewparams->bRedrawGameUI = 1;
+        if ( pHint && pHint != (char *)1 )
+          pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0);
+        pWindow->Release();
+        if (pCurrentScreen == 11)//îêíî ñîõðàíåíèÿ èãðû
+          pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0);
+        else
+          pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
+      }
+      continue;
+    }
+    if ( (signed int)pWindowType > 70 )
+    {
+      if ( (signed int)pWindowType > 95 )
+      {
+        v33 = pWindowType - 96;
+        if ( !v33 )
+        {
+          if ( pWindow->Hint != (char *)1 )
+            pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+          pGUIButton = (GUIButton *)pWindow->ptr_1C;
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]);
+          pHint = pWindow->Hint;
+          viewparams->bRedrawGameUI = 1;
+          if ( pHint && pHint != (char *)1 )
+            pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
+          pWindow->Release();
+          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+            continue;
+          pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+//LABEL_151:
+          pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
+//LABEL_152:
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
+        }
+        v34 = v33 - 1;
+        if ( v34 )
+        {
+          v35 = v34 - 1;
+          if ( v35 )
+          {
+            v36 = v35 - 1;
+            if ( v36 )
+            {
+              v37 = v36 - 4;
+              if ( v37 )
+              {
+                v38 = v37 - 2;
+                if ( v38 )
+                {
+                  if ( v38 == 1 )
+                    GameMenuUI_DrawVideoOptions();
+                }
+                else
+                {
+                  GameMenuUI_DrawKeyBindings();
+                }
+              }
+              else
+              {
+                pWindow->DrawMessageBox(0);
+                pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
+                pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+                if ( !pKeyActionMap->field_204 )
+                {
+                  ItemGen2.Reset();
+                  pWindow->Release();
+                  pEventTimer->Resume();
+                  pCurrentScreen = 0;
+                  viewparams->bRedrawGameUI = 1;
+                  v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+                  if ( v39 > 0 )
+                  {
+                    if ( v39 < 800 )
+                      SpawnActor(v39);
+                  }
+                }
+              }
+              continue;
+            }
+            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);
+            pY = pWindow->uFrameY;
+            pX = pWindow->uFrameX;
+//LABEL_18:
+            pRenderer->DrawTextureIndexed(pX, pY, pTexture);
+//LABEL_114:
+            viewparams->bRedrawGameUI = 1;
+            continue;
+          }
+          memset(&GUIButton2, 0, 0xBCu);
+          GUIButton2.uZ = 197;
+          GUIButton2.uW = 197;
+          GUIButton2.uX = 27;
+          GUIButton2.uY = 161;
+          GUIButton2.uWidth = 171;
+          GUIButton2.uHeight = 37;
+          GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
+          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
+          viewparams->bRedrawGameUI = 1;
+          GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Îòäûõ è ëå÷åíèå 8 ÷àñîâ
+          GUIButton2.pParent = 0;
+          //goto LABEL_134;
+		  pGUIWindow2 = pWindow;
+          //goto LABEL_110;
+		  pGUIWindow2->Release();
+          continue;
+        }
+        if ( pWindow->Hint != (char *)1 )
+          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+        v32 = pWindow->ptr_1C;
+        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
+        goto LABEL_138;
+      }
+      if ( pWindowType == 95 )
+      {
+        if ( pWindow->Hint != (char *)1 )
+          pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+        v32 = pWindow->ptr_1C;
+        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15));
+LABEL_138:
+        pHint = pWindow->Hint;
+        viewparams->bRedrawGameUI = 1;
+        if ( pHint && pHint != (char *)1 )
+          ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
+        pWindow->Release();
+LABEL_142:
+        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+          //goto LABEL_151;
+		{
+		  pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+          ++pMessageQueue_50CBD0->uNumMessages;
+          continue;
+		}
+        continue;
+      }
+      v14 = pWindowType - 80;
+      if ( v14 )
+      {
+        v15 = v14 - 9;
+        if ( !v15 )
+        {
+          pWindow->DrawMessageBox(0);
+          pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
+          pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+          if ( !pKeyActionMap->field_204 )
+          {
+            pItemGen.Reset();
+            pWindow->Release();
+            pEventTimer->Resume();
+            pCurrentScreen = 0;
+            viewparams->bRedrawGameUI = 1;
+            v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+            if ( v26 > 0 )
+            {
+              if ( v26 < 800 )
+              {
+                pItemGen.uAttributes |= 1u;
+                pItemGen.uItemID = v26;
+                if ( pItemsTable->pItems[v26].uEquipType == 12 )
+                {
+                  pItemGen.uNumCharges = rand() % 6 + pItemsTable->pItems[pItemGen.uItemID].uDamageMod + 1;
+                  pItemGen.uMaxCharges = LOBYTE(pItemGen.uNumCharges);
+                }
+                else
+                {
+                  if ( v26 >= 221 && v26 < 271 )
+                    pItemGen._bonus_type = rand() % 10 + 1;
+                }
+                pItemsTable->SetSpecialBonus(&pItemGen);
+                pParty->SetHoldingItem(&pItemGen);
+              }
+            }
+          }
+          continue;
+        }
+        v16 = v15 - 1;
+        if ( !v16 )
+        {
+          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 ( (signed int)pButtonPtr_1C->uX <= 640 )
+            {
+              //v25 = pButtonPtr_1C->uY;
+              if ( (pButtonPtr_1C->uY /*& 0x80000000u*/) == 0 )
+              {
+                if ( (signed int)pButtonPtr_1C->uY <= 480 )
+                {
+                  pTexture2 = pButtonPtr_1C->pTextures[0];
+                  goto LABEL_94;
+                }
+              }
+            }
+          }
+          v23 = pWindow->Hint;
+          viewparams->bRedrawGameUI = 1;
+          if ( v23 )
+          {
+            v24 = v23 == (char *)1;
+            goto LABEL_82;
+          }
+//LABEL_134:
+          pGUIWindow2 = pWindow;
+          //goto LABEL_110;
+		  pGUIWindow2->Release();
+          continue;
+        }
+        v17 = v16 - 1;
+        if ( !v17 )
+        {
+          if ( pWindow->Hint != (char *)1 )
+            pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+          pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
+          pTexture2 = pButtonPtr_1C->pTextures[1];
+LABEL_94:
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
+LABEL_80:
+          v23 = pWindow->Hint;
+          viewparams->bRedrawGameUI = 1;
+          if ( v23 )
+          {
+            v24 = v23 == (char *)1;
+LABEL_82:
+            if ( !v24 )
+              pButtonPtr_1C->DrawLabel(v23, pFontCreate, 0, 0);
+          }
+          //goto LABEL_134;
+		  pGUIWindow2 = pWindow;
+          //goto LABEL_110;
+		  pGUIWindow2->Release();
+          continue;
+        }
+        v18 = v17 - 1;
+        if ( !v18 )
+        {
+          if ( pWindow->Hint != (char *)1 )
+            pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+          pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
+          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButtonPtr_1C->pTextures[0]);
+          goto LABEL_80;
+        }
+        v19 = v18 - 1;
+        if ( !v19 )
+        {
+          if ( pWindow->Hint != (char *)1 )
+            pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
+          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16));
+          viewparams->bRedrawGameUI = 1;
+          //goto LABEL_134;
+		  pGUIWindow2 = pWindow;
+          //goto LABEL_110;
+		  pGUIWindow2->Release();
+          continue;
+        }
+      }
+      else
+      {
+        v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+        if ( ptr_507BD0->field_40 == 1 )
+        {
+          ptr_507BD0->DrawMessageBox(0);
+          ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+          pGUIFont = pFontCreate;
+          v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+          ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pGUIFont);
+          continue;
+        }
+        if ( ptr_507BD0->field_40 == 2 )
+        {
+          v29 = pMessageQueue_50CBD0->uNumMessages;
+          pWindow->field_40 = 0;
+          if ( (signed int)v29 < 40 )
+          {
+            pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
+            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
+            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+            ++pMessageQueue_50CBD0->uNumMessages;
+          }
+          pEventTimer->Resume();
+          ptr_507BD0->Release();
+          pCurrentScreen = 0;
+          //goto LABEL_114;
+		  viewparams->bRedrawGameUI = 1;
+          continue;
+        }
+        if ( ptr_507BD0->field_40 == 3 )
+        {
+          pWindow->field_40 = 0;
+          pEventTimer->Resume();
+          pGUIWindow2 = ptr_507BD0;
+//LABEL_110:
+          pGUIWindow2->Release();
+          continue;
+        }
+      }
+    }
+    else
+    {
+      if ( pWindowType == 70 )
+      {
+        sub_41420D_press_esc();
+        continue;
+      }
+      if ( (signed int)pWindowType > 18 )
+      {
+        if ( (signed int)pWindowType > 25 )
+        {
+          v12 = pWindowType - 26;
+          if ( v12 )
+          {
+            v13 = v12 - 4;
+            if ( v13 )
+            {
+              if ( v13 == 1 )
+              {
+                pRenderer->ClearZBuffer(0, 479);
+                draw_leather();
+                CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+                CharacterUI_DrawPaperdoll(uActiveCharacter);
+                pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
+                  (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
+              }
+            }
+            else
+            {
+              sub_467FB6();
+            }
+          }
+          else
+          {
+            TransitionUI_Draw();
+          }
+          continue;
+        }
+        if ( pWindowType != 25 )
+        {
+          v7 = pWindowType - 19;
+          if ( v7 )
+          {
+            v8 = v7 - 1;
+            if ( v8 )
+            {
+              v9 = v8 - 3;
+              if ( v9 )
+              {
+                //if ( v9 == 1 )
+                //  sub_4606F7();
+              }
+              else
+              {
+                sub_4606FE();
+              }
+            }
+            else
+            {
+              if ( pCurrentScreen == 10 )
+              {
+                Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
+              }
+              else
+              {
+                if ( pCurrentScreen == 15 )
+                {
+                  pRenderer->ClearZBuffer(0, 479);
+                  draw_leather();
+                  CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+                  pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
+                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+                }
+              }
+            }
+          }
+          else
+          {
+            DrawBranchlessDialogueUI();
+          }
+          continue;
+        }
+        pWindowList[pVisibleWindowsIdxs[i] - 1]._4B3157();
+        if ( !ptr_507BC0 )
+          continue;
+        v10 = ptr_507BC0->ptr_1C;
+        if ( (signed int)v10 >= 53 )
+          continue;
+        v11 = pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1];
+        if ( !__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * (_DWORD)v10])
+          || v11 < SHIDWORD(pParty->uTimePlayed)
+          || v11 <= SHIDWORD(pParty->uTimePlayed)
+          && (unsigned int)pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] <= LODWORD(pParty->uTimePlayed) )
+        {
+          if ( (signed int)v10 < 53 )
+          {
+            pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] = 0;
+            pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1] = 0;
+          }
+          continue;
+        }
+        goto LABEL_142;
+      }
+      if ( pWindowType == 18 )
+      {
+        sub_412B58();
+      }
+      else
+      {
+        if ( (signed int)pWindowType > 10 )
+        {
+          v5 = pWindowType - 12;
+          if ( v5 )
+          {
+            v6 = v5 - 4;
+            if ( v6 )
+            {
+              if ( v6 == 1 )
+                TravelUI_Draw();
+            }
+            else
+            {
+              RestUI_Draw();
+            }
+          }
+          else
+          {
+            QuickRefDraw();
+          }
+          continue;
+        }
+        if ( pWindowType != 10 )
+        {
+          v2 = pWindowType - 3;
+          if ( v2 )
+          {
+            v3 = v2 - 1;
+            if ( v3 )
+            {
+              v4 = v3 - 2;
+              if ( v4 )
+              {
+                if ( v4 == 3 )
+                  DrawSpellbook((unsigned int)pWindow->ptr_1C);
+              }
+              else
+              {
+                sub_414F82_DrawGameOptions();
+              }
+            }
+            else
+            {
+              CharacterUI_CharacterScreen_Draw(uActiveCharacter);
+            }
+            continue;
+          }
+          pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);
+          pY = pViewport->uViewportY;
+          pX = pViewport->uViewportX;
+          //goto LABEL_18;
+		  pRenderer->DrawTextureIndexed(pX, pY, pTexture);
+          viewparams->bRedrawGameUI = 1;
+          continue;
+        }
+        DrawDialogueUI();
+      }
+    }
+  }
+  if ( GetCurrentMenuID() == -1 )
+    GameUI_DrawFoodAndGold();
+  if ( sub_4637E0_is_there_popup_onscreen() )
+    sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
+}
+
+//----- (00416196) --------------------------------------------------------
+void __cdecl identify_item()
+{
+  Player *v0; // esi@2
+  POINT *v1; // edi@2
+  signed int v2; // ecx@5
+  signed int v3; // eax@5
+  int v4; // eax@5
+  char v5; // sf@5
+  int v6; // eax@5
+  int v7; // eax@7
+  unsigned __int16 v8; // ax@10
+  int v9; // edi@10
+  int v10; // eax@10
+  int v11; // edx@13
+  LONG v12; // edx@23
+  signed int v13; // edx@23
+  int v14; // edx@25
+  unsigned int v15; // edi@25
+  signed int v16; // edx@27
+  int v17; // eax@54
+  unsigned int v18; // edx@57
+  int v19; // eax@65
+  int v20; // edi@67
+  int v21; // eax@72
+  int v22; // ecx@74
+  int v23; // edx@78
+  int v24; // eax@79
+  int v25; // eax@80
+  int v26; // eax@84
+  ItemGen *v27; // esi@98
+  unsigned int v28; // eax@98
+  ItemGen *v29; // edi@98
+  unsigned int v30; // ecx@103
+  double v31; // st7@112
+  unsigned __int64 v32; // qax@113
+  unsigned int v33; // ecx@117
+  int v34; // eax@126
+  unsigned int v35; // ecx@127
+  double v36; // st7@132
+  signed __int64 v37; // qax@135
+  unsigned int v38; // eax@138
+  Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
+  int *v40; // [sp-Ch] [bp-9Ch]@83
+  int *v41; // [sp-8h] [bp-98h]@83
+  int *v42; // [sp-4h] [bp-94h]@83
+  GUIWindow v43; // [sp+Ch] [bp-84h]@137
+  unsigned int pY; // [sp+60h] [bp-30h]@2
+  int v45; // [sp+64h] [bp-2Ch]@10
+  unsigned int pX; // [sp+68h] [bp-28h]@2
+  int v47; // [sp+6Ch] [bp-24h]@25
+  POINT y; // [sp+70h] [bp-20h]@2
+  POINT a2; // [sp+78h] [bp-18h]@2
+  Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
+  unsigned int v51; // [sp+8Ch] [bp-4h]@23
+
+  if ( dword_50CDCC )
+    return;
+  v0 = pPlayers[uActiveCharacter];
+  v1 = pMouse->GetCursorPos(&a2);
+  pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF;
+  pMouse->GetClickPos(&pX, &pY);
+  if ( !pOut.z )
+  {
+    if ( (signed int)pX <= 13
+      || (signed int)pX >= 462
+      || (v2 = pX - 14,
+          v3 = pY - 17,
+          pX = v2,
+          pY = v3,
+          v4 = 14 * (v3 >> 5),
+          v2 >>= 5,
+          v5 = v2 + v4 < 0,
+          v6 = v2 + v4,
+          pOut.z = v6,
+          v5)
+      || v6 > 126
+      || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 )
+      return;
+    pOut.z = v7;
+  }
+  if ( !v0->CanAct() )
+  {
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]);
+    v43.Hint = pTmpBuf;
+    v43.uFrameWidth = 384;
+    v43.uFrameHeight = 180;
+    v43.uFrameY = 40;
+    if ( pMouse->GetCursorPos(&a2)->x <= 320 )
+      v38 = pMouse->GetCursorPos(&a2)->x + 30;
+    else
+      v38 = pMouse->GetCursorPos(&a2)->x - 414;
+    v43.uFrameX = v38;
+    v43.DrawMessageBox(0);
+    return;
+  }
+  --pOut.z;
+  LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
+  v9 = v8 & 0x3F;
+  v45 = v8 & 0x3F;
+  pOut.y = SkillToMastery(v8);
+  v10 = pOut.z;
+  if ( pParty->pPickedItem.uItemID == 220 )
+  {
+LABEL_116:
+    GameUI_DrawItemInfo(&v0->pInventoryItems[v10]);
+    return;
+  }
+  if ( (signed int)pParty->pPickedItem.uItemID < 200
+    || (signed int)pParty->pPickedItem.uItemID > 219
+    || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) )
+  {
+    if ( (signed int)pParty->pPickedItem.uItemID < 221
+      || (signed int)pParty->pPickedItem.uItemID > 271
+      || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221)
+      || v13 > 271 )
+    {
+      if ( pParty->pPickedItem.uItemID != 236
+        && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250)
+        && pParty->pPickedItem.uItemID != 263
+        && pParty->pPickedItem.uItemID != 233 )
+        goto LABEL_116;
+      v27 = &v0->pInventoryItems[pOut.z];
+      v28 = v27->uItemID;
+      v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
+      v29 = (ItemGen *)(1800 * pParty->pPickedItem._bonus_type);
+      if ( pParty->pPickedItem.uItemID != 233 )
+      {
+        if ( pParty->pPickedItem.uItemID == 236 )
+        {
+          v35 = v27->uAttributes;
+          if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
+            goto LABEL_92;
+          LOWORD(v35) = v35 | 0x210;
+          v27->uAttributes = v35;
+        }
+        else
+        {
+          if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
+            goto LABEL_92;
+          if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
+          {
+            v27->UpdateTempBonus(pParty->uTimePlayed);
+            v33 = v27->uItemID;
+            if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65
+              || (pOut.y = v27->uAttributes, pOut.y & 2)
+              || v27->uAdditionalValue
+              || v27->_bonus_type
+              || v51 && v51 != 1 && v51 != 2
+              || (signed int)v33 >= 500 )
+              goto LABEL_92;
+            v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
+            a2.y = (int)v29 << 7;
+            v31 = (double)(signed int)((int)v29 << 7);
+            v27->uAdditionalValue = v34;
+          }
+          else
+          {
+            if ( pParty->pPickedItem.uItemID != 263
+              || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64)
+              && (signed int)v30 <= 65
+              || (pOut.y = v27->uAttributes, pOut.y & 2)
+              || v27->uAdditionalValue
+              || v27->_bonus_type
+              || v51 && v51 != 1 && v51 != 2
+              || (signed int)v30 >= 500 )
+              goto LABEL_92;
+            a2.y = (int)v29 << 7;
+            v27->uAdditionalValue = 40;
+            v31 = (double)a2.y;
+          }
+          v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
+          LODWORD(v27->uExpireTime) = v32;
+          LODWORD(v32) = pOut.y;
+          LOBYTE(v32) = LOBYTE(pOut.y) | 0x18;
+          HIDWORD(v27->uExpireTime) = HIDWORD(v32);
+          v27->uAttributes = v32;
+        }
+        dword_50C9A8 = 256;
+        goto LABEL_92;
+      }
+      v36 = (70.0 - (double)pParty->pPickedItem._bonus_type) * 0.01;
+      if ( v36 < 0.0 )
+        v36 = 0.0;
+      if ( v51 != 12 )
+      {
+        pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+        return;
+      }
+      a2.y = v27->uMaxCharges;
+      v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
+      v27->uMaxCharges = v37;
+      v27->uNumCharges = (unsigned __int8)v37;
+      goto LABEL_92;
+    }
+    v14 = v13 - 222;
+    v15 = pParty->pPickedItem.uItemID - 222;
+    v47 = v14;
+    y.y = 0;
+    if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 )
+    {
+      v16 = 5;
+    }
+    else
+    {
+      v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388];
+      v10 = pOut.z;
+    }
+    v51 = v16;
+    if ( v45 )
+    {
+      if ( v16 < 225 || v16 > 227 )
+      {
+        if ( v16 < 228 || v16 > 239 )
+        {
+          if ( v16 < 240 || v16 > 261 )
+          {
+            if ( v16 >= 262 && pOut.y != 4 )
+            {
+LABEL_53:
+              v51 = 4;
+              goto LABEL_54;
+            }
+          }
+          else
+          {
+            if ( pOut.y <= 2 )
+            {
+LABEL_38:
+              v51 = 3;
+              goto LABEL_54;
+            }
+          }
+        }
+        else
+        {
+          if ( pOut.y == 1 )
+          {
+LABEL_35:
+            v51 = 2;
+            goto LABEL_54;
+          }
+        }
+      }
+    }
+    else
+    {
+      if ( v16 >= 225 && v16 <= 227 )
+      {
+        v51 = 1;
+        goto LABEL_54;
+      }
+      if ( v16 >= 228 && v16 <= 239 )
+        goto LABEL_35;
+      if ( v16 >= 240 && v16 <= 261 )
+        goto LABEL_38;
+      if ( v16 >= 262 )
+        goto LABEL_53;
+    }
+LABEL_54:
+    pOut.y = 0;
+    pOut.x = v10 + 1;
+    v17 = (int)v0->pInventoryIndices;
+    while ( *(int *)v17 != pOut.x )
+    {
+      ++pOut.y;
+      v17 += 4;
+      if ( pOut.y >= 126 )
+      {
+        v18 = y.y;
+        goto LABEL_59;
+      }
+    }
+    v18 = pOut.y;
+LABEL_59:
+    if ( !v51 )
+    {
+LABEL_115:
+      v10 = pOut.z;
+      goto LABEL_116;
+    }
+    if ( v51 == 1 )
+    {
+      v0->RemoveItemAtInventoryIndex(v18);
+      v26 = rand();
+      v0->ReceiveDamage(v26 % 11 + 10, 0);
+      pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
+      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+      {
+        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;
+      }
+      v42 = (int *)&a2.y;
+      v41 = (int *)&y.y;
+      v40 = (int *)&pOut;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    else
+    {
+      if ( v51 == 2 )
+      {
+        v0->RemoveItemAtInventoryIndex(v18);
+        v25 = rand();
+        v0->ReceiveDamage(v25 % 71 + 30, 0);
+        v23 = 1;
+      }
+      else
+      {
+        if ( v51 == 3 )
+        {
+          v0->RemoveItemAtInventoryIndex(v18);
+          v24 = rand();
+          v0->ReceiveDamage(v24 % 201 + 50, 0);
+          v23 = 5;
+        }
+        else
+        {
+          if ( v51 != 4 )
+          {
+            if ( v51 != 5 )
+            {
+              v19 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
+              if ( v19 )
+                *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
+              v20 = v47 + 50 * v15;
+              v0->pInventoryItems[pOut.z].uItemID = v51;
+              v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type
+                                                       + v0->pInventoryItems[pOut.z]._bonus_type)
+                                                      / 2;
+              v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->field_10168[2 * v20 + 388]);
+LABEL_74:
+              v22 = (int)((char *)v0 + 36 * pOut.z);
+              if ( !BYTE2(pItemsTable->pItems[*(int *)(v22 + 532) + 1].uItemID) )
+                *(int *)(v22 + 552) |= 1u;
+              if ( !dword_4E455C )
+                goto LABEL_92;
+              v0->PlaySound(16, 0);
+              goto LABEL_91;
+            }
+            if ( v45 )
+            {
+              if ( *(int *)(a2.y + 532) == 221 )
+                *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
+              else
+                *(int *)(a2.y + 536) = pParty->pPickedItem._bonus_type;
+              v21 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
+              if ( v21 )
+                *(int *)&v0->field_1F5[36 * v21 + 15] = 1;
+              goto LABEL_74;
+            }
+            goto LABEL_115;
+          }
+          v0->RemoveItemAtInventoryIndex(v18);
+          v0->SetCondition(0x10u, 0);
+          v23 = 0;
+        }
+      }
+      v0->_4160CA(v23);
+      pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
+      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+      {
+        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;
+      }
+      v42 = (int *)&a2.y;
+      v41 = (int *)&y.y;
+      v40 = (int *)&pOut;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
+    Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
+    sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0);
+    if ( dword_4E455C )
+    {
+      if ( v0->CanAct() )
+        v0->PlaySound(17, 0);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
+LABEL_91:
+      dword_4E455C = 0;
+    }
+LABEL_92:
+    pMouse->RemoveHoldingItem();
+    dword_50CDCC = 1;
+    return;
+  }
+  *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
+  switch ( pParty->pPickedItem.uItemID )
+  {
+    case 0xC8u:
+    case 0xC9u:
+    case 0xCAu:
+    case 0xCBu:
+    case 0xCCu:
+      v0->pInventoryItems[pOut.z].uItemID = 222;
+      break;
+    case 0xCDu:
+    case 0xCEu:
+    case 0xCFu:
+    case 0xD0u:
+    case 0xD1u:
+      v0->pInventoryItems[pOut.z].uItemID = 223;
+      break;
+    case 0xD2u:
+    case 0xD3u:
+    case 0xD4u:
+    case 0xD5u:
+    case 0xD6u:
+      v0->pInventoryItems[pOut.z].uItemID = 224;
+      break;
+    case 0xD7u:
+    case 0xD8u:
+    case 0xD9u:
+    case 0xDAu:
+    case 0xDBu:
+      v0->pInventoryItems[pOut.z].uItemID = 221;
+      break;
+    default:
+      break;
+  }
+  pMouse->RemoveHoldingItem();
+  dword_50CDCC = 1;
+  if ( dword_4E455C )
+  {
+    v0->PlaySound(16, 0);
+    dword_4E455C = 0;
+  }
+}
+
+
+//----- (00416B01) --------------------------------------------------------
+void __thiscall sub_416B01(void *_this)
+{
+  int v1; // edi@2
+  int v2; // ecx@2
+  NPCData *v3; // eax@2
+  NPCData *v4; // esi@7
+  NPCData *v5; // eax@16
+  NPCData *v6; // esi@16
+  const CHAR *v7; // eax@18
+  unsigned int v8; // eax@25
+  unsigned int v9; // eax@25
+  const char *v10; // ST14_4@26
+  char *v11; // esi@26
+  const char *v12; // ST18_4@27
+  unsigned __int16 v13; // ax@28
+  char *v14; // eax@28
+  GUIWindow a1; // [sp+Ch] [bp-60h]@23
+  int a2; // [sp+60h] [bp-Ch]@16
+  void *v17; // [sp+64h] [bp-8h]@1
+  LPCSTR lpsz; // [sp+68h] [bp-4h]@6
+
+  v17 = _this;
+  if ( bNoNPCHiring != 1 )
+  {
+    v1 = 0;
+    v2 = 0;
+    v3 = pParty->pHirelings;
+    do
+    {
+      if ( v3->pName )
+        pTmpBuf[v1++] = v2;
+      ++v3;
+      ++v2;
+    }
+    while ( (signed int)v3 < (signed int)&pParty->pPickedItem );
+    lpsz = 0;
+    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+    {
+      v4 = pNPCStats->pNewNPCData;
+      do
+      {
+        if ( v4->uFlags & 0x80
+          && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName))
+          && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) )
+          pTmpBuf[v1++] = (char)lpsz + 2;
+        ++lpsz;
+        ++v4;
+      }
+      while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );
+    }
+    if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
+    {
+      uDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
+      v5 = GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&a2);
+      v6 = v5;
+      if ( v5 )
+      {
+        if ( a2 == 57 )
+          v7 = pNPCTopics[512].pText;
+        else
+          v7 = (const CHAR *)*(&pNPCStats->field_13A5C + 5 * v5->uProfession);
+        lpsz = v7;
+        if ( !v7 )
+        {
+          lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
+          if ( !lpsz )
+            lpsz = "";
+        }
+        a1.Hint = 0;
+        a1.uFrameX = 38;
+        a1.uFrameY = 60;
+        a1.uFrameWidth = 276;
+        a1.uFrameZ = 313;
+        a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0)
+                        + 2 * LOBYTE(pFontArrus->uFontHeight)
+                        + 24;
+        if ( (signed int)a1.uFrameHeight < 130 )
+          a1.uFrameHeight = 130;
+        a1.uFrameWidth = 400;
+        a1.uFrameZ = a1.uFrameX + 399;
+        a1.DrawMessageBox(0);
+        sprintf(pTmpBuf2, "NPC%03d", v6->uPortraitID);
+        v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE);
+        pRenderer->DrawTextureIndexed(
+          a1.uFrameX + 22,
+          a1.uFrameY + 36,
+          (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
+        v9 = v6->uProfession;
+        if ( v9 )
+        {
+          v10 = v6->pName;
+          v11 = pTmpBuf;
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]);
+        }
+        else
+        {
+          v12 = v6->pName;
+          v11 = pTmpBuf;
+          strcpy(pTmpBuf, v12);
+        }
+        v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u);
+        a1.uFrameWidth -= 24;
+        a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
+        v14 = sub_495461((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0);
+        a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0);
+      }
+    }
+  }
+}
+
+
+//----- (00416D62) --------------------------------------------------------
+void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(Vec2_int_ *_this)
+{
+  signed int pPlayerNum; // eax@12
+  char *v2; // eax@32
+  void *v3; // ecx@52
+  unsigned int v4; // eax@59
+  int v5; // esi@62
+  signed int v6; // esi@64
+  signed int v7; // esi@69
+  ItemGen *v8; // ecx@70
+  unsigned int v9; // eax@72
+  unsigned int v10; // eax@76
+  char v11; // zf@83
+  GUIButton *pButton; // esi@84
+  unsigned int v13; // ecx@85
+  char *pStr; // edi@85
+  signed int pControlID; // eax@92
+  int v16; // eax@95
+  int v17; // eax@96
+  enum PLAYER_SKILL_TYPE v18; // eax@98
+  char *pStr2; // eax@99
+  unsigned int v20; // eax@108
+  unsigned int pSkillId; // eax@109
+  const char *pSkillInfo; // eax@111
+  //char *v23; // ebx@112
+  char *pHint; // edx@113
+  unsigned int pColor; // eax@113
+  GUIWindow pWindow; // [sp+4h] [bp-74h]@32
+  double v27; // [sp+58h] [bp-20h]@33
+  struct tagPOINT Point; // [sp+60h] [bp-18h]@6
+  char *v29; // [sp+68h] [bp-10h]@33
+  float v30; // [sp+6Ch] [bp-Ch]@33
+  unsigned int pX; // [sp+70h] [bp-8h]@3
+  unsigned int pY; // [sp+74h] [bp-4h]@3
+
+  if ( pCurrentScreen == 16 )//îêíî âèäåî ðîëèêà 
+    return;
+  if ( _this )
+  {
+    pX = _this->x;
+    pY = _this->y;
+  }
+  else
+  {
+    pMouse->GetClickPos(&pX, &pY);
+  }
+  if ( pRenderer->bWindowMode )
+  {
+    GetCursorPos(&Point);
+    ScreenToClient(hWnd, &Point);
+    if ( Point.x < 1 || Point.y < 1 || Point.x > 638 || Point.y > 478 )
+    {
+      back_to_game();
+      return;
+    }
+  }
+  if ( pParty->pPickedItem.uItemID )//íàæàòèå íà ïîðòðåò ïåðñà ïðàâîé êíîïêîé ìûøè ñ ðàñòâîðîì
+  {
+    //v1 = 0;
+    //do
+	for ( pPlayerNum = 0; pPlayerNum < 4; ++pPlayerNum)
+    {
+      if ( (signed int)pX > RightClickPortraitXmin[pPlayerNum] && (signed int)pX < RightClickPortraitXmax[pPlayerNum]
+        && (signed int)pY > 375 && (signed int)pY < 466 )
+      {
+        pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(pPlayerNum + 1, 1);
+        return;
+      }
+      //++v1;
+    }
+    //while ( v1 < 4 );
+  }
+  pEventTimer->Pause();
+  if ( pCurrentScreen <= 10 )
+  {
+    if ( pCurrentScreen == 10 )//îêíî ÿùèêà
+    {
+      __debugbreak();
+      if ( !pPlayers[uActiveCharacter]->CanAct() )
+      {
+        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s íå â ñîñòîÿíèè %s
+          pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Îïîçíàòü ïðåäìåòû
+        pWindow.Hint = pTmpBuf;
+        pWindow.uFrameWidth = 384;
+        pWindow.uFrameHeight = 180;
+        pWindow.uFrameY = 40;
+        if ( (signed int)pX <= 320 )
+          v10 = pX + 30;
+        else
+          v10 = pX - 414;
+        pWindow.uFrameX = v10;
+		pWindow.DrawMessageBox(0);
+        goto LABEL_132;
+      }
+      v9 = pX + pSRZBufferLineOffsets[pY];
+      if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) )
+        goto LABEL_132;
+      v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
+                       + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
+    }
+    else
+    {
+      if ( pCurrentScreen )
+      {
+        if ( pCurrentScreen != 3 )
+        {
+          if ( pCurrentScreen != 7 )
+          {
+            if ( pCurrentScreen == 8 )//îêíî êíèãè çàêëîâ
+            {
+              if ( dword_507B00_spell_info_to_draw_in_popup )
+                DrawSpellDescriptionPopup((void *)(dword_507B00_spell_info_to_draw_in_popup - 1));
+            }
+            goto LABEL_132;
+          }
+LABEL_119:
+          if ( (signed int)pX > 467 && pCurrentScreen != 14 )
+          {
+            identify_item();
+            goto LABEL_132;
+          }
+          if ( (signed int)pY >= 345 )
+            goto LABEL_132;
+          if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats
+          {
+            CharacterUI_StatsTab_ShowHint();
+            goto LABEL_132;
+          }
+          if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills
+          {
+            CharacterUI_SkillsTab_ShowHint();
+            goto LABEL_132;
+          }
+          v11 = pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103;//2DEvent - CharacerScreenInventory
+          if ( !v11 )
+            goto LABEL_132;
+ 		  identify_item();
+          goto LABEL_132;
+        }
+        if ( !dword_506364
+          || (signed int)pX < (signed int)pViewport->uViewportX
+          || (signed int)pX > (signed int)pViewport->uViewportZ
+          || (signed int)pY < (signed int)pViewport->uViewportY
+          || (signed int)pY > (signed int)pViewport->uViewportW
+          || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) )
+          goto LABEL_132;
+        v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
+        v27 = v30 + 6.7553994e15;
+        v29 = (char *)LODWORD(v27);
+        pWindow.uFrameWidth = LODWORD(v27);
+        pWindow.uFrameX = pX + 5;
+        pWindow.uFrameY = pY + 5;
+		pWindow.uFrameHeight = 64;
+        pAudioPlayer->StopChannels(-1, -1);
+        pWindow.DrawMessageBox(0);
+        goto LABEL_132;
+      }
+      if (GetCurrentMenuID() > 0)
+        goto LABEL_132;
+
+      if ( (signed int)pY > (signed int)pViewport->uViewportW )
+      {
+        pWindow.ptr_1C = (void *)((signed int)pX / 118);
+        if ( (signed int)pX / 118 < 4 )
+        {
+          pWindow.Hint = 0;
+          pWindow.uFrameWidth = 400;
+          pWindow.uFrameHeight = 200;
+          pWindow.uFrameX = 38;
+          pWindow.uFrameY = 60;
+          pAudioPlayer->StopChannels(-1, -1);
+          pWindow.DrawQuickCharRecord();
+        }
+        goto LABEL_132;
+      }
+      if ( (signed int)pX > (signed int)pViewport->uViewportZ )
+      {
+        if ( (signed int)pY >= 130 )
+        {
+          if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
+          {
+            pWindow.Hint = 0;
+            pWindow.uFrameWidth = 400;
+            pWindow.uFrameHeight = 200;
+            pWindow.uFrameX = 38;
+            pWindow.uFrameY = 60;
+            pAudioPlayer->StopChannels(-1, -1);
+            pWindow._41D73D_draw_buff_tooltip();
+            goto LABEL_132;
+          }
+          if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
+          {
+            if ( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 )
+              goto LABEL_132;
+            pAudioPlayer->StopChannels(-1, -1);
+            v3 = (void *)1;
+          }
+          else
+          {
+            pAudioPlayer->StopChannels(-1, -1);
+            v3 = 0;
+          }
+          sub_416B01(v3);
+          goto LABEL_132;
+        }
+        pWindow.Hint = _4443D5_GetMinimapRightClickText();
+        pWindow.uFrameWidth = 256;
+        pWindow.uFrameX = 130;
+        pWindow.uFrameY = 140;
+        pWindow.uFrameHeight = 64;
+        pAudioPlayer->StopChannels(-1, -1);
+        pWindow.DrawMessageBox(0);
+        goto LABEL_132;
+      }
+      pWindow.Hint = 0;
+      pWindow.uFrameWidth = 320;
+      pWindow.uFrameHeight = 320;
+      v4 = pX - 350;
+      if ( (signed int)pX <= 320 )
+        v4 = pX + 30;
+      pWindow.uFrameX = v4;
+      pWindow.uFrameY = 40;
+      if ( pRenderer->pRenderD3D )
+        LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
+      else
+        v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+      v6 = (unsigned __int16)v5;
+      if ( (v6 & 7) != 2 )
+      {
+        if ( (v6 & 7) == 3 )
+        {
+          if ( pRenderer->uNumSceneBegins )
+          {
+            pWindow.DrawMessageBox(1);
+            MonsterPopup_Draw(v6 >> 3, &pWindow);
+          }
+          else
+          {
+            pRenderer->BeginScene();
+            pWindow.DrawMessageBox(1);
+            MonsterPopup_Draw(v6 >> 3, &pWindow);
+            pRenderer->EndScene();
+          }
+        }
+        goto LABEL_132;
+      }
+      v7 = v6 >> 3;
+      if ( pObjectList->pObjects[pLayingItems[v7].uObjectDescID].uFlags & 0x10 )
+        goto LABEL_132;
+      v8 = &pLayingItems[v7].stru_24;
+    }
+    GameUI_DrawItemInfo(v8);
+    goto LABEL_132;
+  }
+  if ( pCurrentScreen == 13 )//îêíî äîìà
+  {
+    if ( (signed int)pY < 345 && (signed int)pX < 469 )
+      sub_4B1A2D();
+    goto LABEL_132;
+  }
+  if ( pCurrentScreen <= 13 )
+    goto LABEL_132;
+  if ( pCurrentScreen <= 15 )
+    goto LABEL_119;
+  if ( pCurrentScreen != 21 )
+  {
+    v11 = pCurrentScreen == 23;
+    if ( !v11 )
+      goto LABEL_132;
+    identify_item();
+    goto LABEL_132;
+  }
+  pWindow.Hint = 0;
+  pStr = 0;
+  for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext)
+  {
+    if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ
+      && (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW )
+    {
+     pControlID = pButton->uControlID;
+     switch ( pControlID )
+	 {
+	 case 0: //stats info
+      pWindow.Hint = pAttributeDescriptions[(signed int)pButton->uControlParam % 7];
+      pStr = aAttributeNames[(signed int)pButton->uControlParam % 7];
+      break;
+	 case 62: //Plus button info 
+      pStr = pGlobalTXT_LocalizationStrings[670];//Äîáàâèòü
+      pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Äîáàâëÿåò î÷êî ê âûäåëåííîìó íàâûêó, çàáèðàÿ åãî èç íàêîïèòåëÿ î÷êîâ"
+	  break;
+	 case 63: //Minus button info
+      pStr = pGlobalTXT_LocalizationStrings[668];//Âû÷åñòü
+      pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Âû÷èòàåò î÷êî èç âûäåëåííîãî íàâûêà, âîçâðàùàÿ åãî â íàêîïèòåëü î÷êîâ"
+	  break;
+	 case 64: //Available skill button info
+      v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->uControlParam + 4);
+      pStr = pSkillNames[v18];
+      pWindow.Hint = pSkillDesc[v18];
+	  break;
+	 case 65: //Available Class Info
+      pWindow.Hint = pClassDescriptions[pButton->uControlParam];
+      pStr = pClassNames[pButton->uControlParam];
+	  break;
+     case 66: //OK Info
+      pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Ùåëêíèòå çäåñü äëÿ óòâåðæäåíèÿ ñîñòàâà îòðÿäà è ïðîäîëæåíèÿ èãðû.
+      pStr = pGlobalTXT_LocalizationStrings[665];//Êíîïêà ÎÊ
+	  break;
+	 case 67: //Clear info
+      pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Ñáðàñûâàåò âñå ïàðàìåòðû è íàâûêè îòðÿäà.
+      pStr = pGlobalTXT_LocalizationStrings[667];//Êíîïêà Î÷èñòèòü
+      break;
+	 case 118: // Character info
+      pStr = pParty->pPlayers[pButton->uControlParam].pName;
+      pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->uControlParam].uClass];
+      break;
+     }
+     if ( pControlID > 68 && pControlID <= 75 ) //Sellected skills info
+     {
+      pSkillId = pParty->pPlayers[pButton->uControlParam].GetSkillIdxByOrder(pControlID - 72);
+      pY = 0;
+      if ( (signed int)pSkillId < 37 )
+      {
+	   pSkillInfo = CharacterUI_GetSkillDescText(pButton->uControlParam, (enum PLAYER_SKILL_TYPE)pSkillId);
+       strcpy(pTmpBuf2, pSkillInfo);
+       pWindow.Hint = pTmpBuf2;
+       pStr = pSkillNames[pSkillId];
+	  }
+     }
+	}
+  }
+  if ( pWindow.Hint )
+  {
+    pHint = pWindow.Hint;
+    pWindow.Hint = 0;
+    pWindow.uFrameWidth = 384;
+    pWindow.uFrameHeight = 256;
+    pWindow.uFrameX = 128;
+    pWindow.uFrameY = 40;
+    pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
+    pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
+    pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
+    pWindow.DrawMessageBox(0);
+    pWindow.uFrameX += 12;
+    pWindow.uFrameWidth -= 24;
+    pWindow.uFrameY += 12;
+    pWindow.uFrameHeight -= 12;
+    pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
+    pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
+    pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+    sprintf(pTmpBuf, pStr, pColor, format_4E2D80);//sprintfex äîëæåí áûòü - íå ðàáîòàåò sprintfex(pTmpBuf, format_4E2D80, v25, pStr)
+    pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
+    pWindow.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, pHint, 0, 0, 0);
+  }
+LABEL_132:
+  dword_507BF0_is_there_popup_onscreen = 1;
+  viewparams->bRedrawGameUI = 1;
+}
+
+//----- (004175C0) --------------------------------------------------------
+void __thiscall UI_OnMouseLeftClick(int *pXY)
+{
+  int *pXY_; // esi@1
+  signed int y; // eax@7
+  signed int x; // ecx@7
+  unsigned int v4; // eax@11
+  signed int v5; // eax@17
+  signed int v6; // esi@19
+  int v7; // esi@30
+  GUIWindow *v8; // edx@31
+  GUIButton *i; // esi@37
+  signed int v10; // eax@50
+  int v11; // ecx@52
+  unsigned int pX; // [sp+14h] [bp-8h]@7
+  unsigned int pY; // [sp+18h] [bp-4h]@7
+
+  pXY_ = pXY;
+  if ( pCurrentScreen == 16
+    || sub_4637E0_is_there_popup_onscreen() )
+    return;
+  if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
+  {
+    sub_4452BB();
+    return;
+  }
+  if ( pXY_ )
+  {
+    x = *pXY_;
+    y = pXY_[1];
+    pX = *pXY_;
+    pY = y;
+  }
+  else
+  {
+    pMouse->GetClickPos(&pX, &pY);
+    y = pY;
+    x = pX;
+  }
+  if ( pCurrentScreen
+    || !dword_507B98_ctrl_pressed )
+    goto LABEL_30;
+  v4 = GetCurrentMenuID();
+  x = pX;
+  if ( (v4 & 0x80000000u) == 0
+    || (signed int)pX < (signed int)pViewport->uViewportX
+    || (signed int)pX > (signed int)pViewport->uViewportZ )
+  {
+    y = pY;
+LABEL_30:
+    v7 = uNumVisibleWindows;
+    if ( uNumVisibleWindows < 0 )
+      return;
+    while ( 1 )
+    {
+      //v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]];
+      v8 = &pWindowList[pVisibleWindowsIdxs[v7] - 1];
+      if ( x >= (signed int)v8->uFrameX )
+      {
+        if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW )
+          break;
+      }
+      --v7;
+      if ( v7 < 0 )
+        return;
+    }
+    for ( i = v8->pControlsHead; ; i = i->pNext )
+    {
+      if ( !i )
+        return;
+      if ( i->uButtonType == 1 )
+        goto LABEL_41;
+      if ( i->uButtonType != 2 )
+        break;
+      if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth )
+        goto LABEL_50;
+      y = pY;
+      x = pX;
+LABEL_45:
+      ;
+    }
+    if ( i->uButtonType != 3 )
+      goto LABEL_45;
+LABEL_41:
+    if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW )
+    {
+LABEL_50:
+      i->field_2C = 1;
+      v10 = pMessageQueue_50CBD0->uNumMessages;
+      if ( pMessageQueue_50CBD0->uNumMessages )
+      {
+        v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+        pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+      }
+      //v11 = i->uControlParam;
+      pMessageQueue_50CBD0->SendMessage((UIMessageType)i->uControlID, i->uControlParam, 0);
+      return;
+    }
+    goto LABEL_45;
+  }
+  y = pY;
+  if ( (signed int)pY < (signed int)pViewport->uViewportY || (signed int)pY > (signed int)pViewport->uViewportW )
+    goto LABEL_30;
+  if ( pRenderer->pRenderD3D )
+    v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
+  else
+    v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+  v6 = (unsigned __int16)v5;
+  if ( (v5 & 7) == 3
+    && uActiveCharacter
+    && v5 < 33554432
+    && pPlayers[uActiveCharacter]->CanAct()
+    && pPlayers[uActiveCharacter]->CanSteal() )
+  {
+    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    {
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)27;
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
+      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+      ++pMessageQueue_50CBD0->uNumMessages;
+    }
+    if ( pParty->bTurnBasedModeOn == 1 )
+    {
+      if ( pTurnEngine->field_4 == 3 )
+        pTurnEngine->field_18 |= 8u;
+    }
+  }
+}
+
+
+
+//----- (00417871) --------------------------------------------------------
+void __thiscall sub_417871(int *pXY)
+{
+  POINT v1; // [sp+0h] [bp-18h]@5
+  POINT a2; // [sp+8h] [bp-10h]@5
+  unsigned int pY; // [sp+10h] [bp-8h]@3
+  unsigned int pX; // [sp+14h] [bp-4h]@3
+
+  if ( !pRenderer->pRenderD3D )
+  {
+    if ( pXY )
+    {
+      pX = *pXY;
+      pY = pXY[1];
+    }
+    else
+    {
+      pMouse->GetClickPos(&pX, &pY);
+    }
+    pMouse->GetCursorPos(&a2);
+    pMouse->GetCursorPos(&v1);
+  }
+}
+
+//----- (004178C4) --------------------------------------------------------
+void __cdecl sub_4178C4()
+{
+  if ( pArcomageGame->bGameInProgress == 1 )
+  {
+    if (pAsyncMouse)
+      pArcomageGame->stru1.field_0 = 7;
+  }
+}
+
+//----- (004178E1) --------------------------------------------------------
+void __cdecl sub_4178E1()
+{
+  if ( pArcomageGame->bGameInProgress == 1 )
+  {
+    if (pAsyncMouse)
+      pArcomageGame->stru1.field_0 = 8;
+  }
+}
+
+//----- (004178FE) --------------------------------------------------------
+unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2)
+{
+  unsigned __int16 v2; // dx@2
+  unsigned __int16 v3; // cx@2
+  int v5; // eax@5
+  unsigned __int16 v6; // [sp-4h] [bp-8h]@2
+
+  if ( a1 <= a2 )
+  {
+    if ( a1 == a2 )
+      return 0;
+    v5 = 100 * a1 / a2;
+    v3 = 255;
+    if ( v5 >= 25 )
+    {
+      v6 = 100;
+      v2 = 255;
+    }
+    else
+    {
+      v6 = 0;
+      v2 = 0;
+    }
+  }
+  else
+  {
+    v6 = 0;
+    v2 = 255;
+    v3 = 0;
+  }
+  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
+}
+
+//----- (00417939) --------------------------------------------------------
+signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx)
+{
+  unsigned int v1; // ebx@1
+  signed int v2; // edi@1
+  unsigned int v3; // esi@1
+  unsigned int v4; // eax@1
+  unsigned int v6; // [sp+Ch] [bp-4h]@1
+
+  v1 = uConditionIdx;
+  v2 = 65535;
+  v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
+  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+  switch ( v1 )
+  {
+    case 0u:
+    case 1u:
+    case 3u:
+    case 4u:
+    case 5u:
+    case 6u:
+    case 7u:
+      v2 = v4;
+      break;
+    case 2u:
+    case 8u:
+    case 9u:
+    case 0xCu:
+    case 0xDu:
+      v2 = v3;
+      break;
+    case 0xAu:
+    case 0xBu:
+    case 0xEu:
+    case 0xFu:
+    case 0x10u:
+      v2 = v6;
+      break;
+    default:
+      return v2;
+  }
+  return v2;
+}
+
+//----- (004179BC) --------------------------------------------------------
+char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2)
+{
+  const char *v2; // ebx@1
+  const char *v3; // edi@1
+  unsigned int v4; // eax@1
+  GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1
+  POINT v6; // [sp+60h] [bp-8h]@1
+
+  v2 = a2;
+  v3 = a1;
+  memset(&Dst, 0, 0x54u);
+  Dst.uFrameWidth = 384;
+  Dst.uFrameHeight = 256;
+  Dst.uFrameX = 128;
+  Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30;
+  Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
+  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+  Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
+  Dst.DrawMessageBox(0);
+  Dst.uFrameX += 12;
+  Dst.uFrameWidth -= 24;
+  Dst.uFrameY += 12;
+  Dst.uFrameHeight -= 12;
+  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+  Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
+  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  sprintf(pTmpBuf, format_4E2D80, v4, v3);
+  Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
+  return Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
+}
+
+//----- (00417AD4) --------------------------------------------------------
+unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3)
+{
+  enum PLAYER_SKILL_TYPE v3; // ebx@1
+  signed int v4; // edi@1
+  unsigned int v5; // ecx@1
+  int v6; // edx@1
+  int v7; // eax@7
+  int v8; // eax@10
+  unsigned __int8 v9; // sf@10
+  unsigned __int8 v10; // of@10
+  int v11; // eax@11
+  int v12; // eax@14
+  unsigned int yellow; // [sp+Ch] [bp-Ch]@1
+  unsigned int red; // [sp+10h] [bp-8h]@1
+  unsigned int white; // [sp+14h] [bp-4h]@1
+
+  v3 = uPlayerSkillType;
+  v4 = uPlayerClass;
+  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
+  yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0);
+  v5 = 0;
+  v6 = v4 % 4;
+  if ( !(v4 % 4) )
+  {
+    v11 = 37 * v4 + v3;
+    if ( byte_4ED970_skill_learn_ability_by_class_table[0][v11] >= a3 )
+      goto LABEL_8;
+    if ( byte_4ED970_skill_learn_ability_by_class_table[1][v11] < a3
+      && byte_4ED970_skill_learn_ability_by_class_table[2][v11] < a3 )
+    {
+      v12 = byte_4ED970_skill_learn_ability_by_class_table[3][v11];
+      v10 = __OFSUB__(v12, a3);
+      v9 = v12 - a3 < 0;
+LABEL_15:
+      v5 = red;
+      if ( v9 ^ v10 )
+        return v5;
+    }
+    return yellow;
+  }
+  if ( v6 == 1 )
+  {
+    v7 = 37 * v4 + v3;
+    if ( byte_4ED970_skill_learn_ability_by_class_table[0][v7] >= a3 )
+      goto LABEL_8;
+    if ( byte_4ED970_skill_learn_ability_by_class_table[1][v7] < a3 )
+    {
+      v8 = byte_4ED970_skill_learn_ability_by_class_table[2][v7];
+      v10 = __OFSUB__(v8, a3);
+      v9 = v8 - a3 < 0;
+      goto LABEL_15;
+    }
+    return yellow;
+  }
+  if ( v6 > 1 && v6 <= 3 )
+  {
+    if ( byte_4ED970_skill_learn_ability_by_class_table[v4][v3] < a3 )
+      return red;
+LABEL_8:
+    v5 = white;
+  }
+  return v5;
+}
+
+//----- (00417BB5) --------------------------------------------------------
+const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, enum PLAYER_SKILL_TYPE uPlayerSkillType)
+{
+  enum PLAYER_SKILL_TYPE v2; // esi@1
+  unsigned int v3; // ebx@1
+  int v4; // edi@1
+  int v5; // eax@1
+  Player *pPlayer; // ebx@7
+  char v7; // al@7
+  char v8; // cl@7
+  unsigned int v9; // eax@8
+  unsigned int v10; // eax@8
+  unsigned int v11; // eax@8
+  enum PLAYER_SKILL_TYPE v12; // edi@8
+  unsigned int v13; // eax@8
+  unsigned int v14; // eax@8
+  enum PLAYER_SKILL_TYPE v15; // esi@8
+  int v16; // edi@8
+  char v17; // al@8
+  int v18; // ST5C_4@8
+  int v19; // ST4C_4@8
+  int v20; // ST3C_4@8
+  int v21; // ST2C_4@8
+  int v22; // ST1C_4@8
+  char *v23; // esi@8
+  unsigned int v24; // eax@9
+  unsigned int v25; // eax@9
+  unsigned int v26; // eax@9
+  unsigned int v27; // ecx@9
+  enum PLAYER_SKILL_TYPE v28; // ebx@9
+  unsigned int v29; // eax@9
+  char a2[1200]; // [sp+Ch] [bp-538h]@7
+  char Source[120]; // [sp+4BCh] [bp-88h]@7
+  unsigned __int16 *v33; // [sp+534h] [bp-10h]@1
+  int v34; // [sp+538h] [bp-Ch]@1
+  unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1
+  enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1
+
+  v2 = uPlayerSkillType;
+  v3 = uPlayerID;
+  v36 = uPlayerSkillType;
+  v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal
+  v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert
+  v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master
+  v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);// Grand
+  v35 = (unsigned __int16 *)v4;
+  if ( v34 > v4 )
+    v35 = (unsigned __int16 *)v34;
+  if ( (signed int)v33 > (signed int)v35 )
+    v35 = v33;
+  if ( v5 > (signed int)v35 )
+    v35 = (unsigned __int16 *)v5;
+  pPlayer = &pParty->pPlayers[v3];
+  v33 = &pPlayer->pActiveSkills[v2];
+  v7 = pPlayer->GetActualSkillLevel(v2);
+  v8 = LOBYTE(pPlayer->pActiveSkills[v2]);
+  a2[0] = 0;
+  Source[0] = 0;
+  if ( (v8 & 0x3F) == (v7 & 0x3F) )
+  {
+    strcpy(a2, "%s\n\n");
+    v24 = sub_417AD4(pPlayer->uClass, v2, 1);
+    sprintf(Source, format_4E2DC8, v24);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v25 = sub_417AD4(pPlayer->uClass, v36, 2);
+    sprintf(Source, format_4E2DC8, v25);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v26 = sub_417AD4(pPlayer->uClass, v36, 3);
+    sprintf(Source, format_4E2DC8, v26);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v27 = pPlayer->uClass;
+    v28 = v36;
+    v29 = sub_417AD4(v27, v36, 4);
+    sprintf(Source, format_4E2DC8, v29);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+
+    v23 = static_sub_417BB5_out_string;
+    sprintf(
+      static_sub_417BB5_out_string,
+      a2,
+      pSkillDesc[v28],
+      pGlobalTXT_LocalizationStrings[431],      // Normal
+      (char *)v35 + 3,
+      v35 + 5,
+      pNormalSkillDesc[v28],
+      pGlobalTXT_LocalizationStrings[433],      // Expert
+      (char *)v35 + 3,
+      v35 + 5,
+      pExpertSkillDesc[v28],
+      pGlobalTXT_LocalizationStrings[432],      // Master
+      (char *)v35 + 3,
+      v35 + 5,
+      pMasterSkillDesc[v28],
+      pGlobalTXT_LocalizationStrings[96],       // Grand
+      (char *)v35 + 3,
+      v35 + 5,
+      pGrandSkillDesc[v28]);
+  }
+  else
+  {
+    strcpy(a2, "%s\n\n");
+    v9 = sub_417AD4(pPlayer->uClass, v2, 1);
+    sprintf(Source, format_4E2DC8, v9);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v10 = sub_417AD4(pPlayer->uClass, v36, 2);
+    sprintf(Source, format_4E2DC8, v10);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v11 = sub_417AD4(pPlayer->uClass, v36, 3);
+    sprintf(Source, format_4E2DC8, v11);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
+    v12 = v36;
+    v13 = sub_417AD4(pPlayer->uClass, v36, 4);
+    sprintf(Source, format_4E2DC8, v13);
+    strcat(a2, Source);
+    strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
+    v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    sprintf(Source, format_4E2DC8, v14);
+    strcat(a2, Source);
+    strcat(a2, "%s: +%d");
+    v15 = v12;
+    v16 = (int)(v35 + 5);
+    v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4);
+    v34 = (int)((char *)v35 + 3);
+    v17 = pPlayer->GetActualSkillLevel(v36);
+    v18 = *(int *)((char *)pGrandSkillDesc + v15);
+    v19 = *(int *)((char *)pMasterSkillDesc + v15);
+    v20 = *(int *)((char *)pExpertSkillDesc + v15);
+    v21 = *(int *)((char *)pNormalSkillDesc + v15);
+    v22 = *(int *)((char *)pSkillDesc + v15);
+    v23 = static_sub_417BB5_out_string;
+    sprintf(
+      static_sub_417BB5_out_string,
+      a2,
+      v22,
+      pGlobalTXT_LocalizationStrings[431],
+      v34,
+      v16,
+      v21,
+      pGlobalTXT_LocalizationStrings[433],
+      v34,
+      v16,
+      v20,
+      pGlobalTXT_LocalizationStrings[432],
+      v34,
+      v16,
+      v19,
+      pGlobalTXT_LocalizationStrings[96],
+      v34,
+      v16,
+      v18,
+      pGlobalTXT_LocalizationStrings[623],
+      (v17 & 0x3F) - (*(char *)v33 & 0x3F));
+  }
+  return v23;
+}
+
+//----- (00417FE5) --------------------------------------------------------
+char __cdecl CharacterUI_SkillsTab_ShowHint()
+{
+  unsigned int v0; // ecx@1
+  unsigned int v1; // eax@1
+  GUIButton *i; // esi@6
+  const char *v3; // eax@12
+  unsigned int pX; // [sp+4h] [bp-8h]@1
+  unsigned int pY; // [sp+8h] [bp-4h]@1
+
+  pMouse->GetClickPos(&pX, &pY);
+  v0 = pX;
+  v1 = pY;
+  if ( (signed int)pX < 24 || (signed int)pX > 455 || (signed int)pY < 18 || (signed int)pY > 36 )
+  {
+    for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
+    {
+      if ( i->uControlID == 121
+        && (signed int)v0 >= (signed int)i->uX
+        && (signed int)v0 <= (signed int)i->uZ
+        && (signed int)v1 >= (signed int)i->uY
+        && (signed int)v1 <= (signed int)i->uW )
+      {
+        v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (enum PLAYER_SKILL_TYPE)i->uControlParam);
+        sub_4179BC_draw_tooltip(pSkillNames[i->uControlParam], v3);
+        v1 = pY;
+        v0 = pX;
+      }
+    }
+  }
+  else
+  {
+    LOBYTE(v1) = sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription);
+  }
+  return v1;
+}
+
+//----- (00418083) --------------------------------------------------------
+char __cdecl CharacterUI_StatsTab_ShowHint()
+{
+  LONG _x; // esi@1
+  Player *_y; // eax@1
+  int v2; // edi@1
+  __int16 *v3; // ecx@1
+  LONG v4; // edx@2
+  signed int v5; // edx@4
+  char *v6; // ecx@9
+  char *v7; // ebx@9
+  unsigned int v8; // ebx@15
+  unsigned __int64 v9; // kr00_8@15
+  char *v10; // ST2C_4@15
+  signed int v11; // eax@15
+  char *v12; // ecx@17
+  char *v13; // eax@20
+  Player *v14; // esi@28
+  int v15; // ebx@28
+  int v16; // eax@33
+  POINT a2; // [sp+Ch] [bp-24h]@1
+  __int64 v19; // [sp+14h] [bp-1Ch]@15
+  char *v20; // [sp+1Ch] [bp-14h]@13
+  Player *v21; // [sp+20h] [bp-10h]@13
+  unsigned int v22; // [sp+24h] [bp-Ch]@15
+  int *v23; // [sp+28h] [bp-8h]@13
+  const char *v24; // [sp+2Ch] [bp-4h]@10
+
+  _x = pMouse->GetCursorPos(&a2)->x;
+  _y = (Player *)pMouse->GetCursorPos(&a2)->y;
+  v2 = 0;
+  v3 = &array_4E2940[0].field_2;
+  while ( 1 )
+  {
+    v4 = *(v3 - 1);
+    if ( _x >= v4 )
+    {
+      if ( _x <= v4 + v3[1] )
+      {
+        v5 = *v3;
+        if ( (signed int)_y >= v5 )
+        {
+          if ( (signed int)_y <= v5 + v3[2] )
+            break;
+        }
+      }
+    }
+    v3 += 4;
+    ++v2;
+    if ( (signed int)v3 >= (signed int)&off_4E2A12 )
+      return (char)_y;
+  }
+  switch ( v2 )
+  {
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+    case 4:
+    case 5:
+    case 6:
+      LOBYTE(_y) = 4 * v2;
+      v6 = aAttributeNames[v2];
+      v7 = pAttributeDescriptions[v2];
+      goto LABEL_46;
+    case 7:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[108]);
+      v7 = pHealthPointsAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[108];
+      goto LABEL_47;
+    case 8:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[212]);
+      v7 = pSpellPointsAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[212];
+      goto LABEL_47;
+    case 9:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[12]);
+      v7 = pArmourClassAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[12];
+      goto LABEL_47;
+    case 10:
+      v24 = pGlobalTXT_LocalizationStrings[47];
+      strcpy(pTmpBuf2, pPlayerConditionAttributeDescription);
+      v7 = pTmpBuf2;
+      v20 = pTmpBuf2;
+      strcat(pTmpBuf2, "\n");
+
+      extern unsigned int pConditionImportancyTable[18];
+      v23 = (int *)pConditionImportancyTable;
+      _y = pPlayers[uActiveCharacter];
+      v21 = pPlayers[uActiveCharacter];
+      do
+      {
+        if ( _y->pConditions[*v23] )
+        {
+          strcat(pTmpBuf2, " \n");
+          v8 = *v23;
+          v9 = pParty->uTimePlayed - v21->pConditions[*v23];
+          a2.x = LODWORD(pParty->uTimePlayed) - LODWORD(v21->pConditions[*v23]);
+          a2.y = HIDWORD(v9);
+          v19 = (signed __int64)((double)*(signed __int64 *)&a2 * 0.234375) / 60 / 60;
+          v22 = (unsigned int)v19 / 0x18;
+          v10 = aCharacterConditionNames[v8];
+          v19 %= 24i64;
+          v11 = GetConditionDrawColor(v8);
+          sprintf(pTmpBuf, &byte_4E2DE8, v11, v10);
+          strcat(pTmpBuf2, pTmpBuf);
+          if ( v19 && v19 <= 1 )
+            v12 = pGlobalTXT_LocalizationStrings[109];
+          else
+            v12 = pGlobalTXT_LocalizationStrings[110];
+          if ( !v22 || (v13 = pGlobalTXT_LocalizationStrings[56], v22 > 1) )
+            v13 = pGlobalTXT_LocalizationStrings[57];
+          sprintf(pTmpBuf, "%lu %s, %lu %s", v22, v13, v19, v12);
+          strcat(pTmpBuf2, pTmpBuf);
+          v7 = v20;
+          _y = v21;
+        }
+        ++v23;
+      }
+      while ( (signed int)v23 < (signed int)&unk_4EDF40 );
+      goto LABEL_47;
+    case 11:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[172]);
+      v7 = pFastSpellAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[172];
+      goto LABEL_47;
+    case 12:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[5]);
+      v7 = pPlayerAgeAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[5];
+      goto LABEL_47;
+    case 13:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[131]);
+      v7 = pPlayerLevelAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[131];
+      goto LABEL_47;
+    case 14:
+      v14 = pPlayers[uActiveCharacter];
+      v24 = pGlobalTXT_LocalizationStrings[83];
+      v15 = v14->uLevel;
+      do
+      {
+        if ( (signed __int64)v14->uExperience < (unsigned int)sub_4B46F8(v15) )
+          break;
+        ++v15;
+      }
+      while ( v15 <= 10000 );
+      pTmpBuf[0] = 0;
+      pTmpBuf2[0] = 0;
+      if ( v15 > v14->uLevel )
+        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[147], v15);
+      v16 = sub_4B46F8(v15) - LODWORD(v14->uExperience);
+      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[538], v16, v15 + 1);
+      strcat(pTmpBuf, "\n");
+      strcat(pTmpBuf, pTmpBuf2);
+      LOBYTE(_y) = sprintf(pTmpBuf2, "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf);
+      v7 = pTmpBuf2;
+      goto LABEL_47;
+    case 15:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[587]);
+      v7 = pAttackBonusAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[587];
+      goto LABEL_47;
+    case 16:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[588]);
+      v7 = pAttackDamageAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[588];
+      goto LABEL_47;
+    case 17:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[589]);
+      v7 = pMissleBonusAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[589];
+      goto LABEL_47;
+    case 18:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[590]);
+      v7 = pMissleDamageAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[590];
+      goto LABEL_47;
+    case 19:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[87]);
+      v7 = pFireResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[87];
+      goto LABEL_47;
+    case 20:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[6]);
+      v7 = pAirResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[6];
+      goto LABEL_47;
+    case 21:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[240]);
+      v7 = pWaterResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[240];
+      goto LABEL_47;
+    case 22:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[70]);
+      v7 = pEarthResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[70];
+      goto LABEL_47;
+    case 23:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[142]);
+      v7 = pMindResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[142];
+      goto LABEL_47;
+    case 24:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[29]);
+      v7 = pBodyResistanceAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[29];
+      goto LABEL_47;
+    case 25:
+      LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[207]);
+      v7 = pSkillPointsAttributeDescription;
+      v24 = pGlobalTXT_LocalizationStrings[207];
+      goto LABEL_47;
+    case 26:
+      _y = (Player *)(4 * pPlayers[uActiveCharacter]->uClass);
+      v6 = *(char **)((char *)_y->pConditions + (int)pClassNames);
+      v7 = *(char **)((char *)_y->pConditions + (int)pClassDescriptions);
+LABEL_46:
+      v24 = v6;
+LABEL_47:
+      if ( v24 && v7 )
+        LOBYTE(_y) = sub_4179BC_draw_tooltip(v24, v7);
+      break;
+    default:
+      return (char)_y;
+  }
+  return (char)_y;
+}
+
+//----- (00418511) --------------------------------------------------------
+char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
+{
+  Player *pPlayer; // edi@1
+  unsigned int v2; // eax@1
+  unsigned int v3; // eax@1
+  unsigned int v4; // eax@2
+  int v5; // ST20_4@4
+  int v6; // ST1C_4@4
+  int v7; // ebp@4
+  int v8; // eax@4
+  unsigned int v9; // eax@4
+  int v10; // ST34_4@4
+  int v11; // ST20_4@4
+  int v12; // ST1C_4@4
+  int v13; // ebp@4
+  int v14; // eax@4
+  unsigned int v15; // eax@4
+  int v16; // ST34_4@4
+  int v17; // ST20_4@4
+  int v18; // ST1C_4@4
+  int v19; // ebp@4
+  int v20; // eax@4
+  unsigned int v21; // eax@4
+  int v22; // ST34_4@4
+  int v23; // ST20_4@4
+  int v24; // ST1C_4@4
+  int v25; // ebp@4
+  int v26; // eax@4
+  unsigned int v27; // eax@4
+  int v28; // ST34_4@4
+  int v29; // ST20_4@4
+  int v30; // ST1C_4@4
+  int v31; // ebp@4
+  int v32; // eax@4
+  unsigned int v33; // eax@4
+  int v34; // ST34_4@4
+  int v35; // ST20_4@4
+  int v36; // ST1C_4@4
+  int v37; // ebp@4
+  int v38; // eax@4
+  unsigned int v39; // eax@4
+  int v40; // ST34_4@4
+  int v41; // ST20_4@4
+  int v42; // ST1C_4@4
+  int v43; // ebp@4
+  int v44; // eax@4
+  unsigned int v45; // eax@4
+  int v46; // ebp@4
+  signed int v47; // ST20_4@6
+  int v48; // ST1C_4@6
+  signed int v49; // eax@6
+  unsigned int v50; // eax@6
+  int v51; // ST20_4@8
+  int v52; // ST1C_4@8
+  int v53; // eax@8
+  unsigned int v54; // eax@8
+  int v55; // ST34_4@8
+  int v56; // ST20_4@8
+  int v57; // ST1C_4@8
+  int v58; // ebp@8
+  int v59; // eax@8
+  unsigned int v60; // eax@8
+  unsigned int v61; // ebp@8
+  unsigned int v62; // eax@8
+  char *v63; // ST20_4@8
+  signed int v64; // eax@8
+  unsigned int v65; // ebp@8
+  unsigned __int8 v66; // al@8
+  char *v67; // eax@9
+  unsigned int v68; // ST20_4@11
+  unsigned int v69; // ST1C_4@11
+  signed int v70; // ebp@11
+  signed int v71; // eax@11
+  unsigned int v72; // eax@11
+  int v73; // ST20_4@13
+  int v74; // ST1C_4@13
+  int v75; // ebp@13
+  int v76; // eax@13
+  unsigned int v77; // eax@13
+  char *v78; // ecx@14
+  int v79; // ST20_4@16
+  char *v80; // ST40_4@16
+  unsigned int v81; // eax@16
+  int v82; // ST34_4@16
+  int v83; // eax@16
+  int v84; // ST34_4@16
+  char *v85; // eax@16
+  int v86; // ST34_4@16
+  int v87; // eax@16
+  int v88; // ST34_4@16
+  char *v89; // eax@16
+  int v90; // eax@16
+  int v91; // ST20_4@19
+  unsigned int v92; // eax@19
+  int v93; // eax@19
+  int v94; // ST20_4@22
+  unsigned int v95; // eax@22
+  int v96; // eax@22
+  int v97; // ST20_4@25
+  unsigned int v98; // eax@25
+  int v99; // eax@25
+  int v100; // ST20_4@27
+  unsigned int v101; // eax@27
+  int v102; // eax@27
+  int v103; // ST20_4@30
+  unsigned int v104; // eax@30
+  char *v105; // ST20_4@32
+  unsigned int v106; // eax@32
+  int v107; // eax@33
+  int v108; // ST20_4@36
+  unsigned int v109; // eax@36
+  char *v110; // ST20_4@38
+  unsigned int v111; // eax@38
+  int uY; // [sp+10h] [bp-10h]@6
+  int uYa; // [sp+10h] [bp-10h]@11
+  int uYb; // [sp+10h] [bp-10h]@13
+  int uYc; // [sp+10h] [bp-10h]@16
+  int uYd; // [sp+10h] [bp-10h]@19
+  int uYe; // [sp+10h] [bp-10h]@22
+  int uYf; // [sp+10h] [bp-10h]@25
+  int uYg; // [sp+10h] [bp-10h]@27
+  int uYh; // [sp+10h] [bp-10h]@33
+  const char *a2; // [sp+14h] [bp-Ch]@4
+  const char *a2a; // [sp+14h] [bp-Ch]@6
+  const char *a2b; // [sp+14h] [bp-Ch]@11
+  const char *a2c; // [sp+14h] [bp-Ch]@16
+  const char *a2d; // [sp+14h] [bp-Ch]@19
+  const char *a2e; // [sp+14h] [bp-Ch]@22
+  const char *a2f; // [sp+14h] [bp-Ch]@25
+  const char *a2g; // [sp+14h] [bp-Ch]@27
+  const char *a2h; // [sp+14h] [bp-Ch]@33
+  int v131; // [sp+18h] [bp-8h]@16
+  int v132; // [sp+18h] [bp-8h]@19
+  int v133; // [sp+18h] [bp-8h]@22
+  int v134; // [sp+18h] [bp-8h]@25
+  int v135; // [sp+18h] [bp-8h]@27
+  int v136; // [sp+18h] [bp-8h]@33
+  int v137; // [sp+1Ch] [bp-4h]@27
+  int v138; // [sp+1Ch] [bp-4h]@33
+
+  pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * uPlayerID + 40552];
+  v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
+  pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
+  v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  sprintf(pTmpBuf, format_4E2DC8, v3);
+  sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
+  strcat(pTmpBuf, pTmpBuf2);
+  if ( pPlayer->uSkillPoints )
+    v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+  else
+    v4 = 0xFFFFu;
+  sprintf(pTmpBuf2, "\xC" "00000\xD" "180%s: \xC%05d%d\xC" "00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
+  strcat(pTmpBuf, pTmpBuf2);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
+  v5 = pPlayer->GetBaseStrength();
+  v6 = pPlayer->GetActualMight();
+  v7 = pPlayer->GetBaseStrength();
+  v8 = pPlayer->GetActualMight();
+  v9 = UI_GetHealthManaStringColor(v8, v7);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
+  v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
+  v11 = pPlayer->GetBaseIntelligence();
+  v12 = pPlayer->GetActualIntelligence();
+  v13 = pPlayer->GetBaseIntelligence();
+  v14 = pPlayer->GetActualIntelligence();
+  v15 = UI_GetHealthManaStringColor(v14, v13);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+  v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
+  v17 = pPlayer->GetBaseWillpower();
+  v18 = pPlayer->GetActualWillpower();
+  v19 = pPlayer->GetBaseWillpower();
+  v20 = pPlayer->GetActualWillpower();
+  v21 = UI_GetHealthManaStringColor(v20, v19);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
+  v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
+  v23 = pPlayer->GetBaseEndurance();
+  v24 = pPlayer->GetActualEndurance();
+  v25 = pPlayer->GetBaseEndurance();
+  v26 = pPlayer->GetActualEndurance();
+  v27 = UI_GetHealthManaStringColor(v26, v25);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
+  v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
+  v29 = pPlayer->GetBaseAccuracy();
+  v30 = pPlayer->GetActualAccuracy();
+  v31 = pPlayer->GetBaseAccuracy();
+  v32 = pPlayer->GetActualAccuracy();
+  v33 = UI_GetHealthManaStringColor(v32, v31);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
+  v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
+  v35 = pPlayer->GetBaseSpeed();
+  v36 = pPlayer->GetActualSpeed();
+  v37 = pPlayer->GetBaseSpeed();
+  v38 = pPlayer->GetActualSpeed();
+  v39 = UI_GetHealthManaStringColor(v38, v37);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
+  v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
+  v41 = pPlayer->GetBaseLuck();
+  v42 = pPlayer->GetActualLuck();
+  v43 = pPlayer->GetBaseLuck();
+  v44 = pPlayer->GetActualLuck();
+  v45 = UI_GetHealthManaStringColor(v44, v43);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
+  a2 = "%s";
+  v46 = v40 + 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
+  if ( pPlayer->GetMaxHealth() >= 1000 )
+    a2 = (const char *)&unk_4E2EB8;
+  v47 = pPlayer->GetMaxHealth();
+  v48 = pPlayer->sHealth;
+  v49 = pPlayer->GetMaxHealth();
+  v50 = UI_GetHealthManaStringColor(pPlayer->sHealth, v49);
+  sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
+  a2a = "%s";
+  uY = LOBYTE(pFontArrus->uFontHeight) + v46 - 2;
+  if ( pPlayer->GetMaxMana() >= 1000 )
+    a2a = (const char *)&unk_4E2EB8;
+  v51 = pPlayer->GetMaxMana();
+  v52 = pPlayer->sMana;
+  v53 = pPlayer->GetMaxMana();
+  v54 = UI_GetHealthManaStringColor(pPlayer->sMana, v53);
+  sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
+  v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
+  v56 = pPlayer->GetBaseAC();
+  v57 = pPlayer->GetActualAC();
+  v58 = pPlayer->GetBaseAC();
+  v59 = pPlayer->GetActualAC();
+  v60 = UI_GetHealthManaStringColor(v59, v58);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
+  v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
+  v62 = pPlayer->GetMajorConditionIdx();
+  v63 = aCharacterConditionNames[v62];
+  v64 = GetConditionDrawColor(v62);
+  sprintf(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[47], v64, v63);
+  pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v61, 0, pTmpBuf, 226, 0);
+  v65 = LOBYTE(pFontArrus->uFontHeight) + v61 - 1;
+  v66 = pPlayer->uQuickSpell;
+  if ( v66 )
+    v67 = pSpellStats->pInfos[v66].pShortName;
+  else
+    v67 = pGlobalTXT_LocalizationStrings[153];
+  sprintf(pTmpBuf, "%s: %s", pGlobalTXT_LocalizationStrings[172], v67);
+  pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v65, 0, pTmpBuf, 226, 0);
+  v68 = pPlayer->GetBaseAge();
+  v69 = pPlayer->GetActualAge();
+  v70 = pPlayer->GetBaseAge();
+  v71 = pPlayer->GetActualAge();
+  v72 = UI_GetHealthManaStringColor(v71, v70);
+  sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
+  a2b = "%s";
+  uYa = LOBYTE(pFontArrus->uFontHeight) + 48;
+  if ( pPlayer->GetBaseLevel() > 99 )
+    a2b = format_4E2E68;
+  v73 = pPlayer->GetBaseLevel();
+  v74 = pPlayer->GetActualLevel();
+  v75 = pPlayer->GetBaseLevel();
+  v76 = pPlayer->GetActualLevel();
+  v77 = UI_GetHealthManaStringColor(v76, v75);
+  sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
+  uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
+  if ( (signed __int64)pPlayer->uExperience <= 9999999 )
+    v78 = pGlobalTXT_LocalizationStrings[83];
+  else
+    v78 = pGlobalTXT_LocalizationStrings[17];
+  v79 = LODWORD(pPlayer->uExperience);
+  v80 = v78;
+  v81 = pPlayer->GetExperienceDisplayColor();
+  sprintf(pTmpBuf, "%s\r180", v80, v81, v79);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYb, 0, pTmpBuf, 0, 0, 0);
+  v82 = uYb + 2 * LOBYTE(pFontArrus->uFontHeight);
+  v83 = pPlayer->GetActualAttack(0);
+  sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v82, 0, pTmpBuf, 0, 0, 0);
+  v84 = v82 + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v85 = pPlayer->GetMeleeDamageString();
+  sprintf(pTmpBuf, "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v84, 0, pTmpBuf, 0, 0, 0);
+  v86 = v84 + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v87 = pPlayer->GetRangedAttack();
+  sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v86, 0, pTmpBuf, 0, 0, 0);
+  v88 = v86 + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v89 = pPlayer->GetRangedDamageString();
+  sprintf(pTmpBuf, "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v88, 0, pTmpBuf, 0, 0, 0);
+  a2c = format_4E2E10;
+  uYc = v88 + 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
+  v131 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
+  v90 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
+  if ( v131 > 99 || v90 > 99 )
+    a2c = format_4E2E68;
+  v91 = v90;
+  v92 = UI_GetHealthManaStringColor(v131, v90);
+  sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
+  a2d = format_4E2E10;
+  uYd = uYc + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v132 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
+  v93 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
+  if ( v132 > 99 || v93 > 99 )
+    a2d = format_4E2E68;
+  v94 = v93;
+  v95 = UI_GetHealthManaStringColor(v132, v93);
+  sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
+  a2e = format_4E2E10;
+  uYe = uYd + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v133 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
+  v96 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
+  if ( v133 > 99 || v96 > 99 )
+    a2e = format_4E2E68;
+  v97 = v96;
+  v98 = UI_GetHealthManaStringColor(v133, v96);
+  sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
+  a2f = format_4E2E10;
+  uYf = uYe + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v134 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
+  v99 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
+  if ( v134 > 99 )
+    a2f = format_4E2E68;
+  v100 = v99;
+  v101 = UI_GetHealthManaStringColor(v134, v99);
+  sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
+  a2g = format_4E2E10;
+  uYg = uYf + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v135 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
+  v102 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
+  v137 = v102;
+  if ( v135 > 99 || v102 > 99 )
+    a2g = format_4E2E68;
+  v103 = v102;
+  v104 = UI_GetHealthManaStringColor(v135, v102);
+  sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
+  if ( pPlayer->uClass == 35 && v137 == 200 )
+  {
+    v105 = pGlobalTXT_LocalizationStrings[625];
+    v106 = UI_GetHealthManaStringColor(v135, 200);
+    sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
+  }
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
+  a2h = format_4E2E10;
+  uYh = uYg + LOBYTE(pFontArrus->uFontHeight) - 2;
+  v136 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
+  v107 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
+  v138 = v107;
+  if ( v136 > 99 || v107 > 99 )
+    a2h = format_4E2E68;
+  v108 = v107;
+  v109 = UI_GetHealthManaStringColor(v136, v107);
+  sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
+  if ( pPlayer->uClass == 35 && v138 == 200 )
+  {
+    v110 = pGlobalTXT_LocalizationStrings[625];
+    v111 = UI_GetHealthManaStringColor(v136, 200);
+    sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
+  }
+  return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
+}
+
+//----- (00419100) --------------------------------------------------------
+int __cdecl sub_419100()
+{
+  Player *v0; // esi@1
+  int v1; // ebx@1
+  unsigned __int8 *v2; // esi@1
+  int v3; // eax@4
+  int result; // eax@6
+  int v5; // esi@6
+  unsigned __int8 v6; // zf@6
+  unsigned __int8 v7; // sf@6
+  int v8; // edx@7
+  int v9; // ecx@7
+  unsigned __int8 v10; // of@7
+  stru179 *v11; // edi@9
+  int v12; // edx@11
+  int v13; // [sp+Ch] [bp-8h]@2
+  signed int v14; // [sp+Ch] [bp-8h]@9
+  int i; // [sp+10h] [bp-4h]@10
+
+  v0 = pPlayers[uActiveCharacter];
+  memset(&pStru179, 0, 0xFA0u);
+  memset(pTmpBuf2, 0, 0x7D0u);
+  v1 = 0;
+  dword_506544 = 0;
+  dword_506548 = 0;
+  dword_506520 = 0;
+  dword_50651C = 0;
+  dword_506528 = 0;
+  v2 = (unsigned __int8 *)v0->field_152;
+  do
+  {
+    v13 = dword_723E80_award_related[2 * v1];
+    if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 )
+    {
+      v3 = dword_506520++;
+      pStru179->field_0[v3] = v1;
+    }
+    ++v1;
+  }
+  while ( v1 < 105 );
+  result = dword_506520;
+  v5 = 0;
+  v6 = dword_506520 == 0;
+  v7 = dword_506520 < 0;
+  dword_506524 = dword_506520;
+  dword_506520 = 0;
+  if ( !(v7 | v6) )
+  {
+    do
+    {
+      v8 = rand() % 16;
+      result = dword_506524;
+      v9 = dword_506524 + v5++;
+      v10 = __OFSUB__(v5, dword_506524);
+      v7 = v5 - dword_506524 < 0;
+      pStru179->field_0[v9] = v8;
+    }
+    while ( v7 ^ v10 );
+    if ( result > 0 )
+    {
+      v14 = 1;
+      v11 = pStru179;
+      do
+      {
+        for ( i = v14; i < result; ++i )
+        {
+          v12 = pStru179->field_0[i];
+          if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] )
+          {
+            pStru179->field_0[i] = v11->field_0[0];
+            v11->field_0[0] = v12;
+          }
+        }
+        ++v14;
+        v11 = (stru179 *)((char *)v11 + 4);
+      }
+      while ( v14 - 1 < result );
+    }
+  }
+  return result;
+}
+
+
+//----- (00419220) --------------------------------------------------------
+void __cdecl sub_419220()
+{
+  GUIButton *i; // eax@2
+
+  if ( !dword_507CBC )
+  {
+    dword_507CBC = 1;
+    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;
+      }
+    }
+    pBtn_Up = pGUIWindow_CurrentMenu->CreateButton(
+                   0x1B6u,
+                   0x2Eu,
+                   (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureWidth : 24),
+                   (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureHeight : 26),
+                   1,
+                   0,
+                   0xA9u,
+                   0,
+                   0,
+                   "",
+                   (Texture *)(uTextureID_ar_up_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_up] : 0),
+                   uTextureID_ar_up_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_dn] : 0,
+                   0);
+    pBtn_Down = pGUIWindow_CurrentMenu->CreateButton(
+                   0x1B6u,
+                   0x124u,
+                   (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureWidth : 24),
+                   (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureHeight : 26),
+                   1,
+                   0,
+                   0xAAu,
+                   0,
+                   0,
+                   "",
+                   (Texture *)(uTextureID_ar_dn_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_up] : 0),
+                   uTextureID_ar_dn_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_dn] : 0,
+                   0);
+    ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(
+                   0x1B8u,
+                   0x3Eu,
+                   0x10u,
+                   0xE8u,
+                   1,
+                   0,
+                   0xC0u,
+                   0,
+                   0,
+                   "",
+                   0);
+  }
+}
+
+
+
+//----- (00419379) --------------------------------------------------------
+void __cdecl sub_419379()
+{
+  GUIButton *i; // esi@2
+
+  if ( dword_507CBC )
+  {
+    dword_507CBC = 0;
+    GUIButton::_41D0D8(ptr_507BA4);
+    GUIButton::_41D0D8(pBtn_Up);
+    GUIButton::_41D0D8(pBtn_Down);
+    pBtn_Down = 0;
+    pBtn_Up = 0;
+    for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
+    {
+      if ( i->uControlID == 120 )
+      {
+        i->uX = dword_50698C;
+        i->uY = dword_506988;
+        i->uZ = dword_506984;
+        i->uW = dword_506980;
+        pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
+      }
+    }
+  }
+}
+
+
+//----- (00419401) --------------------------------------------------------
+void __cdecl sub_419401()
+{
+  unsigned int v0; // ecx@3
+  GUIButton *i; // eax@3
+  GUIFont *v2; // eax@8
+  unsigned int v3; // esi@8
+  int v4; // eax@10
+  unsigned int v5; // esi@14
+  int v6; // eax@17
+  unsigned int v7; // esi@19
+  int v8; // eax@21
+  unsigned int v9; // esi@25
+  int v10; // eax@27
+  int a2; // [sp+10h] [bp-14h]@1
+  int v12; // [sp+14h] [bp-10h]@8
+  int v13; // [sp+14h] [bp-10h]@19
+  unsigned int *v14; // [sp+18h] [bp-Ch]@8
+  unsigned int *v15; // [sp+18h] [bp-Ch]@14
+  unsigned int *v16; // [sp+18h] [bp-Ch]@19
+  unsigned int *v17; // [sp+18h] [bp-Ch]@25
+  char *v18; // [sp+1Ch] [bp-8h]@8
+  int a5; // [sp+20h] [bp-4h]@8
+
+  a2 = 0;
+  if ( dword_507CC0 )
+    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;
+      v0 = uActiveCharacter;
+    }
+  }
+  v12 = 0;
+  a5 = pGUIWindow_CurrentMenu->uNumControls;
+  v18 = &stru_AA1058[3].pSounds[6972 * v0 + 40552];
+  v2 = pFontLucida;
+  v14 = (unsigned int *)dword_4E2A2C;
+  v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
+  do
+  {
+    if ( v18[2 * *v14 + 264] & 0x3F )
+    {
+      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);
+      v2 = pFontLucida;
+    }
+    ++v14;
+  }
+  while ( (signed int)v14 < (signed int)dword_4E2A50 );
+  if ( !v12 )
+    v3 = v3 + LOBYTE(v2->uFontHeight) - 3;
+  v15 = (unsigned int *)_4E2A80_skills;
+  v5 = v3 + 2 * LOBYTE(v2->uFontHeight) - 6;
+  do
+  {
+    if ( v18[2 * *v15 + 264] & 0x3F && a2 < 15 )
+    {
+      v6 = LOBYTE(v2->uFontHeight);
+      v5 = v5 + v6 - 3;
+      ++a2;
+      pGUIWindow_CurrentMenu->CreateButton(
+        0x18u,
+        v5,
+        0xCCu,
+        v6 - 3,
+        3,
+        *v15 | 0x8000,
+        0x79u,
+        *v15,
+        0,
+        "",
+        0);
+      v2 = pFontLucida;
+    }
+    ++v15;
+  }
+  while ( (signed int)v15 < (signed int)pAwardsTextColors );
+  v13 = 0;
+  v16 = (unsigned int *)dword_4E2A18;
+  v7 = 2 * LOBYTE(v2->uFontHeight) + 13;
+  do
+  {
+    if ( v18[2 * *v16 + 264] & 0x3F )
+    {
+      v8 = LOBYTE(v2->uFontHeight);
+      v7 = v7 + v8 - 3;
+      ++a2;
+      ++v13;
+      pGUIWindow_CurrentMenu->CreateButton(
+        0xF6u,
+        v7,
+        0xCCu,
+        v8 - 3,
+        3,
+        *v16 | 0x8000,
+        0x79u,
+        *v16,
+        0,
+        "",
+        0);
+      v2 = pFontLucida;
+    }
+    ++v16;
+  }
+  while ( (signed int)v16 < (signed int)dword_4E2A2C );
+  if ( !v13 )
+    v7 = v7 + LOBYTE(v2->uFontHeight) - 3;
+  v17 = (unsigned int *)dword_4E2A50;
+  v9 = v7 + 2 * LOBYTE(v2->uFontHeight) - 6;
+  do
+  {
+    if ( v18[2 * *v17 + 264] & 0x3F )
+    {
+      v10 = LOBYTE(v2->uFontHeight);
+      v9 = v9 + v10 - 3;
+      ++a2;
+      pGUIWindow_CurrentMenu->CreateButton(
+        0xF6u,
+        v9,
+        0xCCu,
+        v10 - 3,
+        3,
+        *v17 | 0x8000,
+        0x79u,
+        *v17,
+        0,
+        "",
+        0);
+      v2 = pFontLucida;
+    }
+    ++v17;
+  }
+  while ( (signed int)v17 < (signed int)_4E2A80_skills );
+  if ( a2 )
+    pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
+}
\ No newline at end of file