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


C# GSPacketIn.ReadShortLowEndian方法代码示例

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


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

示例1: 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

示例2: 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

示例3: CreateCharacter


//.........这里部分代码省略.........
                    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
                          where j == ch.Race.ToString()
                          select j).Count();
            if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
            {
                log.Debug("Client " + client.Account.Name + " tried to create a disabled race: " + (eRace)ch.Race);
                client.Out.SendCharacterOverview((eRealm)ch.Realm);
                return;
            }

            ch.Gender = ((startRaceGender >> 4) & 0x01);

            bool siStartLocation = ((startRaceGender >> 7) != 0);

            ch.CreationModel = packet.ReadShortLowEndian();
            ch.CurrentModel = ch.CreationModel;
            ch.Region = packet.ReadByte();
            packet.Skip(1); //TODO second byte of region unused currently
            packet.Skip(4); //TODO Unknown Int / last used?

            ch.Strength = (byte)packet.ReadByte();
            ch.Dexterity = (byte)packet.ReadByte();
            ch.Constitution = (byte)packet.ReadByte();
            ch.Quickness = (byte)packet.ReadByte();
            ch.Intelligence = (byte)packet.ReadByte();
            ch.Piety = (byte)packet.ReadByte();
            ch.Empathy = (byte)packet.ReadByte();
            ch.Charisma = (byte)packet.ReadByte();

            packet.Skip(44); //TODO equipment

            if (client.Version >= GameClient.eClientVersion.Version199)
            {
                // skip 4 bytes added in 1.99
                packet.Skip(4);
            }

            // log.DebugFormat("STR {0}, CON {1}, DEX {2}, QUI {3}, INT {4}, PIE {5}, EMP {6}, CHA {7}", ch.Strength, ch.Constitution, ch.Dexterity, ch.Quickness, ch.Intelligence, ch.Piety, ch.Empathy, ch.Charisma);

            // check if client tried to create invalid char
            if (!ValidateCharacter.IsCharacterValid(ch))
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn(ch.AccountName + " tried to create invalid character:" +
                             "\nchar name=" + ch.Name + ", gender=" + ch.Gender + ", race=" + ch.Race + ", realm=" + ch.Realm + ", class=" + ch.Class + ", region=" + ch.Region +
                             "\nstr=" + ch.Strength + ", con=" + ch.Constitution + ", dex=" + ch.Dexterity + ", qui=" + ch.Quickness + ", int=" + ch.Intelligence + ", pie=" + ch.Piety + ", emp=" + ch.Empathy + ", chr=" + ch.Charisma);
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:67,代码来源:CharacterCreateRequestHandler.cs


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