changeset 1540:6e4980797714

Merge
author Grumpy7
date Sat, 07 Sep 2013 05:23:16 +0200
parents 5cf28ec7322d (current diff) 3c33f3e44f71 (diff)
children 7d986a396092 778916dfa666
files
diffstat 15 files changed, 745 insertions(+), 939 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/Actor.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -2985,8 +2985,8 @@
   actor->UpdateAnimation();
 
   for (uint i = 0; i < 5; ++i)
-    if (pParty->field_750[i] == actor->pMonsterInfo.uID)
-      pParty->field_75A[i] = true;
+    if (pParty->monster_id_for_hunting[i] == actor->pMonsterInfo.uID)
+      pParty->monster_for_hunting_killed[i] = true;
 
   for (uint i = 0; i < 22; ++i)
     actor->pActorBuffs[i].Reset();
--- a/Arcomage.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/Arcomage.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -447,10 +447,10 @@
 }
 
 //----- (0040DFC1) --------------------------------------------------------
-void ArcomageGame::OnMouseMove(POINT *pXY)
+void ArcomageGame::OnMouseMove(int x, int y)
 {
-  pArcomageGame->mouse_x = pXY->x;
-  pArcomageGame->mouse_y = pXY->y;
+  pArcomageGame->mouse_x = x;
+  pArcomageGame->mouse_y = y;
 }
 
 
--- a/Arcomage.h	Sat Sep 07 05:18:32 2013 +0200
+++ b/Arcomage.h	Sat Sep 07 05:23:16 2013 +0200
@@ -141,7 +141,7 @@
   static bool MsgLoop(int a1, ArcomageGame_stru1 *a2);
   static void PlaySound(unsigned int event_id);
   static void OnMouseClick(char right_left, bool bDown);
-  static void OnMouseMove(POINT *pXY);
+  static void OnMouseMove(int x, int y);
   static void GetCardRect(unsigned int uCardID, RECT *pCardRect);
 
   static void Loop();
--- a/Math.h	Sat Sep 07 05:18:32 2013 +0200
+++ b/Math.h	Sat Sep 07 05:23:16 2013 +0200
@@ -1,11 +1,7 @@
 #pragma once
+
 #include <cassert>
 #include <limits>
-#include <float.h>
-#include <cmath>
-#include <cstdlib>
-#include <ciso646>
-
 
 /*  186 */
 #pragma pack(push, 1)
@@ -28,26 +24,20 @@
 };
 #pragma pack(pop)
 
-
 int fixpoint_sub0(int, int);
 int fixpoint_div(int, int);
 int fixpoint_mul(int, int);
 int fixpoint_from_float(float value);
 
-#ifndef ROUNDING_EPSILON
-#define ROUNDING_EPSILON 0.0000001
-#endif
-
-
 template <typename FloatType>
-int bankersRounding(
+inline int bankersRounding(
   const FloatType& value
   ) {
     assert("Method unsupported for this type" && false);
     return value;
 }
 
-template<> static int bankersRounding<float>(const float& inValue)
+template<> inline int bankersRounding<float>(const float& inValue)
 {
   union Cast
   {
@@ -61,8 +51,7 @@
 
 #pragma push_macro("max")
 #undef max
-
-template<> static int bankersRounding<double>(const double& inValue)
+template<> inline int bankersRounding<double>(const double& inValue)
 {
   double maxValue = std::numeric_limits<int>::max();
   assert(maxValue - 6755399441055744.0 >= inValue);
@@ -75,8 +64,6 @@
   c.d = inValue + 6755399441055744.0;
   return c.l;
 }
-
-
 #pragma pop_macro("max")
 
-extern struct stru193_math *stru_5C6E00;
\ No newline at end of file
+extern struct stru193_math *stru_5C6E00;
--- a/NPC.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/NPC.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -1343,7 +1343,7 @@
       OracleDialogue();
       goto _return;
     case 311:
-      sub_4BBA85_bounties();
+      CheckBountyRespawnAndAward();
     goto _return;
   }*/
   if ( pEventNumber < 200 || pEventNumber > 310 )
@@ -1358,7 +1358,7 @@
         { 
           if ( pEventNumber == 311 )
           {
-            sub_4BBA85_bounties();
+            CheckBountyRespawnAndAward();
           }
           else
           {
--- a/Party.h	Sat Sep 07 05:18:32 2013 +0200
+++ b/Party.h	Sat Sep 07 05:23:16 2013 +0200
@@ -150,9 +150,10 @@
 #pragma pack(push, 1)
 struct Party_stru0
 {
-  int field_0[20];
+  //__int64 field_0[10];
+  __int64 bountyHunting_next_generation_time[10];
  // int field_50[170];
-  __int64 field_50[85];
+  __int64 Shops_next_generation_time[85];//field_50
   __int64 _shop_ban_times[53];
   int field_4A0[20];
   int field_4F0[38];
@@ -265,8 +266,8 @@
   int uNumPrisonTerms;
   unsigned int uNumBountiesCollected;
   int field_74C;
-  __int16 field_750[5];
-  __int16 field_75A[5];
+  __int16 monster_id_for_hunting[5];
+  __int16 monster_for_hunting_killed[5];
   unsigned char   days_played_without_rest;
   unsigned __int8 _quest_bits[64];
   unsigned __int8 pArcomageWins[16];
--- a/UI/UIGuilds.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/UI/UIGuilds.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -160,7 +160,7 @@
       DrawTextAtStatusBar(statusbar_string, 0);
       if ( !v8 )
       {
-        working_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C] - pParty->uTimePlayed);//"Приходите через 14 дней"
+        working_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] - pParty->uTimePlayed);//"Приходите через 14 дней"
         return;
       }
       v12 = pMouse->GetCursorPos(&v51);
--- a/UI/UIHouses.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/UI/UIHouses.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -989,12 +989,7 @@
 {
   int experience_for_next_level; // eax@5
   GUIWindow *v8; // esi@10
-  int v10; // esi@31
-  int v11; // edi@31
-  int v12; // esi@32
-  __int16 v13; // bp@32
-  int v14; // edx@32
-  GUIWindow *v15; // eax@32
+  //int v11; // edi@31
   int v16; // eax@32
   int v17; // eax@33
   int v18; // eax@34
@@ -1004,15 +999,6 @@
   __int16 v22; // ax@107
   __int16 v23; // ax@132
   __int16 v24; // ax@163
-  int v25; // esi@190
-  __int16 v26; // ax@190
-  char v27; // zf@190
-  Player *v28; // edi@192
-  int v29; // eax@204
-  //void *v30; // esi@208
-  //unsigned __int64 v31; // qax@208
-  //signed int v32; // edi@209
-  //int v33; // eax@210
   unsigned int v34; // eax@211
   signed int v36; // esi@227
   int v37; // ecx@227
@@ -1032,7 +1018,6 @@
   void *v52; // eax@260
   signed int v53; // edi@260
   int v54; // eax@262
-  int v56; // [sp+14h] [bp-Ch]@31
 
   if ( !pDialogueWindow->pNumPresenceButton )
     return;
@@ -1041,54 +1026,54 @@
     v8 = window_SpeakInHouse;
   if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
-	  if ( in_current_building_type == BuildingType_Training )
-	  {
-		if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
-		{
-		  experience_for_next_level = 0;
-		  if ( pPlayers[uActiveCharacter]->uLevel > 0 )
-		  {
-			for( uint i = 0; i < pPlayers[uActiveCharacter]->uLevel; i++ )
-			  experience_for_next_level += i + 1;
-		  }
-		  if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] &&
-			  (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * experience_for_next_level)
-			return;
-		}
-		pDialogueWindow->Release();
-		pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
-		pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-					                                    pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-		pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
-		v8 = window_SpeakInHouse;
-	  }
-	  if ( in_current_building_type != BuildingType_Training )
-	  {
-		  v8 = window_SpeakInHouse;
-		  if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
-			  transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7]
-			|| in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
-		  {
-			pDialogueWindow->Release();
-			pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
-			pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-						                                    pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-			pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
-			v8 = window_SpeakInHouse;
-		  }
-		  else if (uActiveCharacter)
-		  {
-			if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
-			  return;
-			v8 = window_SpeakInHouse;
-		  }
-	  }
-	  dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
-	  if ( in_current_building_type < BuildingType_19 )
-	  {
-		ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)];
-		v8 = window_SpeakInHouse;
-	  }
+    if ( in_current_building_type == BuildingType_Training )
+    {
+      if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
+      {
+        experience_for_next_level = 0;
+        if ( pPlayers[uActiveCharacter]->uLevel > 0 )
+        {
+          for( uint i = 0; i < pPlayers[uActiveCharacter]->uLevel; i++ )
+            experience_for_next_level += i + 1;
+        }
+        if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] &&
+          (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * experience_for_next_level)//test experience
+        return;
+      }
+      pDialogueWindow->Release();
+      pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+      pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
+                                                       pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
+      pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
+      v8 = window_SpeakInHouse;
+    }
+    if ( in_current_building_type != BuildingType_Training )
+    {
+      v8 = window_SpeakInHouse;
+      if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
+           transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7]
+          || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
+      {
+        pDialogueWindow->Release();
+        pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+        pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
+                                                         pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
+        pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
+        v8 = window_SpeakInHouse;
+      }
+      else if (uActiveCharacter)
+      {
+        if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
+          return;
+        v8 = window_SpeakInHouse;
+      }
+    }
+    dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
+    if ( in_current_building_type < BuildingType_19 )
+    {
+      ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)];
+      v8 = window_SpeakInHouse;
+    }
   }
   
   //NEW
