changeset 1827:0c75c3e7e436

cleaned up part of party.cpp, renamed byte_AE3368 to playerAlreadyPicked + 3 vars after it, moved them to party.cpp, some player.cpp bugfixes
author Grumpy7
date Fri, 11 Oct 2013 05:49:39 +0200
parents bdac32c645c5
children 35c1e4ff6ba7
files Actor.cpp OSWindow.cpp Party.cpp Party.h Player.cpp UI/UIShops.cpp UI/UiGame.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 10 files changed, 259 insertions(+), 625 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/Actor.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -2038,7 +2038,7 @@
   if ( v3 )
   {
 LABEL_12:
-    pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + GetPartyReputation());
+    pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + pParty->GetPartyReputation());
     if ( pParty->uFine < 0 )
       pParty->uFine = 0;
     if ( pParty->uFine > 4000000 )
@@ -4109,7 +4109,7 @@
 							{
 								Actor::Die(i);
 								if ( pActor->pMonsterInfo.uExp )
-									GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp);
+									pParty->GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp);
 							}
 						}
 					}
@@ -5286,7 +5286,7 @@
     Actor::ApplyFineForKillingPeasant(uActorID_Monster_);
     Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
     if ( pMonster->pMonsterInfo.uExp )
-      GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
+      pParty->GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
     v40 = SPEECH_51;
     if ( rand() % 100 < 20 )
       v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
--- a/OSWindow.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/OSWindow.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -690,7 +690,7 @@
         //SubMenu "Party"
     case 40006:  pParty->SetFood(pParty->uNumFoodRations + 20); break;
     case 40007:  pParty->SetGold(pParty->uNumGold + 10000);     break;
-    case 40008:  GivePartyExp(20000);  break;
+    case 40008:  pParty->GivePartyExp(20000);  break;
     case 40013:  pParty->SetGold(0);   break;
 
     case 40059:
--- a/Party.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/Party.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -31,6 +31,10 @@
 struct ActionQueue *pPartyActionQueue = new ActionQueue;
 
 
+std::array<bool, 4> playerAlreadyPicked; // byte_AE3368_
+char PickedPlayer2_unused; // byte_AE3369_
+char PickedPlayer3_unused; // byte_AE336A_
+char PickedPlayer4_unused; // byte_AE336B_
 
 
 
@@ -39,7 +43,7 @@
 {
   field_70A = 0;
 
-  for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+  for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; ++i)
   {
     auto npc = pNPCStats->pNewNPCData + i;
     if (npc->Hired() &&
@@ -112,27 +116,19 @@
 bool Party::_497FC5_check_party_perception_against_level()
 {
   int uMaxPerception; // edi@1
-  Player *v2; // esi@1
-  signed int v3; // ebx@1
-  Player *v4; // ecx@2
   signed int v5; // eax@3
   bool result; // eax@7
 
   uMaxPerception = 0;
-  v2 = this->pPlayers;
-  v3 = 4;
-  do
+  for (int i = 0; i < 4; i++)
   {
-    if ( v2->CanAct() )
+    if ( this->pPlayers[i].CanAct() )
     {
-      v5 = v2->GetPerception();
+      v5 = this->pPlayers[i].GetPerception();
       if ( v5 > uMaxPerception )
         uMaxPerception = v5;
     }
-    ++v2;
-    --v3;
   }
-  while ( v3 );
   if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 )
     result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per;
   else
@@ -151,19 +147,11 @@
 //----- (0049370F) --------------------------------------------------------
 int Party::GetNextActiveCharacter()
 {
-  Party *v1; // esi@1
   int v2; // eax@4
-  signed int v4; // ecx@6
-  Player *v5; // edx@6
   Player *v6; // eax@7
-  Player *v7; // ecx@23
   signed int v8; // esi@23
-  signed int v9; // edx@23
-  Player **v10; // edi@23
-  Player *v11; // eax@24
   int v12; // [sp+Ch] [bp-4h]@1
 
-  v1 = this;
   v12 = 0;
   if ( pParty->bTurnBasedModeOn == 1 )
   {
@@ -172,100 +160,54 @@
     v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID);
     return v2 + 1;
   }
-  v4 = 0;
-  v5 = v1->pPlayers;//[0].uTimeToRecovery;
-  while ( 1 )
+
+  if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] )
+    memset(playerAlreadyPicked.data(), 0, 4u);
+  for (int i = 0; i < 4; i++)
   {
-    v6 = ::pPlayers[v4 + 1];
-    if ( v6->pConditions[2]
-      || v6->pConditions[12]
-      || v6->pConditions[13]
-      || v6->pConditions[14]
-      || v6->pConditions[15]
-      || v6->pConditions[16]
-	  || v5->uTimeToRecovery )
+    v6 = &this->pPlayers[i];
+    if ( !v6->CanAct()
+      || v6->uTimeToRecovery > 0)
     {
-      byte_AE3368[v4] = 1;
+      playerAlreadyPicked[i] = true;
     }
-    else if ( !byte_AE3368[v4] )
+    else if ( !playerAlreadyPicked[i] )
+    {
+      playerAlreadyPicked[i] = true;
+      if (i > 0)          //TODO check if this condition really should be here. it is equal to the original source but still seems kind of weird
+        return i + 1;
       break;
-    ++v4;
-    ++v5;
-    if ( v4 >= 4 )
-      break;
-  }
-  if(v4<4)
-  {
-	  v12 = v4;
-	  byte_AE3368[v4] = 1;
+    }
   }
-  if ( (unsigned __int8)(byte_AE3369 & byte_AE336A & byte_AE336B) & byte_AE3368[0] )
-    memset(byte_AE3368.data(), 0, 4u);
-  v2 = v12;
-  if ( v12 )
-    return v2 + 1;
-  v7 = v1->pPlayers;//[0].uSpeedBonus;
-  v8 = 0;
-  v9 = 1;
-  v10 = &::pPlayers[1];
-  while ( 2 )
+
+  for (int i = 0; i < 4; i++)
   {
-    v11 = *v10;
-    if ( !(*v10)->pConditions[2]
-      && !v11->pConditions[12]
-      && !v11->pConditions[13]
-      && !v11->pConditions[14]
-      && !v11->pConditions[15]
-      && !v11->pConditions[16]
-	  && !v7->uTimeToRecovery )
+    if ( this->pPlayers[i].CanAct()
+      && this->pPlayers[i].uTimeToRecovery == 0 )
     {
-      if ( v12 )
+      if ( v12 == 0 || this->pPlayers[i].uSpeedBonus > v8 )
       {
-		if ( v7->uSpeedBonus > v8 )
-        {
-          v8 = v7->uSpeedBonus;
-          v12 = v9;
-        }
-      }
-      else
-      {
-        v8 = *(short *)v7;
-        v12 = v9;
+        v8 = this->pPlayers[i].uSpeedBonus;
+        v12 = i + 1;
       }
     }
-    ++v10;
-    ++v9;
-    ++v7;
-    if ( v9 - 1 < 4 )
-      continue;
-    return v12;
   }
