PutByte() public method

Put the given byte at the current offset.
public PutByte ( byte b ) : void
b byte Byte to insert.
return void
Ejemplo n.º 1
0
 private void ReceiveKeyExchange(IAsyncResult ar)
 {
     try
     {
         if (this.isDisconnected)
         {
             return;
         }
         if (!sock.Connected)
         {
             ClientManager.EnterCriticalArea();
             this.Disconnect();
             ClientManager.LeaveCriticalArea();
             return;
         }
         try { stream.EndRead(ar); }
         catch (Exception)
         {
             ClientManager.EnterCriticalArea();
             this.Disconnect();
             ClientManager.LeaveCriticalArea();
             return;
         }
         byte[] raw = (byte[])ar.AsyncState;
         if (raw.Length == 8)
         {
             Packet p1 = new Packet(529);
             p1.PutUInt(1, 4);
             p1.PutByte(0x32, 8);
             p1.PutUInt(0x100, 9);
             Crypt.MakePrivateKey();
             string bufstring = Conversions.bytes2HexString(Encryption.Module.getBytes());
             p1.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring.ToLower()), 13);
             p1.PutUInt(0x100, 269);
             bufstring = Conversions.bytes2HexString(Crypt.GetKeyExchangeBytes());
             p1.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring), 273);
             SendPacket(p1, true, true);
             try
             {
                 byte[] data = new byte[260];
                 stream.BeginRead(data, 0, 260, this.callbackKeyExchange, data);
             }
             catch (Exception)
             {
                 ClientManager.EnterCriticalArea();
                 this.Disconnect();
                 ClientManager.LeaveCriticalArea();
                 return;
             }
         }
         else if (raw.Length == 260)
         {
             Packet p1 = new Packet();
             p1.data = raw;
             byte[] keyBuf = p1.GetBytes(256, 4);
             Crypt.MakeAESKey(System.Text.Encoding.ASCII.GetString(keyBuf));
             StartPacketParsing();
         }
         else if (raw.Length == 529)
         {
             Packet p1 = new Packet();
             p1.data = raw;
             byte[] keyBuf = p1.GetBytes(256, 273);
             Crypt.MakePrivateKey();
             Packet p2 = new Packet(260);
             p2.PutUInt(0x100, 0);
             string bufstring = Conversions.bytes2HexString(Crypt.GetKeyExchangeBytes());
             p2.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring), 4);
             SendPacket(p2, true, true);
             Crypt.MakeAESKey(System.Text.Encoding.ASCII.GetString(keyBuf));
             StartPacketParsing();
         }
     }
     catch (Exception ex)
     {
         Logger.ShowError(ex);
     }
 }
Ejemplo n.º 2
0
 public override void OnDie()
 {
     base.OnDie();
     if( delay != -1 )
         respawnTask.Activate();
     corpsetask.Activate();
     ai.Pause();
     if( this.map.GetActor( this.timeSignature.actorID ) != null )
     {
         ActorPC pc = (ActorPC)this.map.GetActor( this.timeSignature.actorID );
         ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
         Packet p = new Packet();//don't know its name,maybe for some animation.
         p.data = new byte[9];
         p.ID = 0x060E;
         p.PutUInt( this.Actor.id, 4 );
         p.PutByte( 4, 8 );
         eh.C.netIO.SendPacket(p, eh.C.SessionID);
         SagaDB.Quest.Quest quest = Quest.QuestsManager.GetActiveQuest( pc );
         if( quest != null )//Add a temporary loot for a specificial quest
         {
             if( Quest.QuestsManager.MobQuestItem.ContainsKey( this.Actor.npcType ) )
             {
                 foreach( Quest.QuestsManager.LootInfo i in Quest.QuestsManager.MobQuestItem[this.Actor.npcType] )
                 {
                     if( i.QID == quest.ID )
                     {
                         if( quest.Steps.ContainsKey( i.SID ) )
                         {
                             if( quest.Steps[i.SID].Status == 1 )
                             {
                                 if( this.Actor.NPCinv == null ) Actor.NPCinv = new List<Item>();
                                 int j = Global.Random.Next( 0, 9999 );
                                 if( j < i.rate )
                                     this.Actor.NPCinv.Add( new Item( i.itemID ) );
                                 return;
                             }
                         }
                     }
                 }
             }
         }
         /*if (eh.C.QuestMobItem != null)
         {
             if (eh.C.QuestMobItem.ContainsKey(this.Actor.npcType))
             {
                 if (this.Actor.NPCinv == null) Actor.NPCinv = new List<Item>();
                 this.Actor.NPCinv.Add(ItemFactory.GetItem((int)eh.C.QuestMobItem[this.Actor.npcType]));
             }
         }*/
     }
 }
Ejemplo n.º 3
0
 private void ReceiveKeyExchange(IAsyncResult ar)
 {
     try
     {
         if (this.isDisconnected)
         {
             return;
         }
         if (!sock.Connected)
         {
             ClientManager.EnterCriticalArea();
             this.Disconnect();
             ClientManager.LeaveCriticalArea();
             return;
         }
         try { stream.EndRead(ar); }
         catch (Exception)
         {
             ClientManager.EnterCriticalArea();
             this.Disconnect();
             ClientManager.LeaveCriticalArea();
             return;
         }
         byte[] raw = (byte[])ar.AsyncState;
         if (raw.Length == 8)
         {
             Packet p1 = new Packet(529);
             p1.PutUInt(1, 4);
             p1.PutByte(0x32, 8);
             p1.PutUInt(0x100, 9);
             Crypt.MakePrivateKey();
             string bufstring = Conversions.bytes2HexString(Encryption.Module.getBytes());
             p1.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring.ToLower()), 13);
             p1.PutUInt(0x100, 269);
             bufstring = Conversions.bytes2HexString(Crypt.GetKeyExchangeBytes());
             p1.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring), 273);
             SendPacket(p1, true, true);
             try
             {
                 byte[] data = new byte[260];
                 stream.BeginRead(data, 0, 260, this.callbackKeyExchange, data);
             }
             catch (Exception)
             {
                 ClientManager.EnterCriticalArea();
                 this.Disconnect();
                 ClientManager.LeaveCriticalArea();
                 return;
             }
         }
         else if (raw.Length == 260)
         {
             Packet p1 = new Packet();
             p1.data = raw;
             byte[] keyBuf = p1.GetBytes(256, 4);
             Crypt.MakeAESKey(System.Text.Encoding.ASCII.GetString(keyBuf));
             StartPacketParsing();
         }
         else if (raw.Length == 529)
         {
             Packet p1 = new Packet();
             p1.data = raw;
             byte[] keyBuf = p1.GetBytes(256, 273);
             Crypt.MakePrivateKey();
             Packet p2 = new Packet(260);
             p2.PutUInt(0x100, 0);
             string bufstring = Conversions.bytes2HexString(Crypt.GetKeyExchangeBytes());
             p2.PutBytes(System.Text.Encoding.ASCII.GetBytes(bufstring), 4);
             SendPacket(p2, true, true);
             Crypt.MakeAESKey(System.Text.Encoding.ASCII.GetString(keyBuf));
             StartPacketParsing();
         }
     }
     catch (Exception ex)
     {
         Logger.ShowError(ex);
     }
 }