changeset 711:a5e587c8e30e

some cleaning
author Gloval
date Thu, 21 Mar 2013 23:10:57 +0400
parents af08fc9e29c8
children e7c86528a2b3
files BSPModel.h Indoor.cpp Indoor.h Monsters.h Texture.cpp Texture.h UIBooks.cpp UIHouses.h Viewport.cpp Viewport.h mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.h
diffstat 15 files changed, 154 insertions(+), 214 deletions(-) [+]
line wrap: on
line diff
--- a/BSPModel.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/BSPModel.h	Thu Mar 21 23:10:57 2013 +0400
@@ -3,7 +3,7 @@
 
 
 #pragma pack(push, 1)
-struct BSPNode
+struct BSPNode //8
 {
   __int16 uFront;
   __int16 uBack;
--- a/Indoor.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/Indoor.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -1720,69 +1720,32 @@
 }
 
 //----- (00498C45) --------------------------------------------------------
-int IndoorLocation::Alloc()
-{
-  IndoorLocation *v1; // esi@1
-  void *v2; // eax@1
-  const void *v3; // ST3C_4@1
-  void *v4; // eax@1
-  const void *v5; // ST3C_4@1
-  void *v6; // eax@1
-  const void *v7; // ST3C_4@1
-  void *v8; // eax@1
-  const void *v9; // ST3C_4@1
-  void *v10; // eax@1
-  const void *v11; // ST3C_4@1
-  void *v12; // eax@1
-  const void *v13; // ST3C_4@1
-  void *v14; // eax@1
-  const void *v15; // ST3C_4@1
-  void *v16; // eax@1
-  void *v17; // ecx@1
-  signed int result; // eax@9
-
-  v1 = this;
-  v2 = pAllocator->AllocNamedChunk(this->pVertices, 0x15F90u, "L.V");
-  v3 = v1->pFaces;
-  v1->pVertices = (Vec3_short_ *)v2;
-  v4 = pAllocator->AllocNamedChunk(v3, 0xEA600u, "L.F");
-  v5 = v1->pFaceExtras;
-  v1->pFaces = (BLVFace *)v4;
-  v6 = pAllocator->AllocNamedChunk(v5, 0x2BF20u, "L.FX");
-  v7 = v1->pSectors;
-  v1->pFaceExtras = (BLVFaceExtra *)v6;
-  v8 = pAllocator->AllocNamedChunk(v7, 0xE800u, "L.R");
-  v9 = v1->pLights;
-  v1->pSectors = (BLVSector *)v8;
-  v10 = pAllocator->AllocNamedChunk(v9, 0x1900u, "L.L");
-  v11 = v1->pDoors;
-  v1->pLights = (BLVLightMM7 *)v10;
-  v12 = pAllocator->AllocNamedChunk(v11, 0x3E80u, "L.D");
-  v13 = v1->pNodes;
-  v1->pDoors = (BLVDoor *)v12;
-  v14 = pAllocator->AllocNamedChunk(v13, 0x9C40u, "L.BSP");
-  v15 = v1->pMapOutlines;
-  v1->pNodes = (BSPNode *)v14;
-  v16 = pAllocator->AllocNamedChunk(v15, 0x14824u, "L.Map");
-  v17 = v1->pVertices;
-  v1->pMapOutlines = (BLVMapOutlines *)v16;
-  if ( v17 && v1->pFaces && v1->pFaceExtras && v1->pSectors && v1->pLights && v1->pDoors && v1->pNodes && v16 )
+bool IndoorLocation::Alloc()
+    {
+  pVertices   = (Vec3_short_ *)   pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_),  "L.V");//0x15F90u
+  pFaces      = (BLVFace *)       pAllocator->AllocNamedChunk(pFaces,    10000*sizeof(BLVFace),      "L.F");//0xEA600u
+  pFaceExtras = (BLVFaceExtra *)  pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u
+  pSectors =    (BLVSector *)     pAllocator->AllocNamedChunk(pSectors,    512*sizeof(BLVSector),     "L.R");//0xE800u
+  pLights =     (BLVLightMM7 *)   pAllocator->AllocNamedChunk(pLights,     400*sizeof(BLVLightMM7),   "L.L");//0x1900u
+  pDoors =      (BLVDoor *)       pAllocator->AllocNamedChunk(pDoors,      200*sizeof(BLVDoor),       "L.D");//0x3E80u
+  pNodes =      (BSPNode *)       pAllocator->AllocNamedChunk(pNodes,     5000*sizeof(BSPNode),       "L.BSP");//0x9C40u
+  pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines,   sizeof(BLVMapOutlines), "L.Map");//0x14824u
+  if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines )
   {
-    memset(v17, 90000, 0);
-    memset(v1->pFaces, 960000, 0);
-    memset(v1->pFaceExtras, 180000, 0);
-    memset(v1->pSectors, 59392, 0);
-    memset(v1->pLights, 6400, 0);
-    memset(v1->pDoors, 16000, 0);
-    memset(v1->pNodes, 40000, 0);
-    memset(v1->pMapOutlines, 84004, 0);
-    result = 1;
+    memset(pVertices,  0, 15000*sizeof(Vec3_short_));
+    memset(pFaces,     0, 10000*sizeof(BLVFace));
+    memset(pFaceExtras,0,  5000*sizeof(BLVFaceExtra));
+    memset(pSectors,   0,   512*sizeof(BLVSector));
+    memset(pLights,    0,   400*sizeof(BLVLightMM7));
+    memset(pDoors,     0,   200*sizeof(BLVDoor));
+    memset(pNodes,     0,  5000*sizeof(BSPNode));
+    memset(pMapOutlines,0,  sizeof(BLVMapOutlines));
+    return true;
   }
   else
   {
-    result = 0;
+    return false;
   }
