
Originally Posted by
digistr
Hmm that picture is what your at without playerupdating?
Yup. Could have changed from 317 to 474.

Originally Posted by
digistr
well my server is a 474 but when i remove player updating i get this.
so post your login() method in the PacketSender class.
Login:
Code:
package com.emulation.net.codec;
import java.security.SecureRandom;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
import com.emulation.io.Session;
import com.emulation.model.player.Player;
import com.emulation.net.packet.PacketBuilder;
import com.emulation.util.LoginUtility;
import com.emulation.world.Location;
import com.emulation.world.World;
public class Login extends FrameDecoder {
private int loginSize;
private int encryptedSize;
private SecureRandom random = new SecureRandom();
private long serverKey = this.random.nextLong();
private static byte[] INITIAL_RESPONSE = new byte[] {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};
private enum LoginState {
REQUEST, CONNECTION, CRYPTION;
}
LoginState loginState = LoginState.REQUEST;
@SuppressWarnings("unused")
@Override
protected Object decode(ChannelHandlerContext chc, Channel channel, ChannelBuffer
cb) throws Exception {
switch (this.loginState) {
case REQUEST:
if (cb.readableBytes() >= 2) {
int requestType = cb.readByte() & 0xFF;
if (requestType != 14) {
World.getWorld().getLogger().info("Request type was incorrect! Found: " + requestType);
return false;
}
int nameHash = cb.readByte() & 0xFF;
channel.write(new PacketBuilder().putBytes(Login.INITIAL_RESPONSE).putLong(this.serverKey).toPacket());
this.loginState = LoginState.CONNECTION;
return true;
}
break;
case CONNECTION:
if (cb.readableBytes() >= 2) {
int connectionType = cb.readByte() & 0xFF;
if ((connectionType != 16) && (connectionType != 18)) {
World.getWorld().getLogger().info("Connection type was incorrect! Found: " + connectionType);
return false;
}
this.loginSize = cb.readByte() & 0xFF;
this.encryptedSize = this.loginSize - 40;
if (this.encryptedSize <= 0) {
World.getWorld().getLogger().info("Encrypted size was incorrect! Found: " + this.encryptedSize);
return false;
}
this.loginState = LoginState.CRYPTION;
return true;
}
break;
case CRYPTION:
if (cb.readableBytes() >= this.loginSize) {
int magicCode = cb.readByte() & 0xFF;
if (magicCode != 255) {
World.getWorld().getLogger().info("Magic ID was incorrect! Found: " + magicCode);
return false;
}
int version = cb.readShort();
if (version != 317) {
World.getWorld().getLogger().info("Client's version was incorrect! Found: " + version);
return false;
}
int memory = cb.readByte();
if (memory != 0) {
World.getWorld().getLogger().info("Memory was incorrect! Found: " + memory);
return false;
}
for (int i = 0; i < 9; i++) {
cb.readInt();
}
this.encryptedSize--;
int rsaOpcode = cb.readByte() & 0xFF;
if (this.encryptedSize != rsaOpcode) {
World.getWorld().getLogger().info("Encrypted size was incorrect! Found: " + this.encryptedSize);
return false;
}
rsaOpcode = cb.readByte() & 0xFF;
if (rsaOpcode != 10) {
World.getWorld().getLogger().info("RSA was incorrect! Found: " + rsaOpcode);
return false;
}
long clientKey = cb.readLong();
long reportedKey = cb.readLong();
if (reportedKey != this.serverKey) {
World.getWorld().getLogger().info("Reported key was incorrect! Found: " + reportedKey);
return false;
}
int uid = cb.readInt();
String name = LoginUtility.readString(cb);
if (name.startsWith("\"")) {
name = name.substring(1);
}
if (name.equals("") || (name == null)) {
World.getWorld().getLogger().info("Name was incorrect! Found: " + name);
return false;
}
String pass = LoginUtility.readString(cb);
if (pass.equals("") || (pass == null)) {
World.getWorld().getLogger().info("Pass was incorrect! Found: " + pass);
return false;
}
World.getWorld().getLogger().info("Registering player: " + name);
Player player = new Player(new Session(channel));
player.setLocation(new Location(3200, 3200, 0));
player.setName(name);
player.setPass(pass);
player.setLastLocation(player.getLocation());
World.getWorld().registerPlayer(player);
channel.write(new PacketBuilder().putByte((byte) 2).putByte((byte) 0)
.putByte((byte) 0).toPacket());
World.getWorld().getLogger().info("Sending the packets to the client.");
/** Execution.getScheduledExecutorService().scheduleAtFixedRate(new
EntityUpdate(), 0, Constants.CYCLE_TIME, TimeUnit.MILLISECONDS); */
player.getPacketSender().login();
return true;
}
break;
}
return false;
}
}
PacketSender:
Code:
package com.emulation.net.packet;
import com.emulation.model.player.Player;
import com.emulation.net.packet.Packet.Type;
public class PacketSender {
private Player player;
public PacketSender(Player player) {
this.player = player;
}
public PacketSender login() {
this.playerID().camera().interfaces().mapRegion().message("Welcome.");
return this;
}
public PacketSender playerID() {
this.player.write(new PacketBuilder(249).putByteA(1).putLEShortA(this.player
.getID()).toPacket());
return this;
}
public PacketSender camera() {
this.player.write(new PacketBuilder(107).toPacket());
return this;
}
public PacketSender interfaces() {
int[] interfaceOrder = { 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 0 };
int[] interfaces = {
3917, 638, 3213, 1644, 5608, 1151, 5065, 5715, 2449, 4445, 147, 6299,
2423
};
for (int i = 0; i < interfaceOrder.length; i++) {
this.player.write(new PacketBuilder(71).putShort(interfaces[i])
.putByteA(interfaceOrder[i]).toPacket());
}
return this;
}
public PacketSender message(String message) {
this.player.write(new PacketBuilder(253, Type.VARIABLE).putString(message)
.toPacket());
return this;
}
public PacketSender mapRegion() {
this.player.setLastLocation(this.player.getLocation());
this.player.write(new PacketBuilder(73).putShortA(this.player.getLocation()
.getRegionX() + 6).putShort(this.player.getLocation()
.getRegionY() + 6).toPacket());
return this;
}
public PacketSender logout() {
this.player.write(new PacketBuilder(109).toPacket());
return this;
}
}