changeset 758:9f7db515a8d7

Training Hall & levelling up fixed
author Nomad
date Sat, 23 Mar 2013 13:38:24 +0200
parents 3523c3b581e5
children b2468462a360
files UIHouses.cpp UIHouses.h mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 6 files changed, 94 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/UIHouses.cpp	Sat Mar 23 00:18:02 2013 +0200
+++ b/UIHouses.cpp	Sat Mar 23 13:38:24 2013 +0200
@@ -409,7 +409,7 @@
 	dword_F8B1E4 = 0;
 	dword_F8B1F4 = 0;
 	memset(byte_F8B1F0, 0, 4);
-	memset(byte_F8B148, 0, 16);
+	memset(player_levels, 0, 16);
 	pRenderer->ClearZBuffer(0, 479);
 
 	if (((uCloseTime - 1 <= uOpenTime)&&((pParty->uCurrentHour <uOpenTime)&&(pParty->uCurrentHour >(uCloseTime - 1))))||
@@ -738,7 +738,7 @@
 			}
 			if ( v1 > pParty->uNumGold )
 			{
-				PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+				PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
 				v2 = pParty->uNumGold;
 			}
 			if ( v2 > pParty->uFine )
@@ -834,7 +834,7 @@
 				}
 				if ( v6 > pParty->uNumGold )
 				{
-					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
 					v7 = pParty->uNumGold;
 				}
 				if ( v7 )
