Improvements in handling system, logo in sdkserver

This commit is contained in:
xeon 2024-02-20 22:39:08 +03:00
parent 01a3df0a45
commit a7c4217068
35 changed files with 111 additions and 71 deletions

View file

@ -12,5 +12,5 @@ internal class AchievementController : Controller
} }
[NetEvent(MessageId.AchievementInfoRequest)] [NetEvent(MessageId.AchievementInfoRequest)]
public ResponseMessage OnAchievementInfoRequest() => Response(MessageId.AchievementInfoResponse, new AchievementInfoResponse()); public RpcResult OnAchievementInfoRequest() => Response(MessageId.AchievementInfoResponse, new AchievementInfoResponse());
} }

View file

@ -18,7 +18,7 @@ internal class ChatController : Controller
} }
[NetEvent(MessageId.PrivateChatDataRequest)] [NetEvent(MessageId.PrivateChatDataRequest)]
public async Task<ResponseMessage> OnPrivateChatDataRequest() public async Task<RpcResult> OnPrivateChatDataRequest()
{ {
if (!_modelManager.Chat.AllChatRooms.Any()) if (!_modelManager.Chat.AllChatRooms.Any())
{ {
@ -31,7 +31,7 @@ internal class ChatController : Controller
} }
[NetEvent(MessageId.PrivateChatRequest)] [NetEvent(MessageId.PrivateChatRequest)]
public async Task<ResponseMessage> OnPrivateChatRequest(PrivateChatRequest request, ChatCommandManager chatCommandManager) public async Task<RpcResult> OnPrivateChatRequest(PrivateChatRequest request, ChatCommandManager chatCommandManager)
{ {
ChatRoom chatRoom = _modelManager.Chat.GetChatRoom(1338); ChatRoom chatRoom = _modelManager.Chat.GetChatRoom(1338);
@ -54,7 +54,7 @@ internal class ChatController : Controller
} }
[NetEvent(MessageId.PrivateChatOperateRequest)] [NetEvent(MessageId.PrivateChatOperateRequest)]
public ResponseMessage OnPrivateChatOperateRequest() => Response(MessageId.PrivateChatOperateResponse, new PrivateChatOperateResponse()); public RpcResult OnPrivateChatOperateRequest() => Response(MessageId.PrivateChatOperateResponse, new PrivateChatOperateResponse());
private async Task PushPrivateChatHistory() private async Task PushPrivateChatHistory()
{ {

View file

@ -13,7 +13,7 @@ internal class CombatMessageController : Controller
} }
[NetEvent(MessageId.CombatSendPackRequest)] // TODO: CombatSendPackRequest is important [NetEvent(MessageId.CombatSendPackRequest)] // TODO: CombatSendPackRequest is important
public async Task<ResponseMessage> OnCombatSendPackRequest(CombatSendPackRequest request, CombatManager combatManager) public async Task<RpcResult> OnCombatSendPackRequest(CombatSendPackRequest request, CombatManager combatManager)
{ {
CombatReceivePackNotify combatPackNotify = new(); CombatReceivePackNotify combatPackNotify = new();

View file

@ -1,4 +1,5 @@
using GameServer.Network; global using GameServer.Controllers.Result;
using GameServer.Network;
using GameServer.Network.Messages; using GameServer.Network.Messages;
using Google.Protobuf; using Google.Protobuf;
using Protocol; using Protocol;
@ -13,9 +14,9 @@ internal abstract class Controller
Session = session; Session = session;
} }
protected static ResponseMessage Response<TProtoBuf>(MessageId messageId, TProtoBuf protoBuf) where TProtoBuf : IMessage<TProtoBuf> => new() protected static RpcResult Response<TProtoBuf>(MessageId messageId, TProtoBuf protoBuf) where TProtoBuf : IMessage<TProtoBuf> => new(new ResponseMessage
{ {
MessageId = messageId, MessageId = messageId,
Payload = protoBuf.ToByteArray() Payload = protoBuf.ToByteArray()
}; });
} }

View file

@ -42,7 +42,7 @@ internal class CreatureController : Controller
} }
[NetEvent(MessageId.EntityActiveRequest)] [NetEvent(MessageId.EntityActiveRequest)]
public async Task<ResponseMessage> OnEntityActiveRequest(EntityActiveRequest request) public async Task<RpcResult> OnEntityActiveRequest(EntityActiveRequest request)
{ {
EntityActiveResponse response; EntityActiveResponse response;
@ -68,7 +68,7 @@ internal class CreatureController : Controller
} }
[NetEvent(MessageId.SceneLoadingFinishRequest)] [NetEvent(MessageId.SceneLoadingFinishRequest)]
public async Task<ResponseMessage> OnSceneLoadingFinishRequest() public async Task<RpcResult> OnSceneLoadingFinishRequest()
{ {
_modelManager.Creature.OnWorldDone(); _modelManager.Creature.OnWorldDone();
await UpdateAiHate(); await UpdateAiHate();

View file

@ -12,8 +12,8 @@ internal class DailyActivityController : Controller
} }
[NetEvent(MessageId.ActivityRequest)] [NetEvent(MessageId.ActivityRequest)]
public ResponseMessage OnActivityRequest() => Response(MessageId.ActivityResponse, new ActivityResponse()); public RpcResult OnActivityRequest() => Response(MessageId.ActivityResponse, new ActivityResponse());
[NetEvent(MessageId.LivenessRequest)] [NetEvent(MessageId.LivenessRequest)]
public ResponseMessage OnLivenessRequest() => Response(MessageId.LivenessResponse, new LivenessResponse()); public RpcResult OnLivenessRequest() => Response(MessageId.LivenessResponse, new LivenessResponse());
} }