+  return v12;
 }
 
 
 //----- (00493244) --------------------------------------------------------
 bool Party::HasItem(unsigned int uItemID)
 {
-  Player *v2; // edx@1
-  signed int v3; // ecx@2
-  ItemGen *v4; // eax@2
-
-  v2 = pParty->pPlayers;//[0].pInventoryItems;
-  while ( v2 <= &pParty->pPlayers[3] )
+  for (int player = 0; player < 4; player++)
   {
-    v3 = 0;
-	v4 = v2->pInventoryItemList.data();
-    do
+    for (int itemPos = 0; itemPos < 138; itemPos++)
     {
-      if ( v4->uItemID == uItemID )
-        return 1;
-      ++v3;
-      ++v4;
+      if (pParty->pPlayers[player].pOwnItems[itemPos].uItemID == uItemID)
+        return true;
     }
-    while ( v3 < 138 );
-    ++v2;
   }
-  return 0;
+  return false;
 }
 
 
@@ -324,216 +266,166 @@
   unsigned __int64 total_exp = 0;
   for (uint i = 0; i < 4; ++i)
     total_exp += pPlayers[i].uExperience;
-  return total_exp / 1000;
+  return (unsigned int)(min(total_exp / 1000, UINT_MAX));     //min wasn't present, but could be incorrect without it
 }
 
 //----- (0049137D) --------------------------------------------------------
 void Party::CreateDefaultParty(char bGiveItems)
 {
-  Party *pParty; // esi@1
-  signed __int16 v3; // ax@1
-  //int pResMagicBase; // ecx@1
   Player *pCharacter; // esi@3
-  //signed int uSpellBookPageCount; // edx@5
-  int pMagicSkills; // eax@5
   int uSkillIdx; // eax@11
-  //unsigned __int8 v9; // zf@37
-  //char v10; // sf@37
-  //unsigned __int8 v11; // of@37
-  ItemGen *pItems; // eax@38
-  signed int v13; // ecx@38
-  int uMaxSP; // eax@42
-  unsigned int v15; // [sp-4h] [bp-44h]@14
   unsigned int v16; // [sp-4h] [bp-44h]@26
-  int v17; // [sp+10h] [bp-30h]@1
-  int v18; // [sp+14h] [bp-2Ch]@11
   signed int uNumPlayers; // [sp+18h] [bp-28h]@1
   ItemGen Dst; // [sp+1Ch] [bp-24h]@10
 
-
-  pParty = this;
-
   pHireling1Name[0] = 0;
   pHireling2Name[0] = 0;
-  pParty->hirelingScrollPosition = 0;
+  this->hirelingScrollPosition = 0;
   memset(pHirelings, 0, 2 * sizeof(*pHirelings));
 
   strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan
-  pParty->pPlayers[0].uPrevFace = 17;
-  pParty->pPlayers[0].uCurrentFace = 17;
-  pParty->pPlayers[0].uPrevVoiceID = 17;
-  pParty->pPlayers[0].uVoiceID = 17;
-  pParty->pPlayers[0].uMight = 30;
-  pParty->pPlayers[0].uIntelligence = 5;
-  pParty->pPlayers[0].uWillpower = 5;
-  pParty->pPlayers[0].uEndurance = 13;
-  pParty->pPlayers[0].uAccuracy = 13;
-  pParty->pPlayers[0].uSpeed = 14;
-  pParty->pPlayers[0].uLuck = 7;
-  pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1;        // armsmaster
-  pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1;         // bow
-  pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1;         // sword
-  pParty->pPlayers[1].uPrevFace = 3;
-  pParty->pPlayers[1].uCurrentFace = 3;
-  pParty->pPlayers[1].uPrevVoiceID = 3;
-  pParty->pPlayers[1].uVoiceID = 3;
-  strcpy(pParty->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic
-  pParty->pPlayers[1].uMight = 13;
-  pParty->pPlayers[1].uIntelligence = 9;
-  pParty->pPlayers[1].uWillpower = 9;
-  pParty->pPlayers[1].uEndurance = 13;
-  pParty->pPlayers[1].uAccuracy = 13;
-  pParty->pPlayers[1].uSpeed = 13;
-  pParty->pPlayers[1].uLuck = 13;
-  pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1;        // stealing
-  pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1;         // dagger
-  pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1;        // disarm trap
-  pParty->pPlayers[2].uPrevFace = 14;
-  pParty->pPlayers[2].uCurrentFace = 14;
-  pParty->pPlayers[2].uPrevVoiceID = 14;
-  pParty->pPlayers[2].uVoiceID = 14;
-  strcpy(pParty->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena
-  pParty->pPlayers[2].uMight = 12;
-  pParty->pPlayers[2].uIntelligence = 9;
-  pParty->pPlayers[2].uWillpower = 20;
-  pParty->pPlayers[2].uEndurance = 22;
-  pParty->pPlayers[2].uAccuracy = 7;
-  pParty->pPlayers[2].uSpeed = 13;
-  pParty->pPlayers[2].uLuck = 7;
-  pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1;        // alchemy
-  pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1;        // body
-  pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1;         // mace
-  strcpy(pParty->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis
-  v3 = 10;
-  pParty->pPlayers[3].uPrevFace = 10;
-  pParty->pPlayers[3].uCurrentFace = 10;
-  //pResMagicBase = (int)&pParty->pPlayers[0].sResMagicBase;
-  pParty->pPlayers[3].uEndurance = 13;
-  pParty->pPlayers[3].uAccuracy = 13;
-  pParty->pPlayers[3].uSpeed = 13;
-  pParty->pPlayers[3].uPrevVoiceID = 10;
-  pParty->pPlayers[3].uVoiceID = 10;
-  pParty->pPlayers[3].uMight = 5;
-  pParty->pPlayers[3].uIntelligence = 30;
-  pParty->pPlayers[3].uWillpower = 9;
-  pParty->pPlayers[3].uLuck = 7;
-  pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1;        // air
-  pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1;        // fire
-  pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1;         // staff
-  //uNumPlayers = 4;
-  //while ( 1 )
+  this->pPlayers[0].uPrevFace = 17;
+  this->pPlayers[0].uCurrentFace = 17;
+  this->pPlayers[0].uPrevVoiceID = 17;
+  this->pPlayers[0].uVoiceID = 17;
+  this->pPlayers[0].uMight = 30;
+  this->pPlayers[0].uIntelligence = 5;
+  this->pPlayers[0].uWillpower = 5;
+  this->pPlayers[0].uEndurance = 13;
+  this->pPlayers[0].uAccuracy = 13;
+  this->pPlayers[0].uSpeed = 14;
+  this->pPlayers[0].uLuck = 7;
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1;        // armsmaster
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1;         // bow
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1;         // sword
+  this->pPlayers[1].uPrevFace = 3;
+  this->pPlayers[1].uCurrentFace = 3;
+  this->pPlayers[1].uPrevVoiceID = 3;
+  this->pPlayers[1].uVoiceID = 3;
+  strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic
+  this->pPlayers[1].uMight = 13;
+  this->pPlayers[1].uIntelligence = 9;
+  this->pPlayers[1].uWillpower = 9;
+  this->pPlayers[1].uEndurance = 13;
+  this->pPlayers[1].uAccuracy = 13;
+  this->pPlayers[1].uSpeed = 13;
+  this->pPlayers[1].uLuck = 13;
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1;        // stealing
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1;         // dagger
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1;        // disarm trap
+  this->pPlayers[2].uPrevFace = 14;
+  this->pPlayers[2].uCurrentFace = 14;
+  this->pPlayers[2].uPrevVoiceID = 14;
+  this->pPlayers[2].uVoiceID = 14;
+  strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena
+  this->pPlayers[2].uMight = 12;
+  this->pPlayers[2].uIntelligence = 9;
+  this->pPlayers[2].uWillpower = 20;
+  this->pPlayers[2].uEndurance = 22;
+  this->pPlayers[2].uAccuracy = 7;
+  this->pPlayers[2].uSpeed = 13;
+  this->pPlayers[2].uLuck = 7;
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1;        // alchemy
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1;        // body
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1;         // mace
+  strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis
+  this->pPlayers[3].uPrevFace = 10;
+  this->pPlayers[3].uCurrentFace = 10;
+  this->pPlayers[3].uEndurance = 13;
+  this->pPlayers[3].uAccuracy = 13;
+  this->pPlayers[3].uSpeed = 13;
+  this->pPlayers[3].uPrevVoiceID = 10;
+  this->pPlayers[3].uVoiceID = 10;
+  this->pPlayers[3].uMight = 5;
+  this->pPlayers[3].uIntelligence = 30;
+  this->pPlayers[3].uWillpower = 9;
+  this->pPlayers[3].uLuck = 7;
+  this->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
+  this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1;        // air
+  this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1;        // fire
+  this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1;         // staff
   for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++)
   {
     pCharacter = &pParty->pPlayers[uNumPlayers];
     if (pCharacter->classType == PLAYER_CLASS_KNIGHT)
-      pCharacter->sResMagicBase = v3; //player[i].pResMagicBase
-    //uSpellBookPageCount = 0;
-    //pMagicSkills = pPlayers[uNumPlayers].pActiveSkills[12];// Skills
-    //while ( !*(short *)pMagicSkills )         //player[i].skillFire
+      pCharacter->sResMagicBase = 10; //player[i].pResMagicBase
     pCharacter->lastOpenedSpellbookPage = 0;
-	for (int i = 0; i < 9; i++)//for Magic Book
+    for (int i = 0; i < 9; i++)//for Magic Book
     {
-      //++uSpellBookPageCount;
-      //pMagicSkills++;
-      //if ( uSpellBookPageCount >= 9 )
-        //goto LABEL_10;
 	    if (pPlayers[uNumPlayers].pActiveSkills[12+i])
-        {
-          pCharacter->lastOpenedSpellbookPage = i;
-          break;
-        }
+      {
+        pCharacter->lastOpenedSpellbookPage = i;
+        break;
+      }
     }
-//LABEL_10:
     pCharacter->uExpressionTimePassed = 0;
     Dst.Reset();
     if ( bGiveItems )
     {
       pItemsTable->GenerateItem(2, 40, &Dst); //ring
       pCharacter->AddItem2(-1, &Dst);
-      //uSkillIdx = 0;
-      //v18 = 0;
-      //do
-	  for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++)
+	    for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++)
       {
         if ( pCharacter->pActiveSkills[uSkillIdx] )
         {
           switch ( uSkillIdx )
           {
             case PLAYER_SKILL_STAFF:
-              v15 = ITEM_STAFF_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_STAFF_1);
               break;
             case PLAYER_SKILL_SWORD:
-              v15 = ITEM_LONGSWORD_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_LONGSWORD_1);
               break;
             case PLAYER_SKILL_DAGGER:
-              v15 = ITEM_DAGGER_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_DAGGER_1);
               break;
             case PLAYER_SKILL_AXE:
-              v15 = ITEM_AXE_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_AXE_1);
               break;
             case PLAYER_SKILL_SPEAR:
-              v15 = ITEM_SPEAR_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_SPEAR_1);
               break;
             case PLAYER_SKILL_BOW:
-              v15 = ITEM_CROSSBOW_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_CROSSBOW_1);
               break;
             case PLAYER_SKILL_MACE:
