diff mm7_3.cpp @ 259:92a551e4dbeb

Слияние
author Ritor1
date Mon, 18 Feb 2013 09:44:59 +0600
parents 6764ce3cb9bb e9fabaf75628
children c3bfe1eb3de7
line wrap: on
line diff
--- a/mm7_3.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_3.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -41,6 +41,7 @@
 #include "stru176.h"
 #include "stru159.h"
 #include "stru298.h"
+#include "texts.h"
 #include "Log.h"
 
 #include "mm7_data.h"
@@ -2676,7 +2677,7 @@
         if ( !uActiveCharacter )
           goto LABEL_87;
         v65 = 0;
-        v63 = 63;
+        v63 = SPEECH_63;
         goto LABEL_76;
       case PARTY_LookDown:
         __debugbreak();
@@ -2687,9 +2688,9 @@
         if ( uActiveCharacter )
         {
           v65 = 0;
-          v63 = 64;
+          v63 = SPEECH_64;
 LABEL_76:
-          pPlayers[v35]->PlaySound(v63, v65);
+          pPlayers[v35]->PlaySound((PlayerSpeech)v63, v65);
         }
         break;
       case PARTY_CenterView:
@@ -3507,7 +3508,7 @@
         if ( _angle_x > 128 )
           _angle_x = 128;
         if (uActiveCharacter)
-          pPlayers[uActiveCharacter]->PlaySound(63, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_63, 0);
       break;
 
       case PARTY_LookDown:
@@ -3515,7 +3516,7 @@
         if ( _angle_x < -128 )
           _angle_x = -128;
         if (uActiveCharacter)
-          pPlayers[uActiveCharacter]->PlaySound(64, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_64, 0);
       break;
 
       case PARTY_Jump:
@@ -3623,7 +3624,7 @@
       {
         auto player = pParty->pPlayers + i;
         if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) && player->CanAct())
-          player->PlaySound(66, 0);
+          player->PlaySound(SPEECH_66, 0);
       }
     }
   }
@@ -4747,432 +4748,364 @@
 // 6BE3C5: using guessed type char bNoNPCHiring;
 
 //----- (004763E0) --------------------------------------------------------
-void __cdecl InitializeAwards()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  char v2; // dl@5
-  char *v3; // ecx@5
-  int v4; // esi@9
-  signed int v5; // [sp+Ch] [bp-Ch]@4
-  char *v6; // [sp+10h] [bp-8h]@4
-  Award *v7; // [sp+14h] [bp-4h]@3
-
-  v0 = 0;
+void  InitializeAwards()
+{
+  
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pAwardsTXT_Raw )
     pAllocator->FreeChunk(pAwardsTXT_Raw);
-  pAwardsTXT_Raw = 0;
+  pAwardsTXT_Raw = NULL;
   pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
   strtok(pAwardsTXT_Raw, "\r");
-  v7 = pAwards;
-  for (uint i = 0; i < 104; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v6 = v0;
-    v5 = (signed int)v0;
-    do
-    {
-      v2 = *v1;
-      v3 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v2 )
-            break;
-          ++v3;
-          v2 = v1[(int)v3];
-        }
-        while ( v2 != 9 );
-      }
-      v4 = (int)&v1[(int)v3];
-      if ( v1[(int)v3] == (char)v0 )
-        v5 = 1;
-      *(char *)v4 = (char)v0;
-      if ( v3 == v0 )
-      {
-        v5 = 1;
-      }
-      else
-      {
-        if ( v6 == (char *)1 )
-        {
-          v7->pText = RemoveQuotes(v1);
-        }
-        else
-        {
-          if ( v6 == (char *)2 )
-            v7->uSort = atoi(v1);
-        }
-      }
-      ++v6;
-      v1 = (char *)(v4 + 1);
-    }
-    while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 );
-    ++v7;
-  }
-  //while ( (signed int)v7 < (signed int)&dword_7241C8 );
+
+  for (i=1; i<104; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			   if (decode_step==1)
+				  pAwards[i].pText=RemoveQuotes(test_string);
+			   else if (decode_step==2)
+				  pAwards[i].uSort=atoi(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<3)&&!break_loop);
+	  }
+
 }
 // 7241C8: using guessed type int dword_7241C8;
 
 //----- (004764C2) --------------------------------------------------------
-void __cdecl InitializeScrolls()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  const char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+void  InitializeScrolls()
+{
+  
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pScrollsTXT_Raw )
     pAllocator->FreeChunk(pScrollsTXT_Raw);
-  pScrollsTXT_Raw = 0;
+  pScrollsTXT_Raw = NULL;
   pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
   strtok(pScrollsTXT_Raw, "\r");
-  v6 = pScrolls;
-  for (uint i = 0; i < 82; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          *v6 = RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    ++v6;
-  }
-  //while ( (signed int)v6 < (signed int)dword_723E80_award_related );
+  for (i=0; i<82; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pScrolls[i]=RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 
 //----- (00476590) --------------------------------------------------------
-void __cdecl InitializeMerchants()
-{
-  char *v0; // ebx@1
-  //char **v1; // edi@3
-  char *v2; // ecx@4
-  char v3; // dl@5
-  char *v4; // eax@5
-  int v5; // esi@9
-  signed int v6; // [sp+Ch] [bp-8h]@4
-  char *v7; // [sp+10h] [bp-4h]@4
-
-  v0 = 0;
+void  InitializeMerchants()
+{
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pMerchantsTXT_Raw )
     pAllocator->FreeChunk(pMerchantsTXT_Raw);
-  pMerchantsTXT_Raw = 0;
+  pMerchantsTXT_Raw = NULL;
   pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
   strtok(pMerchantsTXT_Raw, "\r");
-  //v1 = (char **)pMerchantsRepairPhrases;
-  for (uint i = 0; i < 7; ++i)
-  {
-    v7 = v0;
-    v6 = (signed int)v0;
-    v2 = strtok(v0, "\r") + 1;
-    do
-    {
-      v3 = *v2;
-      v4 = 0;
-      if ( *v2 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v2[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v2[(int)v4];
-      if ( v2[(int)v4] == (char)v0 )
-        v6 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v6 = 1;
-      }
-      else
-      {
-        if ( v7 == (char *)1 )
-        {
-          pMerchantsBuyPhrases[i] = RemoveQuotes(v2);
-        }
-        else
-        {
-          if ( v7 == (char *)2 )
-          {
-            pMerchantsSellPhrases[i] = RemoveQuotes(v2);
-          }
-          else
-          {
-            if ( v7 == (char *)3 )
-            {
-              pMerchantsRepairPhrases[i] = RemoveQuotes(v2);
-            }
-            else
-            {
-              if ( v7 - 3 == (char *)1 )
-                pMerchantsIdentifyPhrases[i] = RemoveQuotes(v2);
-            }
-          }
-        }
-      }
-      ++v7;
-      v2 = (char *)(v5 + 1);
-    }
-    while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 );
-    //++v1;
-  }
-  //while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases );
+
+  for (i=0; i<7; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+				switch (decode_step)
+					{
+					case 1:
+						pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
+						break;
+					case 2:
+						pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
+						break;
+					case 3:
+						pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); 
+						break;
+					case 4:
+						pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); 
+						break;
+					}
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<5)&&!break_loop);
+	  }
+
 }
 
 //----- (00476682) --------------------------------------------------------
-void __cdecl InitializeTransitions()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+void InitializeTransitions()
+{
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pTransitionsTXT_Raw )
     pAllocator->FreeChunk(pTransitionsTXT_Raw);
-  pTransitionsTXT_Raw = 0;
+  pTransitionsTXT_Raw = NULL;
   pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
   strtok(pTransitionsTXT_Raw, "\r");
