void CoreTick() { if (DoDayNightCycle) { Ticks++; } CheckAsyncResources(); wom.Tick(); game.Mode.Tick(); if (receivedFirstPosition) { LocalPlayer player = game.LocalPlayer; classic.WritePosition(player.Position, player.HeadY, player.HeadX); } pingTicks++; if (pingTicks >= 20 && cpeData.twoWayPing) { cpe.WriteTwoWayPing(false, PingList.NextTwoWayPingData()); pingTicks = 0; } if (writer.index > 0) { SendPacket(); } }
void CoreTick() { CheckAsyncResources(); wom.Tick(); classic.Tick(); cpe.Tick(); if (writer.index > 0) { SendPacket(); } }
void CoreTick() { CheckAsyncResources(); wom.Tick(); if (!receivedFirstPosition) { return; } LocalPlayer player = game.LocalPlayer; classic.WritePosition(player.Position, player.HeadY, player.HeadX); pingTicks++; if (pingTicks >= 20 && cpeData.twoWayPing) { cpe.WriteTwoWayPing(false, PingList.NextTwoWayPingData()); pingTicks = 0; } SendPacket(); }
public override void Tick(ScheduledTask task) { if (Disconnected) { return; } if ((DateTime.UtcNow - lastPacket).TotalSeconds >= 30) { CheckDisconnection(task.Interval); } if (Disconnected) { return; } LocalPlayer player = game.LocalPlayer; this.task = task; try { reader.ReadPendingData(); } catch (SocketException ex) { ErrorHandler.LogError("reading packets", ex); game.Disconnect("&eLost connection to the server", "I/O error when reading packets"); Dispose(); return; } while ((reader.size - reader.index) > 0) { byte opcode = reader.buffer[reader.index]; // Workaround for older D3 servers which wrote one byte too many for HackControl packets. if (cpeData.needD3Fix && lastOpcode == Opcode.CpeHackControl && (opcode == 0x00 || opcode == 0xFF)) { Utils.LogDebug("Skipping invalid HackControl byte from D3 server."); reader.Skip(1); player.physics.jumpVel = 0.42f; // assume default jump height player.physics.serverJumpVel = player.physics.jumpVel; continue; } if (opcode > maxHandledPacket) { ErrorHandler.LogError("NetworkProcessor.Tick", "received an invalid opcode of " + opcode); reader.Skip(1); continue; } if ((reader.size - reader.index) < packetSizes[opcode]) { break; } ReadPacket(opcode); } reader.RemoveProcessed(); if (receivedFirstPosition) { SendPosition(player.Position, player.HeadY, player.HeadX); } CheckAsyncResources(); wom.Tick(); }