-              v15 = ITEM_MACE_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_MACE_1);
               break;
             case PLAYER_SKILL_SHIELD:
-              v15 = ITEM_BUCKLER_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_BUCKLER_1);
               break;
             case PLAYER_SKILL_LEATHER:
-              v15 = ITEM_LEATHER_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_LEATHER_1);
               break;
             case PLAYER_SKILL_CHAIN:
-              v15 = ITEM_CHAINMAIL_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_CHAINMAIL_1);
               break;
             case PLAYER_SKILL_PLATE:
-              v15 = ITEM_PLATE_1;
-              pCharacter->WearItem(v15);
+              pCharacter->WearItem(ITEM_PLATE_1);
               break;
             case PLAYER_SKILL_FIRE:
-              v16 = ITEM_SPELLBOOK_FIRE_STRIKE;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_FIRE_STRIKE);
               break;
             case PLAYER_SKILL_AIR:
-              v16 = ITEM_SPELLBOOK_AIR_FEATHER_FALL;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_AIR_FEATHER_FALL);
               break;
             case PLAYER_SKILL_WATER:
-              v16 = ITEM_SPELLBOOK_WATER_POISON_SPRAY;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_WATER_POISON_SPRAY);
               break;
             case PLAYER_SKILL_EARTH:
-              v16 = ITEM_SPELLBOOK_EARTH_SLOW;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_EARTH_SLOW);
               break;
             case PLAYER_SKILL_SPIRIT:
