diff mm7_4.cpp @ 518:9c984eef0a7d

m2
author Gloval
date Fri, 01 Mar 2013 22:17:32 +0400
parents 7c86030324a5
children 8f70e52646eb
line wrap: on
line diff
--- a/mm7_4.cpp	Fri Mar 01 20:28:25 2013 +0400
+++ b/mm7_4.cpp	Fri Mar 01 22:17:32 2013 +0400
@@ -11942,9 +11942,9 @@
 void OnSelectDialogueOption(DIALOGUE_TYPE newDialogueType)
 {
   //unsigned int v1; // esi@1
-  NPCData *v2; // ebp@1
+  NPCData *speakingNPC; // ebp@1
   //unsigned int v3; // eax@1
-  int v4; // ecx@10
+  int npc_event_id; // ecx@10
   signed int v5; // edi@14
   char *v6; // esi@15
   const char *v7; // ecx@22
@@ -11958,240 +11958,210 @@
   const char *v15; // [sp-4h] [bp-14h]@60
 
   //v1 = _this;
-  v2 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
+  speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID);
   //v3 = v1;
   uDialogueType = newDialogueType;
-  if ( !v2->uFlags )
-  {
-    v2->uFlags = 1;
+  if ( !speakingNPC->uFlags )
+  {
+    speakingNPC->uFlags = 1;
     //v3 = uDialogueType;
   }
-  if ( (signed int)newDialogueType > 22 )
-  {
-    if ( newDialogueType == DIALOGUE_23 )
-    {
-      v4 = v2->evt_E;
-      goto LABEL_74;
-    }
-    if (newDialogueType == DIALOGUE_24)
-    {
-      v4 = v2->evt_F;
-      goto LABEL_74;
-    }
-    if (newDialogueType != DIALOGUE_76)
-    {
-      if (newDialogueType == DIALOGUE_PROFESSION_DETAILS)
-      {
-        dialogue_show_profession_details = ~dialogue_show_profession_details;
-      }
-      else
-      {
-        if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 )
-        {
-          ArenaFight();
-          return;
-        }
-      }
-      goto LABEL_87;
-    }
-    if (v2->Hired())
-    {
-      v8 = 0;
-      if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-      {
-        v6 = (char *)pNPCStats->pNewNPCData;
-        while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) )
-        {
-          ++v8;
-          v6 += 76;
-          if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
-            goto LABEL_44;
-        }
-        goto LABEL_43;
-      }
+  if ((newDialogueType>DIALOGUE_24)||(newDialogueType<DIALOGUE_19))
+	  {
+
+	  if (newDialogueType != DIALOGUE_76)
+		  {
+		  if (newDialogueType == DIALOGUE_PROFESSION_DETAILS)
+			  {
+			  dialogue_show_profession_details = ~dialogue_show_profession_details;
+			  }
+		  else
+			  {
+			  if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 )
+				  {
+				  ArenaFight();
+				  return;
+				  }
+			  }
+		  goto LABEL_87;
+		  }
+	  if (speakingNPC->Hired())
+		  {
+		  v8 = 0;
+		  if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+			  {
+			  v6 = (char *)pNPCStats->pNewNPCData;
+			  while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
+				  {
+				  ++v8;
+				  v6 += 76;
+				  if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
+					  goto LABEL_44;
+				  }
+			  goto LABEL_43;
+			  }
 LABEL_44:
-      if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, v2->pName) )
-      {
-        if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, v2->pName) )
-        {
+		  if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
+			  {
+			  if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
+				  {
 LABEL_51:
-          pParty->field_709 = 0;
-          sub_44A56A();
-          dword_591084 = 0;
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }*/
-          goto LABEL_89;
-        }
-        v14 = 76;
-        v12 = 0;
-        v11 = &pParty->pHirelings[1];
-      }
-      else
-      {
-        v14 = 76;
-        v12 = 0;
-        v11 = pParty->pHirelings;
-      }
-      memset(v11, v12, v14);
-      goto LABEL_51;
-    }
-    if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
-    {
-      v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
+				  pParty->field_709 = 0;
+				  sub_44A56A();
+				  dword_591084 = 0;
+				  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+
+				  goto LABEL_89;
+				  }
+			  v11 = &pParty->pHirelings[1];
+			  }
+		  else
+			  {
+			  v11 = pParty->pHirelings;
+			  }
+		  memset(v11, 0, sizeof(NPCData));
+		  goto LABEL_51;
+		  }
+	  if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
+		  {
+		  v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
 LABEL_64:
-      ShowStatusBarString(v7, 2u);
-      goto LABEL_87;
-    }
-    //v9 = v2->uProfession;
-    if ( v2->uProfession != 51 )
-    {
-      v10 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice;
-      if ( pParty->uNumGold < v10 )
-      {
-        ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
-        dialogue_show_profession_details = false;
-        uDialogueType = 13;
-        if ( uActiveCharacter )
-          pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
-        v7 = pGlobalTXT_LocalizationStrings[155];
-        goto LABEL_64;
-      }
-      Party::TakeGold(v10);
-    }
-    LOBYTE(v2->uFlags) |= 0x80u;
-    if ( pParty->pHirelings[0].pName )
-    {
-      memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1]));
-      v15 = v2->pName;
-      v13 = pParty->pHireling2Name;
-    }
-    else
-    {
-      memcpy(pParty->pHirelings, v2, 0x4Cu);
-      v15 = v2->pName;
-      v13 = pParty->pHireling1Name;
-    }
-    strcpy(v13, v15);
-    pParty->field_709 = 0;
-    sub_44A56A();
-
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
-    if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
-      pDialogue_SpeakingActor->uAIState = Removed;
-    if ( uActiveCharacter )
-      pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
-    goto LABEL_87;
-  }
-  if (newDialogueType == DIALOGUE_22)
-  {
-    v4 = v2->evt_D;
-    goto LABEL_74;
-  }
-  if (newDialogueType == DIALOGUE_9)
-  {
-    if ( !sub_4BB756(v2->uProfession) )
-    {
-      if ( v2->uProfession != 41 )
-        v2->bHasUsedTheAbility = 1;
-      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      {
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-        *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-        ++pMessageQueue_50CBD0->uNumMessages;
-      }*/
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-      goto LABEL_87;
-    }
-    v7 = pGlobalTXT_LocalizationStrings[140];
-    goto LABEL_64;
-  }
-  if (newDialogueType == DIALOGUE_13)
-  {
-    if (!v2->Hired())
-    {
-      sub_4B3E1E();
-      dialogue_show_profession_details = false;
-      goto LABEL_87;
-    }
-    v5 = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-    {
-      v6 = (char *)pNPCStats->pNewNPCData;
-      while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) )
-      {
-        ++v5;
-        v6 += 76;
-        if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
-          goto LABEL_44;
-      }
+		  ShowStatusBarString(v7, 2u);
+		  goto LABEL_87;
+		  }
+	  //v9 = v2->uProfession;
+	  if ( speakingNPC->uProfession != 51 )
+		  {
+		  v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice;
+		  if ( pParty->uNumGold < v10 )
+			  {
+			  ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
+			  dialogue_show_profession_details = false;
+			  uDialogueType = 13;
+			  if ( uActiveCharacter )
+				  pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
+			  v7 = pGlobalTXT_LocalizationStrings[155];
+			  ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+			  goto LABEL_87;
+			  }
+		  Party::TakeGold(v10);
+		  }
+	  LOBYTE(speakingNPC->uFlags) |= 0x80u;
+	  if ( pParty->pHirelings[0].pName )
+		  {
+		  memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1]));
+		  v15 = speakingNPC->pName;
+		  v13 = pParty->pHireling2Name;
+		  }
+	  else
+		  {
+		  memcpy(pParty->pHirelings, speakingNPC, 0x4Cu);
+		  v15 = speakingNPC->pName;
+		  v13 = pParty->pHireling1Name;
+		  }
+	  strcpy(v13, v15);
+	  pParty->field_709 = 0;
+	  sub_44A56A();
+
+	  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+
+	  if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+		  pDialogue_SpeakingActor->uAIState = Removed;
+	  if ( uActiveCharacter )
+		  pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
+	  goto LABEL_87;
+
+
+	  if (newDialogueType == DIALOGUE_9)
+		  {
+		  if ( !sub_4BB756(speakingNPC->uProfession) )
+			  {
+			  if ( speakingNPC->uProfession != 41 )
+				  speakingNPC->bHasUsedTheAbility = 1;
+
+			  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			  }
+		  else
+			  {
+			  ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!"
+			  }
+
+		  goto LABEL_87;
+		  }
+	  if (newDialogueType == DIALOGUE_13)
+		  {
+		  if (!speakingNPC->Hired())
+			  {
+			  sub_4B3E1E();
+			  dialogue_show_profession_details = false;
+			  goto LABEL_87;
+			  }
+		  else
+			  {
+			  v5 = 0;
+			  if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+				  {
+				  v6 = (char *)pNPCStats->pNewNPCData;
+				  while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
+					  {
+					  ++v5;
+					  v6 += 76;
+					  if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
+						  goto LABEL_44;
+					  }
 LABEL_43:
-      v6[8] &= 0x7Fu;
-      goto LABEL_44;
-    }
-    goto LABEL_44;
-  }
-  if (newDialogueType == DIALOGUE_19)
-  {
-    v4 = v2->evt_A;
-    goto LABEL_74;
-  }
-  if (newDialogueType == DIALOGUE_20)
-  {
-    v4 = v2->evt_B;
-    goto LABEL_74;
-  }
-  if (newDialogueType == DIALOGUE_21)
-  {
-    v4 = v2->evt_C;
-LABEL_74:
-    if ( v4 < 200 || v4 > 310 )
-    {
-      if ( v4 < 400 || v4 > 410 )
-      {
-        switch ( v4 )
-        {
-          case 139:
-            sub_4B1ECE();
-            break;
-          case 311:
-            sub_4BBA85_bounties();
-            break;
-          case 399:
-            sub_4BBCDD();
-            break;
-          default:
-            GlobalEventInfo = 1;
-            ptr_F8B1E8 = 0;
-            EventProcessor(v4, 0, 1);
-            GlobalEventInfo = 0;
-            break;
-        }
-      }
-      else
-      {
-        dword_F8B1D8 = newDialogueType;
-        DrawJoinGuildWindow(v4 - 400);
-      }
-    }
-    else
-    {
-      sub_4B3FE5(v4);
-    }
-  }
+				  v6[8] &= 0x7Fu;
+				  goto LABEL_44;
+				  }
+			  goto LABEL_44;
+			  }
+		  }
+
+	  }
+  else
+	  {
+  switch(newDialogueType)
+	  {
+  case DIALOGUE_19:  npc_event_id = speakingNPC->evt_A; break;
+  case DIALOGUE_20:  npc_event_id = speakingNPC->evt_B; break;
+  case DIALOGUE_21:  npc_event_id = speakingNPC->evt_C; break;
+  case DIALOGUE_22:	 npc_event_id = speakingNPC->evt_D; break;
+  case DIALOGUE_23:  npc_event_id = speakingNPC->evt_E; break;
+  case DIALOGUE_24:	 npc_event_id = speakingNPC->evt_F; break;
+	  }
+  if ( (npc_event_id >= 200) && (npc_event_id <= 310) )
+	  sub_4B3FE5(npc_event_id); //200-310
+  else if (( npc_event_id >= 400) && (npc_event_id <= 410) )
+	  { //400-410
+	  dword_F8B1D8 = newDialogueType;
+	  DrawJoinGuildWindow(npc_event_id - 400);
+	  }
+  else
+	  {
+	  switch ( npc_event_id )
+	  {
+	  case 139:
+		  sub_4B1ECE();
+		  break;
+	  case 311:
+		  sub_4BBA85_bounties();
+		  break;
+	  case 399:
+		  sub_4BBCDD();
+		  break;
+	  default:
+		  GlobalEventInfo = 1;
+		  ptr_F8B1E8 = 0;
+		  EventProcessor(npc_event_id, 0, 1);
+		  GlobalEventInfo = 0;
+		  break;
+	  }
+	 }
+
+
+
+  
+   
 LABEL_87:
   if ( !dword_7241C8 )
     pGame->Draw();