Skip to content

Commit

Permalink
Implement UpdateName packet
Browse files Browse the repository at this point in the history
  • Loading branch information
brndd authored and andreakarasho committed Mar 1, 2020
1 parent f4c1b41 commit 7080f10
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Game/GameObjects/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
using ClassicUO.Game.Data;
using ClassicUO.Game.Managers;
using ClassicUO.Game.UI.Gumps;
using ClassicUO.Network;
using static ClassicUO.Network.NetClient;

namespace ClassicUO.Game.GameObjects
{
Expand Down Expand Up @@ -108,7 +110,9 @@ public override void Update(double totalMS, double frameMS)

//if (gump == null)
{
Socket.Send(new PNameRequest(Serial));
UIManager.Add(new NameOverheadGump(this));

ObjectHandlesOpened = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Game/UI/Gumps/NameOverheadGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public NameOverheadGump(Entity entity) : base(entity.Serial, 0)

public Entity Entity { get; }

private bool SetName()
public bool SetName()
{
if (string.IsNullOrEmpty(_renderedText.Text))
{
Expand Down
20 changes: 20 additions & 0 deletions src/Network/PacketHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public static void Load()
Handlers.Add(0x93, OpenBook);
Handlers.Add(0x95, DyeData);
Handlers.Add(0x97, MovePlayer);
Handlers.Add(0x98, UpdateName);
Handlers.Add(0x99, MultiPlacement);
Handlers.Add(0x9A, ASCIIPrompt);
Handlers.Add(0x9E, SellList);
Expand Down Expand Up @@ -2555,6 +2556,25 @@ private static void MovePlayer(Packet p)
World.Player.Walk(direction & Direction.Mask, (direction & Direction.Running) != 0);
}

private static void UpdateName(Packet p)
{
if (!World.InGame)
return;

uint serial = p.ReadUInt();
string name = p.ReadASCII();

Entity entity = World.Get(serial);
if (entity == null)
return;
entity.Name = name;

NameOverheadGump gump = UIManager.GetGump<NameOverheadGump>(serial);
if (gump == null)
return;
gump.SetName();
}

private static void MultiPlacement(Packet p)
{
if (World.Player == null)
Expand Down

0 comments on commit 7080f10

Please sign in to comment.