changeset 1646:bac69d9157b6

Merge
author Nomad
date Tue, 17 Sep 2013 23:10:07 +0200
parents 07fe868f0b44 (diff) 7182930263b3 (current diff)
children b0a2b8525483 42055a4bd550
files mm7_3.cpp
diffstat 6 files changed, 99 insertions(+), 137 deletions(-) [+]
line wrap: on
line diff
--- a/Events2D.h	Tue Sep 17 19:24:23 2013 +0100
+++ b/Events2D.h	Tue Sep 17 23:10:07 2013 +0200
@@ -16,8 +16,8 @@
   BuildingType_BodyGuild = 11,
   BuildingType_LightGuild = 12,
   BuildingType_DarkGuild = 13,
-  BuildingType_14 = 14,
-  BuildingType_15 = 15,
+  BuildingType_ElementalGuild = 14,
+  BuildingType_SelfGuild = 15,
   BuildingType_16 = 16,
   BuildingType_TownHall = 17,
   BuildingType_18 = 18,
--- a/Outdoor_stuff.h	Tue Sep 17 19:24:23 2013 +0100
+++ b/Outdoor_stuff.h	Tue Sep 17 23:10:07 2013 +0200
@@ -36,8 +36,8 @@
   int field_34;
   struct stru149 *ptr_38;
   struct Texture *pTexture;
-  struct Span *prolly_head;
-  struct Span *prolly_tail;
+  struct Span *_unused_prolly_head;
+  struct Span *_unused_prolly_tail;
   int **ptr_48;
   unsigned __int16 uTileBitmapID;
   __int16 field_4E;
--- a/Render.cpp	Tue Sep 17 19:24:23 2013 +0100
+++ b/Render.cpp	Tue Sep 17 23:10:07 2013 +0200
@@ -5008,20 +5008,20 @@
 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID)
 {
   BLVFace *pFace; // esi@1
-  unsigned int v3; // edi@1
-  PolygonType v4; // al@1
+  //unsigned int v3; // edi@1
+  //PolygonType v4; // al@1
   double v5; // st7@3
   signed __int64 v6; // qax@3
-  PolygonType v7; // cl@3
-  int v8; // esi@7
-  int v9; // eax@7
-  unsigned int v10; // eax@7
-  double v11; // st6@7
+  //PolygonType v7; // cl@3
+  //int v8; // esi@7
+  //int v9; // eax@7
+  //unsigned int v10; // eax@7
+  //double v11; // st6@7
   int v12; // edx@7
   int v13; // eax@7
-  char *v14; // esi@8
+  //char *v14; // esi@8
   void *v15; // ecx@9
-  int v16; // eax@9
+  //int v16; // eax@9
   int v17; // edi@9
   double v18; // st7@9
   signed int v19; // ebx@9
@@ -5059,21 +5059,21 @@
   double v51; // st7@46
   RenderVertexSoft *v52; // edx@46
   void *v53; // edi@48
-  char *v54; // ebx@52
-  unsigned int v55; // eax@53
-  unsigned int v56; // eax@55
-  int v57; // ST10_4@55
-  Texture *v58; // eax@55
+  //char *v54; // ebx@52
+  //unsigned int v55; // eax@53
+  //unsigned int v56; // eax@55
+  //int v57; // ST10_4@55
+  //Texture *v58; // eax@55
   signed int v59; // [sp-4h] [bp-178h]@17
   struct Polygon *v60; // [sp+0h] [bp-174h]@17
   IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
   struct Polygon v62; // [sp+14h] [bp-160h]@6
   unsigned int v63; // [sp+120h] [bp-54h]@7
-  double v64; // [sp+124h] [bp-50h]@7
+  //double v64; // [sp+124h] [bp-50h]@7
   unsigned int v65; // [sp+128h] [bp-4Ch]@1
   unsigned int v66; // [sp+12Ch] [bp-48h]@7
   float v67; // [sp+130h] [bp-44h]@7
-  __int64 v68; // [sp+134h] [bp-40h]@3
+  //__int64 v68; // [sp+134h] [bp-40h]@3
   __int64 v69; // [sp+13Ch] [bp-38h]@3
   int v70; // [sp+144h] [bp-30h]@3
   int X; // [sp+148h] [bp-2Ch]@9
@@ -5088,41 +5088,20 @@
   float v80; // [sp+16Ch] [bp-8h]@3
   const void *v81; // [sp+170h] [bp-4h]@7
 
-  __debugbreak();
-
   pFace = &pIndoor->pFaces[uFaceID];
-  v65 = uFaceID;
-  v3 = uNumVertices;
-  v4 = pFace->uPolygonType;
-  if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
-  {
-    if ( (signed int)uNumVertices > 0 )
-    {
-      v54 = (char *)&array_507D30[0].u;
-      LODWORD(v80) = uNumVertices;
-      do
-      {
-        v69 = (GetTickCount() >> 5) - pGame->pIndoorCameraD3D->vPartyPos.x;
-        *(float *)v54 = (double)v69 + *(float *)v54;
-        *(float *)v54 = *(float *)v54 * 0.25;
-        v55 = GetTickCount();
-        v54 += 48;
-        v44 = LODWORD(v80)-- == 1;
-        v68 = pGame->pIndoorCameraD3D->vPartyPos.y + (v55 >> 5);
-        *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
-      }
-      while ( !v44 );
-      uFaceID = v65;
-    }
-    v56 = 8 * uFaceID;
-    LOBYTE(v56) = PID(OBJECT_BModel,uFaceID);
-    v57 = v56;
-    v58 = pFace->GetTexture();
-    pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
+  if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
+  {
+    int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
+    int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y;
+    for (uint i = 0; i < uNumVertices; ++i)
+    {
+      array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f;
+      array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f;
+    }
+    pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
     return;
   }
-  HIDWORD(v69) = pGame->pIndoorCameraD3D->sRotationX;
-  HIDWORD(v68) = pGame->pIndoorCameraD3D->vPartyPos.z;
+
   *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
   v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)
                        / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
@@ -5130,45 +5109,41 @@
                        + *(float *)&v74);
   v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;
   *(float *)&v75 = v5;