@@ -1107,7 +1092,7 @@
     case BuildingType_15:
     case BuildingType_16:
     {
-      if ( pParty->field_3C.field_50[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed )
+      if ( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed )
       {
         for ( uint i = 0; i < 12; ++i )
         {
@@ -1119,221 +1104,178 @@
           }
         }
       }
-      else
+      else//generation new books
       {
         SpellBookGenerator();
-        pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000
+        pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000
                                   * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335);
       }
-      //return;
       break;
     }
     case BuildingType_TownHall:
     {
-      if ( uMessageParam == 99 )
+      if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_MESSAGE )
       {
-        v10 = (int)((char *)v8->ptr_1C - 102);
-        v56 = v10;
-        v11 = 8 * v10 + 11325428;
-        if ( pParty->field_3C.field_0[2 * v10 + 1] >= (signed __int64)pParty->uTimePlayed
-             && pParty->field_3C.field_0[2 * v10] >= (signed __int64)pParty->uTimePlayed )
+        if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed )//new generation
         {
-          v13 = 0;
+          pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false;
+          pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
+          pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+          v16 = (int)((char *)window_SpeakInHouse->ptr_1C - 102);
+          if ( !v16 )
+          {
+            while ( 1 )
+            {
+              v24 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+              if ( (unsigned __int16)v24 < 115 || (unsigned __int16)v24 > 132 )
+              {
+                if ( ((unsigned __int16)v24 < 235 || (unsigned __int16)v24 > 252)
+                  && ((unsigned __int16)v24 < 133 || (unsigned __int16)v24 > 150)
+                  && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
+                  && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
+                  && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
+                  && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
+                  && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
+                  && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
+                  && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
+                  && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
+                  && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
+                  break;
+              }
+              pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+            }
+          }
+          if ( v16 == 1 )
+          {
+            while ( 1 )
+            {
+              v23 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+              if ( (unsigned __int16)v23 < 115 || (unsigned __int16)v23 > 132 )
+              {
+                if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
+                  && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
+                  && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
+                  && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
+                  && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
+                  && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
+                  && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
+                  && ((unsigned __int16)v23 < 4 || (unsigned __int16)v23 > 6)
+                  && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
+                  && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
+                  && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
+                  && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
+                  && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
+                  && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
+                  break;
+              }
+              pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+            }
+          }
+          if ( v16 == 2 )
+          {
+            while ( 1 )
+            {
+              v22 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+              if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
+              {
+                if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
+                  && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
+                  && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
+                  && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
+                  && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
+                  && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
+                  && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
+                  && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
+                  && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
+                  && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
+                  && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
+                  break;
+              }
+              pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+            }
+          }
+          if ( v16 == 3 )
+          {
+            while ( 1 )
+            {
+              v21 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+              if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
+              {
+                if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
+                  && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
+                  && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
+                  && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
+                  && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
+                  && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
+                  && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
+                  && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
+                  && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
+                  && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
+                  && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
+                  && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
+                  && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
+                  && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
+                  break;
+              }
+              pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+            }
+          }
+          if ( v16 == 4 )
+          {
+            while ( 1 )
+            {
+              v20 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+              if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
+              {
+                if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
+                  && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
+                  && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
+                  && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
+                  && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
+                  && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
+                  && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
+                  && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
+                  && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
+                  && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
+                  && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
+                  && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
+                  && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
+                  && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
+                  && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
+                  && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
+                  && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
+                  && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
+                  break;
+              }
+              pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
+            }
+          }
+        }
+        bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
+        if ( !pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] )
+        {
+          bountyHunting_text = pNPCTopics[351].pText;//"В этом месяцу назначена награда за голову %s..."
+          if ( !pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] )
+            bountyHunting_text = pNPCTopics[353].pText;//"Кое кто уже приходил в этом месяце за наградой"
         }
         else
         {
-          v12 = v10;
-          v13 = 0;
-          pParty->field_75A[v12] = 0;
-          *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
-          v14 = rand() % 258;
-          v15 = window_SpeakInHouse;
-          pParty->field_750[v12] = v14 + 1;
-          v16 = (int)((char *)v15->ptr_1C - 102);
-          if ( v16 )
+          if ( pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] > 0 )//get prize
           {
-            v17 = v16 - 1;
-            if ( v17 )
-            {
-              v18 = v17 - 1;
-              if ( v18 )
-					{
-						v19 = v18 - 1;
-						if ( v19 )
-						{
-							if ( v19 == 1 )
-							{
-								while ( 1 )
-								{
-									v20 = pParty->field_750[v12];
-									if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
-									{
-										if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
-										&& ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
-										&& ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
-										&& ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
-										&& ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
-										&& ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
-										&& ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
-										&& ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
-										&& ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
-										&& ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
-										&& ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
-										&& ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
-										&& ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
-										&& ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
-										&& ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
-										&& ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
-										&& ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
-										&& ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
-											break;
-									}
-									pParty->field_750[v12] = rand() % 258 + 1;
-								}
-							}
-						}
-						else
-						{
-							while ( 1 )
-							{
-								v21 = pParty->field_750[v12];
-								if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
-								{
-								if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
-									&& ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
-									&& ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
-									&& ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
-									&& ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
-									&& ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
-									&& ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
-									&& ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
-									&& ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
-									&& ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
-									&& ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
-									&& ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
-									&& ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
-									&& ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
-										break;
-								}
-								pParty->field_750[v12] = rand() % 258 + 1;
-							}
-						}
-					}
-					else
-					{
-						while ( 1 )
-						{
-							v22 = pParty->field_750[v12];
-							if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
-							{
-								if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
-								&& ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
-								&& ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
-								&& ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
-								&& ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
-								&& ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
-								&& ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
-								&& ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
-								&& ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
-								&& ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
-								&& ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
-								break;
-							}
-							pParty->field_750[v12] = rand() % 258 + 1;
-						}
-					}
-				}
-				else
-				{
-					while ( 1 )
-					{
-						v23 = pParty->field_750[v12];
-						if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
-						{
-						if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
-							&& ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
-							&& ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
-							&& ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
-							&& ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
-							&& ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
-							&& ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
-							&& ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
-							&& ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
-							&& ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
-							&& ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
-							&& ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
-							&& ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
-							&& ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
-								break;
-						}
-						pParty->field_750[v12] = rand() % 258 + 1;
-					}
-				}
-			}
-			else
-			{
-				while ( 1 )
-				{
-					v24 = pParty->field_750[v12];
-					if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
-					{
-						if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
-						&& ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
-						&& ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
-						&& ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
-						&& ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
-						&& ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
-						&& ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
-						&& ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
-						&& ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
-						&& ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
-						&& ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
-							break;
-					}
-					pParty->field_750[v12] = rand() % 258 + 1;
-				}
-			}
-			v10 = v56;
-		}
-		v25 = v10;
-		v26 = pParty->field_750[v25];
-		v27 = pParty->field_75A[v25] == v13;
-		word_F8B1A0 = pParty->field_750[v25];
-		if ( v27 )
-		{
-			//v1 = 0;
-			v27 = v26 == v13;
-			v29 = (int)pNPCTopics[351].pText;
-			if ( v27 )
-				v29 = (int)pNPCTopics[353].pText;
-			dword_F8B1A4 = (char *)v29;
-		}
-		else
-		{
-			if ( v26 != v13 )
-			{
-				party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
-				v28 = pParty->pPlayers;
-				do
-				{
-					v28->SetVariable(VAR_Award, 86);
-					++v28;
-				}
-				while ( (signed int)v28 < (signed int)pParty->pHirelings );
-				pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
-				pParty->field_750[v25] = v13;
-				pParty->field_75A[v25] = v13;
-			}
-			//v1 = 0;
-			dword_F8B1A4 = pNPCTopics[352].pText;
-		}
-	}
-	else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_100 )
-	{
-		pKeyActionMap->EnterText(1, 10, v8);
-	}
-	break;
-	}
+            party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel, 0);
+            for ( uint i = 0; i < 4; ++i )
+              pParty->pPlayers[i].SetVariable(VAR_Award, 86);
+            pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel;
+            pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = 0;
+            pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false;
+          }
+          bountyHunting_text = pNPCTopics[352].pText;//"Поздравляю! Вы успешно..."
+        }
+      }
+      else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_PAY_FINE )
+        pKeyActionMap->EnterText(1, 10, v8);
+      break;
+    }
     case BuildingType_Bank:
     {
       if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
@@ -1583,7 +1525,7 @@
 			  v25 = v10;
 			  v26 = pParty->field_750[v25];
 			  v27 = pParty->field_75A[v25] == v13;
-			  word_F8B1A0 = pParty->field_750[v25];
+			  bountyHunting_monster_id_for_hunting = pParty->field_750[v25];
 			  if ( v27 )
 			  {
 				//v1 = 0;
@@ -1591,7 +1533,7 @@
 				v29 = (int)pNPCTopics[351].pText;
 				if ( v27 )
 				  v29 = (int)pNPCTopics[353].pText;
-				dword_F8B1A4 = (char *)v29;
+				bountyHunting_text = (char *)v29;
 			  }
 			  else
 			  {
@@ -1610,7 +1552,7 @@
 				  pParty->field_75A[v25] = v13;
 				}
 				//v1 = 0;
-				dword_F8B1A4 = pNPCTopics[352].pText;
+				bountyHunting_text = pNPCTopics[352].pText;
 			  }
 			}
 			else if ( uMessageParam == 100 )