-              v16 = ITEM_SPELLBOOK_SPIRIT_BLESS;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_SPIRIT_BLESS);
               break;
             case PLAYER_SKILL_MIND:
-              v16 = ITEM_SPELLBOOK_MIND_MIND_BLAST;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_MIND_MIND_BLAST);
               break;
             case PLAYER_SKILL_BODY:
-              v16 = ITEM_SPELLBOOK_BODY_FIRST_AID;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_SPELLBOOK_BODY_FIRST_AID);
               break;
             case PLAYER_SKILL_ITEM_ID:
             case PLAYER_SKILL_REPAIR:
@@ -547,62 +439,30 @@
               pCharacter->AddItem(-1, v16);
               break;
             case PLAYER_SKILL_DODGE:
-              v16 = ITEM_BOOTS_1;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_BOOTS_1);
               break;
             case PLAYER_SKILL_UNARMED:
-              v16 = ITEM_GAUNTLETS_1;
-              pCharacter->AddItem(-1, v16);
+              pCharacter->AddItem(-1, ITEM_GAUNTLETS_1);
               break;
             default:
               break;
           }
         }
-        //uSkillIdx = v18 + 1;
-        //v11 = uSkillIdx > 36;
-        //v9 = v18 == 35;
-        //v10 = uSkillIdx - 35 < 0;
       }
-      //while (uSkillIdx < 36);
-      pItems = pCharacter->pInventoryItemList.data();
-      //v13 = 138;
       for (int i = 0; i < 138; i++)
       {
-		if ( pItems->uItemID )
-          pItems->uAttributes |= 1;
-        ++pItems;
-        //--v13;
+	      if ( pCharacter->pInventoryItemList[i].uItemID != 0)
+          pCharacter->pInventoryItemList[i].SetIdentified();
       }
-      //while ( v13 );
     }
     pCharacter->sHealth = pCharacter->GetMaxHealth();
     pCharacter->sMana = pCharacter->GetMaxMana();
-    //pCharacter++;
-    //uNumPlayers--;
-    //if (!uNumPlayers)
-      //break;
-    //pResMagicBase = (int)pCharacter;
-    v3 = 10;
   }
 }
 
 //----- (004917CE) --------------------------------------------------------
 int Party::Reset()
-{
-  //Party *v1; // esi@1
-  //unsigned __int64 *pTimePlayed; // edi@1
-  //bool v3; // edx@1
-  //Player **v4; // eax@1
-  //Player *v5; // ecx@1
-  PLAYER_SEX pSex; // cl@3
-  PLAYER_SEX v7; // al@6
-  PLAYER_SEX v8; // al@9
-  PLAYER_SEX v9; // cl@12
-  //Player *v12; // edx@17
-  //signed int v13; // edi@18
-  SpellBuff *v14; // ebx@21
-  signed int v15; // edi@21
-  
+{  
   Zero();
 
   field_708 = 15;
@@ -632,40 +492,8 @@
   pPlayers[0].uPrevVoiceID = 17;
   pPlayers[0].uVoiceID = 17;
   pPlayers[0].SetInitialStats();
- 
-  switch ( pPlayers[0].uVoiceID )
-  {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-    case 8:
-    case 9:
-    case 12:
-    case 13:
-    case 16:
-    case 17:
-    case 20:
-    case 23:
-    default:
-      pSex = SEX_MALE;
-      break;
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 10:
-    case 11:
-    case 14:
-    case 15:
-    case 18:
-    case 19:
-    case 21:
-    case 24:
-      pSex = SEX_FEMALE;
-      break;
-  }
-  pPlayers[0].uSex = pSex;
+
+  pPlayers[0].uSex = pPlayers[0].GetSexByVoice();
   pPlayers[0].RandomizeName();
   strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]);
 
@@ -674,128 +502,24 @@
   pPlayers[1].uPrevVoiceID = 3;
   pPlayers[1].uVoiceID = 3;
   pPlayers[1].SetInitialStats();
-  v7 = SEX_MALE;
-  switch (pPlayers[1].uVoiceID)
-  {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-    case 8:
-    case 9:
-    case 0xCu:
-    case 0xDu:
-    case 0x10u:
-    case 0x11u:
-    case 0x14u:
-    case 0x17u:
-      v7 = SEX_MALE;
-      break;
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 0xAu:
-    case 0xBu:
-    case 0xEu:
-    case 0xFu:
-    case 0x12u:
-    case 0x13u:
-    case 0x15u:
-    case 0x18u:
-      v7 = SEX_FEMALE;
-      break;
-    default:
-      break;
-  }
-  pPlayers[1].uSex = v7;
+  pPlayers[1].uSex = pPlayers[1].GetSexByVoice();
   pPlayers[1].RandomizeName();
   strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]);
   pPlayers[2].uCurrentFace = 14;
   pPlayers[2].uPrevVoiceID = 14;
   pPlayers[2].uVoiceID = 14;
   pPlayers[2].SetInitialStats();
-  v8 = SEX_MALE;
-  switch (pPlayers[2].uVoiceID)
-  {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-    case 8:
-    case 9:
-    case 0xCu:
-    case 0xDu:
-    case 0x10u:
-    case 0x11u:
-    case 0x14u:
-    case 0x17u:
-      v8 = SEX_MALE;
-      break;
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 0xAu:
-    case 0xBu:
-    case 0xEu:
-    case 0xFu:
-    case 0x12u:
-    case 0x13u:
-    case 0x15u:
-    case 0x18u:
-      v8 = SEX_FEMALE;
-      break;
-    default:
-      break;
-  }
-  pPlayers[2].uSex = v8;
+  pPlayers[2].uSex = pPlayers[3].GetSexByVoice();
   pPlayers[2].RandomizeName();
   strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]);
   pPlayers[3].uCurrentFace = 10;
   pPlayers[3].uPrevVoiceID = 10;
   pPlayers[3].uVoiceID = 10;
   pPlayers[3].SetInitialStats();