-  return result;
 }
 
 
@@ -1802,13 +1765,13 @@
 
 
 //----- (004488F7) --------------------------------------------------------
-void IndoorLocation::ToggleLight(unsigned int uLightID, unsigned int bToggle)
+void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle)
 {
   char *v2; // eax@4
 
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (signed int)uLightID <= pIndoor->uNumLights - 1 && (uLightID & 0x80000000u) == 0 )
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) )
   {
-    v2 = (char *)&pIndoor->pLights[uLightID].uAtributes;
+    v2 = (char *)&pIndoor->pLights[sLightID].uAtributes;
     if ( bToggle )
       *v2 &= 0xF7u;
     else
--- a/Indoor.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/Indoor.h	Thu Mar 21 23:10:57 2013 +0400
@@ -177,7 +177,7 @@
 
 /*   98 */
 #pragma pack(push, 1)
-struct BLVLightMM7
+struct BLVLightMM7 //10h
 {
   struct Vec3_short_ vPosition;
   __int16 uRadius;
@@ -202,7 +202,7 @@
 
 /*  100 */
 #pragma pack(push, 1)
-struct BLVDoor
+struct BLVDoor //50h
 {
   enum State: unsigned __int16
   {
@@ -238,7 +238,7 @@
 
 /*  101 */
 #pragma pack(push, 1)
-struct BLVMapOutline
+struct BLVMapOutline //0C
 {
   unsigned __int16 uVertex1ID;
   unsigned __int16 uVertex2ID;
@@ -264,7 +264,7 @@
 
 /*   93 */
 #pragma pack(push, 1)
-struct BLVFace
+struct BLVFace  //60h
 {
   //----- (0046ED02) --------------------------------------------------------
   inline BLVFace()
@@ -315,7 +315,7 @@
 
 /*   94 */
 #pragma pack(push, 1)
-struct BLVFaceExtra
+struct BLVFaceExtra  //24h
 {
 bool HasEventint();
 
@@ -342,7 +342,7 @@
 
 /*   95 */
 #pragma pack(push, 1)
-struct BLVSector
+struct BLVSector //0x74
 {
   int field_0;
   unsigned __int16 uNumFloors;
@@ -392,8 +392,8 @@
 #pragma pack(push, 1)
 struct BLVMapOutlines
 {
-  uint          uNumOutlines;
-  BLVMapOutline pOutlines[1];
+  int          uNumOutlines;
+  BLVMapOutline pOutlines[7000];
 };
 #pragma pack(pop)
 
@@ -435,10 +435,10 @@
 
   int GetSector(int sX, int sY, int sZ);
   void Release();
-  int Alloc();
+  bool Alloc();
   bool Load(char *pFilename, int a3, size_t i, char *pDest);
   void Draw();
-  void ToggleLight(unsigned int uLightID, unsigned int bToggle);
+  void ToggleLight(signed int uLightID, unsigned int bToggle);
 
   static unsigned int GetLocationIndex(const char *Str1);
   static void ExecDraw(bool bD3D);
@@ -503,10 +503,10 @@
   unsigned __int16 *pRenderTarget;
   unsigned int uTargetWidth;
   unsigned int uTargetHeight;
-  unsigned int uViewportX;
-  unsigned int uViewportY;
-  unsigned int uViewportZ;
-  unsigned int uViewportW;
+  signed int uViewportX;
+  signed int uViewportY;
+  signed int uViewportZ;
+  signed int uViewportW;
   int field_3C;
   int *pTargetZ;
 };
--- a/Monsters.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/Monsters.h	Thu Mar 21 23:10:57 2013 +0400
@@ -142,7 +142,7 @@
   unsigned int uAC;
   unsigned int uExp;
   unsigned int uBaseSpeed;
-  unsigned int uRecoveryTime;
+  signed int uRecoveryTime;
   unsigned int uAttackPreference;
 };
 #pragma pack(pop)
--- a/Texture.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/Texture.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -267,28 +267,26 @@
   if ( !v2 )
     Abortf("Unable to save dtft.bin!");
   fwrite(v1, 4u, 1u, v2);
-  fwrite(v1->pTextures, 0x14u, v1->uNumTextures, v3);
+  fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3);
   fclose(v3);
 }
 
 //----- (0044E0A0) --------------------------------------------------------
 void TextureFrameTable::FromFile(void *pSerialized)
 {
-  uNumTextures = *(int *)pSerialized;
-  pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, 20 * uNumTextures, "Txt Frames");
-  memcpy(pTextures, (char *)pSerialized + 4, 20 * uNumTextures);
+  sNumTextures = *(int *)pSerialized;
+  pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, 20 * sNumTextures, "Txt Frames");
+  memcpy(pTextures, (char *)pSerialized + 4, 20 * sNumTextures);
 }
 
 //----- (0044E0ED) --------------------------------------------------------
-unsigned int TextureFrameTable::LoadAnimationSequenceAndPalettes(unsigned int uIconID)
-{
-  unsigned int result; // eax@1
+void TextureFrameTable::LoadAnimationSequenceAndPalettes( signed int uIconID )
+    {
   TextureFrameTable *v3; // ebx@1
   unsigned int i; // edi@3
 
-  result = uIconID;
   v3 = this;
-  if ( (signed int)uIconID <= (signed int)this->uNumTextures && (uIconID & 0x80000000u) == 0 )
+  if ( (uIconID <= this->sNumTextures) && uIconID >= 0 )
   {
     for ( i = uIconID; ; ++i )
     {
@@ -296,12 +294,13 @@
       auto pTex = (v3->pTextures[i].uTextureID != -1 ? &pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID] : 0);
       if (pTex)
         pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1);
-      result = (unsigned int)v3->pTextures;
-      if ( !(*(char *)(result + i * 20 + 18) & 1) )
+      //result = (unsigned int)v3->pTextures;
+      //if ( !(*(char *)(result + i * 20 + 18) & 1) )
+      if( v3->pTextures[i].uFlags&1)
         break;
     }
   }
-  return result;
+  return;
 }
 
 //----- (0044E163) --------------------------------------------------------
@@ -315,7 +314,7 @@
   v2 = this;
   v3 = 0;
   uID = 0;
-  if ( (signed int)this->uNumTextures <= 0 )
+  if ( (signed int)this->sNumTextures <= 0 )
   {
 LABEL_4:
     result = -1;
@@ -326,7 +325,7 @@
     {
       ++uID;
       ++v3;
-      if ( (signed int)uID >= (signed int)v2->uNumTextures )
+      if ( (signed int)uID >= (signed int)v2->sNumTextures )
         goto LABEL_4;
     }
     result = uID;
--- a/Texture.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/Texture.h	Thu Mar 21 23:10:57 2013 +0400
@@ -105,17 +105,17 @@
   inline TextureFrameTable()
   {
     pTextures = 0;
-    uNumTextures = 0;
+    sNumTextures = 0;
   }
   int FromFileTxt(const char *Args);
   void ToFile();
   void FromFile(void *pSerialized);
-  unsigned int LoadAnimationSequenceAndPalettes(unsigned int uIconID);
+  void LoadAnimationSequenceAndPalettes(signed int uIconID);
   unsigned int GetFrameTexture(int uFrameID, signed int a3);
   unsigned int FindTextureByName(const char *Str2);
 
 
-  unsigned int uNumTextures;
+  signed int sNumTextures;
   struct TextureFrame *pTextures;
 };
 #pragma pack(pop)
--- a/UIBooks.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/UIBooks.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -1146,9 +1146,9 @@
         }
     else
         {
-        v6 = viewparams->field_38;
-        v86 = viewparams->field_38;
-        v84 = viewparams->field_3A;
+        v6 = viewparams->indoor_center_x;
+        v86 = viewparams->indoor_center_x;
+        v84 = viewparams->indoor_center_y;
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
             v5 = viewparams->field_2C - 34;
         }
