Подскажите куда копать.

JuDi

Выдающийся
Участник
Сообщения
158
Розыгрыши
0
Репутация
72
Реакции
56
Баллы
1 370
Хроники
  1. The 2nd Throne: Gracia
  2. Chaotic Throne: High Five
Исходники
Присутствуют
Сборка
lostworld
Привет ребят.
Нужна помощь.
Ковыряюсь в исходниках lostworld.
Конкретнее ковыряю пакетку. Пока опкоды меняю просто, чтобы хотя бы можно было зайти персонажем.
С ХФ на ГП2 клиент.
При создании персонажа вот такая картина
25892
Я так понимаю что-то не то в пакете CharacterSelectionInfo?
Патч без изменений, только гг убил.
 
Возьмите любые фениксоподобные сурсы Part 2 как вам нужно и сверте клиент-сервер пакеты.
Вот к примеру от l2dream:

Сервер пакеты:
Код:
package Alfa.game.serverpackets;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import Alfa.Config;
import Alfa.db.DatabaseUtils;
import Alfa.db.FiltredStatement;
import Alfa.db.L2DatabaseFactory;
import Alfa.db.ThreadConnection;
import Alfa.game.model.CharSelectInfoPackage;
import Alfa.game.model.Inventory;
import Alfa.game.network.L2GameClient;
import Alfa.game.tables.CharTemplateTable;
import Alfa.game.templates.L2PlayerTemplate;
import Alfa.util.AutoBan;

public class CharacterSelectionInfo extends L2GameServerPacket
{
    // d (SdSddddddddddffdQdddddddddddddddddddddddddddddddddddddddffdddchhd)
    private static final String _S__09_CHARSELECTINFO = "[S] 09 CharSelectInfo";

    private static Logger _log = Logger.getLogger(CharacterSelectionInfo.class.getName());

    private String _loginName;

    private int _sessionId;

    private CharSelectInfoPackage[] _characterPackages;

    public CharacterSelectionInfo(String loginName, int sessionId)
    {
        _sessionId = sessionId;
        _loginName = loginName;
        _characterPackages = loadCharacterSelectInfo();
    }

    public CharSelectInfoPackage[] getCharInfo()
    {
        return _characterPackages;
    }

    @Override
    protected final void writeImpl()
    {
        int size = _characterPackages != null ? _characterPackages.length : 0;

        writeC(0x09);
        writeD(size);
        writeD(0x00);//Kamael
        writeC(0x01);//Kamael разрешает или запрещает создание игроков

        long lastAccess = 0L;
        int lastUsed = -1;
        for(int i = 0; i < size; i++)
            if(lastAccess < _characterPackages[i].getLastAccess())
            {
                lastAccess = _characterPackages[i].getLastAccess();
                lastUsed = i;
            }
        for(int i = 0; i < size; i++)
        {
            CharSelectInfoPackage charInfoPackage = _characterPackages[i];

            writeS(charInfoPackage.getName());
            writeD(charInfoPackage.getCharId()); // ?
            writeS(_loginName);
            writeD(_sessionId);
            writeD(charInfoPackage.getClanId());
            writeD(0x00); // ??

            writeD(charInfoPackage.getSex());
            writeD(charInfoPackage.getRace());
            writeD(charInfoPackage.getClassId());

            writeD(0x01); // active ??

            writeD(0x00); // x
            writeD(0x00); // y
            writeD(0x00); // z

            writeF(charInfoPackage.getCurrentHp()); // hp cur
            writeF(charInfoPackage.getCurrentMp()); // mp cur

            writeD(charInfoPackage.getSp());
            writeQ(charInfoPackage.getExp());
            writeD(charInfoPackage.getLevel());
            writeD(charInfoPackage.getKarma()); //karma

            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_UNDER));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
            if(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND) > 0)
                writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
            else
                writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
            writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR));
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            writeD(0x00);
            //writeD(5644);

            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_DHAIR));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_CHEST));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_LEGS));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_FEET));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_BACK));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_LRHAND));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
            //writeD(charInfoPackage.getPaperdollObjectId(Inventory.PAPERDOLL_FACE));

            writeD(charInfoPackage.getHairStyle());
            writeD(charInfoPackage.getHairColor());
            writeD(charInfoPackage.getFace());

            writeF(charInfoPackage.getMaxHp()); // hp max
            writeF(charInfoPackage.getMaxMp()); // mp max

            writeD(charInfoPackage.getAccessLevel() > -100 ? charInfoPackage.getDeleteTimer() : -1);
            writeD(charInfoPackage.getClassId());
            writeD(i == lastUsed ? 1 : 0);
            writeC(Math.min(charInfoPackage.getEnchantEffect(), 127));

            writeH(0x00);
            writeH(0x00);
            writeD(0x00);
        }
    }

    private CharSelectInfoPackage[] loadCharacterSelectInfo()
    {
        CharSelectInfoPackage charInfopackage;
        ArrayList<CharSelectInfoPackage> characterList = new ArrayList<CharSelectInfoPackage>();

        ThreadConnection con = null;
        FiltredStatement statement = null;
        FiltredStatement statement2 = null;
        ResultSet pl_rset = null;
        ResultSet ps_rset = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            statement = con.createStatement();
            statement2 = con.createStatement();
            pl_rset = statement.executeQuery("SELECT * FROM `characters` WHERE `account_name`='" + _loginName + "' LIMIT 7");

            while(pl_rset.next())// fills the package
            {
                ps_rset = statement2.executeQuery("SELECT * FROM `character_subclasses` WHERE `char_obj_id`='" + pl_rset.getInt("obj_Id") + "' AND `isBase`='1' LIMIT 1");
                if(!ps_rset.next())
                    throw new Exception("Missing active subclass for player " + pl_rset.getString("char_name"));
                charInfopackage = restoreChar(pl_rset, ps_rset);
                if(charInfopackage != null)
                    characterList.add(charInfopackage);
            }
        }
        catch(Exception e)
        {
            _log.log(Level.WARNING, "could not restore charinfo:", e);
        }
        finally
        {
            DatabaseUtils.closeDatabaseSR(statement2, ps_rset);
            DatabaseUtils.closeDatabaseCSR(con, statement, pl_rset);
        }

        return characterList.toArray(new CharSelectInfoPackage[characterList.size()]);
    }

    private CharSelectInfoPackage restoreChar(ResultSet chardata, ResultSet charclass)
    {
        CharSelectInfoPackage charInfopackage = null;
        try
        {
            int classid = charclass.getInt("class_id");
            boolean female = chardata.getInt("sex") == 1;
            L2PlayerTemplate templ = CharTemplateTable.getInstance().getTemplate(classid, female);
            int objectId = chardata.getInt("obj_Id");
            String name = chardata.getString("char_name");
            charInfopackage = new CharSelectInfoPackage(objectId, name);
            charInfopackage.setLevel(charclass.getInt("level"));
            charInfopackage.setMaxHp(charclass.getInt("maxHp"));
            charInfopackage.setCurrentHp(charclass.getDouble("curHp"));
            charInfopackage.setMaxMp(charclass.getInt("maxMp"));
            charInfopackage.setCurrentMp(charclass.getDouble("curMp"));

            charInfopackage.setFace(chardata.getInt("face"));
            charInfopackage.setHairStyle(chardata.getInt("hairstyle"));
            charInfopackage.setHairColor(chardata.getInt("haircolor"));
            charInfopackage.setSex(female ? 1 : 0);

            charInfopackage.setExp(charclass.getLong("exp"));
            charInfopackage.setSp(charclass.getInt("sp"));
            charInfopackage.setClanId(chardata.getInt("clanid"));

            charInfopackage.setKarma(chardata.getInt("karma"));
            charInfopackage.setRace(templ.race.ordinal());
            charInfopackage.setClassId(classid);
            long deletetime = chardata.getLong("deletetime");
            int deletedays = 0;
            if(Config.DELETE_DAYS > 0)
                if(deletetime > 0)
                {
                    deletetime = (int) (System.currentTimeMillis() / 1000 - deletetime);
                    deletedays = (int) (deletetime / 3600 / 24);
                    if(deletedays >= Config.DELETE_DAYS)
                    {
                        L2GameClient.deleteFromClan(objectId, charInfopackage.getClanId());
                        L2GameClient.deleteCharByObjId(objectId);
                        return null;
                    }
                    deletetime = Config.DELETE_DAYS * 3600 * 24 - deletetime;
                }
                else
                    deletetime = 0;
            charInfopackage.setDeleteTimer((int) deletetime);
            charInfopackage.setLastAccess(chardata.getLong("lastAccess") * 1000);
            charInfopackage.setAccessLevel(chardata.getInt("accesslevel"));

            if(charInfopackage.getAccessLevel() < 0 && !AutoBan.isBanned(objectId))
                charInfopackage.setAccessLevel(0);
        }
        catch(Exception e)
        {
            _log.log(Level.INFO, "", e);
        }

        return charInfopackage;
    }

    @Override
    public String getType()
    {
        return _S__09_CHARSELECTINFO;
    }
}
Код:
package Alfa.game.serverpackets;

