本文整理汇总了C#中Server.Network.PacketReader.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Seek方法的具体用法?C# PacketReader.Seek怎么用?C# PacketReader.Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Network.PacketReader
的用法示例。
在下文中一共展示了PacketReader.Seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TargetResponse
public static void TargetResponse( NetState state, PacketReader pvSrc )
{
int type = pvSrc.ReadByte();
int targetID = pvSrc.ReadInt32();
int flags = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16();
int z = pvSrc.ReadInt16();
int graphic = pvSrc.ReadInt16();
pvSrc.Seek( 1, System.IO.SeekOrigin.Begin );
Mobile from = state.Mobile;
if ( from == null || from.Target == null )
return;
if ( x == 0 && y == 0 && z == 0 && serial != from.Serial )
{
bool ok = false;
if ( serial.IsItem )
{
Item i = World.FindItem( serial );
if ( i != null && i.Location == Point3D.Zero )
ok = true;
}
else if ( serial.IsMobile )
{
Mobile m = World.FindMobile( serial );
if ( m != null && m.Location == Point3D.Zero )
ok = true;
}
object o = m_LastTarget[from];
if ( !ok && o != null && o is Serial && serial != (Serial)o )
{
from.SendAsciiMessage( "This EasyUO target has been blocked." );
from.Target.Cancel( from, TargetCancelType.Canceled );
return;
}
}
if ( from.Serial != serial )
m_LastTarget[from] = serial;
m_Real6C.OnReceive( state, pvSrc );
}
示例2: OpenChatWindowRequest
public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
if ( !Enabled )
{
from.SendMessage( "The chat system has been disabled." );
return;
}
pvSrc.Seek( 2, System.IO.SeekOrigin.Begin );
/*string chatName = */
pvSrc.ReadUnicodeStringSafe( ( 0x40 - 2 ) >> 1 ).Trim();
string chatName = from.Name;
SendCommandTo( from, ChatCommand.OpenChatWindow, chatName );
ChatUser.AddChatUser( from );
}
示例3: LoginServerSeed
public static void LoginServerSeed(NetState state, PacketReader pvSrc)
{
int seed = pvSrc.ReadInt32(); // Seed
int clientMaj = pvSrc.ReadInt32();
int clientMin = pvSrc.ReadInt32();
int clientRev = pvSrc.ReadInt32();
int clientPat = pvSrc.ReadInt32();
if ((seed == 0) && (clientMaj == 0) && (clientMin == 0) && (clientPat == 0) && (clientRev == 0))
{
state.SentFirstPacket = true;
// This is UOExt. Cheers!
state.Send(m_UOExtSupport);
state.Flush();
return;
}
// Enroute to old EF handler
pvSrc.Seek(0, System.IO.SeekOrigin.Begin);
m_OldEFHandler.OnReceive(state, pvSrc);
}
示例4: HeaderChange
public static void HeaderChange( 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
int titleLength = pvSrc.ReadUInt16();
if ( titleLength > 60 )
return;
string title = pvSrc.ReadUTF8StringSafe( titleLength );
int authorLength = pvSrc.ReadUInt16();
if ( authorLength > 30 )
return;
string author = pvSrc.ReadUTF8StringSafe( authorLength );
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;
}
示例5: EquipReq
public static void EquipReq( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
Item item = from.Holding;
bool valid = ( item != null && item.HeldBy == from && item.Map == Map.Internal );
from.Holding = null;
if ( !valid ) {
return;
}
pvSrc.Seek( 5, SeekOrigin.Current );
Mobile to = World.FindMobile( pvSrc.ReadInt32() );
if ( to == null )
to = from;
if ( !to.AllowEquipFrom( from ) || !to.EquipItem( item ) )
item.Bounce( from );
item.ClearBounce();
}
示例6: VendorBuyReply
public static void VendorBuyReply( NetState state, PacketReader pvSrc )
{
pvSrc.Seek( 1, SeekOrigin.Begin );
int msgSize = pvSrc.ReadUInt16();
Mobile vendor = World.FindMobile( pvSrc.ReadInt32() );
byte flag = pvSrc.ReadByte();
if ( vendor == null )
{
return;
}
else if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
{
state.Send( new EndVendorBuy( vendor ) );
return;
}
if ( flag == 0x02 )
{
msgSize -= 1+2+4+1;
if ( (msgSize / 7) > 100 )
return;
List<BuyItemResponse> buyList = new List<BuyItemResponse>( msgSize / 7 );
for ( ;msgSize>0;msgSize-=7)
{
byte layer = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int amount = pvSrc.ReadInt16();
buyList.Add( new BuyItemResponse( serial, amount ) );
}
if ( buyList.Count > 0 )
{
IVendor v = vendor as IVendor;
if ( v != null && v.OnBuyItems( state.Mobile, buyList ) )
state.Send( new EndVendorBuy( vendor ) );
}
}
else
{
state.Send( new EndVendorBuy( vendor ) );
}
}
示例7: PlayCharacter
public static void PlayCharacter( NetState state, PacketReader pvSrc )
{
pvSrc.ReadInt32(); // 0xEDEDEDED
string name = pvSrc.ReadString( 30 );
pvSrc.Seek( 2, SeekOrigin.Current );
int flags = pvSrc.ReadInt32();
if ( FeatureProtection.DisabledFeatures != 0 && ThirdPartyAuthCallback != null )
{
bool authOK = false;
ulong razorFeatures = (((ulong)pvSrc.ReadUInt32())<<32) | ((ulong)pvSrc.ReadUInt32());
if ( razorFeatures == (ulong)FeatureProtection.DisabledFeatures )
{
bool match = true;
for ( int i=0; match && i < m_ThirdPartyAuthKey.Length; i++ )
match = match && pvSrc.ReadByte() == m_ThirdPartyAuthKey[i];
if ( match )
authOK = true;
}
else
{
pvSrc.Seek( 16, SeekOrigin.Current );
}
ThirdPartyAuthCallback( state, authOK );
}
else
{
pvSrc.Seek( 24, SeekOrigin.Current );
}
if ( ThirdPartyHackedCallback != null )
{
pvSrc.Seek( -2, SeekOrigin.Current );
if ( pvSrc.ReadUInt16() == 0xDEAD )
ThirdPartyHackedCallback( state, true );
}
if ( !state.Running )
return;
int charSlot = pvSrc.ReadInt32();
int clientIP = pvSrc.ReadInt32();
IAccount a = state.Account;
if ( a == null || charSlot < 0 || charSlot >= a.Length )
{
state.Dispose();
}
else
{
Mobile m = a[charSlot];
// Check if anyone is using this account
for ( int i = 0; i < a.Length; ++i )
{
Mobile check = a[i];
if ( check != null && check.Map != Map.Internal && check != m )
{
Console.WriteLine( "Login: {0}: Account in use", state );
state.Send( new PopupMessage( PMMessage.CharInWorld ) );
return;
}
}
if ( m == null )
{
state.Dispose();
}
else
{
if ( m.NetState != null )
m.NetState.Dispose();
NetState.ProcessDisposedQueue();
state.Send( new ClientVersionReq() );
state.BlockAllPackets = true;
state.Flags = (ClientFlags)flags;
state.Mobile = m;
m.NetState = state;
new LoginTimer( state, m ).Start();
}
}
}
示例8: EquipItem
private static void EquipItem(NetState state, PacketReader reader, ref byte[] buffer, ref int length)
{
int pos = reader.Seek(0, SeekOrigin.Current);
reader.Seek(1, SeekOrigin.Begin);
Item item = World.FindItem(reader.ReadInt32());
reader.Seek(pos, SeekOrigin.Begin);
if (EquipItemParent != null)
{
EquipItemParent(state, reader, ref buffer, ref length);
}
if (!CMOptions.ModuleEnabled || item == null || item.Deleted || !item.Layer.IsEquip())
{
return;
}
if (CMOptions.ModuleDebug)
{
CMOptions.ToConsole("EquipItem: {0} equiped {1}", state.Mobile, item);
}
Timer.DelayCall(() => Invalidate(state.Mobile, item));
}
示例9: CreateCharacter
public static void CreateCharacter( NetState state, PacketReader pvSrc )
{
/*int unk1 = */pvSrc.ReadInt32();
/*int unk2 = */pvSrc.ReadInt32();
/*int unk3 = */pvSrc.ReadByte();
string name = pvSrc.ReadString( 30 );
pvSrc.Seek( 2, SeekOrigin.Current );
int flags = pvSrc.ReadInt32();
pvSrc.Seek( 8, SeekOrigin.Current );
int prof = pvSrc.ReadByte();
pvSrc.Seek( 15, SeekOrigin.Current );
bool female = pvSrc.ReadByte() > 0 ? true : false;
/*int genderRace = pvSrc.ReadByte();*/
int str = pvSrc.ReadByte();
int dex = pvSrc.ReadByte();
int intl= pvSrc.ReadByte();
int is1 = pvSrc.ReadByte();
int vs1 = pvSrc.ReadByte();
int is2 = pvSrc.ReadByte();
int vs2 = pvSrc.ReadByte();
int is3 = pvSrc.ReadByte();
int vs3 = pvSrc.ReadByte();
int hue = pvSrc.ReadUInt16();
int hairVal = pvSrc.ReadInt16();
int hairHue = pvSrc.ReadInt16();
int hairValf= pvSrc.ReadInt16();
int hairHuef= pvSrc.ReadInt16();
pvSrc.ReadByte();
int cityIndex = pvSrc.ReadByte();
/*int charSlot = */pvSrc.ReadInt32();
/*int clientIP = */pvSrc.ReadInt32();
int shirtHue = pvSrc.ReadInt16();
int pantsHue = pvSrc.ReadInt16();
CityInfo[] info = state.CityInfo;
IAccount a = state.Account;
if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
{
state.Dispose();
}
else
{
// Check if anyone is using this account
for ( int i = 0; i < a.Length; ++i )
{
Mobile check = a[i];
if ( check != null && check.Map != Map.Internal )
{
log.InfoFormat("Login: {0}: Account in use", state);
state.Send( new PopupMessage( PMMessage.CharInWorld ) );
return;
}
}
state.Flags = flags;
CharacterCreatedEventArgs args = new CharacterCreatedEventArgs(
state, a,
name, female, hue,
str, dex, intl,
info[cityIndex],
new SkillNameValue[3]
{
new SkillNameValue( (SkillName)is1, vs1 ),
new SkillNameValue( (SkillName)is2, vs2 ),
new SkillNameValue( (SkillName)is3, vs3 ),
},
shirtHue, pantsHue,
hairVal, hairHue,
hairValf, hairHuef,
prof );
state.Send( new ClientVersionReq() );
state.BlockAllPackets = true;
try {
EventSink.InvokeCharacterCreated(args);
} catch (Exception ex) {
log.Fatal(String.Format("Exception disarmed in CharacterCreated {0}",
name), ex);
}
Mobile m = args.Mobile;
if ( m != null )
{
state.Mobile = m;
m.NetState = state;
new LoginTimer( state, m ).Start();
}
else
{
state.BlockAllPackets = false;
state.Dispose();
}
//.........这里部分代码省略.........
示例10: EquipReq
public static void EquipReq( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
Item item = from.Holding;
bool valid = ( item != null && item.HeldBy == from && item.Map == Map.Internal );
from.Holding = null;
if ( !valid ) {
return;
}
pvSrc.Seek( 5, SeekOrigin.Current );
Mobile to = World.FindMobile( pvSrc.ReadInt32() );
if ( to == null )
to = from;
try {
if ( !to.AllowEquipFrom(from) || !to.EquipItem( item ))
item.Bounce(from);
} catch (Exception e) {
log.Fatal(String.Format("Exception disarmed in equip {0} < {1}",
to, item), e);
}
item.ClearBounce();
}
示例11: EncryptionResponse3D
// UOSA
public static void EncryptionResponse3D(NetState state, PacketReader pvSrc)
{
int size = pvSrc.ReadInt16();
int publicKey_lenght = pvSrc.ReadInt32();
int publicKey = pvSrc.Seek(publicKey_lenght, SeekOrigin.Current);
}
示例12: UOExtPacket
public static void UOExtPacket(NetState state, PacketReader pvSrc)
{
byte header = pvSrc.ReadByte();
int position = pvSrc.Seek(0, System.IO.SeekOrigin.Current);
m_handler.ProcessBuffer(new NetStateAdapter(state), header, pvSrc.Buffer, position, (short)(pvSrc.Size - 4));
}
示例13: ContentChange
public static void ContentChange(NetState state, PacketReader pvSrc)
{
// need to deal with actual books
//string entryText = String.Empty;
//Mobile from = state.Mobile;
int pos = pvSrc.Seek(0, SeekOrigin.Current);
int serial = pvSrc.ReadInt32();
Item bookitem = World.FindItem(serial);
// first try it as a normal basebook
if (bookitem is BaseBook)
{
// do the base book content change
//BaseContentChange(bookitem as BaseBook, state, pvSrc);
pvSrc.Seek(pos, SeekOrigin.Begin);
if (PacketHandlerOverrides.ContentChangeParent != null)
{
PacketHandlerOverrides.ContentChangeParent.OnReceive(state, pvSrc);
}
else
{
BaseBook.ContentChange(state, pvSrc);
}
return;
}
// then try it as a text entry book
var book = bookitem as BaseEntryBook;
if (book == null)
{
return;
}
// get the number of available pages in the book
int pageCount = pvSrc.ReadUInt16();
if (pageCount > book.PagesCount)
{
return;
}
for (int i = 0; i < pageCount; ++i)
{
// get the current page number being read
int index = pvSrc.ReadUInt16();
if (index >= 1 && index <= book.PagesCount)
{
--index;
int lineCount = pvSrc.ReadUInt16();
if (lineCount <= 8)
{
var lines = new string[lineCount];
for (int j = 0; j < lineCount; ++j)
{
if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80)
{
return;
}
}
book.Pages[index].Lines = lines;
}
else
{
return;
}
}
else
{
return;
}
}
var sb = new StringBuilder();
// add the book lines to the entry string
for (int i = 0; i < book.PagesCount; ++i)
{
foreach (string line in book.Pages[i].Lines)
{
sb.Append(line);
}
}
// send the book text off to be processed by invoking the callback if it is a textentry book
var tebook = book as XmlTextEntryBook;
if (tebook != null && tebook.m_bookcallback != null)
{
tebook.m_bookcallback(state.Mobile, tebook.m_args, sb.ToString());
//.........这里部分代码省略.........
示例14: LookReq
public static void LookReq(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
int pos = pvSrc.Seek(0, SeekOrigin.Current);
Serial s = pvSrc.ReadInt32();
pvSrc.Seek(pos, SeekOrigin.Begin);
if (s.IsMobile)
{
Mobile m = World.FindMobile(s);
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m) &&
XmlScript.HasTrigger(m, TriggerName.onSingleClick) &&
UberScriptTriggers.Trigger(m, from, TriggerName.onSingleClick))
{
return;
}
}
else if (s.IsItem)
{
Item item = World.FindItem(s);
if (item != null && !item.Deleted && from.CanSee(item) &&
Utility.InUpdateRange(from.Location, item.GetWorldLocation(from)) &&
XmlScript.HasTrigger(item, TriggerName.onSingleClick) &&
UberScriptTriggers.Trigger(item, from, TriggerName.onSingleClick, item))
{
return;
}
}
if (PacketHandlerOverrides.LookReqParent != null)
{
PacketHandlerOverrides.LookReqParent.OnReceive(state, pvSrc);
}
else
{
PacketHandlers.LookReq(state, pvSrc);
}
}
示例15: UseReq
public static void UseReq(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
if (from.AccessLevel >= AccessLevel.GameMaster || DateTime.UtcNow >= from.NextActionTime)
{
int pos = pvSrc.Seek(0, SeekOrigin.Current);
int value = pvSrc.ReadInt32();
pvSrc.Seek(pos, SeekOrigin.Begin);
if ((value & ~0x7FFFFFFF) != 0)
{
from.OnPaperdollRequest();
}
else
{
Serial s = value;
bool blockdefaultonuse = false;
if (s.IsMobile)
{
Mobile m = World.FindMobile(s);
if (m != null && !m.Deleted)
{
blockdefaultonuse = (XmlScript.HasTrigger(m, TriggerName.onUse) &&
UberScriptTriggers.Trigger(m, from, TriggerName.onUse)) ||
(XmlScript.HasTrigger(from, TriggerName.onUse) && UberScriptTriggers.Trigger(from, from, TriggerName.onUse));
if (!blockdefaultonuse && !m.Deleted)
{
//from.Use(m);
if (PacketHandlerOverrides.UseReqParent != null)
{
PacketHandlerOverrides.UseReqParent.OnReceive(state, pvSrc);
}
else
{
PacketHandlers.UseReq(state, pvSrc);
}
return;
}
}
}
else if (s.IsItem)
{
Item item = World.FindItem(s);
if (item != null && !item.Deleted)
{
blockdefaultonuse = (XmlScript.HasTrigger(from, TriggerName.onUse) &&
UberScriptTriggers.Trigger(from, from, TriggerName.onUse)) ||
(XmlScript.HasTrigger(item, TriggerName.onUse) && UberScriptTriggers.Trigger(item, from, TriggerName.onUse));
// need to check the item again in case it was modified in the OnUse or OnUser method
if (!blockdefaultonuse && !item.Deleted)
{
//from.Use(item);
if (PacketHandlerOverrides.UseReqParent != null)
{
PacketHandlerOverrides.UseReqParent.OnReceive(state, pvSrc);
}
else
{
PacketHandlers.UseReq(state, pvSrc);
}
return;
}
}
}
}
from.NextActionTime = DateTime.UtcNow + Mobile.ServerWideObjectDelay;
}
else
{
from.SendActionMessage();
}
}