--- a/UIHouses.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/UIHouses.h	Thu Mar 21 23:10:57 2013 +0400
@@ -37,7 +37,7 @@
 char *__cdecl JailDialog();
 void  MagicShopDialog();
 void  GuildDialog();
-int __cdecl sub_4B6478();
+void  sub_4B6478();
 bool __fastcall sub_4B68EA(int a1);
 void __cdecl TravelByTransport();
 void TempleDialog();
--- a/Viewport.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/Viewport.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -14,7 +14,6 @@
     unsigned int br_x; // esi@1
     unsigned int tl_y; // edi@3
     unsigned int br_y; // eax@3
-    int v10; // eax@7
 
     tl_x = sTL_X;
     br_x = sBR_X;
@@ -25,7 +24,7 @@
         }
     tl_y = sTL_Y;
     br_y = sBR_Y;
-    if ( (signed int)sTL_Y > (signed int)sBR_Y )
+    if ( sTL_Y > sBR_Y )
         {
         br_y = sBR_Y ^ sTL_Y ^ sBR_Y;                           // swap y's 
         tl_y = br_y ^ sBR_Y ^ sTL_Y;
@@ -150,13 +149,13 @@
 
 
     v1 = this;
-    v2 = this->field_3A;
+    v2 = this->indoor_center_y;
     v3 = 88 >> this->field_2C / 384;
     v4 = (44 - v3) << 9;
     if ( v1->sViewCenterY > v2 + v4 )
         v1->sViewCenterY = v2 + v4;
 
-    v5 = v1->field_38;
+    v5 = v1->indoor_center_x;
     v6 = (v3 - 44) << 9;
     if ( v1->sViewCenterX < v5 + v6 )
         v1->sViewCenterX = v5 + v6;
@@ -179,80 +178,60 @@
 //----- (00443365) --------------------------------------------------------
 void ViewingParams::_443365()
     {
-    ViewingParams *v1; // esi@1
-    __int16 *v2; // edi@3
+  
     Vec3_short_ *v3; // eax@4
-    unsigned int v4; // edx@4
-    signed int v5; // eax@8
     Vec3_short_ *v6; // eax@12
-    signed int v7; // edi@12
-    signed int v8; // eax@16
-    char v9; // zf@20
-    int result; // eax@21
-    unsigned int v11; // [sp+4h] [bp-1Ch]@3
-    unsigned int *v12; // [sp+8h] [bp-18h]@3
-    unsigned int v13; // [sp+Ch] [bp-14h]@8
-    unsigned int v14; // [sp+10h] [bp-10h]@2
-    unsigned int v15; // [sp+14h] [bp-Ch]@2
-    unsigned int v16; // [sp+18h] [bp-8h]@2
-    unsigned int v17; // [sp+1Ch] [bp-4h]@2
+    int minimum_y; // [sp+10h] [bp-10h]@2
+    int maximum_y; // [sp+14h] [bp-Ch]@2
+    int minimum_x; // [sp+18h] [bp-8h]@2
+     int maximum_x; // [sp+1Ch] [bp-4h]@2
 
-    v1 = this;
+ 
     InitGrayPalette();
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
         {
-        v16 = 0x40000000u;
-        v14 = 0x40000000u;
-        v17 = 0xC0000000u;
-        v15 = 0xC0000000u;
-        if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
+        minimum_x = 0x40000000;
+        minimum_y = 0x40000000;
+
+        maximum_x = -0x40000000;
+        maximum_y = -0x40000000;
+        for (int i=0; i<pIndoor->pMapOutlines->uNumOutlines; ++i)
             {
-            v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
-            v11 = pIndoor->pMapOutlines->uNumOutlines;
-            v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
-            do
-                {
-                v3 = &pIndoor->pVertices[*v2];
-                v4 = v3->x;
-                if ( (signed int)v4 < (signed int)v16 )
-                    v16 = v3->x;
-                if ( (signed int)v4 > (signed int)v17 )
-                    v17 = v3->x;
-                v5 = v3->y;
-                v13 = v5;
-                if ( v5 < (signed int)v14 )
-                    v14 = v4;
-                if ( v5 > (signed int)v15 )
-                    v15 = v4;
-                v6 = &pIndoor->pVertices[v2[1]];
-                v7 = v6->x;
-                if ( v7 < (signed int)v16 )
-                    v16 = v4;
-                if ( v7 > (signed int)v17 )
-                    v17 = v4;
-                v8 = v6->y;
-                if ( v8 < (signed int)v14 )
-                    v14 = v13;
-                if ( v8 > (signed int)v15 )
-                    v15 = v13;
-                v2 = (__int16 *)(v12 + 3);
-                v9 = v11-- == 1;
-                v12 += 3;
-                }
-                while ( !v9 );
+            v3 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace1ID];
+
+            if ( v3->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v3->x > maximum_x )
+                maximum_x = v3->x;
+            if ( v3->y < minimum_y )
+                minimum_y = v3->x;
+            if ( v3->y > maximum_y )
+                maximum_y = v3->x;
+
+            v6 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace2ID];
+
+            if ( v6->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v6->x > maximum_x )
+                maximum_x = v3->x;
+ 
+            if ( v6->y < minimum_y )
+                minimum_y = v3->y;
+            if ( v6->y > maximum_y )
+                maximum_y = v3->y;
             }
-        v1->uMinimapZoom = 1024;
-        v1->field_38 = (signed int)(v16 + v17) / 2;
-        v1->field_28 = 10;
-        result = (signed int)(v14 + v15) / 2;
-        v1->field_3A = result;
+
+        uMinimapZoom = 1024;
+        indoor_center_x = (signed int)(minimum_x + maximum_x) / 2;
+        field_28 = 10;
+        indoor_center_y = (signed int)(minimum_y + maximum_y) / 2;
         }
     else
         {
-        v1->field_38 = 0;
-        v1->field_3A = 0;
-        v1->uMinimapZoom = dword_576E2C;
-        v1->field_28 = dword_576E28;
+        indoor_center_x = 0;
+        indoor_center_y = 0;
+        uMinimapZoom = dword_576E2C;
+        field_28 = dword_576E28;
         }
