fix for linking items with ids that are exact multiples of 256 - they seem to require a specific encoding. This may apply to other things as well. Also just adds to the necessity for a refactor of the integer handling in payloads

This commit is contained in:
meli 2020-04-25 19:20:56 -07:00
parent 75aaebccc2
commit 535312dd22
2 changed files with 31 additions and 0 deletions

View file

@ -143,6 +143,24 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
}
}
protected override byte[] MakeInteger(uint value, bool withMarker = true, bool incrementSmallInts = true)
{
// TODO: as part of refactor
// linking an item id that is a multiple of 256 seemingly *requires* using byte*256 marker encoding
// or the link will not display correctly
// I am unsure if this applies to other data types as well, so keeping localized here, pending the
// refactor of all this integer handling mess
if (value % 256 == 0)
{
value /= 256;
// this is no longer a small int, but it was likely converted to that range
incrementSmallInts = false;
}
return base.MakeInteger(value, withMarker, incrementSmallInts);
}
protected override byte GetMarkerForIntegerBytes(byte[] bytes)
{
// custom marker just for hq items?
@ -151,6 +169,12 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
return (byte)IntegerType.Int24Special;
}
// TODO: as in the above function
if (bytes.Length == 1 && (this.itemId % 256 == 0))
{
return (byte)IntegerType.ByteTimes256;
}
return base.GetMarkerForIntegerBytes(bytes);
}
}

View file

@ -28,12 +28,19 @@ namespace Dalamud.Game.Chat.SeStringHandling
// arrow goes here
new TextPayload(displayName),
RawPayload.LinkTerminator
// sometimes there is another set of uiglow/foreground off payloads here
// might be necessary when including additional text after the item name
});
payloads.InsertRange(3, TextArrowPayloads());
return new SeString(payloads);
}
public static SeString CreateItemLink(Item item, bool isHQ, string displayNameOverride = null)
{
return CreateItemLink((uint)item.RowId, isHQ, displayNameOverride ?? item.Name);
}
public static SeString CreateMapLink(uint territoryId, uint mapId, float xCoord, float yCoord, float fudgeFactor = 0.05f)
{
var mapPayload = new MapLinkPayload(territoryId, mapId, xCoord, yCoord, fudgeFactor);