import java.util.HashMap;
import java.util.logging.Logger;

import Alfa.Config;
import Alfa.game.instancemanager.CursedWeaponsManager;
import Alfa.game.model.Inventory;
import Alfa.game.model.L2Player;
import Alfa.game.model.instances.L2CubicInstance;
import Alfa.util.Location;

public class CharInfo extends L2GameServerPacket
{
    private static final Logger _log = Logger.getLogger(CharInfo.class.getName());

    private static final String _S__31_CHARINFO = "[S] 31 CharInfo";
    private L2Player _cha;
    private Inventory _inv;
    private int _mAtkSpd, _pAtkSpd;
    private int _runSpd, _walkSpd, _swimSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd;
    private float _moveMultiplier;
    private Location _loc, _fishLoc;
    private String _name, _title;
    private int _objId, _race, _sex, base_class, pvp_flag, karma, rec_have, rec_left;
    private float speed_move, speed_atack, col_radius, col_height;
    private int hair_style, hair_color, face, abnormal_effect;
    private int clan_id, clan_crest_id, large_clan_crest_id, ally_id, ally_crest_id, class_id;
    private byte _sit, _run, _combat, _dead, _invis, private_store, _enchant;
    private byte _team, _noble, _hero, _fishing, mount_type;
    private int plg_class, pledge_type, clan_rep_score, cw_level, mount_id;
    private int _nameColor, title_color, _transform, _agathion;
    private HashMap<Integer, L2CubicInstance> cubics;
    private boolean can_writeImpl = false;

    protected boolean logHandled()
    {
        return true;
    }

    public CharInfo(L2Player cha)
    {
        if(cha == null)
            return;
        _cha = cha;
    }

