changeset 517:aaefd101c3b1

Merge
author Gloval
date Fri, 01 Mar 2013 20:28:25 +0400
parents d2a55c0a8dda (current diff) 0bbc39457b25 (diff)
children 9c984eef0a7d
files
diffstat 14 files changed, 581 insertions(+), 626 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/Events.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -204,7 +204,7 @@
 	int v60; // eax@126
 	int v61; // edx@133
 	int v62; // eax@139
-	void *v63; // ebp@145
+	int v63; // ebp@145
 	signed int v64; // edi@146
 	unsigned int v65; // edx@148
 	Player *v66; // ecx@148
@@ -221,8 +221,8 @@
 	signed int v77; // ebp@186
 	int v78; // edx@186
 	Player *v79; // esi@187
-	signed int v80; // ebp@200
-	int v81; // edx@200
+	//signed int v80; // ebp@200
+	//int v81; // edx@200
 	Player *v82; // esi@201
 	int v83; // eax@212
 	int v84; // ebp@220
@@ -266,7 +266,7 @@
 	int curr_seq_num; // [sp+10h] [bp-498h]@4
 	//char *v123; // [sp+14h] [bp-494h]@0
 	signed int v124; // [sp+18h] [bp-490h]@7
-	signed int v125; // [sp+1Ch] [bp-48Ch]@155
+	//signed int v125; // [sp+1Ch] [bp-48Ch]@155
 	int v126; // [sp+1Ch] [bp-48Ch]@262
 	int player_choose; // [sp+20h] [bp-488h]@4
 	int v128; // [sp+24h] [bp-484h]@21
@@ -821,52 +821,49 @@
 				//v6 = v123;
 				//v7 = "";
 				break;
-			case EVENT_Compare://_evt->_e_type == 14 cmp in Global.evt event 6
+			case EVENT_Compare:
 				pValue = EVT_DWORD(_evt->v7);
 				if ( player_choose <= 3 )
-					{
+				{
 					if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
-						{
+					{
 						v124 = -1;
 						curr_seq_num = _evt->v11 - 1;
-						};
 					}
+				}
 				else if ( player_choose == 4 ) //active
+				{
+					if ( uActiveCharacter )
 					{
-					if ( uActiveCharacter )
+						if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
 						{
-						if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
-							{
 							v124 = -1;
 							curr_seq_num = _evt->v11 - 1;
-							};
 						}
 					}
+				}
 				else 	if ( player_choose == 5 )//all
-					{
+				{
 					v130=0;
-					for(int i=0; i<4; ++i)
+					for(int i = 0; i < 5; ++i)
+					{
+						if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
 						{
-						if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
-							{
 							v124 = -1;
 							curr_seq_num = _evt->v11 - 1;
 							break;
-							};
-
+						}
 						++v130;
-						}
-
 					}
+				}
 				else if ( player_choose == 6 ) //random
-					{
+				{
 					if ( pPlayers[rand() % 4]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
-						{
+					{
 						v124 = -1;
 						curr_seq_num = _evt->v11 - 1;
-						}
 					}
-			
+				}
 				++curr_seq_num;
 				v4 = v124;
 				//v6 = v123;
@@ -882,12 +879,12 @@
 				 v4 = v124;
 				 break;
 			case EVENT_Substract:
-				v63 = (void *)(_evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8));
-				if ( _evt->v5 + ((uint)_evt->v6 << 8) == VAR_PlayerItemInHands )
+				pValue = EVT_DWORD(_evt->v7);
+				if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands )
+				{
+					v64 = 0;
+					if ( pParty->pPickedItem.uItemID == pValue )
 					{
-					v64 = 0;
-					if ( (void *)pParty->pPickedItem.uItemID == v63 )
-						{
 						pMouse->RemoveHoldingItem();
 						++curr_seq_num;
 						v4 = v124;
@@ -895,14 +892,14 @@
 						//v6 = v123;
 						//v7 = "";
 						break;
-						}
+					}
 					v65 = 0;
 					v66 = pPlayers[uActiveCharacter];
 					v67 = (int)v66->pInventoryIndices;
 					do
+					{
+						if ( (int)&v66->pInventoryItems[v67] == pValue )
 						{
-						if ( *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 )
-							{
 							v66->RemoveItemAtInventoryIndex(v65);
 							++curr_seq_num;
 							v4 = v124;
@@ -910,17 +907,17 @@
 							//v6 = v123;
 							//v7 = "";
 							break;
-							}
+						}
 						++v65;
 						v67 += 4;
-						}
-						while ( (signed int)v65 < 126 );
+					}
+					while ( (signed int)v65 < 126 );
 						v68 = 0;
 						v69 = (int)&v66->pEquipment;
 						do
+						{
+							if ( *(int *)v69 && (int)&v66->pInventoryItems[v69] == pValue )
 							{
-							if ( *(int *)v69 && *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 )
-								{
 								*(&v66->pEquipment.uOffHand + v68) = 0;
 								++curr_seq_num;
 								v4 = v124;
@@ -928,204 +925,187 @@
 								//v6 = v123;
 								//v7 = "";
 								break;
-								}
+							}
 							++v68;
 							v69 += 4;
-							}
-							while ( v68 < 16 );
-							v125 = (signed int)&pPlayers[1];
+						}
+						while ( v68 < 16 );
+							pPlayer = pPlayers[1];
 							while ( 1 )
+							{
+								v70 = pPlayer;
+								if ( !v64 )
 								{
-								v70 = *(Player **)v125;
-								if ( !v64 )
-									{
 									v71 = 0;
 									v72 = (int)v70->pInventoryIndices;
 									do
+									{
+										if ( (int)&v70->pInventoryItems[v72] == pValue )
 										{
-										if ( *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 )
-											{
 											v70->RemoveItemAtInventoryIndex(v71);
 											goto LABEL_169;
-											}
+										}
 										++v71;
 										v72 += 4;
-										}
-										while ( (signed int)v71 < 126 );
+									}
+									while ( (signed int)v71 < 126 );
 										v73 = 0;
 										v74 = (int)&v70->pEquipment;
-										while ( !*(int *)v74
-											|| *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 )
-											{
+										while ( !*(int *)v74 || (int)&v70->pInventoryItems[v74] != pValue )
+										{
 											++v73;
 											v74 += 4;
 											if ( v73 >= 16 )
 												goto LABEL_170;
-											}
+										}
 										*(&v70->pEquipment.uOffHand + v73) = 0;
 LABEL_169:
 										v64 = 1;
-									}
+								}
 LABEL_170:
-								v125 += 4;
-								if ( v125 > (signed int)&pPlayers[4] )
-									{
-									++curr_seq_num;
+								pPlayer += 4;
+								if ( pPlayer > pPlayers[4] )
+								{
+									//++curr_seq_num;
 									v4 = v124;
 									
 									//v6 = v123;
 									//v7 = "";
 									break;
-									}
 								}