-  v6 = pTransitionStrings;
-  for (uint i = 0; i < 464; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          *v6 = (char *)RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    ++v6;
-  }
-  //while ( (signed int)v6 < (signed int)"awards.txt" );
+
+  for (i=0; i<464; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pTransitionStrings[i]=RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 //----- (00476750) --------------------------------------------------------
 void __cdecl InitializeAutonotes()
 {
-  Autonote *v0; // ebp@3
-  int v1; // ebx@4
-  char *v2; // esi@4
-  char v3; // cl@5
-  int v4; // eax@5
-  char *v5; // edi@9
-  signed int v6; // [sp+0h] [bp-4h]@4
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
 
   if ( pAutonoteTXT_Raw )
     pAllocator->FreeChunk(pAutonoteTXT_Raw);
   pAutonoteTXT_Raw = 0;
   pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
   strtok(pAutonoteTXT_Raw, "\r");
-  v0 = pAutonoteTxt;
-  for (uint i = 0; i < 195; ++i)
-  {
-    v1 = 0;
-    v2 = strtok(0, "\r") + 1;
-    v6 = 0;
-    do
-    {
-      v3 = *v2;
-      v4 = 0;
-      while ( v3 != 9 && v3 )
-      {
-        ++v4;
-        v3 = v2[v4];
-      }
-      v5 = &v2[v4];
-      if ( !v2[v4] )
-        v6 = 1;
-      *v5 = 0;
-      if ( v4 )
-      {
-        if ( v1 == 1 )
-        {
-			v0->pText = RemoveQuotes(v2);
-        }
-        else
-        {
-          if ( v1 == 2 )
-          {
-            if ( _strcmpi(v2, "potion") )
-            {
-              if ( _strcmpi(v2, "stat") )
-              {
-                if ( _strcmpi(v2, "seer") )
-                {
-                  if ( _strcmpi(v2, "obelisk") )
-					  v0->eType = (AUTONOTE_TYPE)(5 - (_strcmpi(v2, "teacher") != 0));
-                  else
-					  v0->eType = (AUTONOTE_TYPE)2;
-                }
-                else
-                {
-                  v0->eType = (AUTONOTE_TYPE)3;
-                }
-              }
-              else
-              {
-                v0->eType = (AUTONOTE_TYPE)1;
-              }
-            }
-            else
-            {
-              v0->eType = (AUTONOTE_TYPE)0;
-            }
-          }
-        }
-      }
-      else
-      {
-        v6 = 1;
-      }
-      ++v1;
-      v2 = v5 + 1;
-    }
-    while ( v1 - 1 <= 2 && !v6 );
-    ++v0;
-  }
-  //while ( (signed int)v0 < (signed int)&pScrolls[1] );
+
+  for (i=0; i<195; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  switch (decode_step)
+				  {
+			  case  1:
+				  pAutonoteTxt[i].pText=RemoveQuotes(test_string);
+				  break;
+			  case  2:
+				  {
+				  if ( !_strcmpi(test_string, "potion"))
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "stat") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "seer") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_SEER;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "obelisk") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "teacher") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
+					  break;
+					  }
+				  pAutonoteTxt[i].eType =AUTONOTE_MISC;
+				  break;
+				  }
+				  }
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<3)&&!break_loop);
+	  }
 }
 
 
 //----- (004768A9) --------------------------------------------------------
 void __cdecl InitializeQuests()
 {
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  //const char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+   int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pQuestsTXT_Raw )
     pAllocator->FreeChunk(pQuestsTXT_Raw);
-  pQuestsTXT_Raw = 0;
+  pQuestsTXT_Raw = NULL;
   pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
   strtok(pQuestsTXT_Raw, "\r");
 
-  //v6 = pQuestTable;
-  for (uint i = 0; i < 512; ++i)
-  //do
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != '\t' )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != '\t' );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          pQuestTable[i] = RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    //++v6;
-  }
-  //while ( (signed int)v6 < (signed int)&unk_723714 );
+  for (i=0; i<512; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pQuestTable[i] =RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 
@@ -5180,214 +5113,150 @@
 //----- (00476977) --------------------------------------------------------
 void NPCStats::Initialize2()
 {
-  char *v4; // eax@4
-  char v5; // dl@5
-  char *v6; // ecx@5
-  int v7; // edi@9
-  char *v9; // eax@21
-  char v10; // dl@22
-  char *v11; // ecx@22
-  int v12; // edi@26
-  char *v14; // eax@39
-  char v15; // dl@40
-  int v16; // ecx@40
-  int v17; // edi@44
-  char v18; // zf@47
-  NPCStats_stru0 *v19; // eax@57
-  signed int v20; // edx@57
-  signed int v21; // ecx@58
-  char *v22; // [sp+10h] [bp-10h]@4
-  char *v23; // [sp+10h] [bp-10h]@21
-  char *v25; // [sp+14h] [bp-Ch]@4
-  char *v26; // [sp+14h] [bp-Ch]@21
-  signed int v27; // [sp+14h] [bp-Ch]@39
-  //signed int v28; // [sp+18h] [bp-8h]@3
-  //signed int v29; // [sp+18h] [bp-8h]@20
-  signed int v30; // [sp+18h] [bp-8h]@37
-  char *v31; // [sp+1Ch] [bp-4h]@37
-
-  //v1 = this;
-  //v2 = 0;
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
+
   if (pNPCTextTXT_Raw)
     pAllocator->FreeChunk(pNPCTextTXT_Raw);
-
-  //v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
+  pNPCTextTXT_Raw =NULL;
   pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
   strtok(pNPCTextTXT_Raw, "\r");
 
-  for (uint i = 0; i < 789; ++i)
-  {
-    v4 = strtok(nullptr, "\r") + 1;
-    v22 = nullptr;
-    v25 = nullptr;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      if ( *v4 != 9 )
-      {
-        do
-        {
-          if ( !v5 )
-            break;
-          ++v6;
-          v5 = v4[(int)v6];
-        }
-        while ( v5 != 9 );
-        //v2 = 0;
-      }
-      v7 = (int)&v4[(int)v6];
-      if ( !v4[(int)v6] )
-        v25 = (char *)1;
-      *(char *)v7 = 0;
-      if ( v6 == nullptr )
-      {
-        v25 = (char *)1;
-      }
-      else
-      {
-        if ( v22 == (char *)1 )
-          pNPCTopics[i].pText = RemoveQuotes(v4);
-      }
-      ++v22;
-      v4 = (char *)(v7 + 1);
-    }
-    while ( (signed int)(v22 - 1) <= 1 && v25 == nullptr );
-  }
+  for (i=0; i<789; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pNPCTopics[i].pText =RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 
   if (pNPCTopicTXT_Raw)
     pAllocator->FreeChunk(pNPCTopicTXT_Raw);
-
-  //v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2);
+  pNPCTopicTXT_Raw =NULL;
   pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
   strtok(pNPCTopicTXT_Raw, "\r");
 
-  for (uint i = 0; i < 579; ++i)
-  {
-    v9 = strtok(nullptr, "\r") + 1;
-    v23 = nullptr;
-    v26 = nullptr;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      if ( *v9 != 9 )
-      {
-        do
-        {
-          if ( !v10 )
-            break;
-          ++v11;
-          v10 = v9[(int)v11];
-        }
-        while ( v10 != 9 );
-        //v2 = 0;
-      }
-      v12 = (int)&v9[(int)v11];
-      if ( !v9[(int)v11] )
-        v26 = (char *)1;
-      *(char *)v12 = 0;
-      if ( v11 == nullptr )
-      {
-        v26 = (char *)1;
-      }
-      else
-      {
-        if ( v23 == (char *)1 )
-          pNPCTopics[i].pTopic = RemoveQuotes(v9);
-      }
-      ++v23;
-      v9 = (char *)(v12 + 1);
-    }
-    while ( (signed int)(v23 - 1) <= 1 && v26 == nullptr );
-  }
+   for (i=0; i<579; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 
   if (pNPCDistTXT_Raw)
     pAllocator->FreeChunk(pNPCDistTXT_Raw);
-
-  //v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2);
+  pNPCDistTXT_Raw = NULL;
   pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
   strtok(pNPCDistTXT_Raw, "\r");
-  strtok(nullptr, "\r");
-  v30 = 1;
-  v31 = &array_16544[0].field_4[1];
-
-  char *v2 = 0;
-  while ( 2 )
-  {
-    v14 = strtok(nullptr, "\r") + 1;
-    v27 = 0;
-    char *v24 = nullptr;
-    do
-    {
-      v15 = *v14;
-      v16 = 0;
-      if ( *v14 != 9 )
-      {
-        do
-        {
-          if ( !v15 )
-            break;
-          ++v16;
-          v15 = v14[v16];
-        }
-        while ( v15 != 9 );
-        v2 = v24;
-      }
-      v17 = (int)&v14[v16];
-      if ( !v14[v16] )
-        v27 = 1;
-      *(char *)v17 = 0;
-      if ( !v16 )
-      {
-        v27 = 1;
-        goto LABEL_54;
-      }
-      v18 = v2 == 0;
-      if ( (signed int)v2 > 0 )
-      {
-        if ( (signed int)v2 < 77 )
-        {
-          array_16544[(int)v2].field_4[v30] = atoi(v14);
-          goto LABEL_54;
-        }
-        v18 = v2 == 0;
-      }
-      if ( v18 )
-        *v31 = 10;
-LABEL_54:
-      ++v2;
-      v14 = (char *)(v17 + 1);
-      v24 = v2;
-    }
-    while ( (signed int)(v2 - 1) <= 77 && !v27 );
-    ++v30;
-    ++v31;
-    if ( v30 < 59 )
-    {
-      v2 = 0;
-      continue;
-    }
-    break;
-  }
-  v19 = array_16544;
-  v20 = 77;
-  do
-  {
-    v19->field_0 = 0;
-    v21 = 1;
-    do
-      v19->field_0 += v19->field_4[v21++];
-    while ( v21 < 59 );
-    ++v19;
-    --v20;
-  }
-  while ( v20 );
+  strtok(NULL, "\r");
+
+   for (i=1; i<59; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			   if ((decode_step>0)&&(decode_step<77))
+				   {
+				   array_16544[decode_step].field_4[i]=atoi(test_string);
+				   }
+			   else if (decode_step==0)
+				   {
+				  array_16544[0].field_4[i]=10;
+				   }
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<78)&&!break_loop);
+	  }
+
+  for (i=0; i<78; ++i)
+	  {
+	  array_16544[i].field_0=0;
+	  for (int ii=1; ii<59; ++ii)
+		  {
+		  array_16544[i].field_0+=array_16544[i].field_4[ii];
+		  }
+	  }
 
   if (pNPCDistTXT_Raw)
   {
     pAllocator->FreeChunk(pNPCDistTXT_Raw);
-    pNPCDistTXT_Raw = nullptr;
+    pNPCDistTXT_Raw = NULL;
   }
 }
 
