1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 01:40:53 -03:00
parent 9bb83652e4
commit 2c4af6d91d
263 changed files with 2135 additions and 663 deletions

View File

@@ -261,6 +261,8 @@ public class Lineage2Connection {
.iterable(new CharacterBroadcastFilter(characterID.getObject()))) {
final Lineage2Connection conn = networkService.discover(character
.getID());
if(conn == null)
continue;
futures.add(conn.write(packet));
}
return futures;

View File

@@ -28,8 +28,10 @@ import com.google.inject.Injector;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.ClientPacket;
import com.l2jserver.game.net.packet.client.AuthLoginPacket;
import com.l2jserver.game.net.packet.client.CharacterActionPacket;
import com.l2jserver.game.net.packet.client.CharacterChatMessagePacket;
import com.l2jserver.game.net.packet.client.CharacterCreatePacket;
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
import com.l2jserver.game.net.packet.client.CharacterSelectPacket;
import com.l2jserver.game.net.packet.client.CharacterValidatePositionPacket;
import com.l2jserver.game.net.packet.client.EnterWorld;
@@ -40,7 +42,6 @@ import com.l2jserver.game.net.packet.client.RequestCharacterTemplatesPacket;
import com.l2jserver.game.net.packet.client.RequestGotoLobbyPacket;
import com.l2jserver.game.net.packet.client.RequestKeyMappingPacket;
import com.l2jserver.game.net.packet.client.RequestManorListPacket;
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
import com.l2jserver.game.net.packet.client.RequestRestartPacket;
/**
@@ -160,6 +161,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
return CharacterValidatePositionPacket.class;
case EnterWorld.OPCODE:
return EnterWorld.class;
case CharacterActionPacket.OPCODE:
return CharacterActionPacket.class;
default:
logger.warn("Unknown opcode: 0x{}", Integer.toHexString(opcode));
break;

View File

@@ -27,7 +27,7 @@ import com.l2jserver.game.net.Lineage2Session;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterSelectionListPacket;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.factory.AccountIDFactory;
import com.l2jserver.model.id.provider.AccountIDProvider;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.BufferUtils;
@@ -51,7 +51,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
/**
* The {@link AccountID} factory
*/
private final AccountIDFactory accountIdFactory;
private final AccountIDProvider accountIdFactory;
// packet
/**
@@ -65,7 +65,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
@Inject
public AuthLoginPacket(CharacterDAO characterDao,
AccountIDFactory accountIdFactory) {
AccountIDProvider accountIdFactory) {
this.characterDao = characterDao;
this.accountIdFactory = accountIdFactory;
}

View File

@@ -0,0 +1,99 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.client;
import org.jboss.netty.buffer.ChannelBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Completes the creation of an character. Creates the object, inserts into the
* database and notifies the client about the status of the operation.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterActionPacket extends AbstractClientPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x1f;
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WorldService worldService;
private final ObjectIDResolver idResolver;
private int objectId;
private Coordinate origin;
private CharacterAction action;
public enum CharacterAction {
CLICK(0),
/**
* This is the right click action.
*/
RIGHT_CLICK(1);
public final int id;
CharacterAction(int id) {
this.id = id;
}
public static CharacterAction fromID(int id) {
for (final CharacterAction action : values())
if (action.id == id)
return action;
return null;
}
}
@Inject
public CharacterActionPacket(WorldService worldService,
ObjectIDResolver idResolver) {
this.worldService = worldService;
this.idResolver = idResolver;
}
@Override
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
this.objectId = buffer.readInt();
this.origin = Coordinate.fromXYZ(buffer.readInt(), buffer.readInt(),
buffer.readInt());
this.action = CharacterAction.fromID(buffer.readByte());
}
@Override
public void process(final Lineage2Connection conn) {
// since this is an erasure type, this is safe.
final ObjectID<NPC> id = idResolver.resolve(objectId);
if (!(id instanceof NPCID))
return;
final NPC npc = id.getObject();
npc.action(conn.getCharacter(), action);
}
}

View File