-  v9 = SEX_MALE;
-  switch (pPlayers[3].uVoiceID)
-  {
-    case 0u:
-    case 1u:
-    case 2u:
-    case 3u:
-    case 8u:
-    case 9u:
-    case 0xCu:
-    case 0xDu:
-    case 0x10u:
-    case 0x11u:
-    case 0x14u:
-    case 0x17u:
-      v9 = SEX_MALE;
-      break;
-    case 4u:
-    case 5u:
-    case 6u:
-    case 7u:
-    case 0xAu:
-    case 0xBu:
-    case 0xEu:
-    case 0xFu:
-    case 0x12u:
-    case 0x13u:
-    case 0x15u:
-    case 0x18u:
-      v9 = SEX_FEMALE;
-      break;
-    default:
-      break;
-  }
-  pPlayers[3].uSex = v9;
+  pPlayers[3].uSex = pPlayers[3].GetSexByVoice();
   pPlayers[3].RandomizeName();
   strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]);
-
-
-
+  
   for (uint i = 0; i < 4; ++i)
   {
     pPlayers[i].uTimeToRecovery = 0;
@@ -844,30 +568,22 @@
   int v1; // edi@9
   int v2; // ebx@9
   int v3; // eax@9
-  unsigned int v4; // [sp+8h] [bp-4h]@4
 
   if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 )
     pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
   if ( pParty->bTurnBasedModeOn != 1 )
   {
-    v4 = 0;
-    if ( (signed int)uNumActors > 0 )
+    for (unsigned int i = 0; i < uNumActors; i++)
     {
-      v0 = pActors.data();//[0].pMonsterInfo.uMovementType;
-      do
+      v0 = &pActors[i];
+      if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 )
       {
-        if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 )
-        {
-		  v1 = abs(v0->vPosition.x - pParty->vPosition.x);
-		  v2 = abs(v0->vPosition.y - pParty->vPosition.y);
-		  v3 = abs(v0->vPosition.z - pParty->vPosition.z);
-          if (int_get_vector_length(v1, v2, v3) < 512)
-            Actor::AI_Flee(v4, 4, 0, 0);
-        }
-        ++v4;
-        ++v0;
+        v1 = abs(v0->vPosition.x - pParty->vPosition.x);
+        v2 = abs(v0->vPosition.y - pParty->vPosition.y);
+        v3 = abs(v0->vPosition.z - pParty->vPosition.z);
+        if (int_get_vector_length(v1, v2, v3) < 512)
+          Actor::AI_Flee(i, 4, 0, 0);
       }
-      while ( (signed int)v4 < (signed int)uNumActors );
     }
   }
 }