@@ -9664,7 +9533,7 @@
   for (uint i = 0; i < 16384; ++i)
   //do
   {
-    auto v4 = stru_76E5C8 + i;
+    auto v4 = stru_76E5C8[i];
     //band3a = 256;
     //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8);
     for (uint j = 0; j < 128; ++j)                  // band3a: 0 -> 128
@@ -9676,17 +9545,17 @@
       if (v7 >= v10)
       {
         if (v7 >= v9)
-          v4->field_0 = ((v7 >= v3) - 1) & 2;
+          v4.field_0 = ((v7 >= v3) - 1) & 2;
         else
-          v4->field_0 = 2;
-      }
-      else
-      {
-        v4->field_0 = 1;
+          v4.field_0 = 2;
+      }
+      else
+      {
+        v4.field_0 = 1;
       }
       //band3a += 512;
-      v4->distance = v7;
-      ++v4;
+      v4.distance = v7;
+      //++v4;
     }
     //while ( band3a < 65792 );
   }
@@ -9699,6 +9568,8 @@
 //----- (004811A3) --------------------------------------------------------
 void stru148::_4811A3()
 {
+  __debugbreak();
+
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
   pRenderer->DrawTerrainPolygon(uNumVertices, this,
     pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]],
@@ -13433,10 +13304,14 @@
               v15->uScreenSpaceX = a5;
               v15->uScreenSpaceY = a6;
               v23 = 8 * v26;
-              LOBYTE(v23) = 8 * v26 | 5;
+              LOBYTE(v23) = 8 * v26 | OBJECT_Decoration;
               LOWORD(v22) = 0;
+
+              //v15->sZValue = v22 + v23;
+              v15->actual_z = HIWORD(x);
+              v15->object_pid = 8 * v26 | OBJECT_Decoration;
+
               v15->uTintColor = 0;
-              v15->sZValue = v22 + v23;
               v15->pSpriteFrame = v12;
             }
           }
@@ -13607,7 +13482,7 @@
               v3->uScreenSpaceY = v22;
               LOWORD(v21) = 0;
               v23 = 8 * i;
-              LOBYTE(v23) = 8 * i | 2;
+              LOBYTE(v23) = 8 * i | OBJECT_Item;
               v3->pSpriteFrame = v24;
               v12 = (p->uAttributes & 0x20) == 0;
               v3->sZValue = v21 + v23;
