}
@Override
public void handlePacket(ChannelHandlerContext ctx, P1280_VerifyClient packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
// Try to find accepted player data using the security keys
LoginServerPlayerData foundPlayerData = GameServer.findPlayerDataBySecurityKeys(packet.getKey1(), packet.getKey2());
if (foundPlayerData == null) {
LOGGER.warn("No PlayerData found");
return;
}
LOGGER.info("Searching for map with id: {}", foundPlayerData.getMapId());
// Retrieve the map that will be loaded
// TODO: pass instances, don't start using static things everywhere!
MapData map = GameServer.getMap((int) foundPlayerData.getMapId());
// Convert the security keys to the right format.... again
// TODO: decide on 1 format!!
short[] keys1 = foundPlayerData.getSecurityKey1();
short[] keys2 = foundPlayerData.getSecurityKey2();
byte[] newKeys1 = new byte[keys1.length], newKeys2 = new byte[keys2.length];
for (int i = 0; i < keys1.length; i++) {
newKeys1[i] = (byte) (keys1[i]);
newKeys2[i] = (byte) (keys2[i]);
}
// Set some data we're probably going to need later on...
serverData.setAccId((int) foundPlayerData.getAccId());
// TODO: set the client security keys again later on when needed!
// serverData.getSecurityKeys()[0] = newKeys1;
// serverData.getSecurityKeys()[1] = newKeys2;
serverData.setAccId((int) foundPlayerData.getAccId());
// Load the character on the map
// TODO: how do we share maps between teams? We're not going to have all chars on the same map, right??
CharacterData addedCharacter = loadCharacterById(packet, (int) foundPlayerData.getCharId(), serverData, map);
serverData.setCurrentCharacter(addedCharacter);
// add this Player to the map by adding its clientdata!
//map.addPlayer(clientData); //FIXME: this was commented as the player will be in the general group already and this should be changed to have a group per map/district