diff mm7_6.cpp @ 958:9c2d08e42ed3

GivePartyExp
author Ritor1
date Thu, 02 May 2013 17:58:32 +0600
parents 840b78f6c2d3
children 9a5db2cf999a
line wrap: on
line diff
--- a/mm7_6.cpp	Thu May 02 15:37:16 2013 +0600
+++ b/mm7_6.cpp	Thu May 02 17:58:32 2013 +0600
@@ -1196,74 +1196,37 @@
 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
 
 //----- (004269A2) --------------------------------------------------------
-int __fastcall GivePartyExp(unsigned int a1)
+void __fastcall GivePartyExp(unsigned int pEXPNum)
 {
-  //unsigned __int64 v1; // qax@1
-  Player *v1;
-  int v1b;
-  signed int v2; // ecx@1
-  int *v3; // esi@1
-  bool v4; // edi@6
-  int *v5; // edi@10
-  Player *v6; // esi@10
-  int v7; // eax@13
-  unsigned __int8 v8; // cf@13
-  int v10[4]; // [sp+Ch] [bp-14h]@1
-  int v11; // [sp+1Ch] [bp-4h]@10
-
-  //v1 = __PAIR__((int)((char *)&pParty + 2620), a1);
-  v1 = pParty->pPlayers;
-  v1b = a1;
-  v2 = 0;
-  v3 = v10;
-  do
+  signed int pActivePlayerCount; // ecx@1
+  int pLearningPercent; // eax@13
+
+  pActivePlayerCount = 0;
+  for ( uint i = 0; i < 4; ++i )
+  {
+    if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] )
+      pActivePlayerCount ++;
+  }
+  if ( pActivePlayerCount )
   {
-    /*v4 = !(*(int *)(HIDWORD(v1) - 4) | *(int *)(HIDWORD(v1) - 8))
-      && !*(int *)HIDWORD(v1)
-      && !*(_QWORD *)(HIDWORD(v1) + 8)
-      && !*(_QWORD *)(HIDWORD(v1) + 16);*/
-	v4 = !(HIDWORD(v1->pConditions[13]) | LODWORD(v1->pConditions[13]))
-	  && !v1->pConditions[14]
-	  && !v1->pConditions[15]
-	  && !v1->pConditions[16];
-    *v3 = v4;
-    //HIDWORD(v1) += 6972;
-	++v1;
-    v2 += v4;
-    ++v3;
-  }
-  while ( v1 <= &pParty->pPlayers[3] );
-  if ( v2 )
-  {
-    v1b = v1b / v2;
-    v5 = v10;
-    v6 = pParty->pPlayers;//[0].uExperience;
-    v11 = v1b;
-    do
+    pEXPNum = pEXPNum / pActivePlayerCount;
+    for ( uint i = 0; i < 4; ++i )
     {
-      if ( *v5 )
+      if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] )
       {
-        if ( v11 )
+        if ( pEXPNum )
         {
-          LOBYTE(v7) = v6->GetLearningPercent();
-          v1b = v11 + v11 * (char)v7 / 100;
-          //v8 = __CFADD__((int)v1, LODWORD(v6->uExperience));
-		  //need review
-          LODWORD(v6->uExperience) += v1b;
-          //HIDWORD(v6->uExperience) += HIDWORD(v1) + v8;
-          if ( v6->uExperience > 4000000000i64 )
+          pLearningPercent = pParty->pPlayers[i].GetLearningPercent();
+          pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100;
+          pParty->pPlayers[i].uExperience += pEXPNum;
+          if ( pParty->pPlayers[i].uExperience > 4000000000i64 )
           {
-            HIDWORD(v6->uExperience) = 0;
-            LODWORD(v6->uExperience) = -294967296;
+            pParty->pPlayers[i].uExperience = 0;
           }
         }
       }
-      ++v6;
-      ++v5;
     }
-	while ( v6 <= &pParty->pPlayers[3] );
   }
-  return v1b;
 }
 
 //----- (00426A5A) --------------------------------------------------------