changeset 150:20c034b5a6e2

Слияние
author Ritor1
date Mon, 26 Nov 2012 09:35:24 +0600
parents 13b2a2cd4552 (current diff) 38a1c8ef6874 (diff)
children a8f4a158e284
files Render.cpp
diffstat 4 files changed, 158 insertions(+), 211 deletions(-) [+]
line wrap: on
line diff
--- a/LOD.cpp	Mon Nov 26 09:35:10 2012 +0600
+++ b/LOD.cpp	Mon Nov 26 09:35:24 2012 +0600
@@ -1646,13 +1646,13 @@
 //----- (00461B48) --------------------------------------------------------
 unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4)
 {
-  //LODWriteableFile *v4; // ebx@1
+  LODWriteableFile *v4; // ebx@1
   int v5; // esi@1
-  //unsigned __int8 v7; // zf@7
-  //unsigned __int8 v8; // sf@7
+  unsigned __int8 v7; // zf@7
+  unsigned __int8 v8; // sf@7
   const LOD::Directory *v9; // edi@9
   int v10; // eax@9
-  //unsigned __int8 v11; // of@15
+  unsigned __int8 v11; // of@15
   unsigned __int16 v12; // dx@17
   LOD::Directory *v13; // eax@17
   unsigned __int16 v14; // cx@17
@@ -1674,7 +1674,7 @@
   char NewFilename[256]; // [sp+10Ch] [bp-130h]@51
   //LOD::Directory Str; // [sp+20Ch] [bp-30h]@27
   size_t v33; // [sp+22Ch] [bp-10h]@27
-  //int v34; // [sp+230h] [bp-Ch]@7
+  int v34; // [sp+230h] [bp-Ch]@7
   __int32 v35; // [sp+234h] [bp-8h]@8
   int v36; // [sp+238h] [bp-4h]@7
   size_t Count; // [sp+244h] [bp+8h]@40
@@ -1682,81 +1682,63 @@
   size_t Countb; // [sp+244h] [bp+8h]@47
   FILE *pFile; // [sp+24Ch] [bp+10h]@22
 
-  //v4 = this;
-  //v5 = 0;
-
-  if (!isFileOpened)
+  v4 = this;
+  v5 = 0;
+  if ( !this->isFileOpened )
     return 1;
-  if (!pSubIndices)
+  if ( !this->pSubIndices )
     return 2;
-  if (!pIOBuffer || !uIOBufferSize)
+  if ( !this->pIOBuffer || !this->uIOBufferSize )
     return 3;
-
-  //v7 = this->uNumSubIndices == 0;
-  //v8 = (this->uNumSubIndices & 0x80000000u) != 0;
-  v35 = 0;
+  v7 = this->uNumSubIndices == 0;
+  v8 = (this->uNumSubIndices & 0x80000000u) != 0;
   v36 = 0;
-  //v34 = 0;
-  for (v5 = 0; v5 < uNumSubIndices; ++v5)
-  /*if ( v8 | v7 )
+  v34 = 0;
+  if ( v8 | v7 )
   {
     v9 = pDir;
     goto LABEL_22;
   }
-  while ( 1 )*/
+  v35 = 0;
+  while ( 1 )
   {
     v9 = pDir;
-    v10 = _strcmpi(pSubIndices[v5].pFilename, pDir->pFilename);
-    if (v10 > 0)
-      break;
-    else if (v10 < 0)
-      continue;
-    /*if ( v10 )
+    v10 = _strcmpi((const char *)v4->pSubIndices + v35, (const char *)pDir);
+    if ( v10 )
     {
       if ( v10 > 0 )
         goto LABEL_22;
       goto LABEL_15;
-    }*/
+    }
     if ( !a4 )
-    {
-      v36 = 1;
-      break;
-    }
+      goto LABEL_20;
     if ( a4 == 1 )
-    {
-      v12 = pDir->uNumSubIndices;
-      v13 = &pSubIndices[v5];
-      v14 = v13->uNumSubIndices;
-      if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) )
-        return 4;
-      v36 = 1;
       break;
-    }
     if ( a4 == 2 )
       return 4;
