serverData.setMap(map);
}
private CharacterData loadCharacterById(P1280_VerifyClient packet, int charId, GameServerSession playerData, MapData map) {
Character character = this.getCharacterByCharId(charId);
if (character == null) {
return null;
}
// We found the character, load its data
ByteBuf appearance = Unpooled.buffer(24);
appearance = appearance.order(ByteOrder.LITTLE_ENDIAN);
byte professionPrimary = character.getProfessionprimary();
byte professionSecondary = character.getProfessionSecondary();
int level = character.getLevel();
int skillPointsFree = character.getSkillPointsFree();
int skillPointsTotal = character.getSkillPointsTotal();
int attrPtsFree = character.getAttributePointsFree();
int attrPtsTotal = character.getAttributePointsTotal();
appearance.writeByte((character.getLookHeight() << 4) | (character.getLookSex()));
appearance.writeByte((character.getLookHairColor() << 4) | (character.getLookSkinColor()));
appearance.writeByte((professionPrimary << 4) | (character.getLookHairStyle()));
appearance.writeByte((character.getLookCampaign() << 4) | (character.getLookSex()));
String charName = character.getCharName();
// Get spawn point (random from the list of spawn points (zero-based)
Random r = new Random();
int chosenSpawnPointIndex = r.nextInt(map.getPossibleSpawns().size());
GWVector chosenSpwwnPoint = map.getPossibleSpawns().get(chosenSpawnPointIndex);
if (!map.isIsPve() && playerData.getTeamNumber() < map.getPossibleSpawns().size()) {
chosenSpwwnPoint = map.getPossibleSpawns().get(playerData.getTeamNumber());
}
Account account = this.getAccountByAccountId(playerData.getAccId());
if (account == null) {
return null;
}
int groupId = account.getGroupId();
Group group = this.getGroupByGroupId(groupId);
if (group == null) {
return null;
}
String groupPrefix = group.getGroupPrefix();
byte groupChatColor = group.getGroupChatColor();
CharacterData characterData = new CharacterData();
characterData.setCharID(charId);
characterData.setName(charName);
characterData.setGameFileID(map.getGameFileID());
characterData.setGameMapID(map.getGameMapID());
characterData.setIsOutpost(map.isIsOutpost());
characterData.setProfessionPrimary(professionPrimary);
characterData.setProfessionSecondary(professionSecondary);
characterData.setLevel(level);
characterData.setMorale(100);
characterData.setHealth(12345);
characterData.setEnergy(1337);
byte[] skillBar = character.getSkillBar();
byte[] skillsUnlocked = character.getSkillsAvailable();
characterData.setAttPtsFree(attrPtsFree);
characterData.setAttPtsTotal(attrPtsTotal);
characterData.setAppearance(appearance.array());