@@ -875,15 +591,6 @@
 //----- (00491BF9) --------------------------------------------------------
 void Party::ResetPosMiscAndSpellBuffs()
 {
-  Party *v1; // esi@1
-  Player *v2; // edi@1
-  SpellBuff *v3; // ebx@2
-  SpellBuff *v4; // esi@5
-  signed int v5; // edi@5
-  signed int v6; // [sp+8h] [bp-8h]@1
-  signed int v7; // [sp+Ch] [bp-4h]@2
-
-  v1 = this;
   this->vPosition.y = 0;
   this->vPosition.z = 0;
   this->vPosition.x = 0;
@@ -901,56 +608,30 @@
   this->field_6FC = 0;
   this->field_708 = 15;
   this->field_0 = 25;
-  v2 = this->pPlayers;//[0].pPlayerBuffs;
-  v6 = 4;
-  do
+
+  for (auto playerId = 0; playerId < 4; playerId++)
   {
-    v3 = v2->pPlayerBuffs.data();
-    v7 = 24;
-    do
+    for (auto buffId = 0; buffId < 24; buffId++)
     {
-      v3->Reset();
-      ++v3;
-      --v7;
+      this->pPlayers[playerId].pPlayerBuffs[buffId].Reset();
     }
-    while ( v7 );
-    ++v2;
-    --v6;
   }
-  while ( v6 );
-  v4 = v1->pPartyBuffs;
-  v5 = 20;
-  do
+  for (auto buffId = 0; buffId < 20; buffId++)
   {
-    v4->Reset();
-    ++v4;
-    --v5;
+    this->pPartyBuffs[buffId].Reset();
   }
-  while ( v5 );
 }
 
 //----- (004909F4) --------------------------------------------------------
 void Party::UpdatePlayersAndHirelingsEmotions()
 {
-  //Player *v1; // esi@2
-  //unsigned int v2; // eax@3
-  //__int16 v3; // cx@5
   int v4; // edx@27
-  //signed int v5; // eax@52
-  //PlayerFrame *v6; // edx@53
-  //NPCData *v7; // esi@60
-  //signed int v8; // ebp@61
-  //int v9; // ebx@62
-  //unsigned int v10; // edi@62
-  //signed int v11; // [sp+0h] [bp-4h]@2
 
-  //v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID;
   for (int i = 0; i < 4; ++i)
   {
-    auto player = pPlayers + i;
+    Player* player = &pPlayers[i];
     player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed;
 
-
     auto condition = player->GetMajorConditionIdx();
     if (condition == Condition_Good || condition == Condition_Zombie)
     {
@@ -982,19 +663,19 @@
         else              player->expression = CHARACTER_EXPRESSION_30;
       }
 
-      for (int j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
+      for (unsigned int j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
       {
-        auto frame = pPlayerFrameTable->pFrames + j;
+        PlayerFrame* frame = &pPlayerFrameTable->pFrames[j];
         if (frame->expression == player->expression)
         {
-          player->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[j].uAnimLength;
+          player->uExpressionTimeLength = 8 * frame->uAnimLength;
           break;
         }
       }
     }
-    else if (player->expression != 34 &&
-             player->expression != 35 &&
-             player->expression != 36 ||
+    else if (player->expression != CHARACTER_EXPRESSION_DMGRECVD_MINOR &&
+             player->expression != CHARACTER_EXPRESSION_DMGRECVD_MODERATE &&
+             player->expression != CHARACTER_EXPRESSION_DMGRECVD_MAJOR ||
              player->uExpressionTimePassed >= player->uExpressionTimeLength)
     {
       player->uExpressionTimeLength = 0;
@@ -1025,10 +706,9 @@
     }
   }
 
-
   for (int i = 0; i < 2; ++i)
   {
-    auto hireling = pParty->pHirelings + i;
+    NPCData* hireling = &pParty->pHirelings[i];
     if (!hireling->evt_C)
       continue;
 
@@ -1053,33 +733,11 @@
 void Party::RestAndHeal()
 {
   Player *pPlayer; // esi@4
-  ItemGen *v7; // eax@10
-  signed int v11; // ecx@26
-  signed int v12; // [sp-4h] [bp-1Ch]@26
   bool have_vessels_soul; // [sp+10h] [bp-8h]@10
 
-/*  v1 = pParty->pPartyBuffs;
-  do
-  {
-    v1->Reset();
-    ++v1;
-  }
-  while ( (signed int)v1 < (signed int)pParty->pPlayers );
-  v15 = 0;
-  do
-  {
-    pPlayer = &pParty->pPlayers[v15];
-    v3 = 20;
-    v4 = pPlayer->pPlayerBuffs;
-    do
-    {
-      v4->Reset();
-      ++v4;
-      --v3;
-    }
-    while ( v3 );*/
   for ( uint i = 0; i < 20; ++i )
     pParty->pPartyBuffs[i].Reset();
+
   for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID )
   {
     pPlayer = &pParty->pPlayers[pPlayerID];
@@ -1087,25 +745,23 @@
       pPlayer->pPlayerBuffs[i].Reset();
 
     pPlayer->Zero();
-    if ( pPlayer->pConditions[14] || pPlayer->pConditions[15] || pPlayer->pConditions[16] )//Dead/Petrified/Eradicated
+    if ( pPlayer->pConditions[Condition_Dead] || pPlayer->pConditions[Condition_Pertified] || pPlayer->pConditions[Condition_Eradicated] )//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->pConditions[Condition_Unconcious] = 0;//Unconcious
+    pPlayer->pConditions[Condition_Drunk] = 0;//Drunk
+    pPlayer->pConditions[Condition_Fear] = 0;//Fear
+    pPlayer->pConditions[Condition_Sleep] = 0;//Sleep
+    pPlayer->pConditions[Condition_Weak] = 0;//Weak
     pPlayer->uTimeToRecovery = 0;
     pPlayer->sHealth = pPlayer->GetMaxHealth();
     pPlayer->sMana = pPlayer->GetMaxMana();
     if ( pPlayer->classType == PLAYER_CLASS_LICH )
     {
       have_vessels_soul = false;
-      v7 = pPlayer->pInventoryItemList.data();//[0].field_1A;
-      for ( uint i = 138; i; --i )
+      for ( uint i = 0; i < 138; i++ )
       {
-        if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 )
+        if ( pPlayer->pInventoryItemList[i].uItemID == ITEM_LICH_JAR_FULL && pPlayer->pInventoryItemList[i].uHolderPlayer == pPlayerID + 1 )
           have_vessels_soul = true;
-        ++v7;
       }
       if ( !have_vessels_soul )
       {
@@ -1113,44 +769,28 @@
         pPlayer->sMana = pPlayer->GetMaxMana() / 2;
       }
     }
-    if ( !pPlayer->pConditions[17] )// Zombie
+
+    if (pPlayer->pConditions[Condition_Zombie])
+    {
+      pPlayer->sMana = 0;
+      pPlayer->sHealth /= 2;
+    }
+    else if ( pPlayer->pConditions[Condition_Poison3] || pPlayer->pConditions[Condition_Disease3] )
     {
-      if ( pPlayer->pConditions[10] || pPlayer->pConditions[11] )
-      {
-        v11 = 4;
-        v12 = 4;
-      }
-      else
-      {
-        if ( !pPlayer->pConditions[8] && !pPlayer->pConditions[9] )
-        {
-          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;
-      }
-      pPlayer->sHealth /= v11;
-      pPlayer->sMana = pPlayer->sMana / v12;
-      if ( pPlayer->pConditions[5] )
-        pPlayer->sMana = 0;
-      UpdatePlayersAndHirelingsEmotions();
-      continue;
+      pPlayer->sHealth /= 4;
+      pPlayer->sMana /= 4;
     }
-    pPlayer->sMana = 0;
-    pPlayer->sHealth = pPlayer->sHealth / 2;
-    if ( pPlayer->pConditions[5] )
+    else if ( pPlayer->pConditions[Condition_Poison2] || pPlayer->pConditions[Condition_Disease2] )
+    {
+      pPlayer->sHealth /= 3;
+      pPlayer->sMana /= 3;
+    }
+    else if ( pPlayer->pConditions[Condition_Poison1] || pPlayer->pConditions[Condition_Disease1] )
+    {
+      pPlayer->sHealth /= 2;
+      pPlayer->sMana /=  2;
+    }
+    if ( pPlayer->pConditions[Condition_Insane] )
       pPlayer->sMana = 0;
     UpdatePlayersAndHirelingsEmotions();
   }
@@ -1160,22 +800,16 @@
 //----- (004938D1) --------------------------------------------------------
 void __fastcall Rest(unsigned int uHoursToSleep)
 {
-  unsigned int v1; // esi@1
-  double v2; // st7@3
-  Player **v3; // esi@3
+  signed __int64 v2; // st7@3
 
-  v1 = uHoursToSleep;
   if ( uHoursToSleep > 240 )
     InitializeActors();
-  v2 = (double)(7680 * v1) * 0.033333335;
-  pParty->uTimePlayed += (signed __int64)v2;
-  v3 = &pPlayers[1];
-  do
+  v2 = (signed __int64)((7680 * uHoursToSleep) * 0.033333335);
+  pParty->uTimePlayed += v2;
+  for (int i = 0; i < 4; i++)
   {
-    (*v3)->Recover((signed __int64)v2);
-    ++v3;
+    pPlayers[i + 1]->Recover((int)v2);
   }
-  while ( (signed int)v3 <= (signed int)&pPlayers[4] );
   _494035_timed_effects__water_walking_damage__etc();
 }
 //----- (004B1BDB) --------------------------------------------------------
@@ -1183,7 +817,6 @@
 {
   signed __int64 v1; // ST2C_8@1
   signed __int64 v2; // qax@1
-  signed __int64 v3; // ST1C_8@1
   unsigned __int64 v4; // qax@1
   unsigned int v5; // ebx@1
   Player *v6; // ebx@1
@@ -1193,26 +826,25 @@
   pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335);
   v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
   v2 = v1 / 60 / 60;
-  v3 = v2;
   v4 = (unsigned int)v2 / 0x18;
   v5 = (unsigned int)(v4 / 7) >> 2;
   pParty->uCurrentTimeSecond = v1 % 60;
   pParty->uCurrentMinute = v1 / 60 % 60;
-  pParty->uCurrentHour = v3 % 24;
+  pParty->uCurrentHour = v2 % 24;
   pParty->uCurrentMonthWeek = v4 / 7 & 3;
   pParty->uDaysPlayed = (unsigned int)v4 % 0x1C;
   pParty->uCurrentMonth = v5 % 0xC;
   pParty->uCurrentYear = v5 / 0xC + game_starting_year;
   pParty->RestAndHeal();
   dword_507B94 = 1;
-  v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
-  do
+  for (int i = 0; i < 4; i++)
   {
-	v6->uTimeToRecovery = 0;
-	memset(&v6->uTimeToRecovery, 0, 4u);
-    ++v6;
+    pParty->pPlayers[i].uTimeToRecovery = 0;
+    pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
+    pParty->pPlayers[i].uNumArmageddonCasts = 0;
+    pParty->pPlayers[i].uNumFireSpikeCasts = 0;
+    pParty->pPlayers[i].field_1B3B = 0;
   }
-  while ( v6 <= &pParty->pPlayers[3] );
   pParty->UpdatePlayersAndHirelingsEmotions();
 }
 //----- (0041F5BE) --------------------------------------------------------
@@ -1241,7 +873,7 @@
 }
 
 //----- (0047752B) --------------------------------------------------------
-int  GetPartyReputation()
+int Party::GetPartyReputation()
 {
   DDM_DLV_Header *v0; // ebx@1
   signed int v1; // esi@3
@@ -1263,25 +895,31 @@
   return v1 + v0->uReputation;
 }
 //----- (004269A2) --------------------------------------------------------
-void __fastcall GivePartyExp(unsigned int pEXPNum)
+void Party::GivePartyExp(unsigned int pEXPNum)
 {
   signed int pActivePlayerCount; // ecx@1
   int pLearningPercent; // eax@13
 
-  pActivePlayerCount = 0;
-  for ( uint i = 0; i < 4; ++i )
+  if ( pEXPNum > 0)
   {
-    if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] )
-      pActivePlayerCount ++;
-  }
-  if ( pActivePlayerCount )
-  {
-    pEXPNum = pEXPNum / pActivePlayerCount;
+    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] )
+      if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && 
+        !pParty->pPlayers[i].pConditions[Condition_Dead] && 
+        !pParty->pPlayers[i].pConditions[Condition_Pertified] && 
+        !pParty->pPlayers[i].pConditions[Condition_Eradicated] )
+        pActivePlayerCount ++;
+    }
+    if ( pActivePlayerCount )
+    {
+      pEXPNum = pEXPNum / pActivePlayerCount;
+      for ( uint i = 0; i < 4; ++i )
       {
-        if ( pEXPNum )
+        if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && 
+          !pParty->pPlayers[i].pConditions[Condition_Dead] && 
+          !pParty->pPlayers[i].pConditions[Condition_Pertified] && 
+          !pParty->pPlayers[i].pConditions[Condition_Eradicated] )
         {
           pLearningPercent = pParty->pPlayers[i].GetLearningPercent();
           pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100;
@@ -1299,8 +937,8 @@
 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal)
 {
   unsigned int v2; // edi@1
-  int v3; // ebp@1
-  unsigned int v4; // esi@1
+  int hirelingSalaries; // ebp@1
+  unsigned int goldToGain; // esi@1
   int v5; // ecx@6
   NPCData *v6; // eax@6
   signed int v7; // edx@8
@@ -1310,11 +948,11 @@
   int v11; // eax@21
   NPCData *v12; // ecx@21
   unsigned int v13; // ecx@23
-  signed int v14; // [sp+Ch] [bp-4h]@6
+  signed int hirelingCount; // [sp+Ch] [bp-4h]@6
 
   v2 = 0;
-  v3 = 0;
-  v4 = uNumGold;
+  hirelingSalaries = 0;
+  goldToGain = uNumGold;
   if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal )
   {
     if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 )
@@ -1329,14 +967,14 @@
   }
   else
   {
-    v14 = 0;
+    hirelingCount = 0;
     v5 = 0;
     v6 = pParty->pHirelings;
     do
     {
       if ( v6->pName )
       {
-        v7 = v14++;
+        v7 = hirelingCount++;
         pTmpBuf[v7] = v5;
       }
       ++v6;
@@ -1353,7 +991,7 @@
           && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName))
           && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) )
         {
-          v10 = v14++;
+          v10 = hirelingCount++;
           pTmpBuf[v10] = v8 + 2;
         }
         ++v8;