-  v80 = cos(v5) * 16192.0;
   v6 = (signed __int64)(*(float *)&v74
                       - (double)pBLVRenderParams->fov_rad_fixpoint
-                      / ((v80 + 0.0000001)
+                      / ((cos(v5) * 16192.0 + 0.0000001)
                        * 65535.0)
-                      * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
-  v7 = pFace->uPolygonType;
-  if ( v7 == 4 || v7 == 3 )
-    v70 = v6;
+                      * (sin(*(float *)&v75) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
+
+
   stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
   v62.Create_48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
-  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
+
+  v62.pTexture = pBitmaps_LOD->GetTexture(v62.uTileBitmapID);
   if ( !v62.pTexture )
     return;
-  v8 = pGame->pIndoorCameraD3D->sRotationX;
+
   v62.dimming_level = 0;
-  v62.uNumVertices = v3;
-  v9 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+  v62.uNumVertices = uNumVertices;
   v62.v_18.y = 0;
-  v62.v_18.x = -v9;
-  v62.v_18.z = -stru_5C6E00->Cos(v8 + 16);
-  v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
-  memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
-  LODWORD(v80) = v10;
-  v62.field_24 = 33554432;
-  v64 = (double)(signed int)v10 * 0.5;
-  v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
-  LODWORD(v80) = v62.pTexture->uTextureWidth;
-  v11 = 1.0 / (double)SLODWORD(v80);
-  LODWORD(v80) = v62.pTexture->uTextureHeight;
+  v62.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+  v62.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
+  memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
+  v62.field_24 = 0x2000000;
+
+  extern float _calc_fov(int viewport_width, int angle_degree);
+  //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5;
+  //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
+  v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74);
   v12 = v62.pTexture->uWidthMinus1;
   v13 = v62.pTexture->uHeightMinus1;
-  v67 = v11;
+  v67 = 1.0 / (double)v62.pTexture->uTextureWidth;
   v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
   v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
   v78 = 0;
   v81 = 0;
-  *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
+  float v68 = 1.0 / (double)v62.pTexture->uTextureHeight;
   if ( (signed int)v62.uNumVertices <= 0 )
   {
 LABEL_17:
@@ -5178,23 +5153,21 @@
     v59 = v62.uNumVertices;
     goto LABEL_18;
   }
-  v14 = (char *)&array_507D30[0].vWorldViewProjY;
+
+  //v14 = (char *)&array_507D30[0].vWorldViewProjY;
+  int _507D30_idx = 0;
   while ( 2 )
   {
-    v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
-    LODWORD(v80) = v62.ptr_38->field_14;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
-    v16 = v77 + v62.ptr_38->field_C;
+    v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
+    v77 = (unsigned __int64)(v62.ptr_38->field_14 * (signed __int64)(signed int)v15) >> 16;
+    v74 = v77 + v62.ptr_38->field_C;
     v77 = (int)v15;
-    v74 = v16;
-    LODWORD(v80) = v62.ptr_38->field_20;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
+    v77 = (unsigned __int64)(v62.ptr_38->field_20 * (signed __int64)(signed int)v15) >> 16;
     v79 = v15;
     v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
-    LODWORD(v80) = v62.v_18.z;
     v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
-    v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
-    v18 = *(float *)v14 - 1.0;
+    v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
+    v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
     v19 = -v62.field_24;
     v77 = -v62.field_24;
     X = (int)((char *)v79 + v62.v_18.x);
@@ -5213,7 +5186,6 @@
       v19 = v77;
       v20 = v79;
 LABEL_14:
-      LODWORD(v80) = v62.v_18.z;
       v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
       v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
       --LODWORD(v76);
@@ -5227,23 +5199,22 @@
       HIDWORD(v23) = v77 >> 16;
       v79 = (void *)(v23 / X);
       v77 = v17;
-      LODWORD(v80) = v62.ptr_38->field_10;
       v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
-      LODWORD(v80) = v62.ptr_38->field_1C;
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
+      LODWORD(v76) = v74 + ((unsigned __int64)(v62.ptr_38->field_10 * (signed __int64)v17) >> 16);
+      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v62.ptr_38->field_1C * (signed __int64)v17) >> 16));
       v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
       LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
