From 18414087f3df136d20ca9f7eb8347f7a32540e5b Mon Sep 17 00:00:00 2001 From: AlessandroCH Date: Tue, 13 May 2025 15:12:40 +0200 Subject: [PATCH] moved dispatch cn thing to it's own class --- Campofinale/Game/GameConstants.cs | 20 ++++ Campofinale/Http/Dispatch.cs | 55 +---------- Campofinale/Http/DispatchCN.cs | 91 +++++++++++++++++++ Campofinale/Packets/Cs/HandleCsLogin.cs | 28 +++++- .../Packets/Sc/PacketScSyncCharBagInfo.cs | 5 +- 5 files changed, 145 insertions(+), 54 deletions(-) create mode 100644 Campofinale/Http/DispatchCN.cs diff --git a/Campofinale/Game/GameConstants.cs b/Campofinale/Game/GameConstants.cs index 0f42e40..fa458d8 100644 --- a/Campofinale/Game/GameConstants.cs +++ b/Campofinale/Game/GameConstants.cs @@ -2,9 +2,29 @@ { public static class GameConstants { + //TODO, have to check if this is really userful for support different platform or if android version doesn't need the GAME_VERSION_ASSET_URL (probably not?) + //So, in case is useful only if the android build it's different than 0.5.28 + public static List GAME_VERSIONS = new() + { + new GameVersionConst("0.5.28"), //Windows CBT2 + new GameVersionConst("x.x.xx"), //Android CBT2 + + }; public static string GAME_VERSION = "0.5.28"; //CBT 2 + public static string public static string GAME_VERSION_ASSET_URL = "https://beyond.hg-cdn.com/uXUuLlNbIYmMMTlN/0.5/update/6/1/Windows/0.5.28_U1mgxrslUitdn3hb/files";//CBT 2 public static int MAX_TEAMS_NUMBER = 5; //Not used yet public static (long, string) SERVER_UID = (99, "99"); //Not used yet, no friend chat in current Beta } + public class GameVersionConst + { + public string GAME_VERSION = "0.5.28"; + public string GAME_VERSION_ASSET_URL = "https://beyond.hg-cdn.com/uXUuLlNbIYmMMTlN/0.5/update/6/1/Windows/0.5.28_U1mgxrslUitdn3hb/files";//CBT 2 + public GameVersionConst() { } + + public GameVersionConst(string version) + { + this.GAME_VERSION = version; + } + } } diff --git a/Campofinale/Http/Dispatch.cs b/Campofinale/Http/Dispatch.cs index 3778de7..aa372cd 100644 --- a/Campofinale/Http/Dispatch.cs +++ b/Campofinale/Http/Dispatch.cs @@ -97,17 +97,7 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/network_config")] - public static async Task network_config_cn(HttpContext ctx) - { - string resp = "{\"asset\":\"https://beyond.hg-cdn.com/asset/\",\"hgage\":\"\",\"sdkenv\":\"2\",\"u8root\":\"https://u8.gryphline.com/u8\",\"appcode\":4,\"channel\":\"prod\",\"netlogid\":\"GFz8RRMDN45w\",\"gameclose\":false,\"netlogurl\":\"http://native-log-collect.gryphline.com:32000/\",\"accounturl\":\"https://binding-api-account-prod.gryphline.com\",\"launcherurl\":\"https://launcher.gryphline.com\"}"; - - ctx.Response.StatusCode = 200; - ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/1003/prod-cbt/default/Windows/game_config")] public static async Task game_config(HttpContext ctx) { @@ -119,17 +109,7 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/game_config")] - public static async Task game_config_cn(HttpContext ctx) - { - string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": false, \"enableEntitySpawnLog\": false}"; - - ctx.Response.StatusCode = 200; - ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/gameBulletin/version")] public static async Task Version(HttpContext ctx) { @@ -166,35 +146,8 @@ namespace Campofinale.Http public string password; } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/res_version")] - public static async Task cn_res_version(HttpContext ctx) - { - - string resp = "{\"version\": \"2089329-32\", \"kickFlag\": true}"; - - - ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } - - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/server_config_China")] - public static async Task server_config_China(HttpContext ctx) - { - string requestBody = ctx.Request.DataAsString; - Console.WriteLine(requestBody); - string resp = "{\"addr\": \"" + Server.config.gameServer.accessAddress + "\", \"port\": " + Server.config.gameServer.accessPort + "}"; - - - - ctx.Response.StatusCode = 200; - - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } + + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/1003/prod-cbt/default/default/server_config_EUAndUS")] public static async Task server_config_EUAndUS(HttpContext ctx) { diff --git a/Campofinale/Http/DispatchCN.cs b/Campofinale/Http/DispatchCN.cs new file mode 100644 index 0000000..20e00b5 --- /dev/null +++ b/Campofinale/Http/DispatchCN.cs @@ -0,0 +1,91 @@ +using HttpServerLite; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Campofinale.Http +{ + internal class DispatchCN + { + //SERVER + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/server_config_China")] + public static async Task server_config_China(HttpContext ctx) + { + string requestBody = ctx.Request.DataAsString; + Console.WriteLine(requestBody); + string resp = "{\"addr\": \"" + Server.config.gameServer.accessAddress + "\", \"port\": " + Server.config.gameServer.accessPort + "}"; + + + + ctx.Response.StatusCode = 200; + + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //DEFAULT + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/network_config")] + public static async Task network_config_cn(HttpContext ctx) + { + string resp = "{\"asset\":\"https://beyond.hg-cdn.com/asset/\",\"hgage\":\"\",\"sdkenv\":\"2\",\"u8root\":\"https://u8.gryphline.com/u8\",\"appcode\":4,\"channel\":\"prod\",\"netlogid\":\"GFz8RRMDN45w\",\"gameclose\":false,\"netlogurl\":\"http://native-log-collect.gryphline.com:32000/\",\"accounturl\":\"https://binding-api-account-prod.gryphline.com\",\"launcherurl\":\"https://launcher.gryphline.com\"}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //WINDOWS + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/res_version")] + public static async Task cn_res_version(HttpContext ctx) + { + + string resp = "{\"version\": \"2089329-32\", \"kickFlag\": true}"; + + + ctx.Response.StatusCode = 200; + //ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/game_config")] + public static async Task game_config_cn_windows(HttpContext ctx) + { + string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": true, \"enableEntitySpawnLog\": false}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //ANDROID + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Android/res_version")] + public static async Task cn_android_res_version(HttpContext ctx) + { + + string resp = "{\"version\": \"2332867-572\", \"kickFlag\": true}"; + + + ctx.Response.StatusCode = 200; + //ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Android/game_config")] + public static async Task game_config_cn_android(HttpContext ctx) + { + string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": true, \"enableEntitySpawnLog\": false}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + } +} diff --git a/Campofinale/Packets/Cs/HandleCsLogin.cs b/Campofinale/Packets/Cs/HandleCsLogin.cs index 96307fe..6cf7e6d 100644 --- a/Campofinale/Packets/Cs/HandleCsLogin.cs +++ b/Campofinale/Packets/Cs/HandleCsLogin.cs @@ -186,15 +186,38 @@ namespace Campofinale.Packets.Cs ScSyncAllMission m = Newtonsoft.Json.JsonConvert.DeserializeObject(json1); m.TrackMissionId = ""; + session.Send(ScMsgId.ScSyncAllMission, m); - /*session.Send(ScMsgId.ScSyncAllMission, new ScSyncAllMission() + /* session.Send(ScMsgId.ScSyncAllMission, new ScSyncAllMission() { + NewMissionTags = + { + new NewMissionTag() + { + MissionId="e0m0", + QuestId="e0m0_q#1", + } + }, + Missions = { {"e0m0", new Mission() { MissionId="e0m0", MissionState=(int)MissionState.Processing, + SucceedId=-1, + Properties = + { + {1,new DynamicParameter() + { + RealType=1, + ValueType=1, + ValueBoolList = + { + true + } + } } + } } } }, TrackMissionId = "e0m0", @@ -209,8 +232,9 @@ namespace Campofinale.Packets.Cs { new QuestObjective() { - ConditionId="", + ConditionId="f6415b84", + IsComplete=false } } } } diff --git a/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs b/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs index 4088750..e456948 100644 --- a/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs +++ b/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs @@ -25,7 +25,10 @@ namespace Campofinale.Packets.Sc }, }; - client.chars.ForEach(c => proto.CharInfo.Add(c.ToProto())); + client.chars.ForEach(c => + { + proto.CharInfo.Add(c.ToProto()); + }); client.teams.ForEach(c => { proto.TeamInfo.Add(new CharTeamInfo()