本文整理汇总了C#中PacketReader.ReadStringSafe方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadStringSafe方法的具体用法?C# PacketReader.ReadStringSafe怎么用?C# PacketReader.ReadStringSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadStringSafe方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnFilter
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args )
{
if ( args.Block )
return;
// 0, 1, 2
Serial serial = p.ReadUInt32(); // 3, 4, 5, 6
ushort body = p.ReadUInt16(); // 7, 8
MessageType type = (MessageType)p.ReadByte(); // 9
if ( type != m_Type )
return;
ushort hue = p.ReadUInt16(); // 10, 11
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe( 30 );
string text = p.ReadStringSafe();
for(int i=0;i<m_Strings.Length;i++)
{
if ( text.IndexOf( m_Strings[i] ) != -1 )
{
args.Block = true;
return;
}
}
}
示例2: OnASCIIMessage
private static void OnASCIIMessage(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe(30);
string msg = p.ReadStringSafe().Trim();
Handle(asciiMessage, args, serial, graphic, type, hue, font, string.Empty, name, msg);
}
示例3: CharServerConnected
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void CharServerConnected( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 6/*( 6 + 0 )*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
string l_strWorldPassword = packetReader.ReadStringSafe();
if ( l_strWorldPassword == Program.ConfigInfo.WorldPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
netState.ExtendData = l_ExtendData;
}
}
示例4: LoginServerConnectFromCharServer
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void LoginServerConnectFromCharServer( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 14/*6 + 8 + ?*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
long l_iCharGUID = packetReader.ReadUInt32();
long l_iCharPort = packetReader.ReadUInt32();
string l_strLoginPassword = packetReader.ReadStringSafe();
if ( l_strLoginPassword == Program.ConfigInfo.LoginPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
l_ExtendData.CharGUID = l_iCharGUID;
l_ExtendData.CharHost = netState.NetAddress.ToString();
l_ExtendData.CharPort = l_iCharPort;
netState.ExtendData = l_ExtendData;
Program.CharServerList.Add(l_ExtendData);
l_ExtendData.ConnectToCharServer( l_ExtendData.CharHost, l_ExtendData.CharPort );
}
}
示例5: OnLocalizedMessage
private static void OnLocalizedMessage(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
int num = p.ReadInt32();
string name = p.ReadStringSafe(30);
string arguments = p.ReadUnicodeStringBE(((p.Length - 1) - p.Position) / 2);
Handle(localizedMessage, args, serial, graphic, type, hue, font, num, name, arguments);
}
示例6: ExtBuyInfo
private static void ExtBuyInfo( PacketReader p, PacketHandlerEventArgs args )
{
Serial ser = p.ReadUInt32();
Item pack = World.FindItem( ser );
if ( pack == null )
return;
byte count = p.ReadByte();
if ( count < pack.Contains.Count )
{
World.Player.SendMessage( MsgLevel.Debug, "Buy Agent Warning: Contains Count {0} does not match ExtInfo {1}.", pack.Contains.Count, count );
}
pack.Contains.Sort( ItemXYComparer.Instance );
for ( int i = count-1; i >= 0; i-- )
{
if ( i < pack.Contains.Count )
{
Item item = (Item)pack.Contains[i];
item.Price = p.ReadInt32();
byte len = p.ReadByte();
item.BuyDesc = p.ReadStringSafe( len );
}
else
{
p.ReadInt32();
p.Position += p.ReadByte() + 1;
}
}
}
示例7: WorldServerShout
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
public static void WorldServerShout( NetState netState, PacketReader packetReader )
{
WorldServerExtendData l_ExtendData = netState.ExtendData as WorldServerExtendData;
if ( l_ExtendData == null )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData == null error!" );
return;
}
if ( l_ExtendData.ROSEMobile.IsLoggedIn == false )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData.m_bIsLoggedIn == false error!" );
return;
}
if ( packetReader.Size < 7/*6 + 1 + ?*/ )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - packetReader.Size < 7 error!" );
return;
}
string msg = packetReader.ReadStringSafe();
//SendToMap( &pak, thisclient->PlayerPosition->Map );
netState.Send( new ShoutAck( l_ExtendData.ROSEMobile, msg ) );
}
示例8: WorldServerWhisper
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
public static void WorldServerWhisper( NetState netState, PacketReader packetReader )
{
WorldServerExtendData l_ExtendData = netState.ExtendData as WorldServerExtendData;
if ( l_ExtendData == null )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData == null error!" );
return;
}
if ( l_ExtendData.ROSEMobile.IsLoggedIn == false )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData.m_bIsLoggedIn == false error!" );
return;
}
if ( packetReader.Size < 7/*6 + 1 + ?*/ )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - packetReader.Size < 7 error!" );
return;
}
string msgto = packetReader.ReadStringSafe( 16 );
string msg = packetReader.ReadStringSafe();
NetState l_NetState = ProcessNet.GetClientByCharName( msgto );
if ( l_NetState != null )
{
WorldServerExtendData extendData = l_NetState.ExtendData as WorldServerExtendData;
if ( extendData != null )
{
l_NetState.Send( new WhisperAck( extendData.ROSEMobile, msg ) );
return;
}
}
netState.Send( new WhisperAck( l_ExtendData.ROSEMobile, msg ) );
}
示例9: WorldServerNormalChat
public static void WorldServerNormalChat( NetState netState, PacketReader packetReader )
{
LOGs.WriteLine( LogMessageType.MSG_NONE, " WorldServerNormalChat(...)" );
WorldServerExtendData l_ExtendData = netState.ExtendData as WorldServerExtendData;
if ( l_ExtendData == null )
{
Debug.WriteLine( "WorldPacketHandlers.WorldServerNormalChat(...) - l_ExtendData == null error!" );
return;
}
if ( l_ExtendData.ROSEMobile.IsLoggedIn == false )
{
Debug.WriteLine( "WorldPacketHandlers.WorldServerNormalChat(...) - l_ExtendData.m_bIsLoggedIn == true error!" );
return;
}
if ( packetReader.Size < 7/*( 6 + ?)*/ )
{
Debug.WriteLine( "WorldPacketHandlers.WorldServerStopChar(...) - packetReader.Size < 7 error!" );
return;
}
string l_strNormalChat = packetReader.ReadStringSafe();
LOGs.WriteLine( LogMessageType.MSG_NONE, l_strNormalChat );
BaseGameCommand l_GameCommand = GameCommands.GetGameCommand( l_strNormalChat );
if ( l_GameCommand != null )
l_GameCommand.OnEventGameCommand( netState );
else
{
netState.Send( new NormalChatAck( l_ExtendData.ROSEMobile, l_strNormalChat ) );
}
}
示例10: OnUnicodeMessage
private static void OnUnicodeMessage(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
string lang = p.ReadStringSafe(4);
string name = p.ReadStringSafe(30);
string msg = p.ReadUnicodeStringSafe().Trim();
Handle(unicodeMessage, args, serial, graphic, type, hue, font, lang, name, msg);
}
示例11: OnMessageLocalizedAffix
private static void OnMessageLocalizedAffix(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
int num = p.ReadInt32();
string name = p.ReadStringSafe(30);
Handle(localizedMessage, args, serial, graphic, type, hue, font, num, name, string.Empty);
}
示例12: LoginServerAccountLogin
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void LoginServerAccountLogin( NetState netState, PacketReader packetReader )
{
LOGs.WriteLine( LogMessageType.MSG_NOTICE, "LoginPacketHandlers.LoginServerAccountLogin(...){0}", Thread.CurrentThread.Name );
LoginServerExtendData l_ExtendData = netState.ExtendData as LoginServerExtendData;
if ( l_ExtendData == null )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - l_ExtendData == null error!" );
AccountLogin_ReplyRej( netState, LoginReason.LoginFailed );
return;
}
if ( l_ExtendData.IsLoggedIn == true )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - l_ExtendData.IsLoggedIn == true error!" );
AccountLogin_ReplyRej( netState, LoginReason.LoginFailed );
return;
}
if ( packetReader.Size < 38/*6 + 32*/ )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - packetReader.Size < 38 error!" );
AccountLogin_ReplyRej( netState, LoginReason.LoginFailed );
return;
}
string l_strPassword = packetReader.ReadString( 32 );
string l_strUsername = packetReader.ReadStringSafe();
bool l_bIsReturn = false;
Session l_Session = new Session( BaseDatabase.Domain );
l_Session.BeginTransaction();
{
do
{
Query l_QueryAccounts = new Query( l_Session, "Select Accounts instances where {AccountsName}[email protected]" );
l_QueryAccounts.Parameters.Add( "@Username", l_strUsername );
QueryResult l_AccountsResult = l_QueryAccounts.Execute();
if ( l_AccountsResult == null )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - l_AccountsResult == null error!" );
AccountLogin_ReplyRej( netState, LoginReason.NameError );
l_bIsReturn = true;
break;
}
if ( l_AccountsResult.Count != 1 )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - l_AccountsResult.Count != 1 error!" );
AccountLogin_ReplyRej( netState, LoginReason.LoginFailed );
l_bIsReturn = true;
break;
}
Accounts l_Accounts = l_AccountsResult[0] as Accounts;
if ( l_Accounts == null )
{
Debug.WriteLine( "LoginServerPacketHandlers.LoginServerAccountLogin(...) - l_Accounts == null error!" );
AccountLogin_ReplyRej( netState, LoginReason.LoginFailed );
l_bIsReturn = true;
break;
}
if ( l_Accounts.Banned == true || l_Accounts.GMLevel < 0 )
{
AccountLogin_ReplyRej( netState, LoginReason.Blocked );
l_bIsReturn = true;
break;
}
if ( l_Accounts.Locked == true )
{
AccountLogin_ReplyRej( netState, LoginReason.InUse );
for ( int iIndex = 0; iIndex < Program.CharServerList.Count; iIndex++ )
Program.CharServerList[iIndex].SendToCharServer( (int)l_Accounts.AccountsGuid );
l_bIsReturn = true;
break;
}
if ( l_Accounts.Password != l_strPassword )
{
AccountLogin_ReplyRej( netState, LoginReason.PasswordError );
//.........这里部分代码省略.........