@@ -1362,7 +1000,7 @@
       while ( v8 < (signed int)pNPCStats->uNumNewNPCs );
       v2 = 0;
     }
-    if ( v14 > 0 )
+    if ( hirelingCount > 0 )
     {
       do
       {
@@ -1372,31 +1010,31 @@
           v12 = &pParty->pHirelings[v11];
         v13 = v12->uProfession;
         if ( v13 )
-          v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13);
+          hirelingSalaries += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13);
         ++v2;
       }
-      while ( (signed int)v2 < v14 );
+      while ( (signed int)v2 < hirelingCount );
     }
     if ( CheckHiredNPCSpeciality(Factor) )
-      v4 += (signed int)(10 * v4) / 100;
+      goldToGain += (signed int)(10 * goldToGain) / 100;
     if ( CheckHiredNPCSpeciality(Banker) )
-      v4 += (signed int)(20 * v4) / 100;
+      goldToGain += (signed int)(20 * goldToGain) / 100;
     if ( CheckHiredNPCSpeciality(Pirate) )
-      v4 += (signed int)(10 * v4) / 100;
-    if ( v3 )
+      goldToGain += (signed int)(10 * goldToGain) / 100;
+    if ( hirelingSalaries )
     {
-      v3 = (signed int)(v4 * v3 / 100) / 100;
-      if ( v3 < 1 )
-        v3 = 1;
-      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)!
+      hirelingSalaries = (signed int)(goldToGain * hirelingSalaries / 100) / 100;
+      if ( hirelingSalaries < 1 )
+        hirelingSalaries = 1;
+      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], goldToGain, hirelingSalaries);// You found %lu gold (followers take %lu)!
     }
     else
     {
-      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold!
+      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], goldToGain);// You found %lu gold!
     }
     v2 = 0;
   }