@@ -1662,11 +1604,11 @@
     case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
     case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
     {
-      if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
+      if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
       {
         GenerateStandartShopItems();
         GenerateSpecialShopItems();
-        pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335);
+        pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335);
       }
       if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_STANDARD )
       {
@@ -1745,8 +1687,6 @@
     {
       if( uMessageParam >= HOUSE_DIALOGUE_36 && uMessageParam <= HOUSE_DIALOGUE_GUILD_LEARN_SKILL )
       {
-        //v35 = pPlayers[uActiveCharacter];
-        //v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0);
         v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0);
         v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
         if ( v37 < v36 / 3 )
@@ -1858,7 +1798,7 @@
     sub_421B2C_PlaceInInventory_or_DropPickedItem();
     return;
   }
-  if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
+  if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
   {
     GenerateStandartShopItems();
     GenerateSpecialShopItems();
@@ -1869,7 +1809,7 @@
         //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
         + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C)
                          * 0.033333335);
-    pParty->field_3C.field_50[v40] = v41;
+    pParty->field_3C.Shops_next_generation_time[v40] = v41;
    
   }
   v42 = v8->ptr_1C;
@@ -1976,11 +1916,6 @@
   unsigned int v3; // eax@1
   signed int v4; // ebx@1
   stru365_travel_info *v5; // esi@7
-  //int v6; // eax@9
-  //int v7; // eax@9
-  //int v8; // eax@12
-  //int v9; // edi@12
-  //int v10; // edx@12
   int v11; // ecx@12
   signed int v12; // esi@13
   signed int v13; // edi@14