@@ -881,7 +881,7 @@
 				{
 					if ( v2 > pParty->uNumGoldInBank )
 					{
-						PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+						PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
 						v3 = pParty->uNumGoldInBank;
 					}
 					if ( v3 )
@@ -1194,7 +1194,7 @@
       {
         Party::TakeGold((unsigned int)pOutString);
         v27 = (int)window_SpeakInHouse->ptr_1C;
-        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
         dialog_menu_id = HOUSE_DIALOGUE_NULL;
         sub_4BD8B5();
         sub_4B1D27();
@@ -3242,7 +3242,7 @@
                         if ( pParty->uNumGold < v63 )
                             {
                             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold"
-                            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+                            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
                             }
                         else
                             {
@@ -3726,7 +3726,7 @@
             {
 LABEL_55:
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
             goto LABEL_46;
             }
         Party::TakeGold(v2);
@@ -3844,7 +3844,7 @@
     }
 
 //----- (004B4710) --------------------------------------------------------
-int __cdecl TrainingDialog()
+void TrainingDialog()
 {
   //Player *v0; // ebx@1
   int color2; // eax@1
@@ -3858,7 +3858,7 @@
   double v9; // st7@6
   signed int v10; // esi@6
   int v11; // ecx@6
-  int result; // eax@9
+  //int result; // eax@9
   GUIWindow *v13; // edi@14
   signed int v14; // esi@14
   unsigned int v15; // esi@16
@@ -3874,29 +3874,29 @@
   unsigned int v25; // ecx@28
   int v26; // eax@28
   unsigned __int16 v27; // ax@28
-  int v28; // eax@32
+  //int v28; // eax@32
   unsigned __int16 v29; // ST14_2@34
   int v30; // eax@34
-  const char *v31; // ST18_4@36
-  unsigned __int16 v32; // ST14_2@36
+  //const char *v31; // ST18_4@36
+  //unsigned __int16 v32; // ST14_2@36
   int v33; // eax@36
   int v34; // eax@37
   unsigned int v35; // edi@38
   unsigned int v36; // eax@38
-  int v37; // ecx@41
-  char *v38; // eax@41
-  int *v39; // eax@45
+  //int v37; // ecx@41
+  //char *v38; // eax@41
+  //int *v39; // eax@45
   unsigned int v40; // eax@46
-  void *v41; // ecx@46
+  //void *v41; // ecx@46
   unsigned int v42; // eax@46
   GUIWindow *v43; // ecx@59
   int v44; // edx@59
   char **v45; // esi@60
-  int v46; // eax@62
+  //int v46; // eax@62
   int v47; // eax@68
-  int v48; // edx@69
+  //int v48; // edx@69
   int v49; // ebx@69
-  unsigned __int8 v50; // sf@69
+  //unsigned __int8 v50; // sf@69
   char **v51; // edi@70
   GUIButton *v52; // eax@71
   GUIButton *v53; // esi@71
@@ -3905,12 +3905,12 @@
   int v56; // eax@71
   unsigned __int16 v57; // ax@71
   unsigned __int16 v58; // [sp-Ch] [bp-90h]@38
-  const char *v59; // [sp-Ch] [bp-90h]@63
+  //const char *v59; // [sp-Ch] [bp-90h]@63
   char *v60; // [sp-8h] [bp-8Ch]@38
-  char *v61; // [sp-8h] [bp-8Ch]@63
+  //char *v61; // [sp-8h] [bp-8Ch]@63
   unsigned int v62; // [sp-4h] [bp-88h]@38
   int v63; // [sp-4h] [bp-88h]@52
-  char *v64; // [sp-4h] [bp-88h]@63
+  //char *v64; // [sp-4h] [bp-88h]@63
   GUIWindow v65; // [sp+Ch] [bp-78h]@1
   //__int64 v66; // [sp+60h] [bp-24h]@3
   unsigned int white; // [sp+68h] [bp-1Ch]@1
@@ -3926,7 +3926,7 @@
   v65.uFrameX = 483;
   v65.uFrameWidth = 148;
   v65.uFrameZ = 334;
-  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
   color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   //v71 = color2;
   //v2 = v0->uLevel;
@@ -3938,7 +3938,7 @@
   v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2;  // E n = n(n + 1) / 2
   //v6 = HIDWORD(v0->uExperience);
   //v7 = window_SpeakInHouse->ptr_1C;
-  v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89];
+  v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE];
   //v66 = 1000 * v3;
   if (pPlayers[uActiveCharacter]->uExperience >= v5)
   {
@@ -3955,18 +3955,16 @@
       v11 = v10 / 3;
     //i = v11;
   }
-  result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( result )
+
+  if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
   {
     if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
     {
-      if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_17 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
       {
-        result = dialog_menu_id - 96;
         if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
         {
-          result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-          if ( result )
+          if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
           {
             //i = 0;
             int _v0 = 0;
@@ -4000,11 +3998,11 @@
               v73 = (signed int)(149 - _v0) / v72;
               if ( v73 > 32 )
                 v73 = 32;
-              result = v13->pStartingPosActiveItem;
+              //result = v13->pStartingPosActiveItem;
               v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162;
-              int _v1 = result;
+              int _v1 = v13->pStartingPosActiveItem;
               v68 = v19;
-              if ( result < result + v13->pNumPresenceButton )
+              if (v13->pStartingPosActiveItem < v13->pStartingPosActiveItem + v13->pNumPresenceButton )
               {
                 v72 = 2;
                 do
@@ -4034,12 +4032,10 @@
                       v27 = white;
                     v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u);
                   }
-                  v28 = v13->pStartingPosActiveItem;
                   ++_v1;
-                  result = v13->pNumPresenceButton + v28;
                   ++v72;
                 }
-                while ( (signed int)_v1 < result );
+                while ( (signed int)_v1 < v13->pStartingPosActiveItem + v13->pNumPresenceButton );
               }
             }
             else
@@ -4051,21 +4047,20 @@
               strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
               v29 = color2;
               v30 = pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0);
-              result = (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u);
+              (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u);
             }
           }
         }
-        return result;
+        return;
       }
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
-        v31 = pNPCTopics[122].pText;
-        v32 = color2;
+        //v31 = pNPCTopics[122].pText;
+        //v32 = color2;
         v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
