Skip to content

Commit f34e4b1

Browse files
authored
Fix issue with creatures when quick-switching casts in OTs (jo3bingham#37)
1 parent 759304a commit f34e4b1

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

TibiaAPI/Network/NetworkMessage.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,12 @@ public Creature ReadCreatureInstance(int id = -1, Position position = null)
453453
creature = _client.CreatureStorage.GetCreature(creatureId);
454454
if (creature == null)
455455
{
456-
throw new Exception("[NetworkMessage.ReadCreatureInstance] Outdated creature not found.");
456+
// This should never occur on official servers, but has been observed
457+
// on Open-Tibia servers via cast system. Log the error and create
458+
// a new Creature so that the parser can continue gracefully.
459+
_client.Logger.Error("[NetworkMessage.ReadCreatureInstance] Outdated creature not found.");
460+
creature = new Creature(creatureId);
461+
creature = _client.CreatureStorage.ReplaceCreature(creature);
457462
}
458463

459464
creature.InstanceType = (CreatureInstanceType)id;
@@ -501,7 +506,12 @@ public Creature ReadCreatureInstance(int id = -1, Position position = null)
501506
creature = _client.CreatureStorage.GetCreature(creatureId);
502507
if (creature == null)
503508
{
504-
throw new Exception("[NetworkMessage.ReadCreatureInstance] Known creature not found.");
509+
// This should never occur on official servers, but has been observed
510+
// on Open-Tibia servers via cast system. Log the error and create
511+
// a new Creature so that the parser can continue gracefully.
512+
_client.Logger.Error("[NetworkMessage.ReadCreatureInstance] Known creature not found.");
513+
creature = new Creature(creatureId);
514+
creature = _client.CreatureStorage.ReplaceCreature(creature);
505515
}
506516

507517
creature.InstanceType = (CreatureInstanceType)id;

0 commit comments

Comments
 (0)