changeset 768:67b77b052ef3

Merge
author Nomad
date Sat, 23 Mar 2013 21:16:04 +0200
parents 45615cacad31 (diff) 777c42590ffc (current diff)
children c319601893af
files Outdoor.cpp Outdoor.h Player.cpp mm7_3.cpp mm7_4.cpp
diffstat 17 files changed, 167 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Events.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -440,11 +440,11 @@
 					break;
 					}
 				if ( !_strcmpi(v16, "pcout01") )    // moving to harmondale from emerald isle
-					{
+                {
 					Rest(0x2760u);
 					pParty->RestAndHeal();
-					pParty->field_764 = 0;
-					}
+					pParty->days_played_without_rest = 0;
+                }
 				if ( !v15 || v128 == 3 )
 					{
 					pCurrentScreen = v128;
--- a/Game.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Game.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -395,7 +395,7 @@
         ++pPlayer;
       }
       while ( (signed int)pPlayer < (signed int)pParty->pHirelings );
-      pParty->field_764 = 0;
+      pParty->days_played_without_rest = 0;
       pParty->uTimePlayed += 0x276000ui64;
       LOWORD(pParty->uFlags) &= ~0x204;
       pParty->SetGold(0);
--- a/MapInfo.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/MapInfo.h	Sat Mar 23 21:16:04 2013 +0200
@@ -1,5 +1,25 @@
 #pragma once
 
+enum MAP_TYPE: unsigned __int32
+{
+  MAP_INVALID = 0,
+  MAP_EMERALD_ISLE = 1,
+  MAP_HARMONDALE = 2,
+  MAP_STEADWICK = 3,
+  MAP_PIERPONT = 4,
+  MAP_DEYJA = 5,
+  MAP_BRAKADA_DESERT = 6,
+  MAP_CELESTIA = 7,
+  MAP_THE_PIT = 8,
+  MAP_EVENMORN_ISLE = 9,
+  MAP_MOUNT_NIGHON = 10,
+  MAP_BARROW_DOWNS = 11,
+  MAP_LAND_OF_GIANTS = 12,
+  MAP_TATALIA = 13,
+  MAP_AVLEE = 14,
+  MAP_SHOALS = 15,
+  //...
+};
 
 
 /*  192 */
@@ -53,7 +73,7 @@
 struct MapStats
 {
   void Initialize();
-  unsigned int GetMapInfo(const char *Str2);
+  MAP_TYPE GetMapInfo(const char *Str2);
 
   MapInfo pInfos[77];
   unsigned int uNumMaps;
--- a/Outdoor.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Outdoor.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -42,6 +42,32 @@
 Edge stru_80C9A4;
 Edge stru_80C9D8;
 
+
+struct FogProbabilityTableEntry
+{
+  unsigned char small_fog_chance;
+  unsigned char average_fog_chance;
+  unsigned char dense_fog_chance;
+  unsigned char __unused;
+} fog_probability_table[15] =
+{
+  { 20,  10,   5,   0}, // MAP_EMERALD_ISLE
+  { 20,  10,   5,   0}, // MAP_HARMONDALE
+  { 20,  10,   5,   0}, // MAP_STEADWICK
+  { 20,  10,   5,   0}, // MAP_PIERPONT
+  { 20,  10,   5,   0}, // MAP_DEYJA
+  { 10,   5,   0,   0}, // MAP_BRAKADA_DESERT
+  {  0,   0,   0,   0}, // MAP_CELESTIA
+  {  0,   0,   0,   0}, // MAP_THE_PIT
+  { 20,  30,  50,   0}, // MAP_EVENMORN_ISLE
+  { 30,  20,  10,   0}, // MAP_MOUNT_NIGHON
+  { 10,   5,   0,   0}, // MAP_BARROW_DOWNS
+  { 20,  10,   5,   0}, // MAP_LAND_OF_GIANTS
+  { 20,  10,   5,   0}, // MAP_TATALIA
+  { 20,  10,   5,   0}, // MAP_AVLEE
+  {  0, 100,   0,   0}  // MAP_SHOALS
+};
+
 //for future sky textures?
 int dword_4EC268[9]={3,3,3,3,3,3,3,3,3}; // weak
 int dword_4EC28C[7]={3,3,3,3,3,3,3}; // weak
@@ -288,9 +314,9 @@
       MessageBoxA(0, "Error!", "Couldn't Load Map!", 0);
       CreateDebugLocation();
     }