-        v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, v32, v31, 3);
-        result = (int)pDialogueWindow;
+        v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, color2, pNPCTopics[122].pText, 3);
         pDialogueWindow->pNumPresenceButton = 0;
-        return result;
+        return;
       }
       v34 = pPlayers[uActiveCharacter]->uLevel;
       if ( v34 < v68 )
@@ -4075,28 +4070,28 @@
           if ( pParty->uNumGold >= v11)
           {
             Party::TakeGold(v11);
-            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
             ++pPlayers[uActiveCharacter]->uLevel;
             pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5;
             pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
             pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
-            v37 = 0;
-            v38 = byte_F8B148;
-            do
+
+            uint max_level_in_party = player_levels[0];
+            for (uint _it = 1; _it < 4; ++_it)
             {
-              if ( *(int *)v38 > v37 )
-                v37 = *(int *)v38;
-              v38 += 4;
+              if (player_levels[_it] > max_level_in_party)
+                max_level_in_party = player_levels[_it];
             }
-            while ( (signed int)v38 < (signed int)word_F8B158 );
-            v39 = &dword_F8B144 + uActiveCharacter;
-            ++*v39;
-            if ( *v39 > v37 )
+
+            ++player_levels[uActiveCharacter - 1];
+            if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level
+                                                                          // feature is broken thou, since this array is always zeroed in EnterHouse
             {
-              v40 = sub_494820(pParty->uCurrentHour);
-              v41 = window_SpeakInHouse->ptr_1C;
+              v40 = _494820_training_time(pParty->uCurrentHour);
+              //v41 = window_SpeakInHouse->ptr_1C;
               v42 = 60 * (v40 + 4) - pParty->uCurrentMinute;
-              if ( v41 == (void *)94 || v41 == (void *)95 )
+              if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 ||
+                  (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95)
                 v42 += 720;
               RestAndHeal((signed int)(v42 + 10080));
               if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
@@ -4107,7 +4102,7 @@
                                                 // "%s is now Level %lu and has earned %lu Skill Points!"
             ShowStatusBarString(pTmpBuf, 2);
             pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-            return true;
+            return;
           }
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
           v63 = 4;
@@ -4125,7 +4120,7 @@
           }
           return result;*/
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-          return 1; // void function actually
+          return;
         }
         sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), v34 + 1);// 
                                                 // "You need %d more experience to train to level %d"
@@ -4150,8 +4145,8 @@
       v63 = 3;
       goto LABEL_55;
     }
-    result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
+
+    if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
     {
       v43 = pDialogueWindow;
       v72 = 0;
@@ -4164,31 +4159,21 @@
         v45 = pShopOptions;
         do
         {
-          if ( v43->GetControl(v73)->uControlParam == 17 )
+          if ( v43->GetControl(v73)->uControlParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
           {
-            v46 = pPlayers[uActiveCharacter]->uLevel;
-            if ( v46 < v68 )
-            {
-              if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience < v5 )
-              {
-                v64 = (char *)(v46 + 1);
-                v61 = (char *)(v5 - LODWORD(pPlayers[uActiveCharacter]->uExperience));
-                v59 = pGlobalTXT_LocalizationStrings[538];// "You need %d more experience to train to level %d"
-              }
-              else
-              {
-                v64 = (char *)v11;
-                v61 = (char *)(v46 + 1);
-                v59 = pGlobalTXT_LocalizationStrings[537];// "Train to level %d for %d gold"
-              }
-            }
+            //v46 = pPlayers[uActiveCharacter]->uLevel;
+            if (pPlayers[uActiveCharacter]->uLevel >= v68)
+              sprintfex(*v45, "%s\n \n%s",
+                        pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher."    "Sorry, but we are unable to train you."
             else
             {
-              v64 = pGlobalTXT_LocalizationStrings[529];// ""Sorry, but we are unable to train you.""
-              v61 = pGlobalTXT_LocalizationStrings[536];// ""With your skills, you should be working here as a teacher.""
-              v59 = "%s\n \n%s";
+              if (pPlayers[uActiveCharacter]->uExperience < v5)
+                sprintfex(*v45, pGlobalTXT_LocalizationStrings[538],  // "You need %d more experience to train to level %d"
+                          (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1);
+              else
+                sprintfex(*v45, pGlobalTXT_LocalizationStrings[537],  // "Train to level %d for %d gold"
+                          pPlayers[uActiveCharacter]->uLevel + 1, v11);
             }
-            sprintfex(*v45, v59, v61, v64);
           }
           v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0);
           v43 = pDialogueWindow;
@@ -4198,13 +4183,10 @@
         }
         while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
-      //HIDWORD(v66) = (174 - v72) / 2;
-      result = v43->pStartingPosActiveItem;
-      v48 = result + v43->pNumPresenceButton;
+
       v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138;
-      v50 = -v43->pNumPresenceButton < 0;
       v73 = v43->pStartingPosActiveItem;
-      if ( v50 ^ result < v48 )
+      if (v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton)
       {
         int _v3 = 2;
         v51 = pShopOptions;
@@ -4227,13 +4209,11 @@
           ++_v3;
           ++v51;
           ++v73;
-          result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
         }
-        while ( v73 < result );
+        while ( v73 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton);
       }
     }
   }
