本文整理汇总了C#中PacketReader.Byte方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Byte方法的具体用法?C# PacketReader.Byte怎么用?C# PacketReader.Byte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.Byte方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GuildPermissions
/////////////////////////////////////////////////////////////////////////
//Guild Permissions
/////////////////////////////////////////////////////////////////////////
void GuildPermissions()
{
try
{
PacketReader Reader = new PacketReader(PacketInformation.buffer);
Reader.Byte();
int memberid = Reader.Int32();
byte permissions = (byte)Reader.Int32();
char[] bits = new char[8];
for (int i = 0; i < 8; ++i) bits[i] = (char)0;
bits = Convert.ToString(permissions, 2).ToCharArray();
Reader.Close();
// set the amount to the target player :)
int targetindex = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
if (Character.Network.Guild.MembersInfo[targetindex].Online)
{
Systems member = GetPlayerMainid(memberid);
// so here we can set chars right
member.Character.Network.Guild.joinRight = bits[4] == '1' ? true : false;
member.Character.Network.Guild.withdrawRight = bits[3] == '1' ? true : false;
member.Character.Network.Guild.unionRight = bits[2] == '1' ? true : false;
member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
member.Character.Network.Guild.noticeeditRight = bits[1] == '1' ? true : false;
}
// set new amount to every guild members guild class
foreach (int m in Character.Network.Guild.Members)
{
int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
if (Character.Network.Guild.MembersInfo[index].Online)
{
Systems sys = Helpers.GetInformation.GetPlayerMainid(m);
// here comes the messy way
Global.guild_player mygp = new Global.guild_player();
int myindex = 0;
foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
{
if (gp.MemberID == memberid)
{
mygp = gp; //
mygp.joinRight = bits[4] == '1' ? true : false;
mygp.withdrawRight = bits[3] == '1' ? true : false;
mygp.unionRight = bits[2] == '1' ? true : false;
mygp.guildstorageRight = bits[0] == '1' ? true : false;
mygp.noticeeditRight = bits[1] == '1' ? true : false;
break;
}
myindex++;
}
sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
}
}
DB.query("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
}
catch (Exception ex)
{
Console.WriteLine("Guild permission error: {0}", ex);
Log.Exception(ex);
}
}
示例2: Connect
public void Connect()
{
try
{
PacketReader Reader = new PacketReader(PacketInformation.buffer);
if (Reader.Byte() == 18)
{
string ID = Reader.Text();
string PW = Reader.Text();
byte ukn = Reader.Byte(); // 0xff
UInt16 ServerID = Reader.UInt16();
int lResult = 99;
//Console.WriteLine("Id:{0} Pass:{1} ServerID:{2}",ID,PW,ServerID);
SRX_Serverinfo SSI = GSList[ServerID];
if (SSI != null)
{
UInt16 myKey = 0;
string sReason = "";
lock (Program.IPCResultList)
{
myKey = Program.IPCNewId++;
}
byte[] rqp = Program.IPCServer.PacketRequestLogin(Program.IPCPort, ID, PW, myKey);
Servers.IPCenCode(ref rqp, SSI.code);
lock (Program.IPCResultList)
{
Program.IPCResultList.Add(myKey, new IPCItem());
Program.IPCResultList[myKey].resultCode = 0x8000;
}
Program.IPCServer.Send(SSI.ip, SSI.ipcport, rqp);
DateTime tOut = DateTime.Now.AddSeconds(30);
while ((tOut >= DateTime.Now) && (Program.IPCResultList[myKey].resultCode == 0x8000) && (client.clientSocket.Connected))
{
System.Threading.Thread.Sleep(10);
}
lResult = Program.IPCResultList[myKey].resultCode;
sReason = Program.IPCResultList[myKey].banReason;
lock (Program.IPCResultList)
{
Program.IPCResultList[myKey] = null;
Program.IPCResultList.Remove(myKey);
}
rqp = null;
//Console.WriteLine("Resultado de login: {0}",lResult);
switch (lResult)
{
case 0:
if (SSI.lan_wan)
{
client.Send(ConnectSucces(SSI.wan, SSI.port, 1));
}
else
{
client.Send(ConnectSucces(SSI.ip, SSI.port, 1));
}
return;
case 1:
if (WrongPassword < 3)
{
client.Send(WrongInformation());
WrongPassword++;
return;
}
else
{
client.Disconnect(PacketInformation.Client);
return;
}
case 2:
client.Send(ServerIsFull());
client.Disconnect(PacketInformation.Client);
return;
case 3:
client.Send(AllreadyConnected());
client.Disconnect(PacketInformation.Client);
return;
case 4:
client.Send(BannedUser(sReason));
client.Disconnect(PacketInformation.Client);
return;
default:
if (lResult == 0x8000)
{
Console.WriteLine("[IPC] Timeout");
}
else
{
Console.WriteLine("[IPC] Result unknown {0}", lResult);
}
return;
}
}
else
{
Console.WriteLine("Fuck No fun.. SSI");
}
}
//.........这里部分代码省略.........
示例3: HandleRegisterIcon
void HandleRegisterIcon()
{
try
{
PacketReader reader = new PacketReader(PacketInformation.buffer);
byte type = reader.Byte();
int iconlenght = reader.Int32();
string icon = reader.Text();
reader.Close();
string convertedicon = ConvertToHex(icon);
//Save output to .dat file in hex formatting.
}
catch (Exception ex)
{
Console.WriteLine("Guild icon register error {0}", ex);
}
}