mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 09:22:49 +00:00
Inventory open implementation, Html updates, Pathing generator,
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -31,6 +31,7 @@ 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.CharacterRequestInventoryPacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterSelectPacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterValidatePositionPacket;
|
||||
@@ -163,6 +164,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
|
||||
return EnterWorld.class;
|
||||
case CharacterActionPacket.OPCODE:
|
||||
return CharacterActionPacket.class;
|
||||
case CharacterRequestInventoryPacket.OPCODE:
|
||||
return CharacterRequestInventoryPacket.class;
|
||||
default:
|
||||
logger.warn("Unknown opcode: 0x{}", Integer.toHexString(opcode));
|
||||
break;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
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;
|
||||
@@ -27,7 +25,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -85,7 +82,6 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
// since this is an erasure type, this is safe.
|
||||
System.out.println(objectId);
|
||||
final ObjectID<NPC> id = idResolver.resolve(objectId);
|
||||
if (!(id instanceof NPCID)) {
|
||||
System.out.println("Incorrect type: " + id);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterInventoryPacket;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
|
||||
/**
|
||||
* 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 CharacterRequestInventoryPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0x14;
|
||||
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
final L2Character character = conn.getCharacter();
|
||||
conn.write(new CharacterInventoryPacket(character.getInventory()));
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.model.world.character.event.CharacterMoveEvent;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
@@ -37,16 +36,16 @@ public class CharacterValidatePositionPacket extends AbstractClientPacket {
|
||||
public static final int OPCODE = 0x59;
|
||||
|
||||
/**
|
||||
* The World Event Dispatcher
|
||||
* The {@link CharacterService}
|
||||
*/
|
||||
private final WorldEventDispatcher eventDispatcher;
|
||||
private final CharacterService charService;
|
||||
|
||||
private Point point;
|
||||
private int extra; // vehicle id
|
||||
|
||||
@Inject
|
||||
public CharacterValidatePositionPacket(WorldEventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
public CharacterValidatePositionPacket(CharacterService charService) {
|
||||
this.charService = charService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,8 +57,6 @@ public class CharacterValidatePositionPacket extends AbstractClientPacket {
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
conn.getCharacter().setPoint(point);
|
||||
eventDispatcher.dispatch(new CharacterMoveEvent(conn.getCharacter(),
|
||||
point));
|
||||
charService.receivedValidation(conn.getCharacter(), point);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.L2JConstants;
|
||||
import com.l2jserver.L2JConstant;
|
||||
import com.l2jserver.game.ProtocolVersion;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.Lineage2CryptographyKey;
|
||||
@@ -87,9 +87,9 @@ public class ProtocolVersionPacket extends AbstractClientPacket {
|
||||
|
||||
log.debug("Client protocol version: {}", version);
|
||||
conn.setVersion(version);
|
||||
if (L2JConstants.SUPPORTED_PROTOCOL != version) {
|
||||
if (L2JConstant.SUPPORTED_PROTOCOL != version) {
|
||||
log.info("Incorrect protocol version: {0}. Only {1} is supported.",
|
||||
version, L2JConstants.SUPPORTED_PROTOCOL);
|
||||
version, L2JConstant.SUPPORTED_PROTOCOL);
|
||||
// notify wrong protocol and close connection
|
||||
conn.write(new KeyPacket(inKey, false)).addListener(
|
||||
new ChannelFutureListener() {
|
||||
|
||||
@@ -42,26 +42,28 @@ public class ActorMovementPacket extends AbstractServerPacket {
|
||||
*/
|
||||
private final Actor actor;
|
||||
/**
|
||||
* The source coordinate
|
||||
* The source target
|
||||
*/
|
||||
private Coordinate source;
|
||||
private Coordinate target;
|
||||
|
||||
public ActorMovementPacket(Actor actor, Coordinate source) {
|
||||
public ActorMovementPacket(Actor actor, Coordinate target) {
|
||||
super(OPCODE);
|
||||
this.actor = actor;
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(actor.getID().getID());
|
||||
|
||||
// target
|
||||
buffer.writeInt(target.getX());
|
||||
buffer.writeInt(target.getY());
|
||||
buffer.writeInt(target.getZ());
|
||||
|
||||
// source
|
||||
buffer.writeInt(actor.getPoint().getX());
|
||||
buffer.writeInt(actor.getPoint().getY());
|
||||
buffer.writeInt(actor.getPoint().getZ());
|
||||
|
||||
buffer.writeInt(source.getX());
|
||||
buffer.writeInt(source.getY());
|
||||
buffer.writeInt(source.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
||||
buffer.writeInt(0x01); // special effects? circles around player...
|
||||
buffer.writeInt(200); // max cp
|
||||
buffer.writeInt(200); // cur cp
|
||||
buffer.writeByte(127); // is mount or is airshilhelp = 0; otherwise
|
||||
buffer.writeByte(0x00); // is mount or is airshilhelp = 0; otherwise
|
||||
// enchant effect (minimum 127)
|
||||
|
||||
buffer.writeByte(0x00);// team, 1=blue,2 red,0 is unknown
|
||||
|
||||
@@ -51,26 +51,29 @@ public class CharacterInventoryPacket extends AbstractServerPacket {
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeByte((showWindow ? 0x01 : 0x00));
|
||||
buffer.writeInt(inventory.getItemCount()); // item count
|
||||
buffer.writeShort((showWindow ? 0x01 : 0x00));
|
||||
// TODO warehouse items will have an issue here!
|
||||
buffer.writeShort(inventory.getItemCount()); // item count
|
||||
|
||||
// TODO implement real item slot
|
||||
int slot = 0;
|
||||
for (Item item : inventory) {
|
||||
if (item.getLocation() == InventoryLocation.WAREHOUSE
|
||||
|| item.getLocation() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer.writeInt(item.getID().getID()); // obj id
|
||||
buffer.writeInt(item.getTemplateID().getID()); // item id
|
||||
if (item.getLocation() == InventoryLocation.PAPERDOLL) {
|
||||
buffer.writeInt(item.getPaperdoll().id); // loc slot
|
||||
} else {
|
||||
buffer.writeInt(0x00); // loc slot
|
||||
}
|
||||
buffer.writeInt(slot); // loc slot
|
||||
buffer.writeLong(item.getCount()); // count
|
||||
buffer.writeShort(0x00); // item type2
|
||||
buffer.writeShort(0x00); // item type3
|
||||
if (item.getLocation() == InventoryLocation.PAPERDOLL) {
|
||||
buffer.writeShort(0x01); // equiped?
|
||||
} else {
|
||||
buffer.writeShort(0x00); // equiped?
|
||||
}
|
||||
buffer.writeInt(0x00); // body part
|
||||
buffer.writeShort(0x00); // enchant level
|
||||
buffer.writeShort((item.getLocation() == InventoryLocation.PAPERDOLL ? 0x01
|
||||
: 0x00)); // equiped?
|
||||
buffer.writeInt((item.getPaperdoll() != null ? item.getPaperdoll().id
|
||||
: 0)); // body part
|
||||
buffer.writeShort(127); // enchant level
|
||||
// race tickets
|
||||
buffer.writeShort(0x00); // item type4 (custom type 2)
|
||||
buffer.writeInt(0x00); // augument
|
||||
@@ -85,6 +88,8 @@ public class CharacterInventoryPacket extends AbstractServerPacket {
|
||||
buffer.writeShort(0x00);
|
||||
buffer.writeShort(0x00);
|
||||
buffer.writeShort(0x00);
|
||||
|
||||
slot++;
|
||||
}
|
||||
// TODO inventory block
|
||||
// buffer.writeShort(_inventory.getBlockItems().length);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
import com.l2jserver.util.html.markup.HtmlTemplate;
|
||||
|
||||
/**
|
||||
* This packet sends an HTML message to be displayed in the client.
|
||||
@@ -36,18 +37,24 @@ public class NPCHtmlMessagePacket extends AbstractServerPacket {
|
||||
public static final int OPCODE = 0x19;
|
||||
|
||||
private final NPC npc;
|
||||
private final Html html;
|
||||
private final String html;
|
||||
|
||||
public NPCHtmlMessagePacket(NPC npc, Html html) {
|
||||
super(OPCODE);
|
||||
this.npc = npc;
|
||||
this.html = html;
|
||||
this.html = html.toHtml();
|
||||
}
|
||||
|
||||
public NPCHtmlMessagePacket(NPC npc, HtmlTemplate markup) {
|
||||
super(OPCODE);
|
||||
this.npc = npc;
|
||||
this.html = markup.toHtmlString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(npc.getID().getID());
|
||||
BufferUtils.writeString(buffer, html.toHtml());
|
||||
BufferUtils.writeString(buffer, html);
|
||||
buffer.writeInt(0x00); // item id
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user