-//LABEL_15:
-    //v35 += 32;
-    //++v5;
-    //v11 = __OFSUB__(v5, v4->uNumSubIndices);
-    //v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
-    //v34 = v5;
-    //if ( !(v8 ^ v11) )
-      //goto LABEL_22;
+LABEL_15:
+    v35 += 32;
+    ++v5;
+    v11 = v5 >= v4->uNumSubIndices;
+    v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
+    v34 = v5;
+    if ( !(v8 ^ v11) )
+      goto LABEL_22;
   }
-/*  v12 = pDir->uNumSubIndices;
+  v12 = pDir->uNumSubIndices;
   v13 = &v4->pSubIndices[v5];
   v14 = v13->uNumSubIndices;
   if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) )
     return 4;
 LABEL_20:
   v36 = 1;
-LABEL_22:*/
+LABEL_22:
   strcpy(pFilename, "lod.tmp");
   pFile = fopen(pFilename, "wb+");
   if ( !pFile )
     return 5;
   if ( v36 )
-    v35 = pSubIndices[v5].uDataSize;
+    v35 = v4->pSubIndices[v5].uDataSize;
   else
     v35 = 0;
   v33 = v9->uDataSize;
@@ -1765,9 +1747,9 @@
   LOD::Directory Str; // [sp+20Ch] [bp-30h]@27
   //LOD::Directory::LOD::Directory(&Str);
 
-  strcpy(Str.pFilename, "chapter");
-  v16 = uLODDataSize;
-  Str.uNumSubIndices = uNumSubIndices;
+  strcpy((char *)&Str, "chapter");
+  v16 = v4->uLODDataSize;
+  Str.uNumSubIndices = LOWORD(v4->uNumSubIndices);
   Str.dword_000018 = 0;
   Str.word_00001E = 0;
   if ( !v36 )
@@ -1775,76 +1757,84 @@
     ++Str.uNumSubIndices;
     v15 += 32;
   }
-  //v7 = v36 == 0;
+  v7 = v36 == 0;
   Str.uDataSize = v15 + v16;
   Str.uOfsetFromSubindicesStart = 288;
   v17 = (signed __int16)Str.uNumSubIndices;
-  uNumSubIndices = (signed __int16)Str.uNumSubIndices;
-  if ( !v36 && v17 > v5 )
+  v4->uNumSubIndices = (signed __int16)Str.uNumSubIndices;
+  if ( v7 && v17 > v5 )
   {
     v18 = v17;
     v19 = v17 - v5;
     do
     {
-      v20 = &pSubIndices[v18];
+      v20 = &v4->pSubIndices[v18];
       --v18;
       --v19;
       memcpy(v20, (char *)v20 - 32, 0x20u);
     }
     while ( v19 );
-    //v5 = v34;
+    v5 = v34;
   }
-  //v34 = 32 * v5;
-  memcpy(&pSubIndices[v5], pDir, sizeof(LOD::Directory));
-  v23 = 32 * uNumSubIndices;
-  if ( (signed int)uNumSubIndices > 0 )
+  v21 = v4->pSubIndices;
+  v34 = 32 * v5;
+  memcpy(&v21[v5], pDir, sizeof(v21[v5]));
+  v22 = 0;
+  v23 = 32 * v4->uNumSubIndices;
+  if ( (signed int)v4->uNumSubIndices > 0 )
   {
-    for (int i =  0; i < (signed int)uNumSubIndices; ++i)
+    v24 = v4->pSubIndices;
+    v25 = 0;
+    do
     {
-      pSubIndices[i].uOfsetFromSubindicesStart = v23;
-      v23 += pSubIndices[i].uDataSize;
+      v24[v25].uOfsetFromSubindicesStart = v23;
+      v24 = v4->pSubIndices;
+      v23 += v24[v25].uDataSize;
+      ++v22;
+      ++v25;
     }
+    while ( v22 < (signed int)v4->uNumSubIndices );
   }
