本文整理汇总了C#中Packet.ReadCString方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadCString方法的具体用法?C# Packet.ReadCString怎么用?C# Packet.ReadCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadCString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameobjectQueryResponse
public static void GameobjectQueryResponse(Packet packet)
{
GameObject go = new GameObject();
var entry = packet.ReadEntryKey("Entry");
go.Entry = entry.Key;
if (entry.Value)
return;
go.Type = packet.ReadEnum<GameObjectType>("Type");
go.DisplayID = packet.ReadInt32("Display ID");
for (var i = 0; i < 4; i++)
go.Name[i] = packet.ReadCString("Name " + i);
go.IconName = packet.ReadCString("Icon Name");
go.CastCaption = packet.ReadCString("Cast Caption");
go.UnkString = packet.ReadCString("Unk String");
for (var i = 0; i < 32; i++)
go.Data[i] = packet.ReadInt32("Data " + i);
go.Size = packet.ReadSingle("Size");
for (var i = 0; i < 6; i++)
go.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
go.Exp = packet.ReadInt32("Expansion ID");
GameObjectStorage.GetSingleton().Add(go);
}
示例2: HandleGameObjectQueryResponse
public static void HandleGameObjectQueryResponse(Packet packet)
{
var entry = packet.ReadEntry();
Console.WriteLine("Entry: " + entry.Key);
if (entry.Value)
return;
var unkInt = packet.ReadInt32();
Console.WriteLine("unkInt: " + unkInt);
var type = (GameObjectType)packet.ReadInt32();
Console.WriteLine("Type: " + type);
var dispId = packet.ReadInt32();
Console.WriteLine("Display ID: " + dispId);
var name = new string[4];
for (var i = 0; i < 4; i++)
{
name[i] = packet.ReadCString();
Console.WriteLine("Name " + i + ": " + name[i]);
}
var iconName = packet.ReadCString();
Console.WriteLine("Icon Name: " + iconName);
var castCaption = packet.ReadCString();
Console.WriteLine("Cast Caption: " + castCaption);
var unkStr = packet.ReadCString();
Console.WriteLine("Unk String: " + unkStr);
var data = new int[32];
for (var i = 0; i < 32; i++)
{
data[i] = packet.ReadInt32();
Console.WriteLine("Data " + i + ": " + data[i]);
}
var size = packet.ReadSingle();
Console.WriteLine("Size: " + size);
var qItemCount = packet.ReadByte();
Console.WriteLine("Quest Item Count: " + qItemCount);
var qItem = new int[qItemCount];
for (var i = 0; i < qItemCount; i++)
{
qItem[i] = packet.ReadInt32();
Console.WriteLine("Quest Item " + i + ": " + qItem[i]);
}
var expansion = packet.ReadInt32();
Console.WriteLine("Expansion: " + expansion);
SQLOutput.SQLOutput.WriteData(SQLOutput.SQLOutput.GameObjects.GetCommand(entry.Key, type, dispId, name[0], iconName,
castCaption, unkStr, data, size, qItem));
}
示例3: HandleGuildInfo
public static void HandleGuildInfo(Packet packet)
{
packet.ReadCString("Name");
packet.ReadTime("Created");
packet.ReadInt32("Number of members");
packet.ReadInt32("Number of accounts");
}
示例4: HandleCreatureQueryResponse
public static void HandleCreatureQueryResponse(Packet packet)
{
Creature c = new Creature();
var entry = packet.ReadEntryKey("Entry");
if (entry.Value)
return;
c.Entry = entry.Key;
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Name " + i);
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Unk string " + i);
c.SubName = packet.ReadCString("Sub Name");
c.IconName = packet.ReadCString("Icon Name");
c.TypeFlags = packet.ReadEnum<CreatureTypeFlag>("Type Flags");
c.Type = packet.ReadEnum<CreatureType>("Type");
c.Family = packet.ReadEnum<CreatureFamily>("Family");
int val = packet.ReadInt32("Unk int");
c.Rank = packet.ReadEnum<CreatureRank>("Rank");
c.KillCredit1 = packet.ReadInt32("Kill Credit 1");
c.KillCredit2 = packet.ReadInt32("Kill Credit 2");
for (var i = 0; i < 4; i++)
c.DisplayIDs[i] = packet.ReadInt32("Display ID " + i);
c.HealthModifier = packet.ReadSingle("Health Modifier");
c.ManaModifier = packet.ReadSingle("Mana Modifier");
c.RacialLeader = packet.ReadBoolean("Racial Leader");
for (var i = 0; i < 6; i++)
c.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
c.MovementID = packet.ReadInt32("Movement ID");
c.Exp = packet.ReadInt32("Expansion ID");
CreatureStorage.GetSingleton().Add(c);
}
示例5: HandleChannelList
public static void HandleChannelList(Packet packet)
{
packet.ReadByte("Channel Type");
packet.ReadCString("Channel Name");
packet.ReadByte("Channel Flags");
var listSize = packet.ReadInt32("List Size");
for (int i = 0; i < listSize; i++)
{
packet.ReadGuid("Player GUID");
packet.ReadByte("Player Flags");
}
}
示例6: HandleAuthRequest
private void HandleAuthRequest(TcpSession session, Packet p)
{
var ack = new Packet(EAuthPacket.SAuthAck);
var ip = session.Client.Client.RemoteEndPoint as IPEndPoint;
var username = p.ReadCStringBuffer(13);
var password = p.ReadCString();
// SHA256 encoding
password = SHA256.ComputeHash(password);
//TODO: Implement IP logging options to MySQL after failed handshaking attempts
String[] userDetails = { username, password };
// Update user's lastIP connected in auth
string ip_str = ip.ToString();
AuthDatabase.Instance.UpdateLastIP(ip_str,userDetails[0]);
// Check if account exists
if (!AuthDatabase.Instance.ValidateAccount(userDetails[0], userDetails[1]))
{
HandshakeConnection("failed", ip, userDetails[0], userDetails[1], session, ack);
return;
}
// Check if account is banned
if (AuthDatabase.Instance.IsAccountBanned(userDetails[0]))
{
HandshakeConnection("banned", ip, userDetails[0], userDetails[1], session, ack);
return;
}
// Login successfully
HandshakeConnection("success", ip, userDetails[0], userDetails[1], session, ack);
}
示例7: HandleLoginRequest
private void HandleLoginRequest(TcpSession session, Packet p)
{
var ip = session.Client.Client.RemoteEndPoint as IPEndPoint;
var accID = p.ReadUInt64();
var nickname = p.ReadCString();
_logger.Info("-CLoginReq- User: {0} ID: {1}", nickname, accID);
var ack = new Packet(EChatPacket.SLoginAck);
if (accID == 0 || !ValidateSession(accID, nickname, ip.Address) || _players.GetPlayerByID(accID) != null /* prevent multiple logins! */)
{
ack.Write((uint)1); // error code
session.Send(ack);
session.StopListening();
return;
}
var plr = GameDatabase.Instance.GetPlayer(accID);
plr.Session = session;
_players.TryAdd(session.Guid, plr);
ack.Write((uint)0); // error code
session.Send(ack);
}
示例8: HandleChannelEnter
private void HandleChannelEnter(TcpSession session, Packet p)
{
var chanName = p.ReadCString();
//_logger.Debug("-C_CHANENTER_REQ- Name: {0}", chanName);
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
var chan = _channels.GetChannelByName(chanName);
if (chan.ID == 0)
return;
var ack = new Packet(EChatPacket.SChannelEnterAck);
ack.Write((uint)chan.ID);
session.Send(ack);
}
示例9: HandleAdminAction
private void HandleAdminAction(TcpSession session, Packet p)
{
Logger.Debug("-C_ADMIN_ACTION_REQ-");
var cmd = p.ReadCString();
if (!cmd.StartsWith("/"))
return;
Player player;
if (!Players.TryGetValue(session.Guid, out player))
{
session.StopListening();
return;
}
cmd = cmd.Remove(0, 1); // remove /
var args = HelperUtils.ParseArgs(cmd);
foreach (var plugin in _pluginManager.Plugins)
{
var ret = plugin.OnAdminAction(player, args);
if(string.IsNullOrEmpty(ret))
continue;
var ack = new Packet(EGamePacket.SAdminActionAck);
ack.Write((byte)0x01); // does not matter
ack.Write((ushort)ret.Length);
ack.Write(ret);
session.Send(ack);
}
}
示例10: HandleEventMessage
private void HandleEventMessage(TcpSession session, Packet p)
{
var eventID = p.ReadByte();
var accID = p.ReadUInt64();
var unk1 = p.ReadUInt32();
var unk2 = p.ReadUInt16();
var strLen = p.ReadUInt32();
var str = (strLen > 0) ? p.ReadCString() : string.Empty;
//_logger.Debug("-C_EVENTMESSAGE_REQ- EventID: {0} AccID: {1} Unk1: {2} Unk2: {3} String: {4}", eventID, accID, unk1, unk2, str);
var player = Players.GetPlayerByID(accID);
Player sender;
if (!Players.TryGetValue(session.Guid, out sender))
{
session.StopListening();
return;
}
if (sender.Room == null)
return;
var room = sender.Room;
if (player != null && player.State == EPlayerState.Lobby && eventID == (byte)EPlayerEventMessage.StartGame && room.State != EGameRuleState.Waiting)
{
player.State = player.GameMode == EPlayerGameMode.Normal ? EPlayerState.Alive : EPlayerState.Spectating;
player.GameScore.JoinTime = DateTime.Now;
room.BroadcastBriefing();
}
var ack = new Packet(EGamePacket.SEventMessageAck);
ack.Write(eventID);
ack.Write(accID);
ack.Write(unk1);
ack.Write(unk2);
ack.Write(strLen);
if (strLen > 0)
ack.Write(str);
room.Broadcast(ack);
}
示例11: HandleMessageChat
public static void HandleMessageChat(Packet packet)
{
var type = packet.ReadEnum<ChatMessageType>("Type");
packet.ReadEnum<Language>("Language");
packet.ReadGuid("GUID");
packet.ReadInt32("Unk Int32");
switch (type)
{
case ChatMessageType.Say:
case ChatMessageType.Yell:
case ChatMessageType.Party:
case ChatMessageType.PartyLeader:
case ChatMessageType.Raid:
case ChatMessageType.RaidLeader:
case ChatMessageType.RaidWarning:
case ChatMessageType.Guild:
case ChatMessageType.Officer:
case ChatMessageType.Emote:
case ChatMessageType.TextEmote:
case ChatMessageType.Whisper:
case ChatMessageType.WhisperInform:
case ChatMessageType.System:
case ChatMessageType.Channel:
case ChatMessageType.Battleground:
case ChatMessageType.BattlegroundNeutral:
case ChatMessageType.BattlegroundAlliance:
case ChatMessageType.BattlegroundHorde:
case ChatMessageType.BattlegroundLeader:
case ChatMessageType.Achievement:
case ChatMessageType.GuildAchievement:
{
if (type == ChatMessageType.Channel)
packet.ReadCString("Channel Name");
packet.ReadGuid("Sender GUID");
break;
}
case ChatMessageType.MonsterSay:
case ChatMessageType.MonsterYell:
case ChatMessageType.MonsterParty:
case ChatMessageType.MonsterEmote:
case ChatMessageType.MonsterWhisper:
case ChatMessageType.RaidBossEmote:
case ChatMessageType.RaidBossWhisper:
case ChatMessageType.BattleNet:
{
packet.ReadInt32("Name Length");
packet.ReadCString("Name");
var target = packet.ReadGuid("Receiver GUID");
break;
}
}
packet.ReadInt32("Text Length");
packet.ReadCString("Text");
packet.ReadEnum<ChatTag>("Chat Tag");
if (type != ChatMessageType.Achievement && type != ChatMessageType.GuildAchievement)
return;
packet.ReadInt32("Achievement ID");
}
示例12: HandleTextEmote
public static void HandleTextEmote(Packet packet)
{
packet.ReadGuid("GUID");
packet.ReadInt32("Text Emote");
packet.ReadInt32("Emote #");
packet.ReadInt32("Name Length");
packet.ReadCString("Name");
}
示例13: HandleGuildQueryResponse
public static void HandleGuildQueryResponse(Packet packet)
{
packet.ReadInt64("Guild ID");
packet.ReadCString("Name");
for (byte rank = 0; rank < 10; rank++)
packet.ReadCString("Rank " + rank + " name");
for (byte rank = 0; rank < 10; rank++)
packet.ReadInt32("Rank " + rank + " real rank ID");
// ignore these as they seem to always be identical to the above loop
for (byte rank = 0; rank < 10; rank++)
packet.ReadInt32();
packet.ReadInt32("Emblem style");
packet.ReadInt32("Emblem color");
packet.ReadInt32("Emblem border style");
packet.ReadInt32("Emblem border color");
packet.ReadInt32("Emblem background color");
packet.ReadInt32("Unk int from WotLK");
}
示例14: HandleQuestQueryResponse
public static void HandleQuestQueryResponse(Packet packet)
{
Quest q = new Quest();
q.Entry = packet.ReadInt32("Entry");
q.Method = packet.ReadEnum<QuestMethod>("Method");
q.Level = packet.ReadInt32("Level");
q.MinLevel = packet.ReadInt32("MinLevel");
var sort = packet.ReadInt32();
if (sort >= 0)
Console.WriteLine("Zone: {0}", sort);
else
Console.WriteLine("Sort: {0}", (QuestSort)(-sort));
q.ZoneOrSort = sort;
q.Type = packet.ReadEnum<QuestType>("Type");
q.SuggestedPlayers = packet.ReadInt32("SuggestedPlayers");
q.RepObjectiveFaction1 = packet.ReadInt32("RepObjFaction1");
q.RepObjectiveValue1 = packet.ReadInt32("RepObjValue1");
q.RepObjectiveFaction2 = packet.ReadInt32("RepObjFaction2");
q.RepObjectiveValue2 = packet.ReadInt32("RepObjValue2");
q.NextQuestID = packet.ReadInt32("NextQuestID");
q.XPID = packet.ReadInt32("XPID");
q.RewardMoney = packet.ReadInt32("Money");
q.RewardMoneyAtMaxLevel = packet.ReadInt32("MoneyAtMaxLevel");
q.Spell = packet.ReadInt32("Spell");
q.SpellCast = packet.ReadInt32("SpellCast");
q.Honor = packet.ReadInt32("Honor");
q.HonorMultiplier = packet.ReadSingle("Honor (2)");
q.SourceItemID = packet.ReadInt32("Source Item ID");
q.Flags = packet.ReadEnum<QuestFlag>("Flags");
q.Unk = packet.ReadInt32("Unk");
q.RewardTitleID = packet.ReadInt32("RewardTitleID");
q.PlayersSlain = packet.ReadInt32("PlayersSlain");
q.RewardTalentPoints = packet.ReadInt32("RewardTalentPoints");
q.RewardArenaPoints = packet.ReadInt32("RewardArenaPoints");
q.RewardSkillLineID = packet.ReadInt32("RewardSkillLineID");
q.RewardSkillPoints = packet.ReadInt32("RewardSkillPoints");
q.RewardFactionMask = packet.ReadInt32("RewardFactionMask");
q.QuestGiverPortraitID = packet.ReadInt32("QuestGiverPortraitID");
q.QuestTurnInPortraitID = packet.ReadInt32("QuestTurnInPortraitID");
for (int i = 0; i < 4; i++)
{
q.RewardItem[i] = packet.ReadInt32("RewardItem[" + i + "]");
q.RewardItemCount[i] = packet.ReadInt32("RewardItemCount[" + i + "]");
}
for (int i = 0; i < 6; i++)
{
q.RewardItemChoice[i] = packet.ReadInt32("RewardItemChoice[" + i + "]");
q.RewardItemChoiceCount[i] = packet.ReadInt32("RewardItemChoiceCount[" + i + "]");
}
for (int i = 0; i < 5; i++)
q.RewardRepFactionID[i] = packet.ReadInt32("RewardRepFactionID[" + i + "]");
for (int i = 0; i < 5; i++)
q.RewardRepValueID[i] = packet.ReadInt32("RewardRepValueID[" + i + "]");
for (int i = 0; i < 5; i++)
q.RewardRepValue[i] = packet.ReadInt32("RewardRepValue[" + i + "]");
q.PointMapID = packet.ReadInt32("PointMapID");
q.PointX = packet.ReadSingle("PointX");
q.PointY = packet.ReadSingle("PointY");
q.PointOption = packet.ReadInt32("PointOption");
q.Title = packet.ReadCString("Title");
q.ObjectiveText = packet.ReadCString("ObjectiveText");
q.Description = packet.ReadCString("Description");
q.EndText = packet.ReadCString("EndText");
q.CompletionText = packet.ReadCString("CompletionText");
for (int i = 0; i < 4; i++)
{
q.RequiredCreatureOrGOID[i] = packet.ReadInt32("RequiredCreatureOrGOID[" + i + "]");
q.RequiredCreatureOrGOCount[i] = packet.ReadInt32("RequiredCreatureOrGOCount[" + i + "]");
q.ItemDropIntermediateID[i] = packet.ReadInt32("ItemDropIntermediateID[" + i + "]");
q.ItemDropIntermediateCount[i] = packet.ReadInt32("ItemDropIntermediateCount[" + i + "]");
}
for (int i = 0; i < 6; i++)
{
q.RequiredItemID[i] = packet.ReadInt32("RequiredItemID[" + i + "]");
q.RequiredItemCount[i] = packet.ReadInt32("RequiredItemCount[" + i + "]");
}
q.CriteriaSpellID = packet.ReadInt32("CriteriaSpellID");
for (int i = 0; i < 4; i++)
q.ObjectiveTexts[i] = packet.ReadCString("ObjectiveTexts[" + i + "]");
for (int i = 0; i < 4; i++)
{
q.RewardCurrencyID[i] = packet.ReadInt32("RewardCurrencyID[" + i + "]");
q.RewardCurrencyValue[i] = packet.ReadInt32("RewardCurrencyValue[" + i + "]");
}
for (int i = 0; i < 4; i++)
{
q.RequiredCurrencyID[i] = packet.ReadInt32("RequiredCurrencyID[" + i + "]");
q.RequiredCurrencyValue[i] = packet.ReadInt32("RequiredCurrencyValue[" + i + "]");
}
q.QuestGiverPortraitText = packet.ReadCString("QuestGiverPortraitText");
q.QuestGiverPortraitUnk = packet.ReadCString("QuestGiverPortraitUnk");
q.QuestTurnInPortraitText = packet.ReadCString("QuestTurnInPortraitText");
q.QuestTurnInPortraitUnk = packet.ReadCString("QuestTurnInPortrainUnk");
q.SoundField1 = packet.ReadInt32("Sound field 1");
q.SoundField2 = packet.ReadInt32("Sound field 2");
QuestStorage.GetSingleton().Add(q);
}
示例15: HandleNameQueryResponse
public static void HandleNameQueryResponse(Packet packet)
{
packet.ReadPackedGuid("GUID");
var end = packet.ReadBoolean("Name Found");
if (end)
return;
packet.ReadCString("Name");
packet.ReadCString("Realm Name");
var race = packet.ReadEnum<Race>("Race");
var gender = packet.ReadEnum<Gender>("Gender");
var cClass = packet.ReadEnum<Class>("Class");
var decline = packet.ReadBoolean("Name Declined");
if (!decline)
return;
for (var i = 0; i < 5; i++)
packet.ReadCString("Declined Name " + i);
}