Skip to content

Commit

Permalink
BU Support: avoid crash when NPC mouseover pixel is out of texture bo…
Browse files Browse the repository at this point in the history
…unds
  • Loading branch information
ethanmoffat committed Oct 30, 2024
1 parent 116c9ac commit 86625ef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions EndlessClient/Rendering/NPC/NPCRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ public bool IsClickablePixel(Point currentMousePosition)
var currentFrame = _npcSpriteSheet.GetNPCTexture(_enfFileProvider.ENFFile[NPC.ID].Graphic, NPC.Frame, NPC.Direction);

var adjustedPos = currentMousePosition - DrawArea.Location;
var pixel = cachedTexture[adjustedPos.Y * currentFrame.Width + adjustedPos.X];

return pixel.A > 0;
var index = adjustedPos.Y * currentFrame.Width + adjustedPos.X;
return index < cachedTexture.Length && cachedTexture[index].A > 0;
}

return true;
Expand Down

0 comments on commit 86625ef

Please sign in to comment.