-  fwrite(&header, 0x100, 1, pFile);
-  fwrite(&Str, 0x20, 1, pFile);
-  fseek(pFile, Str.uOfsetFromSubindicesStart, 0);
-  fwrite(pSubIndices, 0x20u, uNumSubIndices, pFile);
-  v26 = 32 * uNumSubIndices;
+  fwrite(&v4->header, 0x100u, 1u, pFile);
+  fwrite(&Str, 0x20u, 1u, pFile);
+  fseek(v4->pFile, Str.uOfsetFromSubindicesStart, 0);
+  fwrite(v4->pSubIndices, 0x20u, v4->uNumSubIndices, pFile);
+  v26 = 32 * v4->uNumSubIndices;
   if ( !v36 )
     v26 -= 32;
-  fseek(pFile, v26, 1);
-  for ( i = pSubIndices[v5].uOfsetFromSubindicesStart
-          - pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count )
+  fseek(v4->pFile, v26, 1);
+  for ( i = *(unsigned int *)((char *)&v4->pSubIndices->uOfsetFromSubindicesStart + v34)
+          - v4->pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count )
   {
-    Count = uIOBufferSize;
-    if ( i <= (signed int)uIOBufferSize )
+    Count = v4->uIOBufferSize;
+    if ( i <= (signed int)v4->uIOBufferSize )
       Count = i;
-    fread(pIOBuffer, 1u, Count, pFile);
-    fwrite(pIOBuffer, 1u, Count, pFile);
+    fread(v4->pIOBuffer, 1u, Count, v4->pFile);
+    fwrite(v4->pIOBuffer, 1u, Count, pFile);
   }
   fwrite(pDirData, 1u, v33, pFile);
   if ( v36 )
-    fseek(pFile, v35, 1);
-  Countc = ftell(pFile);
-  fseek(pFile, 0, 2);
-  v28 = ftell(pFile) - Countc;
-  fseek(pFile, Countc, 0);
+    fseek(v4->pFile, v35, 1);
+  Countc = ftell(v4->pFile);
+  fseek(v4->pFile, 0, 2);
+  v28 = ftell(v4->pFile) - Countc;
+  fseek(v4->pFile, Countc, 0);
   while ( v28 > 0 )
   {
-    Countb = uIOBufferSize;
-    if ( v28 <= (signed int)uIOBufferSize )
+    Countb = v4->uIOBufferSize;
+    if ( v28 <= (signed int)v4->uIOBufferSize )
       Countb = v28;
-    fread(pIOBuffer, 1u, Countb, pFile);
-    fwrite(pIOBuffer, 1u, Countb, pFile);
+    fread(v4->pIOBuffer, 1u, Countb, v4->pFile);
+    fwrite(v4->pIOBuffer, 1u, Countb, pFile);
     v28 -= Countb;
   }
-  strcpy(NewFilename, (const char *)pLODName);
+  strcpy(NewFilename, (const char *)v4->pLODName);
   fclose(pFile);
-  CloseWriteFile();
+  v4->CloseWriteFile();
   remove(NewFilename);
   rename(pFilename, NewFilename);
-  CloseWriteFile();
-  LoadFile(pLODName, 0);
+  v4->CloseWriteFile();
+  v4->LoadFile(v4->pLODName, 0);
   return 0;
 }
 
--- a/Player.cpp	Mon Nov 26 09:35:10 2012 +0600
+++ b/Player.cpp	Mon Nov 26 09:35:24 2012 +0600
@@ -6624,117 +6624,65 @@
 
 //----- (0049048D) --------------------------------------------------------
 //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute)
