diff Game.cpp @ 223:1bd823f52e3a

Merge
author Gloval
date Sun, 17 Feb 2013 11:41:44 +0400
parents 650d96af8855
children bcd55744c2f4
line wrap: on
line diff
--- a/Game.cpp	Sun Feb 17 11:29:10 2013 +0400
+++ b/Game.cpp	Sun Feb 17 11:41:44 2013 +0400
@@ -16,12 +16,13 @@
 #include "GUIWindow.h"
 #include "Party.h"
 #include "TurnEngine.h"
-#include "stru157.h"
 #include "VideoPlayer.h"
 #include "Bink_Smacker.h"
 #include "Events.h"
 #include "Arcomage.h"
 #include "texts.h"
+#include "Actor.h"
+#include "Log.h"
 
 //#include "MM7.h"
 
@@ -583,69 +584,54 @@
 bool Game::_44EEA7()
 {
   //Game *v1; // esi@1
-  double v2; // st7@2
+  //double v2; // st7@2
   float depth; // ST00_4@9
-  bool result; // eax@9
+  //bool result; // eax@9
   unsigned int v5; // eax@14
   __int64 v6; // kr00_8@21
   unsigned int y; // [sp+4h] [bp-24h]@2
   unsigned int x; // [sp+8h] [bp-20h]@2
-  bool v9; // [sp+Ch] [bp-1Ch]@2
-  stru157 *v10; // [sp+10h] [bp-18h]@2
-  stru157 *v11; // [sp+14h] [bp-14h]@2
+  Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2
+  Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2
   POINT a2; // [sp+20h] [bp-8h]@1
 
   //v1 = this;
   ++qword_5C6DF0;
   pParticleEngine->UpdateParticles();
   pMouseInstance->GetCursorPos(&a2);
+
+  x = a2.y;
+  y = a2.x;
   if ( sub_4637E0_is_there_popup_onscreen() )
   {
-    v11 = &a5;
-    v10 = &stru_F93E30;
-    v9 = 0;
-    x = a2.y;
-    y = a2.x;
-    v2 = GetPickDepth();
+    v11 = &vis_face_filter;
+    v10 = &vis_sprite_filter_2;
+    depth = GetPickDepth();
   }
   else
   {
     if ( uFlags2 & 0x10 )
     {
-      v11 = &a5;
-      v10 = &stru_F93E1C;
+      v11 = &vis_face_filter;
+      v10 = &vis_sprite_filter_1;
     }
     else
     {
-      static bool __init_flag = false;
-      static stru157 static_sub_44EEA7_stru157;
-      if (!__init_flag)
-      {
-        __init_flag = true;
-        static_sub_44EEA7_stru157.field_8 = -1;
-        static_sub_44EEA7_stru157.field_0 = 0;
-        static_sub_44EEA7_stru157.field_4 = 2;
-        static_sub_44EEA7_stru157.field_C = 0;
-        static_sub_44EEA7_stru157.field_10 = 0;
-      }
-      v11 = &a5;
-      v10 = &static_sub_44EEA7_stru157;
+      v11 = &vis_face_filter;
+      v10 = &vis_sprite_filter_4;
     }
-    v2 = 5120.0;
-    v9 = 0;
-    x = a2.y;
-    y = a2.x;
+    depth = 5120.0;
   }
-  depth = v2;
+  //depth = v2;
 
-  PickMouse(depth, y, x, v9, v10, v11);
+  PickMouse(depth, y, x, true, v10, v11);
   pLightmapBuilder->std__vector_000004_size = 0;
   pLightmapBuilder->std__vector_183808_size = 0;
   pDecalBuilder->std__vector_pDecals_size = 0;
   pDecalBuilder->field_308008 = 0;
-  result = _44F07B();
-  if ( result )
-  {
+  if (!_44F07B())
+    return false;
+
     if ( uFlags & 8 )
       LOBYTE(pStru10Instance->field_4) = 0;
     if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor)
@@ -669,9 +655,7 @@
       uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
     }
     _44E904();
-    LOBYTE(result) = 1;
-  }
-  return result;
+    return true;
 }
 
 
@@ -1038,51 +1022,38 @@
 }
 
 //----- (0044EA5E) --------------------------------------------------------
-char Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, stru157 *a5, stru157 *a6)
+bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
-  char result; // al@3
-  std::string v10; // [sp-4h] [bp-24h]@5
-  float v11; // [sp+4h] [bp-1Ch]@10
-  float v12; // [sp+8h] [bp-18h]@10
-  const char *v13; // [sp+Ch] [bp-14h]@5
-  int v14; // [sp+10h] [bp-10h]@5
-  std::string *v15; // [sp+18h] [bp-8h]@5
-  int a3; // [sp+1Fh] [bp-1h]@5
+  if (pCurrentScreen || !pRenderer->pRenderD3D)
+    return false;
 