View file

@ -12,5 +12,5 @@ internal class ExchangeRewardController : Controller
} }
[NetEvent(MessageId.ExchangeRewardInfoRequest)] [NetEvent(MessageId.ExchangeRewardInfoRequest)]
public ResponseMessage OnExchangeRewardInfoRequest() => Response(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse()); public RpcResult OnExchangeRewardInfoRequest() => Response(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse());
} }

View file

@ -15,7 +15,7 @@ internal class ExploreProgressController : Controller
} }
[NetEvent(MessageId.ExploreProgressRequest)] [NetEvent(MessageId.ExploreProgressRequest)]
public ResponseMessage OnExploreProgressRequest() public RpcResult OnExploreProgressRequest()
{ {
return Response(MessageId.ExploreProgressResponse, new ExploreProgressResponse return Response(MessageId.ExploreProgressResponse, new ExploreProgressResponse
{ {

View file

@ -90,13 +90,13 @@ internal class EventHandlerFactory
var builder = ImmutableDictionary.CreateBuilder<MessageId, RpcHandler>(); var builder = ImmutableDictionary.CreateBuilder<MessageId, RpcHandler>();
MethodInfo getServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetRequiredService), [typeof(IServiceProvider)])!; MethodInfo getServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetRequiredService), [typeof(IServiceProvider)])!;
MethodInfo taskFromResultMethod = typeof(Task).GetMethod(nameof(Task.FromResult))!.MakeGenericMethod(typeof(ResponseMessage)); MethodInfo taskFromResultMethod = typeof(Task).GetMethod(nameof(Task.FromResult))!.MakeGenericMethod(typeof(RpcResult));
foreach (Type type in controllerTypes) foreach (Type type in controllerTypes)
{ {
IEnumerable<MethodInfo> methods = type.GetMethods() IEnumerable<MethodInfo> methods = type.GetMethods()
.Where(method => method.GetCustomAttribute<NetEventAttribute>() != null .Where(method => method.GetCustomAttribute<NetEventAttribute>() != null
&& (method.ReturnType == typeof(Task<ResponseMessage>) || method.ReturnType == typeof(ResponseMessage))); && (method.ReturnType == typeof(Task<RpcResult>) || method.ReturnType == typeof(RpcResult)));
foreach (MethodInfo method in methods) foreach (MethodInfo method in methods)
{ {
@ -108,7 +108,7 @@ internal class EventHandlerFactory
MethodCallExpression getServiceCall = Expression.Call(getServiceMethod.MakeGenericMethod(type), serviceProviderParam); MethodCallExpression getServiceCall = Expression.Call(getServiceMethod.MakeGenericMethod(type), serviceProviderParam);
Expression handlerCall = Expression.Call(getServiceCall, method, FetchArgumentsForMethod(method, serviceProviderParam, getServiceMethod, dataParam)); Expression handlerCall = Expression.Call(getServiceCall, method, FetchArgumentsForMethod(method, serviceProviderParam, getServiceMethod, dataParam));
if (method.ReturnType == typeof(ResponseMessage)) // Allow non-async methods as well if (method.ReturnType == typeof(RpcResult)) // Allow non-async methods as well
handlerCall = Expression.Call(taskFromResultMethod, handlerCall); handlerCall = Expression.Call(taskFromResultMethod, handlerCall);
Expression<RpcHandler> lambda = Expression.Lambda<RpcHandler>(handlerCall, serviceProviderParam, dataParam); Expression<RpcHandler> lambda = Expression.Lambda<RpcHandler>(handlerCall, serviceProviderParam, dataParam);

View file

@ -12,8 +12,8 @@ internal class FormationAttributeController : Controller
} }
[NetEvent(MessageId.TimeCheckRequest)] [NetEvent(MessageId.TimeCheckRequest)]
public ResponseMessage OnTimeCheckRequest() => Response(MessageId.TimeCheckResponse, new TimeCheckResponse()); public RpcResult OnTimeCheckRequest() => Response(MessageId.TimeCheckResponse, new TimeCheckResponse());
[NetEvent(MessageId.FormationAttrRequest)] [NetEvent(MessageId.FormationAttrRequest)]
public ResponseMessage OnFormationAttrRequest() => Response(MessageId.FormationAttrResponse, new FormationAttrResponse()); public RpcResult OnFormationAttrRequest() => Response(MessageId.FormationAttrResponse, new FormationAttrResponse());
} }

View file

@ -17,7 +17,7 @@ internal class FormationController : Controller
} }
[NetEvent(MessageId.GetFormationDataRequest)] [NetEvent(MessageId.GetFormationDataRequest)]
public ResponseMessage OnGetFormationDataRequest() => Response(MessageId.GetFormationDataResponse, new GetFormationDataResponse public RpcResult OnGetFormationDataRequest() => Response(MessageId.GetFormationDataResponse, new GetFormationDataResponse
{ {
Formations = Formations =
{ {
@ -32,7 +32,7 @@ internal class FormationController : Controller
}); });
[NetEvent(MessageId.UpdateFormationRequest)] [NetEvent(MessageId.UpdateFormationRequest)]
public async Task<ResponseMessage> OnUpdateFormationRequest(UpdateFormationRequest request, EventSystem eventSystem) public async Task<RpcResult> OnUpdateFormationRequest(UpdateFormationRequest request, EventSystem eventSystem)
{ {
_modelManager.Formation.Set([.. request.Formation.RoleIds]); _modelManager.Formation.Set([.. request.Formation.RoleIds]);
await eventSystem.Emit(GameEventType.FormationUpdated); await eventSystem.Emit(GameEventType.FormationUpdated);

View file

@ -12,7 +12,7 @@ internal class FriendSystemController : Controller
} }
[NetEvent(MessageId.FriendAllRequest)] [NetEvent(MessageId.FriendAllRequest)]
public ResponseMessage OnFriendAllRequest() => Response(MessageId.FriendAllResponse, new FriendAllResponse public RpcResult OnFriendAllRequest() => Response(MessageId.FriendAllResponse, new FriendAllResponse
{ {
FriendInfoList = FriendInfoList =
{ {

View file

@ -12,5 +12,5 @@ internal class GachaController : Controller
} }
[NetEvent(MessageId.GachaInfoRequest)] [NetEvent(MessageId.GachaInfoRequest)]
public ResponseMessage OnGachaInfoRequest() => Response(MessageId.GachaInfoResponse, new GachaInfoResponse()); public RpcResult OnGachaInfoRequest() => Response(MessageId.GachaInfoResponse, new GachaInfoResponse());
} }

View file

@ -12,5 +12,5 @@ internal class InfluenceReputationController : Controller
} }
[NetEvent(MessageId.InfluenceInfoRequest)] [NetEvent(MessageId.InfluenceInfoRequest)]
public ResponseMessage OnInfluenceInfoRequest() => Response(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse()); public RpcResult OnInfluenceInfoRequest() => Response(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse());
} }

