Fix crashing on talking to npcs with 0 chatpoints.

This commit is contained in:
SilicaAndPina 2021-02-09 21:25:12 +13:00
parent d776d2adc3
commit fa8f21388c
8 changed files with 214 additions and 10 deletions

View file

@ -2745,9 +2745,22 @@ namespace HISP.Server
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to start talking to an NPC with id that is NaN.");
return;
}
if(!Npc.NpcExists(chatId))
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to start talking to an NPC that doesnt exist.");
return;
}
sender.LoggedinUser.MetaPriority = true;
Npc.NpcEntry entry = Npc.GetNpcById(chatId);
if(entry.Chatpoints.Length <= 0)
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to start talking to an NPC with no chatpoints.");
return;
}
int defaultChatpointId = Npc.GetDefaultChatpoint(sender.LoggedinUser, entry);
Npc.NpcChat startingChatpoint = Npc.GetNpcChatpoint(entry, defaultChatpointId);