diff mm7_5.cpp @ 1055:010a844ef4a0

Слияние
author Ritor1
date Wed, 22 May 2013 22:23:04 +0600
parents 5520fdca7a74 306ec23b37df
children 37498d2cceed
line wrap: on
line diff
--- a/mm7_5.cpp	Wed May 22 22:22:36 2013 +0600
+++ b/mm7_5.cpp	Wed May 22 22:23:04 2013 +0600
@@ -1,7 +1,19 @@
 #include <assert.h>
 
+#include "VideoPlayer.h"
+#include "Sprites.h"
+#include "MapInfo.h"
+#include "BSPModel.h"
+#include "OutdoorCamera.h"
+#include "LightmapBuilder.h"
+#include "DecalBuilder.h"
+#include "Mouse.h"
+#include "Keyboard.h"
+#include "GammaControl.h"
+#include "stru11.h"
+
+#include "Vis.h"
 #include "mm7.h"
-#include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
 #include "GUIFont.h"
@@ -9,13 +21,9 @@
 #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"
@@ -24,19 +32,11 @@
 #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 "Awards.h"
-#include "Autonotes.h"
-#include "stru160.h"
 #include "TurnEngine.h"
 #include "CastSpellInfo.h"
-#include "Weather.h"
 #include "stru298.h"
-#include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
 #include "Log.h"
@@ -47,7 +47,7 @@
 void __cdecl GameUI_MsgProc()
 {
   //signed int v0; // edi@6
-  char *v1; // esi@6
+  //char *v1; // esi@6
   unsigned int v2; // edx@7
   Actor *pActor; // ecx@13
   int v4; // ecx@18
@@ -275,13 +275,12 @@
     memset(&actor, 0, 0x344u);
     dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID;
     actor.sNPC_ID = bDialogueUI_InitializeActor_NPC_ID;
-    actor.InitializeDialogue(0);
+    GameUI_InitializeDialogue(&actor, false);
     bDialogueUI_InitializeActor_NPC_ID = 0;
   }
   if ( pMessageQueue_50CBD0->uNumMessages )
   {
-    //v0 = 1;
-    v1 = "";
+    //v1 = "";
     while ( 2 )
     {
       if ( !pMessageQueue_50CBD0->uNumMessages )
@@ -307,7 +306,7 @@
           dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].sNPC_ID;
           pActor = &pActors[uMessageParam];
           //goto _actor_init_dlg;
-          pActor->InitializeDialogue(1);
+          GameUI_InitializeDialogue(pActor, true);
           continue;
         case UIMSG_StartHireling1Dialogue:
         case UIMSG_StartHireling2Dialogue:
@@ -360,7 +359,7 @@
               memset(&actor, 0, 0x344u);
               actor.sNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx;
               pActor = &actor;
-              pActor->InitializeDialogue(1);
+              GameUI_InitializeDialogue(&actor, true);
             }
           }
           continue;