@@ -2300,177 +2235,131 @@
 //----- (004B7911) --------------------------------------------------------
 void  TownHallDialog()
 {
-  GUIWindow *v0; // eax@4
   int v1; // eax@10
   int v2; // esi@10
-  GUIFont *v3; // ST20_4@20
-  int v4; // eax@20
-  MonsterInfo *v5; // edi@21
-  unsigned int v6; // ST20_4@21
-  char *v7; // ST1C_4@21
-  unsigned int v8; // eax@21
-  int v9; // esi@21
-  char *v10; // eax@23
-  signed int v11; // ebx@24
-  signed int i; // esi@26
-  int v13; // eax@27
-  GUIWindow *v14; // ecx@28
-  __int64 v15; // qax@28
+  signed int pStringSum; // ebx@24
   signed int v16; // ebx@28
   int v17; // ebx@28
-  unsigned __int8 v18; // sf@28
-  char **v19; // edi@29
-  GUIButton *v20; // eax@30
-  GUIButton *v21; // esi@30
-  int v22; // eax@30
+  GUIButton *pButton; // eax@30
+  int pTextHeight; // eax@30
   unsigned int v23; // ecx@30
-  unsigned __int16 v24; // ax@30
-  GUIWindow a1; // [sp+Ch] [bp-110h]@21
-  GUIWindow w; // [sp+60h] [bp-BCh]@21
-  GUIWindow _this; // [sp+B4h] [bp-68h]@1
-  int v28; // [sp+108h] [bp-14h]@1
+  unsigned __int16 pTextColor; // ax@30
+  GUIWindow window; // [sp+60h] [bp-BCh]@21
+  GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1
   int v29; // [sp+10Ch] [bp-10h]@28
-  int v30; // [sp+110h] [bp-Ch]@1
   int v31; // [sp+114h] [bp-8h]@29
   GUIFont *pOutString; // [sp+118h] [bp-4h]@21
 
-  memcpy(&_this, window_SpeakInHouse, sizeof(_this));
-  _this.uFrameX = 483;
-  _this.uFrameWidth = 148;
-  _this.uFrameZ = 334;
-  v28 = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
-  _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf.data(), 3u);
+  memcpy(&townHall_window, window_SpeakInHouse, sizeof(townHall_window));
+  townHall_window.uFrameX = 483;
+  townHall_window.uFrameWidth = 148;
+  townHall_window.uFrameZ = 334;
+  sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);//Текущий штраф
+  townHall_window.DrawTitleText(pFontArrus, 0, 260, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   switch(dialog_menu_id)
   {
-	case HOUSE_DIALOGUE_MAIN:
-		{
-		v11 = 1;
-		pOutString = 0;
-		pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
-		if ( pParty->uFine )
-		{
-			pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
-			v11 = 2;
-		}
-		for ( i = 0; i < v11; ++i )
-		{
-			v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
-			pOutString = (GUIFont *)((char *)pOutString + v13);
-		}
-		v29 = (100 - (signed int)pOutString) / v11;
-		v14 = pDialogueWindow;
-		v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
-		v16 = v15 - HIDWORD(v15);
-		LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
-		HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
-		v17 = (v16 >> 1) - v29 / 2 + 158;
-		v18 = -pDialogueWindow->pNumPresenceButton < 0;
-		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-		if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
-		{
-			v31 = 2;
-			v19 = pShopOptions.data();
-			do
-			{
-				v20 = v14->GetControl((unsigned int)pOutString);
-				v21 = v20;
-				v20->uY = v29 + v17;
-				v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
-				v23 = v21->uY;
-				v21->uHeight = v22;
-				v17 = v23 + v22 - 1;
-				v21->uW = v17;
-				v24 = v30;
-				if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
-					v24 = v28;
-				_this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
-				v14 = pDialogueWindow;
-				++v31;
-				++v19;
-				pOutString = (GUIFont *)((char *)pOutString + 1);
-			}
-			while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-		}
-		break;
-		}
-
-	case HOUSE_DIALOGUE_TOWNHALL_99:
-		{
-		v5 = &pMonsterStats->pInfos[word_F8B1A0];
-		v6 = TargetColor(0xFFu, 0xFFu, 0xFFu);
-		v7 = v5->pName;
-		v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-		sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", v8, v7, v6);
-		sprintf(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * v5->uLevel);
-		current_npc_text = pTmpBuf2.data();
-		memcpy(&a1, pDialogueWindow, sizeof(a1));
-		w.uFrameWidth = 458;
-		w.uFrameZ = 457;
-		pOutString = pFontArrus;
-		v9 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &w, 13, 0) + 7;
-		if ( 352 - v9 < 8 )
-		{
-			pOutString = pFontCreate;
-			v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
-		}
-
-		auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
-		pRenderer->GetLeather(8, 352 - v9, pTex, pTex->uTextureHeight - v9);
-		pRenderer->DrawTextureIndexed(8, 347 - v9, pTexture_591428);
-		v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 13, 0);
-		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
-		break;
-		}
-	case HOUSE_DIALOGUE_TOWNHALL_100:
-		{
-		v0 = window_SpeakInHouse;
-		if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
-		{
-			sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay"   "How Much?"
-			_this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf.data(), 3u);
-			_this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
-			v3 = pFontArrus;
-			v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-			_this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
-			return;
-		}
-		if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
-		{
-			v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-			v2 = v1;
-			if ( v1 <= 0 )
-			{
-				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-				return;
-			}
-			if ( v1 > pParty->uNumGold )
-			{
-				PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-				v2 = pParty->uNumGold;
-			}
-			if ( v2 > pParty->uFine )
-				v2 = pParty->uFine;
-			Party::TakeGold(v2);
-			pParty->uFine -= v2;
-			if ( pParty->uFine < 0 )
-				pParty->uFine = 0;
-			if ( uActiveCharacter )
-				pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-			v0 = window_SpeakInHouse;
-		}
-		if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
-		{
-			v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-		}
-		break;
-		}
-	default:
-		{
-		break;
-		}
+    case HOUSE_DIALOGUE_MAIN:
+    {
+      pStringSum = 1;
+      pTextHeight = 0;
+      pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];//Охота за вознаграждение
+      if ( pParty->uFine > 0 )
+      {
+        pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];//Заплатить штраф
+        pStringSum = 2;
+      }
+      for ( uint i = 0; i < pStringSum; ++i )
+        pTextHeight += pFontArrus->CalcTextHeight(pShopOptions[i], &townHall_window, 0, 0);
+      v29 = (100 - pTextHeight) / pStringSum;
+      v16 = 80 - pStringSum * ((100 - pTextHeight) / pStringSum);
+      v17 = (v16 / 2) - v29 / 2 + 158;
+      if ( pDialogueWindow->pNumPresenceButton > 0 )
+      {
+        v31 = 2;
+        uint j = 0;
+        for ( uint i = pDialogueWindow->pStartingPosActiveItem;
+              i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
+        {
+          pButton = pDialogueWindow->GetControl(i);
+          pButton->uY = v29 + v17;
+          pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0);
+          v23 = pButton->uY;
+          pButton->uHeight = pTextHeight;
+          v17 = v23 + pTextHeight - 1;
+          pButton->uW = v17;
+          pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+          if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
+            pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          townHall_window.DrawTitleText(pFontArrus, 0, v23, pTextColor, pShopOptions[j], 3);
+          ++v31;
+          ++j;
+        }
+      }
+      break;
+    }
+    case HOUSE_DIALOGUE_TOWNHALL_MESSAGE:
+    {
+      sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu),
+      pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName, TargetColor(0xFFu, 0xFFu, 0xFFu));
+      sprintf(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].uLevel);
+      current_npc_text = pTmpBuf2.data();
+      memcpy(&window, pDialogueWindow, sizeof(window));
+      window.uFrameWidth = 458;
+      window.uFrameZ = 457;
+      pOutString = pFontArrus;
+      pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &window, 13, 0) + 7;
+      if ( 352 - pTextHeight < 8 )
+      {
+        pOutString = pFontCreate;
+        pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7;
+      }
+      pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
+      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0);
+      break;
+    }
+    case HOUSE_DIALOGUE_TOWNHALL_PAY_FINE:
+    {
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
+      {
+        sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay"   "How Much?"
+        townHall_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        townHall_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        townHall_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
+        return;
+      }
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
+      {
+        v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+        v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+        if ( v1 <= 0 )
+        {
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          return;
+        }
+        if ( v1 > pParty->uNumGold )
+        {
+          PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
+          v2 = pParty->uNumGold;
+        }
+        if ( v2 > pParty->uFine )
+          v2 = pParty->uFine;
+        Party::TakeGold(v2);
+        pParty->uFine -= v2;
+        if ( pParty->uFine < 0 )
+          pParty->uFine = 0;
+        if ( uActiveCharacter )
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+      }
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
+      {
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      }
+      break;
+    }
+    default:
+      break;
   }
   return;
 }
@@ -4174,7 +4063,6 @@
           v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C);
 LABEL_44:
           v15 = v33;
-LABEL_45:
           v16 = (GUIButton *)pInString;
           goto LABEL_49;
         }
@@ -4187,15 +4075,16 @@
         v28 = v27 - 1;
         if ( !v28 )
         {
-          v29 = (char *)&pMonsterStats + 88 * word_F8B1A0;
+          v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName;
           v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
           v31 = *(int *)v29;
           v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
           sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30);
-          sprintfex(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]);
+          sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]);
           current_npc_text = pTmpBuf2.data();
           v15 = "";
-          goto LABEL_45;
+          v16 = (GUIButton *)pInString;
+          goto LABEL_49;
         }
         if ( v28 != 10 )
           goto LABEL_41;
@@ -4237,7 +4126,8 @@
             sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName);
             sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data());
             current_npc_text = pTmpBuf2.data();
-            goto LABEL_45;
+            v16 = (GUIButton *)pInString;
+            goto LABEL_49;
           }
           v21 = v20 - 1;
           if ( !v21 )
--- a/UI/UIHouses.h	Sat Sep 07 05:18:32 2013 +0200
+++ b/UI/UIHouses.h	Sat Sep 07 05:23:16 2013 +0200
@@ -32,8 +32,8 @@
   HOUSE_DIALOGUE_LEARN_SKILLS = 96,
   HOUSE_DIALOGUE_97 = 97,
   HOUSE_DIALOGUE_98 = 98,
-  HOUSE_DIALOGUE_TOWNHALL_99 = 99,
-  HOUSE_DIALOGUE_TOWNHALL_100 = 100,
+  HOUSE_DIALOGUE_TOWNHALL_MESSAGE = 99,
+  HOUSE_DIALOGUE_TOWNHALL_PAY_FINE = 100,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES = 102,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS = 103,
--- a/UI/UIShops.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/UI/UIShops.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -70,7 +70,7 @@
   int v61; // eax@90
   int v62; // ecx@90
   ItemGen *pItemInShop; // esi@90
-  int v64; // eax@95
+  //int v64; // eax@95
   int all_text_height; // esi@96
   char **v66; // edi@96
   int v67; // eax@97
@@ -233,8 +233,8 @@
               pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];
             if ( !v56 || !Str )
             {
-              v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2);
-              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)],
+                                       uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
               pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
               dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
             }
@@ -248,7 +248,7 @@
         }
         else
         {
-          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);//Приходите через 7 дней
           pNumActiveItem = 0; //added
         }
       }
@@ -424,22 +424,20 @@
               pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
             if ( !v56 || !Str )
             {
-              v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2);
-              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)],
+                                       uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3);
             }
             else
             {
               v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3);
             }
           }
         }
         else
         {
-          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
           pNumActiveItem = 0; //added
         }
       }
@@ -769,7 +767,7 @@
         dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
         return;
       }
-      dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
+      dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
       return;
     }
     break;
