本文整理汇总了C#中Framework.Network.Packets.PacketReader.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Skip方法的具体用法?C# PacketReader.Skip怎么用?C# PacketReader.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework.Network.Packets.PacketReader
的用法示例。
在下文中一共展示了PacketReader.Skip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAuthLogonChallenge
public void HandleAuthLogonChallenge(RealmClass session, PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonChallenge");
data.Skip(10);
ushort ClientBuild = data.ReadUInt16();
data.Skip(8);
account.Language = data.ReadStringFromBytes(4);
data.Skip(4);
account.IP = data.ReadIPAddress();
account.Name = data.ReadAccountName();
SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags FROM accounts WHERE name = '{0}'", account.Name);
var res = result.Read("id", "name", "password", "expansion", "securityFlags");
PacketWriter logonChallenge = new PacketWriter();
logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
logonChallenge.WriteUInt8(0);
if (result.Count != 0)
{
account.Id = result.Read<Int32>("id");
account.Expansion = result.Read<Byte>("expansion");
account.SecurityFlags = result.Read<Byte>("securityFlags");
DB.Realms.Execute("UPDATE accounts SET ip = '{0}', language = '{1}' WHERE id = {2}", account.IP, account.Language, account.Id);
byte[] username = Encoding.UTF8.GetBytes(result.Read<String>("name").ToUpper());
byte[] password = Encoding.UTF8.GetBytes(result.Read<String>("password").ToUpper());
// WoW 5.1.0.16309 (5.1.0)
if (ClientBuild == 16309)
{
session.SecureRemotePassword.CalculateX(username, password);
byte[] buf = new byte[0x10];
SRP6.RAND_bytes(buf, 0x10);
logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
logonChallenge.WriteBytes(session.SecureRemotePassword.B);
logonChallenge.WriteUInt8(1);
logonChallenge.WriteUInt8(session.SecureRemotePassword.g[0]);
logonChallenge.WriteUInt8(0x20);
logonChallenge.WriteBytes(session.SecureRemotePassword.N);
logonChallenge.WriteBytes(session.SecureRemotePassword.salt);
logonChallenge.WriteBytes(buf);
// Security flags
logonChallenge.WriteUInt8(account.SecurityFlags);
// Enable authenticator
if ((account.SecurityFlags & 4) != 0)
logonChallenge.WriteUInt8(1);
}
}
else
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);
session.Send(logonChallenge);
}
示例2: HandleCreateCharacter
public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
packet.Skip(1);
var facialHair = packet.ReadByte();
var skin = packet.ReadByte();
var race = packet.ReadByte();
var hairStyle = packet.ReadByte();
var pClass = packet.ReadByte();
var face = packet.ReadByte();
var gender = packet.ReadByte();
var hairColor = packet.ReadByte();
var nameLength = BitUnpack.GetBits<uint>(6);
var hasUnknown = BitUnpack.GetBit();
var name = Character.NormalizeName(packet.ReadString(nameLength));
if (hasUnknown)
packet.ReadUInt32();
var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name);
var createChar = new PacketWriter(ServerMessage.CreateChar);
if (result.Count != 0)
{
// Name already in use
createChar.WriteUInt8(0x32);
session.Send(ref createChar);
return;
}
result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass);
if (result.Count == 0)
{
createChar.WriteUInt8(0x31);
session.Send(ref createChar);
return;
}
var map = result.Read<uint>(0, "map");
var zone = result.Read<uint>(0, "zone");
var posX = result.Read<float>(0, "posX");
var posY = result.Read<float>(0, "posY");
var posZ = result.Read<float>(0, "posZ");
var posO = result.Read<float>(0, "posO");
// Allow declined names for now
var characterFlags = CharacterFlag.Decline;
DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" +
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags);
// Success
createChar.WriteUInt8(0x2F);
session.Send(ref createChar);
}
示例3: HandleAuthResponse
public static void HandleAuthResponse(ref PacketReader packet, ref WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
packet.Skip(54);
int addonSize = packet.Read<int>();
packet.Skip(addonSize);
uint nameLength = BitUnpack.GetBits<uint>(12);
string accountName = packet.ReadString(nameLength);
SQLResult result = DB.Realms.Select("SELECT * FROM accounts WHERE name = ?", accountName);
if (result.Count == 0)
session.clientSocket.Close();
else
session.Account = new Account()
{
Id = result.Read<int>(0, "id"),
Name = result.Read<String>(0, "name"),
Password = result.Read<String>(0, "password"),
SessionKey = result.Read<String>(0, "sessionkey"),
Expansion = result.Read<byte>(0, "expansion"),
GMLevel = result.Read<byte>(0, "gmlevel"),
IP = result.Read<String>(0, "ip"),
Language = result.Read<String>(0, "language")
};
string K = session.Account.SessionKey;
byte[] kBytes = new byte[K.Length / 2];
for (int i = 0; i < K.Length; i += 2)
kBytes[i / 2] = Convert.ToByte(K.Substring(i, 2), 16);
session.Crypt.Initialize(kBytes);
uint realmId = WorldConfig.RealmId;
SQLResult realmClassResult = DB.Realms.Select("SELECT class, expansion FROM realm_classes WHERE realmId = ?", realmId);
SQLResult realmRaceResult = DB.Realms.Select("SELECT race, expansion FROM realm_races WHERE realmId = ?", realmId);
bool HasAccountData = true;
bool IsInQueue = false;
PacketWriter authResponse = new PacketWriter(ServerMessage.AuthResponse);
BitPack BitPack = new BitPack(authResponse);
BitPack.Write(IsInQueue);
if (IsInQueue)
BitPack.Write(1); // Unknown
BitPack.Write(HasAccountData);
if (HasAccountData)
{
BitPack.Write(0); // Unknown, 5.0.4
BitPack.Write(0); // Unknown, 5.3.0
BitPack.Write(realmRaceResult.Count, 23); // Activation count for races
BitPack.Write(0); // Unknown, 5.1.0
BitPack.Write(0, 21); // Activate character template windows/button
//if (HasCharacterTemplate)
//Write bits for char templates...
BitPack.Write(realmClassResult.Count, 23); // Activation count for classes
BitPack.Write(0, 22); // Unknown, 5.3.0
BitPack.Write(0); // Unknown2, 5.3.0
}
BitPack.Flush();
if (HasAccountData)
{
authResponse.WriteUInt8(0);
for (int c = 0; c < realmClassResult.Count; c++)
{
authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "expansion"));
authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "class"));
}
//if (Unknown2)
// authResponse.WriteUInt16(0);
//if (HasCharacterTemplate)
//Write data for char templates...
//if (Unknown)
// authResponse.WriteUInt16(0);
for (int r = 0; r < realmRaceResult.Count; r++)
{
authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "expansion"));
authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "race"));
}
authResponse.WriteUInt32(0);
authResponse.WriteUInt32(0);
authResponse.WriteUInt32(0);
//.........这里部分代码省略.........
示例4: HandleAuthLogonChallenge
public void HandleAuthLogonChallenge(PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonChallenge");
data.Skip(10);
ushort ClientBuild = data.Read<ushort>();
data.Skip(8);
account.Language = data.ReadStringFromBytes(4);
data.Skip(4);
account.IP = data.ReadIPAddress();
account.Name = data.ReadAccountName();
SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags, online FROM accounts WHERE name = ?", account.Name);
using (var logonChallenge = new PacketWriter())
{
logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
logonChallenge.WriteUInt8(0);
if (result.Count != 0)
{
if (result.Read<bool>(0, "online"))
{
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_ALREADY_ONLINE);
Send(logonChallenge);
return;
}
account.Id = result.Read<Int32>(0, "id");
account.Expansion = result.Read<Byte>(0, "expansion");
account.SecurityFlags = result.Read<Byte>(0, "securityFlags");
DB.Realms.Execute("UPDATE accounts SET ip = ?, language = ? WHERE id = ?", account.IP, account.Language, account.Id);
var username = result.Read<String>(0, "name").ToUpperInvariant();
var password = result.Read<String>(0, "password").ToUpperInvariant();
// WoW 5.2.0.16826
if (ClientBuild == 16826)
{
SecureRemotePassword.CalculateX(username, password);
var randBytes = new byte[0x10];
var random = RNGCryptoServiceProvider.Create();
random.GetBytes(randBytes);
logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
logonChallenge.WriteBytes(SecureRemotePassword.B);
logonChallenge.WriteUInt8(1);
logonChallenge.WriteUInt8(SecureRemotePassword.g.ToByteArray()[0]);
logonChallenge.WriteUInt8(0x20);
logonChallenge.WriteBytes(SecureRemotePassword.N);
logonChallenge.WriteBytes(SecureRemotePassword.Salt);
logonChallenge.WriteBytes(randBytes);
// Security flags
logonChallenge.WriteUInt8(account.SecurityFlags);
// Enable authenticator
if ((account.SecurityFlags & 4) != 0)
logonChallenge.WriteUInt8(1);
}
}
else
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);
Send(logonChallenge);
}
}
示例5: HandlePlayerLogin
public static void HandlePlayerLogin(ref PacketReader packet, WorldClass session)
{
byte[] guidMask = { 4, 2, 7, 1, 0, 5, 6, 3 };
byte[] guidBytes = { 5, 0, 1, 6, 7, 2, 3, 4 };
BitUnpack GuidUnpacker = new BitUnpack(packet);
packet.Skip(4);
var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes);
Log.Message(LogType.Debug, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id);
session.Character = new Character(guid);
if (!WorldMgr.AddSession(guid, ref session))
{
Log.Message(LogType.Error, "A Character with Guid: {0} is already logged in", guid);
return;
}
WorldMgr.WriteAccountDataTimes(AccountDataMasks.CharacterCacheMask, ref session);
MiscHandler.HandleMessageOfTheDay(ref session);
TimeHandler.HandleLoginSetTimeSpeed(ref session);
SpecializationHandler.HandleUpdateTalentData(ref session);
SpellHandler.HandleSendKnownSpells(ref session);
MiscHandler.HandleUpdateActionButtons(ref session);
if (session.Character.LoginCinematic)
CinematicHandler.HandleStartCinematic(ref session);
ObjectHandler.HandleUpdateObjectCreate(ref session);
}