-    v1->field_2C = 384;
+    field_2C = 384;
     }
\ No newline at end of file
--- a/Viewport.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/Viewport.h	Thu Mar 21 23:10:57 2013 +0400
@@ -67,8 +67,8 @@
   int field_2C;
   int sViewCenterX;
   int sViewCenterY;
-  __int16 field_38;
-  __int16 field_3A;
+  __int16 indoor_center_x;
+  __int16 indoor_center_y;
   int field_3C;
   unsigned int uTextureID_LocationMap;
   int bRedrawGameUI;
--- a/mm7_2.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/mm7_2.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -4777,13 +4777,13 @@
     v4 = v24;
   }
   v5 = v2->pTextures;
-  v2->uNumTextures = v4;
+  v2->sNumTextures = v4;
   v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames");
   v2->pTextures = (TextureFrame *)v6;
   if ( !v6 )
     Abortf("CTextureFrameTable::load - Out of Memory!");
   v7 = File;
-  v2->uNumTextures = 0;
+  v2->sNumTextures = 0;
   fseek(v7, 0, 0);
   for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
   {
@@ -4791,23 +4791,23 @@
     memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu);
     if ( v21 && *Str1 != 47 )
     {
-      strcpy(v2->pTextures[v2->uNumTextures].pTextureName, Str1);
-      v2->pTextures[v2->uNumTextures].uAnimTime = atoi(Str);
+      strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1);
+      v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str);
       v9 = 2;
