Pyrdacor/freeserf.net

Flag inventory does not match screen

athach opened this issue · 3 comments

Please see the attached screenshots and save file.

a
b
quicksave-08-02-22-21-34-08.zip

The second sample is very clear. When game is loaded there is a sword at the flag. A serf carries a shield which he puts at the flag when he arrives, he picks up the sword. But the sword is still displayed in the game window. The transport info box is correct, the game window is incorrect.

Fix:
Replace
if (resources[i] == null)
{
var spriteOffset = textureAtlas.GetOffset(2000u + (uint)resource);
resources[i] = spriteFactory.Create(info.Size.Width, info.Size.Height, spriteOffset.X, spriteOffset.Y, false, false);
}

with

var spriteOffset = textureAtlas.GetOffset(2000u + (uint)resource);
resources[i]?.Delete();
resources[i] = spriteFactory.Create(info.Size.Width, info.Size.Height, spriteOffset.X, spriteOffset.Y, false, false);

in RenderFlag.Update()

Fixed it