-					}
-				v75 = player_choose;
-				if ( player_choose != 5 )
-					{
-					if ( player_choose < 0 )
-						goto LABEL_183;
-					if ( player_choose > 3 )
-						{
-						if ( player_choose != 4 )
-							{
-							if ( player_choose == 6 )
-								goto LABEL_180;
-LABEL_183:
-							((Player *)v6)->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
-							++curr_seq_num;
-							v4 = v124;
-							
-							//v6 = v123;
-							//v7 = "";
-							break;
 							}
-						if ( uActiveCharacter )
-							{
-							v6 = pPlayers[uActiveCharacter];
-							goto LABEL_182;
-							}
-LABEL_180:
-						v75 = rand() % 4;
-						
+					}
+				if ( player_choose <= 3 )
+				{
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
+				else if ( player_choose == 4 ) //active
+				{
+					if ( uActiveCharacter )
+					{
+						pPlayer = pPlayers[uActiveCharacter];
+						pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+						++curr_seq_num;
+						v4 = v124;
+						break;
+					}
+				}
+				else 	if ( player_choose == 5 )//all
+				{
+					v130 = 0;
+					for(int i = 0; i < 4; ++i)
+					{
+						if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
+						{
+							++curr_seq_num;
+							break;
 						}
-					v6 = &pParty->pPlayers[v75];
-LABEL_182:
-					//v123 = v6;
-					goto LABEL_183;
 					}
-				v76 = pParty->pPlayers;
-				v130 = 4;
-				do
-					{
-					v76->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
-					++v76;
-					}
-					while ( (signed int)v76 < (signed int)pParty->pHirelings );
+					++v130;
+					break;
+				}
+				else if ( player_choose == 6 ) //random
+				{
+					player_choose = rand() % 4;
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
 					break;
+				}
 			case EVENT_Set:
-				v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				v78 = player_choose;
-				if ( player_choose != 5 )
-					{
-					if ( player_choose < 0 )
-						goto LABEL_197;
-					if ( player_choose > 3 )
-						{
-						if ( player_choose != 4 )
-							{
-							if ( player_choose == 6 )
-								goto LABEL_194;
-LABEL_197:
-							((Player *)v6)->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77);
-							++curr_seq_num;
-							v4 = v124;
-							
-							//v6 = v123;
-							//v7 = "";
-							break;
-							}
-						if ( uActiveCharacter )
-							{
-							v6 = pPlayers[uActiveCharacter];
-							goto LABEL_196;
-							}
-LABEL_194:
-						v78 = rand() % 4;
-						
-						}
-					v6 = &pParty->pPlayers[v78];
-LABEL_196:
-					//v123 = v6;
-					goto LABEL_197;
-					}
-				v79 = pParty->pPlayers;
-				v130 = 4;
-				do
-					{
-					v79->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77);
-					++v79;
-					}
-					while ( (signed int)v79 < (signed int)pParty->pHirelings );
+				pValue = EVT_DWORD(_evt->v7);
+				if ( player_choose <= 3 )
+				{
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
 					break;
-			case EVENT_Add:
-				v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				v81 = player_choose;
-				if ( player_choose != 5 )
+				}
+				else if ( player_choose == 4 ) //active
+				{
+					if ( uActiveCharacter )
 					{
-					if ( player_choose < 0 )
-						goto LABEL_211;
-					if ( player_choose > 3 )
-						{
-						if ( player_choose != 4 )
-							{
-							if ( player_choose == 6 )
-								goto LABEL_208;
-LABEL_211:
-							((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80);
-							goto LABEL_212;
-							}
-						if ( uActiveCharacter )
-							{
-							v6 = pPlayers[uActiveCharacter];
-							goto LABEL_210;
-							}
-LABEL_208:
-						v81 = rand() % 4;
-						
-						}
-					v6 = &pParty->pPlayers[v81];
-LABEL_210:
-					//v123 = v6;
-					goto LABEL_211;
+						pPlayer = pPlayers[uActiveCharacter];
+						pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+						++curr_seq_num;
+						v4 = v124;
+						break;
 					}
-				v82 = pParty->pPlayers;
-				v130 = 4;
-				do
-					{
-					v82->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80);
-					++v82;
-					}
-					while ( (signed int)v82 < (signed int)pParty->pHirelings );
-LABEL_212:
-					v83 = _evt->v5 + ((uint)_evt->v6 << 8);
+				}
+				else if ( player_choose == 5 )//all
+				{
+					for(int i = 1; i < 5; ++i)
+						pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
+				else if ( player_choose == 6 ) //random
+				{
+					player_choose = rand() % 4;
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
+			case EVENT_Add:
+				pValue = EVT_DWORD(_evt->v7);
+				if ( player_choose <= 3 )
+				{
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					v83 = EVT_WORD(_evt->v5);
 					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
 						viewparams->bRedrawGameUI = 1;
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
 					break;
+				}
+				else if ( player_choose == 4 ) //active
+				{
+					if ( uActiveCharacter )
+					{
+						pPlayer = pPlayers[uActiveCharacter];
+						pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+						v83 = EVT_WORD(_evt->v5);
+						if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
+							viewparams->bRedrawGameUI = 1;
+						++curr_seq_num;
+						v4 = v124;
+						break;
+					}
+				}
+				else if ( player_choose == 5 )//all
+				{
+					//v130 = 0;
+					for(int i = 1; i < 5; ++i)
+						pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					v83 = EVT_WORD(_evt->v5);
+					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
+						viewparams->bRedrawGameUI = 1;
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
+				else if ( player_choose == 6 ) //random
+				{
+					player_choose = rand() % 4;
+					pPlayer = &pParty->pPlayers[player_choose];
+					pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					v83 = EVT_WORD(_evt->v5);
+					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
+						viewparams->bRedrawGameUI = 1;
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
 			case EVENT_InputString:
 				if ( !start_event_seq_number )
 					{
--- a/GUIWindow.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/GUIWindow.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -1200,6 +1200,7 @@
           JailDialog();
           break;
         default:
+          __debugbreak;//New BildingType
           break;
       }
   }
--- a/Items.h	Fri Mar 01 20:28:01 2013 +0400
+++ b/Items.h	Fri Mar 01 20:28:25 2013 +0400
@@ -64,8 +64,25 @@
   ITEM_SPELLBOOK_LIGHT_SUN_BURST = 0x1E6,
   ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION = 0x1E7,
   ITEM_ARTIFACT_PUCK = 0x1F4,
+  ITEM_ARTICACT_GOVERNONS_ARMOR = 504,//1F8
+  ITEM_ARTIFACT_YORUBA = 505,//1F9
   ITEM_ARTIFACT_SPLITTER = 506,//1FA
+  ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200
+  ITEM_RELIC_HARECS_LEATHER = 516,//204
+  ITEM_RELIC_TALEDONS_HELM = 521,//209
+  ITEM_RELIC_SCHOLARS_CAP = 522,//20A
+  ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B
+  ITEM_RILIC_TITANS_BELT = 524,//20C
+  ITEM_RELIC_TWILIGHT = 525,//20D
   ITEM_RELIC_MEKORIGS_HAMMER = 0x210,
+  ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212
+  ITEM_ARTIFACT_MINDS_EYE = 532,//214
+  ITEM_ELVEN_CHAINMAIL = 533,//215
+  ITEM_ARTIFAT_HEROS_BELT = 535,//217
+  ITEM_RARE_SHADOWS_MASK = 544,//220
+  ITEM_RARE_SUN_CLOAK = 547,//223
+  ITEM_RARE_MOON_CLOAK = 548,//224
+  ITEM_RARE_VAMPIRES_CAPE = 550,//226
   ITEM_LICH_JAR = 601
 };
 
--- a/MM7.h	Fri Mar 01 20:28:01 2013 +0400
+++ b/MM7.h	Fri Mar 01 20:28:25 2013 +0400
@@ -212,38 +212,22 @@
 #pragma pack(pop)
 extern int paperdoll_Weapon[4][16][2];
 
-/*  371 */
-#pragma pack(push, 1)
-struct stru331
-{
-  int field_0;
-  int field_4;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-  int field_18;
-  int field_1C;
-  int field_20;
-  int field_24;
-  int field_28;
-  int field_2C;
-  int field_30;
-  int field_34;
-  int field_38;
-  int field_3C;
-};
-#pragma pack(pop)
+/*  371 */ // stru331 - deleted
+
 
 /*  372 */
 #pragma pack(push, 1)
 struct stru332
 {
   unsigned int texids[11];
-  stru331 field_2C;
+  int texid1;
+  int texid2;
+  int texid3;
+  int texid4;
+  int texid5;
 };
 #pragma pack(pop)
-extern stru332 stru_511698;
+extern stru332 stru_511698[];
 
 
 /*  373 */
@@ -251,11 +235,11 @@
 struct stru333
 {
   unsigned int texids[5];
-  unsigned int *texid1;
-  int field_18;
+  int texid1;
+  int texid2;
 };
 #pragma pack(pop)
-extern stru333 stru_511718;
+extern stru333 stru_511718[];
 
 
 /*  374 */
--- a/Player.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/Player.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -1744,7 +1744,6 @@
   unsigned int uSlota; // [sp+14h] [bp+4h]@1
 
   pIndices = &this->pInventoryIndices[uSlot];
-
   v3 = &this->pInventoryItems[*pIndices-1];
   v4 = v3->uItemID;
   v3->Reset();
@@ -8893,11 +8892,11 @@
                 //&& (&dword_722F10)[4 * val] )
 				&& pQuestTable[val-1] )
               {
-                v17 = pPlayers[uPlayerIdx + 1];
+                //v17 = pPlayers[uPlayerIdx + 1];
                 bFlashQuestBook = 1;
                 v34 = 1;
                 v3 = 1;
-                v17->PlaySound(SPEECH_93, 0);
+                pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0);
               }
               v15 = (char *)pParty->_quest_bits;
 LABEL_44:
@@ -9279,11 +9278,11 @@
 
 
 //----- (0044B9C4) --------------------------------------------------------
-void Player::SubtractVariable(enum VariableType var, void *a3)
+bool Player::SubtractVariable(enum VariableType VarNum, signed int pValue)
 {
   unsigned int v3; // ebx@1
   signed int v4; // esi@1
-  enum VariableType v5; // eax@8
+  bool result; // eax@8
   int v6; // esi@11
   int v7; // edi@14
   signed int v8; // eax@17
@@ -9293,10 +9292,10 @@
   char *v12; // ecx@27
   __int64 v13; // qax@27
   unsigned __int8 v14; // cf@27
-  char *v15; // edx@29
+  int *v15; // edx@29
   char *v16; // eax@90
   char *v17; // ecx@94
-  void *v18; // esi@97
+  int v18; // esi@97
   signed int v19; // edx@97
   char *v20; // ecx@98
   int v21; // eax@100
@@ -9324,52 +9323,53 @@
   }
   v4 = v24;
 LABEL_8:
-  v5 = var;
-  if ( (signed int)var > 222 )
-  {
-    if ( (signed int)var <= 307 )
-    {
-      if ( var == 307 )
-      {
-        pParty->uNumDeaths -= (unsigned int)a3;
-        return;
-      }
-      if ( var == 223 )
+  result = false;
+  if ( (signed int)VarNum > 222 )
+  {
+    if ( (signed int)VarNum <= 307 )
+    {
+      if ( VarNum == 307 )
+      {
+        pParty->uNumDeaths -= (unsigned int)pValue;
+        return pValue;
+      }
+      if ( VarNum == 223 )
       {
         v11 = (char *)pParty->_autonote_bits;
-        v22 = (short)a3 - 1;
+        v22 = (short)pValue - 1;
       }
       else
       {
-        if ( var != 231 )
+        if ( VarNum != 231 )
         {
-          switch ( var )
+          switch ( VarNum )
           {
             case 232:
-              var = (VariableType)0;
-              GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&var);
-              dword_5B65CC = 0;
-              if ( (void *)var == a3 )
+              VarNum = (VariableType)0;
+              GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&VarNum);
+              result = (bool) pValue;
+			  dword_5B65CC = 0;
+              if ( (int)VarNum == pValue )
               {
-                dword_5B65CC = (int)a3;
+                dword_5B65CC = (int)pValue;
               }
               else
               {
                 pParty->field_709 = 0;
-                LOBYTE(pNPCStats->pNewNPCData[(int)a3].uFlags) &= 0x7Fu;
+                LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu;
                 sub_44A56A();
                 viewparams->bRedrawGameUI = 1;
               }
               break;
             case 241:
-              v18 = a3;
+              v18 = pValue;
               v19 = 0;
               if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
               {
                 v20 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
                 do
                 {
-                  if ( *((void **)v20 + 4) == v18 )
+                  if ( *((void **)v20 + 4) == (void *)v18 )
                   {
                     v21 = *(int *)v20;
                     if ( (char)*(int *)v20 < 0 )
@@ -9383,17 +9383,21 @@
                 }
                 while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
               }
-              if ( (void *)pParty->pHirelings[0].uProfession == v18 )
+              if ( pParty->pHirelings[0].uProfession == v18 )
                 memset(pParty->pHirelings, 0, 0x4Cu);
-              if ( (void *)pParty->pHirelings[1].uProfession == v18 )
+              if ( pParty->pHirelings[1].uProfession == v18 )
                 memset(&pParty->pHirelings[1], 0, 0x4Cu);
               pParty->field_709 = 0;
               sub_44A56A();
               break;
             case 243:
               v17 = (char *)&this->uSkillPoints;
-              if ( (unsigned int)a3 <= *(int *)v17 )
-                *(int *)v17 -= (int)a3;
+			  result = *v17;
+              if ( (unsigned int)pValue <= *(int *)v17 )
+              {
+					*(int *)v17 -= (int)pValue;
+					result = v17;
+			  }
               else
                 *(int *)v17 = 0;
               break;
@@ -9401,70 +9405,80 @@
               v16 = (char *)&pOutdoor->ddm;
               if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
                 v16 = (char *)&pIndoor->dlv;
-              *((int *)v16 + 2) -= (int)a3;
+              *((int *)v16 + 2) -= (int)pValue;
               if ( *((int *)v16 + 2) < -10000 )
                 *((int *)v16 + 2) = -10000;
               break;
             case 306:
-              if ( (unsigned int)a3 <= pParty->uNumGoldInBank )
-                pParty->uNumGoldInBank -= (unsigned int)a3;
+				result = VarNum - 306;
+              if ( (unsigned int)pValue <= pParty->uNumGoldInBank )
+			  {
+				result = (bool)pValue;
+                pParty->uNumGoldInBank -= (unsigned int)pValue;
+			  }
               else
 LABEL_88:
                 dword_5B65C4 = 1;
               break;
           }
-          return;
+          return result;
         }
         v11 = this->field_1A50;
 LABEL_112:
-        v22 = (signed __int16)a3;
+        v22 = (signed __int16)pValue;
       }
       _449B7E_toggle_bit((unsigned char *)v11, v22, 0);
-      return;
-    }
-    switch ( var )
+      return result;
+    }
+    switch ( VarNum )
     {
       case 308:
-        pParty->uNumBountiesCollected -= (unsigned int)a3;
+		  result = (bool)pValue;
+        pParty->uNumBountiesCollected -= (unsigned int)pValue;
         break;
       case 309:
-        pParty->uNumPrisonTerms -= (int)a3;
+		  result = (bool)pValue;
+        pParty->uNumPrisonTerms -= (int)pValue;
         break;
       case 310:
-        pParty->uNumArenaPageWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaPageWins -= (char)pValue;
         break;
       case 311:
-        pParty->uNumArenaSquireWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaSquireWins -= (char)pValue;
         break;
       case 312:
-        pParty->uNumArenaKnightWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaKnightWins -= (char)pValue;
         break;
       case 313:
-        pParty->uNumArenaLordWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaLordWins -= (char)pValue;
         break;
     }
   }
   else
   {
-    if ( (signed int)var >= 123 )
-    {
-      byte_5E4C15[var] -= (char)a3;
+    if ( (signed int)VarNum >= 123 )
+    {
+      byte_5E4C15[VarNum] -= (char)pValue;
     }
     else
     {
-      switch ( var )
+      switch ( VarNum )
       {
         case VAR_RandomGold:
-          v6 = rand() % (signed int)a3 + 1;
+          v6 = rand() % (signed int)pValue + 1;
           if ( v6 > pParty->uNumGold )
             v6 = pParty->uNumGold;
           Party::TakeGold(v6);
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[503], v6);
           ShowStatusBarString(pTmpBuf, 2u);
           GameUI_DrawFoodAndGold();
-          return;
+          return result;
         case VAR_RandomFood:
-          v7 = rand() % (signed int)a3 + 1;
+          v7 = rand() % (signed int)pValue + 1;
           if ( v7 > pParty->uNumFoodRations )
             v7 = pParty->uNumFoodRations;
           Party::TakeFood(v7);
@@ -9473,162 +9487,162 @@
           GameUI_DrawFoodAndGold();
           goto LABEL_17;
         default:
-          return;
+          return result;
         case VAR_CurrentHP:
-          ReceiveDamage((signed int)a3, 4);
+          ReceiveDamage((signed int)pValue, 4);
           goto LABEL_17;
         case VAR_CurrentSP:
           v9 = (char *)&this->sMana;
-          v10 = this->sMana - (signed int)a3 < 0;
-          *(int *)v9 -= (int)a3;
+          v10 = this->sMana - (signed int)pValue < 0;
+          *(int *)v9 -= (int)pValue;
           if ( v10 )
             *(int *)v9 = 0;
           goto LABEL_17;
         case VAR_ACModifier:
-          this->sACModifier -= (unsigned __int8)a3;
+          this->sACModifier -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_BaseLevel:
-          this->uLevel -= (unsigned __int8)a3;
+          this->uLevel -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_LevelModifier:
-          this->sLevelModifier -= (unsigned __int8)a3;
+          this->sLevelModifier -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_Age:
-          this->sAgeModifier -= (signed __int16)a3;
-          return;
+          this->sAgeModifier -= (signed __int16)pValue;
+          return result;
         case VAR_Award:
           v11 = this->_guilds_member_bits;
           goto LABEL_112;
         case VAR_Experience:
           v12 = (char *)&this->uExperience;
-          v13 = (signed int)a3;
-          v14 = *(int *)v12 < (unsigned int)a3;
-          *(int *)v12 -= (int)a3;
+          v13 = (signed int)pValue;
+          v14 = *(int *)v12 < (unsigned int)pValue;
+          *(int *)v12 -= (int)pValue;
           *((int *)v12 + 1) -= v14 + HIDWORD(v13);
           goto LABEL_17;
         case VAR_QBits_QuestsDone:
-          _449B7E_toggle_bit(pParty->_quest_bits, (__int16)a3, 0);
+          _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0);
           pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0);
-          return;
+          return true;
         case VAR_PlayerItemInHands:
-          v15 = (char *)this->pInventoryIndices;
+          v15 = this->pInventoryIndices;
           break;
         case VAR_FixedGold:
-          if ( (unsigned int)a3 > pParty->uNumGold )
+          if ( (unsigned int)pValue > pParty->uNumGold )
             goto LABEL_88;
-          Party::TakeGold((unsigned int)a3);
-          return;
+          Party::TakeGold((unsigned int)pValue);
+          return result;
         case VAR_MightBonus:
         case VAR_ActualMight:
-          this->uMightBonus -= (unsigned __int16)a3;
+          this->uMightBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_IntellectBonus:
         case VAR_ActualIntellect:
-          this->uIntelligenceBonus -= (unsigned __int16)a3;
+          this->uIntelligenceBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_PersonalityBonus:
         case VAR_ActualPersonality:
-          this->uWillpowerBonus -= (unsigned __int16)a3;
+          this->uWillpowerBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_EnduranceBonus:
         case VAR_ActualEndurance:
-          this->uEnduranceBonus -= (unsigned __int16)a3;
+          this->uEnduranceBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_SpeedBonus:
         case VAR_ActualSpeed:
-          this->uSpeedBonus -= (unsigned __int16)a3;
+          this->uSpeedBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_AccuracyBonus:
         case VAR_ActualAccuracy:
-          this->uAccuracyBonus -= (unsigned __int16)a3;
+          this->uAccuracyBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_LuckBonus:
         case VAR_ActualLuck:
-          this->uLuckBonus -= (unsigned __int16)a3;
+          this->uLuckBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_BaseMight:
-          this->uMight -= (unsigned __int16)a3;
+          this->uMight -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseIntellect:
-          this->uIntelligence -= (unsigned __int16)a3;
+          this->uIntelligence -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BasePersonality:
-          this->uWillpower -= (unsigned __int16)a3;
+          this->uWillpower -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseEndurance:
-          this->uEndurance -= (unsigned __int16)a3;
+          this->uEndurance -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseSpeed:
-          this->uSpeed -= (unsigned __int16)a3;
+          this->uSpeed -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseAccuracy:
-          this->uAccuracy -= (unsigned __int16)a3;
+          this->uAccuracy -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseLuck:
-          this->uLuck -= (unsigned __int16)a3;
+          this->uLuck -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_FireResistance:
-          this->sResFireBase -= (signed __int16)a3;
+          this->sResFireBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_AirResistance:
-          this->sResAirBase -= (signed __int16)a3;
+          this->sResAirBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_WaterResistance:
-          this->sResWaterBase -= (signed __int16)a3;
+          this->sResWaterBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_EarthResistance:
-          this->sResEarthBase -= (signed __int16)a3;
+          this->sResEarthBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_SpiritResistance:
-          this->sResSpiritBase -= (signed __int16)a3;
+          this->sResSpiritBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_MindResistance:
-          this->sResMindBase -= (signed __int16)a3;
+          this->sResMindBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_BodyResistance:
-          this->sResBodyBase -= (signed __int16)a3;
+          this->sResBodyBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_LightResistance:
-          this->sResLightBase -= (signed __int16)a3;
+          this->sResLightBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_DarkResistance:
-          this->sResDarkBase -= (signed __int16)a3;
+          this->sResDarkBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_MagicResistance:
-          this->sResMagicBase -= (signed __int16)a3;
+          this->sResMagicBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_FireResistanceBonus:
-          this->sResFireBonus -= (signed __int16)a3;
+          this->sResFireBonus -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_AirResistanceBonus:
-          this->sResAirBonus -= (signed __int16)a3;
+          this->sResAirBonus -= (signed __int16)pValue;
 LABEL_45:
           v25 = 0;
           v23 = 92;
           goto LABEL_73;
         case VAR_WaterResistanceBonus:
-          this->sResWaterBonus -= (signed __int16)a3;
+          this->sResWaterBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_EarthResistanceBonus:
-          this->sResEarthBonus -= (signed __int16)a3;
+          this->sResEarthBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_SpiritResistanceBonus:
-          this->sResSpiritBonus -= (signed __int16)a3;
+          this->sResSpiritBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_MindResistanceBonus:
-          this->sResMindBonus -= (signed __int16)a3;
+          this->sResMindBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_BodyResistanceBonus:
-          this->sResBodyBonus -= (signed __int16)a3;
+          this->sResBodyBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_LightResistanceBonus:
-          this->sResLightBonus -= (signed __int16)a3;
+          this->sResLightBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_DarkResistanceBonus:
-          this->sResDarkBonus -= (signed __int16)a3;
+          this->sResDarkBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_MagicResistanceBonus:
-          this->sResMagicBonus -= (signed __int16)a3;
+          this->sResMagicBonus -= (signed __int16)pValue;
 LABEL_72:
           v25 = 0;
           v23 = SPEECH_91;
@@ -9636,7 +9650,7 @@
           pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25);
           goto LABEL_17;
         case VAR_FixedFood:
-          Party::TakeFood((unsigned int)a3);
+          Party::TakeFood((unsigned int)pValue);
           goto LABEL_17;
         case VAR_StaffSkill:
         case VAR_SwordSkill:
@@ -9668,7 +9682,7 @@
         case VAR_DiplomacySkill:
         case VAR_DisarmTrapSkill:
         case VAR_LearningSkill:
-          *((short *)&this->pConditions[16] + var) -= (unsigned __int8)a3;
+          *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_Cursed:
         case VAR_Weak:
@@ -9687,28 +9701,33 @@
         case VAR_Dead:
         case VAR_Stoned:
         case VAR_Eradicated:
-          *((int *)this + 2 * var - 210) = 0;
-          *((int *)this + 2 * v5 - 209) = 0;
+          *((int *)this + 2 * VarNum - 210) = 0;
+          *((int *)this + 2 * result - 209) = 0;
 LABEL_17:
           pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
           v8 = 8 * v4 + 400;
           LOBYTE(v8) = (8 * v4 - 112) | 4;
           pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
-          return;
-      }
-      do
-      {
-        if ( *(void **)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v15 + 5] == a3 )
+          return result;
+      }
+      //do
+	  for (v3 = 1; v3 < 126; v3++)
+      {
+		  if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue )//pValue = ItemID, pInventoryItems[3] = 222
         {
-          RemoveItemAtInventoryIndex(v3);
-          return;
+          RemoveItemAtInventoryIndex(v3);// &this->pInventoryIndices[puSlot], pInventoryIndices[1] = 4
+          return true;
         }