@@ -383,7 +382,7 @@
         case UIMSG_StartNewGame:
           if ( dword_6BE138 == 124 || uMessageParam )
           {
-            pIcons_LOD->_40F9C5();
+            pIcons_LOD->SyncLoadedFilesCount();
             pIcons_LOD->_4114F2();
             if ( pMessageQueue_50CBD0->uNumMessages )
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -401,18 +400,18 @@
           stru_506E40.Release();
           continue;
         case UIMSG_Game_OpenLoadGameDialog:
-          pIcons_LOD->_40F9C5();
+          pIcons_LOD->SyncLoadedFilesCount();
           pIcons_LOD->_4114F2();
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_LOADGAME;
-          GameUI_DrawLoadMenu(1);
+          LoadUI_Load(1);
           continue;
         case UIMSG_Quit:
           if ( dword_6BE138 == 132 || uMessageParam )
           {
-            pIcons_LOD->_40F9C5();
+            pIcons_LOD->SyncLoadedFilesCount();
             pIcons_LOD->_4114F2();
             if ( pMessageQueue_50CBD0->uNumMessages )
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -433,7 +432,7 @@
           continue;
         case UIMSG_80:
 			__debugbreak();
-          pIcons_LOD->_40F9C5();
+          pIcons_LOD->SyncLoadedFilesCount();
           pIcons_LOD->_4114F2();
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_OPTIONS;
@@ -516,7 +515,7 @@
         case UIMSG_Game_OpenSaveGameDialog:
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_SAVEGAME;
-          GameUI_DrawSaveMenu();
+          SaveUI_Load();
           continue;
         case UIMSG_Game_OpenOptionsDialog://Open
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -550,48 +549,48 @@
           pGUIWindow_CurrentMenu->CreateButton(22, 270,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight,
-                                               1, 0, UIMSG_SetTurnSpeed, 0x80, 0, v1, 0);
+                                               1, 0, UIMSG_SetTurnSpeed, 0x80, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(93, 270,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureHeight,
-                                               1, 0, UIMSG_SetTurnSpeed, 0x40u, 0, v1, 0);
+                                               1, 0, UIMSG_SetTurnSpeed, 0x40u, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(164, 270,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureHeight,
-                                               1, 0, UIMSG_SetTurnSpeed, 0, 0, v1, 0);
+                                               1, 0, UIMSG_SetTurnSpeed, 0, 0, "", 0);
 
           pGUIWindow_CurrentMenu->CreateButton(20, 303,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureHeight,
-                                               1, 0, UIMSG_ToggleWalkSound, 0, 0, v1, 0);
+                                               1, 0, UIMSG_ToggleWalkSound, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(128, 303,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureHeight,
-                                               1, 0, UIMSG_ToggleShowDamage, 0, 0, v1, 0);
+                                               1, 0, UIMSG_ToggleShowDamage, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(20, 325,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureHeight,
-                                               1, 0, UIMSG_ToggleAlwaysRun, 0, 0, v1, 0);
+                                               1, 0, UIMSG_ToggleAlwaysRun, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(128, 325,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureHeight,
-                                               1, 0, UIMSG_ToggleFlipOnExit, 0, 0, v1, 0);
-
-          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
-          pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, 1, 0, UIMSG_ChangeSoundVolume, 0, 0, v1, 0);
-
-          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
-          pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, 1, 0, UIMSG_ChangeMusicVolume, 0, 0, v1, 0);
-
-          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
-          pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, 1, 0, UIMSG_ChangeVoiceVolume, 0, 0, v1, 0);
+                                               1, 0, UIMSG_ToggleFlipOnExit, 0, 0, "", 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, 1, 0, UIMSG_ChangeSoundVolume, 0, 0, "", 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, 1, 0, UIMSG_ChangeMusicVolume, 0, 0, "", 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, 1, 0, UIMSG_ChangeVoiceVolume, 0, 0, "", 0);
 
           pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[619], 0); // "Return to Game"
-          pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, 1, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, 1, 0, UIMSG_OpenVideoOptions, 0, 86, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, 1, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, 1, 0, UIMSG_OpenVideoOptions, 0, 86, "", 0);
           continue;
 
         case UIMSG_OpenKeyMappingOptions://Open
@@ -625,16 +624,16 @@
           pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xBu, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xCu, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, UIMSG_ChangeKeyButton, 0xDu, 0, "", 0);
-          dword_506E68 = -1;
+          uGameMenuUI_CurentlySelectedKeyIdx = -1;
           KeyboardPageNum = 1;
-          memset(KeyButtonFlagChangesArray, 0, sizeof(KeyButtonFlagChangesArray));
+          memset(GameMenuUI_InvaligKeyBindingsFlags, 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags));
           //*(_WORD *)KeyButtonArray[28] = 0;
           memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
-          v1 = "";
+          //v1 = "";
           //v0 = 1;
           continue;
         case UIMSG_ChangeKeyButton:
-          if ( dword_506E68 != -1 )
+          if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
           {
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
@@ -642,7 +641,7 @@
           v14 = uMessageParam;
           if ( KeyboardPageNum != 1 )
             v14 = uMessageParam + 14;
-          dword_506E68 = v14;
+          uGameMenuUI_CurentlySelectedKeyIdx = v14;
           pKeyActionMap->EnterText(0, 1, pGUIWindow_CurrentMenu);
           continue;
         case UIMSG_ResetKeyMapping:
@@ -670,7 +669,7 @@
             v18 = uAction++;
             v13 = uAction > 28;
             v12 = uAction - 28 < 0;
-            KeyButtonFlagChangesArray[v18] = 0;
+            GameMenuUI_InvaligKeyBindingsFlags[v18] = 0;
           }
           while ( v12 ^ v13 );
           pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0);
@@ -707,21 +706,21 @@
           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, 1, 0, UIMSG_Escape, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0);
           if ( pRenderer->pRenderD3D )
           {
-            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleBloodsplats, 0, 0, v1, 0);
-            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, v1, 0);
-            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, v1, 0);
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleBloodsplats, 0, 0, "", 0);
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, "", 0);
+            pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, "", 0);
           }
           if ( !pRenderer->bWindowMode )
           {
             //v0 = 1;
             if ( GammaController::IsGammaSupported() )
             {
-              pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 4u, 0, v1, pIcons_LOD->GetTexture(uTextureID_507C20), 0);
-              pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, v1, pIcons_LOD->GetTexture(uTextureID_507C24), 0);
-              pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, v1, 0);
+              pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 4u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C20), 0);
+              pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C24), 0);
+              pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, "", 0);
             }
           }
           continue;
@@ -1147,7 +1146,7 @@
                       continue;
                     case SCREEN_OPTIONS://Close
                       options_menu_skin.Relaease();
-                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->SyncLoadedFilesCount();
                       WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
                       WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
                       WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier);
@@ -1177,9 +1176,9 @@
                       stru_506E40.Release();
                       break;
                     case SCREEN_MENU:
-                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->SyncLoadedFilesCount();
                       pIcons_LOD->_4114F2();
-                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->SyncLoadedFilesCount();
                       pIcons_LOD->_4114F2();
                       stru_506E40.Release();
                       break;
@@ -1200,24 +1199,27 @@
                       WriteWindowsRegistryInt("GammaPos", uGammaPos);
                       stru_506E40.Release();
                       break;
+
                     case SCREEN_KEYBOARD_OPTIONS://Return to game
                       v197 = 1;
                       v32 = 0;