View file

@ -12,14 +12,14 @@ internal class InventoryController : Controller
} }
[NetEvent(MessageId.NormalItemRequest)] [NetEvent(MessageId.NormalItemRequest)]
public ResponseMessage OnNormalItemRequest() => Response(MessageId.NormalItemResponse, new NormalItemResponse()); public RpcResult OnNormalItemRequest() => Response(MessageId.NormalItemResponse, new NormalItemResponse());
[NetEvent(MessageId.WeaponItemRequest)] [NetEvent(MessageId.WeaponItemRequest)]
public ResponseMessage OnWeaponItemRequest() => Response(MessageId.WeaponItemResponse, new WeaponItemResponse()); public RpcResult OnWeaponItemRequest() => Response(MessageId.WeaponItemResponse, new WeaponItemResponse());
[NetEvent(MessageId.PhantomItemRequest)] [NetEvent(MessageId.PhantomItemRequest)]
public ResponseMessage OnPhantomItemRequest() => Response(MessageId.PhantomItemResponse, new PhantomItemResponse()); public RpcResult OnPhantomItemRequest() => Response(MessageId.PhantomItemResponse, new PhantomItemResponse());
[NetEvent(MessageId.ItemExchangeInfoRequest)] [NetEvent(MessageId.ItemExchangeInfoRequest)]
public ResponseMessage OnItemExchangeInfoRequest() => Response(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse()); public RpcResult OnItemExchangeInfoRequest() => Response(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse());
} }

View file

@ -1,8 +1,6 @@
using GameServer.Controllers.Attributes; using GameServer.Controllers.Attributes;
using GameServer.Network; using GameServer.Network;
using GameServer.Network.Messages;
using GameServer.Systems.Event; using GameServer.Systems.Event;
using Microsoft.Extensions.Logging;
using Protocol; using Protocol;
namespace GameServer.Controllers; namespace GameServer.Controllers;
@ -14,7 +12,7 @@ internal class LoginController : Controller
} }
[NetEvent(MessageId.LoginRequest)] [NetEvent(MessageId.LoginRequest)]
public async Task<ResponseMessage> OnLoginRequest(EventSystem eventSystem) public async Task<RpcResult> OnLoginRequest(EventSystem eventSystem)
{ {
await eventSystem.Emit(GameEventType.Login); await eventSystem.Emit(GameEventType.Login);
@ -27,16 +25,19 @@ internal class LoginController : Controller
} }
[NetEvent(MessageId.EnterGameRequest)] [NetEvent(MessageId.EnterGameRequest)]
public async Task<ResponseMessage> OnEnterGameRequest(EnterGameRequest request, ILogger<LoginController> logger, EventSystem eventSystem) public RpcResult OnEnterGameRequest()
{ {
logger.LogInformation("Enter Game Request:\n{req}", request); return Response(MessageId.EnterGameResponse, new EnterGameResponse())
.AddPostEvent(GameEventType.EnterGame)
.AddPostEvent(GameEventType.PushDataDone);
}
await eventSystem.Emit(GameEventType.EnterGame); [GameEvent(GameEventType.PushDataDone)]
public async Task OnPushDataDone()
{
await Session.Push(MessageId.PushDataCompleteNotify, new PushDataCompleteNotify()); await Session.Push(MessageId.PushDataCompleteNotify, new PushDataCompleteNotify());
return Response(MessageId.EnterGameResponse, new EnterGameResponse());
} }
[NetEvent(MessageId.HeartbeatRequest)] [NetEvent(MessageId.HeartbeatRequest)]
public ResponseMessage OnHeartbeatRequest() => Response(MessageId.HeartbeatResponse, new HeartbeatResponse()); public RpcResult OnHeartbeatRequest() => Response(MessageId.HeartbeatResponse, new HeartbeatResponse());
} }