    @Override
    final public void runImpl()
    {
        if(_cha == null || _cha.isInvisible() || _cha.isDeleting())
            return;

        L2Player activeChar = getClient().getActiveChar();
        if(activeChar == null)
            return;

        if(activeChar.equals(_cha))
        {
            _log.severe("You cant send CharInfo about his character to active user!!!");
            return;
        }

        if(_cha.isPolymorphed())
        {
            activeChar.sendPacket(new NpcInfoPoly(_cha, activeChar));
            return;
        }

        if(_cha.isCursedWeaponEquipped())
        {
            _name = _cha.getTransformationName();
            _title = "";
            clan_id = 0;
            clan_crest_id = 0;
            ally_id = 0;
            ally_crest_id = 0;
            large_clan_crest_id = 0;
            cw_level = CursedWeaponsManager.getInstance().getLevel(_cha.getCursedWeaponEquippedId());
        }
        else
        {
            _name = _cha.getName();
            _title = _cha.getTitle();
            clan_id = _cha.getClanId();
            clan_crest_id = _cha.getClanCrestId();
            ally_id = _cha.getAllyId();
            ally_crest_id = _cha.getAllyCrestId();
            large_clan_crest_id = _cha.getClanCrestLargeId();
            cw_level = 0;
        }

        if(_cha.isMounted())
        {
            _enchant = 0;
            mount_id = _cha.getMountNpcId() + 1000000;
            mount_type = (byte) _cha.getMountType();
        }
        else
        {
            _enchant = (byte) _cha.getEnchantEffect();
            mount_id = 0;
            mount_type = 0;
        }

        _inv = _cha.getInventory();
        _mAtkSpd = _cha.getMAtkSpd();
        _pAtkSpd = _cha.getPAtkSpd();
        _moveMultiplier = _cha.getMovementSpeedMultiplier();
        _runSpd = (int) (_cha.getRunSpeed() / _moveMultiplier);
        _walkSpd = (int) (_cha.getWalkSpeed() / _moveMultiplier);
        _flRunSpd = _runSpd;
        _flWalkSpd = _walkSpd;
        _swimSpd = _cha.getSwimSpeed();
        _loc = _cha.getLoc();
        _objId = _cha.getObjectId();
        _race = _cha.getBaseTemplate().race.ordinal();
        _sex = _cha.getSex();
        base_class = _cha.getBaseClass();
        pvp_flag = _cha.getPvpFlag();
        karma = _cha.getKarma();
        speed_move = _cha.getMovementSpeedMultiplier();
        speed_atack = _cha.getAttackSpeedMultiplier();
        col_radius = _cha.getColRadius();
        col_height = _cha.getColHeight();
        hair_style = _cha.getHairStyle();
        hair_color = _cha.getHairColor();
        face = _cha.getFace();
        if(clan_id > 0 && _cha.getClan() != null)
            clan_rep_score = _cha.getClan().getReputationScore();
        else
            clan_rep_score = 0;
        _sit = _cha.isSitting() ? (byte) 0 : (byte) 1; // standing = 1 sitting = 0
        _run = _cha.isRunning() ? (byte) 1 : (byte) 0; // running = 1 walking = 0
        _combat = _cha.isInCombat() ? (byte) 1 : (byte) 0;
        _dead = _cha.isAlikeDead() ? (byte) 1 : (byte) 0;
        _invis = _cha.isInvisible() ? (byte) 1 : (byte) 0; // invisible = 1 visible = 0
        private_store = (byte) _cha.getPrivateStoreType(); // 1 - sellshop
        cubics = _cha.getCubics();
        abnormal_effect = _cha.getAbnormalEffect();
        rec_left = _cha.getRecomLeft();
        rec_have = _cha.getPlayerAccess().IsGM ? 0 : _cha.getRecomHave();
        class_id = _cha.getClassId().getId();
        _team = (byte) _cha.getTeam(); // team circle around feet 1 = Blue, 2 = red
        _noble = _cha.isNoble() ? (byte) 1 : (byte) 0; // 0x01: symbol on char menu ctrl+I
        _hero = _cha.isHero() || _cha.isGM() && Config.GM_HERO_AURA ? (byte) 1 : (byte) 0; // 0x01: Hero Aura
        _fishing = _cha.isFishing() ? (byte) 1 : (byte) 0;
        _fishLoc = _cha.getFishLoc();
        _nameColor = _cha.getNameColor(); // New C5
        plg_class = _cha.getPledgeClass();
        pledge_type = _cha.getPledgeType();
        title_color = _cha.getTitleColor();
        _transform = _cha.getTransformation();
        _agathion = _cha.getAgathion() != null ? _cha.getAgathion().getId() : 0;
        can_writeImpl = true;
    }

    @Override
    protected final void writeImpl()
    {
        if(!can_writeImpl)
            return;

        writeC(0x31);
        writeD(_loc.x);
        writeD(_loc.y);
        writeD(_loc.z);
        writeD(_loc.h); //?
        writeD(_objId);
        writeS(_name);
        writeD(_race);
        writeD(_sex);
        writeD(base_class);

        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_UNDER));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
        writeD(0x00);//writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR));
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);
        writeD(0x00);

        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        //TODO: Не совсем верная, должны быть H для аугмента.
        writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_RHAND));
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);

        writeD(pvp_flag);
        writeD(karma);

        writeD(_mAtkSpd);
        writeD(_pAtkSpd);

        writeD(pvp_flag);
        writeD(karma);

        writeD(_runSpd);
        writeD(_walkSpd);
        writeD(_swimSpd/* 0x32 */); // swimspeed
        writeD(_swimSpd/* 0x32 */); // swimspeed
        writeD(_flRunSpd);
        writeD(_flWalkSpd);
        writeD(_flyRunSpd);
        writeD(_flyWalkSpd);
        writeF(speed_move); // _cha.getProperMultiplier()
        writeF(speed_atack); // _cha.getAttackSpeedMultiplier()
        writeF(col_radius);
        writeF(col_height);
        writeD(hair_style);
        writeD(hair_color);
        writeD(face);
        writeS(_title);
        writeD(clan_id);
        writeD(clan_crest_id);
        writeD(ally_id);
        writeD(ally_crest_id);

        writeD(0);

        writeC(_sit);
        writeC(_run);
        writeC(_combat);
        writeC(_dead);
        writeC(_invis);
        writeC(mount_type); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
        writeC(private_store);

        if(cubics == null)
            writeH(0);
        else
        {
            writeH(cubics.size());
            for(int id : cubics.keySet())
                writeH(id);
        }

        writeC(0x00); // find party members
        writeD(abnormal_effect);
        writeC(rec_left);
        writeH(rec_have);
        writeD(mount_id);
        writeD(class_id);
        writeD(0); //?
        writeC(_enchant);

        writeC(_team);
        writeD(large_clan_crest_id);
        writeC(_noble);
        writeC(_hero);

        writeC(_fishing);
        writeD(_fishLoc.x);
        writeD(_fishLoc.y);
        writeD(_fishLoc.z);

        writeD(_nameColor);
        writeD(_loc.h);
        writeD(plg_class);
        writeD(pledge_type);
        writeD(title_color);
        writeD(cw_level);
        writeD(clan_rep_score);
        writeD(_transform);
        writeD(_agathion);
       
        writeD(0x00);
    }

    @Override
    public String getType()
    {
        return _S__31_CHARINFO + ": " + _cha;
    }
}
Код:
package Alfa.game.serverpackets;

import Alfa.game.GameTimeController;
import Alfa.game.model.L2Player;
import Alfa.util.Location;

public class CharSelected extends L2GameServerPacket
{
    //   SdSddddddddddffddddddddddddddddddddddddddddddddddddddddd d
    private static final String _S__0b_CHARSELECTED = "[S] 0b CharSelected";
    private int _sessionId, char_id, clan_id, sex, race, class_id;
    private String _name, _title;
    private Location _loc;
    private double curHp, curMp;
    private int _sp, level, karma, _int, _str, _con, _men, _dex, _wit;
    private long _exp;

