本文整理汇总了C#中Estrella.FiestaLib.Networking.Packet.TryReadString方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.TryReadString方法的具体用法?C# Packet.TryReadString怎么用?C# Packet.TryReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Estrella.FiestaLib.Networking.Packet
的用法示例。
在下文中一共展示了Packet.TryReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FriendInvite
public static void FriendInvite(WorldClient pClient, Packet pPacket)
{
string sender, receiver;
if (!pPacket.TryReadString(out sender, 16) ||
!pPacket.TryReadString(out receiver, 16))
{
Log.WriteLine(LogLevel.Warn, "Error reading friend invite.");
return;
}
WorldCharacter inviter = pClient.Character;
WorldClient invitee = ClientManager.Instance.GetClientByCharname(receiver);
if (invitee == null)
{
//character not found
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0946); // Cannot find ${Target}
pClient.SendPacket(pack);
}
}
else if (receiver == sender)
{
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0942); // You cannot add yourself to your Buddy List.
pClient.SendPacket(pack);
}
}
else if (inviter.Friends.Find(f => f.Name == receiver) != null)
{
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0945); // {Target} is already registered in the friends list.
pClient.SendPacket(pack);
}
}
else
{
using (var pack = new Packet(SH21Type.FriendInviteRequest))
{
pack.WriteString(receiver, 16);
pack.WriteString(sender, 16);
invitee.SendPacket(pack);
}
}
}
示例2: ChangeFromGuildAcademyToResponse
public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
{
string GuildName;
string RequestName;
bool answer;
if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
return;
if (answer)
{
GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
if (pMember == null)
return;
pMember.Character.IsInGuildAcademy = false;
pMember.Academy.RemoveMember(pMember);
pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);
pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
pMember.Character.IsInGuild = true;
using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
{
//this packet remove character from academy List and added to GuildList
pack.WriteString(RequestName, 16);
pack.WriteString(client.Character.Character.Name, 16);
pack.WriteByte(6);//rank
pack.WriteInt(0);//unk
pack.WriteUShort(0);//korp
pack.Fill(64, 0x00);//unk
pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
pack.Fill(3, 0x00);//unk
pack.WriteByte(pMember.Character.Character.Job);
pack.WriteByte(pMember.Character.Character.CharLevel);
pack.Fill(13, 0x00);//unk
client.Character.GuildAcademy.Guild.Broadcast(pack);
client.Character.GuildAcademy.Broadcast(pack);
}
}
using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
{
client.Character.Guild.WriteGuildInfo(packet);
client.SendPacket(p2);
}
using (var pack = new Packet(SH29Type.GuildMemberJoined))
{
pack.WriteString(client.Character.Character.Name, 16);
client.Character.GuildAcademy.Guild.Broadcast(pack);
client.Character.GuildAcademy.Broadcast(pack);
}
using (var pack = new Packet(SH29Type.ChangeResponse))
{
pack.WriteUShort(3137);//unk
pack.WriteByte(3);
pack.Fill(2, 0x00);//unk
client.SendPacket(pack);
}
}
示例3: MasterRequest
public static void MasterRequest(WorldClient client, Packet packet)
{
string playername = string.Empty;
string target = string.Empty;
if (!packet.TryReadString(out playername, 16))
return;
if (!packet.TryReadString(out target, 16))
return;
MasterManager.Instance.AddMasterRequest(client, target);
}
示例4: Wisper
public static void Wisper(WorldClient client, Packet packet)
{
string toname;
byte messagelenght;
if (packet.TryReadString(out toname, 16) && packet.TryReadByte(out messagelenght))
{
string message;
if (!packet.TryReadString(out message, messagelenght))
{
return;
}
WorldClient toChar = ClientManager.Instance.GetClientByCharname(toname);
if (toChar != null)
{
using (var frompacket = new Packet(SH8Type.WisperFrom))
{
frompacket.WriteString(client.Character.Character.Name, 16);
if (!toChar.Character.BlocketUser.Contains(client.Character.Character.Name))
{
frompacket.WriteByte(0);
}
else
{
frompacket.WriteByte(12);//blocket notdisplay message
}
frompacket.WriteByte(messagelenght);
frompacket.WriteString(message, messagelenght);
toChar.SendPacket(frompacket);
}
using (var pack = new Packet(SH8Type.WisperTo))
{
pack.WriteString(toname, 16);
pack.WriteByte(messagelenght);
pack.WriteString(message, messagelenght);
client.SendPacket(pack);
}
}
else
{
//target not found
using (var pp = new Packet(SH8Type.WisperTargetNotfound))
{
pp.WriteUShort(3945);//unk
pp.WriteString(toname, 16);
client.SendPacket(pp);
}
}
}
}
示例5: MasterRemove
public static void MasterRemove(WorldClient client, Packet packet)
{
string removename;
if(!packet.TryReadString(out removename,16))
return;
MasterManager.Instance.RemoveMasterMember(client.Character, removename);
}
示例6: FriendInviteResponse
public static void FriendInviteResponse(WorldClient pClient, Packet pPacket)
{
string target, sender;
bool response;
if (!pPacket.TryReadString(out target, 16) ||
!pPacket.TryReadString(out sender, 16) ||
!pPacket.TryReadBool(out response))
{
Log.WriteLine(LogLevel.Warn, "Could not reat friend invite response.");
return;
}
WorldClient sendchar = ClientManager.Instance.GetClientByCharname(sender);
if (sendchar == null)
{
Log.WriteLine(LogLevel.Warn, "Invalid friend reject received.");
return;
}
if (response)
{
Friend sendfriend = sendchar.Character.AddFriend(pClient.Character);
if (sendfriend != null)
{
using (var packet = new Packet(SH21Type.FriendInviteResponse))
{
packet.WriteString(sender, 16);
packet.WriteString(target, 16);
packet.WriteByte(0);
sendchar.SendPacket(packet);
}
using (var packet = new Packet(SH21Type.FriendExtraInformation))
{
sendfriend.WritePacket(packet);
sendchar.SendPacket(packet);
}
}
}
else
{
using (var packet = new Packet(SH21Type.FriendInviteReject))
{
packet.WriteString(target, 16);
sendchar.SendPacket(packet);
}
}
}
示例7: AcceptParty
public static void AcceptParty(WorldClient client, Packet packet)
{
string inviteChar;
if (packet.TryReadString(out inviteChar, 16))
{
GroupManager.Instance.AcceptInvite(client, inviteChar);
}
}
示例8: FileHash
public static void FileHash(LoginClient pClient, Packet pPacket)
{
string hash;
if (!pPacket.TryReadString(out hash)) {
Log.WriteLine(LogLevel.Warn, "Empty filehash received.");
SendFailedLogin(pClient, ServerError.Exception);
} else
AllowFiles(pClient, true);
}
示例9: ChangePartyMaster
public static void ChangePartyMaster(WorldClient client, Packet packet)
{
string mastername;
if (packet.TryReadString(out mastername, 16))
{
if(client.Character.Group.Master.Name != client.Character.Character.Name)
return;
GroupManager.Instance.ChangeMaster(client, mastername);
}
}
示例10: KickPartyMember
public static void KickPartyMember(WorldClient client, Packet packet)
{
string removeName;
if (packet.TryReadString(out removeName, 16))
{
if(!client.Character.Group.HasMember(removeName))
return;
GroupManager.Instance.KickMember(client, removeName);
}
}
示例11: MasterRequestResponse
public static void MasterRequestResponse(WorldClient client, Packet packet)
{
string requester = string.Empty;
string target = string.Empty;
byte response;
if (!packet.TryReadString(out requester, 16))
return;
if (!packet.TryReadString(out target, 16))
return;
if (!packet.TryReadByte(out response))
return;
if (response == 0)
{
MasterManager.Instance.RemoveMasterRequest(client);
}
else if(response == 1)
{
MasterManager.Instance.MasterRequestAccept(requester, target);
}
}
示例12: CreateCharHandler
public static void CreateCharHandler(WorldClient client, Packet packet)
{
string name;
byte slot, jobGender, hair, color, style;
if (!packet.TryReadByte(out slot) || !packet.TryReadString(out name, 20) ||
!packet.TryReadByte(out jobGender) || !packet.TryReadByte(out hair) ||
!packet.TryReadByte(out color) || !packet.TryReadByte(out style))
{
Log.WriteLine(LogLevel.Warn, "Error reading create char for {0}", client.Username);
return;
}
if (DatabaseChecks.IsCharNameUsed(name))
{
SendCharCreationError(client, CreateCharError.NameTaken);
return;
}
else if (DataProvider.Instance.IsBadName(name))
{
SendCharCreationError(client, CreateCharError.NameInUse);
return;
}
byte isMaleByte = (byte)((jobGender >> 7) & 0x01);
byte classIDByte = (byte)((jobGender >> 2) & 0x1F);
Job job = (Job)classIDByte;
switch (job)
{
case Job.Archer:
case Job.Cleric:
case Job.Fighter:
case Job.Mage:
case Job.Trickster:
//create character here
try
{
WorldCharacter wchar = client.CreateCharacter(name, slot, hair, color, style, job, Convert.ToBoolean(isMaleByte));
SendCharOKResponse(client, wchar);
}
catch (Exception ex)
{
Log.WriteLine(LogLevel.Exception, "Error creating character for {0}: {1}", client.Username, ex.InnerException.ToString());
SendCharCreationError(client, CreateCharError.FailedToCreate);
return;
}
break;
default:
SendCharCreationError(client, CreateCharError.WrongClass);
Log.WriteLine(LogLevel.Warn, "Invalid job ID at char creation from {0}", client.Username);
break;
}
}
示例13: PartyChat
public static void PartyChat(WorldClient client, Packet packet)
{
if (client.Character.Group == null)
return;
byte msgLen;
string msg = string.Empty;
if (!packet.TryReadByte(out msgLen) || !packet.TryReadString(out msg, msgLen))
return;
client.Character.Group.Chat(client, msg);
}
示例14: ChangeCharNameHandler
public static void ChangeCharNameHandler(WorldClient client, Packet packet)
{
byte Character_slot;
string charname;
if (!packet.TryReadByte(out Character_slot) || !packet.TryReadString(out charname, 16))
return;
using (var pack = new Packet(SH5Type.SendCharacterChangeNewName))
{
pack.WriteByte(Character_slot);
pack.WriteString(charname,16);
pack.WriteUShort(208);//Responsecode?
}
//Todo ChangeinDatabase
}
示例15: AddBlock
public static void AddBlock(WorldClient client, Packet packet)
{
string AddBlockname;
if (packet.TryReadString(out AddBlockname, 16))
{
client.Character.BlocketUser.Add(AddBlockname);
using (var pp = new Packet(SH42Type.AddToBlockList))
{
pp.WriteUShort(7168);//unk
pp.WriteString(AddBlockname, 16);
pp.WriteUShort(0);//unk
client.SendPacket(pp);
}
Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO BlockUser (CharID,BlockCharname) VALUES ('" + client.Character.ID + "','" + AddBlockname + "')");
}
}