View file

@ -12,5 +12,5 @@ internal class LordGymController : Controller
} }
[NetEvent(MessageId.LordGymInfoRequest)] [NetEvent(MessageId.LordGymInfoRequest)]
public ResponseMessage OnLordGymInfoRequest() => Response(MessageId.LordGymInfoResponse, new LordGymInfoResponse()); public RpcResult OnLordGymInfoRequest() => Response(MessageId.LordGymInfoResponse, new LordGymInfoResponse());
} }

View file

@ -42,6 +42,12 @@ internal class PlayerInfoController : Controller
Key = (int)PlayerAttrKey.HeadPhoto, Key = (int)PlayerAttrKey.HeadPhoto,
ValueType = (int)PlayerAttrType.Int32, ValueType = (int)PlayerAttrType.Int32,
Int32Value = 1402 Int32Value = 1402
},
new PlayerAttr
{
Key = (int)PlayerAttrKey.Sex,
ValueType = (int)PlayerAttrType.Int32,
Int32Value = 1
} }
}, },
RoleShowList = RoleShowList =
@ -67,7 +73,7 @@ internal class PlayerInfoController : Controller
} }
[NetEvent(MessageId.PlayerBasicInfoGetRequest)] [NetEvent(MessageId.PlayerBasicInfoGetRequest)]
public ResponseMessage OnPlayerBasicInfoGetRequest() public RpcResult OnPlayerBasicInfoGetRequest()
{ {
return Response(MessageId.PlayerBasicInfoGetResponse, new PlayerBasicInfoGetResponse return Response(MessageId.PlayerBasicInfoGetResponse, new PlayerBasicInfoGetResponse
{ {

View file

@ -0,0 +1,21 @@
using GameServer.Network.Messages;
using GameServer.Systems.Event;
namespace GameServer.Controllers.Result;
internal class RpcResult
{
public ResponseMessage Response { get; }
public List<GameEventType> PostEvents { get; }
public RpcResult(ResponseMessage response)
{
Response = response;
PostEvents = [];
}
public RpcResult AddPostEvent(GameEventType type)
{
PostEvents.Add(type);
return this;
}
}

View file

@ -12,5 +12,5 @@ internal class RoguelikeController : Controller
} }
[NetEvent(MessageId.RoguelikeSeasonDataRequest)] [NetEvent(MessageId.RoguelikeSeasonDataRequest)]
public ResponseMessage OnRoguelikeSeasonDataRequest() => Response(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse()); public RpcResult OnRoguelikeSeasonDataRequest() => Response(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse());
} }

View file

@ -36,7 +36,7 @@ internal class RoleController : Controller
} }
[NetEvent(MessageId.SwitchRoleRequest)] [NetEvent(MessageId.SwitchRoleRequest)]
public async Task<ResponseMessage> OnSwitchRoleRequest(SwitchRoleRequest request, CreatureController creatureController) public async Task<RpcResult> OnSwitchRoleRequest(SwitchRoleRequest request, CreatureController creatureController)
{ {
await creatureController.SwitchPlayerEntity(request.RoleId); await creatureController.SwitchPlayerEntity(request.RoleId);
return Response(MessageId.SwitchRoleResponse, new SwitchRoleResponse return Response(MessageId.SwitchRoleResponse, new SwitchRoleResponse
@ -46,7 +46,7 @@ internal class RoleController : Controller
} }
[NetEvent(MessageId.RoleFavorListRequest)] [NetEvent(MessageId.RoleFavorListRequest)]
public ResponseMessage OnRoleFavorListRequest() => Response(MessageId.RoleFavorListResponse, new RoleFavorListResponse()); public RpcResult OnRoleFavorListRequest() => Response(MessageId.RoleFavorListResponse, new RoleFavorListResponse());
private static List<ArrayIntInt> CreateBasePropList(BasePropertyConfig? config) private static List<ArrayIntInt> CreateBasePropList(BasePropertyConfig? config)
{ {

View file

@ -41,7 +41,7 @@ internal class RouletteController : Controller
} }
[NetEvent(MessageId.VisionExploreSkillSetRequest)] [NetEvent(MessageId.VisionExploreSkillSetRequest)]
public async Task<ResponseMessage> OnVisionExploreSkillSetRequest(VisionExploreSkillSetRequest request, CreatureController creatureController, EventSystem eventSystem) public async Task<RpcResult> OnVisionExploreSkillSetRequest(VisionExploreSkillSetRequest request, CreatureController creatureController, EventSystem eventSystem)
{ {
PlayerEntity? playerEntity = creatureController.GetPlayerEntity(); PlayerEntity? playerEntity = creatureController.GetPlayerEntity();
if (playerEntity == null) return Response(MessageId.VisionExploreSkillSetResponse, new VisionExploreSkillSetResponse { ErrCode = (int)ErrorCode.PlayerNotInAnyScene }); if (playerEntity == null) return Response(MessageId.VisionExploreSkillSetResponse, new VisionExploreSkillSetResponse { ErrCode = (int)ErrorCode.PlayerNotInAnyScene });

View file

@ -12,5 +12,5 @@ internal class ShopController : Controller
} }
[NetEvent(MessageId.PayShopInfoRequest)] [NetEvent(MessageId.PayShopInfoRequest)]
public ResponseMessage OnPayShopInfoRequest() => Response(MessageId.PayShopInfoResponse, new PayShopInfoResponse()); public RpcResult OnPayShopInfoRequest() => Response(MessageId.PayShopInfoResponse, new PayShopInfoResponse());
} }