-      for ( v2->pTextures[v2->uNumTextures].uFlags = 0; v9 < v21; ++v9 )
+      for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
       {
         if ( !_strcmpi((&Str1)[4 * v9], "New") )
         {
-          v10 = (int)&v2->pTextures[v2->uNumTextures].uFlags;
+          v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags;
           *(char *)v10 |= 2u;
         }
       }
-      ++v2->uNumTextures;
+      ++v2->sNumTextures;
     }
   }
   fclose(File);
   v11 = 0;
-  if ( (signed int)(v2->uNumTextures - 1) > 0 )
+  if ( (signed int)(v2->sNumTextures - 1) > 0 )
   {
     v12 = 0;
     do
@@ -4818,9 +4818,9 @@
       ++v11;
       ++v12;
     }
-    while ( v11 < (signed int)(v2->uNumTextures - 1) );
-  }
-  for ( j = 0; j < (signed int)v2->uNumTextures; *(short *)(Argsa + 16) = v16 )
+    while ( v11 < (signed int)(v2->sNumTextures - 1) );
+  }
+  for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 )
   {
     v15 = v2->pTextures;
     Argsa = (int)&v15[j];
--- a/mm7_3.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/mm7_3.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -12362,8 +12362,8 @@
   v19 = (double)viewparams->field_2C * 0.000015258789;
   if ( viewparams->field_2C == 384 )
   {
-    v20 = viewparams->field_38;
-    v21 = viewparams->field_3A;
+    v20 = viewparams->indoor_center_x;
+    v21 = viewparams->indoor_center_y;
   }
   v17 = 0;
   v16 = pOutdoor->uNumBModels;
@@ -13247,7 +13247,7 @@
   }
   if ( npcid >= 5000 )
     goto LABEL_7;
