Use the named retcode and reason constants
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.
This commit is contained in:
parent
62205c8062
commit
a4b3b669a8
10 changed files with 20 additions and 26 deletions
|
|
@ -111,7 +111,7 @@ internal sealed class AccountController : ControllerBase
|
||||||
|
|
||||||
return Response(CmdType.PlayerLoginRsp, new PlayerLoginRsp
|
return Response(CmdType.PlayerLoginRsp, new PlayerLoginRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
GameBiz = "hk4e_global"
|
GameBiz = "hk4e_global"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ internal sealed class AvatarController : ControllerBase
|
||||||
SetUpAvatarTeamReq req = Packet!.DecodeBody<SetUpAvatarTeamReq>();
|
SetUpAvatarTeamReq req = Packet!.DecodeBody<SetUpAvatarTeamReq>();
|
||||||
|
|
||||||
if (req.AvatarTeamGuidList.Count == 0)
|
if (req.AvatarTeamGuidList.Count == 0)
|
||||||
return Response(CmdType.SetUpAvatarTeamRsp, new SetUpAvatarTeamRsp { Retcode = -1 });
|
return Response(CmdType.SetUpAvatarTeamRsp, new SetUpAvatarTeamRsp { Retcode = Retcode.RET_FAIL });
|
||||||
|
|
||||||
await sceneManager.SetupTeamAsync(req.TeamId, req.AvatarTeamGuidList, req.CurAvatarGuid);
|
await sceneManager.SetupTeamAsync(req.TeamId, req.AvatarTeamGuidList, req.CurAvatarGuid);
|
||||||
await persistence.SaveAsync();
|
await persistence.SaveAsync();
|
||||||
|
|
||||||
SetUpAvatarTeamRsp rsp = new()
|
SetUpAvatarTeamRsp rsp = new()
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
TeamId = req.TeamId,
|
TeamId = req.TeamId,
|
||||||
CurAvatarGuid = player.CurrentAvatarGuid
|
CurAvatarGuid = player.CurrentAvatarGuid
|
||||||
};
|
};
|
||||||
|
|
@ -43,7 +43,7 @@ internal sealed class AvatarController : ControllerBase
|
||||||
|
|
||||||
return Response(CmdType.ChangeAvatarRsp, new ChangeAvatarRsp
|
return Response(CmdType.ChangeAvatarRsp, new ChangeAvatarRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
CurrGuid = req.Guid,
|
CurrGuid = req.Guid,
|
||||||
SkillId = req.SkillId
|
SkillId = req.SkillId
|
||||||
});
|
});
|
||||||
|
|
@ -102,7 +102,7 @@ internal sealed class AvatarController : ControllerBase
|
||||||
|
|
||||||
return Response(CmdType.WearEquipRsp, new WearEquipRsp
|
return Response(CmdType.WearEquipRsp, new WearEquipRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
AvatarGuid = req.AvatarGuid,
|
AvatarGuid = req.AvatarGuid,
|
||||||
EquipGuid = req.EquipGuid
|
EquipGuid = req.EquipGuid
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ internal sealed class ChatController : ControllerBase
|
||||||
await ReplyAsync(session, req.ChannelId, player.Uid, text);
|
await ReplyAsync(session, req.ChannelId, player.Uid, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(CmdType.PlayerChatRsp, new PlayerChatRsp { Retcode = 0 });
|
return Response(CmdType.PlayerChatRsp, new PlayerChatRsp { Retcode = Retcode.RET_SUCC });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async ValueTask ReplyAsync(NetSession session, uint channelId, uint uid, string text)
|
private static async ValueTask ReplyAsync(NetSession session, uint channelId, uint uid, string text)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ namespace Yuanshen.Gameserver.Controllers;
|
||||||
internal sealed class GadgetController : ControllerBase
|
internal sealed class GadgetController : ControllerBase
|
||||||
{
|
{
|
||||||
private const uint ChestOpenedState = 102;
|
private const uint ChestOpenedState = 102;
|
||||||
private const uint ActionReasonOpenChest = 39;
|
|
||||||
private const uint ActionReasonGather = 11;
|
|
||||||
private const uint MoraItemId = 202;
|
private const uint MoraItemId = 202;
|
||||||
private const uint PrimogemItemId = 201;
|
private const uint PrimogemItemId = 201;
|
||||||
|
|
||||||
|
|
@ -55,7 +53,7 @@ internal sealed class GadgetController : ControllerBase
|
||||||
await scene.SetGadgetStateAsync(gadget, ChestOpenedState, false);
|
await scene.SetGadgetStateAsync(gadget, ChestOpenedState, false);
|
||||||
|
|
||||||
Dictionary<uint, uint> rolled = drops.Roll(gadget.Node.DropId, Random);
|
Dictionary<uint, uint> rolled = drops.Roll(gadget.Node.DropId, Random);
|
||||||
await GrantAsync(session, player, drops, excel, gadget, rolled, ActionReasonOpenChest);
|
await GrantAsync(session, player, drops, excel, gadget, rolled, (uint)ActionReasonType.ActionReasonOpenChest);
|
||||||
|
|
||||||
await persistence.SaveAsync();
|
await persistence.SaveAsync();
|
||||||
|
|
||||||
|
|
@ -89,7 +87,7 @@ internal sealed class GadgetController : ControllerBase
|
||||||
if (rolled.Count == 0 && gadget.Node.GatherItemId != 0)
|
if (rolled.Count == 0 && gadget.Node.GatherItemId != 0)
|
||||||
rolled[gadget.Node.GatherItemId] = 1;
|
rolled[gadget.Node.GatherItemId] = 1;
|
||||||
|
|
||||||
await GrantAsync(session, player, drops, excel, gadget, rolled, ActionReasonGather);
|
await GrantAsync(session, player, drops, excel, gadget, rolled, (uint)ActionReasonType.ActionReasonGather);
|
||||||
await scene.DespawnGadgetAsync(gadget, VisionType.VisionGatherEscape);
|
await scene.DespawnGadgetAsync(gadget, VisionType.VisionGatherEscape);
|
||||||
await persistence.SaveAsync();
|
await persistence.SaveAsync();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ internal sealed class GmTalkController : ControllerBase
|
||||||
|
|
||||||
return Response(CmdType.GmTalkRsp, new GmTalkRsp
|
return Response(CmdType.GmTalkRsp, new GmTalkRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
Msg = message,
|
Msg = message,
|
||||||
Retmsg = string.Join('\n', reply)
|
Retmsg = string.Join('\n', reply)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
|
|
||||||
GetScenePointRsp rsp = new()
|
GetScenePointRsp rsp = new()
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
SceneId = req.SceneId,
|
SceneId = req.SceneId,
|
||||||
BelongUid = player.Uid
|
BelongUid = player.Uid
|
||||||
};
|
};
|
||||||
|
|
@ -50,7 +50,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
|
|
||||||
GetSceneAreaRsp rsp = new()
|
GetSceneAreaRsp rsp = new()
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
SceneId = req.SceneId
|
SceneId = req.SceneId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
public ValueTask<IResult> OnGetPlayerSocialDetailReq(Player player)
|
public ValueTask<IResult> OnGetPlayerSocialDetailReq(Player player)
|
||||||
=> ValueTask.FromResult(Response(CmdType.GetPlayerSocialDetailRsp, new GetPlayerSocialDetailRsp
|
=> ValueTask.FromResult(Response(CmdType.GetPlayerSocialDetailRsp, new GetPlayerSocialDetailRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
DetailData = new SocialDetail
|
DetailData = new SocialDetail
|
||||||
{
|
{
|
||||||
Uid = player.Uid,
|
Uid = player.Uid,
|
||||||
|
|
@ -77,7 +77,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
|
|
||||||
[NetCommand(CmdType.GetPlayerBlacklistReq)]
|
[NetCommand(CmdType.GetPlayerBlacklistReq)]
|
||||||
public ValueTask<IResult> OnGetPlayerBlacklistReq()
|
public ValueTask<IResult> OnGetPlayerBlacklistReq()
|
||||||
=> ValueTask.FromResult(Response(CmdType.GetPlayerBlacklistRsp, new GetPlayerBlacklistRsp { Retcode = 0 }));
|
=> ValueTask.FromResult(Response(CmdType.GetPlayerBlacklistRsp, new GetPlayerBlacklistRsp { Retcode = Retcode.RET_SUCC }));
|
||||||
|
|
||||||
[NetCommand(CmdType.SceneTransToPointReq)]
|
[NetCommand(CmdType.SceneTransToPointReq)]
|
||||||
public async ValueTask<IResult> OnSceneTransToPointReq(NetSession session, GameState state, Player player, ScenePointTable points, ILogger<MiscController> logger)
|
public async ValueTask<IResult> OnSceneTransToPointReq(NetSession session, GameState state, Player player, ScenePointTable points, ILogger<MiscController> logger)
|
||||||
|
|
@ -105,7 +105,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
|
|
||||||
return Response(CmdType.SceneTransToPointRsp, new SceneTransToPointRsp
|
return Response(CmdType.SceneTransToPointRsp, new SceneTransToPointRsp
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
SceneId = req.SceneId,
|
SceneId = req.SceneId,
|
||||||
PointId = req.PointId
|
PointId = req.PointId
|
||||||
});
|
});
|
||||||
|
|
@ -115,7 +115,7 @@ internal sealed class MiscController : ControllerBase
|
||||||
public ValueTask<IResult> OnMarkMapReq()
|
public ValueTask<IResult> OnMarkMapReq()
|
||||||
{
|
{
|
||||||
MarkMapReq req = Packet!.DecodeBody<MarkMapReq>();
|
MarkMapReq req = Packet!.DecodeBody<MarkMapReq>();
|
||||||
MarkMapRsp rsp = new() { Retcode = 0 };
|
MarkMapRsp rsp = new() { Retcode = Retcode.RET_SUCC };
|
||||||
if (req.Mark is not null)
|
if (req.Mark is not null)
|
||||||
rsp.MarkList.Add(req.Mark);
|
rsp.MarkList.Add(req.Mark);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ namespace Yuanshen.Gameserver.Controllers;
|
||||||
[NetController]
|
[NetController]
|
||||||
internal sealed class ShopController : ControllerBase
|
internal sealed class ShopController : ControllerBase
|
||||||
{
|
{
|
||||||
private const uint ActionReasonShop = 4;
|
|
||||||
|
|
||||||
[NetCommand(CmdType.GetShopmallDataReq)]
|
[NetCommand(CmdType.GetShopmallDataReq)]
|
||||||
public ValueTask<IResult> OnGetShopmallDataReq(ExcelTableCollection excel)
|
public ValueTask<IResult> OnGetShopmallDataReq(ExcelTableCollection excel)
|
||||||
|
|
@ -106,7 +105,7 @@ internal sealed class ShopController : ControllerBase
|
||||||
await session.NotifyAsync(CmdType.StoreItemChangeNotify, store);
|
await session.NotifyAsync(CmdType.StoreItemChangeNotify, store);
|
||||||
await session.NotifyAsync(CmdType.PlayerPropNotify, player.BuildCurrencyProps());
|
await session.NotifyAsync(CmdType.PlayerPropNotify, player.BuildCurrencyProps());
|
||||||
|
|
||||||
ItemAddHintNotify hint = new() { Reason = ActionReasonShop };
|
ItemAddHintNotify hint = new() { Reason = (uint)ActionReasonType.ActionReasonShop };
|
||||||
hint.ItemList.Add(new ItemHint { ItemId = goods.ItemId, Count = gained, IsNew = false });
|
hint.ItemList.Add(new ItemHint { ItemId = goods.ItemId, Count = gained, IsNew = false });
|
||||||
await session.NotifyAsync(CmdType.ItemAddHintNotify, hint);
|
await session.NotifyAsync(CmdType.ItemAddHintNotify, hint);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ internal sealed class CombatManager
|
||||||
{
|
{
|
||||||
private const uint FightPropCurHp = 1010;
|
private const uint FightPropCurHp = 1010;
|
||||||
private const uint FightPropMaxHp = 2000;
|
private const uint FightPropMaxHp = 2000;
|
||||||
private const uint ActionReasonMonsterDie = 37;
|
|
||||||
private const uint ActionReasonMonsterEnvAnimal = 8;
|
|
||||||
private const uint MoraItemId = 202;
|
private const uint MoraItemId = 202;
|
||||||
private const uint PrimogemItemId = 201;
|
private const uint PrimogemItemId = 201;
|
||||||
|
|
||||||
|
|
@ -104,7 +102,7 @@ internal sealed class CombatManager
|
||||||
StoreItemChangeNotify store = new() { StoreType = StoreType.StorePack };
|
StoreItemChangeNotify store = new() { StoreType = StoreType.StorePack };
|
||||||
ItemAddHintNotify hint = new()
|
ItemAddHintNotify hint = new()
|
||||||
{
|
{
|
||||||
Reason = monster.IsWildlife ? ActionReasonMonsterEnvAnimal : ActionReasonMonsterDie,
|
Reason = monster.IsWildlife ? (uint)ActionReasonType.ActionReasonMonsterEnvAnimal : (uint)ActionReasonType.ActionReasonMonsterDie,
|
||||||
Position = monster.Pos,
|
Position = monster.Pos,
|
||||||
IsPositionValid = true
|
IsPositionValid = true
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ internal sealed class GmCommandService
|
||||||
{
|
{
|
||||||
private const int TeamSize = 4;
|
private const int TeamSize = 4;
|
||||||
private const uint MoraItemId = 202;
|
private const uint MoraItemId = 202;
|
||||||
private const uint ActionReasonTrifle = 3;
|
|
||||||
private const uint MaxConstellation = 6;
|
private const uint MaxConstellation = 6;
|
||||||
|
|
||||||
private readonly Player _player;
|
private readonly Player _player;
|
||||||
|
|
@ -419,7 +418,7 @@ internal sealed class GmCommandService
|
||||||
|
|
||||||
await _session.NotifyAsync(CmdType.StoreItemChangeNotify, notify);
|
await _session.NotifyAsync(CmdType.StoreItemChangeNotify, notify);
|
||||||
|
|
||||||
ItemAddHintNotify hint = new() { Reason = ActionReasonTrifle };
|
ItemAddHintNotify hint = new() { Reason = (uint)ActionReasonType.ActionReasonTrifle };
|
||||||
hint.ItemList.Add(new ItemHint { ItemId = itemId, Count = count, IsNew = false });
|
hint.ItemList.Add(new ItemHint { ItemId = itemId, Count = count, IsNew = false });
|
||||||
await _session.NotifyAsync(CmdType.ItemAddHintNotify, hint);
|
await _session.NotifyAsync(CmdType.ItemAddHintNotify, hint);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public static class RegionHandler
|
||||||
{
|
{
|
||||||
QueryRegionListHttpRsp rsp = new()
|
QueryRegionListHttpRsp rsp = new()
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
EnableLoginPc = true,
|
EnableLoginPc = true,
|
||||||
ClientCustomConfigEncrypted = ByteString.CopyFromUtf8(CLIENT_CUSTOM_CONFIG),
|
ClientCustomConfigEncrypted = ByteString.CopyFromUtf8(CLIENT_CUSTOM_CONFIG),
|
||||||
Servers =
|
Servers =
|
||||||
|
|
@ -41,7 +41,7 @@ public static class RegionHandler
|
||||||
{
|
{
|
||||||
QueryCurrRegionHttpRsp rsp = new()
|
QueryCurrRegionHttpRsp rsp = new()
|
||||||
{
|
{
|
||||||
Retcode = 0,
|
Retcode = Retcode.RET_SUCC,
|
||||||
RegionInfo = new RegionInfo
|
RegionInfo = new RegionInfo
|
||||||
{
|
{
|
||||||
Ip = GATESERVER_IP,
|
Ip = GATESERVER_IP,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue