changeset 124:eeb0a8222d59

Слияние
author Ritor1
date Mon, 11 Feb 2013 19:13:38 +0600
parents 4e35bb416dea (current diff) fe0e317c0de0 (diff)
children b5c3f448cd74
files Game.cpp
diffstat 8 files changed, 126 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/Game.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/Game.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -58,8 +58,10 @@
     uFlags2 |= 2u;
   pIndoorCamera->sRotationX = pParty->sRotationX;
   pIndoorCamera->sRotationY = pParty->sRotationY;
-  pIndoorCamera->pos.x = pParty->vPosition.x - pParty->field_18 * (stru_5C6E00->SinCos(pIndoorCamera->sRotationY) / 2048.0);//12552
-  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->field_18 * (stru_5C6E00->SinCos(pIndoorCamera->sRotationY) / 2048.0);//800
+  //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552
+  //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800
+  pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0);
+  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0);
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353
   pIndoorCamera->Initialize2();
   pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
--- a/Indoor.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/Indoor.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -373,9 +373,9 @@
   _this.uFlags = v0;
   _this.vPosition.x = pParty->vPosition.x
                    - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
-                                       * (signed __int64)pParty->field_18) >> 16);
+                                       * (signed __int64)pParty->y_rotation_granularity) >> 16);
   v2 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
-  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
+  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->y_rotation_granularity) >> 16;
   _this.field_1C_mb_fov = 65;
   _this.vPosition.y = pParty->vPosition.y - v3;
   _this.sRotationY = pParty->sRotationY;
--- a/Outdoor.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/Outdoor.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -60,10 +60,10 @@
   pIndoorCamera->sRotationY = pParty->sRotationY;
   pIndoorCamera->pos.x = pParty->vPosition.x
                       - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
-                                          * (signed __int64)pParty->field_18) >> 16);
+                                          * (signed __int64)pParty->y_rotation_granularity) >> 16);
   //v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
   pIndoorCamera->field_4C = v1;