-                      while ( KeyButtonFlagChangesArray[v32] != 1 )
+                      while ( !GameMenuUI_InvaligKeyBindingsFlags[v32])
                       {
                         ++v32;
                         if ( v32 >= 28 )
                         {
                           thisb = (signed int)&uTextureID_Optkb;
+                          assert(false && "Invalid condition values");
                           do
                           {
                             if ( *(int *)thisb )
                               pIcons_LOD->pTextures[*(int *)thisb].Release();
                             thisb += 4;
                           }
-                          while ( thisb < (signed int)&dword_507C08 );
+                          while ( thisb < (signed int)0x00507C08 );
+
                           memset(&uTextureID_Optkb, 0, 0x14u);
-                          pIcons_LOD->_40F9C5();
+                          pIcons_LOD->SyncLoadedFilesCount();
                           uAction = 0;
                           do
                           {
@@ -1263,7 +1265,7 @@
                       pTexture_RestUI_CurrentHourglassFrame->Release();
                       pTexture_RestUI_CurrentHourglassFrame = 0;
                       pTexture_RestUI_CurrentSkyFrame = 0;
-                      pIcons_LOD->_40F9C5();
+                      pIcons_LOD->SyncLoadedFilesCount();
                       pIcons_LOD->_4114F2();
                       _506F18_num_hours_to_sleep = 0;
                       dword_506F14 = 0;
@@ -1342,7 +1344,7 @@
                       pGUIWindow_CurrentMenu = 0;
                       pEventTimer->Resume();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       pIcons_LOD->_4355F7();
                       continue;
                     case SCREEN_INPUT_BLV://click escape
@@ -1353,34 +1355,34 @@
                       {
                         pParty->field_709 = 0;
                         LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
-                        Party__CountHirelings();
-                        viewparams->bRedrawGameUI = 1;
+                        pParty->CountHirelings();
+                        viewparams->bRedrawGameUI = true;
                         dword_5B65CC = 0;
                       }
                       DialogueEnding();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       continue;
                     case SCREEN_NPC_DIALOGUE://click escape
                       if ( dword_5B65CC )
                       {
                         pParty->field_709 = 0;
                         LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
-                        Party__CountHirelings();
-                        viewparams->bRedrawGameUI = 1;
+                        pParty->CountHirelings();
+                        viewparams->bRedrawGameUI = true;
                         dword_5B65CC = 0;
                       }
                       //goto LABEL_317;
                       DialogueEnding();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       continue;
                     case SCREEN_BRANCHLESS_NPC_DIALOG://click escape
                       memset(GameUI_Footer_TimedString, 0, 0xC8u);
                       sub_4452BB();
                       DialogueEnding();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       continue;
                     case SCREEN_CHANGE_LOCATION://click escape
                       if ( pParty->vPosition.x < -22528 )
@@ -1393,7 +1395,7 @@
                         pParty->vPosition.y = 22528;
                       DialogueEnding();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       continue;
                     case SCREEN_VIDEO:
                       pVideoPlayer->Unload();
@@ -1426,7 +1428,7 @@
                       pGUIWindow_CurrentMenu = 0;
                       pEventTimer->Resume();
                       pCurrentScreen = SCREEN_GAME;
-                      viewparams->bRedrawGameUI = 1;
+                      viewparams->bRedrawGameUI = true;
                       pIcons_LOD->_4355F7();
                       continue;
                     default:
@@ -1482,7 +1484,7 @@
                   pGUIWindow_CurrentMenu = 0;
                   pEventTimer->Resume();
                   pCurrentScreen = SCREEN_GAME;
-                  viewparams->bRedrawGameUI = 1;
+                  viewparams->bRedrawGameUI = true;
                   pIcons_LOD->_4355F7();
                   continue;
                 }
@@ -1514,7 +1516,7 @@
               pGUIWindow_CurrentMenu = 0;
               pEventTimer->Resume();
               pCurrentScreen = SCREEN_GAME;
-              viewparams->bRedrawGameUI = 1;
+              viewparams->bRedrawGameUI = true;
               pIcons_LOD->_4355F7();
               continue;
             }
@@ -1524,10 +1526,12 @@
               GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_GameSettings, 1);
               pEventTimer->Pause();
               pAudioPlayer->StopChannels(-1, -1);
+              pCurrentScreen = SCREEN_MENU;
+              
               ++pIcons_LOD->uTexturePacksCount;
-              pCurrentScreen = 1;
               if ( !pIcons_LOD->uNumPrevLoadedFiles )
                 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+
               pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_OptionsButtons, 0, 0);
               uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
               uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
@@ -1663,12 +1667,12 @@
           pVideoPlayer->Unload();
           DialogueEnding();
           start_event_seq_number = 0;
-          viewparams->bRedrawGameUI = 1;
+          viewparams->bRedrawGameUI = true;
           continue;
         case UIMSG_CycleCharacters:
           v39 = GetAsyncKeyState(VK_SHIFT);
           uActiveCharacter = CycleCharacter(v39);
-          viewparams->bRedrawGameUI = 1;
+          viewparams->bRedrawGameUI = true;
           continue;
         case UIMSG_OnTravelByFoot:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -2295,10 +2299,7 @@
             pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubDirs / 2);
             v70 = atoi(v216.pProperties[0]);
             if ( v70 <= 0 || v70 >= 77 )
-            {
-              v1 = "";
               continue;
-            }
             v71 = v70;
             strcpy(Str2, pMapStats->pInfos[v70].pFilename);
             pNPCData3 = 0;
@@ -2319,7 +2320,6 @@
                 dword_6BE364_game_settings_1 |= 1u;
                 uGameState = GAME_STATE_2;
                 OnMapLeave();
-                v1 = "";
                 continue;
               }
             }