-unsigned __int16 Player::DecreaseAttribute(int eAttribute)
+void Player::DecreaseAttribute(int eAttribute)
 {
   int v2; // eax@1
-  Player *v3; // edx@1
-  int v4; // ecx@1
-  int v5; // ebx@1
-  int v6; // esi@1
+  int pBaseValue; // ecx@1
+  int pDroppedStep; // ebx@1
+  int pStep; // esi@1
   unsigned __int16 result; // ax@7
-  int v8; // edi@8
-  int v9; // edi@12
-  int v10; // edi@16
-  int v11; // edi@20
-  int v12; // edi@24
-  int v13; // edi@28
-  int v14; // edi@32
   int uMinValue; // [sp+Ch] [bp-4h]@1
 
   v2 = eAttribute + 7 * GetRace();
-  v4 = stru_4ED7B0.race[0].attr[v2].uBaseValue;
-  v5 = stru_4ED7B0.race[0].attr[v2].uDroppedStep;
-  uMinValue = v4 - 2;
-  v6 = stru_4ED7B0.race[0].attr[v2].uBaseStep;
-  if ( eAttribute )
-  {
+  pBaseValue = stru_4ED7B0.race[0].attr[v2].uBaseValue;
+  pDroppedStep = stru_4ED7B0.race[0].attr[v2].uDroppedStep;
+  uMinValue = pBaseValue - 2;
+  pStep = stru_4ED7B0.race[0].attr[v2].uBaseStep;
     switch ( eAttribute )
     {
-      case 1:
-        result = v3->uIntelligence;
-        v13 = v3->uIntelligence;
-        if ( v13 <= v4 )
-          v6 = v5;
-        if ( v13 - v6 >= uMinValue )
-        {
-          result -= v6;
-          v3->uIntelligence = result;
-        }
+      case CHARACTER_MIGHT:
+        if ( this->uMight <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uMight - pStep >= uMinValue )
+         this->uMight -= pStep;
         break;
-      case 2:
-        result = v3->uWillpower;
-        v12 = v3->uWillpower;
-        if ( v12 <= v4 )
-          v6 = v5;
-        if ( v12 - v6 >= uMinValue )
-        {
-          result -= v6;
-          v3->uWillpower = result;
-        }
+	  case CHARACTER_INTELLIGANCE:
+        if ( this->uIntelligence <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uIntelligence - pStep >= uMinValue )
+          this->uIntelligence -= pStep;
         break;
-      case 3:
-        result = v3->uEndurance;
-        v11 = v3->uEndurance;
-        if ( v11 <= v4 )
-          v6 = v5;
-        if ( v11 - v6 >= uMinValue )
-        {
-          result -= v6;
-          v3->uEndurance = result;
-        }
+      case CHARACTER_WILLPOWER:
+        if ( this->uWillpower <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uWillpower - pStep >= uMinValue )
+          this->uWillpower -= pStep;
         break;
-      case 4:
-        result = v3->uAccuracy;
-        v10 = v3->uAccuracy;
-        if ( v10 <= v4 )
-          v6 = v5;
-        if ( v10 - v6 >= uMinValue )
-        {
-          result -= v6;
-          v3->uAccuracy = result;
-        }
+      case CHARACTER_ENDURANCE:
+        if ( this->uEndurance <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uEndurance - pStep >= uMinValue )
+          this->uEndurance -= pStep;
         break;
-      case 5:
-        result = v3->uSpeed;
-        v9 = v3->uSpeed;
-        if ( v9 <= v4 )
-          v6 = v5;
-        if ( v9 - v6 >= uMinValue )
-        {
-          result -= v6;
-          v3->uSpeed = result;
-        }
+      case CHARACTER_ACCURACY:
+        if ( this->uAccuracy <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uAccuracy - pStep >= uMinValue )
+          this->uAccuracy -= pStep;
         break;
-      default:
-        result = eAttribute - 6;
-        if ( eAttribute == 6 )
-        {
-          result = v3->uLuck;
-          v8 = v3->uLuck;
-          if ( v8 <= v4 )
-            v6 = v5;
-          if ( v8 - v6 >= uMinValue )
-          {
-            result -= v6;
-            v3->uLuck = result;
-          }
-        }
+      case CHARACTER_SPEED:
+        if ( this->uSpeed <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uSpeed - pStep >= uMinValue )
+          this->uSpeed -= pStep;
         break;
-    }
-  }
-  else
-  {
-    result = v3->uMight;
-    v14 = v3->uMight;
-    if ( v14 <= v4 )
-      v6 = v5;
-    if ( v14 - v6 >= uMinValue )
-    {
-      result -= v6;
-      v3->uMight = result;
-    }
-  }
-  return result;
+      case CHARACTER_LUCK:
+		if ( this->uLuck <= pBaseValue )
+          pStep = pDroppedStep;
+        if ( this->uLuck - pStep >= uMinValue )
+          this->uLuck -= pStep;
+        break;
+    }
 }
 
 //----- (004905F5) --------------------------------------------------------