View file

@ -12,8 +12,8 @@ internal class TeleportController : Controller
} }
[NetEvent(MessageId.TeleportFinishRequest)] [NetEvent(MessageId.TeleportFinishRequest)]
public ResponseMessage OnTeleportFinishRequest() => Response(MessageId.TeleportFinishResponse, new TeleportFinishResponse()); public RpcResult OnTeleportFinishRequest() => Response(MessageId.TeleportFinishResponse, new TeleportFinishResponse());
[NetEvent(MessageId.TeleportDataRequest)] [NetEvent(MessageId.TeleportDataRequest)]
public ResponseMessage OnTeleportDataRequest() => Response(MessageId.TeleportDataResponse, new TeleportDataResponse()); public RpcResult OnTeleportDataRequest() => Response(MessageId.TeleportDataResponse, new TeleportDataResponse());
} }

View file

@ -12,8 +12,8 @@ internal class TowerController : Controller
} }
[NetEvent(MessageId.TowerChallengeRequest)] [NetEvent(MessageId.TowerChallengeRequest)]
public ResponseMessage OnTowerChallengeRequest() => Response(MessageId.TowerChallengeResponse, new TowerChallengeResponse()); public RpcResult OnTowerChallengeRequest() => Response(MessageId.TowerChallengeResponse, new TowerChallengeResponse());
[NetEvent(MessageId.CycleTowerChallengeRequest)] [NetEvent(MessageId.CycleTowerChallengeRequest)]
public ResponseMessage OnCycleTowerChallengeRequest() => Response(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse()); public RpcResult OnCycleTowerChallengeRequest() => Response(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse());
} }

View file