-  return result;
 }
 
 
--- a/UIHouses.h	Sat Mar 23 00:18:02 2013 +0200
+++ b/UIHouses.h	Sat Mar 23 13:38:24 2013 +0200
@@ -21,7 +21,7 @@
   HOUSE_DIALOGUE_14 = 14,
   HOUSE_DIALOGUE_TAVERN_REST = 15,
   HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16,
-  HOUSE_DIALOGUE_TRAININGHALL_17 = 17,
+  HOUSE_DIALOGUE_TRAININGHALL_TRAIN = 17,
   HOUSE_DIALOGUE_GULD_BUY_BOOKS = 18,
   //...
   HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72,
@@ -55,7 +55,14 @@
   HOUSE_STABLES_HARMONDALE = 54,
   HOUSE_TEMPLE_EMERALD_ISLE = 74,
   HOUSE_TEMPLE_HARMONDALE = 75,
+  HOUSE_TRAINING_HALL_EMERALD_ISLE = 89,
   HOUSE_TRAINING_HALL_HARMONDALE = 90,
+  HOUSE_TRAINING_HALL_91 = 91,
+  HOUSE_TRAINING_HALL_92 = 92,
+  HOUSE_TRAINING_HALL_93 = 93,
+  HOUSE_TRAINING_HALL_94 = 94,
+  HOUSE_TRAINING_HALL_95 = 95,
+
   HOUSE_TOWNHALL_HARMONDALE = 102,
   HOUSE_TAVERN_EMERALD_ISLE = 107,
   HOUSE_BANK_HARMONDALE = 128,
@@ -82,13 +89,13 @@
 
 enum HouseSoundID: unsigned __int32
 {
-  HouseSound_Greeting = 1,
-  HouseSound_NotEnoughMoney = 2,
-  HouseSound_Greeting_2 = 3,      // good greeting when you're guild member
+  HouseSound_Greeting = 1,        // General greeting
+  HouseSound_NotEnoughMoney_TrainingSuccessful = 2,
+  HouseSound_Greeting_2 = 3,      // Polite Greeting when you're guild member
   HouseSound_Goodbye = 4          // farewells when bought something
 };
 
-int __cdecl TrainingDialog();
+void TrainingDialog();
 char *__cdecl JailDialog();
 void  MagicShopDialog();
 void  GuildDialog();
--- a/mm7_4.cpp	Sat Mar 23 00:18:02 2013 +0200
+++ b/mm7_4.cpp	Sat Mar 23 13:38:24 2013 +0200
@@ -3730,14 +3730,14 @@
 }
 
 //----- (00494820) --------------------------------------------------------