    public CharSelected(final L2Player cha, final int sessionId)
    {
        _sessionId = sessionId;

        _name = cha.getName();
        char_id = cha.getCharId(); // ??
        _title = cha.getTitle();
        clan_id = cha.getClanId();
        sex = cha.getSex();
        race = cha.getRace().ordinal();
        class_id = cha.getClassId().getId();
        _loc = cha.getLoc();
        curHp = cha.getCurrentHp();
        curMp = cha.getCurrentMp();
        _sp = cha.getSp();
        _exp = cha.getExp();
        level = cha.getLevel();
        karma = cha.getKarma();
        _int = cha.getINT();
        _str = cha.getSTR();
        _con = cha.getCON();
        _men = cha.getMEN();
        _dex = cha.getDEX();
        _wit = cha.getWIT();
    }

    @Override
    protected final void writeImpl()
    {
        writeC(0x0b);

        writeS(_name);
        writeD(char_id);
        writeS(_title);
        writeD(_sessionId);
        writeD(clan_id);
        writeD(0x00); //??
        writeD(sex);
        writeD(race);
        writeD(class_id);
        writeD(0x01); // active ??
        writeD(_loc.x);
        writeD(_loc.y);
        writeD(_loc.z);

        writeF(curHp);
        writeF(curMp);
        writeD(_sp);
        writeQ(_exp);
        writeD(level);
        writeD(karma); //?
        writeD(0x0); //?
        writeD(_int);
        writeD(_str);
        writeD(_con);
        writeD(_men);
        writeD(_dex);
        writeD(_wit);
        for(int i = 0; i < 30; i++)
            writeD(0x00);

        writeF(0x00); //c3  work
        writeF(0x00); //c3  work
        // extra info
        writeD(GameTimeController.getInstance().getGameTime()); // in-game time
        writeD(0x00); //
        writeD(0x00); //c3
        writeC(0x00); //c3 InspectorBin
        writeH(0x00); //c3
        writeH(0x00); //c3
        writeD(0x00); //c3
        //writeD(0x00); //c3 InspectorBin for 528 client
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3
        //writeD(0x00); //c3

        //writeD(0x00); //c5
        //writeD(0x00); //c5
        //writeD(0x00); //c5
    }

    @Override
    public String getType()
    {
        return _S__0b_CHARSELECTED;
    }
}
Код:
package Alfa.game.serverpackets;

import javolution.util.FastList;

import Alfa.Config;
import Alfa.game.instancemanager.CursedWeaponsManager;
import Alfa.game.model.Inventory;
import Alfa.game.model.L2Player;
import Alfa.game.model.L2Skill;
import Alfa.game.model.PcInventory;
import Alfa.game.tables.NpcTable;
import Alfa.util.Location;

public class UserInfo extends L2GameServerPacket
{
    private static final String _S__04_USERINFO = "[S] 04 UserInfo";
    private boolean can_writeImpl = false;
    private final L2Player _cha;
    private int _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd, _relation;
    private float move_speed, attack_speed, col_radius, col_height;
    private PcInventory _inv;
    private Location _loc, _fishLoc;
    private int obj_id, _race, sex, base_class, level, curCp, maxCp, _enchant;
    private long _exp;
    private int curHp, maxHp, curMp, maxMp, curLoad, maxLoad, rec_left, rec_have;
    private int _str, _con, _dex, _int, _wit, _men, _sp, ClanPrivs, InventoryLimit;
    private int _patk, _patkspd, _pdef, evasion, accuracy, crit, _matk, _matkspd;
    private int _mdef, pvp_flag, karma, hair_style, hair_color, face, gm_commands;
    private int clan_id, clan_crest_id, ally_id, ally_crest_id, large_clan_crest_id;
    private int private_store, can_crystalize, pk_kills, pvp_kills, class_id, agathion, vitalityLevel, fame;
    private int team, AbnormalEffect, noble, hero, fishing, mount_id, cw_level;
    private int name_color, running, pledge_class, pledge_type, title_color, transformation;
    private int DefenceFire, DefenceWater, DefenceWind, DefenceEarth, DefenceHoly, DefenceUnholy;
    private byte mount_type;
    private String _name, title;
    private FastList<Integer> _cubics;
    private int[] attackElement;

    public UserInfo(L2Player cha)
    {
        _cha = cha;
    }