@@ -841,7 +839,7 @@
         dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
         return;
       }
-      dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
+      dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
       return;
     }
     break;
@@ -1018,7 +1016,7 @@
         while ( v104 < 8 );
         return;
       }
-      dialog_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C]-  pParty->uTimePlayed);
+      dialog_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]-  pParty->uTimePlayed);
       return;
     }
     break;
@@ -1351,7 +1349,7 @@
         DrawTextAtStatusBar(v65, 0);
         if ( !v109 )
         {
-          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
           return;
         }
         v66 = pMouse->GetCursorPos(&v98);
@@ -1551,7 +1549,7 @@
         DrawTextAtStatusBar(v65, 0);
         if ( !v109 )
         {
-          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
           return;
         }
         v66 = pMouse->GetCursorPos(&v98);
@@ -1932,7 +1930,7 @@
       DrawTextAtStatusBar(v69, 0);
       if ( !v117 )
       {
-        dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+        dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
         return;
       }
       v70 = pMouse->GetCursorPos(&v102);
@@ -2063,7 +2061,7 @@
       DrawTextAtStatusBar(v69, 0);
       if ( !v117 )
       {
-        dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+        dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
         return;
       }
       v70 = pMouse->GetCursorPos(&v102);
--- a/VectorTypes.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/VectorTypes.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -1,6 +1,7 @@
 #include <utility>
 
 #include "mm7_data.h"
+#include "Math.h"
 
 //----- (004621DA) --------------------------------------------------------
 uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z)
@@ -25,14 +26,14 @@
 template <class T>
 void Vec3<T>::Normalize_float()
 {
-  long double x = this->x;
-  long double y = this->y;
-  long double z = this->z;
-  long double s = sqrtl(x * x + y * y + z * z);
+  double x = this->x;
+  double y = this->y;
+  double z = this->z;
+  double s = sqrt(x * x + y * y + z * z);
 
-  this->x = (T)(x / s);
-  this->y = (T)(y / s);
-  this->z = (T)(z / s);
+  this->x = bankersRounding(x / s);
+  this->y = bankersRounding(y / s);
+  this->z = bankersRounding(z / s);
 }
 
 //----- (0043AA99) --------------------------------------------------------
--- a/mm7_2.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/mm7_2.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -218,81 +218,59 @@
 }
 
 //----- (004BBA85) --------------------------------------------------------
-const char *sub_4BBA85_bounties()
+void CheckBountyRespawnAndAward()
 {
-  int v0; // edi@1
-  signed __int64 v1; // qax@2
   int i; // eax@2
-  int v3; // edx@3
-  int v4; // edi@14
-  __int16 v5; // ax@14
-  char v6; // zf@14
-  Player *v7; // ebx@16
-  const char *result; // eax@19
+  int rand_monster_id; // edx@3
 
   uDialogueType = 83;
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
+  pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
                  pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
-  pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0);
+  pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_0, 83, 0, "", 0);
   pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
-  v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102);
-  if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed )
-  {
-    pParty->field_75A[v0] = 0;
-    __debugbreak(); // starting year-related constant here;
-    v1 = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015))
-                        * 0.033333335);
-    pParty->field_3C.field_0[2 * v0] = v1;
-    pParty->field_3C.field_0[2 * v0 + 1] = HIDWORD(v1);
+  //get new monster for hunting
+  if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed )
+  {
+    pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false;
+    pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
     for ( i = rand(); ; i = rand() )
     {
-      v3 = i % 258 + 1;
-      pParty->field_750[v0] = v3;
-      if ( (unsigned __int16)v3 < 0x73u || (unsigned __int16)v3 > 0x84u )
+      rand_monster_id = i % 258 + 1;
+      pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = rand_monster_id;
+      if ( (unsigned __int16)rand_monster_id < 0x73u || (unsigned __int16)rand_monster_id > 0x84u )
       {
-        if ( ((unsigned __int16)v3 < 0xEBu || (unsigned __int16)v3 > 0xFCu)
-          && ((unsigned __int16)v3 < 0x85u || (unsigned __int16)v3 > 0x96u)
-          && ((unsigned __int16)v3 < 0x97u || (unsigned __int16)v3 > 0xBAu)
-          && ((unsigned __int16)v3 < 0xC4u || (unsigned __int16)v3 > 0xC6u) )
+        if ( ((unsigned __int16)rand_monster_id < 0xEBu || (unsigned __int16)rand_monster_id > 0xFCu)
+          && ((unsigned __int16)rand_monster_id < 0x85u || (unsigned __int16)rand_monster_id > 0x96u)
+          && ((unsigned __int16)rand_monster_id < 0x97u || (unsigned __int16)rand_monster_id > 0xBAu)
+          && ((unsigned __int16)rand_monster_id < 0xC4u || (unsigned __int16)rand_monster_id > 0xC6u) )
           break;
       }
     }
   }
-  v4 = v0;
-  v5 = pParty->field_750[v4];
-  v6 = pParty->field_75A[v4] == 0;
-  word_F8B1A0 = pParty->field_750[v4];
-  if ( v6 )
-  {
-    v6 = v5 == 0;
-    result = pNPCTopics[351].pText;
-    if ( v6 )
-      result = pNPCTopics[353].pText;
-  }
-  else
-  {
-    if ( v5 )
+  bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)];
+  if ( !pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
+  {
+    bountyHunting_text = pNPCTopics[351].pText;
+    if ( !pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
+      bountyHunting_text = pNPCTopics[353].pText;
+  }
+  else//get prize
+  {
+    if ( pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
     {
-      party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v5].uLevel, 0);
-      v7 = pParty->pPlayers;
-      do
-      {
-        v7->SetVariable(VAR_Award, 86);
-        ++v7;
-      }
-      while ( (signed int)v7 < (signed int)pParty->pHirelings );
-      pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v4]].uLevel;
-      pParty->field_750[v4] = 0;
-      pParty->field_75A[v4] = 0;
+      party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0);
+      for ( uint i = 0; i < 4; ++i )
+        pParty->pPlayers[i].SetVariable(VAR_Award, 86);
+      pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel;
+      pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = 0;
+      pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false;
     }
-    result = pNPCTopics[352].pText;
-  }
-  dword_F8B1A4 = (char *)result;
-  return result;
+    bountyHunting_text = pNPCTopics[352].pText;
+  }
 }
 
 //----- (004BBCDD) --------------------------------------------------------