-      v14 += 48;
+      //v14 += 48;
       LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
       v81 = (char *)v81 + 1;
       v24 = (double)SLODWORD(v80) * 0.000015259022;
       LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
       v26 = __OFSUB__((int)v81, v62.uNumVertices);
       v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
-      *((float *)v14 - 10) = v24 * v67;
-      *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
-      *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
+      array_507D30[_507D30_idx].u = v24 * v67;
+      array_507D30[_507D30_idx].v = (double)SLODWORD(v80) * 0.000015259022 * v68;
+      array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
+      _507D30_idx++;
       if ( !(v25 ^ v26) )
         goto LABEL_17;
       continue;
@@ -5369,7 +5340,7 @@
     v45 = (double)v78 * 0.000015259022;
     v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
     *((float *)v34 - 10) = v45 * v67;
-    *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
+    *((float *)v34 - 9) = (double)v78 * 0.000015259022 * v68;
     v46 = (double)(signed int)v79;
     *((float *)v34 - 16) = 0.000015258789 * v46;
     *((float *)v34 - 11) = 65536.0 / v46;
--- a/UI/UIHouses.cpp	Tue Sep 17 19:24:23 2013 +0100
+++ b/UI/UIHouses.cpp	Tue Sep 17 23:10:07 2013 +0200
@@ -459,7 +459,7 @@
     }
     break;
 
-    case BuildingType_14:
+    case BuildingType_ElementalGuild:
     {
       CreateButtonInColumn(0, 18);
       CreateButtonInColumn(1, 48);
@@ -470,7 +470,7 @@
     }
     break;
 
-    case BuildingType_15:
+    case BuildingType_SelfGuild:
     {
       CreateButtonInColumn(0, 18);
       CreateButtonInColumn(1, 52);
@@ -1087,8 +1087,8 @@
     case BuildingType_BodyGuild:
     case BuildingType_LightGuild:
     case BuildingType_DarkGuild:
-    case BuildingType_14:
-    case BuildingType_15:
+    case BuildingType_ElementalGuild:
+    case BuildingType_SelfGuild:
     case BuildingType_16:
     {
       if ( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed )
--- a/UI/UiGame.cpp	Tue Sep 17 19:24:23 2013 +0100
+++ b/UI/UiGame.cpp	Tue Sep 17 23:10:07 2013 +0200
@@ -501,71 +501,64 @@
     else if (pButton->msg_param == 24)
     {
       __debugbreak(); // learn conditions of this event
-      auto topic = pNPCTopics[pNPC->evt_F - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
+      if (!pNPC->evt_F)
+      {
+        pButton->pButtonName[0] = 0;
+        pButton->msg_param = 0;
+      }
+      else
+        strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_F].pTopic);
+    }
+    else if (pButton->msg_param == 9)
+      strcpy(pButton->pButtonName, GetProfessionActionText(pNPC->uProfession));
+    else if (pButton->msg_param == 19) // Scavenger Hunt
+    {
+      if (!pNPC->evt_A)
       {
         pButton->pButtonName[0] = 0;
         pButton->msg_param = 0;
       }
       else
-        strcpy(pButton->pButtonName, topic);
+        strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_A].pTopic);
     }