    @Override
    final public void runImpl()
    {
        L2Player activeChar = getClient().getActiveChar();
        if(activeChar == null)
            return;
        if(!activeChar.equals(_cha))
            return;

        if(_cha.isCursedWeaponEquipped())
        {
            _name = _cha.getTransformationName();
            clan_crest_id = 0;
            ally_crest_id = 0;
            large_clan_crest_id = 0;
            cw_level = CursedWeaponsManager.getInstance().getLevel(_cha.getCursedWeaponEquippedId());
        }
        else
        {
            _name = _cha.getName();
            clan_crest_id = _cha.getClanCrestId();
            ally_crest_id = _cha.getAllyCrestId();
            large_clan_crest_id = _cha.getClanCrestLargeId();
            cw_level = 0;
        }

        if(_cha.isMounted())
        {
            _enchant = 0;
            mount_id = _cha.getMountNpcId() + 1000000;
            mount_type = (byte) _cha.getMountType();
        }
        else
        {
            _enchant = (byte) _cha.getEnchantEffect();
            mount_id = 0;
            mount_type = 0;
        }

        move_speed = _cha.getMovementSpeedMultiplier();
        _runSpd = (int) (_cha.getRunSpeed() / move_speed);
        _walkSpd = (int) (_cha.getWalkSpeed() / move_speed);
        _flRunSpd = _flyRunSpd = _runSpd;
        _flWalkSpd = _flyWalkSpd = _walkSpd;
        _swimRunSpd = _cha.getSwimSpeed();
        _swimWalkSpd = _cha.getSwimSpeed();
        _inv = _cha.getInventory();
        _relation = _cha.isClanLeader() ? 0x40 : 0;
        if(_cha.getSiegeState() == 1)
            _relation |= 0x180;
        else if(_cha.getSiegeState() == 2)
            _relation |= 0x80;

        _loc = _cha.getLoc();
        obj_id = _cha.getObjectId();
        _race = _cha.getRace().ordinal();
        sex = _cha.getSex();
        base_class = _cha.getBaseClass();
        level = _cha.getLevel();
        _exp = _cha.getExp();
        _str = _cha.getSTR();
        _dex = _cha.getDEX();
        _con = _cha.getCON();
        _int = _cha.getINT();
        _wit = _cha.getWIT();
        _men = _cha.getMEN();
        curHp = (int) _cha.getCurrentHp();
        maxHp = _cha.getMaxHp();
        curMp = (int) _cha.getCurrentMp();
        maxMp = _cha.getMaxMp();
        curLoad = _cha.getCurrentLoad();
        maxLoad = _cha.getMaxLoad();
        _sp = _cha.getSp();
        _patk = _cha.getPAtk(null);
        _patkspd = _cha.getPAtkSpd();
        _pdef = _cha.getPDef(null);
        evasion = _cha.getEvasionRate(null);
        accuracy = _cha.getAccuracy();
        crit = _cha.getCriticalHit(null, null);
        _matk = _cha.getMAtk(null, null);
        _matkspd = _cha.getMAtkSpd();
        _mdef = _cha.getMDef(null, null);
        pvp_flag = _cha.getPvpFlag(); // 0=white, 1=purple, 2=purpleblink
        karma = _cha.getKarma();
        attack_speed = _cha.getAttackSpeedMultiplier();
        col_radius = _cha.getColRadius();
        col_height = _cha.getColHeight();
        hair_style = _cha.getHairStyle();
        hair_color = _cha.getHairColor();
        face = _cha.getFace();
        gm_commands = _cha.getPlayerAccess().IsGM || _cha.getPlayerAccess().UseGMComand || Config.ALLOW_SPECIAL_COMMANDS ? 1 : 0;
        // builder level активирует в клиенте админские команды
        title = _cha.getTitle();
        if(_cha.isInvisible())
            title = "Invisible";
        if(_cha.isPolymorphed())
            title += " - " + NpcTable.getTemplate(_cha.getPolyid()).name;
        clan_id = _cha.getClanId();
        ally_id = _cha.getAllyId();
        private_store = _cha.getPrivateStoreType();
        can_crystalize = _cha.getSkillLevel(L2Skill.SKILL_CRYSTALLIZE) > 0 ? 1 : 0;
        pk_kills = _cha.getPkKills();
        pvp_kills = _cha.getPvpKills();
        _cubics = new FastList<Integer>();
        for(int id : _cha.getCubics().keySet())
            _cubics.add(id);
        AbnormalEffect = _cha.getAbnormalEffect();
        ClanPrivs = _cha.getClanPrivileges();
        rec_left = _cha.getRecomLeft(); //c2 recommendations remaining
        rec_have = _cha.getPlayerAccess().IsGM ? 0 : _cha.getRecomHave(); //c2 recommendations received
        InventoryLimit = _cha.getInventoryLimit();
        class_id = _cha.getClassId().getId();
        maxCp = _cha.getMaxCp();
        curCp = (int) _cha.getCurrentCp();
        team = _cha.getTeam(); //team circle around feet 1= Blue, 2 = red
        noble = _cha.isNoble() || _cha.isGM() && Config.GM_HERO_AURA ? 1 : 0; //0x01: symbol on char menu ctrl+I
        hero = _cha.isHero() || _cha.isGM() && Config.GM_HERO_AURA ? 1 : 0; //0x01: Hero Aura and symbol
        fishing = _cha.isFishing() ? 1 : 0; // Fishing Mode
        _fishLoc = _cha.getFishLoc();
        name_color = _cha.getNameColor();
        running = _cha.isRunning() ? 0x01 : 0x00; //changes the Speed display on Status Window
        pledge_class = _cha.getPledgeClass();
        pledge_type = _cha.getPledgeType();
        title_color = _cha.getTitleColor();
        transformation = _cha.getTransformation();
        attackElement = _cha.getAttackElement();
        DefenceFire = _cha.getDefenceFire();
        DefenceWater = _cha.getDefenceWater();
        DefenceWind = _cha.getDefenceWind();
        DefenceEarth = _cha.getDefenceEarth();
        DefenceHoly = _cha.getDefenceHoly();
        DefenceUnholy = _cha.getDefenceUnholy();
        agathion = _cha.getAgathion() != null ? _cha.getAgathion().getId() : 0; //агнишен
        vitalityLevel = _cha.getVitalityLevel();
        fame = _cha.getFame();
       
        _cha.refreshSavedStats();
        if(_cha.isMounted())
            getClient().sendPacket(new Ride(_cha));

        can_writeImpl = true;
    }