@@ -334,7 +312,7 @@
       {
         uDialogueType = 91;
         v4 = pParty->pPlayers;
-        ++*((char *)&pParty->field_75A[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1);
+        ++*((char *)&pParty->monster_for_hunting_killed[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1);
         do
         {
           v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3);
@@ -707,7 +685,7 @@
   char *v9; // eax@14
   unsigned int v10; // eax@25
   GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1
-  MSG Msg; // [sp+88h] [bp-48h]@22
+  //MSG Msg; // [sp+88h] [bp-48h]@22
   unsigned int v14; // [sp+A4h] [bp-2Ch]@5
   void *v15; // [sp+A8h] [bp-28h]@1
   char *pInString; // [sp+ACh] [bp-24h]@5
@@ -827,15 +805,12 @@
     LODWORD(v23) = GetTickCount() + 5000;
     while ( (unsigned int)v23 > GetTickCount() )
       ;
-    while ( 1 )
+    for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
     {
-      v10 = PeekMessageA(&Msg, 0, 0, 0, 1u);
-      if ( !v10 )
-        break;
-      if ( Msg.message == 18 )
+      if (msg.message == WM_QUIT)
         Game_DeinitializeAndTerminate(0);
-      TranslateMessage(&Msg);
-      DispatchMessageA(&Msg);
+      TranslateMessage(&msg);
+      DispatchMessage(&msg);
     }
     if ( pMessageQueue_50CBD0->uNumMessages )
     {
@@ -846,12 +821,12 @@
     pKeyActionMap->uLastKeyPressed = 0;
     do
     {
-      while ( PeekMessageA(&Msg, 0, 0, 0, 1u) )
+      for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
       {
-        if ( Msg.message == 18 )
+        if (msg.message == WM_QUIT)
           Game_DeinitializeAndTerminate(0);
-        TranslateMessage(&Msg);
-        DispatchMessageA(&Msg);
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
       }
     }
     while ( !pKeyActionMap->uLastKeyPressed );
@@ -3193,13 +3168,12 @@
       pWindow = pGUIWindow_CurrentMenu;
     }
 
-    MSG msg;
-    while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) )
+    for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
     {
       if (msg.message == WM_QUIT)
         Game_DeinitializeAndTerminate(0);
       TranslateMessage(&msg);
-      DispatchMessageA(&msg);
+      DispatchMessage(&msg);
     }
     if (dword_6BE364_game_settings_1 & 0x0100)
     {
@@ -3280,33 +3254,41 @@
 }
 
 //----- (004637EB) --------------------------------------------------------
-int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam)
+LRESULT CALLBACK aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-  HANDLE v6; // eax@32
-  HDC v10; // edi@50
-  int v11; // esi@50
-  signed int v13; // eax@135
-  char v29; // dl@209
-  bool v31; // ebx@211
-  float v33; // ST04_4@246
-  float v34; // ST04_4@254
-  struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
-  int pXY[2]; // [sp+64h] [bp-8h]@261
-  int a2; // [sp+7Ch] [bp+10h]@50
-
-  switch (Msg)
-  {
-    case WM_SIZING:  return 1;
+  //HANDLE v6; // eax@32
+  //HDC v10; // edi@50
+  //int v11; // esi@50
+  //signed int v13; // eax@135
+  //char v29; // dl@209
+  //bool v31; // ebx@211
+  //float v33; // ST04_4@246
+  //float v34; // ST04_4@254
+  //struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
+  //int pXY[2]; // [sp+64h] [bp-8h]@261
+  //int a2; // [sp+7Ch] [bp+10h]@50
+
+  switch (uMsg)
+  {
+    case WM_SIZING: 
+      return 1;
+
     case WM_SHOWWINDOW:
     case WM_GETTEXT:
-    case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam);
+    case WM_SETTEXT:
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_DESTROY:
+      SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
+      PostQuitMessage(0);
+      return 0;
 
     case WM_WINDOWPOSCHANGED:
     {
       if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
         BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
 
-      return DefWindowProcW(hWnd, Msg, wParam, lParam);
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
     }
 
     case WM_CHAR:
@@ -3314,13 +3296,13 @@
       if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C)
         GUI_HandleHotkey(wParam);
     }
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
 
 
     case WM_DEVICECHANGE:
     {
       if (wParam == 0x8000)          // CD or some device has been inserted - notify InsertCD dialog
-        PostMessageA(hInsertCDWindow, WM_USER + 1, 0, 0);
+        PostMessage(hInsertCDWindow, WM_USER + 1, 0, 0);
       return 0;
     }
 
@@ -3332,7 +3314,7 @@
 
         case 101:  // Quit game
         case 40001:
-          SendMessageA(::hWnd, WM_DESTROY, 0, 0);
+          SendMessage(hWnd, WM_DESTROY, 0, 0);
         return 0;
 
 
