/// <summary> /// 实例化单个GO /// </summary> /// <param name="loadItem"></param> private void InstantiateSingleObj(LoadItemData loadItem) { GameObject go = GameObject.Instantiate(cacheObjs[loadItem.prefabABName]) as GameObject; go.name = NameTool.GetRealName(loadItem.prefabABName); EntityInfo info = cacheObjs[loadItem.organizeDataABName] as EntityInfo; go.GetComponent <EntityConfig>().InitSelf(info); RegistGameObject(go); if (go.GetComponent <ModuleBase>() != null) { go.GetComponent <ModuleBase>().Regist(); } }
/// <summary> /// 卸载不再需要的AssetBundle /// </summary> private void UnloadUnNeededAB() { List <string> unloadABs = new List <string>(); foreach (LoadItemData loadItem in loadDic.Values) { string bundleName = NameTool.GetBundleName(loadItem.prefabABName); if (!unloadABs.Contains(bundleName)) { unloadABs.Add(bundleName); } } MgrCenter.Instance.SendMsg(Msgs.GetMsgUnloadAssetBundles((ushort)AssetLoadEvent.UnloadBundles, unloadABs.ToArray(), false)); }
/// <summary> /// 加载资源申请 /// </summary> /// <param name="bundleName"></param> /// <param name="assetName"></param> public void LoadObjRequest(string bundleName, string assetName) { //↓发送加载资源请求给Asset Bundle的load模块 MgrCenter.Instance.SendMsg(Msgs.GetMsgAssetLoadRequest((ushort)AssetLoadEvent.LoadRequest, bundleName, assetName)); string uniqueName = NameTool.GetUniqueAssetStr(bundleName, assetName); //↓记录有多少个针对此资源的加载调用 if (!loadRequest.ContainsKey(uniqueName)) { loadRequest.Add(uniqueName, 1); } else { loadRequest[uniqueName]++; } }
public RectangleSetting(NameTool name = NameTool.Rectangle) { Name = name; if (Settings[Name] == null) { var borderColor = new ColorSelection(new Point(170, 8), new Size(90, 36)); borderColor.LabelText = "Рамка:"; borderColor.Color = Color.Crimson; var fillColor = new ColorSelection(new Point(260, 8), new Size(110, 36)); fillColor.LabelText = "Заливка:"; fillColor.Color = Color.Yellow; var slider = new Slider(new Point(370, 0), new Size(200, 50), "Размер:", 0, 100); slider.Format = SliderFormat.Pixel; slider.BackColor = Color.FromArgb(38, 38, 38); slider.Value = 5; Settings[Name] = new Control[] { slider, borderColor, fillColor }; } }
public void InvalidsFirstName() { NameTool.extractInitials("John1", "Tolkien"); }
public override void Execute(PointBlankPlayer executor, string[] args) { UnturnedPlayer player = (UnturnedPlayer)executor; if (args.Length > 1) { if (!UnturnedPlayer.TryGetPlayer(args[1], out player)) { UnturnedChat.SendMessage(executor, Translate("PlayerNotFound"), ConsoleColor.Red); return; } } if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer pTarget)) { if (player.Metadata.ContainsKey("pPosition")) { player.Metadata["pPosition"] = player.Position.Duplicate(); } else { player.Metadata.Add("pPosition", player.Position.Duplicate()); } player.Teleport(pTarget.Player.transform.position); UnturnedChat.SendMessage(executor, Translate("Teleport_Teleport", player.PlayerName, pTarget.PlayerName), ConsoleColor.Green); } else { Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name)); if (nTarget == null) { UnturnedChat.SendMessage(executor, Translate("Teleport_Invalid"), ConsoleColor.Red); return; } if (player.Metadata.ContainsKey("pPosition")) { player.Metadata["pPosition"] = player.Position.Duplicate(); } else { player.Metadata.Add("pPosition", player.Position.Duplicate()); } player.Teleport(nTarget.point); UnturnedChat.SendMessage(executor, Translate("Teleport_Teleport", player.PlayerName, ((LocationNode)nTarget).name), ConsoleColor.Green); } }
public override void Execute(PointBlankPlayer executor, string[] args) { if (args.Length < 2 || !UnturnedPlayer.TryGetPlayer(args[1], out UnturnedPlayer ply)) { if (executor == null) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } ply = (UnturnedPlayer)executor; } if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer pTarget)) { ply.Teleport(pTarget.Player.transform.position); UnturnedChat.SendMessage(executor, string.Format(Translations["Teleport_Teleport"], ply.PlayerName, pTarget.PlayerName), ConsoleColor.Green); } else { Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name)); if (nTarget == null) { UnturnedChat.SendMessage(executor, Translations["Teleport_Invalid"], ConsoleColor.Red); return; } ply.Teleport(nTarget.point); UnturnedChat.SendMessage(executor, string.Format(Translations["Teleport_Teleport"], ply.PlayerName, ((LocationNode)nTarget).name), ConsoleColor.Green); } }
public static void IShit(CSteamID steamID, byte[] packet, int offset, int size, int channel) { Provider._bytesReceived += (uint)size; Provider._packetsReceived++; if (Dedicator.isDedicated) { ESteamPacket packet2 = (ESteamPacket)packet[offset]; if (Provider.isUpdate(packet2)) { if (steamID == Provider.server) { for (int i = 0; i < Provider.receivers.Count; i++) { if (Provider.receivers[i].id == channel) { Provider.receivers[i].receive(steamID, packet, offset, size); return; } } } else { for (int j = 0; j < Provider.clients.Count; j++) { if (Provider.clients[j].playerID.steamID == steamID) { for (int k = 0; k < Provider.receivers.Count; k++) { if (Provider.receivers[k].id == channel) { Provider.receivers[k].receive(steamID, packet, offset, size); return; } } return; } } } } else { SteamPending pending; switch (packet2) { case ESteamPacket.WORKSHOP: { ulong num8; List <ulong> list = new List <ulong>(); string[] strArray = ReadWrite.getFolders("/Bundles/Workshop/Content"); for (int m = 0; m < strArray.Length; m++) { ulong num5; if (ulong.TryParse(ReadWrite.folderName(strArray[m]), out num5)) { list.Add(num5); } } string[] strArray2 = ReadWrite.getFolders(ServerSavedata.directory + "/" + Provider.serverID + "/Workshop/Content"); for (int n = 0; n < strArray2.Length; n++) { ulong num7; if (ulong.TryParse(ReadWrite.folderName(strArray2[n]), out num7)) { list.Add(num7); } } if (ulong.TryParse(new DirectoryInfo(Level.info.path).Parent.Name, out num8)) { list.Add(num8); } byte[] array = new byte[2 + (list.Count * 8)]; array[0] = 1; array[1] = (byte)list.Count; for (byte num9 = 0; num9 < list.Count; num9 = (byte)(num9 + 1)) { BitConverter.GetBytes(list[num9]).CopyTo(array, (int)(2 + (num9 * 8))); } Provider.send(steamID, ESteamPacket.WORKSHOP, array, array.Length, 0); return; } case ESteamPacket.TICK: { int num10; object[] objects = new object[] { (byte)14, Provider.net }; byte[] buffer2 = SteamPacker.getBytes(0, out num10, objects); Provider.send(steamID, ESteamPacket.TIME, buffer2, num10, 0); return; } case ESteamPacket.TIME: for (int num11 = 0; num11 < Provider.clients.Count; num11++) { if (Provider.clients[num11].playerID.steamID == steamID) { if (Provider.clients[num11].lastPing > 0f) { Provider.clients[num11].lastNet = Time.realtimeSinceStartup; Provider.clients[num11].lag(Time.realtimeSinceStartup - Provider.clients[num11].lastPing); Provider.clients[num11].lastPing = -1f; } return; } } return; case ESteamPacket.CONNECT: { long num14; double num15; long num16; double num17; SteamBlacklistID tid; for (int num12 = 0; num12 < Provider.pending.Count; num12++) { if (Provider.pending[num12].playerID.steamID == steamID) { Provider.Reject(steamID, ESteamRejection.ALREADY_PENDING); return; } } for (int num13 = 0; num13 < Provider.clients.Count; num13++) { if (Provider.clients[num13].playerID.steamID == steamID) { Provider.Reject(steamID, ESteamRejection.ALREADY_CONNECTED); return; } } Type[] types = new Type[] { Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE }; object[] objArray = SteamPacker.getObjects(steamID, offset, 0, packet, types); SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objArray[1], (string)objArray[2], (string)objArray[3], (string)objArray[11], (CSteamID)objArray[12]); if (((string)objArray[8]) != Provider.Version) { Provider.Reject(steamID, ESteamRejection.WRONG_VERSION); return; } if (newPlayerID.SteamName.Length < 2) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_SHORT); return; } if (newPlayerID.CharacterName.Length < 2) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT); return; } if (newPlayerID.SteamName.Length > 0x20) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_LONG); return; } if (newPlayerID.CharacterName.Length > 0x20) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_LONG); return; } if (long.TryParse(newPlayerID.SteamName, out num14) || double.TryParse(newPlayerID.SteamName, out num15)) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER); return; } if (long.TryParse(newPlayerID.CharacterName, out num16) || double.TryParse(newPlayerID.CharacterName, out num17)) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER); return; } if (Provider.filterName) { if (!NameTool.isValid(newPlayerID.SteamName)) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return; } if (!NameTool.isValid(newPlayerID.CharacterName)) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return; } } if (SteamBlacklist.checkBanned(steamID, out tid)) { int num18; object[] objArray2 = new object[] { (byte)9, tid.reason, tid.getTime() }; byte[] buffer3 = SteamPacker.getBytes(0, out num18, objArray2); Provider.send(steamID, ESteamPacket.BANNED, buffer3, num18, 0); return; } if (!SteamWhitelist.checkWhitelisted(steamID)) { Provider.Reject(steamID, ESteamRejection.WHITELISTED); return; } if ((Provider.clients.Count + 1) > Provider.maxPlayers) { Provider.Reject(steamID, ESteamRejection.SERVER_FULL); return; } byte[] buffer4 = (byte[])objArray[4]; if (buffer4.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } byte[] buffer5 = (byte[])objArray[5]; if (buffer5.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } byte[] h = (byte[])objArray[6]; if (h.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } if ((Provider.serverPassword == string.Empty) || Hash.verifyHash(buffer4, Provider._serverPasswordHash)) { if (Hash.verifyHash(buffer5, Level.hash)) { if (ReadWrite.appIn(h, (byte)objArray[7])) { if (((float)objArray[10]) < Provider.timeout) { Provider.pending.Add(new SteamPending(newPlayerID, (bool)objArray[9], (byte)objArray[13], (byte)objArray[14], (byte)objArray[15], (Color)objArray[0x10], (Color)objArray[0x11], (bool)objArray[0x12], (ulong)objArray[0x13], (ulong)objArray[20], (ulong)objArray[0x15], (ulong)objArray[0x16], (ulong)objArray[0x17], (ulong)objArray[0x18], (ulong)objArray[0x19], (ulong[])objArray[0x1a], (EPlayerSpeciality)((byte)objArray[0x1b]))); byte[] buffer1 = new byte[] { 3 }; Provider.send(steamID, ESteamPacket.VERIFY, buffer1, 1, 0); return; } Provider.Reject(steamID, ESteamRejection.PING); return; } Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } Provider.Reject(steamID, ESteamRejection.WRONG_PASSWORD); return; } default: if (packet2 != ESteamPacket.AUTHENTICATE) { Debug.LogError("Failed to handle message: " + packet2); return; } pending = null; for (int num19 = 0; num19 < Provider.pending.Count; num19++) { if (Provider.pending[num19].playerID.steamID == steamID) { pending = Provider.pending[num19]; break; } } break; } if (pending == null) { Provider.Reject(steamID, ESteamRejection.NOT_PENDING); } else if ((Provider.clients.Count + 1) > Provider.maxPlayers) { Provider.Reject(steamID, ESteamRejection.SERVER_FULL); } else { ushort count = BitConverter.ToUInt16(packet, 1); byte[] dst = new byte[count]; Buffer.BlockCopy(packet, 3, dst, 0, count); ushort num21 = BitConverter.ToUInt16(packet, 3 + count); byte[] buffer8 = new byte[num21]; Buffer.BlockCopy(packet, 5 + count, buffer8, 0, num21); if (!Provider.verifyTicket(steamID, dst)) { Provider.Reject(steamID, ESteamRejection.AUTH_VERIFICATION); } else if (num21 > 0) { if (!SteamGameServerInventory.DeserializeResult(out pending.inventoryResult, buffer8, num21, false)) { Provider.Reject(steamID, ESteamRejection.AUTH_ECON); } } else { pending.shirtItem = 0; pending.pantsItem = 0; pending.hatItem = 0; pending.backpackItem = 0; pending.vestItem = 0; pending.maskItem = 0; pending.glassesItem = 0; pending.skinItems = new int[0]; pending.packageShirt = 0L; pending.packagePants = 0L; pending.packageHat = 0L; pending.packageBackpack = 0L; pending.packageVest = 0L; pending.packageMask = 0L; pending.packageGlasses = 0L; pending.packageSkins = new ulong[0]; pending.inventoryResult = SteamInventoryResult_t.Invalid; pending.inventoryDetails = new SteamItemDetails_t[0]; pending.hasProof = true; } } } } }
public void ConvertUppercaseTest() { string initiale = NameTool.extractInitials("john", "tolkien"); Assert.AreEqual(initiale, "J T"); }
/// <summary> /// 设置plc父设备信息配置 /// </summary> /// <param name="mapID">地图ID</param> /// <param name="equList">设备列表</param> /// <param name="m_object">实体对象</param> /// <param name="note">YK,YX,YC 设置需要的分区类型</param> /// <returns>分区编号,-1表示失败</returns> private int SetPLCFartherInfo(string mapID, List <MyObject> equList, MyObject m_object, string note, ref List <p_area_cfg> areaList) { int areaID = -1; try { string farterEquid = string.Empty; farterEquid = (from a in equList where a.equtype == MyObject.ObjectType.P && a.equ.plcStationAddress == m_object.equ.plcStationAddress select a.equ.EquID).FirstOrDefault(); if (string.IsNullOrEmpty(farterEquid)) { PLCEqu plcInfo = new PLCEqu(); plcInfo.equtype = MyObject.ObjectType.P; plcInfo.equ.EquID = NameTool.CreateEquId(plcInfo.equtype); plcInfo.equ.EquName = plcInfo.equ.EquID; plcInfo.equ.plcStationAddress = m_object.equ.plcStationAddress; plcInfo.equ.AddressDiscribe = m_object.equ.plcStationAddress; plcInfo.equ.PointX = (Convert.ToInt32(m_object.equ.PointX) + 20).ToString(); plcInfo.equ.PointY = m_object.equ.PointY; plcInfo.equ.TaskWV = 1; plcInfo.equ.MapID = mapID; equList.Add(plcInfo); farterEquid = plcInfo.equ.EquID; } m_object.equ.FatherEquID = farterEquid; var temp = (from a in areaList where a.equid == farterEquid && a.note == note select a).FirstOrDefault(); if (temp == null) { p_area_cfg areainfo = new p_area_cfg(); areainfo = (from a in PlcString.p_config.areas where a.note == note select a).FirstOrDefault(); areainfo.equid = m_object.equ.FatherEquID; if (areainfo != null) { areaID = dbop.InsertArea(areainfo); areaList.Add(new p_area_cfg { equid = areainfo.equid, id = areaID, note = areainfo.note, point = areainfo.point, yclength = areainfo.yclength, ycstartAddress = areainfo.ycstartAddress, yxcommlength = areainfo.yxcommlength, yxlength = areainfo.yxlength, yxstartAddress = areainfo.yxstartAddress }); //areaList.Clear(); //areaList = ds.GetAllArea(); } } else { areaID = temp.id; } } catch (Exception e) { Log.WriteLog("SetPLCFartherInfo:" + e); return(-1); } return(areaID); }
private void AddFireConfig(List <MyObject> m_objList, XmlNode ConXml, string name, int x, ref string fartherEquID, string mapid) { int numMax = 0, numMin = 0; XmlNodeList PointNode = ConXml.SelectSingleNode("SY").ChildNodes; if (PointNode != null) { bool down; if (ConXml.Attributes["StrName"].Value.IndexOf('u') < 0) { down = false; } else { down = true; } if (fartherEquID == null) { FObject fire = new FObject(); fire.equ.EquTypeID = "F"; fire.equ.EquID = NameTool.CreateEquId(fire.equtype); fire.equ.EquName = "火灾主机"; fire.equ.PointX = "100"; fire.equ.PointY = "0"; fire.equ.MapID = mapid; m_objList.Add(fire); fartherEquID = fire.equ.EquID; } if (PointNode[1].Attributes["YX"].Value != "65535") { int temp = 0; numMax = Convert.ToInt32(PointNode[1].Attributes["YX"].Value); numMin = Convert.ToInt32(PointNode[0].Attributes["YX"].Value); for (; numMin <= numMax; numMin++) { FsbObject equinfo = new FsbObject(); equinfo.equ.EquTypeID = "F_SB"; equinfo.equ.EquID = NameTool.CreateEquId(equinfo.equtype); equinfo.equ.EquName = name + numMin; equinfo.equ.PointX = (x + temp * 20).ToString(); equinfo.equ.PointY = down == true ? "-1100" : "100"; equinfo.fire_pro.EquID = equinfo.equ.EquID; equinfo.equ.MapID = mapid; equinfo.equ.AddressDiscribe = 2 + "" + numMin.ToString("0000"); equinfo.fire_pro = new f_c_cfg { EquID = equinfo.equ.EquID, FireNum = 2 + "" + numMin.ToString("0000"), Note = equinfo.equ.EquName }; temp++; m_objList.Add(equinfo); } } if (PointNode[3].Attributes["YX"].Value != "65535") { int temp = 0; numMax = Convert.ToInt32(PointNode[3].Attributes["YX"].Value); numMin = Convert.ToInt32(PointNode[2].Attributes["YX"].Value); for (; numMin <= numMax; numMin++) { FlObject equinfo = new FlObject(); equinfo.equ.EquTypeID = "F_L"; equinfo.equ.EquID = NameTool.CreateEquId(equinfo.equtype); equinfo.equ.EquName = name + numMin; equinfo.equ.PointX = (x + temp * 20).ToString(); equinfo.equ.PointY = down == true ? "-1150" : "50"; equinfo.equ.MapID = mapid; equinfo.equ.AddressDiscribe = 4 + "" + numMin.ToString("0000"); equinfo.fire_pro = new f_c_cfg { EquID = equinfo.equ.EquID, FireNum = 4 + "" + numMin.ToString("0000"), Note = equinfo.equ.EquName }; temp++; m_objList.Add(equinfo); } } if (PointNode[5].Attributes["YX"].Value != "65535") { int temp = 0; numMax = Convert.ToInt32(PointNode[5].Attributes["YX"].Value); numMin = Convert.ToInt32(PointNode[4].Attributes["YX"].Value); for (; numMin <= numMax; numMin++) { FygObject equinfo = new FygObject(); equinfo.equtype = MyObject.ObjectType.F_YG; equinfo.equ.EquID = NameTool.CreateEquId(equinfo.equtype); equinfo.equ.EquName = 3 + name + numMin.ToString("0000"); equinfo.equ.PointX = (x + temp * 30).ToString(); equinfo.equ.PointY = down == true ? "-1200" : "0"; equinfo.equ.MapID = mapid; equinfo.equ.AddressDiscribe = 3 + "" + numMin.ToString("0000"); equinfo.fire_pro = new f_c_cfg { EquID = equinfo.equ.EquID, FireNum = 3 + "" + numMin, Note = equinfo.equ.EquName }; temp++; m_objList.Add(equinfo); } } } }
public void InvalidsParametersTest() { NameTool.extractInitials("John1", "Tolkien3"); }
// Start is called before the first frame update void Start() { introduction.gameObject.SetActive(false); // 读表 Role role; role.roleId = 1; role.name = "调皮镜"; role.ackId = (int)SkillEunm.SkillID.normalAck; role.ackDescribe = "发射光线"; role.skillId = (int)SkillEunm.SkillID.groupChaos; role.skillDescribe = "颠倒方向"; roles.Add(role); role.roleId = 2; role.name = "智慧镜"; role.ackId = (int)SkillEunm.SkillID.normalAck; role.ackDescribe = "发射光线"; role.skillId = (int)SkillEunm.SkillID.fiveThunder; role.skillDescribe = "直接伤害"; roles.Add(role); role.roleId = 3; role.name = "活泼镜"; role.ackId = (int)SkillEunm.SkillID.normalAck; role.ackDescribe = "发射光线"; role.skillId = (int)SkillEunm.SkillID.protectiveCover; role.skillDescribe = "护盾防御"; roles.Add(role); role.roleId = 4; role.name = "邪恶镜"; role.ackId = (int)SkillEunm.SkillID.normalAck; role.ackDescribe = "发射光线"; role.skillId = (int)SkillEunm.SkillID.nightBringer; role.skillDescribe = "限制视野"; roles.Add(role); nameTool = GetComponent <NameTool>(); audioController = GetComponent <AudioController>(); audioController.BGMPlay(AudioEunm.mainBGM, 0.8f); instance = this; for (int i = 0; i < roleBtns.Length; ++i) { int index = i; indexs.Add(index); roleBtns[i].onClick.AddListener( delegate() { onClickHandler(index); } ); } nameInput.onEndEdit.AddListener(EditEndHandler); if (LocalStorage.GetString("name") == string.Empty) { string name = nameTool.getName(); nameInput.text = name; LocalStorage.SetString("name", name); } else { nameInput.text = LocalStorage.GetString("name"); } if (GameData.user == null) { // 没有UUID,第一次登陆 if (LocalStorage.GetString("UUID") == string.Empty) { // 生成UUID,发射给服务端,服务端返回UUID以及ID,然后记录下来 string uuid = System.Guid.NewGuid().ToString(); LocalStorage.SetString("UUID", uuid); LocalStorage.SetInt("ROLE", selectIndex); UserDTO user = new UserDTO(); user.Id = -1; user.Uuid = uuid; this.WriteMessage((int)MsgTypes.TypeLogin, (int)LoginTypes.LoginCreq, user.ToByteArray()); } else { selectIndex = LocalStorage.GetInt("ROLE"); UserDTO user = new UserDTO(); user.Id = -1; user.Uuid = LocalStorage.GetString("UUID"); this.WriteMessage((int)MsgTypes.TypeLogin, (int)LoginTypes.LoginCreq, user.ToByteArray()); } } else { selectIndex = LocalStorage.GetInt("ROLE"); if (GameData.match) { Match(); } } onClickHandler(selectIndex); }
public void NullLastName() { NameTool.extractInitials("John", null); }
public void NullFirstName() { NameTool.extractInitials(null, "Tolkien"); }
public void NullParametersTest() { NameTool.extractInitials(null, null); }
public void EasyTest() { string initiale = NameTool.extractInitials("John", "Tolkien"); Assert.AreEqual(initiale, "J T"); }
public static bool Prefix(CSteamID steamID, byte[] packet, int offset, int size, int channel) { if (!Dedicator.isDedicated) { return(true); } byte index1 = packet[offset]; if (!(index1 < (byte)26)) { UnityEngine.Debug.LogWarning((object)("Received invalid packet index from " + (object)steamID + ", so we're refusing them")); SDG.Unturned.Provider.refuseGarbageConnection(steamID, "sv invalid packet index"); } else { ESteamPacket packet1 = (ESteamPacket)index1; if (packet1 == ESteamPacket.AUTHENTICATE || packet1 == ESteamPacket.CONNECT) { Console.WriteLine(packet1); } if (packet1 == ESteamPacket.CONNECT) { RocketPlayer player = new RocketPlayer(steamID.ToString()); bool result = player.HasPermission("QueueBypasser.Skip"); Console.WriteLine(result); if (!result) { return(true); //We don't need to do jack shit because he doesn't have the right permission. } for (int index2 = 0; index2 < SDG.Unturned.Provider.pending.Count; ++index2) { if (SDG.Unturned.Provider.pending[index2].playerID.steamID == steamID) { Console.WriteLine("line 1"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_PENDING); return(true); } } for (int index2 = 0; index2 < SDG.Unturned.Provider.clients.Count; ++index2) { if (SDG.Unturned.Provider.clients[index2].playerID.steamID == steamID) { Console.WriteLine("line 2"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_CONNECTED); return(true); } } object[] objects = SteamPacker.getObjects(steamID, offset, 0, packet, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.UINT32_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.UINT32_TYPE); SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objects[1], (string)objects[2], (string)objects[3], (string)objects[11], (CSteamID)objects[12]); if (objects[8].ToString() != SDG.Unturned.Provider.APP_VERSION && (int)(uint)objects[8] != Parser.getUInt32FromIP(SDG.Unturned.Provider.APP_VERSION)) { Console.WriteLine("line 3"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_VERSION); return(true); } if (newPlayerID.playerName.Length < 2) { Console.WriteLine("line 4"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_SHORT); return(true); } if (newPlayerID.characterName.Length < 2) { Console.WriteLine("line 5"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT); return(true); } if (newPlayerID.playerName.Length > 32) { Console.WriteLine("line 6"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_LONG); return(true); } if (newPlayerID.characterName.Length > 32) { Console.WriteLine("line 7"); //Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_LONG); return(true); } long result1; double result2; if (long.TryParse(newPlayerID.playerName, out result1) || double.TryParse(newPlayerID.playerName, out result2)) { Console.WriteLine("line 8"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER); return(true); } long result3; double result4; if (long.TryParse(newPlayerID.characterName, out result3) || double.TryParse(newPlayerID.characterName, out result4)) { Console.WriteLine("line 9"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER); return(true); } if (SDG.Unturned.Provider.filterName) { if (!NameTool.isValid(newPlayerID.playerName)) { Console.WriteLine("line 10"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(true); } if (!NameTool.isValid(newPlayerID.characterName)) { Console.WriteLine("line 11"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(true); } } if (NameTool.containsRichText(newPlayerID.playerName)) { Console.WriteLine("line 12"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(true); } if (NameTool.containsRichText(newPlayerID.characterName)) { Console.WriteLine("line 13"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(true); } P2PSessionState_t pConnectionState; uint ip = !SteamGameServerNetworking.GetP2PSessionState(steamID, out pConnectionState) ? 0U : pConnectionState.m_nRemoteIP; SteamBlacklistID blacklistID; if (SteamBlacklist.checkBanned(steamID, ip, out blacklistID)) { //int size1; //byte[] bytes = SteamPacker.getBytes(0, out size1, (object)(byte)9, (object)blacklistID.reason, (object)blacklistID.getTime()); //SDG.Unturned.Provider.send(steamID, ESteamPacket.BANNED, bytes, size1, 0); Console.WriteLine("line 15"); return(true); } bool flag3 = SteamWhitelist.checkWhitelisted(steamID); if (SDG.Unturned.Provider.isWhitelisted && !flag3) { Console.WriteLine("line 16"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WHITELISTED); return(true); } byte[] hash_0_1 = (byte[])objects[4]; if (hash_0_1.Length != 20) { Console.WriteLine("line 17"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); return(true); } byte[] hash_0_2 = (byte[])objects[5]; if (hash_0_2.Length != 20) { Console.WriteLine("line 18"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); return(true); } byte[] h = (byte[])objects[6]; if (h.Length != 20) { Console.WriteLine("line 19"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); return(true); } string str1 = (string)objects[29]; ModuleDependency[] moduleDependencyArray; if (string.IsNullOrEmpty(str1)) { moduleDependencyArray = new ModuleDependency[0]; } else { string[] strArray1 = str1.Split(';'); moduleDependencyArray = new ModuleDependency[strArray1.Length]; for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2) { string[] strArray2 = strArray1[index2].Split(','); if (strArray2.Length == 2) { moduleDependencyArray[index2] = new ModuleDependency(); moduleDependencyArray[index2].Name = strArray2[0]; uint.TryParse(strArray2[1], out moduleDependencyArray[index2].Version_Internal); } } } critMods.Clear(); ModuleHook.getRequiredModules(critMods); bool flag4 = true; for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2) { bool flag2 = false; if (moduleDependencyArray[index2] != null) { for (int index3 = 0; index3 < critMods.Count; ++index3) { if (critMods[index3] != null && critMods[index3].config != null && (critMods[index3].config.Name == moduleDependencyArray[index2].Name && critMods[index3].config.Version_Internal >= moduleDependencyArray[index2].Version_Internal)) { flag2 = true; return(true); } } } if (!flag2) { flag4 = false; return(true); } } if (!flag4) { //SDG.Unturned.Provider.reject(steamID, ESteamRejection.CLIENT_MODULE_DESYNC); Console.WriteLine("line 20"); return(true); } bool flag5 = true; for (int index2 = 0; index2 < critMods.Count; ++index2) { bool flag2 = false; if (critMods[index2] != null && critMods[index2].config != null) { for (int index3 = 0; index3 < moduleDependencyArray.Length; ++index3) { if (moduleDependencyArray[index3] != null && moduleDependencyArray[index3].Name == critMods[index2].config.Name && moduleDependencyArray[index3].Version_Internal >= critMods[index2].config.Version_Internal) { flag2 = true; return(true); } } } if (!flag2) { flag5 = false; return(true); } } if (!flag5) { //SDG.Unturned.Provider.reject(steamID, ESteamRejection.SERVER_MODULE_DESYNC); Console.WriteLine("line 21"); return(true); } Console.WriteLine("section 1"); if (SDG.Unturned.Provider.serverPassword == string.Empty || Hash.verifyHash(hash_0_1, _serverPasswordHash)) { Console.WriteLine("section 2"); if (Hash.verifyHash(hash_0_2, Level.hash)) { Console.WriteLine("section 3"); if (ReadWrite.appIn(h, (byte)objects[7])) { Console.WriteLine("section 4"); if ((double)(float)objects[10] < (double)SDG.Unturned.Provider.configData.Server.Max_Ping_Milliseconds / 1000.0) { Console.WriteLine("section 5"); //var pending = new SteamPending(newPlayerID, (bool)objects[9], (byte)objects[13], (byte)objects[14], (byte)objects[15], (Color)objects[16], (Color)objects[17], (Color)objects[18], (bool)objects[19], (ulong)objects[20], (ulong)objects[21], (ulong)objects[22], (ulong)objects[23], (ulong)objects[24], (ulong)objects[25], (ulong)objects[26], (ulong[])objects[27], (EPlayerSkillset)(byte)objects[28], (string)objects[30], (CSteamID)objects[31]); //Provider.pending.Insert(0, pending); //pending.sendVerifyPacket(); //Console.WriteLine($"Accepting {pending.playerID.steamID}."); return(false); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.PING); Console.WriteLine("line 22"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); Console.WriteLine("line 23"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); Console.WriteLine("line 24"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); Console.WriteLine("line 25"); return(true); } } return(true); }
public static bool Prefix(CSteamID steamID, byte[] packet, int offset) { var steamPacket = (ESteamPacket)packet[offset]; if (steamPacket == ESteamPacket.CONNECT) { for (int l = 0; l < Provider.pending.Count; l++) { if (Provider.pending[l].playerID.steamID == steamID) { Provider.reject(steamID, ESteamRejection.ALREADY_PENDING); return(false); } } for (int m = 0; m < Provider.clients.Count; m++) { if (Provider.clients[m].playerID.steamID == steamID) { Provider.reject(steamID, ESteamRejection.ALREADY_CONNECTED); return(false); } } object[] objects = SteamPacker.getObjects(steamID, offset, 0, packet, new Type[] { Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.UINT32_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.UINT32_TYPE, Types.BYTE_ARRAY_TYPE }); byte[] array3 = (byte[])objects[33]; if (array3.Length != 20) { Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); return(false); } byte newCharacterID = (byte)objects[1]; if (!Provider.modeConfigData.Players.Allow_Per_Character_Saves) { newCharacterID = 0; } SteamPlayerID steamPlayerID = new SteamPlayerID(steamID, newCharacterID, (string)objects[2], (string)objects[3], (string)objects[11], (CSteamID)objects[12], array3); if ((uint)objects[8] != Provider.APP_VERSION_PACKED) { Provider.reject(steamID, ESteamRejection.WRONG_VERSION, Provider.APP_VERSION); return(false); } if ((uint)objects[32] != Level.packedVersion) { Provider.reject(steamID, ESteamRejection.WRONG_LEVEL_VERSION, Level.version); return(false); } if (steamPlayerID.playerName.Length < 2) { Provider.reject(steamID, ESteamRejection.NAME_PLAYER_SHORT); return(false); } if (steamPlayerID.characterName.Length < 2) { Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT); return(false); } if (steamPlayerID.playerName.Length > 32) { Provider.reject(steamID, ESteamRejection.NAME_PLAYER_LONG); return(false); } if (steamPlayerID.characterName.Length > 32) { Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_LONG); return(false); } if (long.TryParse(steamPlayerID.playerName, NumberStyles.Any, CultureInfo.InvariantCulture, out _) || double.TryParse(steamPlayerID.playerName, NumberStyles.Any, CultureInfo.InvariantCulture, out _)) { Provider.reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER); return(false); } if (long.TryParse(steamPlayerID.characterName, NumberStyles.Any, CultureInfo.InvariantCulture, out _) || double.TryParse(steamPlayerID.characterName, NumberStyles.Any, CultureInfo.InvariantCulture, out _)) { Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER); return(false); } if (Provider.filterName) { if (!NameTool.isValid(steamPlayerID.playerName)) { Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(false); } if (!NameTool.isValid(steamPlayerID.characterName)) { Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(false); } } if (NameTool.containsRichText(steamPlayerID.playerName)) { Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(false); } if (NameTool.containsRichText(steamPlayerID.characterName)) { Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(false); } uint remoteIP; if (SteamGameServerNetworking.GetP2PSessionState(steamID, out P2PSessionState_t p2PSessionState_t)) { remoteIP = p2PSessionState_t.m_nRemoteIP; } else { remoteIP = 0U; } Utils.checkBanStatus(steamPlayerID, remoteIP, out bool flag3, out string object_, out uint num5); if (flag3) { byte[] bytes3 = SteamPacker.getBytes(0, out int size4, 9, object_, num5); Provider.send(steamID, ESteamPacket.BANNED, bytes3, size4, 0); return(false); } bool flag4 = SteamWhitelist.checkWhitelisted(steamID); if (Provider.isWhitelisted && !flag4) { Provider.reject(steamID, ESteamRejection.WHITELISTED); return(false); } if (Provider.clients.Count - Dummy.Instance.Dummies.Count + 1 > Provider.maxPlayers && Provider.pending.Count + 1 > Provider.queueSize) { Provider.reject(steamID, ESteamRejection.SERVER_FULL); return(false); } byte[] array4 = (byte[])objects[4]; if (array4.Length != 20) { Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); return(false); } byte[] array5 = (byte[])objects[5]; if (array5.Length != 20) { Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); return(false); } byte[] array6 = (byte[])objects[6]; if (array6.Length != 20) { Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); return(false); } string text = (string)objects[29]; ModuleDependency[] array7; if (string.IsNullOrEmpty(text)) { array7 = Array.Empty <ModuleDependency>(); } else { string[] array8 = text.Split(new char[] { ';' }); array7 = new ModuleDependency[array8.Length]; for (int n = 0; n < array7.Length; n++) { string[] array9 = array8[n].Split(new char[] { ',' }); if (array9.Length == 2) { array7[n] = new ModuleDependency { Name = array9[0] }; uint.TryParse(array9[1], NumberStyles.Any, CultureInfo.InvariantCulture, out array7[n].Version_Internal); } } } var moduleList = new List <Module>(); ModuleHook.getRequiredModules(moduleList); bool flag5 = true; for (int num6 = 0; num6 < array7.Length; num6++) { bool flag6 = false; if (array7[num6] != null) { for (int num7 = 0; num7 < moduleList.Count; num7++) { if (moduleList[num7]?.config != null && moduleList[num7].config.Name == array7[num6].Name && moduleList[num7].config.Version_Internal >= array7[num6].Version_Internal) { flag6 = true; break; } } } if (!flag6) { flag5 = false; break; } } if (!flag5) { Provider.reject(steamID, ESteamRejection.CLIENT_MODULE_DESYNC); return(false); } bool flag7 = true; for (int num8 = 0; num8 < moduleList.Count; num8++) { bool flag8 = false; if (moduleList[num8]?.config != null) { for (int num9 = 0; num9 < array7.Length; num9++) { if (array7[num9] != null && array7[num9].Name == moduleList[num8].config.Name && array7[num9].Version_Internal >= moduleList[num8].config.Version_Internal) { flag8 = true; break; } } } if (!flag8) { flag7 = false; break; } } if (!flag7) { Provider.reject(steamID, ESteamRejection.SERVER_MODULE_DESYNC); return(false); } if (!string.IsNullOrEmpty(Provider.serverPassword) && !Hash.verifyHash(array4, Provider.serverPasswordHash)) { Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); return(false); } if (!Hash.verifyHash(array5, Level.hash)) { Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); return(false); } if (!ReadWrite.appIn(array6, (byte)objects[7])) { Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); return(false); } if ((float)objects[10] >= Provider.configData.Server.Max_Ping_Milliseconds / 1000f) { Provider.reject(steamID, ESteamRejection.PING); return(false); } Utils.notifyClientPending(steamID); SteamPending item = new SteamPending(steamPlayerID, (bool)objects[9], (byte)objects[13], (byte)objects[14], (byte)objects[15], (Color)objects[16], (Color)objects[17], (Color)objects[18], (bool)objects[19], (ulong)objects[20], (ulong)objects[21], (ulong)objects[22], (ulong)objects[23], (ulong)objects[24], (ulong)objects[25], (ulong)objects[26], (ulong[])objects[27], (EPlayerSkillset)((byte)objects[28]), (string)objects[30], (CSteamID)objects[31]); if (Provider.isWhitelisted || !flag4) { Provider.pending.Add(item); if (Provider.pending.Count == 1) { Utils.verifyNextPlayerInQueue(); } return(false); } if (Provider.pending.Count == 0) { Provider.pending.Add(item); Utils.verifyNextPlayerInQueue(); return(false); } Provider.pending.Insert(1, item); return(false); } return(true); }
public void InvalidsLastName() { NameTool.extractInitials("John", "Tolkien1"); }
/// <summary> /// 读取地图中的配置 /// </summary> /// <param name="mapID">地图ID</param> /// <param name="path">配置文件路径</param> /// <param name="mapHeight">地图高度</param> /// <param name="MapWidth">地图宽度</param> /// <param name="readEquType">该设备类型是否进行读取</param> /// <returns>读取是否成功</returns> public bool Read(string mapID, string path, int mapHeight, int MapWidth, ReadEquType readEquType) { XmlDocument doc = new XmlDocument(); // 缓存设备 List <MyObject> equList = new List <MyObject>(); try { doc.Load(path); // 设备加载 List <Equ> equs = ds.ReadEqu(Convert.ToInt32(mapID)); List <yx> yxs = ds.GetYXs(); List <Yx_cfg> yxcfgs = ds.GetYXcfgs(); List <yk> yks = ds.GetYks(); List <Yk_cfg> ykcfgs = ds.GetYKcfgs(); List <yc> ycs = ds.GetYcs(); List <Yc_cfg> yccfgs = ds.GetYccfgs(); List <p_area_cfg> areas = ds.GetAllArea(); Log.WriteLog("start readxml:" + DateTime.Now.ToString("HH:mm:ss.fff")); List <Yx_cfg> yxcfgdb = new List <Yx_cfg>(); List <Yk_cfg> ykcfgdb = new List <Yk_cfg>(); //交大地图的宽度和高度 int width = Convert.ToInt32(doc.GetElementsByTagName("PicInfo")[0].Attributes["width"].InnerText); int hight = Convert.ToInt32(doc.GetElementsByTagName("PicInfo")[0].Attributes["hight"].InnerText); XmlNodeList xnl = doc.GetElementsByTagName("ob"); if (xnl != null) { //读取父设备信息 string tvFarther = ds.GetFartherID("TV"); string epFarther = ds.GetFartherID("EP"); string firFarther = ds.GetFartherID("F"); for (int i = 0; i < xnl.Count; i++) { MyObject m_object = null; //m_object = new MyObject(); string type = xnl[i].Attributes["Type"].Value; XmlNode ConXml = xnl[i].SelectSingleNode("ControlObject"); XmlNode drawob = xnl[i].SelectSingleNode("DrawOb"); XmlNode name = drawob.SelectSingleNode("ObjectName"); XmlNode xy = drawob.SelectSingleNode("EndPoint"); if (Convert.ToInt32(xy.Attributes["X"].Value) < 0) { continue; } if (Convert.ToInt32(xy.Attributes["Y"].Value) < 0) { continue; } switch (type) { case "12836": //情报板 #region 情报板 if (!readEquType.CMS) { continue; } m_object = new CMObject(); string strName = ConXml.Attributes["StrName"].Value; if (strName.IndexOf("1") > 0) //门架 { m_object.equtype = MyObject.ObjectType.CM; } //else //if (strName.IndexOf("2") > 0)//限速标志 //{ // m_object.equtype = "S"; //} else //F板 { m_object.equtype = MyObject.ObjectType.CF; } if (strName.IndexOf("r") > 0) { m_object.equ.DirectionID = 1; } if (strName.IndexOf("l") > 0) { m_object.equ.DirectionID = 2; } #region 情报板配置信息读取 XmlDocument xd = new XmlDocument(); var cmsNode = ConXml.SelectSingleNode("ExtAttribute"); if (cmsNode == null) { continue; } string cmsInfo = cmsNode.InnerText; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); xd.LoadXml(cmsInfo); ((CMSEqu)m_object).cms_pro.CMSWidth = Convert.ToInt32(xd.GetElementsByTagName("CMS")[0].Attributes["Width"].InnerText); ((CMSEqu)m_object).cms_pro.CMSHeight = Convert.ToInt32(xd.GetElementsByTagName("CMS")[0].Attributes["Height"].InnerText); ((CMSEqu)m_object).cms_pro.EquID = m_object.equ.EquID; ((CMSEqu)m_object).cms_pro.FontType = "楷体"; ((CMSEqu)m_object).cms_pro.FontColor = "黄"; ((CMSEqu)m_object).cms_pro.BackColor = "黑"; ((CMSEqu)m_object).cms_pro.FontSize = 24; ((CMSEqu)m_object).cms_pro.ContentType = 1; ((CMSEqu)m_object).cms_pro.CharBetween = 5; ((CMSEqu)m_object).cms_pro.OutType = 1; ((CMSEqu)m_object).cms_pro.OutSpeed = 20; ((CMSEqu)m_object).cms_pro.StayTime = 200; ((CMSEqu)m_object).cms_pro.BlankCount = 0; ((CMSEqu)m_object).cms_pro.MinFontSize = 16; ((CMSEqu)m_object).cms_pro.SupportPic = 1; ((CMSEqu)m_object).cms_pro.PicLocation = "CmsListBitmap1"; #endregion m_object.equ.TaskWV = 1; #endregion break; case "12839": //限速标志 m_object = new MyObject(); if (!readEquType.S) { continue; } m_object.equtype = MyObject.ObjectType.S; m_object.equ.TaskWV = 1; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); break; case "12838": //车检器 if (!readEquType.VC) { continue; } m_object = new MyObject(); m_object.equtype = MyObject.ObjectType.VC; m_object.equ.AlarmMethod = "NORMAL"; m_object.equ.TaskWV = 1; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); break; case "12862": //气象仪 if (!readEquType.VI) { continue; } m_object = new MyObject(); m_object.equtype = MyObject.ObjectType.VI; m_object.equ.AlarmMethod = "YW"; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.TaskWV = 1; break; case "12834": //广播 continue; case "12832": //紧急电话 if (!readEquType.EP) { continue; } m_object = new EPEqu(); m_object.equtype = MyObject.ObjectType.EP_T; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); AddEPConfig((EPEqu)m_object, ConXml); break; case "12833": //摄像机 if (!readEquType.TV) { continue; } m_object = new TVEqu(); switch (ConXml.Attributes["StrName"].Value) { case "lcctv1_mov.bmp": case "rcctv1_mov.bmp": m_object.equtype = MyObject.ObjectType.TV_CCTV_Gun; break; case "rcctv2_mov.bmp": case "lcctv2_mov.bmp": m_object.equtype = MyObject.ObjectType.TV_CCTV_E; break; default: m_object.equtype = MyObject.ObjectType.TV_CCTV_Ball; break; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); if (!ConXml.Attributes["Region"].Value.Equals("0")) { AddCCTVConfig((TVEqu)m_object, ConXml.Attributes["Region"].Value); } break; case "12835": //火灾 if (!readEquType.FIRE) { continue; } //m_object = new MyObject(); XmlNode addressxy = drawob.SelectSingleNode("EndPoint"); int x = Convert.ToInt32(addressxy.Attributes["X"].Value) * MapWidth / width; AddFireConfig(equList, ConXml, name.InnerText, x, ref firFarther, mapID); continue; #region plc case "12837": //车道指示器 if (!readEquType.P_TL) { continue; } m_object = new PLCEqu(); switch (ConXml.Attributes["StrName"].Value) { case "lindicator_mov.bmp": //左 case "uindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL5_Left; break; case "rindicator_mov.bmp": //右 case "dindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL5_Right; break; case "sindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL2_Close; break; default: continue; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12831": //交通灯 if (!readEquType.P_HL) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_HL2; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12830": //照明 if (!readEquType.LIGHT) { continue; } m_object = new PLCEqu(); if (name.InnerText.IndexOf("应") > 0 || name.InnerText.IndexOf("引") > 0) //基本 { m_object.equtype = MyObject.ObjectType.P_LYJ; } else if (name.InnerText.IndexOf("JQ") > 0 || name.InnerText.IndexOf("加") > 0) //加强 { m_object.equtype = MyObject.ObjectType.P_LJQ; } else //基本 { m_object.equtype = MyObject.ObjectType.P_L; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12829": //风机 if (!readEquType.P_JF) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_JF; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12846": //GJ if (!readEquType.GJ) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_GJ; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12843": //CO if (!readEquType.CO) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_CO; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12844": //VI if (!readEquType.VI) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_VI; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12848": //TW if (!readEquType.TW) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_TW; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12842": //横通门 if (!readEquType.TD) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_TD; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12845": //高位水池 if (!readEquType.LLID) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_LLDI; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12855": //水泵 if (!readEquType.P_P) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_P; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12840": //车行横通标志\转弯灯 if (!readEquType.P_TL2) { continue; } m_object = new PLCEqu(); switch (ConXml.Attributes["StrName"].Value) { case "uvehicleflag_mov.bmp": //向上 m_object.equtype = MyObject.ObjectType.P_TL2_UP; break; case "dvehicleflag_mov.bmp": //向下 m_object.equtype = MyObject.ObjectType.P_TL2_Down; break; default: continue; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; #endregion default: continue; } m_object.equ.EquName = name.InnerText; m_object.equ.PileNo = ConXml.Attributes["Badge"].Value; m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; m_object.equ.MapID = mapID; m_object.equ.plcStationAddress = ConXml.Attributes["Station"].Value; m_object.equ.AddressDiscribe = xnl[i].Attributes["ID"].Value; #region 子系统 if ("-1".Equals(ConXml.Attributes["Station"].Value) && m_object.equtype != MyObject.ObjectType.TV_CCTV_Gun) { if (m_object.equtype == MyObject.ObjectType.TV_CCTV_Gun || m_object.equtype == MyObject.ObjectType.TV_CCTV_E || m_object.equtype == MyObject.ObjectType.TV_CCTV_Ball || m_object.equtype == MyObject.ObjectType.EP_T) { } else { continue; } } if (m_object.equ.EquTypeID.StartsWith("TV_CCTV")) { if (tvFarther == null) { TVEqu tvInfo = new TVEqu(); tvInfo.equtype = MyObject.ObjectType.TV; tvInfo.equ.EquID = NameTool.CreateEquId(tvInfo.equtype); tvInfo.equ.EquName = "摄像机流媒体服务器"; tvInfo.equ.PointX = "0"; tvInfo.equ.PointY = "0"; tvInfo.equ.TaskWV = 1; tvInfo.equ.MapID = mapID; equList.Add(tvInfo); tvFarther = tvInfo.equ.EquID; } m_object.equ.FatherEquID = tvFarther; } if (m_object.equ.EquTypeID.StartsWith("EP_")) { if (epFarther == null) { EPEqu epInfo = new EPEqu(); epInfo.equtype = MyObject.ObjectType.EP; epInfo.equ.EquID = NameTool.CreateEquId(epInfo.equtype); epInfo.equ.EquName = "紧急电话主机"; epInfo.equ.PointX = "50"; epInfo.equ.PointY = "0"; epInfo.equ.TaskWV = 1; epInfo.equ.MapID = mapID; equList.Add(epInfo); epFarther = epInfo.equ.EquID; } m_object.equ.FatherEquID = epFarther; } if (m_object.equ.EquTypeID.StartsWith("F_")) { } #endregion equList.Add(m_object); } int InsertCount = 0; if (equList.Count > 0) { InsertCount = dbop.InsertEqu(equList); List <Tv_cctv_cfg> tvinfos = new List <Tv_cctv_cfg>(); List <f_c_cfg> fireinfos = new List <f_c_cfg>(); List <ep_c_cfg> epinfos = new List <ep_c_cfg>(); List <c_cfg> cms = new List <c_cfg>(); Log.WriteLog("yxcfgdb:" + DateTime.Now); if (yxcfgdb.Count > 0) { dbop.InsertYXConfig(yxcfgdb); } Log.WriteLog("ykcfgdb:" + DateTime.Now); if (ykcfgdb.Count > 0) { dbop.InsertYKConfig(ykcfgdb); } Log.WriteLog("子系统:" + DateTime.Now); for (int i = 0; i < equList.Count; i++) { if (equList[i] is FireEqu)//插入火灾配置信息 { fireinfos.Add((equList[i] as FireEqu).fire_pro); } else if (equList[i] is TVEqu)//插入摄像机配置信息 { if ((equList[i] as TVEqu).tv_pro.CCTVID != null) { tvinfos.Add((equList[i] as TVEqu).tv_pro); } } else if (equList[i] is EPEqu)//插入紧急电话配置 { epinfos.Add((equList[i] as EPEqu).ep_pro); } else if (equList[i] is CMSEqu)//插入plc配置信息 { cms.Add((equList[i] as CMSEqu).cms_pro); } } Log.WriteLog("火灾配置条数:" + dbop.InsertFire(fireinfos)); Log.WriteLog("摄像机配置条数:" + dbop.InsertCCTV(tvinfos)); Log.WriteLog("紧急电话配置条数:" + dbop.InsertEpList(epinfos)); Log.WriteLog("情报板配置条数:" + dbop.InsertC_cfgList(cms)); } //Log.WriteLog("InsertCount:" + InsertCount); } } catch (Exception e) { Log.WriteLog(e); return(false); } return(true); }
public void MultipleFirstName() { string initiale = NameTool.extractInitials("John Ronald Reuel", "Tolkien"); Assert.AreEqual(initiale, "JRR T"); }
public override void Execute(PointBlankPlayer executor, string[] args) { if (args.Length > 0) { if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer target)) { UnturnedServer.Players.ForEach((player) => { if (player.Metadata.ContainsKey("pPosition")) { player.Metadata["pPosition"] = player.Position.Duplicate(); } else { player.Metadata.Add("pPosition", player.Position.Duplicate()); } player.Teleport(target.Position); }); return; } Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name)); if (nTarget == null) { UnturnedChat.SendMessage(executor, Translate("TpAll_Invalid"), ConsoleColor.Red); return; } UnturnedServer.Players.ForEach((player) => { if (player.Metadata.ContainsKey("pPosition")) { player.Metadata["pPosition"] = player.Position.Duplicate(); } else { player.Metadata.Add("pPosition", player.Position.Duplicate()); } player.Teleport(nTarget.point); }); } else { if (UnturnedPlayer.IsServer(executor)) { UnturnedChat.SendMessage(executor, Translate("TargetServer"), ConsoleColor.Red); return; } UnturnedServer.Players.ForEach((player) => { if (player.Metadata.ContainsKey("pPosition")) { player.Metadata["pPosition"] = player.Position.Duplicate(); } else { player.Metadata.Add("pPosition", player.Position.Duplicate()); } player.Teleport(((UnturnedPlayer)executor).Position); }); } }
public void MultipleLastName() { string initiale = NameTool.extractInitials("John", "Tolkien Saquet"); Assert.AreEqual(initiale, "J TS"); }