    @Override
    protected final void writeImpl()
    {
        if(!can_writeImpl)
            return;

        writeC(0x32);

        writeD(_loc.x);
        writeD(_loc.y);
        writeD(_loc.z);
        writeD(_loc.h < 7 ? 7 : _loc.h / 7 * 7); // мальенькая хитрость препятствующая использованию патча на других серверах
        writeD(obj_id);
        writeS(_name);
        writeD(_race);
        writeD(sex);
        writeD(base_class);
        writeD(level);
        writeQ(_exp);
        writeD(_str);
        writeD(_dex);
        writeD(_con);
        writeD(_int);
        writeD(_wit);
        writeD(_men);
        writeD(maxHp);
        writeD(curHp);
        writeD(maxMp);
        writeD(curMp);
        writeD(_sp);
        writeD(curLoad);
        writeD(maxLoad);
        writeD(0x28); // unknown. В снифе бывает 0х28 и 0х14
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_UNDER));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_CHEST));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LEGS));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_FEET));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
        writeD(0);//writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LRHAND));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DHAIR));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RBRACELET));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LBRACELET));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[0]));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[1]));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[2]));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[3]));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[4]));
        writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[5]));

        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_UNDER));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
        writeD(0);//writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[0]));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[1]));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[2]));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[3]));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[4]));
        writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[5]));

        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        //TODO: Не совсем верная, должны быть H для аугмента.
        writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_RHAND));
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeH(0x00);
        writeD(_patk);
        writeD(_patkspd);
        writeD(_pdef);
        writeD(evasion);
        writeD(accuracy);
        writeD(crit);
        writeD(_matk);
        writeD(_matkspd);
        writeD(_patkspd);
        writeD(_mdef);
        writeD(pvp_flag);
        writeD(karma);
        writeD(_runSpd);
        writeD(_walkSpd);
        writeD(_swimRunSpd); // swimspeed
        writeD(_swimWalkSpd); // swimspeed
        writeD(_flRunSpd);
        writeD(_flWalkSpd);
        writeD(_flyRunSpd);
        writeD(_flyWalkSpd);
        writeF(move_speed);
        writeF(attack_speed);
        writeF(col_radius);
        writeF(col_height);
        writeD(hair_style);
        writeD(hair_color);
        writeD(face);
        writeD(gm_commands);
        writeS(title);
        writeD(clan_id);
        writeD(clan_crest_id);
        writeD(ally_id);
        writeD(ally_crest_id);
        // 0x40 leader rights
        // siege flags: attacker - 0x180 sword over name, defender - 0x80 shield, 0xC0 crown (|leader), 0x1C0 flag (|leader)
        writeD(_relation);
        writeC(mount_type); // mount type
        writeC(private_store);
        writeC(can_crystalize);
        writeD(pk_kills);
        writeD(pvp_kills);
        writeH(_cubics.size());
        while(_cubics.size() > 0)
            writeH(_cubics.removeFirst());
        writeC(0x00); //1-find party members
        writeD(AbnormalEffect);
        writeC(0x11);
        writeD(ClanPrivs);
        writeH(rec_left);
        writeH(rec_have);
        writeD(mount_id);
        writeH(InventoryLimit);
        writeD(class_id);
        writeD(0x00); // special effects? circles around player...
        writeD(maxCp);
        writeD(curCp);
        writeC(_enchant);
        writeC(team);
        writeD(large_clan_crest_id);
        writeC(noble);
        writeC(hero);
        writeC(fishing);
        writeD(_fishLoc.x);
        writeD(_fishLoc.y);
        writeD(_fishLoc.z);
        writeD(name_color);
        writeC(running);
        writeD(pledge_class);
        writeD(pledge_type);
        writeD(title_color);
        writeD(cw_level);
        writeD(transformation); // Transformation id
        // AttackElement (0 - Fire, 1 - Water, 2 - Wind, 3 - Earth, 4 - Holy, 5 - Dark, -2 - None)
        writeD(attackElement == null ? -2 : attackElement[0]);
        writeD(attackElement == null ? 0 : attackElement[1]); // AttackElementValue
        writeD(DefenceFire); // DefAttrFire
        writeD(DefenceWater); // DefAttrWater
        writeD(DefenceWind); // DefAttrWind
        writeD(DefenceEarth); // DefAttrEarth
        writeD(DefenceHoly); // DefAttrHoly
        writeD(DefenceUnholy); // DefAttrUnholy
        writeD(agathion);
       
        writeD(fame);  // Fame
        writeD(0x00); // Unknown
        writeD(vitalityLevel);  // Vitality Level
    }

    @Override
    public String getType()
    {
        return _S__04_USERINFO;
    }
}

А вот клиент пакеты:
Код:
package Alfa.game.clientpackets;

import Alfa.game.model.L2Player;
import Alfa.game.network.L2GameClient;
import Alfa.game.network.L2GameClient.GameClientState;
import Alfa.game.serverpackets.CharSelected;
import Alfa.game.serverpackets.SSQInfo;
import Alfa.util.AutoBan;

public class CharacterSelected extends L2GameClientPacket
{
    private static String _C__12_CHARACTERSELECTED = "[C] 12 CharacterSelected";
    private int _charSlot;

    /**
     * @param decrypt
     * Format: cdhddd
     */
    @Override
    public void readImpl()
    {
        _charSlot = readD();
    }

    @Override
    public void runImpl()
    {
        L2GameClient client = getClient();

        if(client.getActiveChar() != null)
            return;

        L2Player activeChar = client.loadCharFromDisk(_charSlot);
        if(activeChar == null)
            return;

        if(AutoBan.isBanned(activeChar.getObjectId()))
            return;

        if(activeChar.getAccessLevel() < 0)
            activeChar.setAccessLevel(0);

        client.setState(GameClientState.IN_GAME);

        sendPacket(new SSQInfo());

        sendPacket(new CharSelected(activeChar, client.getSessionId().playOkID1));
    }

    @Override
    public String getType()
    {
        return _C__12_CHARACTERSELECTED;
    }
}
Код:
package Alfa.game.clientpackets;

import static Alfa.game.model.L2Zone.ZoneType.no_restart;

import java.io.File;
import java.sql.ResultSet;
import java.util.logging.Logger;

import Alfa.Config;
import Alfa.db.DatabaseUtils;
import Alfa.db.FiltredPreparedStatement;
import Alfa.db.L2DatabaseFactory;
import Alfa.db.ThreadConnection;
import Alfa.ext.multilang.CustomMessage;
import Alfa.ext.scripts.Scripts;
import Alfa.game.Announcements;
import Alfa.game.GameTimeController;
import Alfa.game.cache.Msg;
import Alfa.game.instancemanager.CastleManager;
import Alfa.game.instancemanager.CoupleManager;
import Alfa.game.instancemanager.CursedWeaponsManager;
import Alfa.game.instancemanager.DimensionalRiftManager;
import Alfa.game.instancemanager.QuestManager;
import Alfa.game.instancemanager.SiegeManager;
import Alfa.game.instancemanager.PlayerMessageStack;
import Alfa.game.model.L2Clan;
import Alfa.game.model.L2Player;
import Alfa.game.model.L2World;
import Alfa.game.model.L2Zone.ZoneType;
import Alfa.game.model.entity.SevenSigns;
import Alfa.game.model.entity.siege.Siege;
import Alfa.game.model.entity.siege.SiegeUnit;
import Alfa.game.model.quest.Quest;
import Alfa.game.serverpackets.ChangeWaitType;
import Alfa.game.serverpackets.ClientSetTime;
import Alfa.game.serverpackets.Die;
import Alfa.game.serverpackets.EtcStatusUpdate;
import Alfa.game.serverpackets.ExBasicActionList;
import Alfa.game.serverpackets.ExPCCafePointInfo;
import Alfa.game.serverpackets.ExStorageMaxCount;
import Alfa.game.serverpackets.HennaInfo;
import Alfa.game.serverpackets.ItemList;
import Alfa.game.serverpackets.L2FriendList;
import Alfa.game.serverpackets.L2FriendStatus;
import Alfa.game.serverpackets.NpcHtmlMessage;
import Alfa.game.serverpackets.PledgeShowInfoUpdate;
import Alfa.game.serverpackets.PledgeShowMemberListAll;
import Alfa.game.serverpackets.PledgeShowMemberListUpdate;
import Alfa.game.serverpackets.PledgeSkillList;
import Alfa.game.serverpackets.PrivateStoreMsgBuy;
import Alfa.game.serverpackets.PrivateStoreMsgSell;
import Alfa.game.serverpackets.QuestList;
import Alfa.game.serverpackets.RecipeShopMsg;
import Alfa.game.serverpackets.ShortCutInit;
import Alfa.game.serverpackets.SkillList;
import Alfa.game.serverpackets.SystemMessage;
import Alfa.game.serverpackets.UserInfo;
import Alfa.game.tables.MapRegionTable;
import Alfa.game.tables.SkillTable;
import Alfa.util.Log;