@@ -3501,355 +3483,311 @@
 
       }
     }
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
-  };
-
-  if ( Msg > WM_SYSCOMMAND )
-  {
-    switch ( Msg )
-    {
-      case WM_LBUTTONDOWN:
-        if ( pArcomageGame->bGameInProgress )
-        {
-          pArcomageGame->stru1.field_0 = 7;
-          ArcomageGame::OnMouseClick(0, 1);
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-        goto __handle_mouse_click;
-
-      case WM_RBUTTONDOWN:
-        v31 = 0;
-        if ( !pArcomageGame->bGameInProgress )
-          //goto LABEL_240;
-        {
-          if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
-            pVideoPlayer->bStopBeforeSchedule = 1;
-
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-          if (pGame)
-          {
-            v33 = pGame->pIndoorCameraD3D->GetPickDepth();
-            pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter);
-          }
-
-            sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-
-        }
-
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_LBUTTONDOWN:
+      if (pArcomageGame->bGameInProgress)
+      {
+        pArcomageGame->stru1.field_0 = 7;
+        ArcomageGame::OnMouseClick(0, true);
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+
+      goto __handle_mouse_click;
+
+    case WM_RBUTTONDOWN:
+      if (pArcomageGame->bGameInProgress)
+      {
         pArcomageGame->stru1.field_0 = 8;
-        ArcomageGame::OnMouseClick(1, 1);
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      case WM_LBUTTONUP:
-        if ( !pArcomageGame->bGameInProgress )
-          //goto LABEL_218;
-        {
-          back_to_game();
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-        pArcomageGame->stru1.field_0 = 3;
-        ArcomageGame::OnMouseClick(0, 0);
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      case WM_RBUTTONUP:
-        if ( !pArcomageGame->bGameInProgress )
-        {
-//LABEL_218:
-
-          back_to_game();
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-        pArcomageGame->stru1.field_0 = 4;
-        ArcomageGame::OnMouseClick(1, false);
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-
-      case WM_LBUTTONDBLCLK:
-        if ( pArcomageGame->bGameInProgress )
-        {
-          pArcomageGame->stru1.field_0 = 7;
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
+        ArcomageGame::OnMouseClick(1, true);
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+
+      if (pVideoPlayer->pVideoFrame.pPixels)
+        pVideoPlayer->bStopBeforeSchedule = 1;
+
+      pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
+
+      if (pGame)
+      {
+        pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 0, &vis_sprite_filter_2, &vis_door_filter);
+      }
+
+      sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+
+    case WM_LBUTTONUP:
+      if ( !pArcomageGame->bGameInProgress )
+      {
+        back_to_game();
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+      pArcomageGame->stru1.field_0 = 3;
+      ArcomageGame::OnMouseClick(0, 0);
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+    case WM_RBUTTONUP:
+      if ( !pArcomageGame->bGameInProgress )
+      {
+        back_to_game();
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+      pArcomageGame->stru1.field_0 = 4;
+      ArcomageGame::OnMouseClick(1, false);
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_LBUTTONDBLCLK:
+      if ( pArcomageGame->bGameInProgress )
+      {
+        pArcomageGame->stru1.field_0 = 7;
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
         
 __handle_mouse_click:
-        if ( pVideoPlayer->pVideoFrame.pPixels )
+      if (pVideoPlayer->pVideoFrame.pPixels)
+        pVideoPlayer->bStopBeforeSchedule = 1;
+
+      pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
+
+      if (GetCurrentMenuID() == MENU_CREATEPARTY)
+      {
+        UI_OnKeyDown(VK_SELECT);
+      }
+
+      if (pGame)
+        pGame->PickMouse(512.0, LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_3, &vis_door_filter);
+
+      UI_OnMouseLeftClick(0);
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_RBUTTONDBLCLK:
+      if ( !pArcomageGame->bGameInProgress )
+      {
+        if (pVideoPlayer->pVideoFrame.pPixels)
           pVideoPlayer->bStopBeforeSchedule = 1;
 
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-
-        if (GetCurrentMenuID() != MENU_CREATEPARTY)
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        else
+        pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
+
+        if (pGame)
         {
-          UI_OnKeyDown(VK_SELECT);
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        }
-
-
-          if (pGame)
-            pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter);
-
-          UI_OnMouseLeftClick(0);
-
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-
-      case WM_RBUTTONDBLCLK:
-        v31 = 0;
-        if ( !pArcomageGame->bGameInProgress )
-        {
-//LABEL_240:
-          if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
-            pVideoPlayer->bStopBeforeSchedule = 1;
-
-            pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-          if (pGame)
-          {
-            v33 = pGame->pIndoorCameraD3D->GetPickDepth();
-            pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter);
-          }
-
-            sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-
+          pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_2, &vis_door_filter);
         }
-        pArcomageGame->stru1.field_0 = 8;
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      case WM_MBUTTONDOWN:
-        if ( pRenderer->pRenderD3D )
-        {
-          if ( pGame )
-          {
-            v34 = pGame->pIndoorCameraD3D->GetPickDepth();
-            pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter);
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          }
-        }
-        if ( !pGame )
-          //goto _def_wnd_proc;
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      case WM_MOUSEMOVE:
-        if ( pArcomageGame->bGameInProgress )
-        {
-          pXY[0] = (unsigned __int16)lParam;
-          pXY[1] = lParam >> 16;
-          ArcomageGame::OnMouseMove((POINT *)pXY);
-          ArcomageGame::OnMouseClick(0, wParam & 1);
-          v29 = (wParam >> 1) & 1;
-          ArcomageGame::OnMouseClick(1, v29 != 0);
-        }
-        else
-        {
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        }
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      default:
-        //goto _def_wnd_proc;
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-    }
-  }
-  if ( Msg == WM_SYSCOMMAND )
-  {
-    if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
-      return 0;
-    //goto _def_wnd_proc;
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
-  }
-  if ( Msg > WM_ACTIVATEAPP )
-  {
-    if ( Msg != WM_KEYFIRST && Msg != WM_WINDOWPOSCHANGED)
-    {
-      if ( Msg == WM_KEYUP && wParam == VK_CONTROL )
+
+        sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+
+      pArcomageGame->stru1.field_0 = 8;
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_MBUTTONDOWN:
+      if (pRenderer->pRenderD3D && pGame)
+      {
+        pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter);
+      }
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_MOUSEMOVE:
+      if ( pArcomageGame->bGameInProgress )
+      {
+        ArcomageGame::OnMouseMove(LOWORD(lParam), HIWORD(lParam));
+        ArcomageGame::OnMouseClick(0, wParam == MK_LBUTTON);
+        ArcomageGame::OnMouseClick(1, wParam == MK_RBUTTON);
+      }
+      else
+      {
+        pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
+      }
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_SYSCOMMAND:
+      if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
+        return 0;
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_KEYUP:
+      if (wParam == VK_CONTROL)
       {
         dword_507B98_ctrl_pressed = 0;
       }
-      return DefWindowProcA(hWnd, Msg, wParam, lParam);
-    }
-    if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
-    {
-      pKeyActionMap->_459F10(wParam);
-      return DefWindowProcA(hWnd, Msg, wParam, lParam);
-    }
-    if ( !pArcomageGame->bGameInProgress )
-    {
-      if ( pVideoPlayer->pVideoFrame.pPixels )
-        pVideoPlayer->bStopBeforeSchedule = 1;
-      if ( wParam == VK_RETURN )
-      {
-        if ( !viewparams->field_4C )
-          UI_OnKeyDown(wParam);
-        return 0;
-      }
-      if ( wParam == VK_CONTROL )
+
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_KEYDOWN:
+      if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
       {
-        dword_507B98_ctrl_pressed = 1;
-        return 0;
-      }
-      if ( wParam == VK_ESCAPE )
-      {
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
-        return 0;
+        pKeyActionMap->_459F10(wParam);
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
       }
-      if ( wParam <= VK_HOME )
-        return 0;
-      if ( wParam > VK_DOWN )
+      if ( !pArcomageGame->bGameInProgress )
       {
-        if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
-          return 0;
-        SendMessageA(hWnd, WM_COMMAND, 104, 0);
-        return 0;
-      }
-      if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
-      {
-        if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
+        if ( pVideoPlayer->pVideoFrame.pPixels )
+          pVideoPlayer->bStopBeforeSchedule = 1;
+        if ( wParam == VK_RETURN )
         {
           if ( !viewparams->field_4C )
             UI_OnKeyDown(wParam);
           return 0;
         }
-      }
-      if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
-        return 0;
-    }
-
-    pArcomageGame->stru1.field_0 = 1;
-
-    v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u);
-    set_stru1_field_8_InArcomage(v13);
-    if ( wParam == 27 )
-    {
-      pArcomageGame->GameOver = 1;
-      pArcomageGame->field_F4 = 1;
-      pArcomageGame->uGameResult = 2;
-      pArcomageGame->field_B0 = -2;
-      return DefWindowProcA(hWnd, Msg, wParam, lParam);
-    }
-    if ( wParam != 114 )
-    {
-      if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-        SendMessageA(hWnd, 0x111u, 0x68u, 0);
-      return DefWindowProcA(hWnd, Msg, wParam, lParam);
-    }
-    SendMessageA(hWnd, WM_COMMAND, 103, 0);
-    return 0;
-  }
-  if ( Msg == WM_ACTIVATEAPP )
-  {
-    if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) )
-    {
-      if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
-      {
-        dword_4E98BC_bApplicationActive = 1;
-        if ( pRenderer->bWindowMode )
+        if ( wParam == VK_CONTROL )
+        {
+          dword_507B98_ctrl_pressed = 1;
+          return 0;
+        }
+        if ( wParam == VK_ESCAPE )
         {
-          v10 = GetDC(0);
-          a2 = GetDeviceCaps(v10, BITSPIXEL);
-          v11 = GetDeviceCaps(v10, PLANES);
-          ReleaseDC(0, v10);
-          if ( a2 != 16 || v11 != 1 )
-            Abortf(pGlobalTXT_LocalizationStrings[62]);
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
+          return 0;
         }
-        BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
-
-        if ( pArcomageGame->bGameInProgress )
-        {
-          pArcomageGame->field_F9 = 1;
-        }
-        else
+        if ( wParam <= VK_HOME )
+          return 0;
+        if ( wParam > VK_DOWN )
         {
-          if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
-            BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
-          else
-            pEventTimer->Resume();
-          if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
-            BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
-          else
-            pMiscTimer->Resume();
-
-          viewparams->bRedrawGameUI = true;
-          if ( pVideoPlayer->pSmackerMovie )
+          if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
+            return 0;
+          SendMessage(hWnd, WM_COMMAND, 104, 0);
+          return 0;
+        }
+        if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
+        {
+          if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
           {
-            pRenderer->RestoreFrontBuffer();
-            pRenderer->_4A184C();
-            pVideoPlayer->_4BF5B2();
+            if ( !viewparams->field_4C )
+              UI_OnKeyDown(wParam);
+            return 0;
           }
         }
-        if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
-          AIL_redbook_resume(pAudioPlayer->hAILRedbook);
+        if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
+          return 0;
       }
-    }
-    else
-    {
-      if ( !(dword_6BE364_game_settings_1 & 0x100) )
+
+      pArcomageGame->stru1.field_0 = 1;
+
+      set_stru1_field_8_InArcomage(MapVirtualKey(wParam, MAPVK_VK_TO_CHAR));
+      if ( wParam == 27 )
       {
-        while(initing); //ADDED spinlock to allow int players ets! Gloval
-          dword_4E98BC_bApplicationActive = 0;
-        if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
-          pVideoPlayer->bStopBeforeSchedule = 1;
-
-        if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
-          SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
-        ClipCursor(0);
-        dword_6BE364_game_settings_1 |= 0x100u;
-        if ( pEventTimer->bPaused )
-          BYTE1(dword_6BE364_game_settings_1) |= 2u;
-        else
-          pEventTimer->Pause();
-        if ( pMiscTimer->bPaused )
-          BYTE1(dword_6BE364_game_settings_1) |= 4u;
-        else
-          pMiscTimer->Pause();
-
-        pAudioPlayer->StopChannels(-1, -1);
-        if ( pAudioPlayer->hAILRedbook )
-          AIL_redbook_pause(pAudioPlayer->hAILRedbook);
+        pArcomageGame->GameOver = 1;
+        pArcomageGame->field_F4 = 1;
+        pArcomageGame->uGameResult = 2;
+        pArcomageGame->field_B0 = -2;
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      }
+      if ( wParam != 114 )
+      {
+        if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
+          SendMessage(hWnd, WM_COMMAND, 0x68u, 0);
+        return DefWindowProc(hWnd, uMsg, wParam, lParam);
       }
-    }
-    return 0;
-  }
-  if (Msg == WM_CREATE)
-  {
-    auto hDC = GetDC(hWnd);
-    {
-      if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
+      SendMessage(hWnd, WM_COMMAND, 103, 0);
+      return 0;
+
+    case WM_ACTIVATEAPP:
+      if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) )
       {
-        ReleaseDC(hWnd, hDC);
-        Log::Warning(L"You must be running in 256 color mode or higher.");
-        Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon.");
+        if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
+        {
+          dword_4E98BC_bApplicationActive = 1;
+          if ( pRenderer->bWindowMode )
+          {
+            HDC hDC = GetDC(hWnd);
+            int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
+            int planes = GetDeviceCaps(hDC, PLANES);
+            ReleaseDC(hWnd, hDC);
+            if (bitsPerPixel != 16 || planes != 1)
+              Abortf(pGlobalTXT_LocalizationStrings[62]);
+          }
+          BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
+
+          if ( pArcomageGame->bGameInProgress )
+          {
+            pArcomageGame->field_F9 = 1;
+          }
+          else
+          {
+            if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
+              BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
+            else
+              pEventTimer->Resume();
+            if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
+              BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
+            else
+              pMiscTimer->Resume();
+
+            viewparams->bRedrawGameUI = true;
+            if ( pVideoPlayer->pSmackerMovie )
+            {
+              pRenderer->RestoreFrontBuffer();
+              pRenderer->_4A184C();
+              pVideoPlayer->_4BF5B2();
+            }
+          }
+          if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
+            AIL_redbook_resume(pAudioPlayer->hAILRedbook);
+        }
       }