--- a/Player.h	Mon Nov 26 09:35:10 2012 +0600
+++ b/Player.h	Mon Nov 26 09:35:24 2012 +0600
@@ -14,7 +14,16 @@
   CHARACTER_RACE_GOBLIN = 0x2,
   CHARACTER_RACE_DWARF = 0x3,
 };
-
+enum CHARACTER_ATTRIBUTE
+{
+  CHARACTER_MIGHT = 0x0,
+  CHARACTER_INTELLIGANCE = 0x1,
+  CHARACTER_WILLPOWER = 0x2,
+  CHARACTER_ENDURANCE = 0x3,
+  CHARACTER_ACCURACY = 0x4,
+  CHARACTER_SPEED = 0x5,
+  CHARACTER_LUCK = 0x6,
+};
 
 /*  332 */
 enum CHARACTER_ATTRIBUTE_TYPE
@@ -297,7 +306,7 @@
   int SetSexByVoice();
   void Reset(unsigned __int8 uClass);
   enum PLAYER_SKILL_TYPE GetSkillIdxByOrder(signed int order);
-  unsigned __int16 DecreaseAttribute(int eAttribute);
+  void DecreaseAttribute(int eAttribute);
   int IncreaseAttribute(int eAttribute);
   void Player::Zero();
   __int16 GetStatColor(unsigned int uStat);
--- a/Render.cpp	Mon Nov 26 09:35:10 2012 +0600
+++ b/Render.cpp	Mon Nov 26 09:35:24 2012 +0600
@@ -1838,28 +1838,28 @@
       v5 = abs(X);
       v6 = abs(v83);
       --X;
-      v93 =  &stru_76E5C8[(v5 << 7) + v6];
-	  if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
-                                                                      v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
-            ((a8 = v9,
-              pVertices = &pVerticesSR_801A10[1] + v7,
-              v11 = v8->vWorldPosition.x,
-              v101 = v10,
-              v12 = v11 + 6.755399441055744e15,
-              sX = LODWORD(v12),
-              v13 = v8->vWorldPosition.y + 6.755399441055744e15,
-              sY = LODWORD(v13),
-              thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
-              v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),
-              v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
-              v89 = v14,
-              thise = v15 * 0.5,
-              _this = (LightmapBuilder *)WorldPosToGridCellX(floorf(thise + 0.5f)),
-              WorldPosToGridCellX(sX),
-              WorldPosToGridCellZ(sY),
-              !byte_4D864C)
-          || !(pGame->uFlags & 0x80))
-         && !sub_481EFA(v8, v9, v101, pVertices, 1)) )
+      v93 = &stru_76E5C8[(v5 << 7) + v6];
+ 	  if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
+                                                                       v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
+             ((a8 = v9,
+               pVertices = &pVerticesSR_801A10[1] + v7,
+               v11 = v8->vWorldPosition.x,
+               v101 = v10,
+               v12 = v11 + 6.755399441055744e15,
+               sX = LODWORD(v12),
+               v13 = v8->vWorldPosition.y + 6.755399441055744e15,
+               sY = LODWORD(v13),
+               thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
+               v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(thisd + 6.755399441055744e15)),
+               v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
+               v89 = v14,
+               thise = v15 * 0.5,
+               _this = (LightmapBuilder *)WorldPosToGridCellZ(COERCE_UNSIGNED_INT64(thise + 6.755399441055744e15)),
+               WorldPosToGridCellX(sX),
+               WorldPosToGridCellZ(sY),
+               !byte_4D864C)
+           || !(pGame->uFlags & 0x80))
+          && !sub_481EFA(v8, v9, v101, pVertices, 1)) )
         goto LABEL_162;
       if ( v8->vWorldPosition.z != v9->vWorldPosition.z || v9->vWorldPosition.z != pVertices->vWorldPosition.z || pVertices->vWorldPosition.z != v101->vWorldPosition.z )
         break;
@@ -4640,7 +4640,7 @@
 
   memset(&v3, 0, sizeof(DDBLTFX));
   if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4)
+      pVersion->pVersionInfo.dwMajorVersion >= 5)
   {
     x.left = uWindowX;
     x.right = uWindowX + uWindowHeight;