/**
* Enter World Packet Handler<p>
* <p>
* 0000: 11 <p>
*/
public class EnterWorld extends L2GameClientPacket
{
    private static String _C__11_ENTERWORLD = "[C] 11 EnterWorld";
    //Format1(EnterWorldPacket): cbddddbdcccccccccccccccccccc
    //Format2(EnterWorld): cS
    private static Logger _log = Logger.getLogger(EnterWorld.class.getName());

    @Override
    public void readImpl()
    {}

    @Override
    public void runImpl()
    {
        L2Player activeChar = getClient().getActiveChar();

        if(activeChar == null)
        {
            getClient().closeNow(false);
            return;
        }

        if(activeChar != null)
            if(Config.SHOW_COPYRIGHT)
                activeChar.sendMessage("Developed by Alfa Team");
       
        if(activeChar.isGM() && !Config.SHOW_GM_LOGIN)
            activeChar.setInvisible(true);

        activeChar.spawnMe();
        activeChar.updateTerritories();
       
        // Restore Vitality
        if (Config.RECOVER_VITALITY_ON_RECONNECT)
            activeChar.restoreVitality();

        /*
         * TODO SignsSky в Kamael заменен пакетом SSQInfo
         * if(SevenSigns.getInstance().isSealValidationPeriod())
         *    activeChar.sendPacket(new SignsSky());
         */

        //sendPacket(new UserInfo(activeChar));
        sendPacket(new HennaInfo(activeChar));
        sendPacket(new ItemList(activeChar, false));
        sendPacket(new ShortCutInit(activeChar));
        activeChar.getMacroses().sendUpdate();
        sendPacket(new ClientSetTime());
        if(Config.DAY_STATUS_FORCE_CLIENT_UPDATE)
            if(GameTimeController.getInstance().isNowNight())
                sendPacket(Msg.SunSet);
            else
                sendPacket(Msg.SunRise);
        sendPacket(new SkillList(activeChar));
        sendPacket(new SystemMessage(SystemMessage.WELCOME_TO_THE_WORLD_OF_LINEAGE_II));
        Announcements.getInstance().showAnnouncements(activeChar);

        //add char to online characters
        activeChar.setOnlineStatus(true);

        // Вызов всех хэндлеров, определенных в скриптах
        for(String handler : Scripts.onPlayerEnter)
        {
            String[] list = handler.split(":");
            String _class = list[0];
            String _method = list[1];
            activeChar.callScripts(_class, _method, new Object[] { activeChar });
        }

        SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);

        // send user info again .. just like the real client
        // sendPacket(new UserInfo(activeChar));

        if(activeChar.getClanId() != 0 && activeChar.getClan() != null)
        {
            notifyClanMembers(activeChar);
            sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
            sendPacket(new PledgeShowInfoUpdate(activeChar.getClan()));
            sendPacket(new PledgeSkillList(activeChar.getClan()));

            for(SiegeUnit castle : CastleManager.getInstance().getCastles().values())
            {
                Siege siege = castle.getSiege();
                if(!siege.isInProgress())
                    continue;
                if(siege.checkIsAttacker(activeChar.getClan()))
                    activeChar.setSiegeState(1);
                else if(siege.checkIsDefender(activeChar.getClan()))
                    activeChar.setSiegeState(2);
            }
        }

        // engage and notify Partner
        if(Config.ALLOW_WEDDING)
        {
            CoupleManager.getInstance().engage(activeChar);
            CoupleManager.getInstance().notifyPartner(activeChar);
        }

        Log.LogChar(activeChar, Log.EnterWorld, "");

        notifyFriends(activeChar, true);

        loadTutorial(activeChar);

        sendPacket(new ExStorageMaxCount(activeChar));
        sendPacket(new QuestList(activeChar));
        if(activeChar.isTransformed())
            sendPacket(ExBasicActionList.TRANSFORMED_ACTION_LIST);
        else
            sendPacket(ExBasicActionList.DEFAULT_ACTION_LIST);