-        ++v3;
-        v15 += 4;
-      }
-      while ( (signed int)v3 < 126 );
-      if ( (void *)pParty->pPickedItem.uItemID == a3 )
-        pMouse->RemoveHoldingItem();
+        //++v3;
+        //v15 ++;
+      }
+      //while ( (signed int)v3 < 126 );
+      if ( pParty->pPickedItem.uItemID == pValue )
+      {
+         pMouse->RemoveHoldingItem();
+		 return true;
+	  }
+	  return false;
     }
   }
 }
--- a/Player.h	Fri Mar 01 20:28:01 2013 +0400
+++ b/Player.h	Fri Mar 01 20:28:25 2013 +0400
@@ -448,7 +448,7 @@
 
   void SetVariable(enum VariableType var, signed int a3);
   void AddVariable(enum VariableType var, signed int val);
-  void SubtractVariable(enum VariableType var, void *a3);
+  bool SubtractVariable(enum VariableType VarNum, signed int pValue);
   bool CompareVariable(enum VariableType VarNum, signed int pValue);
   void UseItem_DrinkPotion_etc(signed int a2, int a3);
   bool AddItem(struct ItemGen *pItem);
--- a/Spells.h	Fri Mar 01 20:28:01 2013 +0400
+++ b/Spells.h	Fri Mar 01 20:28:25 2013 +0400
@@ -118,7 +118,7 @@
   SPELL_LASER_PROJECTILE = 102,
 
   BECOME_MAGIC_GUILD_MEMBER = 150,
-  SPELL_151 = 151,
+  SPELL_QUEST_COMPLETED = 151,
   SPELL_152 = 152,
   SPELL_153 = 153
 };
--- a/mm7_1.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_1.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -2926,17 +2926,9 @@
       v116 = v106.uViewportZ;
     if ( v119 > (signed int)v106.uViewportW )
       v119 = v106.uViewportW;
-    pRenderer->FillRectFast(
-      v106.uViewportX,
-      v106.uViewportY,
-      v106.uViewportZ - v106.uViewportX,
-      v106.uViewportW - v106.uViewportY,
+    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY,
       pRenderer->uTargetBMask | pRenderer->uTargetGMask);
-    pRenderer->FillRectFast(
-      v106.uViewportX,
-      v106.uViewportY,
-      v106.uViewportZ - v106.uViewportX,
-      v106.uViewportW - v106.uViewportY,
+    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY,
       pRenderer->uTargetBMask | pRenderer->uTargetGMask);
     v84.left = v106.uViewportX;
     v84.top = v106.uViewportY;
@@ -3020,9 +3012,7 @@
 				{
 				  v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
 				  v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
-				  v34 = v33 & 0x1F | 2
-								   * (unsigned __int16)(v108[(int)((char *)v110
-																	+ pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
+				  v34 = v33 & 0x1F | 2 * (unsigned __int16)(v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
 				  v35 = v124;
 				  *(short *)v30 = v34;
 				  v30 += 2;
@@ -3045,12 +3035,7 @@
   }
   else
   {
-    pRenderer->FillRectFast(
-      v106.uViewportX,
-      v106.uViewportY,
-      v106.uViewportZ - v106.uViewportX,
-      v106.uViewportW - v106.uViewportY,
-      0);
+    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0);
     v36 = v10->pHwSpriteIDs[0];
     if ( v36 >= 0 )
       pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0);
@@ -3097,7 +3082,7 @@
 	  LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
 	  v120 = v40;
 	  if ( !v40 )
-					v45 = 1;
+		v45 = 1;
 	  else
 	  {
 		  v41 = (unsigned __int8)v40 & 0x3F;
@@ -3110,7 +3095,7 @@
 			  v119 = 1;
 			}
 			else
-						v45 = 1;
+				v45 = 1;
 		  }
 		  else
 		  {
@@ -3374,22 +3359,11 @@
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v57 = v121->pMonsterInfo.uAttack1DamageBonus;
     if ( v57 )
-      sprintf(
-        pTmpBuf,
-        "%s\f%05u\t080%dd%d+%d\n",
-        pGlobalTXT_LocalizationStrings[53],
-        0,
-        v121->pMonsterInfo.uAttack1DamageDiceRolls,
-        v121->pMonsterInfo.uAttack1DamageDiceSides,
-        v57);
+      sprintf(pTmpBuf, "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53],
+        0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides, v57);
     else
-      sprintf(
-        pTmpBuf,
-        "%s\f%05u\t080%dd%d\n",
-        pGlobalTXT_LocalizationStrings[53],
-        0,
-        v121->pMonsterInfo.uAttack1DamageDiceRolls,
-        v121->pMonsterInfo.uAttack1DamageDiceSides);
+      sprintf(pTmpBuf, "%s\f%05u\t080%dd%d\n", pGlobalTXT_LocalizationStrings[53],
+        0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides);
   }
   else
   {
@@ -3510,13 +3484,7 @@
   {
     sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP);
     pFontSmallnum->GetLineWidth(pTmpBuf);
-    result = a1->DrawTitleText(
-               pFontSmallnum,
-               0,
-               a1->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12,
-               0,
-               pTmpBuf,
-               3u);
+    result = a1->DrawTitleText(pFontSmallnum, 0, a1->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf, 3);
   }
   return result;
 }
@@ -5107,88 +5075,90 @@
   int a4; // [sp+44h] [bp-4h]@2
 
   v0 = pPlayers[uActiveCharacter];
-  if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103
-    || (pMouse->GetClickPos(&pX, &pY),
-        v1 = pY - 17,
-        v2 = pX - 14,
-        pY = v1,
-        pX = v2,
-        v3 = 14 * (v1 >> 5),
-        v2 >>= 5,
-        v4 = v2 + v3 < 0,
-        v5 = v2 + v3,
-        a4 = v5,
-        v4)
-    || v5 > 126
-    || pMouse->GetCursorPos(&a2)->x >= 462
-    || pMouse->GetCursorPos(&a2)->x < 14 )
-    return;
-  if ( unk_50C9A0 )
+  if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )
   {
-    v6 = v0->GetItemIDAtInventoryIndex(&a4);
-    if ( v6 )
+    pMouse->GetClickPos(&pX, &pY);
+    pY = pY - 17;
+    v2 =pX - 14;
+    pX = v2;
+    v3 = 14 * (pY >> 5);
+    v2 >>= 5;
+    v4 = v2 + v3 < 0;
+    v5 = v2 + v3;
+    a4 = v5;
+    if ( !v4 )
     {
-      *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
-      *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
-      *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
-      *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
-      ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
-      unk_50C9A0 = 0;
-      if ( pMessageQueue_50CBD0->uNumMessages )
-        pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-      pMouse->SetCursorBitmap("MICON1");
-      dword_50C9D0 = 113;
-      dword_50C9D4 = 0;
-      dword_50C9D8 = 256;
-    }
-    return;
-  }
-  if ( ptr_50C9A4 )
-    return;
-  v7 = pParty->pPickedItem.uItemID;
-  v8 = v0->GetItemIDAtInventoryIndex(&a4);
-  if ( !v7 )
-  {
-    if ( !v8 )
-      return;
-    memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
-    v0->RemoveItemAtInventoryIndex(a4);
-    v9 = pParty->pPickedItem.uItemID;
-    goto LABEL_24;
-  }
-  v13 = v8;
-  if ( v8 )
-  {
-    a2.y = (LONG)&v0->pInventoryItems[v8-1];
-    memcpy(&this_, (const void *)a2.y, sizeof(this_));
-    v0->RemoveItemAtInventoryIndex(a4);
-    pX = v0->AddItem2(a4, &pParty->pPickedItem);
-    if ( !pX )
-    {
-      pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem);
-      if ( !pX )
+      if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462
+            && pMouse->GetCursorPos(&a2)->x >= 14 )
       {
-        v0->_49298B(&this_, v13 - 1, a4);
-        memcpy((void *)a2.y, &this_, sizeof(ItemGen));
-        return;
+        if ( unk_50C9A0 )
+        {
+          v6 = v0->GetItemIDAtInventoryIndex(&a4);
+          if ( v6 )
+          {
+            *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
+            *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
+            *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
+            *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
+            ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
+            unk_50C9A0 = 0;
+            if ( pMessageQueue_50CBD0->uNumMessages )
+              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+            pMouse->SetCursorBitmap("MICON1");
+            dword_50C9D0 = 113;
+            dword_50C9D4 = 0;
+            dword_50C9D8 = 256;
+          }
+          return;
+        }
+        if ( ptr_50C9A4 )
+          return;
+        v7 = pParty->pPickedItem.uItemID;
+        v8 = v0->GetItemIDAtInventoryIndex(&a4);
+        if ( !v7 )
+        {
+          if ( !v8 )
+            return;
+          memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
+          v0->RemoveItemAtInventoryIndex(a4);
+          v9 = pParty->pPickedItem.uItemID;
+          goto LABEL_24;
+        }
+        v13 = v8;
+        if ( v8 )
+        {
+          a2.y = (LONG)&v0->pInventoryItems[v8-1];
+          memcpy(&this_, (const void *)a2.y, sizeof(this_));
+          v0->RemoveItemAtInventoryIndex(a4);
+          pX = v0->AddItem2(a4, &pParty->pPickedItem);
+          if ( !pX )
+          {
+            pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem);
+            if ( !pX )
+            {
+              v0->_49298B(&this_, v13 - 1, a4);
+              memcpy((void *)a2.y, &this_, sizeof(ItemGen));
+              return;
+            }
+          }
+          v9 = this_.uItemID;
+          memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
+LABEL_24:
+          pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
+          return;
+        }
+        v10 = v0->AddItem(a4, v7);
+        pX = v10;
+        if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
+        {
+          memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
+          pMouse->RemoveHoldingItem();
+        }
       }
     }
