本文整理汇总了C#中Server.Network.PacketReader.ReadStringSafe方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadStringSafe方法的具体用法?C# PacketReader.ReadStringSafe怎么用?C# PacketReader.ReadStringSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Network.PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadStringSafe方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChatAction
public static void ChatAction( NetState state, PacketReader pvSrc )
{
if ( !m_Enabled )
return;
try
{
Mobile from = state.Mobile;
ChatUser user = ChatUser.GetChatUser( from );
if ( user == null )
return;
/*string lang = */pvSrc.ReadStringSafe( 4 );
int actionID = pvSrc.ReadInt16();
string param = pvSrc.ReadUnicodeString();
ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );
if ( handler != null )
{
Channel channel = user.CurrentChannel;
if ( handler.RequireConference && channel == null )
{
user.SendMessage( 31 ); /* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
}
else if ( handler.RequireModerator && !user.IsModerator )
{
user.SendMessage( 29 ); // You must have operator status to do this.
}
else
{
handler.Callback( user, channel, param );
}
}
else
{
log.Warn(String.Format("Client: {0}: Unknown chat action 0x{1:X}: {2}",
state, actionID, param));
}
}
catch ( Exception e )
{
log.Error( e );
}
}
示例2: ChatAction
public static void ChatAction( NetState state, PacketReader pvSrc )
{
if ( !Enabled )
return;
try
{
Mobile from = state.Mobile;
ChatUser user = ChatUser.GetChatUser( from );
if ( user == null )
return;
string lang = pvSrc.ReadStringSafe( 4 );
int actionId = pvSrc.ReadInt16();
string param = pvSrc.ReadUnicodeString();
ChatActionHandler handler = ChatActionHandlers.GetHandler( actionId );
if ( handler != null )
{
Channel channel = user.CurrentChannel;
if ( handler.RequireConference && channel == null )
{
/* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
user.SendMessage( 31 );
}
else
{
handler.Callback( user, channel, param );
}
}
else
{
Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionId, param );
}
}
catch ( Exception e )
{
Console.WriteLine(e.ToString());
}
}
示例3: AsciiSpeechChat3
public static void AsciiSpeechChat3(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
MessageType type = (MessageType)pvSrc.ReadByte();
int hue = pvSrc.ReadInt16();
pvSrc.ReadInt16(); // font
string text = pvSrc.ReadStringSafe().Trim();
if (text.Length <= 0 || text.Length > 128)
return;
if (!Enum.IsDefined(typeof(MessageType), type))
type = MessageType.Regular;
Channel c = Channel.GetByType(typeof(Guild));
if (RUOVersion.GuildChat(type) && c != null)
c.OnChat(from, text);
else
from.DoSpeech(text, c_EmptyInts, type, Utility.ClipDyedHue(hue));
}
示例4: OnReceive
public static void OnReceive(NetState state, PacketReader pvSrc)
{
pvSrc.ReadByte(); // 1: <4.0.1a, 2>=4.0.1a
HardwareInfo info = new HardwareInfo();
info.m_InstanceID = pvSrc.ReadInt32();
info.m_OSMajor = pvSrc.ReadInt32();
info.m_OSMinor = pvSrc.ReadInt32();
info.m_OSRevision = pvSrc.ReadInt32();
info.m_CpuManufacturer = pvSrc.ReadByte();
info.m_CpuFamily = pvSrc.ReadInt32();
info.m_CpuModel = pvSrc.ReadInt32();
info.m_CpuClockSpeed = pvSrc.ReadInt32();
info.m_CpuQuantity = pvSrc.ReadByte();
info.m_PhysicalMemory = pvSrc.ReadInt32();
info.m_ScreenWidth = pvSrc.ReadInt32();
info.m_ScreenHeight = pvSrc.ReadInt32();
info.m_ScreenDepth = pvSrc.ReadInt32();
info.m_DXMajor = pvSrc.ReadInt16();
info.m_DXMinor = pvSrc.ReadInt16();
info.m_VCDescription = pvSrc.ReadUnicodeStringLESafe(64);
info.m_VCVendorID = pvSrc.ReadInt32();
info.m_VCDeviceID = pvSrc.ReadInt32();
info.m_VCMemory = pvSrc.ReadInt32();
info.m_Distribution = pvSrc.ReadByte();
info.m_ClientsRunning = pvSrc.ReadByte();
info.m_ClientsInstalled = pvSrc.ReadByte();
info.m_PartialInstalled = pvSrc.ReadByte();
info.m_Language = pvSrc.ReadUnicodeStringLESafe(4);
info.m_Unknown = pvSrc.ReadStringSafe(64);
info.m_TimeReceived = DateTime.Now;
Account acct = state.Account as Account;
if (acct != null)
acct.HardwareInfo = info;
}
示例5: AsciiPromptResponse
public static void AsciiPromptResponse( NetState state, PacketReader pvSrc )
{
int serial = pvSrc.ReadInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string text = pvSrc.ReadStringSafe();
if ( text.Length > 128 )
return;
Mobile from = state.Mobile;
Prompt p = from.Prompt;
if ( p != null && p.Serial == serial && p.Serial == prompt )
{
from.Prompt = null;
if ( type == 0 )
p.OnCancel( from );
else
p.OnResponse( from, text );
}
}
示例6: RenameRequest
public static void RenameRequest( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
Mobile targ = World.FindMobile( pvSrc.ReadInt32() );
if ( targ != null )
EventSink.InvokeRenameRequest( new RenameRequestEventArgs( from, targ, pvSrc.ReadStringSafe() ) );
}
示例7: AsciiSpeech
public static void AsciiSpeech( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
MessageType type = (MessageType)pvSrc.ReadByte();
int hue = pvSrc.ReadInt16();
pvSrc.ReadInt16(); // font
string text = pvSrc.ReadStringSafe().Trim();
if ( text.Length <= 0 || text.Length > 128 )
return;
if ( !Enum.IsDefined( typeof( MessageType ), type ) )
type = MessageType.Regular;
from.DoSpeech( text, m_EmptyInts, type, Utility.ClipDyedHue( hue ) );
}
示例8: OldHeaderChange
public static void OldHeaderChange(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;
if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
return;
pvSrc.Seek(4, SeekOrigin.Current); // Skip flags and page count
string title = pvSrc.ReadStringSafe(60);
string author = pvSrc.ReadStringSafe(30);
book.Title = Utility.FixHtml(title);
book.Author = Utility.FixHtml(author);
}
示例9: AsciiPromptResponse
public static void AsciiPromptResponse( NetState state, PacketReader pvSrc )
{
int serial = pvSrc.ReadInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string text = pvSrc.ReadStringSafe();
if ( text.Length > 128 )
return;
Mobile from = state.Mobile;
Prompt p = from.Prompt;
if ( p != null && p.Serial == serial && p.Serial == prompt )
{
from.Prompt = null;
try {
if ( type == 0 )
p.OnCancel( from );
else
p.OnResponse( from, text );
} catch (Exception e) {
log.Fatal(String.Format("Exception disarmed in AsciiPrompt response {0}, type {1}",
state.Mobile, type), e);
}
}
}
示例10: AsciiPromptResponse
public static void AsciiPromptResponse(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Prompt p = from.Prompt;
int senderSerial = pvSrc.ReadInt32();
int promptId = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string text = pvSrc.ReadStringSafe();
if (text.Length > 128)
return;
if (p != null && p.Sender.Serial == senderSerial && p.TypeId == promptId)
{
from.Prompt = null;
try
{
if (type == 0)
p.OnCancel(from);
else
p.OnResponse(from, text);
}
catch (Exception e)
{
Console.WriteLine("Exception disarmed in AsciiPrompt response {0}, type {1}: {2}", state.Mobile, type, e);
}
}
}
示例11: ChatAction
public static void ChatAction(NetState state, PacketReader pvSrc)
{
/*if ( !m_Enabled )
return;
*/
if (state == null || state.Mobile == null || state.Account == null)
return;
try
{
/*
ChatUser user = ChatUser.GetChatUser( from );
if ( user == null )
return;
*/
string lang = pvSrc.ReadStringSafe(4);
int actionID = pvSrc.ReadInt16();
string param = pvSrc.ReadUnicodeString();
/*
ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );
if ( handler != null )
{
Channel channel = user.CurrentChannel;
if ( handler.RequireConference && channel == null )
{
user.SendMessage( 31 ); // You must be in a conference to do this.
// To join a conference, select one from the Conference menu.
}
else if ( handler.RequireModerator && !user.IsModerator )
{
user.SendMessage( 29 ); // You must have operator status to do this.
}
else
{
handler.Callback( user, channel, param );
}
}
else
{
Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param );
}*/
// CUSTOM CODE for uoforever--Chat b/w mobs with the same teamflags
Mobile from = state.Mobile;
List<XmlTeam> fromTeams = XmlAttach.GetTeams(from);
if (fromTeams != null)
{
List<NetState> states = NetState.Instances;
foreach (NetState nextstate in states)
{
if (nextstate.Mobile == null) continue;
if (nextstate.Mobile.AccessLevel >= AccessLevel.GameMaster)
{
// just get the first team
nextstate.Mobile.SendMessage(101, "[" + fromTeams[0].TeamVal + "] " + from.Name + ": " + param);
}
else
{
if (nextstate.Mobile.CustomTeam)
{
List<XmlTeam> toTeams = XmlAttach.GetTeams(nextstate.Mobile);
if (XmlTeam.SameTeam(fromTeams, toTeams))
{
nextstate.Mobile.SendMessage(101, from.Name + ": " + param);
}
}
}
}
}
else if (from.AccessLevel >= AccessLevel.Counselor
|| CreaturePossession.HasAnyPossessPermissions(from))
{
List<NetState> states = NetState.Instances;
Mobile sourceMobile = from;
if (from is BaseCreature)
{
sourceMobile = state.Account.GetPseudoSeerLastCharacter();
}
if (sourceMobile != null)
{
foreach (NetState nextstate in states)
{
if (nextstate.Mobile == null) continue;
if (nextstate.Mobile.AccessLevel >= AccessLevel.Counselor
|| CreaturePossession.HasAnyPossessPermissions(nextstate.Mobile))
{
// just get the first team
nextstate.Mobile.SendMessage(101, sourceMobile.Name + ": " + param);
}
else if (nextstate.Mobile is BaseCreature)
{
//.........这里部分代码省略.........
示例12: OldHeaderChange
public static void OldHeaderChange( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
BaseBook book = World.FindItem( pvSrc.ReadInt32() ) as BaseBook;
if ( book == null || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) )
return;
pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count
string title = pvSrc.ReadStringSafe( 60 );
string author = pvSrc.ReadStringSafe( 30 );
title = Utility.FixHtml(title);
author = Utility.FixHtml(author);
#region AntiAdverts
if (!String.IsNullOrWhiteSpace(title))
{
int exit = 100;
string detected;
while (AntiAdverts.Detect(title, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
{
title = title.Replace(detected, new String('*', detected.Length));
}
}
if (!String.IsNullOrWhiteSpace(author))
{
int exit = 100;
string detected;
while (AntiAdverts.Detect(author, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
{
author = author.Replace(detected, new String('*', detected.Length));
}
}
#endregion
book.Title = title;
book.Author = author;
}