@@ -2329,10 +2329,7 @@
           else
           {
             if ( v216.uPropCount != 3 )
-            {
-              v1 = "";
               continue;
-            }
             v74 = atoi(v216.pProperties[0]);
             thisi = atoi(v216.pProperties[1]);
             v75 = atoi(v216.pProperties[2]);
@@ -2346,7 +2343,6 @@
                 pParty->vPosition.y = v77;
                 pParty->vPosition.z = v76;
                 pParty->uFallStartY = v76;
-                v1 = "";
                 continue;
               }
             }
@@ -2365,7 +2361,6 @@
                       pParty->vPosition.y = v77;
                       pParty->vPosition.z = v76;
                       pParty->uFallStartY = v76;
-                      v1 = "";
                       continue;
                     }
                   }
@@ -2376,7 +2371,6 @@
             v73 = "Can't jump to that location!";
           }
           ShowStatusBarString(v73, 6u);
-          v1 = "";
           continue;
         case UIMSG_CastQuickSpell:
           if ( bUnderwater == 1 )
@@ -2386,10 +2380,7 @@
             continue;
           }
           if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) )
-          {
-            v1 = "";
             continue;
-          }
           _42777D_CastSpell_UseWand_ShootArrow(pPlayer2->uQuickSpell, uActiveCharacter - 1, 0, 0, uActiveCharacter);
           continue;
         case UIMSG_CastSpell_Monster_Improvement:
@@ -2408,10 +2399,7 @@
           v44 = (unsigned __int16)v81;
           v84 = v83 >> 16;
           if ( PID_TYPE(v44) != 3 || v84 >= 5120 )
-          {
-            v1 = "";
             continue;
-          }
           pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C;
           if ( uMessage == UIMSG_CastSpell_Shoot_Monster )
           {
@@ -2437,10 +2425,7 @@
         case UIMSG_1C:
 			__debugbreak();
           if ( !uActiveCharacter || pCurrentScreen )
-          {
-            v1 = "";
             continue;
-          }
           ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, WINDOW_68, uMessageParam, 0);
           pCurrentScreen = SCREEN_19;
           pEventTimer->Pause();
@@ -2448,10 +2433,7 @@
         case UIMSG_1B:
 			__debugbreak();
           if ( !uActiveCharacter )
-          {
-            v1 = "";
             continue;
-          }
           if ( pParty->bTurnBasedModeOn != 1 )
           {
             if ( pActors[uMessageParam].uAIState == 5 )
@@ -2461,10 +2443,7 @@
             continue;
           }
           if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3 )
-          {
-            v1 = "";
             continue;
-          }
           if ( !(pTurnEngine->field_18 & 2) )
           {
             if ( pActors[uMessageParam].uAIState == 5 )
@@ -2476,20 +2455,14 @@
 
         case UIMSG_Attack:
           if ( !uActiveCharacter )
-          {
-            v1 = "";
             continue;
-          }
           if ( pParty->bTurnBasedModeOn != 1 )
           {
             _42ECB5_PlayerAttacksActor();
             continue;
           }
           if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3 )
-          {
-            v1 = "";
             continue;
-          }
           if ( !(pTurnEngine->field_18 & 2) )
             _42ECB5_PlayerAttacksActor();
           continue;
@@ -2522,7 +2495,7 @@
           continue;
         case UIMSG_RentRoom:
           dword_506F14 = 2;
-          RestUI_Initialize();
+          RestUI_Load();
           v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
           _506F18_num_hours_to_sleep = v86;
           if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
@@ -2552,10 +2525,7 @@
               v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
             ShowStatusBarString(v88, 2);
             if ( !uActiveCharacter )
-            {
-              v1 = "";
               continue;
-            }
             pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0);
             continue;
           }
@@ -2566,7 +2536,7 @@
           }
           if ( !(pParty->uFlags & 0x88) )
           {
-            RestUI_Initialize();
+            RestUI_Load();
             continue;
           }
           if ( pParty->bTurnBasedModeOn == 1 )
@@ -2579,10 +2549,7 @@
             v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
           ShowStatusBarString(v88, 2u);
           if ( !uActiveCharacter )