@@ -14512,7 +14387,7 @@
 {
   int v5; // ebx@1
   int v6; // edi@1
-  unsigned int *v7; // eax@8
+  BLVMapOutlines *v7; // eax@8
   unsigned __int8 v8; // zf@8
   unsigned __int8 v9; // sf@8
   int v10; // esi@10
@@ -14528,7 +14403,7 @@
   int v20; // eax@16
   signed int v21; // esi@18
   int v22; // ecx@21
-  int v23; // ecx@21
+  BLVMapOutline *v23; // ecx@21
   Vec3_short_ *v24; // edx@21
   Vec3_short_ *v25; // eax@21
   int v26; // ecx@21
@@ -14537,7 +14412,7 @@
   int v29; // eax@21
   double v30; // st7@23
   signed __int64 v31; // qax@23
-  char *v32; // edx@23
+  unsigned short *v32; // edx@23
   int v33; // esi@23
   signed int v34; // eax@23
   signed int v35; // ecx@23
@@ -14545,12 +14420,12 @@
   int v37; // ecx@27
   int v38; // edx@31
   unsigned int v39; // eax@33
-  const void *v40; // esi@33
-  unsigned __int16 *v41; // edi@33
+  short *v40; // esi@33
+  short *v41; // edi@33
   unsigned __int8 v42; // cf@33
   unsigned int v43; // ecx@33
-  int v44; // edi@33
-  int v45; // esi@33
+  short *v44; // edi@33
+  short *v45; // esi@33
   int v46; // ecx@33
   signed int v47; // esi@38
   signed int v48; // ecx@38
@@ -14571,7 +14446,7 @@
   signed int v63; // esi@85
   int v64; // eax@87
   unsigned int v65; // ebx@95
-  char *v66; // edx@95
+  unsigned short *v66; // edx@95
   unsigned __int16 *v67; // esi@96
   int v68; // edi@98
   unsigned __int16 v69; // cx@99
@@ -14580,7 +14455,7 @@
   unsigned int v72; // [sp-8h] [bp-4806Ch]@80
   signed int v73; // [sp-4h] [bp-48068h]@59
   unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-  char v75; // [sp+Ch] [bp-48058h]@23
+  unsigned short v75[131070]; // [sp+Ch] [bp-48058h]@23
   int v76; // [sp+4800Ch] [bp-58h]@23
   unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
   unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23
@@ -14599,11 +14474,11 @@
   unsigned int i; // [sp+48048h] [bp-1Ch]@9
   unsigned int v92; // [sp+4804Ch] [bp-18h]@16
   unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
-  unsigned int v94; // [sp+48054h] [bp-10h]@8
+  signed int v94; // [sp+48054h] [bp-10h]@8
   unsigned int v95; // [sp+48058h] [bp-Ch]@16
   int v96; // [sp+4805Ch] [bp-8h]@10
   const void *v97; // [sp+48060h] [bp-4h]@16
-  char *a4a; // [sp+4806Ch] [bp+8h]@85
+  unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
   int a5a; // [sp+48070h] [bp+Ch]@86
 
   x_ = x;
@@ -14620,13 +14495,20 @@
   {
     if ( viewparams->field_2C == 768 )
     {
-      if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
-        goto LABEL_23;
-      v5 = 680;
-    }
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      goto LABEL_8;
-LABEL_23:
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+		v5 = 680;
+    }
+  }
+  else
+  {
+	  v6 = viewparams->field_38;
+	  v86 = viewparams->field_38;
+	  v84 = viewparams->field_3A;
+	  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+	    v5 = viewparams->field_2C - 34;
+  }
+  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+  {
     v94 = a4 - x_ + 1;
     v92 = a5 - y_ + 1;
     v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
@@ -14639,7 +14521,7 @@
     v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
     v96 = 32768 - black - v84;
     v31 = (signed __int64)((double)v96 / v30);
-    v32 = &v75;
+    v32 = v75;
     v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
     v34 = (int)v31 << 16;
     v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
@@ -14661,8 +14543,8 @@
           v77 = (unsigned __int16 *)v36;
           do
           {
-            *(short *)v32 = v78[*((char *)v77 + v37)];
-            v32 += 2;
+            *(short *)v32 = v78[*((char *)v77 + v37)];//crash
+            ++v32;
             v97 = (char *)v97 + v87;
             v37 = (signed int)v97 >> 16;
             --i;
@@ -14688,22 +14570,22 @@
         if ( (signed int)v94 > 0 )
         {
           v39 = v94;
-          v40 = v97;
-          v41 = v93;
+          v40 = (short *)v97;
+          v41 = (short *)v93;
           v42 = v94 & 1;
           v43 = v94 >> 1;
-          memcpy(v93, v97, 4 * (v94 >> 1));
-          v45 = (int)((char *)v40 + 4 * v43);
-          v44 = (int)&v41[2 * v43];
+          memcpy(v93, v97, 2 * (v94 >> 1));
+          v45 = &v40[2 * v43];
+          v44 = &v41[2 * v43];
           v46 = v42;
           v39 *= 2;
           v93 = (unsigned __int16 *)((char *)v93 + v39);
           v97 = (char *)v97 + v39;
           while ( v46 )
           {
-            *(short *)v44 = *(short *)v45;
-            v45 += 2;
-            v44 += 2;
+            *v44 = *v45;
+            ++v45;
+            ++v44;
             --v46;
           }
           v6 = v86;
@@ -14713,105 +14595,103 @@
       }
       while ( v96 );
     }
-    goto LABEL_38;
-  }
-  v6 = viewparams->field_38;
-  v86 = viewparams->field_38;
-  v84 = viewparams->field_3A;
-  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
-    goto LABEL_23;
-  v5 = viewparams->field_2C - 34;
-LABEL_8:
-  black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-  teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
-  v7 = (uint *)pIndoor->pMapOutlines;
-  uNumBlueFacesInBLVMinimap = 0;
-  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
-  v9 = (pIndoor->pMapOutlines->uNumOutlines & 0x80000000u) != 0;
-  v94 = 0;
-  if ( !(v9 | v8) )
-  {
-    i = 0;
-    do
-    {
-      v10 = (int)((char *)v7 + i + 4);
-      v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
-      if ( BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )
-        goto LABEL_17;
-      v12 = *(short *)((char *)v7 + i + 14);
-      if ( !(v12 & 1) )
-      {
-        if ( !(v96 & 0x80) && (v11 & 0x80u) == 0 )
-          goto LABEL_17;
-        v96 = (signed int)v94 >> 3;
-        v13 = v94;
-        *(short *)(v10 + 10) = v12 | 1;
-        pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
-      }
-      v14 = *(short *)v10;
-      v88 = v5;
-      v15 = &pIndoor->pVertices[v14];
-      v16 = v15->x;
-      v17 = v15->y - v84;
-      v93 = (unsigned __int16 *)(v16 - v6);
-      v92 = v17;
-      v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
-      v19 = v18->x;
-      v20 = v18->y - v84;
-      v95 = v19 - v6;
-      v97 = (const void *)v20;
-      v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
-      v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
-      v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
-      v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
-      pRenderer->Line2D(
-        v85 + v88,
-        v90 - v87,
-        v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
-        v90 - v92,
-        black);
-      v7 = (uint *)pIndoor->pMapOutlines;
-LABEL_17:
-      ++v94;
-      i += 12;
-    }
-    while ( (signed int)v94 < (signed int)*v7 );
-  }
-  v21 = 0;
-  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
-  {
-    while ( 1 )
-    {
-      v22 = pBlueFacesInBLVMinimapIDs[v21];
-      v87 = v5;
-      v23 = (int)&v7[3 * v22 + 1];
-      v24 = &pIndoor->pVertices[*(short *)v23];
-      v25 = &pIndoor->pVertices[*(short *)(v23 + 2)];
-      v26 = v25->x;
-      v27 = (unsigned __int16 *)(v24->x - v86);
-      v28 = v24->y - v84;
-      v29 = v25->y - v84;
-      v93 = v27;
-      v92 = v28;
-      v97 = (const void *)v29;
-      v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
-      v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
-      i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
-      v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
-      pRenderer->Line2D(
-        v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
-        v90 - v88,
-        v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
-        v90 - v95,
-        teal);
-      ++v21;
-      if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
-        break;
-      v7 = (uint *)pIndoor->pMapOutlines;
-    }
-    v6 = v86;
-  }
-LABEL_38:
+  }
+  else
+  {
+	  black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
+	  teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+	  v7 = pIndoor->pMapOutlines;
+	  uNumBlueFacesInBLVMinimap = 0;
+	  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
+	  v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
+	  v94 = 0;
+	  if ( !(v9 | v8) )
+	  {
+		i = 0;
+		do
+		{
+		  v10 = (int)((char *)v7 + i + 4);
+		  v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
+		  if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) ))
+		  {
+			  v12 = *(short *)((char *)v7 + i + 14);
+			  if ( !(v12 & 1) )
+			  {
+				if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
+				{
+					v96 = (signed int)v94 >> 3;
+					v13 = v94;
+					*(short *)(v10 + 10) = v12 | 1;
+					pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
+				}
+			  }
+			  if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1)
+			  {
+				  v14 = *(short *)v10;
+				  v88 = v5;
+				  v15 = &pIndoor->pVertices[v14];
+				  v16 = v15->x;
+				  v17 = v15->y - v84;
+				  v93 = (unsigned __int16 *)(v16 - v6);
+				  v92 = v17;
+				  v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
+				  v19 = v18->x;
+				  v20 = v18->y - v84;
+				  v95 = v19 - v6;
+				  v97 = (const void *)v20;
+				  v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
+				  v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
+				  v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
+				  v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
+				  pRenderer->Line2D(
+					v85 + v88,
+					v90 - v87,
+					v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
+					v90 - v92,
+					black);
+				  v7 = pIndoor->pMapOutlines;
+			  }
+		  }
+		  ++v94;
+		  i += 12;
+		}
+		while ( v94 < (signed int)v7->uNumOutlines );
+	  }
+	  v21 = 0;
+	  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
+	  {
+		while ( 1 )
+		{
+		  v22 = pBlueFacesInBLVMinimapIDs[v21];
+		  v87 = v5;
+		  v23 = &v7->pOutlines[v22];
+		  v24 = &pIndoor->pVertices[v23->uVertex1ID];
+		  v25 = &pIndoor->pVertices[v23->uVertex2ID];
+		  v26 = v25->x;
+		  v27 = (unsigned __int16 *)(v24->x - v86);
+		  v28 = v24->y - v84;
+		  v29 = v25->y - v84;
+		  v93 = v27;
+		  v92 = v28;
+		  v97 = (const void *)v29;
+		  v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
+		  v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
+		  i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
+		  v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
+		  pRenderer->Line2D(
+			v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
+			v90 - v88,
+			v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
+			v90 - v95,
+			teal);
+		  ++v21;
+		  if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
+			break;
+		  v7 = pIndoor->pMapOutlines;
+		}
+		v6 = v86;
+	  }
+  }
   v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
   v81 = pParty->vPosition.y - v84;
   v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