-    day_attrib = v5->day_attrib;
-    day_fogrange_1 = v5->day_fogrange_1;
-    day_fogrange_2 = v5->day_fogrange_2;
+    ::day_attrib = v5->day_attrib;
+    ::day_fogrange_1 = v5->day_fogrange_1;
+    ::day_fogrange_2 = v5->day_fogrange_2;
     if ( Is_out15odm_underwater() )
       SetUnderwaterFog();
     _6BE134_odm_main_tile_group = v5->pTileTypes[0].tileset;
@@ -545,63 +571,50 @@
   }
   return 1;
 }
-// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
-// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
+
 
 //----- (00489487) --------------------------------------------------------
-int OutdoorLocation::SetFog()
+void OutdoorLocation::SetFog()
 {
-  int result; // eax@1
-  int v2; // esi@1
-  int v3; // edx@5
-  unsigned __int8 *v4; // eax@5
-  int v5; // ecx@5
-  int v6; // esi@7
-  unsigned __int8 v7; // al@9
+  strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
 
-  strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
-  result = pMapStats->GetMapInfo(pCurrentMapName);
-  v2 = result;
-  if ( result < 1 || result == 7 || result == 8 || result > 15 )
-    return result;
-  day_attrib &= 0xFFFFFFFEu;
-  v3 = rand() % 100;
-  v4 = (unsigned __int8 *)&byte_4ECB0C[4 * v2];
-  v5 = *v4;
-  if ( v3 < v5 )
+  auto map_id = pMapStats->GetMapInfo(pCurrentMapName);
+  if (map_id == MAP_INVALID || map_id == MAP_CELESTIA || map_id == MAP_THE_PIT || map_id > MAP_SHOALS)
+    return;
+
+  uint chance = rand() % 100;
+
+  if (chance < fog_probability_table[map_id - 1].small_fog_chance)
   {
-    day_fogrange_1 = 4096;
-    day_fogrange_2 = 8192;
-LABEL_13:
-    day_attrib |= 1u;
-    goto LABEL_14;
+    ::day_fogrange_1 = 4096;
+    ::day_fogrange_2 = 8192;
+    ::day_attrib |= DAY_ATTRIB_FOG;
   }
-  v6 = v4[1];
-  if ( v3 < v6 + v5 )
+  else if (chance < fog_probability_table[map_id - 1].small_fog_chance +
+                    fog_probability_table[map_id - 1].average_fog_chance)
   {
-    day_fogrange_2 = 4096;
-LABEL_12:
-    day_fogrange_1 = 0;
-    goto LABEL_13;
+    ::day_fogrange_2 = 4096;
+    ::day_fogrange_1 = 0;
+    ::day_attrib |= DAY_ATTRIB_FOG;
   }
-  v7 = v4[2];
-  if ( v7 && v3 < v5 + v6 + v7 )
+  else if (fog_probability_table[map_id - 1].dense_fog_chance &&
+           chance < fog_probability_table[map_id - 1].small_fog_chance + 
+                    fog_probability_table[map_id - 1].average_fog_chance +
+                    fog_probability_table[map_id - 1].dense_fog_chance)
   {
-    day_fogrange_2 = 2048;
-    goto LABEL_12;
+    ::day_fogrange_2 = 2048;
+    ::day_fogrange_1 = 0;
+    ::day_attrib |= DAY_ATTRIB_FOG;
   }
-LABEL_14:
+  else
+    ::day_attrib &= ~DAY_ATTRIB_FOG;
+
   if ( Is_out15odm_underwater() )
     SetUnderwaterFog();
-  pOutdoor->day_fogrange_1 = day_fogrange_1;
-  pOutdoor->day_fogrange_2 = day_fogrange_2;
-  result = day_attrib;
-  pOutdoor->day_attrib = day_attrib;
-  return result;
+  pOutdoor->day_fogrange_1 = ::day_fogrange_1;
+  pOutdoor->day_fogrange_2 = ::day_fogrange_2;
+  pOutdoor->day_attrib = ::day_attrib;
 }
