当前位置: 首页>>代码示例>>C#>>正文


C# GSPacketIn.Skip方法代码示例

本文整理汇总了C#中GSPacketIn.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# GSPacketIn.Skip方法的具体用法?C# GSPacketIn.Skip怎么用?C# GSPacketIn.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GSPacketIn的用法示例。


在下文中一共展示了GSPacketIn.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            packet.Skip(4);
            int slot = packet.ReadShort();
            InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot);
            if (item != null)
            {
                if (item.IsIndestructible)
                {
                    client.Out.SendMessage(String.Format("You can't destroy {0}!",
                        item.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (item.Id_nb == "ARelic")
                {
                    client.Out.SendMessage("You cannot destroy a relic!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (client.Player.Inventory.EquippedItems.Contains(item))
                {
                    client.Out.SendMessage("You cannot destroy an equipped item!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (client.Player.Inventory.RemoveItem(item))
                {
                    client.Out.SendMessage("You destroy the " + item.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    InventoryLogging.LogInventoryAction(client.Player, "(destroy)", eInventoryActionType.Other, item.Template, item.Count);
                }
            }
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:33,代码来源:DestroyItemRequestHandler.cs

示例2: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			if (client == null || client.Player == null)
				return;

			if ((client.Player.TargetObject is IGameInventoryObject) == false)
				return;

			MarketSearch.SearchData search = new MarketSearch.SearchData();

			search.name = packet.ReadString(64);
			search.slot = (int)packet.ReadInt();
			search.skill = (int)packet.ReadInt();
			search.resist = (int)packet.ReadInt();
			search.bonus = (int)packet.ReadInt();
			search.hp = (int)packet.ReadInt();
			search.power = (int)packet.ReadInt();
			search.proc = (int)packet.ReadInt();
			search.qtyMin = (int)packet.ReadInt();
			search.qtyMax = (int)packet.ReadInt();
			search.levelMin = (int)packet.ReadInt();
			search.levelMax = (int)packet.ReadInt();
			search.priceMin = (int)packet.ReadInt();
			search.priceMax = (int)packet.ReadInt();
			search.visual = (int)packet.ReadInt();
			search.page = (byte)packet.ReadByte();
			byte unk1 = (byte)packet.ReadByte();
			short unk2 = (short)packet.ReadShort();
			byte unk3 = 0;
			byte unk4 = 0;
			byte unk5 = 0;
			byte unk6 = 0;
			byte unk7 = 0;
			byte unk8 = 0;

			if (client.Version >= GameClient.eClientVersion.Version198)
			{
				// Dunnerholl 2009-07-28 Version 1.98 introduced new options to Market search. 12 Bytes were added, but only 7 are in usage so far in my findings.
				// update this, when packets change and keep in mind, that this code reflects only the 1.98 changes
				search.armorType = search.page; // page is now used for the armorType (still has to be logged, i just checked that 2 means leather, 0 = standard
				search.damageType = (byte)packet.ReadByte(); // 1=crush, 2=slash, 3=thrust
				unk3 = (byte)packet.ReadByte();
				unk4 = (byte)packet.ReadByte();
				unk5 = (byte)packet.ReadByte();
				search.playerCrafted = (byte)packet.ReadByte(); // 1 = show only Player crafted, 0 = all
				// 3 bytes unused
				packet.Skip(3);
				search.page = (byte)packet.ReadByte(); // page is now sent here
				unk6 = (byte)packet.ReadByte();
				unk7 = (byte)packet.ReadByte();
				unk8 = (byte)packet.ReadByte();
			}

			search.clientVersion = client.Version.ToString();

			(client.Player.TargetObject as IGameInventoryObject).SearchInventory(client.Player, search);
		}
开发者ID:mynew4,项目名称:DOLSharp,代码行数:57,代码来源:PlayerMarketSearchRequestHandler.cs

示例3: HandlePacket

		/// <summary>
		/// Called when the packet has been received
		/// </summary>
		/// <param name="client">Client that sent the packet</param>
		/// <param name="packet">Packet data</param>
		/// <returns>Non zero if function was successfull</returns>
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			packet.Skip(4); //Skip the first 4 bytes
			long pingDiff = (DateTime.Now.Ticks - client.PingTime)/1000;
			client.PingTime = DateTime.Now.Ticks;
			ulong timestamp = packet.ReadInt();

			client.Out.SendPingReply(timestamp,packet.Sequence);
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:15,代码来源:PingRequestHandler.cs

示例4: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			// for 1.115c+ The First client packet Changes.
			if (client.Version < GameClient.eClientVersion.Version1115)
			{
				int rc4 = packet.ReadByte();
				byte clientType = (byte)packet.ReadByte();
				client.ClientType = (GameClient.eClientType)(clientType & 0x0F);
				client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0);
				byte major = (byte)packet.ReadByte();
				byte minor = (byte)packet.ReadByte();
				byte build = (byte)packet.ReadByte();
				if(rc4==1)
				{
					//DOLConsole.Log("SBox=\n");
					//DOLConsole.LogDump(client.PacketProcessor.Encoding.SBox);
					packet.Read(((PacketEncoding168)client.PacketProcessor.Encoding).SBox,0,256);
					((PacketEncoding168)client.PacketProcessor.Encoding).EncryptionState=PacketEncoding168.eEncryptionState.PseudoRC4Encrypted;
					//DOLConsole.WriteLine(client.Socket.RemoteEndPoint.ToString()+": SBox set!");
					//DOLConsole.Log("SBox=\n");
					//DOLConsole.LogDump(((PacketEncoding168)client.PacketProcessor.Encoding).SBox);
				}
				else
				{
				  //Send the crypt key to the client
					client.Out.SendVersionAndCryptKey();
				}
			}
			else
			{
				// we don't handle Encryption for 1.115c
				// the rc4 secret can't be unencrypted from RSA.
				
				// register client type
				byte clientType = (byte)packet.ReadByte();
				client.ClientType = (GameClient.eClientType)(clientType & 0x0F);
				client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0);
				
				// if the DataSize is above 7 then the RC4 key is bundled
				// this is stored in case we find a way to handle encryption someday !
				if (packet.DataSize > 7)
				{
					packet.Skip(6);
					ushort length = packet.ReadShortLowEndian();
					packet.Read(client.PacketProcessor.Encoding.SBox, 0, length);
					// ((PacketEncoding168)client.PacketProcessor.Encoding).EncryptionState=PacketEncoding168.eEncryptionState.PseudoRC4Encrypted;
				}
				
				//Send the crypt key to the client
				client.Out.SendVersionAndCryptKey();
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:52,代码来源:CryptKeyRequestHandler.cs

示例5: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			packet.Skip(8);
			string cmdLine = packet.ReadString(255);
			if(!ScriptMgr.HandleCommand(client, cmdLine))
			{
				if (cmdLine[0] == '&')
				{
					cmdLine = '/' + cmdLine.Remove(0, 1);
				}
				client.Out.SendMessage("No such command ("+cmdLine+")",eChatType.CT_System,eChatLoc.CL_SystemWindow);
			}
		}
开发者ID:Refizul,项目名称:DOL-Kheldron,代码行数:13,代码来源:PlayerCommandHandler.cs

示例6: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			int packetVersion;
			switch (client.Version)
			{
				case GameClient.eClientVersion.Version168:
				case GameClient.eClientVersion.Version169:
				case GameClient.eClientVersion.Version170:
				case GameClient.eClientVersion.Version171:
				case GameClient.eClientVersion.Version172:
				case GameClient.eClientVersion.Version173:
					packetVersion = 168;
					break;
				default:
					packetVersion = 174;
					break;
			}

			packet.Skip(4); //Skip the first 4 bytes
			if (packetVersion == 174)
			{
				packet.Skip(1);
			}

			string charName = packet.ReadString(28);

            // WHRIA START
            if (charName.Length >= 5)
            {
                if (charName.Substring(0, 4) == "slot")
                {
                    int iSelected = 0;
                    if (charName.Substring(4, 1) == "a") iSelected = 0;
                    if (charName.Substring(4, 1) == "b") iSelected = 1;
                    if (charName.Substring(4, 1) == "c") iSelected = 2;
                    if (charName.Substring(4, 1) == "d") iSelected = 3;
                    if (charName.Substring(4, 1) == "e") iSelected = 4;
                    if (charName.Substring(4, 1) == "f") iSelected = 5;
                    if (charName.Substring(4, 1) == "g") iSelected = 6;
                    if (charName.Substring(4, 1) == "h") iSelected = 7;
                    if (charName.Substring(4, 1) == "i") iSelected = 8;
                    if (charName.Substring(4, 1) == "j") iSelected = 9;

                    int sizeOfCharacter = client.Account.Characters.Length;

                    for (int j = 0; j < sizeOfCharacter; j++)
                    {
                        int iSlot = client.Account.Characters[j].AccountSlot;
                        if (iSlot >= 300) iSlot -= 300; if (iSlot >= 200) iSlot -= 200; if (iSlot >= 100) iSlot -= 100;

                        if (iSlot == iSelected)
                        {
                            Regex nameCheck = new Regex("^[A-Z][a-zA-Z]");
                            if (!nameCheck.IsMatch(client.Account.Characters[j].Name)
                                && client.Account.Characters[j] != null)
                            {
                                charName = client.Account.Characters[j].Name;
                            }
                        }
                    }
                }
            }
            //  END


			//TODO Character handling 
			if (charName.Equals("noname"))
			{
				client.Out.SendSessionID();
			}
			else
			{
				// SH: Also load the player if client player is NOT null but their charnames differ!!!
				// only load player when on charscreen and player is not loaded yet
				// packet is sent on every region change (and twice after "play" was pressed)
				if (
					(
						(client.Player == null && client.Account.Characters != null)
						|| (client.Player != null && client.Player.Name.ToLower() != charName.ToLower())
					) && client.ClientState == GameClient.eClientState.CharScreen)
				{
					bool charFound = false;
					for (int i = 0; i < client.Account.Characters.Length; i++)
					{
						if (client.Account.Characters[i] != null
						    && client.Account.Characters[i].Name == charName)
						{
							charFound = true;
							// Notify Character Selection Event, last hope to fix any bad data before Loading.
							GameEventMgr.Notify(DatabaseEvent.CharacterSelected, new CharacterEventArgs(client.Account.Characters[i], client));
							client.LoadPlayer(i);
							break;
						}
					}
					if (charFound == false)
					{
						client.Player = null;
						client.ActiveCharIndex = -1;
					}
					else
//.........这里部分代码省略.........
开发者ID:mynew4,项目名称:DAoC,代码行数:101,代码来源:CharacterSelectRequestHandler.cs

示例7: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int packetVersion;
            switch (client.Version)
            {
                case GameClient.eClientVersion.Version168:
                case GameClient.eClientVersion.Version169:
                case GameClient.eClientVersion.Version170:
                case GameClient.eClientVersion.Version171:
                case GameClient.eClientVersion.Version172:
                case GameClient.eClientVersion.Version173:
                    packetVersion = 168;
                    break;
                default:
                    packetVersion = 174;
                    break;
            }

            packet.Skip(4); //Skip the first 4 bytes
            if (packetVersion == 174)
            {
                packet.Skip(1);
            }

            string charName = packet.ReadString(28);

            //TODO Character handling
            if (charName.Equals("noname"))
            {
                client.Out.SendSessionID();
            }
            else
            {
                // SH: Also load the player if client player is NOT null but their charnames differ!!!
                // only load player when on charscreen and player is not loaded yet
                // packet is sent on every region change (and twice after "play" was pressed)
                if (
                    (
                        (client.Player == null && client.Account.Characters != null)
                        || (client.Player != null && client.Player.Name.ToLower() != charName.ToLower())
                    ) && client.ClientState == GameClient.eClientState.CharScreen)
                {
                    bool charFound = false;
                    for (int i = 0; i < client.Account.Characters.Length; i++)
                    {
                        if (client.Account.Characters[i] != null
                            && client.Account.Characters[i].Name == charName)
                        {
                            charFound = true;
                            client.LoadPlayer(i);
                            break;
                        }
                    }
                    if (charFound == false)
                    {
                        client.Player = null;
                        client.ActiveCharIndex = -1;
                    }
                    else
                    {
                        // Log character play
                        AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, "", charName);
                    }
                }

                if (client.Player == null)
                {
                    // client keeps sending the name of the deleted char even if new one was created, correct name only after "play" button pressed
                    //client.Server.Error(new Exception("ERROR, active character not found!!! name="+charName));
                }

                client.Out.SendSessionID();
            }
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:74,代码来源:CharacterSelectRequestHandler.cs

示例8: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player == null)
                return;

            string filter = packet.ReadString(64);
            int slot = (int)packet.ReadInt();
            int skill = (int)packet.ReadInt();
            int resist = (int)packet.ReadInt();
            int bonus = (int)packet.ReadInt();
            int hp = (int)packet.ReadInt();
            int power = (int)packet.ReadInt();
            int proc = (int)packet.ReadInt();
            int qtyMin = (int)packet.ReadInt();
            int qtyMax = (int)packet.ReadInt();
            int levelMin = (int)packet.ReadInt();
            int levelMax = (int)packet.ReadInt();
            int priceMin = (int)packet.ReadInt();
            int priceMax = (int)packet.ReadInt();
            int visual = (int)packet.ReadInt();
            byte page = (byte)packet.ReadByte();
            byte unk1 = (byte)packet.ReadByte();
            short unk2 = (short)packet.ReadShort();
			if(client.Version >= GameClient.eClientVersion.Version198)
			{
				// Dunnerholl 2009-07-28 Version 1.98 introduced new options to Market search. 12 Bytes were added, but only 7 are in usage so far in my findings.
				// update this, when packets change and keep in mind, that this code reflects only the 1.98 changes
				byte armorType = page; // page is now used for the armorType (still has to be logged, i just checked that 2 means leather, 0 = standard
				byte damageType = (byte)packet.ReadByte(); // 1=crush, 2=slash, 3=thrust
				// 3 bytes unused
				packet.Skip(3);
				byte playerCrafted = (byte)packet.ReadByte(); // 1 = show only Player crafted, 0 = all
				// 3 bytes unused
				packet.Skip(3);
				page = (byte)packet.ReadByte(); // page is now sent here
				byte unknown = (byte)packet.ReadByte(); // always been 0xE5, if u page it is 0x4B, tested on alb only
				byte unknown2 = (byte)packet.ReadByte(); //always been 0x12, if u page it is 0x7C, tested on alb only
				byte unknown3 = (byte)packet.ReadByte(); //always been 0x00, if u page it is 0x1B, tested on alb only
			}
            int requestedPage = (int)page;

            int firstSlot = 0 + (requestedPage * 20);
            int lastSlot = 19 + (requestedPage * 20);

            StringBuilder sql = new StringBuilder();

            sql.Append("SlotPosition >= 1500 AND OwnerLot != 0 ");

            if (filter != null && filter != "")
                sql.Append(" AND Name LIKE '%" + filter + "%'");


			#region Slot
			if (slot != -1)
			{
				switch (slot)
				{
					case 0:
						sql.Append(" AND Item_Type = '22'");
						break;
					case 1:
						sql.Append(" AND Item_Type = '23'");
						break;
					case 2:
						sql.Append(" AND Item_Type = '21'");
						break;
					case 3:
						sql.Append(" AND Item_Type = '28'");
						break;
					case 4:
						sql.Append(" AND Item_Type = '27'");
						break;
					case 5:
						sql.Append(" AND Item_Type = '25'");
						break;
					case 6:
						sql.Append(" AND Item_Type IN (35, 36)");
						break;
					case 7:
						sql.Append(" AND Item_Type IN (33, 34)");
						break;
					case 8:
						sql.Append(" AND Item_Type = '32'");
						break;
					case 9:
						sql.Append(" AND Item_Type = '29'");
						break;
					case 10:
						sql.Append(" AND Item_Type = '26'");
						break;
					case 11:
						sql.Append(" AND Item_Type = '24'");
						break;
					case 12:
						sql.Append(" AND Item_Type IN (10, 11)");
						break;
					case 13:
						sql.Append(" AND Object_Type = '42'");
						break;
					case 14:
//.........这里部分代码省略.........
开发者ID:boscorillium,项目名称:dol,代码行数:101,代码来源:PlayerMarketSearchRequestHandler.cs

示例9: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			string ipAddress = client.TcpEndpointAddress;

			packet.Skip(2); //Skip the client_type byte
			var major = (byte)packet.ReadByte();
			var minor = (byte)packet.ReadByte();
			var build = (byte)packet.ReadByte();
			string password = packet.ReadString(20);

			bool v174;
			//the logger detection we had is no longer working
			//bool loggerUsing = false;
			switch (client.Version)
			{
				case GameClient.eClientVersion.Version168:
				case GameClient.eClientVersion.Version169:
				case GameClient.eClientVersion.Version170:
				case GameClient.eClientVersion.Version171:
				case GameClient.eClientVersion.Version172:
				case GameClient.eClientVersion.Version173:
					v174 = false;
					break;
				default:
					v174 = true;
					break;
			}

			if (v174)
			{
				packet.Skip(11);
			}
			else
			{
				packet.Skip(7);
			}

			uint c2 = packet.ReadInt();
			uint c3 = packet.ReadInt();
			uint c4 = packet.ReadInt();

			if (v174)
			{
				packet.Skip(27);
			}
			else
			{
				packet.Skip(31);
			}

			string userName = packet.ReadString(20);
			/*
			if (c2 == 0 && c3 == 0x05000000 && c4 == 0xF4000000)
			{
				loggerUsing = true;
				Log.Warn("logger detected (" + username + ")");
			}*/

			// check server status
			if (GameServer.Instance.ServerStatus == eGameServerStatus.GSS_Closed)
			{
				client.Out.SendLoginDenied(eLoginError.GameCurrentlyClosed);
				Log.Info(ipAddress + " disconnected because game is closed!");
				GameServer.Instance.Disconnect(client);

				return;
			}

			// check connection allowed with serverrules
			try
			{
				if (!GameServer.ServerRules.IsAllowedToConnect(client, userName))
				{
					if (Log.IsInfoEnabled)
						Log.Info(ipAddress + " disconnected because IsAllowedToConnect returned false!");

					GameServer.Instance.Disconnect(client);

					return;
				}
			}
			catch (Exception e)
			{
				if (Log.IsErrorEnabled)
					Log.Error("Error shutting down Client after IsAllowedToConnect failed!", e);
			}

			// Handle connection
			EnterLock(userName);

			try
			{
				Account playerAccount;
				// Make sure that client won't quit
				lock (client)
				{
					GameClient.eClientState state = client.ClientState;
					if (state != GameClient.eClientState.NotConnected)
					{
						Log.DebugFormat("wrong client state on connect {0} {1}", userName, state.ToString());
//.........这里部分代码省略.........
开发者ID:boscorillium,项目名称:dol,代码行数:101,代码来源:LoginRequestHandler.cs

示例10: HandlePacket

        //static int lastZ=int.MinValue;
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            //Tiv: in very rare cases client send 0xA9 packet before sending S<=C 0xE8 player world initialize
            if ((client.Player.ObjectState != GameObject.eObjectState.Active) ||
                (client.ClientState != GameClient.eClientState.Playing))
                return;

            int environmentTick = Environment.TickCount;
            int packetVersion;
            if (client.Version > GameClient.eClientVersion.Version171)
            {
                packetVersion = 172;
            }
            else
            {
                packetVersion = 168;
            }

            int oldSpeed = client.Player.CurrentSpeed;

            //read the state of the player
            packet.Skip(2); //PID
            ushort data = packet.ReadShort();
            int speed = (data & 0x1FF);

            //			if(!GameServer.ServerRules.IsAllowedDebugMode(client)
            //				&& (speed > client.Player.MaxSpeed + SPEED_TOL))

            if ((data & 0x200) != 0)
                speed = -speed;

            if (client.Player.IsMezzed || client.Player.IsStunned)
            {
                // Nidel: updating client.Player.CurrentSpeed instead of speed
                client.Player.CurrentSpeed = 0;
            }
            else
            {
                client.Player.CurrentSpeed = (short)speed;
            }

            client.Player.IsStrafing = ((data & 0xe000) != 0);

            int realZ = packet.ReadShort();
            ushort xOffsetInZone = packet.ReadShort();
            ushort yOffsetInZone = packet.ReadShort();
            ushort currentZoneID;
            if (packetVersion == 168)
            {
                currentZoneID = (ushort)packet.ReadByte();
                packet.Skip(1); //0x00 padding for zoneID
            }
            else
            {
                currentZoneID = packet.ReadShort();
            }

            //Dinberg - Instance considerations.
            //Now this gets complicated, so listen up! We have told the client a lie when it comes to the zoneID.
            //As a result, every movement update, they are sending a lie back to us. Two liars could get confusing!

            //BUT, the lie we sent has a truth to it - the geometry and layout of the zone. As a result, the zones
            //x and y offsets will still actually be relevant to our current zone. And for the clones to have been
            //created, there must have been a real zone to begin with, of id == instanceZone.SkinID.

            //So, although our client is lying to us, and thinks its in another zone, that zone happens to coincide
            //exactly with the zone we are instancing - and so all the positions still ring true.

            //Philosophically speaking, its like looking in a mirror and saying 'Am I a reflected, or reflector?'
            //What it boils down to has no bearing whatsoever on the result of anything, so long as someone sitting
            //outside of the unvierse knows not to listen to whether you say which you are, and knows the truth to the
            //answer. Then, he need only know what you are doing ;)

            Zone newZone = WorldMgr.GetZone(currentZoneID);
            if (newZone == null)
            {
                if (client.Player == null) return;
                if (!client.Player.TempProperties.getProperty("isbeingbanned", false))
                {
                    if (log.IsErrorEnabled)
                        log.Error(client.Player.Name + "'s position in unknown zone! => " + currentZoneID);
                    GamePlayer player = client.Player;
                    player.TempProperties.setProperty("isbeingbanned", true);
                    player.MoveToBind();
                }

                return; // TODO: what should we do? player lost in space
            }

            // move to bind if player fell through the floor
            if (realZ == 0)
            {
                client.Player.MoveTo(
                    (ushort)client.Player.DBCharacter.BindRegion,
                    client.Player.DBCharacter.BindXpos,
                    client.Player.DBCharacter.BindYpos,
                    (ushort)client.Player.DBCharacter.BindZpos,
                    (ushort)client.Player.DBCharacter.BindHeading
                );
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:PlayerPositionUpdateHandler.cs

示例11: HandlePacket

		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			int packetVersion;
			switch (client.Version)
			{
				case GameClient.eClientVersion.Version168:
				case GameClient.eClientVersion.Version169:
				case GameClient.eClientVersion.Version170:
				case GameClient.eClientVersion.Version171:
				case GameClient.eClientVersion.Version172:
				case GameClient.eClientVersion.Version173:
					packetVersion = 168;
					break;
				default:
					packetVersion = 174;
					break;
			}

			packet.Skip(4); //Skip the first 4 bytes
			if (packetVersion == 174)
			{
				packet.Skip(1);
			}

			string charName = packet.ReadString(28);

			//TODO Character handling 
			if (charName.Equals("noname"))
			{
				client.Out.SendSessionID();
			}
			else
			{
				// SH: Also load the player if client player is NOT null but their charnames differ!!!
				// only load player when on charscreen and player is not loaded yet
				// packet is sent on every region change (and twice after "play" was pressed)
				if (
					(
						(client.Player == null && client.Account.Characters != null)
						|| (client.Player != null && client.Player.Name.ToLower() != charName.ToLower())
					) && client.ClientState == GameClient.eClientState.CharScreen)
				{
					bool charFound = false;
					for (int i = 0; i < client.Account.Characters.Length; i++)
					{
						if (client.Account.Characters[i] != null
						    && client.Account.Characters[i].Name == charName)
						{
							charFound = true;
							// Notify Character Selection Event, last hope to fix any bad data before Loading.
							GameEventMgr.Notify(DatabaseEvent.CharacterSelected, new CharacterEventArgs(client.Account.Characters[i], client));
							client.LoadPlayer(i);
							break;
						}
					}
					if (charFound == false)
					{
						client.Player = null;
						client.ActiveCharIndex = -1;
					}
					else
					{
						// Log character play
						AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, "", charName);
					}
				}

				client.Out.SendSessionID();
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:70,代码来源:CharacterSelectRequestHandler.cs

示例12: CheckCharacterForUpdates

        private int CheckCharacterForUpdates(GameClient client, GSPacketIn packet, DOLCharacters character, string charName, byte customizationMode)
        {
            int newModel = character.CurrentModel;

            if (customizationMode == 1 || customizationMode == 2 || customizationMode == 3)
            {
                bool flagChangedStats = false;
                character.EyeSize = (byte)packet.ReadByte();
                character.LipSize = (byte)packet.ReadByte();
                character.EyeColor = (byte)packet.ReadByte();
                character.HairColor = (byte)packet.ReadByte();
                character.FaceType = (byte)packet.ReadByte();
                character.HairStyle = (byte)packet.ReadByte();
                packet.Skip(3);
                character.MoodType = (byte)packet.ReadByte();
                packet.Skip(89); // Skip location string, race string, classe string, level ,class ,realm and startRaceGender
                newModel = packet.ReadShortLowEndian(); //read new model

                if (customizationMode != 3 && client.Version >= GameClient.eClientVersion.Version189)
                {
                    packet.Skip(6); // Region ID + character Internal ID
                    int[] stats = new int[8];
                    stats[0] = (byte)packet.ReadByte(); // Strength
                    stats[2] = (byte)packet.ReadByte(); // Dexterity
                    stats[1] = (byte)packet.ReadByte(); // Constitution
                    stats[3] = (byte)packet.ReadByte(); // Quickness
                    stats[4] = (byte)packet.ReadByte(); // Intelligence
                    stats[5] = (byte)packet.ReadByte(); // Piety
                    stats[6] = (byte)packet.ReadByte(); // Empathy
                    stats[7] = (byte)packet.ReadByte(); // Charisma

                    packet.Skip(43);// armor models/armor color/weapon models/active weapon slots/siZone
                    if (client.Version >= GameClient.eClientVersion.Version199)
                    {
                        // skip 4 bytes added in 1.99
                        packet.Skip(4);
                    }

                    // what is this?
                    byte newConstitution = (byte)packet.ReadByte();
                    if (newConstitution > 0 && newConstitution < 255) // added 255 check, still not sure why this is here - tolakram
                        stats[1] = newConstitution;

                    flagChangedStats |= stats[0] != character.Strength;
                    flagChangedStats |= stats[1] != character.Constitution;
                    flagChangedStats |= stats[2] != character.Dexterity;
                    flagChangedStats |= stats[3] != character.Quickness;
                    flagChangedStats |= stats[4] != character.Intelligence;
                    flagChangedStats |= stats[5] != character.Piety;
                    flagChangedStats |= stats[6] != character.Empathy;
                    flagChangedStats |= stats[7] != character.Charisma;

                    //
                    // !! Stat changes disabled by Tolakram until someone figures out why this can create invalid stats !!
                    //
                    flagChangedStats = false;

                    if (flagChangedStats)
                    {
                        ICharacterClass charClass = ScriptMgr.FindCharacterClass(character.Class);

                        if (charClass != null)
                        {
                            int points = 0;
                            int[] leveledStats = new int[8];
                            int[] raceStats = new int[8];
                            bool valid = true;
                            for (int j = 0; j < 8; j++)
                            {
                                eStat stat = (eStat)ValidateCharacter.eStatIndex[j];
                                raceStats[j] = ValidateCharacter.STARTING_STATS[character.Race][j];
                                for (int level = character.Level; level > 5; level--)
                                {
                                    if (charClass.PrimaryStat != eStat.UNDEFINED && charClass.PrimaryStat == stat)
                                    {
                                        leveledStats[j]++;
                                    }
                                    if (charClass.SecondaryStat != eStat.UNDEFINED && charClass.SecondaryStat == stat)
                                    {
                                        if ((level - 6) % 2 == 0)
                                            leveledStats[j]++;
                                    }
                                    if (charClass.TertiaryStat != eStat.UNDEFINED && charClass.TertiaryStat == stat)
                                    {
                                        if ((level - 6) % 3 == 0)
                                            leveledStats[j]++;
                                    }
                                }

                                int result = stats[j] - leveledStats[j] - raceStats[j];

                                bool validBeginStat = result >= 0;
                                int pointsUsed = result;
                                string statCategory = "";

                                if (charClass.PrimaryStat != eStat.UNDEFINED && charClass.PrimaryStat == stat)
                                    statCategory = "1)";
                                if (charClass.SecondaryStat != eStat.UNDEFINED && charClass.SecondaryStat == stat)
                                    statCategory = "2)";
                                if (charClass.TertiaryStat != eStat.UNDEFINED && charClass.TertiaryStat == stat)
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:CharacterCreateRequestHandler.cs

示例13: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            string accountName = packet.ReadString(24);

            log.Debug("CharacterCreateRequestHandler for account " + accountName + " using version " + client.Version);

            if (!accountName.StartsWith(client.Account.Name))// TODO more correctly check, client send accountName as account-S, -N, -H (if it not fit in 20, then only account)
            {
                if (ServerProperties.Properties.BAN_HACKERS)
                {
                    DBBannedAccount b = new DBBannedAccount();
                    b.Author = "SERVER";
                    b.Ip = client.TcpEndpointAddress;
                    b.Account = client.Account.Name;
                    b.DateBan = DateTime.Now;
                    b.Type = "B";
                    b.Reason = String.Format("Autoban wrong Account '{0}'", GameServer.Database.Escape(accountName));
                    GameServer.Database.AddObject(b);
                    GameServer.Database.SaveObject(b);
                    GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
                }

                client.Disconnect();
                return;
            }

            if (client.Version >= GameClient.eClientVersion.Version1104)
            {
                packet.ReadIntLowEndian(); //unk - probably indicates customize or create
            }

            int charsCount = client.Version < GameClient.eClientVersion.Version173 ? 8 : 10;
            for (int i = 0; i < charsCount; i++)
            {
                string charName = packet.ReadString(24);

                //log.DebugFormat("Character[{0}] = {1}", i, charName);

                if (charName.Length == 0)
                {
                    // 1.104+  if character is not in list but is in DB then delete the character
                    if (client.Version >= GameClient.eClientVersion.Version1104)
                    {
                        CheckForDeletedCharacter(accountName, client, i);
                    }

                    //If the charname is empty, skip the other bytes
                    packet.Skip(160);
                    if (client.Version >= GameClient.eClientVersion.Version199)
                    {
                        // skip 4 bytes added in 1.99
                        packet.Skip(4);
                    }
                }
                else
                {
                    // Graveen: changed the following to allow GMs to have special chars in their names (_,-, etc..)
                    Regex nameCheck = new Regex("^[A-Z][a-zA-Z]");
                    if (charName.Length < 3 || !nameCheck.IsMatch(charName))
                    {
                        if (client.Account.PrivLevel == 1)
                        {
                            if (ServerProperties.Properties.BAN_HACKERS)
                            {
                                DBBannedAccount b = new DBBannedAccount();
                                b.Author = "SERVER";
                                b.Ip = client.TcpEndpointAddress;
                                b.Account = client.Account.Name;
                                b.DateBan = DateTime.Now;
                                b.Type = "B";
                                b.Reason = String.Format("Autoban bad CharName '{0}'", GameServer.Database.Escape(charName));
                                GameServer.Database.AddObject(b);
                                GameServer.Database.SaveObject(b);
                                GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
                            }

                            client.Disconnect();
                            return;
                        }
                    }

                    String select = String.Format("Name = '{0}'", GameServer.Database.Escape(charName));
                    DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select);
                    if (character != null)
                    {
                        if (character.AccountName != client.Account.Name)
                        {
                            if (Properties.BAN_HACKERS == true)
                            {
                                DBBannedAccount b = new DBBannedAccount();
                                b.Author = "SERVER";
                                b.Ip = client.TcpEndpointAddress;
                                b.Account = client.Account.Name;
                                b.DateBan = DateTime.Now;
                                b.Type = "B";
                                b.Reason = String.Format("Autoban CharName '{0}' on wrong Account '{1}'", GameServer.Database.Escape(charName), GameServer.Database.Escape(client.Account.Name));
                                GameServer.Database.AddObject(b);
                                GameServer.Database.SaveObject(b);
                                GameServer.Instance.LogCheatAction(string.Format(b.Reason + ". Client Account: {0}, DB Account: {1}", client.Account.Name, character.AccountName));
                            }
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:CharacterCreateRequestHandler.cs

示例14: CreateCharacter

        private void CreateCharacter(GameClient client, GSPacketIn packet, string charName, int accountSlot)
        {
            Account account = client.Account;
            DOLCharacters ch = new DOLCharacters();
            ch.AccountName = account.Name;
            ch.Name = charName;

            if (packet.ReadByte() == 0x01)
            {
                ch.EyeSize = (byte)packet.ReadByte();
                ch.LipSize = (byte)packet.ReadByte();
                ch.EyeColor = (byte)packet.ReadByte();
                ch.HairColor = (byte)packet.ReadByte();
                ch.FaceType = (byte)packet.ReadByte();
                ch.HairStyle = (byte)packet.ReadByte();
                packet.Skip(3);
                ch.MoodType = (byte)packet.ReadByte();
                ch.CustomisationStep = 2; // disable config button
                packet.Skip(13);
                log.Debug("Disable Config Button");
            }
            else
            {
                packet.Skip(23);
            }

            packet.Skip(24); //Location String
            ch.LastName = "";
            ch.GuildID = "";
            packet.Skip(24); //Skip class name
            packet.Skip(24); //Skip race name
            ch.Level = packet.ReadByte(); //not safe!
            ch.Level = 1;
            ch.Class = packet.ReadByte();
            if (ServerProperties.Properties.START_AS_BASE_CLASS)
            {
                ch.Class = RevertClass(ch);
            }
            ch.Realm = packet.ReadByte();

            if (log.IsDebugEnabled)
                log.Debug("Creation " + client.Version + " character, class:" + ch.Class + ", realm:" + ch.Realm);

            // Is class disabled ?
            int occurences = 0;
            List<string> disabled_classes = Properties.DISABLED_CLASSES.SplitCSV(true);
            occurences = (from j in disabled_classes
                          where j == ch.Class.ToString()
                          select j).Count();

            if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
            {
                log.Debug("Client " + client.Account.Name + " tried to create a disabled classe: " + (eCharacterClass)ch.Class);
                client.Out.SendCharacterOverview((eRealm)ch.Realm);
                return;
            }

            if (client.Version >= GameClient.eClientVersion.Version193)
            {
                ValidateCharacter.init_post193_tables();
            }
            else
            {
                ValidateCharacter.init_pre193_tables();
            }

            if (!Enum.IsDefined(typeof(eCharacterClass), (eCharacterClass)ch.Class))
            {
                log.Error(client.Account.Name + " tried to create a character with wrong class ID: " + ch.Class + ", realm:" + ch.Realm);
                if (ServerProperties.Properties.BAN_HACKERS)
                {
                    DBBannedAccount b = new DBBannedAccount();
                    b.Author = "SERVER";
                    b.Ip = client.TcpEndpointAddress;
                    b.Account = client.Account.Name;
                    b.DateBan = DateTime.Now;
                    b.Type = "B";
                    b.Reason = string.Format("Autoban character create class: id:{0} realm:{1} name:{2} account:{3}", ch.Class, ch.Realm, ch.Name, account.Name);
                    GameServer.Database.AddObject(b);
                    GameServer.Database.SaveObject(b);
                    GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
                    client.Disconnect();
                }
                return;
            }

            ch.AccountSlot = accountSlot + ch.Realm * 100;

            //The following byte contains
            //1bit=start location ... in ShroudedIsles you can choose ...
            //1bit=first race bit
            //1bit=unknown
            //1bit=gender (0=male, 1=female)
            //4bit=race
            byte startRaceGender = (byte)packet.ReadByte();

            ch.Race = (startRaceGender & 0x0F) + ((startRaceGender & 0x40) >> 2);

            List<string> disabled_races = new List<string>(Properties.DISABLED_RACES.SplitCSV(true));
            occurences = (from j in disabled_races
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:CharacterCreateRequestHandler.cs

示例15: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client == null || client.Player == null)
                return;

            if (client.Player.ObjectState != GameObject.eObjectState.Active) return;

            ushort sessionId = packet.ReadShort(); // session ID
            if (client.SessionID != sessionId)
            {
                //				GameServer.BanAccount(client, 120, "Hack sessionId", string.Format("Wrong sessionId:0x{0} in 0xBA packet (SessionID:{1})", sessionId, client.SessionID));
                return; // client hack
            }

            ushort head = packet.ReadShort();
            client.Player.Heading = (ushort)(head & 0xFFF);
            packet.Skip(1); // unknown
            int flags = packet.ReadByte();
            //			client.Player.PetInView = ((flags & 0x04) != 0); // TODO
            client.Player.GroundTargetInView = ((flags & 0x08) != 0);
            client.Player.TargetInView = ((flags & 0x10) != 0);

            byte[] con = packet.ToArray();
            if (!client.Player.IsAlive)
            {
                con[9] = 5; // set dead state
            }
            else if (client.Player.Steed != null && client.Player.Steed.ObjectState == GameObject.eObjectState.Active)
            {
                client.Player.Heading = client.Player.Steed.Heading;
                con[9] = 6; // Set ride state
                con[7] = (byte)(client.Player.Steed.RiderSlot(client.Player)); // there rider slot this player
                con[2] = (byte)(client.Player.Steed.ObjectID >> 8); //heading = steed ID
                con[3] = (byte)(client.Player.Steed.ObjectID & 0xFF);
            }
            con[5] &= 0xC0; //11 00 00 00 = 0x80(Torch) + 0x40(Unknown), all other in view check's not need send anyone
            if (client.Player.IsWireframe)
            {
                con[5] |= 0x01;
            }
            //stealth is set here
            if (client.Player.IsStealthed)
            {
                con[5] |= 0x02;
            }
            con[8] = (byte)((con[8] & 0x80) | client.Player.HealthPercent);

            GSUDPPacketOut outpak = new GSUDPPacketOut(client.Out.GetPacketCode(eServerPackets.PlayerHeading));
            //Now copy the whole content of the packet
            outpak.Write(con, 0, /*con.Length*/10);
            outpak.WritePacketLength();

            GSUDPPacketOut outpak190 = null;

            //			byte[] outp = outpak.GetBuffer();
            //			outpak = null;

            foreach (GamePlayer player in client.Player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                if (player != null && player != client.Player)
                {
                    if (player.Client.Version >= GameClient.eClientVersion.Version190)
                    {
                        if (outpak190 == null)
                        {
                            outpak190 = new GSUDPPacketOut(client.Out.GetPacketCode(eServerPackets.PlayerHeading));
                            byte[] con190 = (byte[])con.Clone();
                            //Now copy the whole content of the packet
                            outpak190.Write(con190, 0, /*con190.Lenght*/10);
                            outpak190.WriteByte(client.Player.ManaPercent);
                            outpak190.WriteByte(client.Player.EndurancePercent);
                            outpak190.WritePacketLength();
                            //							byte[] outp190 = outpak190.GetBuffer();
                            //							outpak190 = null;// ?
                        }
                        player.Out.SendUDPRaw(outpak190);
                    }
                    else
                        player.Out.SendUDPRaw(outpak);
                }
            }
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:82,代码来源:PlayerHeadingUpdateHandler.cs


注:本文中的GSPacketIn.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。