changeset 513:3ee1e351e710

Some CharacterUI_LoadPaperdollTextures overflows
author Nomad
date Fri, 01 Mar 2013 18:22:43 +0200
parents a13d7b95424e
children 0bbc39457b25
files Items.h MM7.h mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 5 files changed, 168 insertions(+), 180 deletions(-) [+]
line wrap: on
line diff
--- a/Items.h	Fri Mar 01 19:18:32 2013 +0600
+++ b/Items.h	Fri Mar 01 18:22:43 2013 +0200
@@ -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 19:18:32 2013 +0600
+++ b/MM7.h	Fri Mar 01 18:22:43 2013 +0200
@@ -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/mm7_5.cpp	Fri Mar 01 19:18:32 2013 +0600
+++ b/mm7_5.cpp	Fri Mar 01 18:22:43 2013 +0200
@@ -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 19:18:32 2013 +0600
+++ b/mm7_data.cpp	Fri Mar 01 18:22:43 2013 +0200
@@ -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 19:18:32 2013 +0600
+++ b/mm7_data.h	Fri Mar 01 18:22:43 2013 +0200
@@ -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