@@ -14865,9 +14745,8 @@
               {
                 if ( (signed int)v51 >= 1664 )
                 {
-                  if ( (signed int)v51 > 1920 )
-                    goto LABEL_71;
-                  v73 = 7;
+                  if ( (signed int)v51 <= 1920 )
+				    v73 = 7;
                 }
                 else
                 {
@@ -14893,12 +14772,12 @@
         {
           v73 = 2;
         }
-        v50 = v73;
-        goto LABEL_71;
-      }
-      v50 = 1;
-    }
-LABEL_71:
+		if( (signed int)v51 <=1920)
+          v50 = v73;
+      }
+	  else
+        v50 = 1;
+    }
     pRenderer->_4A6776(
       v47,
       v49,
@@ -14970,7 +14849,7 @@
     v62 = (int)v61 << 16;
     teal = v60 >> 16;
     v63 = (signed __int16)v61;
-    a4a = &v75;
+    a4a = v75;
     result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
     v85 = 0;
     for ( i = result; v85 < (signed int)v95; result = v85 )
@@ -14988,14 +14867,14 @@
             if ( pOutdoor->_47F097(v81, v96) )
             {
               if ( !((a5a + v85) % 2) )
-                *(short *)a4a = i;
+                *a4a = i;
             }
             else
             {
-              *(short *)a4a = 0;
-            }
-          }
-          a4a += 2;
+              *a4a = 0;
+            }
+          }
+          ++a4a;
           v97 = (char *)v97 + black;
           v64 = (signed int)v97 >> 16;
           ++a5a;
@@ -15004,13 +14883,13 @@
       }
       v62 += black;
       v97 = (const void *)v60;
-      a4a += 2 * (v90 - a5a);
+      a4a += v90 - a5a;
       v63 = v62 >> 16;
       ++v85;
       teal = (unsigned int)v78;
     }
     v65 = v95;
-    v66 = &v75;
+    v66 = v75;
     if ( (signed int)v95 > 0 )
     {
       v67 = v77;
@@ -15025,7 +14904,7 @@
             v69 = *(short *)v66;
             if ( !*(short *)v66 || v69 == (short)i )
               *v67 = v69;
-            v66 += 2;
+            ++v66;
             ++v67;
             --v68;
           }
@@ -15236,322 +15115,259 @@
 
 
 //----- (00443801) --------------------------------------------------------