-    v9 = this_.uItemID;
-    memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
-LABEL_24:
-    pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
-    return;
-  }
-  v10 = v0->AddItem(a4, v7);
-  pX = v10;
-  if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
-  {
-    memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
-    pMouse->RemoveHoldingItem();
   }
 }
 
-
 //----- (0042213C) --------------------------------------------------------
 void __cdecl OnGameViewportClick()
 {
--- a/mm7_3.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_3.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -12630,7 +12630,6 @@
   while (++_it != 4);
 }
 
-
 //----- (00441A4E) --------------------------------------------------------
 __int16 __fastcall sub_441A4E(int a1)
 {
@@ -17087,20 +17086,17 @@
 }
 
 //----- (00449B7E) --------------------------------------------------------
-unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle)
+void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle)
 {
   signed int v3; // esi@1
-  unsigned char *result; // eax@1
-  unsigned int v5; // edx@1
+  unsigned char set_bit; // edx@1
 
   v3 = a2 - 1;
-  result = &pArray[v3 / 8];
-  v5 = 0x80 >> v3 % 8;
+  set_bit = 0x80 >> v3 % 8;
   if ( bToggle )
-    *result |= v5;
-  else
-    *result &= ~(unsigned char)v5;
-  return result;
+    pArray[v3 / 8] |=  set_bit;
+  else
+    pArray[v3 / 8] &= ~set_bit;
 }
 
 
--- a/mm7_4.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_4.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -8941,7 +8941,8 @@
       v10 = result->_guilds_member_bits;
       result = (Player *)_449B57_test_bit((unsigned __int8 *)result->_guilds_member_bits, 1);
       if ( !(short)result )
-        result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u);
+		  __debugbreak;
+        //result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u);
     }
     ++v8;
   }
@@ -9364,6 +9365,7 @@
 	  v9->uHolderPlayer = v5;
   }
 }
+
 // 4F08EC: using guessed type int dword_4F08EC[];
 // 722B3C: using guessed type int dword_722B3C;
 // 722B44: using guessed type int dword_722B44;
--- a/mm7_5.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_5.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -6223,7 +6223,7 @@
 }
 
 //----- (0043BCA7) --------------------------------------------------------
-int __cdecl CharacterUI_LoadPaperdollTextures()
+void CharacterUI_LoadPaperdollTextures()
 {
   int v0; // edi@7
   enum CHARACTER_RACE pRace; // ebx@7
@@ -6238,14 +6238,14 @@
   char v10; // al@16
   signed int v11; // edi@21
   Player *pPlayer3; // ebx@23
-  Player *pPlayer4; // edi@29
-  int v14; // ebp@29
-  stru331 *v15; // edi@65
-  signed int v16; // ebx@66
-  unsigned int v17; // eax@67
-  unsigned int *v18; // ecx@67
-  unsigned int *v19; // ebx@68
-  int v20; // edi@73
+  //Player *pPlayer4; // edi@29
+  //int v14; // ebp@29
+  //stru331 *v15; // edi@65
+  //signed int v16; // ebx@66
+  //unsigned int v17; // eax@67
+  //unsigned int *v18; // ecx@67
+  //unsigned int *v19; // ebx@68
+  //int v20; // edi@73
   int v21; // ebp@73
   unsigned int v22; // eax@76
   int v23; // ecx@76
@@ -6254,19 +6254,19 @@
   int v26; // ebx@79
   unsigned int v27; // eax@80
   int v28; // ecx@80
-  int result; // eax@83
+  //int result; // eax@83
   int v30; // [sp+10h] [bp-28h]@5
-  signed int v31; // [sp+10h] [bp-28h]@68
+  //signed int v31; // [sp+10h] [bp-28h]@68
   signed int v32; // [sp+10h] [bp-28h]@75
   signed int v33; // [sp+10h] [bp-28h]@77
   int v34; // [sp+10h] [bp-28h]@79
-  char *v35; // [sp+14h] [bp-24h]@65
+  //char *v35; // [sp+14h] [bp-24h]@65
   int v36; // [sp+14h] [bp-24h]@75
   int v37; // [sp+14h] [bp-24h]@77
   signed int v38; // [sp+14h] [bp-24h]@79
-  unsigned int *v39; // [sp+18h] [bp-20h]@66
+  //unsigned int *v39; // [sp+18h] [bp-20h]@66
   int *v40; // [sp+18h] [bp-20h]@73
-  unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73
+  //unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73
   int v42; // [sp+20h] [bp-18h]@6
   int v43; // [sp+20h] [bp-18h]@73
   char pContainer[128]; // [sp+24h] [bp-14h]@12
@@ -6363,116 +6363,103 @@
     ++v11;
   }
   while ( v11 < 54 );