-  if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+  if ( sDialogue_SpeakingActorNPC_ID >= 0 )
   {
     *(int *)a2 = 0;
     result = 0;
@@ -15792,7 +15792,7 @@
       v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
       if ( (signed int)v28 > 0 )
         v21->pMonsterInfo.uRecoveryTime = v28 - v27;
-      if ( (v21->pMonsterInfo.uRecoveryTime & 0x80000000u) != 0 )
+      if ( v21->pMonsterInfo.uRecoveryTime< 0 )
         v21->pMonsterInfo.uRecoveryTime = 0;
       v29 = v21->uAttributes;
       if ( !(v29 & 0x8000) )
--- a/mm7_4.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/mm7_4.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -5921,10 +5921,10 @@
 
 
 //----- (004AD504) --------------------------------------------------------
-int __fastcall sub_4AD504(unsigned int uFaceID)
+int __fastcall sub_4AD504(signed int sFaceID)
 {
   int result; // eax@1
-  unsigned int v2; // ebx@1
+  signed int v2; // ebx@1
   BLVFace *v3; // esi@3
   Texture *v4; // edi@6
   int v5; // eax@7
@@ -6048,17 +6048,17 @@
   unsigned int v123; // [sp+A0h] [bp-4h]@13
 
   result = pRenderer->uTargetSurfacePitch;
-  v2 = uFaceID;
+  v2 = sFaceID;
   v95 = pRenderer->uTargetSurfacePitch;
-  if ( (uFaceID & 0x80000000u) == 0 )
-  {
-    if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces )
-    {
-      v3 = &pIndoor->pFaces[uFaceID];
-      v91 = &pIndoor->pFaces[uFaceID];
+  if ( sFaceID >= 0 )
+  {
+    if ( sFaceID < (signed int)pIndoor->uNumFaces )
+    {
+      v3 = &pIndoor->pFaces[sFaceID];
+      v91 = &pIndoor->pFaces[sFaceID];
       if ( !pRenderer->pRenderD3D )
       {
-        result = sub_423B5D(uFaceID);
+        result = sub_423B5D(sFaceID);
         if ( result )
         {
           result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
@@ -9621,7 +9621,7 @@
 
 			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
 
-			if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+			if ( sDialogue_SpeakingActorNPC_ID >= 0 )
 				pDialogue_SpeakingActor->uAIState = Removed;
 			if ( uActiveCharacter )
 				pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
@@ -9842,8 +9842,8 @@
 
 
 //----- (004B6478) --------------------------------------------------------
-int __cdecl sub_4B6478()
-{
+void sub_4B6478()
+    {
   GUIWindow *v0; // ebx@1
   Player *v1; // edi@1
   unsigned int v2; // eax@1
@@ -9950,7 +9950,7 @@
       ++pMessageQueue_50CBD0->uNumMessages;
     }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
-    return result; // void func
+    return; // void func
   }
   if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
@@ -9958,13 +9958,12 @@
     v25 = v31;
     v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0);
     v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u);
-    result = (int)pDialogueWindow;
     pDialogueWindow->pNumPresenceButton = 0;
-    return result;
-  }
-  result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( !result )
-    return result;
+    return ;
+  }
+
+  if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+    return;
   v8 = pDialogueWindow;
   v33 = 0;
   v34 = 0;
@@ -9995,17 +9994,18 @@
     strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
     v22 = v31;
     v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0);
-    return (int)v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
+    v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
+    return; 
   }
   sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
   v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   v32 = (149 - v33) / v34;
   if ( (149 - v33) / v34 > 32 )
     v32 = 32;
-  result = v8->pStartingPosActiveItem;
-  v35 = result;
+
+  v35 = v8->pStartingPosActiveItem;
   v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162;
-  if ( result < result + v8->pNumPresenceButton )
+  if ( v8->pStartingPosActiveItem < v8->pStartingPosActiveItem+ v8->pNumPresenceButton )
   {
     v33 = 2;
     do
@@ -10043,11 +10043,10 @@
       v8 = v29;
       ++v35;
       ++v33;
-      result = v29->pNumPresenceButton + v29->pStartingPosActiveItem;
-    }
-    while ( v35 < result );
-  }
-  return result;
+    }
+    while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem );
+  }
+  return;
 }
 
 