-  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->field_18 * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16);
+  pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16);
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if ( v2 || pRenderer->pRenderD3D )
   {
@@ -276,7 +276,7 @@
     pIcons_LOD->ReleaseAll2();
     sub_46080D();
     TryLoadLevelFromLOD();
-    if ( !Load((char *)pFilename, (ODMFace *)File, uRespawnInterval, thisa) )
+    if ( !Load(pFilename, (ODMFace *)File, uRespawnInterval, thisa) )
     {
       MessageBoxA(0, "Error!", "Couldn't Load Map!", 0);
       CreateDebugLocation();
@@ -1192,7 +1192,7 @@
 }
 
 //----- (0047D0A6) --------------------------------------------------------
-bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa)// 
+bool OutdoorLocation::Load(const char *pFilename, ODMFace *File, size_t pNumItems, int thisa)// 
 {
   //OutdoorLocation *pOutdoorLocation; // esi@1
   /*bool result; // eax@9
@@ -1644,10 +1644,15 @@
   if (!pGames_LOD->DoesContainerExist(pFilename))
     Abortf("Unable to find %s in Games.LOD", pFilename);
 
+
+  char pMinimapTextureFilename[1024];
+  strcpy(pMinimapTextureFilename, pFilename);
+  pMinimapTextureFilename[strlen(pMinimapTextureFilename) - 4] = 0;
+  viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pMinimapTextureFilename, TEXTURE_16BIT_PALETTE);
+
   //strcpy(FileName, pContainer);
   strcpy(Str, pFilename);
   strcpy(Str + strlen(Str) - 4, ".odm");
-  viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE);
   //v141 = &v139;
   //v38 = strlen(pFilename);
   //strcpy((char *)&v139 + v38, ".odm");
--- a/Outdoor.h	Mon Feb 11 19:13:23 2013 +0600
+++ b/Outdoor.h	Mon Feb 11 19:13:38 2013 +0600
@@ -143,7 +143,7 @@
   unsigned int DrawActors();
   void CreateDebugLocation();
   void Release();
-  bool Load(char *pFilename, ODMFace *File, size_t a4, int thisa);
+  bool Load(const char *pFilename, ODMFace *File, size_t a4, int thisa);
   int _47ECC1(signed int a2);
   unsigned int DoGetTileTexture(unsigned int uX, unsigned int uZ);
   int _47ED83(signed int a2, signed int a3);
--- a/Party.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/Party.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -828,7 +828,7 @@
   this->field_28 = 0;
   this->uDefaultPartyHeight = 120;
   this->field_14 = 37;
-  this->field_18 = 25;
+  this->y_rotation_granularity = 25;
   this->uWalkSpeed = 384;
   this->field_20_prolly_turn_speed = 90;
   this->field_24 = 5;
--- a/Party.h	Mon Feb 11 19:13:23 2013 +0600
+++ b/Party.h	Mon Feb 11 19:13:38 2013 +0600
@@ -127,6 +127,8 @@
 
     field_6FC = 0;
     field_764 = 0;
+
+    y_rotation_granularity = 1;
   }
 
   void _4909F4();
@@ -164,7 +166,7 @@
   int sEyelevel;
   unsigned int uDefaultEyelevel;
   int field_14;
-  int field_18;
+  int y_rotation_granularity;
   unsigned int uWalkSpeed;
   int field_20_prolly_turn_speed;
   int field_24;
--- a/mm7_2.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/mm7_2.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -13758,7 +13758,7 @@
   }
   else
   {
-    uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64;
+    uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64; // adjust turn speed to estimated fps
   }
   return true;
 }
--- a/mm7_3.cpp	Mon Feb 11 19:13:23 2013 +0600
+++ b/mm7_3.cpp	Mon Feb 11 19:13:38 2013 +0600
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
@@ -8036,7 +8038,7 @@
   stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
   v62._48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
-  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
+  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
   if ( !v62.pTexture )
     return;
   v8 = pBLVRenderParams->sPartyRotX;
@@ -13559,13 +13561,13 @@
   double v20; // st7@30
   double v21; // st6@30
   double v22; // st5@33
-  unsigned __int16 *v26; // edx@37
+  //unsigned __int16 *v26; // edx@37
   signed int v27; // eax@37
   unsigned __int16 *v28; // ecx@37
   signed int v29; // edi@40
-  int v30; // eax@42
-  unsigned __int16 *v31; // ebx@43
-  signed int v32; // edi@46
+  //int v30; // eax@42
+  //unsigned __int16 *v31; // ebx@43
+  //signed int v32; // edi@46
   signed int v33; // ebx@50
   unsigned int v34; // eax@50
   signed int v35; // ecx@50
@@ -13583,7 +13585,7 @@
   int v47; // eax@108
   unsigned int v48; // ebx@114
   unsigned int v49; // ST64_4@114
-  double v50; // ST20_8@117
+  //double v50; // ST20_8@117
   unsigned int v51; // [sp-10h] [bp-64h]@79
   unsigned int v52; // [sp-10h] [bp-64h]@100
   unsigned int v53; // [sp-Ch] [bp-60h]@79
@@ -13595,9 +13597,9 @@
   unsigned __int16 v59; // [sp-4h] [bp-58h]@100
   unsigned __int16 v60; // [sp+10h] [bp-44h]@66
   unsigned int v61; // [sp+10h] [bp-44h]@85
-  unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
+  //unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
   unsigned int v63; // [sp+14h] [bp-40h]@85
-  int v64; // [sp+18h] [bp-3Ch]@39
+  //int v64; // [sp+18h] [bp-3Ch]@39
   unsigned int v65; // [sp+18h] [bp-3Ch]@85
   unsigned int lPitch; // [sp+20h] [bp-34h]@1
   unsigned int lPitcha; // [sp+20h] [bp-34h]@23
@@ -13607,28 +13609,28 @@
   unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
   signed int uBluea; // [sp+28h] [bp-2Ch]@37
   int v73; // [sp+2Ch] [bp-28h]@30
-  unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
+  //unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
   int v76; // [sp+34h] [bp-20h]@91
   int v77; // [sp+34h] [bp-20h]@108
-  signed int v78; // [sp+38h] [bp-1Ch]@37
+  //signed int v78; // [sp+38h] [bp-1Ch]@37
   int v79; // [sp+38h] [bp-1Ch]@72
-  signed int a2b; // [sp+40h] [bp-14h]@41
+  //signed int a2b; // [sp+40h] [bp-14h]@41
   char *a2c; // [sp+40h] [bp-14h]@68
-  int a3a; // [sp+44h] [bp-10h]@40
+  //int a3a; // [sp+44h] [bp-10h]@40
   signed int uCenterY; // [sp+48h] [bp-Ch]@1
   signed int uCenterX; // [sp+4Ch] [bp-8h]@1
   //signed int uZb; // [sp+5Ch] [bp+8h]@27
   signed int uWidth; // [sp+5Ch] [bp+8h]@30
-  signed int uZd; // [sp+5Ch] [bp+8h]@45
+  //signed int uZd; // [sp+5Ch] [bp+8h]@45
   signed int uZe; // [sp+5Ch] [bp+8h]@67
   signed int uZf; // [sp+5Ch] [bp+8h]@85
   signed int uZg; // [sp+5Ch] [bp+8h]@105
   unsigned int uWa; // [sp+60h] [bp+Ch]@23
   float uWb; // [sp+60h] [bp+Ch]@30
-  unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
+  //unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
   unsigned int uWd; // [sp+60h] [bp+Ch]@95
   float uZooma; // [sp+64h] [bp+10h]@117
-  signed int flagsa; // [sp+68h] [bp+14h]@42
+  //signed int flagsa; // [sp+68h] [bp+14h]@42
   unsigned int flagsb; // [sp+68h] [bp+14h]@66
   Actor *flagsc; // [sp+68h] [bp+14h]@86
   unsigned int flagsd; // [sp+68h] [bp+14h]@105
@@ -13654,102 +13656,114 @@
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
     v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
-    v74 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
-    v62 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
+    auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
+    auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
     v73 = (1 << (v17 + 16)) / (signed int)uZoom;
     v18 = (double)(1 << (16 - v17));
     v19 = v18;
     v20 = (double)(pParty->vPosition.x + 32768) / v18;
     v21 = (double)(32768 - pParty->vPosition.y) / v19;
     uWb = v21;
-    if ( uZoom == 512 )
-    {
-      v20 = v20 - (double)(uWidth / 2);
-      v22 = (double)(uHeight / 2);
-    }
-    else
-    {
-      if ( uZoom == 1024 )
+    switch (uZoom)
+    {
+      case 512:
+      {
+        v20 = v20 - (double)(uWidth / 2);
+        v22 = (double)(uHeight / 2);
+        uWb = v21 - v22;
+      }
+      break;
+
+      case 1024:
       {
         v20 = v20 - (double)(uWidth / 4);
         v22 = (double)(uHeight / 4);
-      }
-      else
-      {
-        if ( uZoom != 2048 )
-          goto LABEL_37;
+        uWb = v21 - v22;
+      }
+      break;
+
+      case 2048:
+      {
         v20 = v20 - (double)(uWidth / 8);
         v22 = (double)(uHeight / 8);
-      }
-    }
-    uWb = v21 - v22;
-LABEL_37:
+        uWb = v21 - v22;
+      }
+      break;
+
+      default: assert(false);
+    }
+//LABEL_37:
     //v23 = v20 * 65536.0;
     //v24 = v23 + 6.7553994e15;
     v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
     //uWe = uWb * 65536.0;
     //v25 = uWe + 6.7553994e15;
-    v78 = v70;
+    //v78 = v70;
     uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
-    v26 = (unsigned __int16 *)_56EFD8_minimap;
     v27 = uBluea >> 16;
-    uWc = (unsigned __int16 *)_56EFD8_minimap;
     v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
-    if ( flags )
-    {
-      if ( v74 )
-      {
-        v64 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        if ( uHeight > 0 )
-        {
-          a3a = uHeight;
+    if ( flags && pMapLod0)
+    {
+      auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
+      //if ( v74 )
+      //{
+        auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
+        //if ( uHeight > 0 )
+        //{
+          //a3a = uHeight;
           v29 = v70 >> 16;
-          do
-          {
-            a2b = 0;
-            if ( uWidth > 0 )
-            {
-              v30 = (int)&v74[v27 * v64];
-              flagsa = uWidth;
-              a2b = uWidth;
-              do
-              {
-                v31 = uWc;
-                ++uWc;
-                *v31 = v62[*(char *)(v30 + v29)];
-                v78 += v73;
-                v29 = v78 >> 16;
-                --flagsa;
-              }
-              while ( flagsa );
-            }
-            v78 = v70;
+          //do
+          for (int y = 0; y < uHeight; ++y)
+          {
+            //a2b = 0;
+            //if ( uWidth > 0 )
+            //{
+              auto pMapLod0Line = &pMapLod0[v27 * mapWidth];
+              //flagsa = uWidth;
+              //a2b = uWidth;
+              for (int x = 0; x < uWidth; ++x)
+              //do
+              {
+                //v31 = uWc;
+                //++uWc;
+                *pMinimap++ = pPal[pMapLod0Line[v29]];
+                //v78 += v73;
+                v29 = (v70 + x * v73) >> 16;
+                //--flagsa;
+              }
+              //while ( flagsa );
+            //}
+            //v78 = v70;
             v29 = v70 >> 16;
-            v28 += 137 - a2b;
+            v28 += 137 - uWidth;
             uBluea += v73;
             v27 = uBluea >> 16;
-            --a3a;
-          }
-          while ( a3a );
-        }
-      }
-    }
-    uZd = 117;
-    do
-    {
-      v32 = 137;
-      do
-      {
-        *v28 = *v26;
-        ++v28;
-        ++v26;
-        --v32;
-      }
-      while ( v32 );
+            //--a3a;
+          }
+          //while ( a3a );
+        //}
+      //}
+    }
+
+    auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
+    //uZd = 117;
+    //do
+    for (int y = 0; y < 117; ++y)
+    {
+      //v32 = 137;
+      //do
+      for (int x = 0; x < 137; ++x)
+      {
+        *v28++ = *pMinimap++;
+        //++v28;
+        //++v26;
+        //--v32;
+      }
+      //while ( v32 );
       v28 += lPitch - 137;
-      --uZd;
-    }
-    while ( uZd );
+      //--uZd;
+    }
+    //while ( uZd );
     uNumBlueFacesInBLVMinimap = 0;
   }
   else
@@ -13883,7 +13897,7 @@
   v35 = v57;
 LABEL_66:
   pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3,
-    (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
+    (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
   v36 = 255;
   flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
   v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
@@ -14051,9 +14065,9 @@
   }
   pRenderer->DrawTextureTransparent(0x1D4u, v33, (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
   uZooma = (double)pParty->sRotationY * 0.1171875;
-  v50 = uZooma + 6.7553994e15;
+  //v50 = uZooma + 6.7553994e15;
   pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
-  pRenderer->DrawTextureIndexed(LODWORD(v50) + 285, 0x88u, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
+  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 0x88u, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
   pRenderer->ResetClip();
 }