-  *(int *)byte_5111F6 = 0;
-  *(int *)&byte_5111F6[4] = 0;
-  *(int *)&byte_5111F6[8] = 0;
-  *(int *)&byte_5111F6[12] = 0;
-  *(int *)&byte_5111F6[16] = 0;
-  pPlayer4 = pParty->pPlayers;
-  v14 = 1;
-  do
-  {
-    if ( sub_43EE15_player_has_item(0x204u, pPlayer4, 1) )
-      byte_5111F6[2] = 1;
-    if ( sub_43EE15_player_has_item(0x1F8u, pPlayer4, 1) )
-      byte_5111F6[0] = 1;
-    if ( sub_43EE15_player_has_item(0x1F9u, pPlayer4, 1) )
-      byte_5111F6[1] = 1;
-    if ( sub_43EE15_player_has_item(0x215u, pPlayer4, 1) )
-      byte_5111F6[16] = 1;
-    if ( sub_43EE15_player_has_item(0x200u, pPlayer4, 1) )
-      byte_5111F6[3] = 1;
-    if ( sub_43EE15_player_has_item(0x209u, pPlayer4, 1) )
-      byte_5111F6[4] = 1;
-    if ( sub_43EE15_player_has_item(0x20Au, pPlayer4, 1) )
-      byte_5111F6[5] = 1;
-    if ( sub_43EE15_player_has_item(0x20Bu, pPlayer4, 1) )
-      byte_5111F6[6] = 1;
-    if ( sub_43EE15_player_has_item(0x214u, pPlayer4, 1) )
-      byte_5111F6[7] = 1;
-    if ( sub_43EE15_player_has_item(0x220u, pPlayer4, 1) )
-      byte_5111F6[8] = 1;
-    if ( sub_43EE15_player_has_item(0x20Cu, pPlayer4, 1) )
-      byte_5111F6[9] = 1;
-    if ( sub_43EE15_player_has_item(0x217u, pPlayer4, 1) )
-      byte_5111F6[10] = 1;
-    if ( sub_43EE15_player_has_item(0x20Du, pPlayer4, 1) )
-      byte_5111F6[11] = 1;
-    if ( sub_43EE15_player_has_item(0x212u, pPlayer4, 1) )
-      byte_5111F6[12] = 1;
-    if ( sub_43EE15_player_has_item(0x223u, pPlayer4, 1) )
-      byte_5111F6[13] = 1;
-    if ( sub_43EE15_player_has_item(0x224u, pPlayer4, 1) )
-      byte_5111F6[14] = 1;
-    if ( sub_43EE15_player_has_item(0x226u, pPlayer4, 1) )
-      byte_5111F6[15] = 1;
-    ++pPlayer4;
-  }
-  while ( (signed int)pPlayer4 < (signed int)pParty->pHirelings );
-  v15 = &stru_511698.field_2C;
-  v35 = (char *)&stru_511718.field_18;
-  do
-  {
-    v16 = 0;
-    v39 = (unsigned int *)(v35 - 24);
-    do
-    {
-      _43C91D_FormItemTextureFilename(pContainer, v16 + 100, v14, 0);
-      v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      ++v16;
-      v18 = v39;
-      ++v39;
-      *v18 = v17;
-    }
-    while ( v16 < 5 );
-    _43C91D_FormItemTextureFilename(pContainer, 535, v14, 0);
-    v31 = 0;
-    v19 = (unsigned int *)((char *)v15 - 44);
-    *(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    do
-    {
-      _43C91D_FormItemTextureFilename(pContainer, v31++ + 89, v14, 0);
-      *v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      ++v19;
-    }
-    while ( v31 < 11 );
-    _43C91D_FormItemTextureFilename(pContainer, 521, v14, 0);
-    v15->field_0 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    _43C91D_FormItemTextureFilename(pContainer, 522, v14, 0);
-    v15->field_4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    _43C91D_FormItemTextureFilename(pContainer, 523, v14, 0);
-    v15->field_8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    _43C91D_FormItemTextureFilename(pContainer, 532, v14, 0);
-    v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0);
-    v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+
+  memset(byte_5111F6, 0, 16);
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto player = pParty->pPlayers + i;
+
+    if (sub_43EE15_player_has_item(ITEM_ARTICACT_GOVERNONS_ARMOR, player, 1))    byte_5111F6[0] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ARTIFACT_YORUBA, player, 1))             byte_5111F6[1] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RELIC_HARECS_LEATHER, player, 1))        byte_5111F6[2] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ARTIFACT_LEAGUE_BOOTS, player, 1))       byte_5111F6[3] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RELIC_TALEDONS_HELM, player, 1))         byte_5111F6[4] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RELIC_SCHOLARS_CAP, player, 1))          byte_5111F6[5] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RELIC_PHYNAXIAN_CROWN, player, 1))       byte_5111F6[6] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1))          byte_5111F6[7] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1))           byte_5111F6[8] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RILIC_TITANS_BELT, player, 1))           byte_5111F6[9] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ARTIFAT_HEROS_BELT, player, 1))          byte_5111F6[10] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RELIC_TWILIGHT, player, 1))              byte_5111F6[11] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RARE_SUN_CLOAK, player, 1))              byte_5111F6[13] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RARE_MOON_CLOAK, player, 1))             byte_5111F6[14] = 1;
+    if (sub_43EE15_player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1))          byte_5111F6[15] = 1;
+    if (sub_43EE15_player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1))             byte_5111F6[16] = 1;
+  }
+  
+  //v14 = 1;
+  //v15 = &stru_511698.field_2C;
+  //v35 = (char *)&stru_511718.field_18;
+  for (uint i = 0; i < 2; ++i)
+  {
+    //v16 = 0;
+    //v39 = (unsigned int *)(v35 - 24);
+    for (uint j = 0; j < 5; ++j)
+    {
+      _43C91D_FormItemTextureFilename(pContainer, j + 100, i + 1, 0);
+      //v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      //++v16;
+      //v18 = v39;
+      //++v39;
+      //*v18 = v17;
+      stru_511718[i].texids[j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    }
+    //while ( v16 < 5 );
+    
+    //*(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 535, i + 1, 0);
+    stru_511718[i].texid2 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+
+    //v31 = 0;
+    //v19 = (unsigned int *)((char *)v15 - 44);
+    for (uint j = 0; j < 11; ++j)
+    {
+      _43C91D_FormItemTextureFilename(pContainer, j + 89, i + 1, 0);
+      //*v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      //++v19;
+      stru_511698[i].texids[j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    }
+    //while ( v31 < 11 );
+
+    _43C91D_FormItemTextureFilename(pContainer, 521, i + 1, 0);
+    stru_511698[i].texid1 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 522, i + 1, 0);
+    stru_511698[i].texid2 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 523, i + 1, 0);
+    stru_511698[i].texid3 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 532, i + 1, 0);
+    stru_511698[i].texid4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    _43C91D_FormItemTextureFilename(pContainer, 544, i + 1, 0);
+    stru_511698[i].texid5 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     if ( _43ED6F_check_party_races(true) )
       papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE);
-    v35 += 28;
-    ++v14;
-    ++v15;
-  }
-  while ( v14 - 1 < 2 );
+    //v35 += 28;
+    //++v14;
+    //++v15;
+  }
+  //while ( v14 - 1 < 2 );
+
   v43 = 0;
-  v20 = 1;
+  //v20 = 1;
   v40 = &dword_511638[0][5];
   v21 = (int)paperdoll_array_511290[0][13];
-  v41 = (unsigned int *)&stru_511718.texid1;
-  do
-  {
-    if ( sub_43EDB9_get_some_race_sex_relation_2(v20 - 1) )
-    {
-      _43C91D_FormItemTextureFilename(pContainer, 524, v20, 0);
+  //v41 = (unsigned int *)&stru_511718.texid1;
+  for (uint i = 0; i < 4; ++i)
+  {
+    if ( sub_43EDB9_get_some_race_sex_relation_2(i) )
+    {
+      _43C91D_FormItemTextureFilename(pContainer, 524, i + 1, 0);
       v32 = 66;
-      *v41 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      stru_511718[i].texid1 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       v36 = v21 - 152;
       do
       {
-        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 0);
+        _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 0);
         *(int *)(v36 - 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 1);
+        _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 1);
         *(int *)v36 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-        _43C91D_FormItemTextureFilename(pContainer, v32, v20, 2);
+        _43C91D_FormItemTextureFilename(pContainer, v32, i + 1, 2);
         v22 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v23 = v36;
         v36 += 12;
@@ -6480,35 +6467,35 @@
         *(int *)(v23 + 4) = v22;
       }
       while ( v32 - 66 < 13 );
-      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 0);
       *(int *)v21 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 1);
       *(int *)(v21 + 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 516, v20, 2);