-unsigned int __fastcall sub_494820(unsigned int a1)
+unsigned int __fastcall _494820_training_time(unsigned int a1)
 {
   signed int v1; // eax@1
 
   v1 = 5;
-  if ( a1 % 0x18 >= 5 )
+  if ( a1 % 24 >= 5 )
     v1 = 29;
-  return v1 - a1 % 0x18;
+  return v1 - a1 % 24;
 }
 
 //----- (00494836) --------------------------------------------------------
@@ -7207,7 +7207,7 @@
     sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// 
                                                 // "%s is in no condition to %s"
                                                 // "do anything"
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0x9Bu);
     v3 = pFontArrus->CalcTextHeight(pTmpBuf, &v4, 0, 0);
     v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf, 3u);
     result = 0;
@@ -9793,7 +9793,7 @@
           pParty->uFallStartY = pParty->vPosition.z;
           pParty->sRotationY = v5->field_18;
         }
-        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
+        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
         v12 = v5->uTravelTime;
         int _v47;
         if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
--- a/mm7_5.cpp	Sat Mar 23 00:18:02 2013 +0200
+++ b/mm7_5.cpp	Sat Mar 23 13:38:24 2013 +0200
@@ -1579,7 +1579,7 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           dword_50CDC8 = v0;
           sub_42FBDD();
-          PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney);
+          PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful);
           pVideoPlayer->Unload();
           sub_44603D();
           viewparams->bRedrawGameUI = v0;
@@ -2561,7 +2561,7 @@
         case UIMSG_OpenRestUI:
           dword_506F14 = 2;
           RestUI_Initialize();
-          v86 = 60 * (sub_494820(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
+          v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
           _506F18_num_hours_to_sleep = v86;
           if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
             _506F18_num_hours_to_sleep = v86 + 720;
@@ -2733,7 +2733,7 @@
           }
           GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_5A,
             (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
-          v97 = sub_494820(pParty->uCurrentHour);
+          v97 = _494820_training_time(pParty->uCurrentHour);
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
           continue;
--- a/mm7_data.cpp	Sat Mar 23 00:18:02 2013 +0200
+++ b/mm7_data.cpp	Sat Mar 23 13:38:24 2013 +0200
@@ -2222,8 +2222,8 @@
 int dword_AE3370; // weak
 char byte_AE5B91; // weak
 int dword_F1B430[32]; // weak
-int dword_F8B144; // idb
-char byte_F8B148[16];
+//int dword_F8B144; // nexindex [-1] to the following
+int player_levels[4] = {1, 1, 1, 1};
 __int16 word_F8B158[777]; // weak
 struct Texture *ShopTexture; // idb
 struct Texture *ItemsInShopTexture[12];
--- a/mm7_data.h	Sat Mar 23 00:18:02 2013 +0200
+++ b/mm7_data.h	Sat Mar 23 13:38:24 2013 +0200
@@ -1678,8 +1678,7 @@
 extern int dword_AE3370; // weak
 extern char byte_AE5B91; // weak
 extern int dword_F1B430[32]; // weak
-extern int dword_F8B144; // idb
-extern char byte_F8B148[16];
+extern int player_levels[4];
 extern __int16 word_F8B158[]; // weak
 extern struct Texture *ShopTexture; // idb
 extern struct Texture *ItemsInShopTexture[12];
@@ -2240,7 +2239,7 @@
 int __cdecl _493938_regenerate();
 void sub_493F79(struct stru351_summoned_item *_this, __int64 a2);
 void __cdecl _494035_timed_effects__water_walking_damage__etc();
-unsigned int __fastcall sub_494820(unsigned int a1);
+unsigned int __fastcall _494820_training_time(unsigned int a1);
 char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2);
 char * GetReputationString(signed int a1);
 char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6);