-// 6BE030: using guessed type int day_attrib;
-// 6BE040: using guessed type int day_fogrange_1;
-// 6BE044: using guessed type int day_fogrange_2;
 
 //----- (00482170) --------------------------------------------------------
 bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, stru148 *a3)
--- a/Outdoor.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/Outdoor.h	Sat Mar 23 21:16:04 2013 +0200
@@ -5,6 +5,9 @@
 #include "TileFrameTable.h"
 
 
+
+#define DAY_ATTRIB_FOG  1
+
 /*  256 */
 #pragma pack(push, 1)
 struct ODMHeader
@@ -179,7 +182,7 @@
   void UpdateSunlightVectors();
   void UpdateFog();
   int GetNumFoodRequiredToRestInCurrentPos(int x, signed int y, int z);
-  int SetFog();
+  void SetFog();
   void Draw();
 
 
--- a/Party.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Party.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -1023,16 +1023,11 @@
     v2->Zero();
     if ( v2->pConditions[14] || v2->pConditions[15] || v2->pConditions[16] )
       goto LABEL_33;
-    LODWORD(v2->pConditions[13]) = 0;
-    HIDWORD(v2->pConditions[13]) = 0;
-    LODWORD(v2->pConditions[4]) = 0;
-    HIDWORD(v2->pConditions[4]) = 0;
-    LODWORD(v2->pConditions[2]) = 0;
-    HIDWORD(v2->pConditions[2]) = 0;
-    LODWORD(v2->pConditions[3]) = 0;
-    HIDWORD(v2->pConditions[3]) = 0;
-    LODWORD(v2->pConditions[1]) = 0;
-    HIDWORD(v2->pConditions[1]) = 0;
+    v2->pConditions[13] = 0;
+    v2->pConditions[4] = 0;
+    v2->pConditions[2] = 0;
+    v2->pConditions[3] = 0;
+    v2->pConditions[1] = 0;
     v2->uTimeToRecovery = 0;
     v2->sHealth = v2->GetMaxHealth();
     v5 = v2->GetMaxMana();
@@ -1094,5 +1089,5 @@
     ++v15;
   }
   while ( v15 < 4 );
-  pParty->field_764 = 0;
+  pParty->days_played_without_rest = 0;
 }
\ No newline at end of file
--- a/Party.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/Party.h	Sat Mar 23 21:16:04 2013 +0200
@@ -152,7 +152,7 @@
     uCurrentTimeSecond = 0;
 
     field_6FC = 0;
-    field_764 = 0;
+    days_played_without_rest = 0;
 
     vPosition.y = 0;
     vPosition.z = 0;
@@ -262,7 +262,7 @@
   int field_74C;
   __int16 field_750[5];
   __int16 field_75A[5];
-  char field_764; // num hours resting or some sort of.
+  unsigned char   days_played_without_rest;
   unsigned __int8 _quest_bits[64];
   unsigned __int8 pArcomageWins[16];
   char field_7B5_in_arena_quest;