+      _43C91D_FormItemTextureFilename(pContainer, 516, i + 1, 2);
       *(int *)(v21 + 8) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 0);
       *(int *)(v21 + 12) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 1);
       *(int *)(v21 + 16) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 505, v20, 2);
+      _43C91D_FormItemTextureFilename(pContainer, 505, i + 1, 2);
       *(int *)(v21 + 20) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 0);
       *(int *)(v21 + 24) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 1);
       *(int *)(v21 + 28) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 504, v20, 2);
+      _43C91D_FormItemTextureFilename(pContainer, 504, i + 1, 2);
       *(int *)(v21 + 32) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 0);
       *(int *)(v21 + 36) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 1);
       *(int *)(v21 + 40) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 533, v20, 2);
+      _43C91D_FormItemTextureFilename(pContainer, 533, i + 1, 2);
       *(int *)(v21 + 44) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       v33 = 0;
       v37 = (int)(v40 - 5);
       do
       {
-        _43C91D_FormItemTextureFilename(pContainer, v33 + 115, v20, 0);
+        _43C91D_FormItemTextureFilename(pContainer, v33 + 115, i + 1, 0);
         v24 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         ++v33;
         v25 = v37;
@@ -6516,16 +6503,16 @@
         *(int *)v25 = v24;
       }
       while ( v33 < 5 );
-      _43C91D_FormItemTextureFilename(pContainer, 512, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 512, i + 1, 0);
       v26 = v43;
       v38 = 105;
       v34 = v43;
       *v40 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       do
       {
-        _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
+        _43C91D_FormItemTextureFilename(pContainer, v38, i + 1, 0);
         *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-        _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1);
+        _43C91D_FormItemTextureFilename(pContainer, v38, i + 1, 1);
         v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v28 = v34;
         v34 += 4;
@@ -6533,40 +6520,40 @@
         *(int *)((char *)dword_511788 + v28) = v27;
       }
       while ( v38 - 105 < 5 );
-      _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 525, i + 1, 0);
       *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 530, i + 1, 0);
       *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 547, i + 1, 0);
       *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 548, i + 1, 0);
       *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0);
+      _43C91D_FormItemTextureFilename(pContainer, 550, i + 1, 0);
       *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 525, i + 1, 1);
       *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 530, i + 1, 1);
       *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 547, i + 1, 1);
       *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 548, i + 1, 1);
       *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
+      _43C91D_FormItemTextureFilename(pContainer, 550, i + 1, 1);
       *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     }
     else
     {
       v26 = v43;
     }
-    v41 += 7;
+    //v41 += 7;
     v40 += 6;
     v21 += 204;
-    ++v20;
-    result = v20 - 1;
+    //++v20;
+    //result = v20 - 1;
     v43 = v26 + 40;
   }
-  while ( v20 - 1 < 4 );
-  return result;
+  //while ( v20 - 1 < 4 );
+  //return result;
 }
 
 
@@ -7292,9 +7279,9 @@
                                 a2f = pPaperdoll_BodyX + paperdoll_Belt[0][v74][0];
                                 a3f = pPaperdoll_BodyY + paperdoll_Belt[0][v74][1];
                                 if ( IsDwarf != 1 || v73 == 5 )
-                                  v75 = stru_511718.texids[v74];
+                                  v75 = stru_511718[pBodyComplection].texids[v73];
                                 else
-                                  v75 = stru_511718.texids[v73 + 7 * (pBodyComplection - 2)];
+                                  v75 = stru_511718[pBodyComplection - 2].texids[v73];
                                 v76 = *(int *)&pPlayer->field_1F5[36 * v71 + 15];
                                 if ( !(*(int *)&pPlayer->field_1F5[36 * v71 + 15] & 0xF0) )
                                 {
@@ -7498,7 +7485,7 @@
                                                   a2j = pPaperdoll_BodyX + dword_4E58D0[v126];
                                                   a3i = pPaperdoll_BodyY + dword_4E58D4[v126];
                                                   if ( IsDwarf != 1 || *(int *)v124 != 92 )
-                                                    v127 = stru_511698.texids[v125 + 16 * pSex];
+                                                    v127 = stru_511698[0].texids[v125 + 16 * pSex];
                                                   else
                                                     v127 = papredoll_dbrds[11];
                                                   v128 = *(int *)(v124 + 20);
@@ -9061,7 +9048,7 @@
 //LABEL_15:
   pSex = 1;
   return pSex;*/
-  for (int i = 1; i <= 4; &pPlayers[i]) 
+  for (uint i = 1; i <= 4; pPlayers[i]) 
     {
       pRace = pPlayers[i]->GetRace();
       pSex = pPlayers[i]->GetSexByVoice();
--- a/mm7_data.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_data.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -485,8 +485,8 @@
   0x83, 0xD8,  0x1D, 0xBA,  0x58, 0x77,  0, 0,  0, 0,  0, 0,  0, 0,        0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
   0x7B, 0xD8,  0x23, 0xB8,  0x62, 0x77,  0, 0,  0, 0,  0, 0,  0, 0,        0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
 };
-stru332 stru_511698;
-stru333 stru_511718;
+stru332 stru_511698[2];
+stru333 stru_511718[4];
 stru334 array_4E2940[26];
 stru348 stru_4E1890[13];
 
@@ -1962,7 +1962,7 @@
 char pStartingMapName[777]; // idb
 unsigned __int8 IsPlayerWearingWatersuit[5];
 char byte_5111C0[54];
-char byte_5111F6[18];
+char byte_5111F6[16];
 unsigned int papredoll_dbrds[16];
 unsigned int papredoll_drhs[4];
 unsigned int papredoll_dlhus[4];
--- a/mm7_data.h	Fri Mar 01 20:28:01 2013 +0400
+++ b/mm7_data.h	Fri Mar 01 20:28:25 2013 +0400
@@ -1285,7 +1285,7 @@
 extern char pStartingMapName[]; // idb
 extern unsigned __int8 IsPlayerWearingWatersuit[5];
 extern char byte_5111C0[54];
-extern char byte_5111F6[18];
+extern char byte_5111F6[];
 extern unsigned int papredoll_dbrds[16];
 extern unsigned int papredoll_drhs[4];
 extern unsigned int papredoll_dlhus[4];
@@ -1970,7 +1970,7 @@
 void Software_ResetNewEdges();
 // int __cdecl crt_deconstruct_43B9E3();
 int __stdcall DirectInputMouse_enumerator(int, int); // weak
-int __cdecl CharacterUI_LoadPaperdollTextures();
+void CharacterUI_LoadPaperdollTextures();
 int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4);
 void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID); // idb
 void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID); // idb
@@ -2045,7 +2045,7 @@
 void __thiscall TeleportToStartingPoint(unsigned int uPointType); // idb
 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb
 unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
-unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
+void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
 void __cdecl sub_44A56A();
 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
 void __cdecl ShowNothingHereStatus();
--- a/stru6.cpp	Fri Mar 01 20:28:01 2013 +0400
+++ b/stru6.cpp	Fri Mar 01 20:28:25 2013 +0400
@@ -1348,8 +1348,7 @@
       v6 = "spboost1";
     break;
       
-    case SPELL_151:
-      __debugbreak(); // spell id == 151 wtf
+    case SPELL_QUEST_COMPLETED:
     case SPELL_AIR_INVISIBILITY:
     case SPELL_WATER_WATER_WALK:
     case SPELL_SPIRIT_PRESERVATION: