diff mm7_4.cpp @ 766:a464d28566a6

days_played_without_rest
author Nomad
date Sat, 23 Mar 2013 20:22:51 +0200
parents a84db04439a4
children 45615cacad31
line wrap: on
line diff
--- a/mm7_4.cpp	Sat Mar 23 19:47:18 2013 +0200
+++ b/mm7_4.cpp	Sat Mar 23 20:22:51 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 )
   {