--- a/mm7_5.cpp	Thu Mar 21 12:37:49 2013 +0200
+++ b/mm7_5.cpp	Thu Mar 21 23:10:57 2013 +0400
@@ -6631,7 +6631,7 @@
 
   v1 = uPlayerID - 1;
   v8 = uPlayerID;
-  if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
+  if ( (uPlayerID - 1) >= 0 )
   {
     v2 = &pPlayers[uPlayerID];
     v3 = (*v2)->GetRace();
--- a/mm7_data.h	Thu Mar 21 12:37:49 2013 +0200
+++ b/mm7_data.h	Thu Mar 21 23:10:57 2013 +0400
@@ -2276,7 +2276,7 @@
 struct Vec4_int_ *__thiscall sub_4AC277(unsigned int _this, Vec4_int_ *a2);
 struct Vec4_int_ *__thiscall sub_4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1);
 struct Vec4_int_ *__thiscall sub_4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1);
-int __fastcall sub_4AD504(unsigned int uFaceID);
+int __fastcall sub_4AD504(signed int uFaceID);
 void __fastcall sub_4ADD1D(int uFaceID);
 int __fastcall sub_4AE1E7(int a1, int a2, int a3);
 int __fastcall sub_4AE313(int viewport_space_x, int viewport_space_y, struct stru337_stru0 *p);