-  pParty->uNumGold += v4 - v3;
+  pParty->uNumGold += goldToGain - hirelingSalaries;
   pUIAnim_Gold->uAnimTime = v2;
   pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength;
   if ( pTmpBuf2[0] )
--- a/Party.h	Wed Oct 09 09:08:15 2013 +0200
+++ b/Party.h	Fri Oct 11 05:49:39 2013 +0200
@@ -185,7 +185,10 @@
   bool AddItemToParty(ItemGen *pItem);
   void Yell();
   void CountHirelings();
-  
+
+  void GivePartyExp(unsigned int pEXPNum);
+  int GetPartyReputation();
+
   static void SetGold(unsigned int uNumGold);
   static void TakeGold(unsigned int uNumGold);
   static void SetFood(unsigned int uNumFood);
--- a/Player.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/Player.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -1184,7 +1184,7 @@
   if ( SkillToMastery(v2) >= 4 )
     return 10000;
 
-  v7 = GetPartyReputation();
+  v7 = pParty->GetPartyReputation();
   int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
   v5 = multiplier * (v2 & 0x3F);
   if (v5 == 0)
@@ -2936,7 +2936,7 @@
 
   v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt);
 
-  Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery);
+  //Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery);
 
   if (uTimeToRecovery > v3)
   {
@@ -4232,8 +4232,10 @@
     break;
   case 6:
     statToChange = &this->uLuck;
+    break;
   default:
     Error("(%u)", eAttribute);
+    break;
   }
   if ( *statToChange < baseValue )
   {
@@ -7403,7 +7405,7 @@
               Actor::ApplyFineForKillingPeasant(uActorID);
               Actor::AggroSurroundingPeasants(uActorID, 1);
               if ( actorPtr->pMonsterInfo.uExp )
-                GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
+                pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
               int speechToPlay = SPEECH_51;
               if ( rand() % 100 < 20 )
                 speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1;
@@ -7595,7 +7597,7 @@
                 Actor::ApplyFineForKillingPeasant(uActorID);
                 Actor::AggroSurroundingPeasants(uActorID, 1);
                 if ( actorPtr->pMonsterInfo.uExp )
-                  GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
+                  pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
                 int speechToPlay = SPEECH_51;
                 if ( rand() % 100 < 20 )
                   speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1;
@@ -7976,6 +7978,7 @@
     uPlayerIdx = 2;
   else if ( this == pPlayers[4] )  
     uPlayerIdx = 3;
-  Error("Unexpected player pointer");
+  else
+    Error("Unexpected player pointer");
   return uPlayerIdx;
 }
\ No newline at end of file
--- a/UI/UIShops.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/UI/UIShops.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -1649,7 +1649,7 @@
       a3 = 0;
       if ( pMapStats->GetMapInfo(pCurrentMapName) )
         a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm;
-      party_reputation = GetPartyReputation();
+      party_reputation = pParty->GetPartyReputation();
       if (pPlayers[uActiveCharacter]->CanSteal())
       {
         if ( GetAsyncKeyState(VK_CONTROL) )
--- a/UI/UiGame.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/UI/UiGame.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -932,9 +932,9 @@
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pText, 84, 0);
   }
 
-  if ( GetPartyReputation() >= 0 )
+  if ( pParty->GetPartyReputation() >= 0 )
   {
-    if ( GetPartyReputation() <= 5 )
+    if ( pParty->GetPartyReputation() <= 5 )
       pTextColor = ui_character_default_text_color;
     else
       pTextColor = ui_character_bonus_text_color_neg;
@@ -942,7 +942,7 @@
   else
     pTextColor = ui_character_bonus_text_color;
 
-  sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], pTextColor, GetReputationString(GetPartyReputation()));//Reputation
+  sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], pTextColor, GetReputationString(pParty->GetPartyReputation()));//Reputation
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0);
   sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Слава
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0);
--- a/mm7_4.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/mm7_4.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -1888,7 +1888,7 @@
           i += 2;
           break;
         case 11:
-          pReputation = GetPartyReputation();
+          pReputation = pParty->GetPartyReputation();
           if ( pReputation >= 25 )
             pText = pGlobalTXT_LocalizationStrings[379];
           else//v25 < 25
--- a/mm7_data.cpp	Wed Oct 09 09:08:15 2013 +0200
+++ b/mm7_data.cpp	Fri Oct 11 05:49:39 2013 +0200
@@ -1316,10 +1316,6 @@
 std::array<char *, 36> pClassNames;
 std::array<char *, 19> aCharacterConditionNames;
 std::array<char *, 38> pSkillNames;
-std::array<char, 777> byte_AE3368; // weak
-char byte_AE3369; // weak
-char byte_AE336A; // weak
-char byte_AE336B; // weak
 int dword_AE336C; // weak
 int dword_AE3370; // weak
 char byte_AE5B91; // weak
--- a/mm7_data.h	Wed Oct 09 09:08:15 2013 +0200
+++ b/mm7_data.h	Fri Oct 11 05:49:39 2013 +0200
@@ -975,10 +975,6 @@
 extern std::array<char *, 36> pClassNames;
 extern std::array<char *, 19> aCharacterConditionNames;
 extern std::array<char *, 38> pSkillNames;
-extern std::array<char, 777> byte_AE3368; // weak
-extern char byte_AE3369; // weak
-extern char byte_AE336A; // weak
-extern char byte_AE336B; // weak
 extern int dword_AE336C; // weak
 extern int dword_AE3370; // weak
 extern char byte_AE5B91; // weak
@@ -1100,7 +1096,6 @@
 bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID);
 int sr_424CD7(unsigned int uVertexID); // idb
 int BuildingVerticesClipping(unsigned int uNumVertices);
-void __fastcall GivePartyExp(unsigned int pEXPNum);
 bool __fastcall sub_427769_spell(unsigned int uSpellID);
 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);
 void _42ECB5_PlayerAttacksActor();
@@ -1195,7 +1190,6 @@
 void OnPaperdollLeftClick();
 void OnPressSpace();
 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2);
-int GetPartyReputation();
 void OracleDialogue();
 void __fastcall ClickNPCTopic(signed int uMessageParam);
 char * _4B254D_SkillMasteryTeacher(int _this);