mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 21:04:43 +01:00
okey
This commit is contained in:
31
Common/Utils/Misc.cs
Normal file
31
Common/Utils/Misc.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace Common.Utils
|
||||
{
|
||||
public static class Misc
|
||||
{
|
||||
public static byte[] StringToByteArray(string hex)
|
||||
{
|
||||
if (hex.Length % 2 == 1)
|
||||
throw new Exception("The binary key cannot have an odd number of digits");
|
||||
|
||||
byte[] arr = new byte[hex.Length >> 1];
|
||||
|
||||
for (int i = 0; i < hex.Length >> 1; ++i)
|
||||
{
|
||||
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static int GetHexVal(char hex)
|
||||
{
|
||||
int val = (int)hex;
|
||||
//For uppercase A-F letters:
|
||||
//return val - (val < 58 ? 48 : 55);
|
||||
//For lowercase a-f letters:
|
||||
//return val - (val < 58 ? 48 : 87);
|
||||
//Or the two combined, but a bit slower:
|
||||
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
GameServer/Handlers/ChapterGroupGetDataReqHandler.cs
Normal file
17
GameServer/Handlers/ChapterGroupGetDataReqHandler.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Common.Resources.Proto;
|
||||
using Common.Utils;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.ChapterGroupGetDataReq)]
|
||||
internal class ChapterGroupGetDataReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
MemoryStream ms = new(Misc.StringToByteArray("08001212080112060801100118031206080210021803122208021206080310031803120608041004180312060805100518031206080610061803122a08031206080710071803120608081008180312060809100918031206080a100a18031206080b100b1803122208041206080c100c18031206080d100d18031206080e100e18031206080f100f18031212080512060810101018031206081110111803121a08061206081210121803120608131013180312060814101418031212080712060815101518031206081610161803121a0808120608171017180312060818101818031206081910191803121a08091206081a101a18031206081b101b18031206081c101c18031212080a1206081d101d18031206081e101e1802120a080b1206081f101f1802121a080c1206082010201803120608211021180312060822102218021212080d120608241024180312060825102518021801"));
|
||||
ChapterGroupGetDataRsp Rsp = Serializer.Deserialize<ChapterGroupGetDataRsp>(ms);
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.ChapterGroupGetDataRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
19
GameServer/Handlers/ClientReportReqHandler.cs
Normal file
19
GameServer/Handlers/ClientReportReqHandler.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Common;
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.ClientReportReq)]
|
||||
internal class ClientReportReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
ClientReportReq Data = packet.GetDecodedBody<ClientReportReq>();
|
||||
|
||||
if((int)Global.config.VerboseLevel > 0)
|
||||
session.c.Warn($"ClientReport | {Data.ReportType} = {Data.ReportValue}");
|
||||
|
||||
session.Send(Packet.FromProto(new ClientReportRsp() { retcode = ClientReportRsp.Retcode.Succ }, CmdId.ClientReportRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
24
GameServer/Handlers/GetAuthkeyReqHandler.cs
Normal file
24
GameServer/Handlers/GetAuthkeyReqHandler.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetAuthkeyReq)]
|
||||
internal class GetAuthkeyReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetAuthkeyReq Data = packet.GetDecodedBody<GetAuthkeyReq>();
|
||||
|
||||
GetAuthkeyRsp Rsp = new()
|
||||
{
|
||||
retcode = GetAuthkeyRsp.Retcode.Succ,
|
||||
AuthAppid = Data.AuthAppid,
|
||||
Authkey = "0",
|
||||
SignType = 2,
|
||||
AuthkeyVer = 1
|
||||
};
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetAuthkeyRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
18
GameServer/Handlers/GetBulletinActivityMissionReqHandler.cs
Normal file
18
GameServer/Handlers/GetBulletinActivityMissionReqHandler.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetBulletinActivityMissionReq)]
|
||||
internal class GetBulletinActivityMissionReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetBulletinActivityMissionReq Data = packet.GetDecodedBody<GetBulletinActivityMissionReq>();
|
||||
|
||||
GetBulletinActivityMissionRsp Rsp = new() { retcode = GetBulletinActivityMissionRsp.Retcode.Succ };
|
||||
Rsp.MissionGroupLists.AddRange(Data.ActivityIdLists.Select(activityId => new BulletinMissionGroup() { ActivityId = activityId }).ToList());
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetBulletinActivityMissionRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
13
GameServer/Handlers/GetBulletinReqHandler.cs
Normal file
13
GameServer/Handlers/GetBulletinReqHandler.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetBulletinReq)]
|
||||
internal class GetBulletinReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
session.Send(Packet.FromProto(new GetBulletinRsp() { retcode = GetBulletinRsp.Retcode.Succ, IsAll = true }, CmdId.GetBulletinRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
16
GameServer/Handlers/GetCustomHeadDataReqHandler.cs
Normal file
16
GameServer/Handlers/GetCustomHeadDataReqHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetCustomHeadDataReq)]
|
||||
internal class GetCustomHeadDataReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetCustomHeadDataRsp Rsp = new() { retcode = GetCustomHeadDataRsp.Retcode.Succ, IsAll = true };
|
||||
Rsp.CustomHeadLists.Add(new CustomHead() { Id = 161001 });
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetCustomHeadDataRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
16
GameServer/Handlers/GetFrameDataReqHandler.cs
Normal file
16
GameServer/Handlers/GetFrameDataReqHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetFrameDataReq)]
|
||||
internal class GetFrameDataReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetFrameDataRsp Rsp = new() { retcode = GetFrameDataRsp.Retcode.Succ, IsAll = true };
|
||||
Rsp.FrameLists.Add(new FrameData() { Id = 200001 });
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetFrameDataRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
23
GameServer/Handlers/GetGalInteractTriggerEventReqHandler.cs
Normal file
23
GameServer/Handlers/GetGalInteractTriggerEventReqHandler.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetGalInteractTriggerEventReq)]
|
||||
internal class GetGalInteractTriggerEventReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetGalInteractTriggerEventReq Data = packet.GetDecodedBody<GetGalInteractTriggerEventReq>();
|
||||
|
||||
Random random = new ();
|
||||
GetGalInteractTriggerEventRsp Rsp = new()
|
||||
{
|
||||
retcode = GetGalInteractTriggerEventRsp.Retcode.Succ,
|
||||
AvatarId = Data.AvatarId,
|
||||
EventId = Data.EventIdLists[random.Next(0, Data.EventIdLists.Length - 1)]
|
||||
};
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetGalInteractTriggerEventRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace PemukulPaku.GameServer.Handlers
|
||||
Id = 581,
|
||||
LoginDays = 1,
|
||||
AcceptTime = session.Player.User.GetCreationTime(),
|
||||
DurationEndTime = session.Player.User.GetCreationTime() + 604800
|
||||
DurationEndTime = session.Player.User.GetCreationTime() + 604800 * 2
|
||||
});
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetLoginActivityRsp));
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace PemukulPaku.GameServer.Handlers
|
||||
OpenPanelActivityLists = new uint[] { 2 },
|
||||
ChatworldActivityInfo = new()
|
||||
{
|
||||
IsHasNpcRedEnvelope = true,
|
||||
TreasureScheduleId = 1
|
||||
IsHasNpcRedEnvelope = false,
|
||||
TreasureScheduleId = 0
|
||||
},
|
||||
IsAllowCostSeniorEquipOnCurDevice = true,
|
||||
TypeLists = new uint[] { 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39 },
|
||||
|
||||
13
GameServer/Handlers/GetShopListReqHandler.cs
Normal file
13
GameServer/Handlers/GetShopListReqHandler.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetShopListReq)]
|
||||
internal class GetShopListReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
session.Send(Packet.FromProto(new GetShopListRsp() { retcode = GetShopListRsp.Retcode.Succ, IsAll = true }, CmdId.GetShopListRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
GameServer/Handlers/GetWorldMapDataReqHandler.cs
Normal file
17
GameServer/Handlers/GetWorldMapDataReqHandler.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Common.Resources.Proto;
|
||||
using Common.Utils;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.GetWorldMapDataReq)]
|
||||
internal class GetWorldMapDataReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
MemoryStream ms = new(Misc.StringToByteArray("0800121c080110c0c4f4eb0418bffbaad60720002800300038c0c4f4eb044001121c080210c0c4f4eb0418bffbaad60720002800300038c0c4f4eb044002121c080310c0c4f4eb0418bffbaad6072019281e300038c0c4f4eb044003121c080410c0c4f4eb0418bffbaad60720002800300138c0c4f4eb044004121c080510c0c4f4eb0418bffbaad60720002800300138c0c4f4eb044005121c080610c0c4f4eb0418bffbaad607200f2858300138c0c4f4eb044006121c080710c0c4f4eb0418bffbaad607201e2828300138c0c4f4eb044007121c080810c0c4f4eb0418bffbaad60720002800300138c0c4f4eb044008121c080910c0c4f4eb0418bffbaad60720002800300138c0c4f4eb044009121c080a10c0c4f4eb0418bffbaad60720002800300138c0c4f4eb04400a121c080b10c0c4f4eb0418bffbaad60720002800300138c0c4f4eb04400b121c080c10c0c4f4eb0418bffbaad60720002800300138c0c4f4eb044031121e08bb1010a099aae90518bffbaad6072014286330cd0138a099aae9054079121d081210c0c4f4eb0418bffbaad60720322863300138c0c4f4eb04409e02121e08ad1110a092c3800618bffbaad607200f2858300138a092c3800640b302121e08db1110c0e494a30618bfa2f2a40620002800307a38c0e494a306408103"));
|
||||
GetWorldMapDataRsp Rsp = Serializer.Deserialize<GetWorldMapDataRsp>(ms);
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetWorldMapDataRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace PemukulPaku.GameServer.Handlers
|
||||
session.ProcessPacket(Packet.FromProto(new GetMainDataReq() { }, CmdId.GetMainDataReq));
|
||||
session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
|
||||
session.ProcessPacket(Packet.FromProto(new GetWorldMapDataReq() { }, CmdId.GetWorldMapDataReq));
|
||||
session.ProcessPacket(Packet.FromProto(new ChapterGroupGetDataReq() { }, CmdId.ChapterGroupGetDataReq));
|
||||
session.ProcessPacket(Packet.FromProto(new ChapterGroupGetDataReqHandler() { }, CmdId.ChapterGroupGetDataReq));
|
||||
session.ProcessPacket(Packet.FromProto(new GetStageDataReq() { }, CmdId.GetStageDataReq));
|
||||
|
||||
Rsp.PlayerExpReward = 100;
|
||||
|
||||
21
GameServer/Handlers/SyncTimeReqHandler.cs
Normal file
21
GameServer/Handlers/SyncTimeReqHandler.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Common;
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.SyncTimeReq)]
|
||||
internal class SyncTimeReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
SyncTimeReq Data = packet.GetDecodedBody<SyncTimeReq>();
|
||||
|
||||
session.Send(Packet.FromProto(new SyncTimeRsp()
|
||||
{
|
||||
retcode = SyncTimeRsp.Retcode.Succ,
|
||||
CurTime = (uint)Global.GetUnixInSeconds(),
|
||||
Seq = Data.Seq
|
||||
}, CmdId.SyncTimeRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace PemukulPaku.GameServer
|
||||
public readonly string Id;
|
||||
public readonly TcpClient Client;
|
||||
public readonly Logger c;
|
||||
public long LastKeepAlive = Global.GetUnixInSeconds();
|
||||
public Player Player = default!;
|
||||
|
||||
public Session(string id, TcpClient client)
|
||||
@@ -82,6 +83,7 @@ namespace PemukulPaku.GameServer
|
||||
public void ProcessPacket(Packet _packet)
|
||||
{
|
||||
string PacketName = Enum.GetName(typeof(CmdId), _packet.CmdId)!;
|
||||
if(PacketName == "KeepAliveNotify") { LastKeepAlive = Global.GetUnixInSeconds(); c.Log(PacketName); return; }
|
||||
try
|
||||
{
|
||||
CmdId cmdId = (CmdId)Enum.ToObject(typeof(CmdId), _packet.CmdId);
|
||||
|
||||
Reference in New Issue
Block a user