-          {
-            v1 = "";
             continue;
-          }
           pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0);
           continue;
         case UIMSG_Rest8Hour:
@@ -2803,7 +2770,8 @@
                     dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1;
                     ++dword_50C9E8;
                   }*/
-                  pMessageQueue_50CBD0->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                  pMessageQueue_50C9E8->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                //  pMessageQueue_50CBD0->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
                 }
                 else
                 {
@@ -2819,7 +2787,7 @@
             _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 0, 0, 0);
         continue;
 
-        case UIMSG_92:
+        case UIMSG_SpellScrollUse:
 			__debugbreak();
           if ( pTurnEngine->field_4 != 3 )
             _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, 1, 0);
@@ -2943,7 +2911,7 @@
           pCharacterScreen_DetalizBtn = pGUIWindow_CurrentMenu->CreateButton(v121, v123, v125, v128, 1, 0, UIMSG_ChangeDetaliz, 0, 0,
                          pGlobalTXT_LocalizationStrings[64],// "Detail Toggle"
                          0);
-          pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, v1, 0);
+          pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
           viewparams->bRedrawGameUI = 1;
           continue;
         case UIMSG_ClickPaperdoll:
@@ -3261,9 +3229,13 @@
       }
     }
   }
-  pMessageQueue_50CBD0->uNumMessages = dword_50C9E8;
-  memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
-  dword_50C9E8 = 0;
+  pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50C9E8->uNumMessages;//dword_50C9E8;
+  memcpy(pMessageQueue_50CBD0->pMessages, pMessageQueue_50C9E8->pMessages, sizeof(GUIMessage) * pMessageQueue_50C9E8->uNumMessages);
+  //memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
+  //dword_50C9E8 = 0;
+
+
+   pMessageQueue_50C9E8->uNumMessages=0;
   if ( dword_50C9DC )
   {
     /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
@@ -3395,11 +3367,11 @@
           break;
         case UIMSG_PlayerCreation_FacePrev:
           pPlayer = &pParty->pPlayers[pParam];
-          if (!pPlayer->uFace)
-            pPlayer->uFace = 19;
+          if (!pPlayer->uCurrentFace)
+            pPlayer->uCurrentFace = 19;
           else
-            pPlayer->uFace -= 1;
-          pPlayer->uVoiceID = pPlayer->uFace;
+            pPlayer->uCurrentFace -= 1;
+          pPlayer->uVoiceID = pPlayer->uCurrentFace;
           pPlayer->SetInitialStats();
           pPlayer->SetSexByVoice();
           pPlayer->RandomizeName();
@@ -3413,8 +3385,8 @@
           break;
         case UIMSG_PlayerCreation_FaceNext:
           pPlayer = &pParty->pPlayers[pParam];
-          v20 = (char)((int)pPlayer->uFace + 1) % 20;
-          pPlayer->uFace = v20;
+          v20 = (char)((int)pPlayer->uCurrentFace + 1) % 20;
+          pPlayer->uCurrentFace = v20;
           pPlayer->uVoiceID = v20;
           pPlayer->SetInitialStats();
           pPlayer->SetSexByVoice();
@@ -3665,15 +3637,9 @@
 //----- (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;
+  this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x;
+  this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y;
+  this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z;
 }
 
 //----- (004385B5) --------------------------------------------------------
@@ -5393,22 +5359,26 @@
 //----- (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
 
-/*  anglea = (unsigned __int64)(stru_5C6E00->SinCos(sRotX) * (signed __int64)sDepth) >> 16;
+  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(sRotY) * (signed __int64)anglea) >> 16);
   *outy = v.y + ((unsigned __int64)(stru_5C6E00->SinCos(sRotY - stru_5C6E00->uIntegerHalfPi) * (signed __int64)anglea) >> 16);
   *outz = v.z + ((unsigned __int64)(stru_5C6E00->SinCos(sRotX - stru_5C6E00->uIntegerHalfPi) * (signed __int64)sDepth) >> 16);*/
 
  float cosf_x = cosf(3.14159265f * sRotX / 1024.0f),
+       sinf_x = sinf(3.14159265f * sRotX / 1024.0f),
        cosf_y = cosf(3.14159265f * sRotY / 1024.0f),
-       sinf_x = sinf(3.14159265f * sRotX / 1024.0f),
        sinf_y = sinf(3.14159265f * sRotY / 1024.0f);
-
- sDepth = 14000000;
- anglea = (unsigned __int64)(cosf_x * (signed __int64)sDepth) >> 16;
- *outx = v.x + (unsigned __int64)(sinf_y * (signed __int64)anglea);
- *outy = v.y + (unsigned __int64)(cosf_y * (signed __int64)anglea);
+ //sDepth = 14000000;
+ *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16)));
+ *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16)));
  *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16);
 
 }
@@ -5416,16 +5386,9 @@
 //----- (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 = integer_sqrt(*y * *y + *z * *z + *x * *x);
-  *v3 *= 65536 / (v5 | 1);
-  *v4 *= 65536 / (v5 | 1);
-  *z *= 65536 / (v5 | 1);
+  *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
+  *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
+  *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
 }
 
 //----- (0043AE12) --------------------------------------------------------
@@ -5455,10 +5418,7 @@
   }
   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];
+    result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 3]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2];
   }
   return result;
 }
@@ -6049,10 +6009,10 @@
     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;
+    v6 = pPlayers[v1 + 1]->uCurrentFace;
     if ( v6 == 12 || v6 == 13 )
-      papredoll_dbrds[pPlayers[v8]->uFace] = 0;
-    papredoll_flying_feet[pPlayers[v8]->uFace] = 0;
+      papredoll_dbrds[pPlayers[v8]->uCurrentFace] = 0;
+    papredoll_flying_feet[pPlayers[v8]->uCurrentFace] = 0;
     IsPlayerWearingWatersuit[v8] = 1;
   }
 }
@@ -6074,22 +6034,22 @@
   {
     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;
+    papredoll_dbods[v3] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlads[v3] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlaus[v3] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    papredoll_drhs[v3] = pIcons_LOD->LoadTexture(drh_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlhs[v3] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    papredoll_dlhus[v3] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
+    v4 = (int)&(*v2)->uCurrentFace;
     v5 = *(char *)v4;
     if ( *(char *)v4 == 12 || v5 == 13 )
     {
       wsprintfA(pContainer, "pc%02dbrd", v5 + 1);
-      v4 = (int)&(*v2)->uFace;
+      v4 = (int)&(*v2)->uCurrentFace;
       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);
+    papredoll_flying_feet[(*v2)->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     result = v7;
     IsPlayerWearingWatersuit[v7] = 0;
   }
@@ -9159,14 +9119,14 @@
 
 
 //----- (0040D75D) --------------------------------------------------------
-char __fastcall pPrimaryWindow_draws_text(int a1, const char *pText, int *pXY)
-{
+void 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(
+  pPrimaryWindow->DrawText(
            pFontComic,
            *pXY,
            pXY[1] - (((signed int)v4 - HIDWORD(v4)) >> 1) + 3,
@@ -9950,21 +9910,6 @@
 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
 
 
-//----- (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];
-}
-
 //----- (00413FF1) --------------------------------------------------------
 void SetMonthNames()
 {
@@ -10107,23 +10052,25 @@
   Dst.uFrameY = 470 - Dst.uFrameHeight;
   Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
   Dst.uFrameW = 469;
+  //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
   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;
-  Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[157], 3u);
+  Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3);
 }
 
 
 
 //----- (004156F0) --------------------------------------------------------
-void __cdecl GUI_UpdateWindows() 
+void GUI_UpdateWindows() 
 {
   GUIWindow *pWindow; // esi@4
-  unsigned int pWindowType; // eax@4
+  //unsigned int pWindowType; // eax@4
   char *pHint; // edx@66
   GUIButton *pButtonPtr_1C; // ebp@79
   char *pHint1; // edx@80
@@ -10151,7 +10098,6 @@
   for ( i = 1; i <= uNumVisibleWindows; ++i )
   {
     pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
-    pWindowType = pWindow->eWindowType;
     switch (pWindow->eWindowType)
     {
       case WINDOW_OptionsButtons:
@@ -10168,7 +10114,7 @@
       }
       case WINDOW_Options:
       {
-        DrawGameOptions();
+        GameMenuUI_Options_Draw();
         continue;
       }
       case WINDOW_Book:
@@ -10178,7 +10124,7 @@
       }
       case WINDOW_Dialogue:
       {
-        DrawDialogueUI();
+        GameUI_DrawDialogue();
         continue;
       }
       case WINDOW_QuickReference:
@@ -10198,12 +10144,12 @@
       }
       case WINDOW_SpellBook:
       {
-        DrawSpellBookContent();
+        DrawSpellBookContent(pPlayers[uActiveCharacter]);
         continue;
       }
       case WINDOW_GreetingNPC:
       {
-        DrawBranchlessDialogueUI();
+        GameUI_DrawBranchlessDialogue();
         continue;
       }
       case WINDOW_Chest:
@@ -10223,12 +10169,12 @@
       }
       case WINDOW_SaveLoadButtons:
       {
-        sub_4606FE();
+        SaveUI_Draw();
         continue;
       }
       case WINDOW_MainMenu_Load:
       {
-        GameUI_MainMenu_DrawLoad();
+        LoadUI_Draw();
         continue;
       }
       case WINDOW_HouseInterior:
@@ -10491,7 +10437,7 @@
         pButton = (GUIButton *)pWindow->ptr_1C;
         pRenderer->DrawTextureIndexed(pWindow->uFrameY,
                                       pWindow->uFrameX, pButton->pTextures[0]);
-        viewparams->bRedrawGameUI = 1;
+        viewparams->bRedrawGameUI = true;
         continue;
       }
       case WINDOW_CharacterWindow_Inventory:
@@ -10538,7 +10484,7 @@
 }
 
 //----- (00416196) --------------------------------------------------------
-void __cdecl identify_item()
+void identify_item()
 {
   Player *v0; // esi@2
   POINT *v1; // edi@2
@@ -10826,13 +10772,7 @@
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      {
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-        *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-        ++pMessageQueue_50CBD0->uNumMessages;
-      }*/
+
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
@@ -10862,9 +10802,10 @@
           {
             if ( v51 != 5 )
             {
-              v19 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
+              v19 = v0->AddItem(-1, 0xDCu);
               if ( v19 )
-                *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
+               // *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
+                 v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED;
               v20 = v47 + 50 * v15;
               v0->pInventoryItems[pOut.z].uItemID = v51;
               v0->pInventoryItems[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
@@ -10886,9 +10827,10 @@
                 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
               else
                 *(int *)(a2.y + 536) = pParty->pPickedItem.uEnchantmentType;
-              v21 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
+              v21 = v0->AddItem(-1, 0xDCu);
               if ( v21 )
-                *(int *)&v0->field_1F5[36 * v21 + 15] = 1;
+                //*(int *)&v0->field_1F5[36 * v21 + 15] = 1;
+                v0->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED;
               goto LABEL_74;
             }
             goto LABEL_115;
@@ -10898,17 +10840,11 @@
           v23 = 0;
         }
       }
-      v0->_4160CA(v23);
+      v0->ItemsEnchant(v23);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      {
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-        *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-        ++pMessageQueue_50CBD0->uNumMessages;
-      }*/
+
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
@@ -10975,7 +10911,7 @@
 
 
 //----- (00416B01) --------------------------------------------------------
-void __thiscall sub_416B01(void *_this)//PopupWindowForBenefitAndJoinText
+void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText
 {
   int v1; // edi@2
   int v2; // ecx@2
@@ -11361,8 +11297,8 @@
 }
 
 //----- (004179BC) --------------------------------------------------------
-char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2)
-{
+void __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
@@ -11389,7 +11325,7 @@
   v4 = TargetColor(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);
+  Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
 }
 
 //----- (00417AD4) --------------------------------------------------------