-    }
-    ReleaseDC(hWnd, hDC);
-    return 0;
-  }
-  if ( Msg == WM_DESTROY )
-  {
-    v6 = GetCurrentProcess();
-    SetPriorityClass(v6, 0x20u);
-    if ( pGame )
-    {
-
-    }
-
-    PostQuitMessage(0);
-    return 0;
-  }
-  if ( Msg == WM_SETFOCUS )
-  {
-    if ( ::hWnd == (HWND)wParam )
-    {
+      else
+      {
+        if (!(dword_6BE364_game_settings_1 & 0x100))
+        {
+          dword_4E98BC_bApplicationActive = 0;
+          if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
+            pVideoPlayer->bStopBeforeSchedule = 1;
+
+          if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
+            SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
+          ClipCursor(0);
+          dword_6BE364_game_settings_1 |= 0x100u;
+          if ( pEventTimer->bPaused )
+            BYTE1(dword_6BE364_game_settings_1) |= 2u;
+          else
+            pEventTimer->Pause();
+          if ( pMiscTimer->bPaused )
+            BYTE1(dword_6BE364_game_settings_1) |= 4u;
+          else
+            pMiscTimer->Pause();
+
+          pAudioPlayer->StopChannels(-1, -1);
+          if ( pAudioPlayer->hAILRedbook )
+            AIL_redbook_pause(pAudioPlayer->hAILRedbook);
+        }
+      }
+      return 0;
+
+    case WM_CREATE:
+      {
+        auto hDC = GetDC(hWnd);
+        {
+          if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
+          {
+            ReleaseDC(hWnd, hDC);
+            Log::Warning(L"You must be running in 256 color mode or higher.");
+            Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon.");
+          }
+        }
+        ReleaseDC(hWnd, hDC);
+      }
+      return 0;
+
+    case WM_SETFOCUS:
       dword_4E98BC_bApplicationActive = 0;
       if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
-        SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
+        SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
       ClipCursor(0);
-
-    }
-//_def_wnd_proc:
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
-  }
-  if ( Msg != WM_KILLFOCUS )
-  {
-    if ( Msg == WM_PAINT )
-    {
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_KILLFOCUS:
+      dword_4E98BC_bApplicationActive = 1;
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+    case WM_PAINT:
       if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
         return 0;
+      PAINTSTRUCT Paint;
       BeginPaint(hWnd, &Paint);
       if ( pArcomageGame->bGameInProgress )
       {
@@ -3866,13 +3804,10 @@
       pRenderer->Present();
       EndPaint(hWnd, &Paint);
       return 0;
-    }
-    //goto _def_wnd_proc;
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
-  }
-  if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || true )
-    return DefWindowProcA(hWnd, Msg, wParam, lParam);
-
+
+    default:
+      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+  }
 }
 
 //----- (00464479) --------------------------------------------------------
@@ -4406,7 +4341,6 @@
 //----- (004651F4) --------------------------------------------------------
 bool MM7_Initialize()
 {
-initing=true; //ADDED Gloval
   wchar_t pCurrentDir[1024];
   _wgetcwd(pCurrentDir, 1024);
 
@@ -4469,15 +4403,14 @@
   uWindowY = uDesktopHeight / 2 - 480 / 2;
   WriteWindowsRegistryInt("window Y", uWindowY);
 
-  hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic® VII",
-                         uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
-                         uWindowX, uWindowY,
-                         640, 480,
-                         nullptr,
-                         hOSMenu = nullptr,
-                         wcxw.hInstance,
-                         nullptr);
-  SetWindowTextW(hWnd, L"Might and Magic® VII");
+  hWnd = CreateWindowEx(0, wcxw.lpszClassName, L"Might and Magic® VII",
+                        uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
+                        uWindowX, uWindowY,
+                        640, 480,
+                        nullptr,
+                        hOSMenu = nullptr,
+                        wcxw.hInstance,
+                        nullptr);
 
   HMENU menu = CreateMenu();
   {
@@ -4686,7 +4619,6 @@
   MoveWindow(hWnd, uWindowX, uWindowY,
     rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640,
     rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0);
-  ShowWindow(hWnd, SW_SHOWNORMAL);
 
   pIcons_LOD = new LODFile_IconsBitmaps;
   if (!pIcons_LOD->Load("data\\icons.lod", "icons"))
@@ -5021,7 +4953,7 @@
       break;
     }
 
-  initing = false; //ADDED Gloval
+  ShowWindow(hWnd, SW_SHOWNORMAL);
   return true;
 }
 
--- a/mm7_4.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/mm7_4.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -3629,7 +3629,7 @@
 					OracleDialogue();
 					break;
 				case 311:
-					sub_4BBA85_bounties();
+					CheckBountyRespawnAndAward();
 					break;
 				case 399:
                   __debugbreak(); // what kind of dialogue is that?
--- a/mm7_data.cpp	Sat Sep 07 05:18:32 2013 +0200
+++ b/mm7_data.cpp	Sat Sep 07 05:23:16 2013 +0200
@@ -1349,8 +1349,8 @@
 std::array<__int16, 777> word_F8B158; // weak
 struct Texture *ShopTexture; // idb
 std::array<struct Texture *, 12> ItemsInShopTexture;
-__int16 word_F8B1A0; // weak
-const char *dword_F8B1A4; // idb
+__int16 bountyHunting_monster_id_for_hunting; // word_F8B1A0
+const char *bountyHunting_text; // word_F8B1A4
 int contract_approved; // weak
 int dword_F8B1AC_award_bit_number; // idb
 int dword_F8B1B0; // weak
@@ -1376,5 +1376,3 @@
 std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18
 int dword_F93F20; // weak
 int dword_F93F70; // weak
-
-volatile bool initing;
\ No newline at end of file
--- a/mm7_data.h	Sat Sep 07 05:18:32 2013 +0200
+++ b/mm7_data.h	Sat Sep 07 05:23:16 2013 +0200
@@ -1009,8 +1009,8 @@
 extern std::array<__int16, 777> word_F8B158; // weak
 extern struct Texture *ShopTexture; // idb
 extern std::array<struct Texture *, 12> ItemsInShopTexture;
-extern __int16 word_F8B1A0; // weak
-extern const char *dword_F8B1A4; // idb
+extern __int16 bountyHunting_monster_id_for_hunting; // weak
+extern const char *bountyHunting_text; // idb
 extern int contract_approved; // weak
 extern int dword_F8B1AC_award_bit_number; // idb
 extern int dword_F8B1B0; // weak
@@ -1040,7 +1040,6 @@
 extern int dword_F93F20; // weak
 extern int dword_F93F70; // weak
 
-extern volatile bool initing; //ADDED
 
 
 
@@ -1243,7 +1242,7 @@
 void _4B4224_UpdateNPCTopics(int _this);
 void __fastcall DrawTextAtStatusBar(const char *Str, int a5);
 __int64 GetExperienceRequiredForLevel(int a1);
-const char *sub_4BBA85_bounties();
+void CheckBountyRespawnAndAward();
 void sub_4BBCDD();
 void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb
 void ArenaFight();