forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestAction.cs
More file actions
67 lines (60 loc) · 2.02 KB
/
Copy pathRequestAction.cs
File metadata and controls
67 lines (60 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using L2dotNET.Logging.Abstraction;
using L2dotNET.World;
using L2dotNET.Models;
using L2dotNET.Models.Player;
using L2dotNET.Utility;
namespace L2dotNET.Network.clientpackets
{
class RequestAction : PacketBase
{
private readonly GameClient _client;
private readonly int _objectId;
private readonly int _x;
private readonly int _y;
private readonly int _z;
private readonly int _actionId;
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
public RequestAction(IServiceProvider serviceProvider, Packet packet, GameClient client) : base(serviceProvider)
{
_client = client;
_objectId = packet.ReadInt();
_x = packet.ReadInt();
_y = packet.ReadInt();
_z = packet.ReadInt();
_actionId = packet.ReadByte(); // Action identifier : 0-Simple click, 1-Shift click
}
public override void RunImpl()
{
L2Player player = _client.CurrentPlayer;
L2Object obj = null;
if (_objectId == player.ObjId)
obj = player;
else
{
if (L2World.Instance.GetObject(_objectId) != null)
obj = L2World.Instance.GetObject(_objectId);
}
//fixed nullreference exception when obj is null
Log.Debug($"Action Requested with { Utilz.GetTypeLower(obj).ToString() } of ID : { _objectId.ToString()}");
if(obj==null)
{
Log.Debug("Action Requested Failed");
player.SendActionFailed();
return;
}
switch (_actionId)
{
case 0:
obj.OnAction(player);
break;
case 1:
obj.OnActionShift(player);
break;
default:
player.SendActionFailed();
break;
}
}
}
}