-int __cdecl Initialize2DA()
-{
-  const char *v0; // esi@3
-  _2devent *v1; // edi@3
-  char *v2; // esi@5
-  int v3; // edx@5
-  char v4; // cl@6
-  int v5; // eax@6
-  int v6; // ebx@10
-  int v7; // eax@60
-  int result; // eax@78
-  signed int v9; // [sp+10h] [bp-8h]@5
-  signed int v10; // [sp+14h] [bp-4h]@5
-
-  int it = 0;
-
-  if ( p2DEventsTXT_Raw )
-    pAllocator->FreeChunk(p2DEventsTXT_Raw);
-  p2DEventsTXT_Raw = 0;
-  v0 = "\r";
-  p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
-  strtok(p2DEventsTXT_Raw, "\r");
-  strtok(0, "\r");
-  v1 = p2DEvents;
-  while ( 1 )
-  {
-    v2 = strtok(0, v0) + 1;
-    v10 = 0;
-    v3 = -2;
-    v9 = -2;
-    do
-    {
-      v4 = *v2;
-      v5 = 0;
-      while ( v4 != 9 && v4 )
-      {
-        ++v5;
-        v4 = v2[v5];
-      }
-      v6 = (int)&v2[v5];
-      if ( !v2[v5] )
-        v10 = 1;
-      *(char *)v6 = 0;
-      if ( v5 )
-      {
-        switch ( v3 )
-        {
-          case 0:
-            if ( _strnicmp(v2, "wea", 3u) )
-            {
-              if ( _strnicmp(v2, "arm", 3u) )
-              {
-                if ( _strnicmp(v2, "mag", 3u) )
-                {
-                  if ( _strnicmp(v2, "alc", 3u) )
-                  {
-                    if ( _strnicmp(v2, "sta", 3u) )
-                    {
-                      if ( _strnicmp(v2, "boa", 3u) )
-                      {
-                        if ( _strnicmp(v2, "tem", 3u) )
-                        {
-                          if ( _strnicmp(v2, "tra", 3u) )
-                          {
-                            if ( _strnicmp(v2, "tow", 3u) )
-                            {
-                              if ( _strnicmp(v2, "tav", 3u) )
-                              {
-                                if ( _strnicmp(v2, "ban", 3u) )
-                                {
-                                  if ( _strnicmp(v2, "fir", 3u) )
-                                  {
-                                    if ( _strnicmp(v2, "air", 3u) )
-                                    {
-                                      if ( _strnicmp(v2, "wat", 3u) )
-                                      {
-                                        if ( _strnicmp(v2, "ear", 3u) )
-                                        {
-                                          if ( _strnicmp(v2, "spi", 3u) )
-                                          {
-                                            if ( _strnicmp(v2, "min", 3u) )
-                                            {
-                                              if ( _strnicmp(v2, "bod", 3u) )
-                                              {
-                                                if ( _strnicmp(v2, "lig", 3u) )
-                                                {
-                                                  if ( _strnicmp(v2, "dar", 3u) )
-                                                  {
-                                                    if ( _strnicmp(v2, "ele", 3u) )
-                                                    {
-                                                      if ( _strnicmp(v2, "sel", 3u) )
-                                                      {
-                                                        if ( _strnicmp(v2, "mir", 3u) )
-                                                        {
-                                                          v7 = -(_strnicmp(v2, "mer", 3u) != 0);
-                                                          LOBYTE(v7) = v7 & 0xEE;
-                                                          v1->uType = v7 + 18;
-                                                        }
-                                                        else
-                                                        {
-                                                          v1->uType = 16;
-                                                        }
-                                                      }
-                                                      else
-                                                      {
-                                                        v1->uType = 15;
-                                                      }
-                                                    }
-                                                    else
-                                                    {
-                                                      v1->uType = 14;
-                                                    }
-                                                  }
-                                                  else
-                                                  {
-                                                    v1->uType = 13;
-                                                  }
-                                                }
-                                                else
-                                                {
-                                                  v1->uType = 12;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                v1->uType = 11;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              v1->uType = 10;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            v1->uType = 9;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          v1->uType = 8;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        v1->uType = 7;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      v1->uType = 6;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    v1->uType = 5;
-                                  }
-                                }
-                                else
-                                {
-                                  v1->uType = 22;
-                                }
-                              }
-                              else
-                              {
-                                v1->uType = 21;
-                              }
-                            }
-                            else
-                            {
-                              v1->uType = 17;
-                            }
-                          }
-                          else
-                          {
-                            v1->uType = 30;
-                          }
-                        }
-                        else
-                        {
-                          v1->uType = 23;
-                        }
-                      }
-                      else
-                      {
-                        v1->uType = 28;
-                      }
-                    }
-                    else
-                    {
-                      v1->uType = 27;
-                    }
-                  }
-                  else
-                  {
-                    v1->uType = 4;
-                  }
-                }
-                else
-                {
-                  v1->uType = 3;
-                }
-              }
-              else
-              {
-                v1->uType = 2;
-              }
-            }
-            else
-            {
-              v1->uType = 1;
-            }
-            break;
-          case 2:
-            v1->uAnimationID = atoi(v2);
-            break;
-          case 3:
-            v1->pName = (char *)RemoveQuotes(v2);
-            break;
-          case 4:
-            v1->pProprieterName = RemoveQuotes(v2);
-            break;
-          case 5:
-            v1->pProprieterTitle = RemoveQuotes(v2);
-            break;
-          case 6:
-            v1->field_14 = atoi(v2);
-            break;
-          case 7:
-            v1->_state = atoi(v2);
-            break;
-          case 8:
-            v1->_rep = atoi(v2);
-            break;
-          case 9:
-            v1->_per = atoi(v2);
-            break;
-          case 10:
-            v1->fPriceMultiplier = atof(v2);
-            break;
-          case 11:
-            v1->flt_24 = atof(v2);
-            break;
-          case 13:
-            v1->field_1C = atoi(v2);
-            break;
-          case 16:
-            v1->uOpenTime = atoi(v2);
-            break;
-          case 17:
-            v1->uCloseTime = atoi(v2);
-            break;
-          case 18:
-            v1->uExitPicID = atoi(v2);
-            break;
-          case 19:
-            v1->uExitMapID = atoi(v2);
-            break;
-          case 20:
-            v1->_quest_related = atoi(v2);
-            break;
-          case 21:
-            v1->pEnterText = RemoveQuotes(v2);
-            break;
-          default:
-            break;
-        }
-      }
-      v2 = (char *)(v6 + 1);
-      v3 = v9 + 1;
-      v9 = v3;
-      result = v3 + 1;
-    }
-    while ( v3 + 1 <= 23 && !v10 );
-    ++v1;
-    //if ( (signed int)v1 >= (signed int)&unk_597F10 )
-    if (++it >= 525)
-      return result;
-    v0 = "\r";
-  }
+void Initialize2DA()
+{
+ 
+  int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+
+	if ( p2DEventsTXT_Raw )
+		pAllocator->FreeChunk(p2DEventsTXT_Raw);
+	p2DEventsTXT_Raw = NULL;
+	p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
+	strtok(p2DEventsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+
+	for (i=0;i<525;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 2:
+					{
+					if ( !_strnicmp(test_string, "wea", 3) )
+						{
+						p2DEvents[i].uType = 1;
+						break;
+						}
+					if ( !_strnicmp(test_string, "arm", 3) )
+						{
+						p2DEvents[i].uType = 2;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mag", 3) )
+						{
+						p2DEvents[i].uType = 3;
+						break;
+						}
+					if ( !_strnicmp(test_string, "alc", 3) )
+						{
+						p2DEvents[i].uType = 4;
+						break;
+						}
+					if ( !_strnicmp(test_string, "sta", 3) )
+						{
+						p2DEvents[i].uType = 27;
+						break;
+						}
+					if ( !_strnicmp(test_string, "boa", 3) )
+						{
+						p2DEvents[i].uType = 28;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tem", 3) )
+						{
+						p2DEvents[i].uType = 23;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tra", 3) )
+						{
+						p2DEvents[i].uType = 30;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tow", 3) )
+						{
+						p2DEvents[i].uType = 17;
+						break;
+						}
+
+					if ( !_strnicmp(test_string, "tav", 3) )
+						{
+						p2DEvents[i].uType = 21;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ban", 3) )
+						{
+						p2DEvents[i].uType = 22;
+						break;
+						}
+					if ( !_strnicmp(test_string, "fir", 3) )
+						{
+						p2DEvents[i].uType = 5;
+						break;
+						}
+					if ( !_strnicmp(test_string, "air", 3) )
+						{
+						p2DEvents[i].uType = 6;
+						break;
+						}
+					if ( !_strnicmp(test_string, "wat", 3) )
+						{
+						p2DEvents[i].uType = 7;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ear", 3) )
+						{
+						p2DEvents[i].uType = 8;
+						break;
+						}
+					if ( !_strnicmp(test_string, "spi", 3) )
+						{
+						p2DEvents[i].uType = 9;
+						break;
+						}
+					if ( !_strnicmp(test_string, "min", 3) )
+						{
+						p2DEvents[i].uType = 10;
+						break;
+						}
+					if ( !_strnicmp(test_string, "bod", 3) )
+						{
+						p2DEvents[i].uType = 11;
+						break;
+						}
+					if ( !_strnicmp(test_string, "lig", 3) )
+						{
+						p2DEvents[i].uType = 12;
+						break;
+						}
+					if ( !_strnicmp(test_string, "dar", 3) )
+						{
+						p2DEvents[i].uType = 13;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ele", 3) )
+						{
+						p2DEvents[i].uType = 14;
+						break;
+						}
+					if ( !_strnicmp(test_string, "sel", 3) )
+						{
+						p2DEvents[i].uType = 15;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mir", 3) )
+						{
+						p2DEvents[i].uType = 16;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mer", 3) )
+						{
+						p2DEvents[i].uType = 17;
+						break;
+						}
+					p2DEvents[i].uType = 18;
+					}
+					break;
+
+				case 4:
+					p2DEvents[i].uAnimationID = atoi(test_string);
+					break;
+				case 5:
+					p2DEvents[i].pName = RemoveQuotes(test_string);
+					break;
+				case 6:
+					p2DEvents[i].pProprieterName = RemoveQuotes(test_string);
+					break;
+				case 7:
+					p2DEvents[i].pProprieterTitle = RemoveQuotes(test_string);
+					break;
+				case 8:
+					p2DEvents[i].field_14 = atoi(test_string);
+					break;
+				case 9:
+					p2DEvents[i]._state = atoi(test_string);
+					break;
+				case 10:
+					p2DEvents[i]._rep = atoi(test_string);
+					break;
+				case 11:
+					p2DEvents[i]._per = atoi(test_string);
+					break;
+				case 12:
+					p2DEvents[i].fPriceMultiplier = atof(test_string);
+					break;
+				case 13:
+					p2DEvents[i].flt_24 = atof(test_string);
+					break;
+				case 15:
+					p2DEvents[i].field_1C = atoi(test_string);
+					break;
+				case 18:
+					p2DEvents[i].uOpenTime = atoi(test_string);
+					break;
+				case 19:
+					p2DEvents[i].uCloseTime = atoi(test_string);
+					break;
+				case 20:
+					p2DEvents[i].uExitPicID = atoi(test_string);
+					break;
+				case 21:
+					p2DEvents[i].uExitMapID = atoi(test_string);
+					break;
+				case 22:
+					p2DEvents[i]._quest_related = atoi(test_string);
+					break;
+				case 23:
+					p2DEvents[i].pEnterText = RemoveQuotes(test_string);
+					break;
+					}
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<24)&&!break_loop);
+		}
+
 }
 
 //----- (00443CE1) --------------------------------------------------------
-unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize)
-{
-  const char *v3; // edi@1
-  FILE *v4; // eax@1
-  unsigned int v5; // esi@3
-  char Args; // [sp+8h] [bp-B4h]@6
-  //Texture DstBuf; // [sp+6Ch] [bp-50h]@1
-  void *Dst; // [sp+B4h] [bp-8h]@1
+unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize)
+{
+  FILE *pLodFile; // eax@1
+  unsigned int uTextureSize; // esi@3
+  char Args[60]; // [sp+8h] [bp-B4h]@6
   void *ptr; // [sp+B8h] [bp-4h]@1
-
-  v3 = pContainerName;
-  Dst = a2;
-  ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
-  
   Texture DstBuf; // [sp+6Ch] [bp-50h]@1
-  //Texture::Texture(&DstBuf);
-
-  v4 = pEvents_LOD->FindContainer(v3, 0);
-  if ( !v4 )
-    Abortf("Unable to load %s", v3);
-  fread(&DstBuf, 1u, 0x30u, v4);
-  v5 = DstBuf.uDecompressedSize;
+
+  ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
+  pLodFile = pEvents_LOD->FindContainer(pContainerName, 0);
+  if ( !pLodFile )
+    Abortf("Unable to load %s", pContainerName);
+  fread(&DstBuf, 1, 48, pLodFile);
+  uTextureSize = DstBuf.uDecompressedSize;
   if ( !DstBuf.uDecompressedSize )
-    v5 = DstBuf.uTextureSize;
-  memset(&DstBuf, 0, 0x48u);
-  if ( (signed int)v5 >= (signed int)uBufferSize )
-  {
-    sprintf(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
-    Abortf(&Args);
-  }
-  memcpy(Dst, ptr, v5);
+    uTextureSize = DstBuf.uTextureSize;
+  memset(&DstBuf, 0, 72);
+  if ( uTextureSize >= (signed int)uBufferSize )
+  {
+    sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize);
+    Abortf(Args);
+  }
+  memcpy(pBuffer, ptr, uTextureSize);
   pAllocator->FreeChunk(ptr);
-  return v5;
+  return uTextureSize;
 }
 
 //----- (00443DA1) --------------------------------------------------------
@@ -16416,19 +16232,8 @@
   GUIButton *v14; // eax@43
   GUIButton *v15; // edi@43
   signed int v16; // eax@44
-  int v17; // eax@46
-  int v18; // eax@47
-  int v19; // eax@48
-  int v20; // eax@49
-  int v21; // eax@50
-  int v22; // eax@51
   unsigned int v23; // eax@53
   const char *v24; // eax@59
-  int v25; // eax@65
-  int v26; // eax@66
-  int v27; // eax@67
-  int v28; // eax@68
-  int v29; // eax@69
   unsigned __int16 v30; // cx@83
   int v31; // ecx@86
   int v32; // ebx@93
@@ -16456,7 +16261,7 @@
   __int16 v54[2]; // [sp+104h] [bp-10h]@2
   unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82
   GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39
-  char *pInString; // [sp+110h] [bp-4h]@32
+  char *pInString=NULL; // [sp+110h] [bp-4h]@32
 
   if ( !pDialogueWindow )
     return;
@@ -16483,9 +16288,9 @@
   }
   v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3);
   pParty->GetPartyFame();
-  if ( (signed int)uDialogueType > 89 )
-  {
-    if ( uDialogueType == 90 )
+  if ( (signed int)uDialogueType > DIALOGUE_ARENA_WELCOME )
+  {
+    if ( uDialogueType == DIALOGUE_ARENA_FIGHT_NOT_OVER_YET )
     {
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
@@ -16501,235 +16306,231 @@
       pRenderer->DrawTextureIndexed(8, 347 - v12, pTexture_591428);
       v13 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[577], pFontArrus, &pWindow, 0xDu, 0);
       pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 91 )
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_REWARD )
     {
       sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
       pInString = v4;
-      v8 = 0;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 92 )
-    {
-      v7 = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
-      v8 = 0;
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON )
+    {
+      pInString = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
+      pWindow.uFrameWidth = 460;
+      pWindow.uFrameZ = 452;
+      pOutString = pFontArrus;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+      if ( 352 - v12 < 8 )
+      {
+        pOutString = pFontCreate;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+      }
+      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( uDialogueType == DIALOGUE_ARENA_WELCOME )
+    {
+      v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death.  Remember, you are only allowed one arena combat per visit.  To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:"
       pInString = v7;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-  else
-  {
-    if ( uDialogueType == 89 )
-    {
-      v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death.  Remember, you are only allowed one arena combat per visit.  To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:"
-      v8 = 0;
-      pInString = v7;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 13 )
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( uDialogueType == DIALOGUE_13 )
     {
       v5 = 5 * pNPC->uProfession;
       v6 = (char *)*(&pNPCStats->field_13A64 + v5);
-      v8 = 0;
       v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
       pInString = v7;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( (signed int)uDialogueType > 18 )
-    {
-      if ( (signed int)uDialogueType > 24 )
-      {
-        if ( uDialogueType == 77 )
-        {
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( (signed int)uDialogueType > DIALOGUE_18 && !((signed int)uDialogueType > DIALOGUE_24 && uDialogueType != DIALOGUE_77 || byte_5B0938[0]) )
+    {
+      if ( (signed int)uDialogueType > DIALOGUE_24 && uDialogueType == DIALOGUE_77 )
+      {
           v5 = 5 * pNPC->uProfession;
           if ( byte_F8B1EC )
           {
             v6 = (char *)*(&pNPCStats->field_13A5C + 5 * pNPC->uProfession);
-            v8 = 0;
             v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
             pInString = v7;
             pWindow.uFrameWidth = 460;
             pWindow.uFrameZ = 452;
             pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             if ( 352 - v12 < 8 )
             {
               pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             }
             pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
                               (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
             pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-            goto LABEL_42;
-          }
-          if ( pNPC->uFlags & 0x80 )
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+          else if ( pNPC->uFlags & 0x80 )
           {
             v6 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
-            v8 = 0;
             v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
             pInString = v7;
             pWindow.uFrameWidth = 460;
             pWindow.uFrameZ = 452;
             pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             if ( 352 - v12 < 8 )
             {
               pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             }
             pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
                                (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
             pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-            goto LABEL_42;
-          }
-          v6 = (char *)*(&pNPCStats->field_13A64 + v5);
-          v8 = 0;
-          v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
-          pInString = v7;
-          pWindow.uFrameWidth = 460;
-          pWindow.uFrameZ = 452;
-          pOutString = pFontArrus;
-          v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-          if ( 352 - v12 < 8 )
-          {
-            pOutString = pFontCreate;
-            v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-          }
-          pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-                                     (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-          pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-          v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, v8);
-          pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-          goto LABEL_42;
-        }
-        goto LABEL_24;
-      }
-      if ( byte_5B0938[0] )
-        goto LABEL_24;
-      v7 = (char *)ptr_F8B1E8;
-      v8 = 0;
-      pInString = v7;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-LABEL_24:
-  if ( *(int *)v54 == 1 )
-  {
-    v11 = pNPC->greet;
-    v8 = 0;
-    if ( v11 )
-    {
-      v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
-      goto LABEL_32;
-    }
-  }
-  else
-  {
-    if ( *(int *)v54 == 2 )
-    {
-      v8 = 0;
-      if ( pNPC->uFlags & 0x80 )
-        v9 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
-      else
-        v9 = (char *)*(&pNPCStats->field_13A64 + 5 * pNPC->uProfession); //"Invalid String Passed"
-      v10 = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
-LABEL_32:
-      pInString = v10;
-      if ( v10 == (char *)v8 )
-        goto LABEL_42;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-LABEL_42:
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+		  else
+		  {
+			v6 = (char *)*(&pNPCStats->field_13A64 + v5);
+			v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
+			pInString = v7;
+			pWindow.uFrameWidth = 460;
+			pWindow.uFrameZ = 452;
+			pOutString = pFontArrus;
+			v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			if ( 352 - v12 < 8 )
+			{
+			pOutString = pFontCreate;
+			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			}
+			pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+										(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+			pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+			v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, 0);
+			pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+		  }
+      }
+	  else
+	  {
+		  v7 = (char *)ptr_F8B1E8;
+		  pInString = v7;
+		  pWindow.uFrameWidth = 460;
+		  pWindow.uFrameZ = 452;
+		  pOutString = pFontArrus;
+		  v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+		  if ( 352 - v12 < 8 )
+		  {
+			pOutString = pFontCreate;
+			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+		  }
+		  pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+			(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+		  pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+		  v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+		  pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+	  }
+    }
+	else
+	{    
+		if ( *(int *)v54 == 1 )
+		{
+			v11 = pNPC->greet;
+			v8 = 0;
+			if ( v11 )
+			{
+				v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
+				if (  pInString != NULL )
+				{
+					pWindow.uFrameWidth = 460;
+					pWindow.uFrameZ = 452;
+					pOutString = pFontArrus;
+					v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					if ( 352 - v12 < 8 )
+					{
+						pOutString = pFontCreate;
+						v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					}
+					pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+					(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+					pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+					v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+					pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+				}
+			}
+		}
+		else
+		{
+			if ( *(int *)v54 == 2 )
+			{
+				if ( pNPC->uFlags & 0x80 )
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
+				else
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
+				pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
+				if (  pInString != NULL )
+				{
+					pWindow.uFrameWidth = 460;
+					pWindow.uFrameZ = 452;
+					pOutString = pFontArrus;
+					v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					if ( 352 - v12 < 8 )
+					{
+						pOutString = pFontCreate;
+						v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					}
+					pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+					(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+					pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+					v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+					pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+				}
+			}
+		}
+	}
+  }
   memcpy(&v52, pDialogueWindow, sizeof(v52));
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
@@ -16743,125 +16544,107 @@
     if ( !v14 )
       break;
     v16 = v14->uControlParam;
-    if ( v16 > 24 )
-    {
-      v25 = v16 - 76;
-      if ( v25 )
-      {
-        v26 = v25 - 1;
-        if ( v26 )
-        {
-          v27 = v26 - 8;
-          if ( v27 )
-          {
-            v28 = v27 - 1;
-            if ( v28 )
-            {
-              v29 = v28 - 1;
-              if ( v29 )
-              {
-                if ( v29 != 1 )
-                {
-                  v24 = "";
-                  goto LABEL_79;
-                }
-                v24 = pGlobalTXT_LocalizationStrings[581];
-              }
-              else
-              {
-                v24 = pGlobalTXT_LocalizationStrings[580];
-              }
-            }
-            else
-            {
-              v24 = pGlobalTXT_LocalizationStrings[579];
-            }
-          }
-          else
-          {
-            v24 = pGlobalTXT_LocalizationStrings[578];
-          }
-        }
-        else
-        {
-          v24 = pGlobalTXT_LocalizationStrings[407];
-        }
-      }
-      else
-      {
-        if ( pNPC->uFlags & 0x80 )
-        {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-          v24 = pTmpBuf;
-          goto LABEL_79;
-        }
-        v24 = pGlobalTXT_LocalizationStrings[406];
-      }
-    }
-    else
-    {
-      if ( v16 == 24 )
-      {
-        v23 = pNPC->evtf;
-LABEL_63:
-        v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
-        if ( !v24 )
-        {
-          v24 = "";
-          v15->uControlParam = 0;
-        }
-        goto LABEL_79;
-      }
-      v17 = v16 - 9;
-      if ( !v17 )
-      {
-        v24 = (const char *)sub_445308(pNPC->uProfession);
-        goto LABEL_79;
-      }
-      v18 = v17 - 4;
-      if ( v18 )
-      {
-        v19 = v18 - 6;
-        if ( !v19 )
-        {
-          v23 = pNPC->bDrawSomeAnim;
-          goto LABEL_63;
-        }
-        v20 = v19 - 1;
-        if ( !v20 )
-        {
-          v23 = pNPC->_anim_current_time;
-          goto LABEL_63;
-        }
-        v21 = v20 - 1;
-        if ( !v21 )
-        {
-          v23 = pNPC->_anim_end_time;
-          goto LABEL_63;
-        }
-        v22 = v21 - 1;
-        if ( !v22 )
-        {
-          v23 = pNPC->evtd;
-          goto LABEL_63;
-        }
-        if ( v22 == 1 )
-        {
-          v23 = pNPC->evte;
-          goto LABEL_63;
-        }
+
+    if ( v16 > 88 )
+    {
         v24 = "";
-        goto LABEL_79;
-      }
-      if ( pNPC->uFlags & 0x80 )
-      {
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-        v24 = pTmpBuf;
-        goto LABEL_79;
-      }
-      v24 = pGlobalTXT_LocalizationStrings[122];
-    }
-LABEL_79:
+    }
+	else if ( v16 == 88 )
+		v24 = pGlobalTXT_LocalizationStrings[581];
+    else if ( v16 == 87 )
+	    v24 = pGlobalTXT_LocalizationStrings[580];
+    else if ( v16 == 86 )
+	    v24 = pGlobalTXT_LocalizationStrings[579];
+    else if ( v16 == 85 )
+		v24 = pGlobalTXT_LocalizationStrings[578];
+    else if ( v16 == 77 )
+        v24 = pGlobalTXT_LocalizationStrings[407];
+    else if ( v16 == 76 )
+    {
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[406];
+    }
+	else if ( v16 == 24 )
+    {
+		v23 = pNPC->evtf;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+    }
+	else if ( v16 == 9 )
+		v24 = (const char *)sub_445308(pNPC->uProfession);
+	else if ( v16 == 19 )
+	{
+		v23 = pNPC->bDrawSomeAnim;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 20 )
+	{
+		v23 = pNPC->_anim_current_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 21 )
+	{
+		v23 = pNPC->_anim_end_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 22 )
+	{
+		v23 = pNPC->evtd;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 23 )
+	{
+		v23 = pNPC->evte;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 13 )
+	{
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[122];
+	}
+	else
+		v24 = "";
+	
+
     if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 )
     {
       pInString = 0;
@@ -16949,18 +16732,23 @@
   NPCData *result; // eax@5
   int v3; // esi@9
   int v4; // ecx@9
-  int v5; // edx@9
-  NPCData *v6; // eax@9
+  //int v5; // edx@9
+  //NPCData *v6; // eax@9
   char *v7; // ebx@14
   NPCData *v8; // edi@14
   char v9; // al@22
-  std::string v10; // [sp-18h] [bp-2Ch]@4
-  const char *v11; // [sp-8h] [bp-1Ch]@4
+  char v10;
+  //std::string v10; // [sp-18h] [bp-2Ch]@4
+  int v11;
+  //const char *v11; // [sp-8h] [bp-1Ch]@4
   int v12; // [sp-4h] [bp-18h]@4
-  std::string *v13; // [sp+Ch] [bp-8h]@4
+  int v13; 
+  char *v14;
+  //std::string *v13; // [sp+Ch] [bp-8h]@4
   int a3; // [sp+13h] [bp-1h]@4
-
-  v1 = npcid;
+  int i;
+
+  /*v1 = npcid;
   if ( (npcid & 0x80000000u) == 0 )
   {
     if ( (signed int)npcid < 5000 )
@@ -17015,7 +16803,60 @@
     else
       result = &pParty->pHirelings[(unsigned __int8)v9];
   }
-  return result;
+  return result;*/
+  v1 = npcid;
+  if ( npcid >= 0 )
+  {
+    if ( npcid < 5000 )
+    {
+      if ( npcid >= 501 )
+      {
+        MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0);
+      }
+      return &pNPCStats->pNewNPCData[v1];// - 1];
+    }
+    return &pNPCStats->array_13EF4[npcid - 5000];
+  }
+
+
+  if ( npcid >= 5000 )
+    return &pNPCStats->array_13EF4[npcid - 5000];
+  if (uDialogue_SpeakingActorNPC_ID >= 0)
+  {
+    result = 0;
+  }
+  else
+  {
+    v3 = uDialogue_SpeakingActorNPC_ID - 1;
+    v4 = 0;
+
+    for (i = 0; i < 4; ++i)
+    {
+      if (pParty->pHirelings[i].pName)
+        pTmpBuf[v4++] = i;
+    }
+
+    if (pNPCStats->uNumNewNPCs > 0)
+    {
+      for (i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+      {
+        if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+        {
+          if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
+          {
+            if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName))
+              pTmpBuf[v4++] = i + 2;
+          }
+        }
+      }
+    }
+
+    v9 = pTmpBuf[v3];
+    if ( v9 >= 2 )
+     result = &pNPCStats->pNPCData[499 + v9];
+    else
+      result = &pParty->pHirelings[v9];
+  }
 }
 
 //----- (00445B2C) --------------------------------------------------------
@@ -18080,7 +17921,7 @@
 LABEL_119:
               v56 = &pParty->pPlayers[v57];
 LABEL_120:
-              v56->PlaySound(v114, v118);
+              v56->PlaySound((PlayerSpeech)v114, v118);
               ++v122;
               //v4 = v124;
               //v5 = pSomeEVT;
@@ -18089,12 +17930,12 @@
               break;
             }
             v55 = pParty->pPlayers;
-            do
-            {
-              v55->PlaySound(_evt->v6, 0);
+            for (int iii = 0; iii < 4; ++iii)
+            {
+              v55->PlaySound((PlayerSpeech)_evt->v6, 0);
               ++v55;
             }
-            while ( (signed int)v55 < (signed int)pParty->pHirelings );
+            //while ( (signed int)v55 < (signed int)pParty->pHirelings );
             ++v122;
             //v4 = v124;
             //v5 = pSomeEVT;