Core/GameEngine/DataToCtl/PackageRegedit.cs
@@ -11,23 +11,24 @@ public static void Init() { // 登记相应的数据体及对应的数据转逻辑类 Register(typeof(H0132_tagCreateRoleSucess), typeof(DTC0132_tagCreateRoleSucess)); Register(typeof(HA326_tagMCNPCIDCollectionCntInfo), typeof(DTCA326_tagMCNPCIDCollectionCntInfo)); Register(typeof(HA904_tagGCDogzNPCRefreshTime), typeof(DTCA904_tagGCDogzNPCRefreshTime)); Register(typeof(HA714_tagMCNPCCntList), typeof(DTCA714_tagMCNPCCntList)); Register(typeof(HAA16_tagMCSuperGiftInfo), typeof(DTCAA16_tagMCSuperGiftInfo)); Register(typeof(HAC10_tagGCAllFamilyBossHurtInfoList), typeof(DTCAC10_tagGCAllFamilyBossHurtInfoList)); Register(typeof(HA715_tagMCFamilyBossHurtList), typeof(DTCA715_tagMCFamilyBossHurtList)); Register(typeof(HAB04_tagMCBossRebornInfo), typeof(DTCAB04_tagMCBossRebornInfo)); Register(typeof(HA40B_tagGCPlayerJoinFamilyWarInfo), typeof(DTCA40B_tagGCPlayerJoinFamilyWarInfo)); Register(typeof(HA319_tagMCPackDownloadRecord), typeof(DTCA319_tagMCPackDownloadRecord)); Register(typeof(HAA16_tagMCSuperGiftInfo), typeof(DTCAA16_tagMCSuperGiftInfo)); Register(typeof(HAC10_tagGCAllFamilyBossHurtInfoList), typeof(DTCAC10_tagGCAllFamilyBossHurtInfoList)); Register(typeof(HA715_tagMCFamilyBossHurtList), typeof(DTCA715_tagMCFamilyBossHurtList)); Register(typeof(HAB04_tagMCBossRebornInfo), typeof(DTCAB04_tagMCBossRebornInfo)); Register(typeof(HA40B_tagGCPlayerJoinFamilyWarInfo), typeof(DTCA40B_tagGCPlayerJoinFamilyWarInfo)); Register(typeof(HA319_tagMCPackDownloadRecord), typeof(DTCA319_tagMCPackDownloadRecord)); Register(typeof(HAC0A_tagGCMultiRealmPointInfo), typeof(DTCAC0A_tagGCMultiRealmPointInfo)); Register(typeof(HAC08_tagGCBossRebornPoint), typeof(DTCAC08_tagGCBossRebornPoint)); Register(typeof(HAB03_tagMCBossRebornPlayerInfo), typeof(DTCAB03_tagMCBossRebornPlayerInfo)); Register(typeof(HAA11_tagMCSpringSaleInfo), typeof(DTCAA11_tagMCSpringSaleInfo)); Register(typeof(HAA10_tagMCCostRebatePlayerInfo), typeof(DTCAA10_tagMCCostRebatePlayerInfo)); Register(typeof(HAA09_tagMCCostRebateInfo), typeof(DTCAA09_tagMCCostRebateInfo)); Register(typeof(HAC06_tagGCMultiExpRateInfo), typeof(DTCAC06_tagGCMultiExpRateInfo)); Register(typeof(HA001_tagBroadCastInfo), typeof(DTCA001_tagBroadCastInfo)); Register(typeof(HAB03_tagMCBossRebornPlayerInfo), typeof(DTCAB03_tagMCBossRebornPlayerInfo)); Register(typeof(HAA11_tagMCSpringSaleInfo), typeof(DTCAA11_tagMCSpringSaleInfo)); Register(typeof(HAA10_tagMCCostRebatePlayerInfo), typeof(DTCAA10_tagMCCostRebatePlayerInfo)); Register(typeof(HAA09_tagMCCostRebateInfo), typeof(DTCAA09_tagMCCostRebateInfo)); Register(typeof(HAC06_tagGCMultiExpRateInfo), typeof(DTCAC06_tagGCMultiExpRateInfo)); Register(typeof(HA001_tagBroadCastInfo), typeof(DTCA001_tagBroadCastInfo)); Register(typeof(HA40A_tagGCFakeFamilyInfo), typeof(DTCA40A_tagGCFakeFamilyInfo)); Register(typeof(HA110_tagMCCoinToGoldCountInfo), typeof(DTCA110_tagMCCoinToGoldCountInfo)); Register(typeof(HAA02_tagMCFirstGoldInfo), typeof(DTCAA02_tagMCFirstGoldInfo)); @@ -363,9 +364,9 @@ Register(typeof(HB202_tagMCPushNotificationsSetting), typeof(DTCB202_tagMCPushNotificationsSetting)); Register(typeof(HA318_tagMCFreeGoodsInfo),typeof(DTCA318_tagMCFreeGoodsInfo)); Register(typeof(HA318_tagMCFreeGoodsInfo), typeof(DTCA318_tagMCFreeGoodsInfo)); Register(typeof(HAA12_tagMCFlashGiftbagInfo), typeof(DTCAA12_tagMCFlashGiftbagInfo)); Register(typeof(HAA13_tagMCFlashGiftbagPlayerInfo),typeof(DTCAA13_tagMCFlashGiftbagPlayerInfo)); Register(typeof(HAA13_tagMCFlashGiftbagPlayerInfo), typeof(DTCAA13_tagMCFlashGiftbagPlayerInfo)); #region 仙界盛典 Register(typeof(HAC09_tagGCFairyCeremonyInfo), typeof(DTCAC09_tagGCFairyCeremonyInfo)); Core/GameEngine/Login/LaunchPostProcess.cs
@@ -39,6 +39,7 @@ AnyCountDownUtility.Instance.Initialize(); MapTransferUtility.Instance.Initialize(); DirtyWordConfig.Init(); DirtyNameConfig.Init(); NewBieCenter.Instance.Init(); DebugEx.LogFormat("解析配置表耗时:{0}", Time.time - startTime); Core/GameEngine/Model/Config/DirtyNameConfig.cs
New file @@ -0,0 +1,41 @@ //-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Friday, September 07, 2018 //-------------------------------------------------------- using UnityEngine; using System; namespace TableConfig { public partial class DirtyNameConfig : ConfigBase { public int id { get ; private set ; } public string word { get ; private set; } public override string getKey() { return id.ToString(); } public override void Parse() { try { id=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0; word = rawContents[1].Trim(); } catch (Exception ex) { DebugEx.Log(ex); } } } } Core/GameEngine/Model/Config/DirtyNameConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 82951a956f653c244b4289f30d794187 timeCreated: 1536292732 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/GameEngine/Model/ConfigManager.cs
@@ -189,6 +189,7 @@ AddAsyncTask<TrialRewardsConfig>(); AddAsyncTask<DogzEquipPlusConfig>(); AddAsyncTask<FairyGrabBossConfig>(); AddAsyncTask<DirtyNameConfig>(); while (!AllCompleted()) { var completedCount = 0; Core/GameEngine/Model/TelPartialConfig/DirtyNameConfig.cs
New file @@ -0,0 +1,211 @@ // ------------------------------------------------------------------------------ // <autogenerated> // This code was generated by a tool. // Mono Runtime Version: 2.0.50727.1433 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> // ------------------------------------------------------------------------------ namespace TableConfig { using System; using System.Collections.Generic; using System.Text.RegularExpressions; using UnityEngine; using System.Threading; public partial class DirtyNameConfig : ConfigBase, IConfigPostProcess { private static WordGroup[] DIRTYWORLD = new WordGroup[(int)char.MaxValue]; private static List<string> memoryList = new List<string>(); private static bool inited = false; static int cursor = 0; static int wordlenght = 0; static int nextCursor = 0; public void OnConfigParseCompleted() { string key = ToDBC(word); memoryList.Add(key); } private static string ToDBC(string input) { char[] c = input.ToCharArray(); for (int i = 0; i < c.Length; i++) { if (c[i] == 12288) { c[i] = (char)32; continue; } if (c[i] > 65280 && c[i] < 65375) c[i] = (char)(c[i] - 65248); } return new string(c).ToLower(); } public static bool IsDirtName(string source) { if (!inited) { Init(); } if (source != string.Empty) { cursor = 0; nextCursor = 0; for (int i = 0; i < source.Length; i++) { //查询以该字为首字符的词组 WordGroup group = DIRTYWORLD[(int)ToDBC(source)[i]]; if (group != null) { for (int z = 0; z < group.Count(); z++) { string word = group.GetWord(z); if (word.Length == 0 || Check(word, source)) { return true; } } } cursor++; } } return false; } private static bool Check(string blackWord, string source) { wordlenght = 0; int wordCnt = 0; //检测源下一位游标 nextCursor = cursor + 1; bool found = false; //遍历词的每一位做匹配 for (int i = 0; i < blackWord.Length; i++) { //特殊字符偏移游标 int offset = 0; if (nextCursor >= source.Length) { break; } else { //检测下位字符如果不是汉字 数字 字符 偏移量加1,,过滤特殊字符 for (int y = nextCursor; y < source.Length; y++) { //if (!IsCHS(source[y]) && !IsNum(source[y]) && !IsAlphabet(source[y])) { if (IsSpecial(source[y])) { offset++; //避让特殊字符,下位游标如果>=字符串长度 跳出 if (nextCursor + offset >= source.Length) break; wordlenght++; } else break; } if (nextCursor + offset >= source.Length) { break; } if ((int)blackWord[i] == (int)source[nextCursor + offset]) { wordCnt++; found = true; } else { found = false; break; } } nextCursor = nextCursor + 1 + offset; wordlenght++; } if (blackWord.Length != wordCnt) return false; return found; } private static bool IsSpecial(char character) { if (character == ' ') { return true; } return false; } static public void Init() { if (inited) { return; } inited = true; ThreadPool.QueueUserWorkItem((object aaa) => { memoryList.Sort((string x, string y) => { return x.CompareTo(y); }); for (int i = memoryList.Count - 1; i > 0; i--) { if (memoryList[i].ToString() == memoryList[i - 1].ToString()) { memoryList.RemoveAt(i); } } foreach (string word in memoryList) { WordGroup group = DIRTYWORLD[(int)word[0]]; if (group == null) { group = new WordGroup(); DIRTYWORLD[(int)word[0]] = group; } group.Add(word.Substring(1)); } }); } public static bool IsCHS(char character) { // 中文表意字符的范围 4E00-9FA5 int charVal = (int)character; return (charVal >= 0x4e00 && charVal <= 0x9fa5); } private static bool IsNum(char character) { int charVal = (int)character; return (charVal >= 48 && charVal <= 57); } private static bool IsAlphabet(char character) { int charVal = (int)character; return ((charVal >= 97 && charVal <= 122) || (charVal >= 65 && charVal <= 90)); } private const string FACE_REPLACE = @"#~[0-9a-zA-Z]{1,3}"; private static Regex FaceRegex = new Regex(FACE_REPLACE, RegexOptions.Singleline); public static string FitterSpecial(string source) { return FaceRegex.Replace(source, " "); } } } Core/GameEngine/Model/TelPartialConfig/DirtyNameConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 0e5d71dd541cbe34d8b8476ffee4b7c3 timeCreated: 1536298690 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/ClientPack/ClientToMapServer/CB9_Team/CB90A_tagCGInvitePlayerJoinTeamByLV.cs
New file @@ -0,0 +1,20 @@ using UnityEngine; using System.Collections; // B9 0A 按条件邀请玩家加入队伍 #tagCGInvitePlayerJoinTeamByLV public class CB90A_tagCGInvitePlayerJoinTeamByLV : GameNetPackBasic { public ushort LVLimit; // 目标玩家大于等于此等级 public byte InviteCnt; // 邀请玩家个数 public CB90A_tagCGInvitePlayerJoinTeamByLV () { combineCmd = (ushort)0x03FE; _cmd = (ushort)0xB90A; } public override void WriteToBytes () { WriteBytes (LVLimit, NetDataType.WORD); WriteBytes (InviteCnt, NetDataType.BYTE); } } Core/NetworkPackage/ClientPack/ClientToMapServer/CB9_Team/CB90A_tagCGInvitePlayerJoinTeamByLV.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 72367b0233bf0d943b47ab08e61439d1 timeCreated: 1536287241 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0102_tagCDBPlayer.cs
@@ -1,33 +1,41 @@ using UnityEngine; using Snxxz.UI; using TableConfig; using System; //01 02 玩家初始化#tagCDBPlayer public class DTC0102_tagCDBPlayer : DtcBasic { public static bool DEBUG_0102 = false; public static int DEBUG_STEP = 0; public static event Action beforePlayerDataInitializeEvent; public static event Action afterPlayerDataInitializeEvent; public static event Action switchAccountEvent; using UnityEngine; using Snxxz.UI; using TableConfig; using System; //01 02 玩家初始化#tagCDBPlayer public class DTC0102_tagCDBPlayer : DtcBasic { public static bool DEBUG_0102 = false; public static int DEBUG_STEP = 0; public static event Action beforePlayerDataInitializeEvent; public static event Action afterPlayerDataInitializeEvent; public static event Action switchAccountEvent; public static uint playerIdBuf = 0; public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); DEBUG_0102 = true; DTC0403_tagPlayerLoginLoadOK.finishedLogin = false; DEBUG_STEP = 0; DTC0403_tagPlayerLoginLoadOK.neverLoginOk = true; if (beforePlayerDataInitializeEvent != null) { beforePlayerDataInitializeEvent(); public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); H0102_tagCDBPlayer vNetData = vNetPack as H0102_tagCDBPlayer; SDKUtility.Instance.RoleLogin(vNetData.PlayerID.ToString(), vNetData.PlayerName, vNetData.LV.ToString(), vNetData.VIPLv.ToString()); DEBUG_0102 = true; DTC0403_tagPlayerLoginLoadOK.finishedLogin = false; DEBUG_STEP = 0; DTC0403_tagPlayerLoginLoadOK.neverLoginOk = true; if (beforePlayerDataInitializeEvent != null) { beforePlayerDataInitializeEvent(); } DEBUG_STEP = 1; DEBUG_STEP = 1; try { RedpointCenter.Instance.ResetAllRedpointState(); @@ -36,30 +44,28 @@ { Debug.LogError(ex); } H0102_tagCDBPlayer vNetData = vNetPack as H0102_tagCDBPlayer; if (vNetData.LV == 1) { OperationLogCollect.Instance.RecordEvent(8); } PlayerDatas.Instance.InitPlayerData(vNetData); var _mapConfig = Config.Instance.Get<MapConfig>(vNetData.MapID); DTCA127_tagMCStartChangeMap.LineID = 0; int _realMapDataID = vNetData.MapID; if (_mapConfig.MapFBType != 0) { PlayerDatas.Instance.InitPlayerData(vNetData); var _mapConfig = Config.Instance.Get<MapConfig>(vNetData.MapID); DTCA127_tagMCStartChangeMap.LineID = 0; int _realMapDataID = vNetData.MapID; if (_mapConfig.MapFBType != 0) { DungeonModel _model = ModelCenter.Instance.GetModel<DungeonModel>(); _realMapDataID = _model.GetDungeonDataIdByMapId(vNetData.MapID); _realMapDataID = _model.GetDungeonDataIdByMapId(vNetData.MapID); if (vNetData.MapID != 52020 && vNetData.MapID != 52010) { DTCA127_tagMCStartChangeMap.LineID = (int)vNetData.ExAttr3; } DTCA127_tagMCStartChangeMap.LineID = (int)vNetData.ExAttr3; } } var _mapResConfig = DTCA127_tagMCStartChangeMap.GetMapResourcesConfig(_realMapDataID, DTCA127_tagMCStartChangeMap.LineID); @@ -68,20 +74,20 @@ { DTCA127_tagMCStartChangeMap.LineID = 0; _mapResConfig = DTCA127_tagMCStartChangeMap.GetMapResourcesConfig(_realMapDataID, DTCA127_tagMCStartChangeMap.LineID); } if (_mapResConfig != null) { GA_Hero.MapOffset.x = _mapResConfig.MapOffset.x; GA_Hero.MapOffset.z = _mapResConfig.MapOffset.y; } else { GA_Hero.MapOffset.x = 0; GA_Hero.MapOffset.z = 0; } #if UNITY_EDITOR } if (_mapResConfig != null) { GA_Hero.MapOffset.x = _mapResConfig.MapOffset.x; GA_Hero.MapOffset.z = _mapResConfig.MapOffset.y; } else { GA_Hero.MapOffset.x = 0; GA_Hero.MapOffset.z = 0; } #if UNITY_EDITOR DebugEx.LogFormat("------------ 0102 =>玩家ID: {0}, 职业: {1}, 地图: {2}", vNetData.PlayerID, vNetData.Job, vNetData.MapID); #endif DEBUG_STEP = 2; @@ -102,93 +108,93 @@ } } switch (vNetData.MapID) { case 31250: StageManager.Instance.Load<GuardDungeonStage>(_mapConfig.MapID); break; case RuneTowerModel.RUNETOWER_MAPID: StageManager.Instance.Load<RuneTowerDungeonStage>(_mapConfig.MapID); break; case DemonJarModel.DEMONJAR_SINGLEMAPID: StageManager.Instance.Load<FakeDemonJarDungeonStage>(_mapConfig.MapID); break; default: StageManager.Instance.Load<DungeonStage>(_mapConfig.MapID); break; } DTCA713_tagMCDynamicBarrierState.Clear(); switch (vNetData.MapID) { case 31250: StageManager.Instance.Load<GuardDungeonStage>(_mapConfig.MapID); break; case RuneTowerModel.RUNETOWER_MAPID: StageManager.Instance.Load<RuneTowerDungeonStage>(_mapConfig.MapID); break; case DemonJarModel.DEMONJAR_SINGLEMAPID: StageManager.Instance.Load<FakeDemonJarDungeonStage>(_mapConfig.MapID); break; default: StageManager.Instance.Load<DungeonStage>(_mapConfig.MapID); break; } DTCA713_tagMCDynamicBarrierState.Clear(); MainRedDot.Instance.Register(); DEBUG_STEP = 3; if (playerIdBuf != 0 && playerIdBuf != PlayerDatas.Instance.baseData.PlayerID) { if (switchAccountEvent != null) { switchAccountEvent(); } DEBUG_STEP = 3; if (playerIdBuf != 0 && playerIdBuf != PlayerDatas.Instance.baseData.PlayerID) { if (switchAccountEvent != null) { switchAccountEvent(); } } playerIdBuf = PlayerDatas.Instance.baseData.PlayerID; if (afterPlayerDataInitializeEvent != null) { afterPlayerDataInitializeEvent(); } playerIdBuf = PlayerDatas.Instance.baseData.PlayerID; if (afterPlayerDataInitializeEvent != null) { afterPlayerDataInitializeEvent(); } SettingEffectMgr.Instance.Begin(); DEBUG_STEP = 4; QuickSetting.Instance.SetQuickSetting(vNetData.Setting); NetLinkWin.Hide(); WindowCenter.Instance.Close<SelectRoleWin>(); DEBUG_STEP = 4; QuickSetting.Instance.SetQuickSetting(vNetData.Setting); NetLinkWin.Hide(); WindowCenter.Instance.Close<SelectRoleWin>(); WindowCenter.Instance.Close<CreateRoleWin>(); DEBUG_STEP = 5; if (VersionConfig.Get().debugVersion) { GMCommand.Instance.Begin(); if (VersionConfig.Get().debugVersion) { GMCommand.Instance.Begin(); } DEBUG_STEP = 6; // 初始化摄像机 if (!CameraController.Instance) { UnityEngine.Object.Instantiate(Resources.Load<GameObject>("Prefabs/GameCamera")); CameraController.Instance.AcceptInput = false; CameraController.Instance.CameraObject.enabled = false; DEBUG_STEP = 6; // 初始化摄像机 if (!CameraController.Instance) { UnityEngine.Object.Instantiate(Resources.Load<GameObject>("Prefabs/GameCamera")); CameraController.Instance.AcceptInput = false; CameraController.Instance.CameraObject.enabled = false; } var hudRoot = HUDCenter.hudRoot; if (!hudRoot) { hudRoot = HUDCenter.CreateHUDRoot(); hudRoot.SetCamera(CameraController.Instance.CameraObject); var hudRoot = HUDCenter.hudRoot; if (!hudRoot) { hudRoot = HUDCenter.CreateHUDRoot(); hudRoot.SetCamera(CameraController.Instance.CameraObject); } DEBUG_STEP = 7; GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null) { _hero = GAMgr.Instance.RequestPlayer<GA_Hero>(PlayerDatas.Instance.PlayerId, E_ActorGroup.User, null); PlayerDatas.Instance.hero = _hero; } else // 重连 { if (PreFightMission.Instance.IsFinished()) { _hero.StopAll(); _hero.InitBornPos(vNetData.PosX, vNetData.PosY); } DEBUG_STEP = 7; GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null) { _hero = GAMgr.Instance.RequestPlayer<GA_Hero>(PlayerDatas.Instance.PlayerId, E_ActorGroup.User, null); PlayerDatas.Instance.hero = _hero; } else // 重连 { if (PreFightMission.Instance.IsFinished()) { _hero.StopAll(); _hero.InitBornPos(vNetData.PosX, vNetData.PosY); } } DEBUG_STEP = 8; _hero.OnPathFindStop -= MapTransferUtility.Instance.OnHeroStopPathFind; _hero.OnPathFindStop += MapTransferUtility.Instance.OnHeroStopPathFind; DEBUG_STEP = 8; _hero.OnPathFindStop -= MapTransferUtility.Instance.OnHeroStopPathFind; _hero.OnPathFindStop += MapTransferUtility.Instance.OnHeroStopPathFind; StatusMgr.Instance.ReleaseActor(PlayerDatas.Instance.PlayerId); GAMgr.Instance.UnInit(); DEBUG_STEP = 9; } } DEBUG_STEP = 9; } } Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0132_tagCreateRoleSucess.cs
New file @@ -0,0 +1,16 @@ public class DTC0132_tagCreateRoleSucess : DtcBasic { public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); var _package = vNetPack as H0132_tagCreateRoleSucess; if (_package == null) { return; } SDKUtility.Instance.CreateRoleOk(_package.PlayerID.ToString(), _package.PlayerName); } } Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0132_tagCreateRoleSucess.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: e6f4990770762fa418dbed041e3c8f70 timeCreated: 1535981625 licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/ServerPack/H01_System/H0132_tagCreateRoleSucess.cs
New file @@ -0,0 +1,22 @@ using UnityEngine; using System.Collections; //01 32 创角成功 #tagCreateRoleSucess public class H0132_tagCreateRoleSucess : GameNetPackBasic { public uint PlayerID; public string PlayerName; public H0132_tagCreateRoleSucess() { _cmd = (ushort)0x0132; } public override void ReadFromBytes(byte[] vBytes) { TransBytes(out PlayerID, vBytes, NetDataType.DWORD); TransBytes(out PlayerName, vBytes, NetDataType.Chars, 33); } } Core/NetworkPackage/ServerPack/H01_System/H0132_tagCreateRoleSucess.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: bb83d94cd4209ff48a9c0df87282f3bc timeCreated: 1535981625 licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/SDK/SDKUtility.cs
@@ -16,6 +16,14 @@ ChargingFull = 3, } public enum E_ChannelPlatform { Free, Mr, } public E_ChannelPlatform ChannelPlatform { get; private set; } /// <summary> /// sdk初始化是否完成标识 /// 客户端一般需要等待这个值为true才继续逻辑 @@ -86,6 +94,8 @@ { RegistrationID = string.Empty; AssetCopyFinished = false; ChannelPlatform = E_ChannelPlatform.Free; #if !UNITY_EDITOR if (InitFinished) { @@ -254,16 +264,16 @@ var _code = (int)_json["code"]; switch (_code) { case CodeA2U.DeviceInfo: case CodeA2U.DeviceInfo: Device = new DeviceInfo (); Device.uniqueID = _json ["unique_id"].ToString (); Device.androidID = _json ["android_id"].ToString ();// ios平台下为idfa Device.userAgent = _json ["userAgent"].ToString (); Device = new DeviceInfo(); Device.uniqueID = _json["unique_id"].ToString(); Device.androidID = _json["android_id"].ToString();// ios平台下为idfa Device.userAgent = _json["userAgent"].ToString(); #if UNITY_ANDROID Device.macAddress = _json ["mac"].ToString (); Device.imei = _json ["imei"].ToString (); Device.totalMemory = (int)_json ["memoryTotal"]; Device.macAddress = _json["mac"].ToString(); Device.imei = _json["imei"].ToString(); Device.totalMemory = (int)_json["memoryTotal"]; #endif if (OnDeviceInfoChanged != null) { @@ -294,6 +304,19 @@ break; case CodeA2U.SdkInitComplete: InitFinished = true; var _dict = _json as IDictionary; if (_dict != null && _dict.Contains("channelPlatform")) { var _channelPlatform = _json["channelPlatform"].ToString(); if (!string.IsNullOrEmpty(_channelPlatform)) { if (_channelPlatform.Equals("mr")) { ChannelPlatform = E_ChannelPlatform.Mr; Debug.Log("当前渠道平台为猫耳渠道"); } } } break; case CodeA2U.PushClientID: RegistrationID = _json["clientID"].ToString(); @@ -473,6 +496,8 @@ public const int FreePlatformSwitchAccount = 103; public const int FreePlatformPay = 104; public const int PayFinished = 105; public const int CreateRole = 106; public const int RoleLogin = 107; /** * 极光推送 * */ @@ -543,7 +568,6 @@ public string platfromId = "1000"; public UnityAction<FP_CheckIDAuthentication> onFreePlatfromCheckIDOK; public UnityAction<FP_DoIDAuthentication> onFreePlatfromDoIDAuthenticationOk; public void FreePlatformInit() { @@ -619,6 +643,10 @@ m_PaymentTable["OrderTitle"] = title; m_PaymentTable["OrderInfo"] = cpInfo; m_PaymentTable["AppID"] = VersionConfig.Get().appId; if (ChannelPlatform == E_ChannelPlatform.Mr) { m_PaymentTable["RechargeChannel"] = "1"; } var _stringBuilder = new System.Text.StringBuilder(); var _md5Body = _stringBuilder.Append(m_PaymentTable["AppID"]). @@ -647,6 +675,7 @@ { if (result) { Debug.Log(" ------------------ : " + message); JsonData _json = JsonMapper.ToObject(message); int _callbackResult = (int)_json["result"]; @@ -660,6 +689,15 @@ m_Json["mount"] = money; m_Json["cpInfo"] = cpInfo; m_Json["title"] = title; m_Json["notifyurl"] = _json["notifyurl"]; if (ChannelPlatform == E_ChannelPlatform.Mr) { m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID; m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; m_Json["level"] = PlayerDatas.Instance.baseData.LV.ToString(); m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag; } #if UNITY_IOS m_Json["identifier"] = VersionConfig.Get().bundleIdentifier; #endif @@ -750,18 +788,25 @@ if (_iDict.Contains("token")) { FreePlatformInfo.token = json["token"].ToString(); Debug.Log("token: " + FreePlatformInfo.token); } if (_iDict.Contains("token_expire")) { FreePlatformInfo.tokenExpire = json["token_expire"].ToString(); } else { FreePlatformInfo.tokenExpire = ""; } if (_iDict.Contains("account")) { FreePlatformInfo.account = json["account"].ToString(); Debug.Log("account: " + FreePlatformInfo.account); } if (_iDict.Contains("account_id")) { int.TryParse(json["account_id"].ToString(), out FreePlatformInfo.accountID); Debug.Log("account_id: " + FreePlatformInfo.accountID); } FreePlatformInfo.phone = 0; @@ -799,6 +844,29 @@ m_Json["money"] = (float)coin / 100; SendMessageToSDK(m_Json); } public void CreateRoleOk(string roleID, string roleName) { m_Json.Clear(); m_Json["code"] = CodeU2A.CreateRole; m_Json["roleID"] = roleID; m_Json["roleName"] = roleName; m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag; SendMessageToSDK(m_Json); } public void RoleLogin(string roleID, string roleName, string lv, string vipLV) { m_Json.Clear(); m_Json["code"] = CodeU2A.RoleLogin; m_Json["roleID"] = roleID; m_Json["roleName"] = roleName; m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag; m_Json["level"] = lv; m_Json["vipLevel"] = vipLV; SendMessageToSDK(m_Json); } #endregion #region 极光推送相关 Fight/PreFightMission.cs
@@ -652,7 +652,7 @@ _model.direction = 2; _model.arrowScale = 2; _model.pressedClose = false; _model.clickClosed = true; _model.clickClosed = false; _model.onClose = null; WindowCenter.Instance.Open<NewGuideWin>(); System/AssetVersion/RemoteFile.cs
@@ -1,60 +1,67 @@ //#define UseWebClient using UnityEngine; using System.Collections; using System.Net; using System.IO; using System.ComponentModel; using System; using System.Threading; //#define UseWebClient using UnityEngine; using System.Collections; using System.Net; using System.IO; using System.ComponentModel; using System; using System.Threading; public class RemoteFile { static bool m_ProcessErroring = false; public static bool processErroring { static bool m_ProcessErroring = false; public static bool processErroring { get { return m_ProcessErroring; } } public static int maxDownLoadTask = 48; public static int MaxConnectLimit = 48; static int gDownloadIsRunningCount; public static int DownloadIsRunningCount { get { return gDownloadIsRunningCount; } } public static int gStartTickcount = 0; static long gTotalDownloadSize = 0L; //已下载的字节数 static object lockObj = new object(); public static long TotalDownloadedSize { get { return System.Threading.Interlocked.Read(ref gTotalDownloadSize); } set { } public static int maxDownLoadTask = 48; public static int MaxConnectLimit = 48; static int gDownloadIsRunningCount; public static int DownloadIsRunningCount { get { return gDownloadIsRunningCount; } } public static int gStartTickcount = 0; static long gTotalDownloadSize = 0L; //已下载的字节数 static object lockObj = new object(); public static long TotalDownloadedSize { get { return System.Threading.Interlocked.Read(ref gTotalDownloadSize); } set { gTotalDownloadSize = value; } } static float downloadSpeedRef = 0f; //字节/秒 static long downloadSizeRef = 0L; public static string DownloadSpeed { get { float speed = downloadSpeedRef; } } static float downloadSpeedRef = 0f; //字节/秒 static long downloadSizeRef = 0L; public static string DownloadSpeed { get { float speed = downloadSpeedRef; if (RemoteFile.gStartTickcount != 0) { float second = Mathf.Abs(System.Environment.TickCount - RemoteFile.gStartTickcount) / 1000f; { float second = Mathf.Abs(System.Environment.TickCount - RemoteFile.gStartTickcount) / 1000f; if (second > 1f || (downloadSpeedRef <= 0.1f && TotalDownloadedSize > 0)) { { if (second > 0f) { var delta = TotalDownloadedSize - downloadSizeRef; { var delta = TotalDownloadedSize - downloadSizeRef; downloadSizeRef = TotalDownloadedSize; speed = (delta / second + downloadSpeedRef) * 0.5f; downloadSpeedRef = speed; RemoteFile.gStartTickcount = System.Environment.TickCount; } } } } } if (speed > 1048576f) @@ -68,23 +75,23 @@ else { return StringUtility.Contact(speed.ToString("f1"), " B/S"); } } } public AssetVersion assetVersion { get; private set; } protected string mRemoteFile; protected string localFile; bool speedLimit = false; protected string mLocalFileTemp; //临时文件 protected System.DateTime mRemoteLastModified; protected System.DateTime mLocalLastModified; protected long mRemoteFileSize = 0; public static long TotalRemoteFileSize = 0L; const int bufferSize = 8192; } } } public AssetVersion assetVersion { get; private set; } protected string mRemoteFile; protected string localFile; bool speedLimit = false; protected string mLocalFileTemp; //临时文件 protected System.DateTime mRemoteLastModified; protected System.DateTime mLocalLastModified; protected long mRemoteFileSize = 0; public static long TotalRemoteFileSize = 0L; const int bufferSize = 8192; byte[] buff; HttpWebRequest headRequest; @@ -94,15 +101,18 @@ Action<bool, AssetVersion> onCompleted; protected bool mHadError = false; public bool HaveError { get { return mHadError; } } bool m_Done = false; public bool done { get { return m_Done; } private set { protected bool mHadError = false; public bool HaveError { get { return mHadError; } } bool m_Done = false; public bool done { get { return m_Done; } private set { m_Done = value; if (value) { @@ -113,14 +123,14 @@ onCompleted = null; } } } } State state = State.Wait; int read_Stream_startTickcount = 0; //请求操作开始,用于超时判断 int timeOut = 5000; //超时时间 } } State state = State.Wait; int read_Stream_startTickcount = 0; //请求操作开始,用于超时判断 int timeOut = 5000; //超时时间 public static void Prepare() { gDownloadIsRunningCount = 0; @@ -128,16 +138,16 @@ TotalDownloadedSize = 0L; downloadSpeedRef = 0f; downloadSizeRef = 0L; } } public void Init(string remoteFile, string _localFile, AssetVersion _assetVersion, bool _speedLimit = false) { mRemoteFile = remoteFile; localFile = _localFile; assetVersion = _assetVersion; this.speedLimit = _speedLimit; } mRemoteFile = remoteFile; localFile = _localFile; assetVersion = _assetVersion; this.speedLimit = _speedLimit; } public void Begin(Action<bool, AssetVersion> _onCompleted) { onCompleted = _onCompleted; @@ -206,7 +216,7 @@ gDownloadIsRunningCount--; } } } } private void OnDispose() { @@ -214,18 +224,18 @@ } void MakeSureDirectory(string filePath) { string dir = Path.GetDirectoryName(filePath); { string dir = Path.GetDirectoryName(filePath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } } } bool Move(string sourceFile, string destFile) { bool ret = true; #if !UNITY_WEBPLAYER { bool ret = true; #if !UNITY_WEBPLAYER try { if (speedLimit) @@ -239,20 +249,20 @@ { File.Move(sourceFile, destFile); } } } catch (Exception ex) { DebugEx.LogError(ex.Message); ret = false; } #endif return ret; DebugEx.LogError(ex.Message); ret = false; } #endif return ret; } IEnumerator Co_DownloadRemoteFile() { done = false; while (gDownloadIsRunningCount >= maxDownLoadTask) { if (stop) @@ -261,8 +271,8 @@ } //超过最大任务数时,先等待 yield return null; } } while (assetVersion != null && assetVersion.extersion == ".manifest" && !AssetVersionUtility.GetAssetVersion(assetVersion.relativePath.Replace(".manifest", "")).localValid) { if (stop) @@ -270,165 +280,165 @@ yield break; } yield return null; } state = State.Working; gDownloadIsRunningCount++; mHadError = false; fileWriteState = FileWriteState.None; mLocalFileTemp = localFile + ".tmp"; //先下载为临时文件 MakeSureDirectory(mLocalFileTemp); //确保文件写入目录存在 mLocalLastModified = DateTime.MinValue; long localFileSize = 0L; #if !UNITY_WEBPLAYER } state = State.Working; gDownloadIsRunningCount++; mHadError = false; fileWriteState = FileWriteState.None; mLocalFileTemp = localFile + ".tmp"; //先下载为临时文件 MakeSureDirectory(mLocalFileTemp); //确保文件写入目录存在 mLocalLastModified = DateTime.MinValue; long localFileSize = 0L; #if !UNITY_WEBPLAYER mLocalLastModified = File.GetLastWriteTime(mLocalFileTemp); #endif headRequest = (HttpWebRequest)System.Net.WebRequest.Create(mRemoteFile); #endif headRequest = (HttpWebRequest)System.Net.WebRequest.Create(mRemoteFile); if (headRequest.ServicePoint.ConnectionLimit < RemoteFile.MaxConnectLimit) { headRequest.ServicePoint.ConnectionLimit = RemoteFile.MaxConnectLimit; } headRequest.Method = "HEAD"; // Only the header info, not full file! headRequest.ServicePoint.Expect100Continue = false; headRequest.Timeout = 3000; headRequest.Proxy = null; headRequest.KeepAlive = false; bool isAcceptRange = true; bool headRequestOk = false; //是否支持断点续传 int tick1 = 0; { headRequest.ServicePoint.ConnectionLimit = RemoteFile.MaxConnectLimit; } headRequest.Method = "HEAD"; // Only the header info, not full file! headRequest.ServicePoint.Expect100Continue = false; headRequest.Timeout = 3000; headRequest.Proxy = null; headRequest.KeepAlive = false; bool isAcceptRange = true; bool headRequestOk = false; //是否支持断点续传 int tick1 = 0; try { headRequest.BeginGetResponse( //改为异步的方法 { headRequest.BeginGetResponse( //改为异步的方法 (x) => { { try { headResponse = (x.AsyncState as HttpWebRequest).EndGetResponse(x) as HttpWebResponse; mRemoteLastModified = headResponse.LastModified; mRemoteFileSize = headResponse.ContentLength; { headResponse = (x.AsyncState as HttpWebRequest).EndGetResponse(x) as HttpWebResponse; mRemoteLastModified = headResponse.LastModified; mRemoteFileSize = headResponse.ContentLength; if (headResponse.Headers["Accept-Ranges"] != null) { string s = headResponse.Headers["Accept-Ranges"]; { string s = headResponse.Headers["Accept-Ranges"]; if (s == "none") { isAcceptRange = false; } } System.Threading.Interlocked.Add(ref RemoteFile.TotalRemoteFileSize, mRemoteFileSize); headRequestOk = true; } { isAcceptRange = false; } } System.Threading.Interlocked.Add(ref RemoteFile.TotalRemoteFileSize, mRemoteFileSize); headRequestOk = true; } catch (Exception ex) { DebugEx.LogWarning("ERROR: " + ex); mHadError = true; } { DebugEx.LogWarning("ERROR: " + ex); mHadError = true; } finally { { if (headResponse != null) { headResponse.Close(); headResponse = null; } { headResponse.Close(); headResponse = null; } if (headRequest != null) { headRequest.Abort(); headRequest = null; } } }, headRequest); tick1 = System.Environment.TickCount; } } } }, headRequest); tick1 = System.Environment.TickCount; } catch (WebException webEx) { DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning("ERROR: " + webEx); mHadError = true; gDownloadIsRunningCount--; done = true; yield break; } { DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning("ERROR: " + webEx); mHadError = true; gDownloadIsRunningCount--; done = true; yield break; } catch (System.Exception e) { DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning("ERROR: " + e); mHadError = true; gDownloadIsRunningCount--; done = true; yield break; } { DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning("ERROR: " + e); mHadError = true; gDownloadIsRunningCount--; done = true; yield break; } while (!headRequestOk && !mHadError) { if (stop) { yield break; } } if (processErroring) { mHadError = true; break; } float dur = System.Environment.TickCount - tick1; { mHadError = true; break; } float dur = System.Environment.TickCount - tick1; if (dur > timeOut) { DebugEx.LogWarningFormat("获取远程文件{0} 信息超时!", mRemoteFile); mHadError = true; break; } yield return null; } { DebugEx.LogWarningFormat("获取远程文件{0} 信息超时!", mRemoteFile); mHadError = true; break; } yield return null; } if (mHadError) { DebugEx.LogWarningFormat("获取远程文件{0} 信息失败!", mRemoteFile); { DebugEx.LogWarningFormat("获取远程文件{0} 信息失败!", mRemoteFile); if (headRequest != null) { headRequest.Abort(); headRequest = null; } done = true; gDownloadIsRunningCount--; yield break; } //判断是否有已经下载部分的临时文件 } done = true; gDownloadIsRunningCount--; yield break; } //判断是否有已经下载部分的临时文件 if (File.Exists(mLocalFileTemp)) { // This will not work in web player! //判断是否断点续传, 依据临时文件是否存在,以及修改时间是否小于服务器文件时间 #if !UNITY_WEBPLAYER localFileSize = (File.Exists(mLocalFileTemp)) ? (new FileInfo(mLocalFileTemp)).Length : 0L; #endif bool outDated = IsOutdated; { // This will not work in web player! //判断是否断点续传, 依据临时文件是否存在,以及修改时间是否小于服务器文件时间 #if !UNITY_WEBPLAYER localFileSize = (File.Exists(mLocalFileTemp)) ? (new FileInfo(mLocalFileTemp)).Length : 0L; #endif bool outDated = IsOutdated; if (localFileSize == mRemoteFileSize && !outDated) { gDownloadIsRunningCount--; done = true; mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 yield break; // We already have the file, early out } { gDownloadIsRunningCount--; mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 done = true; yield break; // We already have the file, early out } else if (localFileSize > mRemoteFileSize || outDated) { if (!outDated) DebugEx.LogWarning("Local file is larger than remote file, but not outdated. PANIC!"); { if (!outDated) DebugEx.LogWarning("Local file is larger than remote file, but not outdated. PANIC!"); if (outDated) { DebugEx.LogWarning(mLocalFileTemp + " Local file is outdated, deleting"); } { DebugEx.LogWarning(mLocalFileTemp + " Local file is outdated, deleting"); } try { if (File.Exists(mLocalFileTemp)) File.Delete(mLocalFileTemp); } { if (File.Exists(mLocalFileTemp)) File.Delete(mLocalFileTemp); } catch (System.Exception e) { DebugEx.LogWarning("<color=red>Could not delete local file</color>"); DebugEx.LogError(e); } { DebugEx.LogWarning("<color=red>Could not delete local file</color>"); DebugEx.LogError(e); } while (File.Exists(mLocalFileTemp)) { if (stop) @@ -436,31 +446,31 @@ yield break; } yield return null; } localFileSize = 0; } } } localFileSize = 0; } } if (mHadError) { gDownloadIsRunningCount--; done = true; yield break; } { gDownloadIsRunningCount--; done = true; yield break; } if (File.Exists(localFile)) { { try { if (File.Exists(localFile)) File.Delete(localFile); } { if (File.Exists(localFile)) File.Delete(localFile); } catch (System.Exception e) { DebugEx.LogWarning("<color=red>Could not delete local file</color>"); DebugEx.LogWarning(e); } { DebugEx.LogWarning("<color=red>Could not delete local file</color>"); DebugEx.LogWarning(e); } while (File.Exists(localFile)) { if (stop) @@ -468,241 +478,244 @@ yield break; } yield return null; } } #if UseWebClient //|| UNITY_IOS using (WebClient client = new WebClient()) { client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted); client.DownloadFileAsync(new Uri(mRemoteFile), mLocalFileTemp); } while (!done) { yield return null; } mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 #else } } #if UseWebClient //|| UNITY_IOS using (WebClient client = new WebClient()) { client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted); client.DownloadFileAsync(new Uri(mRemoteFile), mLocalFileTemp); } while (!done) { yield return null; } mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 #else try { fileRequest = (HttpWebRequest)HttpWebRequest.Create(mRemoteFile); { fileRequest = (HttpWebRequest)HttpWebRequest.Create(mRemoteFile); if (fileRequest.ServicePoint.ConnectionLimit < RemoteFile.MaxConnectLimit) { fileRequest.ServicePoint.ConnectionLimit = RemoteFile.MaxConnectLimit; } fileRequest.ServicePoint.Expect100Continue = false; fileRequest.Timeout = 3000; fileRequest.Proxy = null; fileRequest.KeepAlive = false; { fileRequest.ServicePoint.ConnectionLimit = RemoteFile.MaxConnectLimit; } fileRequest.ServicePoint.Expect100Continue = false; fileRequest.Timeout = 3000; fileRequest.Proxy = null; fileRequest.KeepAlive = false; if (localFileSize != 0L && isAcceptRange) { fileRequest.AddRange((int)localFileSize, (int)mRemoteFileSize - 1); } #if !UNITY_WEBPLAYER fileRequest.Method = WebRequestMethods.Http.Get; #endif fileRequest.BeginGetResponse(AsynchCallback, fileRequest); tick1 = System.Environment.TickCount; } { fileRequest.AddRange((int)localFileSize, (int)mRemoteFileSize - 1); } #if !UNITY_WEBPLAYER fileRequest.Method = WebRequestMethods.Http.Get; #endif fileRequest.BeginGetResponse(AsynchCallback, fileRequest); tick1 = System.Environment.TickCount; } catch (System.Exception ex) { DebugEx.LogWarning("BeginGetResponse exception: " + ex.Message); DebugEx.LogWarning(ex); { DebugEx.LogWarning("BeginGetResponse exception: " + ex.Message); DebugEx.LogWarning(ex); if (fileRequest != null) { fileRequest.Abort(); fileRequest = null; } mHadError = true; done = true; gDownloadIsRunningCount--; yield break; } { fileRequest.Abort(); fileRequest = null; } mHadError = true; done = true; gDownloadIsRunningCount--; yield break; } while (fileResponse == null && !mHadError) { // Wait for asynch to finish if (stop) { yield break; } } if (processErroring) { mHadError = true; break; } float dur = System.Environment.TickCount - tick1; { mHadError = true; break; } float dur = System.Environment.TickCount - tick1; if (dur > timeOut) { DebugEx.LogWarningFormat("下载远程文件{0} 超时!", mRemoteFile); mHadError = true; break; } yield return null; } { DebugEx.LogWarningFormat("下载远程文件{0} 超时!", mRemoteFile); mHadError = true; break; } yield return null; } if (mHadError) { DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); { DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); if (fileRequest != null) { fileRequest.Abort(); fileRequest = null; } { fileRequest.Abort(); fileRequest = null; } if (fileResponse != null) { fileResponse.Close(); fileResponse = null; } done = true; gDownloadIsRunningCount--; yield break; } { fileResponse.Close(); fileResponse = null; } done = true; gDownloadIsRunningCount--; yield break; } try { inStream = fileResponse.GetResponseStream(); fs = new FileStream(mLocalFileTemp, (localFileSize > 0) ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.ReadWrite); { inStream = fileResponse.GetResponseStream(); fs = new FileStream(mLocalFileTemp, (localFileSize > 0) ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.ReadWrite); if (buff == null) { buff = new byte[bufferSize]; } fileWriteState = FileWriteState.Writting; inStream.BeginRead(buff, 0, bufferSize, ReadDataCallback, null); read_Stream_startTickcount = System.Environment.TickCount; } { buff = new byte[bufferSize]; } fileWriteState = FileWriteState.Writting; inStream.BeginRead(buff, 0, bufferSize, ReadDataCallback, null); read_Stream_startTickcount = System.Environment.TickCount; } catch (Exception ex) { DebugEx.LogWarning("<color=red>ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning(ex); { DebugEx.LogWarning("<color=red>ERROR: " + mRemoteFile + "</color>"); DebugEx.LogWarning(ex); if (inStream != null) { inStream.Close(); inStream = null; } { inStream.Close(); inStream = null; } if (fs != null) { fs.Close(); fs = null; } { fs.Close(); fs = null; } if (fileResponse != null) { fileResponse.Close(); fileResponse = null; } mHadError = true; fileWriteState = FileWriteState.Error; } { fileResponse.Close(); fileResponse = null; } mHadError = true; fileWriteState = FileWriteState.Error; } while (fileWriteState == FileWriteState.Writting) { if (stop) { yield break; } } if (processErroring) { fileWriteState = FileWriteState.Error; break; } { fileWriteState = FileWriteState.Error; break; } if (downloadSpeedRef == 0) { int dura = System.Environment.TickCount - read_Stream_startTickcount; { int dura = System.Environment.TickCount - read_Stream_startTickcount; if (dura > timeOut) { fileWriteState = FileWriteState.Timeout; DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 读取超时{1}!", mRemoteFile, dura); break; } } yield return null; } { fileWriteState = FileWriteState.Timeout; DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 读取超时{1}!", mRemoteFile, dura); break; } } yield return null; } if (fileRequest != null) { fileRequest.Abort(); fileRequest = null; } { fileRequest.Abort(); fileRequest = null; } if (fileWriteState == FileWriteState.Error || fileWriteState == FileWriteState.Timeout) { DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); { DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); if (fileResponse != null) { fileResponse.Close(); fileResponse = null; } mHadError = true; done = true; gDownloadIsRunningCount--; yield break; } { fileResponse.Close(); fileResponse = null; } gDownloadIsRunningCount--; mHadError = true; done = true; yield break; } try { FileInfo localTempFileInfo = new FileInfo(mLocalFileTemp); FileInfo localTempFileInfo = new FileInfo(mLocalFileTemp); if (localTempFileInfo.Exists) { //临时文件存在,需要判断大小是否一致 //判断临时文件和远程文件size是否一致 #if !UNITY_WEBPLAYER if (localTempFileInfo.Length != mRemoteFileSize && mRemoteFileSize != 0L) { mHadError = true; DebugEx.LogError(string.Format(localFile + " 下载完成后, 但是大小{0} 和远程文件不一致 {1}", localTempFileInfo.Length, mRemoteFileSize)); } { mHadError = true; DebugEx.LogError(string.Format(localFile + " 下载完成后, 但是大小{0} 和远程文件不一致 {1}", localTempFileInfo.Length, mRemoteFileSize)); } else { //大小一致 mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 } gDownloadIsRunningCount--; done = true; #endif } { //大小一致 mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件 } } else { //临时文件不存在 mHadError = true; gDownloadIsRunningCount--; done = true; } #endif } { //临时文件不存在 mHadError = true; } #endif } catch (Exception ex) { DebugEx.LogError(ex); mHadError = true; } } bool IsOutdated { get { if (File.Exists(mLocalFileTemp)) return mRemoteLastModified > mLocalLastModified; return false; } } { DebugEx.LogError(ex); mHadError = true; } yield return null; gDownloadIsRunningCount--; done = true; } bool IsOutdated { get { if (File.Exists(mLocalFileTemp)) return mRemoteLastModified > mLocalLastModified; return false; } } enum FileWriteState { None, Writting, Completed, Error, Timeout, } Stream inStream; FileStream fs; FileWriteState fileWriteState = FileWriteState.None; //下载文件写入状态 { None, Writting, Completed, Error, Timeout, } Stream inStream; FileStream fs; FileWriteState fileWriteState = FileWriteState.None; //下载文件写入状态 void ReadDataCallback(IAsyncResult ar) { { if (stop) { return; } } try { { if (inStream != null) { int read = inStream.EndRead(ar); @@ -738,79 +751,79 @@ fileWriteState = FileWriteState.Completed; } } } } catch (Exception ex) { { if (!processErroring) { DebugEx.LogWarning(ex); DebugEx.LogWarning("ReadDataCallback 异常信息: " + ex.Message); } { DebugEx.LogWarning(ex); DebugEx.LogWarning("ReadDataCallback 异常信息: " + ex.Message); } if (fs != null) { fs.Close(); fs = null; } { fs.Close(); fs = null; } if (inStream != null) { inStream.Close(); inStream = null; } fileWriteState = FileWriteState.Error; } } { inStream.Close(); inStream = null; } fileWriteState = FileWriteState.Error; } } void WriteDataCallBack(IAsyncResult _asyncResult) { fs.Flush(); inStream.BeginRead(buff, 0, bufferSize, new AsyncCallback(ReadDataCallback), null); read_Stream_startTickcount = System.Environment.TickCount; } #if UseWebClient //|| UNITY_IOS protected void DownloadCompleted(System.Object sender, AsyncCompletedEventArgs e) { done = true; } #else // Throwind an exception here will not propogate to unity! } #if UseWebClient //|| UNITY_IOS protected void DownloadCompleted(System.Object sender, AsyncCompletedEventArgs e) { done = true; } #else // Throwind an exception here will not propogate to unity! protected void AsynchCallback(IAsyncResult result) { { try { { if (result == null) { DebugEx.LogError("Asynch result is null!"); mHadError = true; } HttpWebRequest webRequest = (HttpWebRequest)result.AsyncState; { DebugEx.LogError("Asynch result is null!"); mHadError = true; } HttpWebRequest webRequest = (HttpWebRequest)result.AsyncState; if (webRequest == null) { DebugEx.LogError("Could not cast to web request"); mHadError = true; } fileResponse = webRequest.EndGetResponse(result) as HttpWebResponse; { DebugEx.LogError("Could not cast to web request"); mHadError = true; } fileResponse = webRequest.EndGetResponse(result) as HttpWebResponse; if (fileResponse == null) { DebugEx.LogError("Asynch response is null!"); mHadError = true; } } { DebugEx.LogError("Asynch response is null!"); mHadError = true; } } catch (Exception ex) { mHadError = true; DebugEx.LogWarning(ex); DebugEx.LogWarning("[RemoteFile] AsynchCallback 异常: " + ex.Message); } } #endif { mHadError = true; DebugEx.LogWarning(ex); DebugEx.LogWarning("[RemoteFile] AsynchCallback 异常: " + ex.Message); } } #endif public enum State { Wait, Working, Stoped, } } } } System/Chat/ChatCenter.cs
@@ -766,8 +766,8 @@ #endregion #region 境界渡劫私聊感谢 private string[] realmThankChats = new string[7] {"ThankMessage1", "ThankMessage2", "ThankMessage3", "ThankMessage4", "ThankMessage5","ThankMessage6","ThankMessage7"}; const string RealmThank = "ThankMessage"; const int RealmThankCount = 11; public void CheckSendRealmThanks() { try @@ -804,7 +804,7 @@ ChatCtrl.Inst.PteChatID = (int)teammate.id; ChatCtrl.Inst.PteChatName = teammate.mateName; LanguageVerify.toPlayerLevel = teammate.level; var content = realmThankChats[UnityEngine.Random.Range(0, 7)]; var content = StringUtility.Contact(RealmThank, UnityEngine.Random.Range(1, RealmThankCount + 1)); ChatCtrl.Inst.SendChatInfo(ChatInfoType.Friend, Language.Get(content)); } } System/FairyAu/FairyChangeTipWin.cs
@@ -68,6 +68,15 @@ notifyPack.Msg = result; GameNetSystem.Instance.SendInfo(notifyPack); CloseImmediately(); try { OperationLogCollect.Instance.ChatReport(result, Language.Get("GameNotice1"), string.Empty, ChatInfoType.Fairy); } catch (Exception e) { DebugEx.Log(e.Message); } } }); } System/FairyAu/FairyCreateWin.cs
@@ -75,7 +75,8 @@ MessageWin.Inst.ShowFixedTip(Language.Get("L1015")); return; } if (DirtyWordConfig.IsDirtWord(creationInput.text) || UIHelper.HasSpecialCharac(creationInput.text)) if (DirtyWordConfig.IsDirtWord(creationInput.text) || UIHelper.HasSpecialCharac(creationInput.text) || DirtyNameConfig.IsDirtName(creationInput.text)) { SysNotifyMgr.Instance.ShowTip("FamilyNameChangeUnlegal"); return; System/FairyAu/FairyModel.cs
@@ -461,7 +461,8 @@ errorCode = 0; return false; } if (DirtyWordConfig.IsDirtWord(_name) || UIHelper.HasSpecialCharac(_name)) if (DirtyWordConfig.IsDirtWord(_name) || UIHelper.HasSpecialCharac(_name) || DirtyNameConfig.IsDirtName(_name)) { errorCode = 1; return false; System/GeneralConfig/GeneralConfig.cs
@@ -137,6 +137,9 @@ public List<int> RebornAutoFightMapID { get; private set; } public string teamWorldCall; public int teamWorldCallInviteCount; public void Init() { try @@ -484,6 +487,9 @@ int[] mapIDs = GetIntArray("RebornAutoFightDungeon"); RebornAutoFightMapID = new List<int>(mapIDs); teamWorldCall = GetInputString("TeamWorldCall"); teamWorldCallInviteCount = GetInt("TeamWorldCall", 2); } catch (Exception ex) { System/HttpRequest/HttpBehaviour.cs
@@ -5,6 +5,8 @@ using System.Net; using System.Text; using System.IO; using System.Net.Security; using System.Security.Cryptography.X509Certificates; public class HttpBehaviour : MonoBehaviour { @@ -55,6 +57,7 @@ request.ReadWriteTimeout = 2000; request.Proxy = null; request.KeepAlive = false; ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationCallback; } catch (Exception ex) { @@ -107,6 +110,50 @@ } private static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) return true; var _acceptCertificate = true; if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) == SslPolicyErrors.RemoteCertificateNotAvailable) { _acceptCertificate = false; } else { if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNameMismatch) == SslPolicyErrors.RemoteCertificateNameMismatch) { _acceptCertificate = false; } if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) == SslPolicyErrors.RemoteCertificateChainErrors) { foreach (X509ChainStatus item in chain.ChainStatus) { if (item.Status != X509ChainStatusFlags.RevocationStatusUnknown && item.Status != X509ChainStatusFlags.OfflineRevocation) break; if (item.Status != X509ChainStatusFlags.NoError) { _acceptCertificate = false; } } } } if (_acceptCertificate == false) { _acceptCertificate = true; } return _acceptCertificate; } void Update() { if (Time.time > timeOut && !getResult) System/Login/CreateRoleWin.cs
@@ -196,7 +196,8 @@ MessageWin.Inst.ShowFixedTip(Language.Get("CreateRole_NameLimit")); return; } if (DirtyWordConfig.IsDirtWord(userNameInput.text) || UIHelper.HasSpecialCharac(userNameInput.text)) if (DirtyWordConfig.IsDirtWord(userNameInput.text) || UIHelper.HasSpecialCharac(userNameInput.text) || DirtyNameConfig.IsDirtName(userNameInput.text)) { MessageWin.Inst.ShowFixedTip(Language.Get("L1007")); return; System/Login/LoginModel.cs
@@ -15,7 +15,8 @@ public SDKUtility.FP_LoginOk sdkLoginResult; public SDKUtility.FP_CheckIDAuthentication sdkIDCheckIDAuthentication; public string localSaveAccountName { public string localSaveAccountName { get { return LocalSave.GetString(USER_ACCOUNT); } set { LocalSave.SetString(USER_ACCOUNT, value); } } @@ -24,19 +25,22 @@ public event Action accountBindOkEvent; bool m_ReconnecBackGround = false; public bool reconnectBackGround { public bool reconnectBackGround { get { return m_ReconnecBackGround; } set { m_ReconnecBackGround = value; } } bool m_OnCreateRole = false; public bool onCreateRole { public bool onCreateRole { get { return m_OnCreateRole; } set { m_OnCreateRole = value; } } bool m_Busy = false; public bool busy { public bool busy { get { return m_Busy; } set { m_Busy = value; } } @@ -269,7 +273,14 @@ send.Adult = 1; break; case VersionAuthority.Release: send.IDType = 1; if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Free) { send.IDType = 1; } else if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Mr) { send.IDType = 2; } send.AccID = sdkLoginResult.account; send.Password = sdkLoginResult.token; send.MAC = DeviceUtility.GetMac(); @@ -280,7 +291,6 @@ send.TokenExpire = sdkLoginResult.tokenExpire;// 内部登陆的时长,无所谓的 send.Phone = (byte)sdkLoginResult.phone; send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag; if (sdkIDCheckIDAuthentication.type == "1") { send.Adult = 1; System/Team/TeamModel.cs
@@ -3,6 +3,7 @@ using UnityEngine; using System; using TableConfig; using LitJson; namespace Snxxz.UI { @@ -15,9 +16,11 @@ FriendsModel friendsModel { get { return ModelCenter.Instance.GetModel<FriendsModel>(); } } DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } } public bool autoAcceptApplication { public bool autoAcceptApplication { get { return (PlayerDatas.Instance.baseData.ExAttr2 / 10) % 10 == 0; } set { set { var sendInfo = new CB904_tagCMChangeTeamCheckState(); sendInfo.JoinReqCheck = (byte)(value ? 0 : 1); sendInfo.InviteCheck = (byte)(autoAcceptInvitation ? 0 : 1); @@ -25,9 +28,11 @@ } } public bool autoAcceptInvitation { public bool autoAcceptInvitation { get { return PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0; } set { set { if ((PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0) != value) { var sendInfo = new CB904_tagCMChangeTeamCheckState(); @@ -46,15 +51,18 @@ public Dictionary<int, TeamTargetPreference> targetPreferences = new Dictionary<int, TeamTargetPreference>(); MyTeam m_MyTeam = new MyTeam(); public MyTeam myTeam { public MyTeam myTeam { get { return m_MyTeam; } private set { m_MyTeam = value; } } TeamMission m_CurrentMission; public TeamMission currentMission { public TeamMission currentMission { get { return m_CurrentMission; } set { set { if (m_CurrentMission != value) { m_CurrentMission = value; @@ -63,9 +71,11 @@ } TeamMission m_MissionBuf = new TeamMission(CURRENTMAP_MISSION, 0); public TeamMission missionBuf { public TeamMission missionBuf { get { return m_MissionBuf; } set { set { m_MissionBuf = value; if (missionLevelLimitChangeEvent != null) { @@ -75,27 +85,32 @@ } int m_LevelMinBuf = 1; public int levelMinBuf { public int levelMinBuf { get { return m_LevelMinBuf; } set { m_LevelMinBuf = value; } } int m_LevelMaxBuf = 1; public int levelMaxBuf { public int levelMaxBuf { get { return m_LevelMaxBuf; } set { m_LevelMaxBuf = value; } } TeamInviteType m_CurrentInviteType = TeamInviteType.Friend; public TeamInviteType currentInviteType { public TeamInviteType currentInviteType { get { return m_CurrentInviteType; } private set { m_CurrentInviteType = value; } } int m_CurrentSelectedInvitation = 0; public int currentSelectedInvitation { public int currentSelectedInvitation { get { return m_CurrentSelectedInvitation; } set { set { if (m_CurrentSelectedInvitation != value) { m_CurrentSelectedInvitation = value; @@ -111,9 +126,11 @@ public DateTime matchingEndTime { get; private set; } bool m_IsMatching = false; public bool isMatching { public bool isMatching { get { return m_IsMatching; } set { set { if (m_IsMatching != value) { m_IsMatching = value; @@ -151,13 +168,15 @@ } DateTime m_PrepareBeginTime; public DateTime prepareBeginTime { public DateTime prepareBeginTime { get { return m_PrepareBeginTime; } private set { m_PrepareBeginTime = value; } } TeamPrepare m_TeamPreapare = new TeamPrepare(); public TeamPrepare teamPrepare { public TeamPrepare teamPrepare { get { return m_TeamPreapare; } private set { m_TeamPreapare = value; } } @@ -373,9 +392,66 @@ levelRequirement = StringUtility.Contact(levelMin, "--", levelMax); } if (dungeonId != 0) { try { var json = JsonMapper.ToObject(GeneralConfig.Instance.teamWorldCall); if (json.Keys.Contains(dungeonId.ToString())) { var invite = false; var level = 1; var count = GeneralConfig.Instance.teamWorldCallInviteCount; switch (dungeonId) { case 311101: if (Config.Instance.Get<RealmConfig>(PlayerDatas.Instance.baseData.realmLevel).IsBigRealm == 1) { var index = 0; foreach (var item in Config.Instance.GetAllValues<RealmConfig>()) { if (item.IsBigRealm == 1) { index++; } if (item.Lv == PlayerDatas.Instance.baseData.realmLevel) { break; } } if (index <= 2) { invite = true; int.TryParse(json["311101"][index - 1].ToString(), out level); } } break; default: invite = true; int.TryParse(json[dungeonId.ToString()][0].ToString(), out level); break; } if (invite) { var sendInfo = new CB90A_tagCGInvitePlayerJoinTeamByLV(); sendInfo.LVLimit = (ushort)level; sendInfo.InviteCnt = (byte)count; GameNetSystem.Instance.SendInfo(sendInfo); } } } catch (System.Exception ex) { Debug.Log(ex); } } var content = Language.Get("WorldInvite", missionName, levelRequirement); ChatCtrl.Inst.SendInvite(content); SysNotifyMgr.Instance.ShowTip("SendWorldMessage"); } } Utility/LanguageVerify.cs
@@ -113,7 +113,7 @@ tables["edit_uid"] = account; tables["edit_rid"] = playerId.ToString(); tables["edit_name"] = playerName; tables["edit_name"] = UIHelper.ServerStringTrim(playerName); tables["notice"] = op_type == 2 ? string.Empty : verifyContent; var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0); @@ -170,16 +170,16 @@ tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag); tables["chat_type"] = 1.ToString(); tables["chat_channel"] = channel.ToString(); tables["chat_content"] = content; tables["chat_content"] = WWW.EscapeURL(UIHelper.TrimContentToServer(content)); tables["sender_uid"] = account; tables["sender_rid"] = playerId.ToString(); tables["sender_name"] = playerName; tables["sender_name"] = UIHelper.ServerStringTrim(playerName); tables["sender_level"] = PlayerDatas.Instance.baseData.PlayerID.ToString(); tables["sender_vip_level"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); tables["receiver_uid"] = string.Empty; tables["receiver_rid"] = channel == 3 ? toPlayer.ToString() : string.Empty; tables["receiver_name"] = channel == 3 ? toPlayerName : string.Empty; tables["receiver_name"] = channel == 3 ? UIHelper.ServerStringTrim(toPlayerName) : string.Empty; tables["receiver_level"] = channel == 3 ? (toPlayerLevel == 0 ? string.Empty : toPlayerLevel.ToString()) : string.Empty; tables["receiver_vip_level"] = string.Empty; Utility/OperationLogCollect.cs
@@ -146,12 +146,12 @@ tables["IP"] = DeviceUtility.GetIp(); tables["ChatChannel"] = channelName; tables["AccountID"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account; tables["RoleID"] = StringUtility.Contact(isFairy ? PlayerDatas.Instance.baseData.FamilyName : string.Empty, isFairy ? "-" : string.Empty, PlayerDatas.Instance.baseData.PlayerName); tables["RoleID"] = StringUtility.Contact(isFairy ? UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.FamilyName) : string.Empty, isFairy ? "-" : string.Empty, UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName)); tables["ToRoleID"] = toPlayer; tables["Level"] = PlayerDatas.Instance.baseData.LV.ToString(); tables["VIPLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); tables["Content"] = content; tables["Content"] = WWW.EscapeURL(UIHelper.TrimContentToServer(content)); HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(chatReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType); #endif Utility/UIHelper.cs
@@ -764,4 +764,13 @@ } return "D"; } public static string TrimContentToServer(string content) { content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty); content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty); content = content.Replace("=", string.Empty); content = content.Replace(" ", string.Empty); return content; } }