--- a/Player.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Player.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -6792,7 +6792,6 @@
 void Player::Zero()
 {
   Player *v1; // esi@1
-  void *result; // eax@1
 
   v1 = this;
   this->sLevelModifier = 0;
@@ -6813,7 +6812,7 @@
   this->field_E8 = 0;
   this->field_E4 = 0;
   this->field_E0 = 0;
-  result = memset(&this->sResFireBonus, 0, 0x16u);
+  memset(&this->sResFireBonus, 0, 0x16u);
   v1->field_1A97 = 0;
   v1->_ranged_dmg_bonus = 0;
   v1->field_1A95 = 0;
--- a/Player.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/Player.h	Sat Mar 23 21:16:04 2013 +0200
@@ -574,6 +574,7 @@
   inline bool Eradicated() {return pConditions[Condition::Condition_Eradicated] != 0;}
   inline bool Zombie()     {return pConditions[Condition::Condition_Zombie] != 0;}
   inline bool Cursed()     {return pConditions[Condition::Condition_Cursed] != 0;}
+  inline bool Pertified()  {return pConditions[Condition::Condition_Pertified] != 0;}
 
 
 
--- a/Render.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/Render.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -634,7 +634,7 @@
   array_77EC08[1999].field_24 = 0x2000000u;
   array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
   array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
-  if ( day_attrib & 1
+  if ( day_attrib & DAY_ATTRIB_FOG
     && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5)
     && pParty->uCurrentHour < 0x15
     || bUnderwater )
--- a/Weather.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/Weather.h	Sat Mar 23 21:16:04 2013 +0200
@@ -9,6 +9,10 @@
 #pragma pack(push, 1)
 struct Weather
 {
+  inline Weather():
+    bNight(false), bRenderSnow(false)
+  {}
+
   int DrawSnow();
   int Initialize();
   int Draw();
--- a/mm7_2.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_2.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -6741,25 +6741,15 @@
 
 
 //----- (004547A3) --------------------------------------------------------
-unsigned int MapStats::GetMapInfo(const char *Str2)
-{
-  MapStats *v2; // esi@1
-  unsigned int v3; // edi@1
-  const char **v4; // ebx@2
-  unsigned int result; // eax@6
-
-  v3 = 1;
-  if ( (signed int)uNumMaps <= 1 )
-     return 0;
-  
-    while ( !*this->pInfos[v3].pFilename || _strcmpi(this->pInfos[v3].pFilename, Str2) )
-    {
-      ++v3;
-      if ( (signed int)v3 >= (signed int)uNumMaps )
-        return 0;
-    }
-    return v3;
-
+MAP_TYPE MapStats::GetMapInfo(const char *Str2)
+{
+  assert(uNumMaps >= 2);
+
+  for (uint i = 1; i < uNumMaps; ++i)
+    if (!strcmpi(pInfos[i].pFilename, Str2))
+      return (MAP_TYPE)i;
+
+  assert(false && "Map not found!");
 }
 
 //----- (004547E4) --------------------------------------------------------
--- a/mm7_3.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_3.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -6674,7 +6674,7 @@
   {
     v4 = (MapInfo *)thisa;
   }
-  day_attrib &= 0xFFFFFFFEu;
+  day_attrib &= ~DAY_ATTRIB_FOG;
   dword_6BE13C_uCurrentlyLoadedLocationID = v2;
   pOutdoor->Initialize(
     pFilename,
@@ -6813,7 +6813,7 @@
     return PaletteManager::Get(a2);
   if ( !pWeather->bNight )
   {
-    if ( day_attrib & 1 )
+    if (day_attrib & DAY_ATTRIB_FOG)
     {
       v14 = day_fogrange_1 << 16;
       if ( a3 >= day_fogrange_1 << 16 )
@@ -6946,7 +6946,7 @@
     v10 = 0;
   if ( !v10 )
   {
-    if ( !(day_attrib & 1) && !bUnderwater )
+    if ( !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater )
     {
       v14 = a5;
       v15 = a6;
@@ -7221,13 +7221,13 @@
 
   if ( bUnderwater )
   {
-    result = 0xFF258F5Cu;
-  }
-  else
-  {
-    if ( day_attrib & 1 )
-    {
-      if ( pWeather->bNight )
+    result = 0xFF258F5C;
+  }
+  else
+  {
+    if (day_attrib & DAY_ATTRIB_FOG)
+    {
+      if ( pWeather->bNight ) // night-time fog
       {
         __debugbreak(); // decompilation can be inaccurate, please  send savegame to Nomad
         v2 = -(pWeather->bNight != 1);
@@ -7240,9 +7240,7 @@
       }
     }
     else
-    {
-      result = 0;
-    }
+      return 0;
   }
   return result;
 }
@@ -7265,7 +7263,7 @@
   v3 = pWeather->bNight;
   if ( bUnderwater == 1 )
     v3 = 0;
-  if ( pParty->armageddon_timer || !(day_attrib & 1) && !bUnderwater )
+  if ( pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater )
     return 0xFF000000;
   if ( v3 )
   {
--- a/mm7_4.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_4.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -2421,7 +2421,7 @@
   //char *v6; // ecx@5
   //Player *v7; // esi@8
   //char *v8; // ecx@12
-  Player *pPlayer; // esi@15
+  //Player *pPlayer; // esi@15
   //void *v10; // esi@25
   unsigned int v11; // ecx@27
   signed int v12; // edi@29
@@ -2467,23 +2467,23 @@
   signed int v52; // ecx@130
   int v53; // eax@131
   Player *v54; // eax@141
-  unsigned int v55; // [sp-8h] [bp-38h]@18
+  //unsigned int v55; // [sp-8h] [bp-38h]@18
   unsigned int v56; // [sp-8h] [bp-38h]@55
-  int v57; // [sp-4h] [bp-34h]@18
+  //int v57; // [sp-4h] [bp-34h]@18
   int v58; // [sp-4h] [bp-34h]@33
   int v59; // [sp-4h] [bp-34h]@55
   unsigned int v60; // [sp+10h] [bp-20h]@1
   unsigned int v61; // [sp+14h] [bp-1Ch]@1
   Player **v62; // [sp+14h] [bp-1Ch]@50
-  unsigned int a2; // [sp+18h] [bp-18h]@1
+  //unsigned int a2; // [sp+18h] [bp-18h]@1
   signed int a2a; // [sp+18h] [bp-18h]@47
   signed int v65; // [sp+1Ch] [bp-14h]@47
 
-  a2 = pParty->uCurrentHour;
+  //a2 = pParty->uCurrentHour;
   v61 = pParty->uDaysPlayed;
   v60 = pEventTimer->uTimeElapsed;
-  pParty->uTimePlayed += (signed int)pEventTimer->uTimeElapsed;
-  v0 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60;
+  pParty->uTimePlayed += pEventTimer->uTimeElapsed;
+  v0 = (signed __int64)(pParty->uTimePlayed * 0.234375) / 60;
   v1 = v0;
   v0 /= 60i64;
   v2 = v0;
@@ -2496,7 +2496,7 @@
   pParty->uDaysPlayed = (unsigned int)v3 % 28;
   pParty->uCurrentMonth = v4 % 12;
   pParty->uCurrentYear = v4 / 0xC + game_starting_year;
-  if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 28 > v61) )
+  if ( pParty->uCurrentHour >= 3 && (pParty->uCurrentHour < 3 || pParty->uDaysPlayed > v61) ) // new day dawns
   {
     pParty->pHirelings[0].bHasUsedTheAbility = false;
     pParty->pHirelings[1].bHasUsedTheAbility = false;
@@ -2504,56 +2504,41 @@
     for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
       pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false;
 
-    ++pParty->field_764;
-    if ( pParty->field_764 > 1u )
+    ++pParty->days_played_without_rest;
+    if (pParty->days_played_without_rest > 1)
     {
       for (uint i = 0; i < 4; ++i)
-        pParty->pPlayers[i].SetCondition(1, 0);
-
-      if ( pParty->uNumFoodRations )
-      {
-        Party::TakeFood(1u);
-      }
+        pParty->pPlayers[i].SetCondition(Player::Condition_Weak, 0);
+
+      if (pParty->uNumFoodRations)
+        Party::TakeFood(1);
       else
-      {
         for (uint i = 0; i < 4; ++i)
-          pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / ((unsigned __int8)pParty->field_764 + 1) + 1;
-      }
-      if ( pParty->field_764 > 3u )
-      {
-        pPlayer = pParty->pPlayers;
-        do
+          pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1;
+
+      if (pParty->days_played_without_rest > 3)
+        for (uint i = 0; i < 4; ++i)
         {
-          pPlayer->Zero();
-          if ( !(pPlayer->pConditions[15] | pPlayer->pConditions[16] | pPlayer->pConditions[14]) )
+          auto player = pParty->pPlayers + i;
+
+          player->Zero();
+
+          if (!player->Pertified() && !player->Eradicated() && !player->Dead())
           {
-            if ( rand() % 100 < 5 * (unsigned __int8)pParty->field_764 )
-            {
-              v57 = 0;
-              v55 = 14;
-LABEL_21:
-              pPlayer->SetCondition(v55, v57);
-              goto LABEL_22;
-            }
-            if ( rand() % 100 < 10 * (unsigned __int8)pParty->field_764 )
-            {
-              v57 = 0;
-              v55 = 5;
-              goto LABEL_21;
-            }
+            if (rand() % 100 < 5 * pParty->days_played_without_rest)
+              player->SetCondition(Player::Condition_Dead, 0);
+            if (rand() % 100 < 10 * pParty->days_played_without_rest)
+              player->SetCondition(Player::Condition_Insane, 0);
           }
-LABEL_22:
-          ++pPlayer;
         }
-        while ( (signed int)pPlayer < (signed int)pParty->pHirelings );
-      }
-    }
-    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+    }
+    if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
       pOutdoor->SetFog();
 
     for (uint i = 0; i < 4; ++i)
       pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
   }
+
   v11 = LODWORD(pParty->uTimePlayed);
   if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )
   {
--- a/mm7_5.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_5.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -1694,7 +1694,7 @@
                   ++pPlayer7;
                 }
                 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
-                ++pParty->field_764;
+                ++pParty->days_played_without_rest;
               }
               Party::TakeFood((unsigned int)pNPCData4);
             }
@@ -1707,7 +1707,7 @@
                 ++pPlayer8;
               }
               while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings );
-              ++pParty->field_764;
+              ++pParty->days_played_without_rest;
             }
             pPaletteManager->ResetNonLocked();
             pSpriteFrameTable->ResetSomeSpriteFlags();
@@ -2568,11 +2568,11 @@
           //goto LABEL_615;
           dword_506F14 = 2;
           pParty->RestAndHeal();
-          pParty->field_764 = 0;
-          pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
-          pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
-          pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
-          pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
+          pParty->days_played_without_rest = 0;
+          pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+          pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+          pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+          pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
           continue;
         case UIMSG_68:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -2715,11 +2715,11 @@
 //LABEL_615:
             dword_506F14 = 2;
             pParty->RestAndHeal();
-            pParty->field_764 = 0;
-            pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
-            pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
-            pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
-            pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
+            pParty->days_played_without_rest = 0;
+            pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+            pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+            pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+            pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
           }
           continue;
         case UIMSG_AlreadyResting:
--- a/mm7_data.cpp	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_data.cpp	Sat Mar 23 21:16:04 2013 +0200
@@ -1107,7 +1107,6 @@
 char aTiletableLoadU[777]; // idb
 char byte_4ECA93[777]; // weak
 char byte_4ECACF[777]; // weak
-char byte_4ECB0C[64]; // idb
 char aError_0[777]; // idb
 char aCouldnTLoadMap[777]; // idb
 char aOut02d_odm[777]; // idb
--- a/mm7_data.h	Sat Mar 23 21:42:01 2013 +0400
+++ b/mm7_data.h	Sat Mar 23 21:16:04 2013 +0200
@@ -953,7 +953,6 @@
 extern char aTiletableLoadU[]; // idb
 extern char byte_4ECA93[]; // weak
 extern char byte_4ECACF[]; // weak
-extern char byte_4ECB0C[64]; // idb
 extern char aError_0[]; // idb
 extern char aCouldnTLoadMap[]; // idb
 extern char aOut02d_odm[]; // idb