Fixed a possible bug causing TSPlayer.StrikeNPC to cause NullReferenceExceptions depending on the calling thread.

This commit is contained in:
CoderCow 2013-07-22 12:12:02 +02:00
parent 56d17224b6
commit f4aa36b8d1

View file

@ -899,6 +899,10 @@ namespace TShockAPI
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
{
// Main.rand is thread static.
if (Main.rand == null)
Main.rand = new Random();
Main.npc[npcid].StrikeNPC(damage, knockBack, hitDirection);
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
}