@@ -27,9 +27,9 @@ import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateOkPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.factory.CharacterIDFactory;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.AbstractActor.Sex;
@@ -66,11 +66,11 @@ public class CharacterCreatePacket extends AbstractClientPacket {
/**
* The {@link CharacterID} factory
*/
private final CharacterIDFactory characterIdFactory;
private final CharacterIDProvider characterIdFactory;
/**
* The {@link CharacterTemplateID} factory
*/
private final CharacterTemplateIDFactory characterTemplateIdFactory;
private final CharacterTemplateIDProvider characterTemplateIdFactory;
// packet
/**
@@ -136,8 +136,8 @@ public class CharacterCreatePacket extends AbstractClientPacket {
@Inject
public CharacterCreatePacket(CharacterDAO characterDao,
CharacterIDFactory characterIdFactory,
CharacterTemplateIDFactory characterTemplateIdFactory) {
CharacterIDProvider characterIdFactory,
CharacterTemplateIDProvider characterTemplateIdFactory) {
this.characterDao = characterDao;
this.characterIdFactory = characterIdFactory;
this.characterTemplateIdFactory = characterTemplateIdFactory;

View File

@@ -25,7 +25,7 @@ import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterTemplatePacket;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.character.CharacterClass;
@@ -62,10 +62,10 @@ public class RequestCharacterTemplatesPacket extends AbstractClientPacket {
/**
* The {@link CharacterTemplateID} factory
*/
private final CharacterTemplateIDFactory idFactory;
private final CharacterTemplateIDProvider idFactory;
@Inject
public RequestCharacterTemplatesPacket(CharacterTemplateIDFactory idFactory) {
public RequestCharacterTemplatesPacket(CharacterTemplateIDProvider idFactory) {
this.idFactory = idFactory;
}

View File

@@ -57,7 +57,7 @@ import com.l2jserver.util.BufferUtils;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class UserInformationPacket extends AbstractServerPacket {
public class CharacterInformationPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
@@ -68,7 +68,7 @@ public class UserInformationPacket extends AbstractServerPacket {
*/
private L2Character character;
public UserInformationPacket(L2Character character) {
public CharacterInformationPacket(L2Character character) {
super(OPCODE);
this.character = character;
}
@@ -95,7 +95,7 @@ public class UserInformationPacket extends AbstractServerPacket {
buffer.writeInt(character.getAttributes().getWitness());
buffer.writeInt(character.getAttributes().getMentality());
buffer.writeInt(200); // max hp
buffer.writeInt((int) 200); // cur hp
buffer.writeInt(character.getHP()); // cur hp
buffer.writeInt(200); // max mp
buffer.writeInt((int) 200); // cur mp
buffer.writeInt(0); // sp

View File

@@ -0,0 +1,61 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
import com.l2jserver.model.world.capability.Actor;
/**
* This packet notifies the client that the chosen character has been
* successfully selected.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
* @see Reason
*/
public class CharacterTargetSelectedPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0xb9;
/**
* The selected character
*/
private final Actor object;
private int color;
public CharacterTargetSelectedPacket(Actor object, int color) {
super(OPCODE);
this.object = object;
this.color = color;
}
public CharacterTargetSelectedPacket(Actor object) {
this(object, 0);
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
buffer.writeInt(object.getID().getID());
buffer.writeShort(color);
buffer.writeInt(0x00);
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.NPC;
import com.l2jserver.util.BufferUtils;
/**
* This packet sends to the client an actor information about an actor (except
* players)
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCInformationPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x0c;
private final NPC npc;
public NPCInformationPacket(NPC npc) {
super(OPCODE);
this.npc = npc;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
final NPCTemplate template = npc.getTemplate();
buffer.writeInt(npc.getID().getID());
buffer.writeInt(template.getID().getID() + 1000000); // npctype id
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00));
buffer.writeInt(npc.getPoint().getX());
buffer.writeInt(npc.getPoint().getY());
buffer.writeInt(npc.getPoint().getZ());
buffer.writeInt((int) npc.getPoint().getAngle());
buffer.writeInt(0x00); // unk
buffer.writeInt(template.getCastSpeed());
buffer.writeInt(template.getAttackSpeed());
buffer.writeInt((int) template.getMoveSpeed());
buffer.writeInt((int) template.getMoveSpeed());
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
buffer.writeDouble(template.getMovementSpeedMultiplier());
buffer.writeDouble(template.getAttackSpeedMultiplier());
buffer.writeDouble(template.getCollisionRadius());
buffer.writeDouble(template.getCollisionHeigth());
buffer.writeInt(0x00); // right hand weapon
buffer.writeInt(0x00); // chest
buffer.writeInt(0x00); // left hand weapon
buffer.writeByte(1); // name above char 1=true ... ??
buffer.writeByte(0x00); // is running
buffer.writeByte(0x00); // is in combat
buffer.writeByte(0x00); // is like dead (faking)
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
BufferUtils.writeString(buffer, template.getName());
BufferUtils.writeString(buffer, template.getTitle());
buffer.writeInt(0x00); // Title color 0=client default
buffer.writeInt(0x00); // pvp flag
buffer.writeInt(0x00); // karma
buffer.writeInt(0x00); // C2 - abnormal effect
buffer.writeInt(0x00); // clan id
buffer.writeInt(0x00); // crest id
buffer.writeInt(0x00); // ally id
buffer.writeInt(0x00); // all crest
buffer.writeByte(0x00); // C2 - is flying
buffer.writeByte(0x00); // title color 0=client
buffer.writeDouble(template.getCollisionRadius());
buffer.writeDouble(template.getCollisionHeigth());
buffer.writeInt(0x00); // C4 - enchant effect
buffer.writeInt(0x00); // C6 -- is flying
buffer.writeInt(0x00); // unk
buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect
buffer.writeByte(0x00); // hide name
buffer.writeByte(0x00); // hide name, again
buffer.writeInt(0x00); // special effects
buffer.writeInt(0x00); // display effect
}
}

View File

@@ -0,0 +1,67 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.NPC;
import com.l2jserver.util.BufferUtils;
/**
* This packet sends to the client an actor information about an actor (except
* players)
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ServerObjectPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x92;
private final NPC npc;
public ServerObjectPacket(NPC npc) {
super(OPCODE);
this.npc = npc;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
final NPCTemplate template = npc.getTemplate();
buffer.writeInt(npc.getID().getID()); // obj id
buffer.writeInt(npc.getTemplateID().getID() + 1000000); // template id
BufferUtils.writeString(buffer, template.getName()); // name
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00)); // attackable
buffer.writeInt(npc.getPoint().getX()); // x
buffer.writeInt(npc.getPoint().getY()); // y
buffer.writeInt(npc.getPoint().getZ()); // z
buffer.writeInt((int) npc.getPoint().getAngle()); // angle
buffer.writeDouble(template.getMovementSpeedMultiplier());
buffer.writeDouble(template.getAttackSpeedMultiplier());
buffer.writeDouble(template.getCollisionRadius()); // coll radius
buffer.writeDouble(template.getCollisionHeigth()); // coll height
buffer.writeInt((template.isAttackable() ? npc.getHP() : 0x00));
buffer.writeInt((template.isAttackable() ? template.getMaxHP() : 0x00));
buffer.writeInt(0x01); // object type
buffer.writeInt(0x00); // special effects
}
}