private void ProcessPacket(byte[] packet, int bytes) { var offset = 0; const int SIZE_OF_PACKET = 100; //104 on new server try { if (bytes > 0) { // we have received some bytes, check if this is the beginning of a new packet or a chunk of an existing one. offset = CheckStart(packet); eq.BeginProcessPacket(); //clears spawn&ground arrays for (; offset + SIZE_OF_PACKET <= bytes; offset += SIZE_OF_PACKET) { Spawninfo si = new Spawninfo(); if (offset < 0) { // copy the missing chunk of the incomplete packet to the incomplete packet buffer try { PacketCopy(packet, SIZE_OF_PACKET); } catch (Exception ex) { LogLib.WriteLine("Error: ProcessPacket: Copy Incomplete packet buffer: ", ex); } incompleteCount = 0; if (incompletebuffer.Length == 0) { numPackets = 0; break; } si.Frombytes(incompletebuffer, 0); } else { si.Frombytes(packet, offset); } numProcessed++; ProcessPacket(si); } eq.ProcessSpawnList(f1.SpawnList); eq.ProcessGroundItemList(f1.GroundItemList); } } catch (Exception ex) { LogLib.WriteLine("Error: ProcessPacket: ", ex); } ProcessedPackets(packet, bytes, offset); }