// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov Date: 13.11.2015 15:46:45
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: CharacterCreate.java
package net.sf.l2j.gameserver.network.clientpackets;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import java.util.regex.*;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.LoginServerThread;
import net.sf.l2j.gameserver.datatables.*;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.QuestManager;
import net.sf.l2j.gameserver.model.*;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.*;
import net.sf.l2j.gameserver.templates.L2PcTemplate;
import net.sf.l2j.gameserver.util.Util;
import org.mmocore.network.MMOConnection;
// Referenced classes of package net.sf.l2j.gameserver.network.clientpackets:
// L2GameClientPacket
public final class CharacterCreate extends L2GameClientPacket
{
public CharacterCreate()
{
}
protected void readImpl()
{
_name = readS();
_race = readD();
_sex = (byte)readD();
_classId = readD();
_int = readD();
_str = readD();
_con = readD();
_men = readD();
_dex = readD();
_wit = readD();
_hairStyle = (byte)readD();
_hairColor = (byte)readD();
_face = (byte)readD();
}
protected void runImpl()
{
if(CharNameTable.getInstance().accountCharNumber(((L2GameClient)getClient()).getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT && Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0)
{
if(Config.DEBUG)
_log.fine("Max number of characters reached. Creation failed.");
CharCreateFail ccf = new CharCreateFail(1);
sendPacket(ccf);
return;
}
if(CharNameTable.getInstance().doesCharNameExist(_name))
{
if(Config.DEBUG)
_log.fine((new StringBuilder()).append("charname: ").append(_name).append(" already exists. creation failed.").toString());
CharCreateFail ccf = new CharCreateFail(2);
sendPacket(ccf);
return;
}
if(_name.length() < 3 || _name.length() > 16 || !Util.isAlphaNumeric(_name) || !isValidName(_name))
{
if(Config.DEBUG)
_log.fine((new StringBuilder()).append("charname: ").append(_name).append(" is invalid. creation failed.").toString());
CharCreateFail ccf = new CharCreateFail(3);
sendPacket(ccf);
return;
}
L2PcTemplate template = CharTemplateTable.getInstance().getTemplate(_classId);
if(Config.DEBUG)
_log.fine((new StringBuilder()).append("charname: ").append(_name).append(" classId: ").append(_classId).append(" template: ").append(template).toString());
if(template == null || template.classBaseLevel > 1)
{
CharCreateFail ccf = new CharCreateFail(0);
sendPacket(ccf);
return;
} else
{
int objectId = IdFactory.getInstance().getNextId();
L2PcInstance newChar = L2PcInstance.create(objectId, template, ((L2GameClient)getClient()).getAccountName(), _name, _hairStyle, _hairColor, _face, _sex != 0);
newChar.setCurrentHp(template.baseHpMax);
newChar.setCurrentCp(template.baseCpMax);
newChar.setCurrentMp(template.baseMpMax);
CharCreateOk cco = new CharCreateOk();
sendPacket(cco);
initNewChar((L2GameClient)getClient(), newChar);
return;
}
}
private boolean isValidName(String text)
{
boolean result = true;
String test = text;
Pattern pattern;
try
{
pattern = Pattern.compile(Config.CNAME_TEMPLATE);
}
catch(PatternSyntaxException e)
{
_log.warning("ERROR : Character name pattern of config is wrong!");
pattern = Pattern.compile(".*");
}
Matcher regexp = pattern.matcher(test);
if(!regexp.matches())
result = false;
return result;
}
private void initNewChar(L2GameClient client, L2PcInstance newChar)
{
if(Config.DEBUG)
_log.fine("Character init start");
L2World.getInstance().storeObject(newChar);
L2PcTemplate template = newChar.getTemplate();
newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
newChar.setTitle("");
L2ShortCut shortcut = new L2ShortCut(0, 0, 3, 2, -1, 1);
newChar.registerShortCut(shortcut);
shortcut = new L2ShortCut(3, 0, 3, 5, -1, 1);
newChar.registerShortCut(shortcut);
shortcut = new L2ShortCut(10, 0, 3, 0, -1, 1);
newChar.registerShortCut(shortcut);
Iterator i$ = template.getItems().iterator();
do
{
if(!i$.hasNext())
break;
net.sf.l2j.gameserver.templates.L2PcTemplate.PcTemplateItem ia = (net.sf.l2j.gameserver.templates.L2PcTemplate.PcTemplateItem)i$.next();
L2ItemInstance item = newChar.getInventory().addItem("Init", ia.getItemId(), ia.getAmount(), newChar, null);
if(item.getItemId() == 5588)
{
shortcut = new L2ShortCut(11, 0, 1, item.getObjectId(), -1, 1);
newChar.registerShortCut(shortcut);
}
if(item.isEquipable() && ia.isEquipped())
newChar.getInventory().equipItemAndRecord(item);
} while(true);
L2SkillLearn arr$[] = SkillTreeTable.getInstance().getAvailableSkills(newChar, newChar.getClassId());
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2SkillLearn skill = arr$[i$];
newChar.addSkill(SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()), true);
if(skill.getId() == 1001 || skill.getId() == 1177)
{
shortcut = new L2ShortCut(1, 0, 2, skill.getId(), 1, 1);
newChar.registerShortCut(shortcut);
}
if(skill.getId() == 1216)
{
shortcut = new L2ShortCut(10, 0, 2, skill.getId(), 1, 1);
newChar.registerShortCut(shortcut);
}
if(Config.DEBUG)
_log.fine((new StringBuilder()).append("adding starter skill:").append(skill.getId()).append(" / ").append(skill.getLevel()).toString());
}
startTutorialQuest(newChar);
L2GameClient.saveCharToDisk(newChar);
newChar.deleteMe();
CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);
client.getConnection().sendPacket(cl);
client.setCharSelection(cl.getCharInfo());
if(Config.DEBUG)
_log.fine("Character init end");
}
public void startTutorialQuest(L2PcInstance player)
{
QuestState qs = player.getQuestState("255_Tutorial");
Quest q = null;
if(qs == null)
q = QuestManager.getInstance().getQuest("255_Tutorial");
if(q != null)
q.newQuestState(player);
}
public String getType()
{
return "[C] 0B CharacterCreate";
}
private static final String _C__0B_CHARACTERCREATE = "[C] 0B CharacterCreate";
private static Logger _log = Logger.getLogger(net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.getName());
private String _name;
private int _race;
private byte _sex;
private int _classId;
private int _int;
private int _str;
private int _con;
private int _men;
private int _dex;
private int _wit;
private byte _hairStyle;
private byte _hairColor;
private byte _face;
}
Содержимое какой таблицы? Не совсем понял -(