@ -12,7 +12,7 @@ internal class TutorialController : Controller
} }
[NetEvent(MessageId.TutorialInfoRequest)] [NetEvent(MessageId.TutorialInfoRequest)]
public ResponseMessage OnTutorialInfoRequest() public RpcResult OnTutorialInfoRequest()
{ {
int[] tutorials = [30001, 30002, 30003, 30004, 30005, 30006, 30007, 30011, 30012, 30008, 30009, 30010, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, 30023, 30024, 40001, 30025, 30026, 30027, 30028, 30029, 30030, 30031, 30032, 30033, 30034, 30035, 30036, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 33001, 34017, 34018, 32001, 32002, 32003, 32004, 32005, 32006, 32007, 32008, 32009, 32010, 32011, 32012, 32013, 32014, 32015, 32016, 32017, 32018, 32019, 32020, 32021, 33002, 33003, 33004, 33005, 34001, 34002, 34003, 34004, 34005, 34006, 34007, 34008, 34009, 34010, 34011, 34012, 34013, 34014, 34015, 34016, 34019, 34020, 34021, 34022, 34023, 34024, 34025, 34027, 34028, 34029, 34030, 34031, 34032, 34033]; int[] tutorials = [30001, 30002, 30003, 30004, 30005, 30006, 30007, 30011, 30012, 30008, 30009, 30010, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, 30023, 30024, 40001, 30025, 30026, 30027, 30028, 30029, 30030, 30031, 30032, 30033, 30034, 30035, 30036, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 33001, 34017, 34018, 32001, 32002, 32003, 32004, 32005, 32006, 32007, 32008, 32009, 32010, 32011, 32012, 32013, 32014, 32015, 32016, 32017, 32018, 32019, 32020, 32021, 33002, 33003, 33004, 33005, 34001, 34002, 34003, 34004, 34005, 34006, 34007, 34008, 34009, 34010, 34011, 34012, 34013, 34014, 34015, 34016, 34019, 34020, 34021, 34022, 34023, 34024, 34025, 34027, 34028, 34029, 34030, 34031, 34032, 34033];
TutorialInfoResponse rsp = new(); TutorialInfoResponse rsp = new();
@ -30,7 +30,7 @@ internal class TutorialController : Controller
} }
[NetEvent(MessageId.GetDetectionLabelInfoRequest)] [NetEvent(MessageId.GetDetectionLabelInfoRequest)]
public ResponseMessage OnGetDetectionLabelInfoRequest() public RpcResult OnGetDetectionLabelInfoRequest()
{ {
int[] guides = [0, 1, 2, 3, 14, 15, 16, 4, 21, 22, 7, 5, 18, 6, 61, 8, 9, 10, 11, 12, 13, 17, 19]; int[] guides = [0, 1, 2, 3, 14, 15, 16, 4, 21, 22, 7, 5, 18, 6, 61, 8, 9, 10, 11, 12, 13, 17, 19];
int[] detectionTexts = [1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 61]; int[] detectionTexts = [1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 61];
@ -43,7 +43,7 @@ internal class TutorialController : Controller
} }
[NetEvent(MessageId.GuideInfoRequest)] [NetEvent(MessageId.GuideInfoRequest)]
public ResponseMessage OnGuideInfoRequest() => Response(MessageId.GuideInfoResponse, new GuideInfoResponse() public RpcResult OnGuideInfoRequest() => Response(MessageId.GuideInfoResponse, new GuideInfoResponse()
{ {
GuideGroupFinishList = { 60001, 60002, 60003, 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60013, 60014, 60015, 60016, 60017, 60018, 60019, 60020, 60021, 60101, 60102, 60103, 62002, 62004, 62005, 62006, 62007, 62009, 62010, 62011, 62012, 62013, 62014, 62015, 62016, 62017, 62022, 62027, 62028, 62029, 62030, 62031, 62032, 62033, 62034, 62036, 65001, 67001, 67002, 67003, 67004, 67005, 67006, 67007, 67008, 67009, 67010, 67011, 67012, 67013, 67014, 67015, 67016, 67017, 67018, 67019, 67022, 62001, 62008, 62018, 62019, 62020, 62021, 62023, 62024, 62025, 62026, 62035, 65002, 65003, 65004, 65005 } GuideGroupFinishList = { 60001, 60002, 60003, 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60013, 60014, 60015, 60016, 60017, 60018, 60019, 60020, 60021, 60101, 60102, 60103, 62002, 62004, 62005, 62006, 62007, 62009, 62010, 62011, 62012, 62013, 62014, 62015, 62016, 62017, 62022, 62027, 62028, 62029, 62030, 62031, 62032, 62033, 62034, 62036, 65001, 67001, 67002, 67003, 67004, 67005, 67006, 67007, 67008, 67009, 67010, 67011, 67012, 67013, 67014, 67015, 67016, 67017, 67018, 67019, 67022, 62001, 62008, 62018, 62019, 62020, 62021, 62023, 62024, 62025, 62026, 62035, 65002, 65003, 65004, 65005 }
}); });

View file

@ -19,14 +19,14 @@ internal class WorldController : Controller
} }
[NetEvent(MessageId.EntityOnLandedRequest)] [NetEvent(MessageId.EntityOnLandedRequest)]
public ResponseMessage OnEntityOnLandedRequest() => Response(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse()); public RpcResult OnEntityOnLandedRequest() => Response(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse());
[NetEvent(MessageId.PlayerMotionRequest)] [NetEvent(MessageId.PlayerMotionRequest)]
public ResponseMessage OnPlayerMotionRequest() => Response(MessageId.PlayerMotionResponse, new PlayerMotionResponse()); public RpcResult OnPlayerMotionRequest() => Response(MessageId.PlayerMotionResponse, new PlayerMotionResponse());
[NetEvent(MessageId.EntityLoadCompleteRequest)] [NetEvent(MessageId.EntityLoadCompleteRequest)]
public ResponseMessage OnEntityLoadCompleteRequest() => Response(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse()); public RpcResult OnEntityLoadCompleteRequest() => Response(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse());
[NetEvent(MessageId.UpdateSceneDateRequest)] [NetEvent(MessageId.UpdateSceneDateRequest)]
public ResponseMessage OnUpdateSceneDateRequest() => Response(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse()); public RpcResult OnUpdateSceneDateRequest() => Response(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse());
} }

View file