        if(Config.ENABLE_OLYMPIAD && activeChar.isInZoneOlympiad())
        {
            activeChar.sendMessage(new CustomMessage("Alfa.game.clientpackets.EnterWorld.TeleportedReasonOlympiad", activeChar));
            activeChar.teleToLocation(MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClosestTown));
        }

        if(activeChar.isInZoneIncludeZ(no_restart))
        {
            long allowed_time = activeChar.getZone(no_restart).getRestartTime();
            long last_time = activeChar.getLastAccess();
            long curr_time = System.currentTimeMillis() / 1000;

            if(curr_time - last_time > allowed_time)
            {
                activeChar.sendMessage(new CustomMessage("Alfa.game.clientpackets.EnterWorld.TeleportedReasonNoRestart", activeChar));
                activeChar.teleToLocation(MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClosestTown));
            }
        }

        if(!activeChar.isGM() && activeChar.isInZone(ZoneType.Siege))
        {
            Siege siege = SiegeManager.getSiege(activeChar.getX(), activeChar.getY());
            if(siege != null && !siege.checkIsDefender(activeChar.getClan()))
                if(siege.getHeadquarter(activeChar.getClan()) == null)
                    activeChar.teleToLocation(MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClosestTown));
                else
                    activeChar.teleToLocation(MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Headquarter));
        }

        if(activeChar.isDead())
        {
            sendPacket(new UserInfo(activeChar));
            // no broadcast needed since the player will already spawn dead to others
            sendPacket(new Die(activeChar));
        }

        // activeChar.broadcastUserInfo(); уже шлется в restoreEffects()
        activeChar.restoreEffects();
        activeChar.restoreDisableSkills();

        CursedWeaponsManager.getInstance().checkPlayer(activeChar);

        // refresh player info
        sendPacket(new EtcStatusUpdate(activeChar));
        //activeChar.getInventory().refreshListeners();
        activeChar.checkHpMessages(activeChar.getMaxHp(), activeChar.getCurrentHp());
        activeChar.checkDayNightMessages();

        if(DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getLoc(), false))
            DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);

        sendPacket(new ExPCCafePointInfo(activeChar));

        if(Config.SHOW_HTML_WELCOME)
        {
            String welcomePath = "data/html/welcome/index.htm";
            File mainText = new File(Config.DATAPACK_ROOT, welcomePath); // Return the pathfile of the HTML file
            if(mainText.exists())
            {
                NpcHtmlMessage html = new NpcHtmlMessage(1);
                html.setFile(welcomePath);
                sendPacket(html);
            }
        }

        if(activeChar.isSitting())
            activeChar.sendPacket(new ChangeWaitType(activeChar, ChangeWaitType.WT_SITTING));
        if(activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
            if(activeChar.getPrivateStoreType() == L2Player.STORE_PRIVATE_BUY)
                sendPacket(new PrivateStoreMsgBuy(activeChar));
            else if(activeChar.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL || activeChar.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL_PACKAGE)
                sendPacket(new PrivateStoreMsgSell(activeChar));
            else if(activeChar.getPrivateStoreType() == L2Player.STORE_PRIVATE_MANUFACTURE)
                sendPacket(new RecipeShopMsg(activeChar));

        activeChar.unsetVar("offline");

        // на всякий случай
        activeChar.sendActionFailed();

        if(activeChar.isGM() && Config.SAVE_GM_EFFECTS && activeChar.getPlayerAccess().UseGMComand)
        {
            //silence
            if(activeChar.getVarB("gm_silence"))
            {
                activeChar.setMessageRefusal(true);
                activeChar.sendPacket(new SystemMessage(SystemMessage.MESSAGE_REFUSAL_MODE));
            }
            //invul
            if(activeChar.getVarB("gm_invul"))
            {
                activeChar.setIsInvul(true);
                activeChar.sendMessage(activeChar.getName() + " is now immortal.");
            }
            //gmspeed
            try
            {
                int var_gmspeed = Integer.parseInt(activeChar.getVar("gm_gmspeed"));
                if(var_gmspeed >= 1 && var_gmspeed <= 4)
                    activeChar.doCast(SkillTable.getInstance().getInfo(7029, var_gmspeed), activeChar, true);
            }
            catch(Exception E)
            {}
        }

        PlayerMessageStack.getInstance().CheckMessages(activeChar);
    }

    public static void notifyFriends(L2Player cha, boolean login)
    {
        if(login)
            cha.sendPacket(new L2FriendList(cha, false));
        ThreadConnection con = null;
        FiltredPreparedStatement statement = null;
        ResultSet rset = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            statement = con.prepareStatement("SELECT friend_id from character_friends where char_id=?");
            statement.setInt(1, cha.getObjectId());
            rset = statement.executeQuery();
            while(rset.next())
            {
                int objectId = rset.getInt("friend_id");
                L2Player friend = (L2Player) L2World.findObject(objectId);
                if(friend != null)
                    if(login)
                    {
                        friend.sendPacket(new SystemMessage(SystemMessage.S1_FRIEND_HAS_LOGGED_IN).addString(cha.getName()));
                        friend.sendPacket(new L2FriendStatus(cha, true));
                    }
                    else
                    {
                        friend.sendPacket(new L2FriendStatus(cha, false));
                        cha.sendPacket(new L2FriendList(cha, false));
                    }
            }
        }
        catch(Exception e)
        {
            _log.warning("could not restore friend data:" + e);
        }
        finally
        {
            DatabaseUtils.closeDatabaseCSR(con, statement, rset);
        }
    }

    /**
     * @param activeChar
     */
    private void notifyClanMembers(L2Player activeChar)
    {
        L2Clan clan = activeChar.getClan();
        if(clan == null || clan.getClanMember(activeChar.getObjectId()) == null)
            return;

        clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
        //if(activeChar.isClanLeader())
        //{
        //    if(activeChar.getClan().getHasHideout() != 0 && ClanHallManager.getInstance().getClanHall(activeChar.getClan().getHasHideout()).getNotPaid())
        //        activeChar.sendPacket(new SystemMessage(SystemMessage.THE_CLAN_HALL_FEE_IS_ONE_WEEK_OVERDUE_THEREFORE_THE_CLAN_HALL_OWNERSHIP_HAS_BEEN_REVOKED));
        //}

        int sponsor = activeChar.getSponsor();
        int apprentice = activeChar.getApprentice();
        SystemMessage msg = new SystemMessage(SystemMessage.CLAN_MEMBER_S1_HAS_LOGGED_INTO_GAME).addString(activeChar.getName());
        PledgeShowMemberListUpdate memberUpdate = new PledgeShowMemberListUpdate(activeChar);
        for(L2Player clanMember : clan.getOnlineMembers(activeChar.getName()))
        {
            clanMember.sendPacket(memberUpdate);
            if(clanMember.getObjectId() == sponsor)
                clanMember.sendPacket(new SystemMessage(SystemMessage.S1_YOUR_CLAN_ACADEMYS_APPRENTICE_HAS_LOGGED_IN).addString(activeChar.getName()));
            else if(clanMember.getObjectId() == apprentice)
                clanMember.sendPacket(new SystemMessage(SystemMessage.S1_YOUR_CLAN_ACADEMYS_SPONSOR_HAS_LOGGED_IN).addString(activeChar.getName()));
            else
                clanMember.sendPacket(msg);
        }
    }

    private void loadTutorial(L2Player player)
    {
        Quest q = QuestManager.getQuest(255);
        if(q != null)
            player.processQuestEvent(q.getName(), "UC");
    }

    @Override
    public String getType()
    {
        return _C__11_ENTERWORLD;
    }
}

Авось сгодится.
 
  • Мне нравится
Реакции: JuDi
Назад
Сверху Снизу