diff Party.cpp @ 910:8cd0b155bebe

Rings
author Ritor1
date Mon, 22 Apr 2013 17:34:36 +0600
parents 8fc2f035abc0
children ae747684f644
line wrap: on
line diff
--- a/Party.cpp	Mon Apr 22 09:25:22 2013 +0600
+++ b/Party.cpp	Mon Apr 22 17:34:36 2013 +0600
@@ -1029,24 +1029,13 @@
 //----- (00490D02) --------------------------------------------------------
 void Party::RestAndHeal()
 {
-  SpellBuff *v1; // esi@1
-  Player *v2; // esi@4
-  signed int v3; // ebx@4
-  SpellBuff *v4; // edi@4
-  int v5; // eax@9
-  char v6; // zf@9
+  Player *pPlayer; // esi@4
   ItemGen *v7; // eax@10
-  signed int v8; // ecx@10
-  int v9; // eax@18
-  int v10; // eax@25
   signed int v11; // ecx@26
   signed int v12; // [sp-4h] [bp-1Ch]@26
-  Party *v13; // [sp+Ch] [bp-Ch]@1
-  signed int v14; // [sp+10h] [bp-8h]@10
-  signed int v15; // [sp+14h] [bp-4h]@3
+  bool have_vessels_soul; // [sp+10h] [bp-8h]@10
 
-  v13 = this;
-  v1 = pParty->pPartyBuffs;
+/*  v1 = pParty->pPartyBuffs;
   do
   {
     v1->Reset();
@@ -1056,84 +1045,91 @@
   v15 = 0;
   do
   {
-    v2 = &pParty->pPlayers[v15];
+    pPlayer = &pParty->pPlayers[v15];
     v3 = 20;
-    v4 = v2->pPlayerBuffs;
+    v4 = pPlayer->pPlayerBuffs;
     do
     {
       v4->Reset();
       ++v4;
       --v3;
     }
-    while ( v3 );
-    v2->Zero();
-    if ( v2->pConditions[14] || v2->pConditions[15] || v2->pConditions[16] )
-      goto LABEL_33;
-    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();
-    v6 = v2->classType == PLAYER_CLASS_LICH;
-    v2->sMana = v5;
-    if ( v6 )
+    while ( v3 );*/
+  for ( uint i = 0; i < 20; ++i )
+    pParty->pPartyBuffs[i].Reset();
+  for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID )
+  {
+    pPlayer = &pParty->pPlayers[pPlayerID];
+    for ( uint i = 0; i < 20; ++i )
+      pPlayer->pPlayerBuffs[i].Reset();
+
+    pPlayer->Zero();
+    if ( pPlayer->pConditions[14] || pPlayer->pConditions[15] || pPlayer->pConditions[16] )//Dead/Petrified/Eradicated
+      continue;
+    pPlayer->pConditions[13] = 0;//Unconcious
+    pPlayer->pConditions[4] = 0;//Drunk
+    pPlayer->pConditions[3] = 0;//Fear
+    pPlayer->pConditions[2] = 0;//Sleep
+    pPlayer->pConditions[1] = 0;//Weak
+    pPlayer->uTimeToRecovery = 0;
+    pPlayer->sHealth = pPlayer->GetMaxHealth();
+    pPlayer->sMana = pPlayer->GetMaxMana();
+    if ( pPlayer->classType == PLAYER_CLASS_LICH )
     {
-      v14 = 0;
-      v7 = v2->pInventoryItems;//[0].field_1A;
-      v8 = 138;
-      do
+      have_vessels_soul = false;
+      v7 = pPlayer->pInventoryItems;//[0].field_1A;
+      for ( uint i = 138; i; --i )
       {
-		if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer== v15 + 1 )
-          v14 = 1;
+        if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 )
+          have_vessels_soul = true;
         ++v7;
-        --v8;
       }
-      while ( v8 );
-      if ( !v14 )
+      if ( !have_vessels_soul )
       {
-        v2->sHealth = v2->GetMaxHealth() / 2;
-        v2->sMana = v2->GetMaxMana() / 2;
+        pPlayer->sHealth = pPlayer->GetMaxHealth() / 2;
+        pPlayer->sMana = pPlayer->GetMaxMana() / 2;
       }
     }
-    if ( !v2->pConditions[17] )
+    if ( !pPlayer->pConditions[17] )// Zombie
     {
-      if ( v2->pConditions[10] || v2->pConditions[11] )
+      if ( pPlayer->pConditions[10] || pPlayer->pConditions[11] )
       {
         v11 = 4;
         v12 = 4;
       }
       else
       {
-        if ( !v2->pConditions[8] && !v2->pConditions[9] )
+        if ( !pPlayer->pConditions[8] && !pPlayer->pConditions[9] )
         {
-          if ( !v2->pConditions[6] && !v2->pConditions[7] )
-            goto LABEL_30;
-          v2->sHealth /= 2;
-          v10 = v2->sMana / 2;
-          goto LABEL_29;
+          if ( !pPlayer->pConditions[6] && !pPlayer->pConditions[7] )
+          {
+            if ( pPlayer->pConditions[5] )
+              pPlayer->sMana = 0;
+            UpdatePlayersAndHirelingsEmotions();
+            continue;
+          }
+          pPlayer->sHealth /= 2;
+          pPlayer->sMana = pPlayer->sMana / 2;
+          if ( pPlayer->pConditions[5] )
+            pPlayer->sMana = 0;
+          UpdatePlayersAndHirelingsEmotions();
+          continue;
         }
         v11 = 3;
         v12 = 3;
       }
-      v2->sHealth /= v11;
-      v10 = v2->sMana / v12;
-LABEL_29:
-      v2->sMana = v10;
-      goto LABEL_30;
+      pPlayer->sHealth /= v11;
+      pPlayer->sMana = pPlayer->sMana / v12;
+      if ( pPlayer->pConditions[5] )
+        pPlayer->sMana = 0;
+      UpdatePlayersAndHirelingsEmotions();
+      continue;
     }
-    v9 = v2->sHealth;
-    v2->sMana = 0;
-    v2->sHealth = v9 / 2;
-LABEL_30:
-    if ( v2->pConditions[5] )
-      v2->sMana = 0;
+    pPlayer->sMana = 0;
+    pPlayer->sHealth = pPlayer->sHealth / 2;
+    if ( pPlayer->pConditions[5] )
+      pPlayer->sMana = 0;
     UpdatePlayersAndHirelingsEmotions();
-LABEL_33:
-    ++v15;
   }
-  while ( v15 < 4 );
   pParty->days_played_without_rest = 0;
 }
\ No newline at end of file