@ -15,20 +15,20 @@ internal class WorldMapController : Controller
} }
[NetEvent(MessageId.MapTraceInfoRequest)] [NetEvent(MessageId.MapTraceInfoRequest)]
public ResponseMessage OnMapTraceInfoRequest() => Response(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse() public RpcResult OnMapTraceInfoRequest() => Response(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse()
{ {
// Don't. // Don't.
//MarkIdList = { 1, 2, 3, 1000, 1001, 1002, 1003, 1004, 1005, 1007, 1008, 1009, 3000, 3002, 3003, 3005, 3010, 3011, 3012, 4020, 4021, 4022, 4023, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5021, 5022, 5023, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 380000, 380002, 380003, 380004, 380006, 380007, 380015, 301203, 380013, 380014, 301204, 300201, 300202, 300203, 300301, 300302, 300303, 300304, 300306, 300309, 300310, 300311, 300312, 300313, 300401, 300402, 300403, 300404, 300405, 300406, 300407, 300408, 300410, 300413, 300501, 300502, 300506, 300507, 300508, 300509, 300510, 300511, 300601, 300603, 300604, 300605, 300606, 300607, 300608, 300701, 300703, 300704, 300707, 300708, 300711, 300712, 300713, 300901, 300902, 300911, 300912, 300914, 300915, 300918, 301001, 301003, 301004, 301005, 301006, 301007, 301008, 301009, 301010, 301012, 301013, 301014, 301015, 10000, 10001, 10002, 10003, 10005, 10006, 300801, 301201, 300412, 3015, 3016, 3017, 300411 } //MarkIdList = { 1, 2, 3, 1000, 1001, 1002, 1003, 1004, 1005, 1007, 1008, 1009, 3000, 3002, 3003, 3005, 3010, 3011, 3012, 4020, 4021, 4022, 4023, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5021, 5022, 5023, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 380000, 380002, 380003, 380004, 380006, 380007, 380015, 301203, 380013, 380014, 301204, 300201, 300202, 300203, 300301, 300302, 300303, 300304, 300306, 300309, 300310, 300311, 300312, 300313, 300401, 300402, 300403, 300404, 300405, 300406, 300407, 300408, 300410, 300413, 300501, 300502, 300506, 300507, 300508, 300509, 300510, 300511, 300601, 300603, 300604, 300605, 300606, 300607, 300608, 300701, 300703, 300704, 300707, 300708, 300711, 300712, 300713, 300901, 300902, 300911, 300912, 300914, 300915, 300918, 301001, 301003, 301004, 301005, 301006, 301007, 301008, 301009, 301010, 301012, 301013, 301014, 301015, 10000, 10001, 10002, 10003, 10005, 10006, 300801, 301201, 300412, 3015, 3016, 3017, 300411 }
}); });
[NetEvent(MessageId.MapUnlockFieldInfoRequest)] [NetEvent(MessageId.MapUnlockFieldInfoRequest)]
public ResponseMessage OnMapUnlockFieldInfoRequest() => Response(MessageId.MapUnlockFieldInfoResponse, new MapUnlockFieldInfoResponse public RpcResult OnMapUnlockFieldInfoRequest() => Response(MessageId.MapUnlockFieldInfoResponse, new MapUnlockFieldInfoResponse
{ {
FieldId = { Enumerable.Range(1, 12) } FieldId = { Enumerable.Range(1, 12) }
}); });
[NetEvent(MessageId.MapMarkRequest)] [NetEvent(MessageId.MapMarkRequest)]
public async Task<ResponseMessage> OnMapMarkRequest(MapMarkRequest request, IOptions<GameplayFeatureSettings> gameplayFeatures, CreatureController creatureController) public async Task<RpcResult> OnMapMarkRequest(MapMarkRequest request, IOptions<GameplayFeatureSettings> gameplayFeatures, CreatureController creatureController)
{ {
if (gameplayFeatures.Value.TeleportByMapMark) if (gameplayFeatures.Value.TeleportByMapMark)
{ {

View file

@ -4,7 +4,7 @@ using Protocol;
namespace GameServer.Network.Messages; namespace GameServer.Network.Messages;
internal delegate Task PushHandler(IServiceProvider serviceProvider, ReadOnlySpan<byte> data); internal delegate Task PushHandler(IServiceProvider serviceProvider, ReadOnlySpan<byte> data);
internal delegate Task<ResponseMessage> RpcHandler(IServiceProvider serviceProvider, ReadOnlySpan<byte> data); internal delegate Task<RpcResult> RpcHandler(IServiceProvider serviceProvider, ReadOnlySpan<byte> data);
internal class MessageManager internal class MessageManager
{ {
private readonly EventHandlerFactory _handlerFactory; private readonly EventHandlerFactory _handlerFactory;
@ -16,7 +16,7 @@ internal class MessageManager
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public async Task<ResponseMessage?> ExecuteRpc(MessageId messageId, ReadOnlyMemory<byte> data) public async Task<RpcResult?> ExecuteRpc(MessageId messageId, ReadOnlyMemory<byte> data)
{ {
RpcHandler? handler = _handlerFactory.GetRpcHandler(messageId); RpcHandler? handler = _handlerFactory.GetRpcHandler(messageId);
if (handler != null) if (handler != null)

View file

@ -1,4 +1,5 @@
using GameServer.Network.Messages; using GameServer.Network.Messages;
using GameServer.Systems.Event;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace GameServer.Network.Rpc; namespace GameServer.Network.Rpc;
@ -7,26 +8,33 @@ internal class RpcManager
private readonly IRpcEndPoint _endPoint; private readonly IRpcEndPoint _endPoint;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly MessageManager _messageManager; private readonly MessageManager _messageManager;
private readonly EventSystem _eventSystem;
public RpcManager(MessageManager messageManager, IRpcEndPoint endPoint, ILogger<RpcManager> logger) public RpcManager(MessageManager messageManager, IRpcEndPoint endPoint, ILogger<RpcManager> logger, EventSystem eventSystem)
{ {
_endPoint = endPoint; _endPoint = endPoint;
_logger = logger; _logger = logger;
_messageManager = messageManager; _messageManager = messageManager;
_eventSystem = eventSystem;
} }
public async Task Execute(RequestMessage request) public async Task Execute(RequestMessage request)
{ {
ResponseMessage? response = await _messageManager.ExecuteRpc(request.MessageId, request.Payload); RpcResult? result = await _messageManager.ExecuteRpc(request.MessageId, request.Payload);
if (response == null) if (result == null)
{ {
_logger.LogWarning("Rpc was not handled properly (message: {msg_id}, id: {rpc_id})", request.MessageId, request.RpcID); _logger.LogWarning("Rpc was not handled properly (message: {msg_id}, id: {rpc_id})", request.MessageId, request.RpcID);
return; return;
} }
response.RpcID = request.RpcID; result.Response.RpcID = request.RpcID;
await _endPoint.SendRpcResult(response); await _endPoint.SendRpcResult(result.Response);
_logger.LogInformation("Rpc with id {rpc_id} was handled, return message: {msg_id}", request.RpcID, response.MessageId); foreach (GameEventType postEvent in result.PostEvents)
{
await _eventSystem.Emit(postEvent);
}
_logger.LogInformation("Rpc with id {rpc_id} was handled, return message: {msg_id}", request.RpcID, result.Response.MessageId);
} }
} }

View file

@ -25,7 +25,7 @@ internal static class Program
private static async Task Main(string[] args) private static async Task Main(string[] args)
{ {
Console.Title = "Wuthering Waves | Game Server"; Console.Title = "Wuthering Waves | Game Server";
Console.WriteLine(" __ __ __ .__ .__ __ __ \r\n/ \\ / \\__ ___/ |_| |__ ___________|__| ____ ____ / \\ / \\_____ ___ __ ____ ______\r\n\\ \\/\\/ / | \\ __\\ | \\_/ __ \\_ __ \\ |/ \\ / ___\\ \\ \\/\\/ /\\__ \\\\ \\/ // __ \\ / ___/\r\n \\ /| | /| | | Y \\ ___/| | \\/ | | \\/ /_/ > \\ / / __ \\\\ /\\ ___/ \\___ \\ \r\n \\__/\\ / |____/ |__| |___| /\\___ >__| |__|___| /\\___ / \\__/\\ / (____ /\\_/ \\___ >____ >\r\n \\/ \\/ \\/ \\//_____/ \\/ \\/ \\/ \\/ \n"); Console.WriteLine(" __ __ __ .__ .__ __ __ \r\n/ \\ / \\__ ___/ |_| |__ ___________|__| ____ ____ / \\ / \\_____ ___ __ ____ ______\r\n\\ \\/\\/ / | \\ __\\ | \\_/ __ \\_ __ \\ |/ \\ / ___\\ \\ \\/\\/ /\\__ \\\\ \\/ // __ \\ / ___/\r\n \\ /| | /| | | Y \\ ___/| | \\/ | | \\/ /_/ > \\ / / __ \\\\ /\\ ___/ \\___ \\ \r\n \\__/\\ / |____/ |__| |___| /\\___ >__| |__|___| /\\___ / \\__/\\ / (____ /\\_/ \\___ >____ >\r\n \\/ \\/ \\/ \\//_____/ \\/ \\/ \\/ \\/ \r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\tGame Server\n");
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddConsole(); builder.Logging.AddConsole();

View file

@ -3,6 +3,7 @@ internal enum GameEventType
{ {
Login = 1, Login = 1,
EnterGame, EnterGame,
PushDataDone,
// Actions // Actions
FormationUpdated, FormationUpdated,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 199 KiB

View file

@ -1,4 +1,3 @@
using Microsoft.AspNetCore.Builder;
using SDKServer.Handlers; using SDKServer.Handlers;
using SDKServer.Middleware; using SDKServer.Middleware;
@ -8,11 +7,14 @@ internal static class Program
{ {
private static async Task Main(string[] args) private static async Task Main(string[] args)
{ {
var builder = WebApplication.CreateBuilder(args); Console.Title = "Wuthering Waves | SDK Server";
Console.WriteLine(" __ __ __ .__ .__ __ __ \r\n/ \\ / \\__ ___/ |_| |__ ___________|__| ____ ____ / \\ / \\_____ ___ __ ____ ______\r\n\\ \\/\\/ / | \\ __\\ | \\_/ __ \\_ __ \\ |/ \\ / ___\\ \\ \\/\\/ /\\__ \\\\ \\/ // __ \\ / ___/\r\n \\ /| | /| | | Y \\ ___/| | \\/ | | \\/ /_/ > \\ / / __ \\\\ /\\ ___/ \\___ \\ \r\n \\__/\\ / |____/ |__| |___| /\\___ >__| |__|___| /\\___ / \\__/\\ / (____ /\\_/ \\___ >____ >\r\n \\/ \\/ \\/ \\//_____/ \\/ \\/ \\/ \\/ \r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\tSDK Server\n");
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://*:5500"); builder.WebHost.UseUrls("http://*:5500");
builder.Logging.AddSimpleConsole(); builder.Logging.AddSimpleConsole();
var app = builder.Build(); WebApplication app = builder.Build();
app.UseMiddleware<NotFoundMiddleware>(); app.UseMiddleware<NotFoundMiddleware>();
app.MapGet("/api/login", LoginHandler.Login); app.MapGet("/api/login", LoginHandler.Login);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 199 KiB