-    else if (pButton->msg_param == 9)
-      strcpy(pButton->pButtonName, GetProfessionActionText(pNPC->uProfession));
-    else if (pButton->msg_param == 19)
+    else if (pButton->msg_param == 20) // Scavenger Hunt
     {
-     // __debugbreak(); // learn conditions of this event Scavenger Hunt
-      auto topic = pNPCTopics[pNPC->evt_A - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
+      if (!pNPC->evt_B)
       {
         pButton->pButtonName[0] = 0;
         pButton->msg_param = 0;
       }
-      else strcpy(pButton->pButtonName, topic);
-    }
-    else if (pButton->msg_param == 20)
-    {
-      //__debugbreak(); // learn conditions of this event instruments
-      auto topic = pNPCTopics[pNPC->evt_B - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
-      {
-        pButton->pButtonName[0] = 0;
-        pButton->msg_param = 0;
-      }
-      else strcpy(pButton->pButtonName, topic);
+      else strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_B].pTopic);
     }
     else if (pButton->msg_param == 21)
     {
       //__debugbreak(); // learn conditions of this event
-      auto topic = pNPCTopics[pNPC->evt_C - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
+      if (!pNPC->evt_C)
       {
         pButton->pButtonName[0] = 0;
         pButton->msg_param = 0;
       }
-      else strcpy(pButton->pButtonName, topic);
+      else strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_C].pTopic);
     }
     else if (pButton->msg_param == 22)
     {
       //__debugbreak(); // learn conditions of this event
-      auto topic = pNPCTopics[pNPC->evt_D - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
+      if (!pNPC->evt_D)
       {
         pButton->pButtonName[0] = 0;
         pButton->msg_param = 0;
       }
-      else strcpy(pButton->pButtonName, topic);
+      else strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_D].pTopic);
     }
     else if (pButton->msg_param == 23)
     {
       //__debugbreak(); // learn conditions of this event
-      auto topic = pNPCTopics[pNPC->evt_E - 1].pTopic;//(&dword_721660)[8 * v23];
-      if (!topic)
+      if (!pNPC->evt_E)
       {
         pButton->pButtonName[0] = 0;
         pButton->msg_param = 0;
       }
-      else strcpy(pButton->pButtonName, topic);
+      else strcpy(pButton->pButtonName, pNPCTopics[pNPC->evt_E].pTopic);
     }
     else if (pButton->msg_param == 13)
     {
--- a/mm7_3.cpp	Tue Sep 17 19:24:23 2013 +0100
+++ b/mm7_3.cpp	Tue Sep 17 23:10:07 2013 +0200
@@ -5583,9 +5583,7 @@
   for (int i = 0; i < 20000; ++i)
   {
     array_77EC08[i].ptr_38 = &stru_8019C8;
-    
-    array_77EC08[i].prolly_head = nullptr;
-    array_77EC08[i].prolly_tail = nullptr;
+
     array_77EC08[i].ptr_48 = nullptr;
   }
 
@@ -6455,14 +6453,14 @@
 						p2DEvents[i].uType = BuildingType_DarkGuild;
 						break;
 						}
-					if ( !_strnicmp(test_string, "ele", 3) )
+					if ( !_strnicmp(test_string, "ele", 3) ) // "Element Guild" from mm6
 						{
-						p2DEvents[i].uType = BuildingType_14;
+						p2DEvents[i].uType = BuildingType_ElementalGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "sel", 3) )
 						{
-						p2DEvents[i].uType = BuildingType_15;
+						p2DEvents[i].uType = BuildingType_SelfGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "mir", 3) )
@@ -6470,7 +6468,7 @@
 						p2DEvents[i].uType = BuildingType_16;
 						break;
 						}
-					if ( !_strnicmp(test_string, "mer", 3) )
+					if ( !_strnicmp(test_string, "mer", 3) ) // "Merc Guild" from mm6
 						{
 						p2DEvents[i].uType = BuildingType_TownHall;
 						break;