-  auto v7 = this;
-  if (!pCurrentScreen && pRenderer->pRenderD3D)
+  if (!pVisInstance)
   {
-    if (!pVisInstance)
-    {
-      MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0);
-      ExitProcess(0);
-    }
+    MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0);
+    return false;
+  }
 
-    if ( (signed int)uMouseX >= (signed int)pViewport->uScreenX
-      && (signed int)uMouseX <= (signed int)pViewport->uScreenZ
-      && (signed int)uMouseY >= (signed int)pViewport->uScreenY
-      && (signed int)uMouseY <= (signed int)pViewport->uScreenW )
-    {
-      v14 = (int)a6;
-      v12 = (double)(signed int)uMouseY;
-      v11 = (double)(signed int)uMouseX;
-      pVisInstance->PickMouse(fPickDepth, v11, v12, a5, a6);
+  if (uMouseX >= (signed int)pViewport->uScreenX &&
+      uMouseX <= (signed int)pViewport->uScreenZ &&
+      uMouseY >= (signed int)pViewport->uScreenY &&
+      uMouseY <= (signed int)pViewport->uScreenW)
+  {
+    pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter);
 
-      if (bOutline)
-        OutlineSelection();
-    }
-    return true;
+    if (bOutline)
+      OutlineSelection();
   }
-  return false;
+
+  return true;
 }
 // 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0044EB12) --------------------------------------------------------
-bool Game::_44EB12(bool bOutline, stru157 *a3, stru157 *a4)
+bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
   if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D )
   {
-    bool r = pVisInstance->PickKeyboard(&pVisInstance->stru1, a3, a4);
+    bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter);
 
     if (bOutline)
       OutlineSelection();
@@ -1107,58 +1078,47 @@
 //----- (0044EB5A) --------------------------------------------------------
 void Game::OutlineSelection()
 {
-  Vis *v1; // eax@1
-  Vis_stru1_stru0 *v2; // eax@3
-  void *v3; // edx@9
-  int v4; // eax@10
-  int v5; // eax@11
-  int v6; // eax@14
-  int v7; // eax@15
-  const char *v9; // [sp-8h] [bp-14h]@8
-  int v10; // [sp-4h] [bp-10h]@8
-  char v11; // [sp+0h] [bp-Ch]@18
-  int a3; // [sp+Ah] [bp-2h]@8
+  if (!pVisInstance)
+    return;
+
+  if (!pVisInstance->default_list.uNumPointers)
+    return;
 
-  v1 = this->pVisInstance;
-  if ( v1 )
-  {
-    v2 = (Vis_stru1_stru0 *)((signed int)v1->stru1.uNumPointers <= 0 ? 0 : v1->stru1.array_1804[0]);
-    if ( v2 )
+  auto object_info = pVisInstance->default_list.object_pointers[0];
+  if (object_info)
+    switch (object_info->object_type)
     {
-      if ( v2->uObjectType == 1 )
+      case VisObjectType_Sprite:
       {
-        MessageBoxW(nullptr, L"Sprite outline currently Unsupported", nullptr, 0);
-        ExitProcess(0);
+        Log::Warning(L"Sprite outline currently unsupported");
+        return;
       }
 
-        if ( v2->uObjectType == 2 )
+      case VisObjectType_Face:
+      {
+        if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         {
-          v3 = v2->pObjectInfo;                 // TODO  2 objects for indoor/outdoor
-                                                // some clues in header for Vis_stru1_stru0
-          if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-          {
-            v4 = *((int *)v3 + 11);
-            if ( v4 & 0x10000 )
-              v5 = v4 & 0xFFFEFFFF;
-            else
-              v5 = v4 | 0x10000;
-            *((int *)v3 + 11) = v5;
-          }
+          auto face = (ODMFace *)object_info->object;
+          if (face->uAttributes & FACE_OUTLINED)
+            face->uAttributes &= ~FACE_OUTLINED;
           else
-          {
-            v6 = *((int *)v3 + 7);
-            if ( v6 & 0x10000 )
-              v7 = v6 & 0xFFFEFFFF;
-            else
-              v7 = v6 | 0x10000;
-            *((int *)v3 + 7) = v7;
-          }
+            face->uAttributes |= FACE_OUTLINED;
+        }
+        else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        {
+          auto face = (BLVFace *)object_info->object;
+          if (face->uAttributes & FACE_OUTLINED)
+            face->uAttributes &= ~FACE_OUTLINED;
+          else
+            face->uAttributes |= FACE_OUTLINED;
         }
-        else
-        {
-          MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0);
-          ExitProcess(0);
-        }
+        else assert(false);
+      }
+
+      default:
+      {
+        MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0);
+        ExitProcess(0);
+      }
     }
-  }
 }
\ No newline at end of file