Half the handlers were still answering with a bare 0 or -1 even though the whole retcode table is generated. Values on the wire are unchanged, they just read properly now. Same for the item hint reasons. ActionReasonType is a generated enum and we were redeclaring six of its members as private consts in four different files.
128 lines
4.4 KiB
C#
128 lines
4.4 KiB
C#
using Yuanshen.Gameserver.Controllers.Attributes;
|
|
using Yuanshen.Gameserver.Controllers.Result;
|
|
using Yuanshen.Gameserver.Game;
|
|
using Yuanshen.Protocol;
|
|
using Yuanshen.Gameserver.Network.Session;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Yuanshen.Gameserver.Controllers;
|
|
|
|
[NetController]
|
|
internal sealed class MiscController : ControllerBase
|
|
{
|
|
[NetCommand(CmdType.EnterWorldAreaReq)]
|
|
public ValueTask<IResult> OnEnterWorldAreaReq()
|
|
{
|
|
EnterWorldAreaReq req = Packet!.DecodeBody<EnterWorldAreaReq>();
|
|
|
|
return ValueTask.FromResult(Response(CmdType.EnterWorldAreaRsp, new EnterWorldAreaRsp
|
|
{
|
|
AreaType = req.AreaType,
|
|
AreaId = req.AreaId
|
|
}));
|
|
}
|
|
|
|
[NetCommand(CmdType.GetScenePointReq)]
|
|
public ValueTask<IResult> OnGetScenePointReq(Player player)
|
|
{
|
|
GetScenePointReq req = Packet!.DecodeBody<GetScenePointReq>();
|
|
|
|
GetScenePointRsp rsp = new()
|
|
{
|
|
Retcode = Retcode.RET_SUCC,
|
|
SceneId = req.SceneId,
|
|
BelongUid = player.Uid
|
|
};
|
|
|
|
for (uint pointId = 1; pointId <= 1000; pointId++)
|
|
rsp.UnlockedPointList.Add(pointId);
|
|
|
|
for (uint areaId = 1; areaId <= 100; areaId++)
|
|
rsp.UnlockAreaList.Add(areaId);
|
|
|
|
return ValueTask.FromResult(Response(CmdType.GetScenePointRsp, rsp));
|
|
}
|
|
|
|
[NetCommand(CmdType.GetSceneAreaReq)]
|
|
public ValueTask<IResult> OnGetSceneAreaReq()
|
|
{
|
|
GetSceneAreaReq req = Packet!.DecodeBody<GetSceneAreaReq>();
|
|
|
|
GetSceneAreaRsp rsp = new()
|
|
{
|
|
Retcode = Retcode.RET_SUCC,
|
|
SceneId = req.SceneId
|
|
};
|
|
|
|
for (uint areaId = 1; areaId <= 100; areaId++)
|
|
rsp.AreaIdList.Add(areaId);
|
|
|
|
return ValueTask.FromResult(Response(CmdType.GetSceneAreaRsp, rsp));
|
|
}
|
|
|
|
[NetCommand(CmdType.GetPlayerSocialDetailReq)]
|
|
public ValueTask<IResult> OnGetPlayerSocialDetailReq(Player player)
|
|
=> ValueTask.FromResult(Response(CmdType.GetPlayerSocialDetailRsp, new GetPlayerSocialDetailRsp
|
|
{
|
|
Retcode = Retcode.RET_SUCC,
|
|
DetailData = new SocialDetail
|
|
{
|
|
Uid = player.Uid,
|
|
Nickname = "Traveler",
|
|
Level = 1,
|
|
WorldLevel = 0,
|
|
IsFriend = false
|
|
}
|
|
}));
|
|
|
|
[NetCommand(CmdType.GetPlayerBlacklistReq)]
|
|
public ValueTask<IResult> OnGetPlayerBlacklistReq()
|
|
=> ValueTask.FromResult(Response(CmdType.GetPlayerBlacklistRsp, new GetPlayerBlacklistRsp { Retcode = Retcode.RET_SUCC }));
|
|
|
|
[NetCommand(CmdType.SceneTransToPointReq)]
|
|
public async ValueTask<IResult> OnSceneTransToPointReq(NetSession session, GameState state, Player player, ScenePointTable points, ILogger<MiscController> logger)
|
|
{
|
|
SceneTransToPointReq req = Packet!.DecodeBody<SceneTransToPointReq>();
|
|
|
|
uint sceneId = req.SceneId != 0 ? req.SceneId : GameState.SceneId;
|
|
if (points.TryGet(sceneId, req.PointId, out Vector target))
|
|
state.UpdatePosition(target);
|
|
|
|
logger.LogInformation("Teleport scene={s} point={p} -> ({x}, {y}, {z})",
|
|
sceneId, req.PointId, state.CurrentPos.X, state.CurrentPos.Y, state.CurrentPos.Z);
|
|
|
|
await session.NotifyAsync(CmdType.PlayerEnterSceneNotify, new PlayerEnterSceneNotify
|
|
{
|
|
SceneId = sceneId,
|
|
Pos = state.CurrentPos,
|
|
SceneBeginTime = (ulong)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
Type = EnterType.EnterGoto,
|
|
TargetUid = player.Uid,
|
|
EnterSceneToken = state.NextEnterSceneToken(),
|
|
WorldLevel = 0,
|
|
EnterReason = 4
|
|
});
|
|
|
|
return Response(CmdType.SceneTransToPointRsp, new SceneTransToPointRsp
|
|
{
|
|
Retcode = Retcode.RET_SUCC,
|
|
SceneId = req.SceneId,
|
|
PointId = req.PointId
|
|
});
|
|
}
|
|
|
|
[NetCommand(CmdType.MarkMapReq)]
|
|
public ValueTask<IResult> OnMarkMapReq()
|
|
{
|
|
MarkMapReq req = Packet!.DecodeBody<MarkMapReq>();
|
|
MarkMapRsp rsp = new() { Retcode = Retcode.RET_SUCC };
|
|
if (req.Mark is not null)
|
|
rsp.MarkList.Add(req.Mark);
|
|
|
|
return ValueTask.FromResult(Response(CmdType.MarkMapRsp, rsp));
|
|
}
|
|
|
|
[NetCommand(CmdType.TowerAllDataReq)]
|
|
public ValueTask<IResult> OnTowerAllDataReq()
|
|
=> ValueTask.FromResult(Response(CmdType.TowerAllDataRsp, new TowerAllDataRsp()));
|
|
}
|