Rename and clean up MapleQuickslotBinding
This commit is contained in:
@@ -29,7 +29,7 @@ import client.inventory.Equip.StatUpgrade;
|
||||
import client.inventory.manipulator.CashIdGenerator;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import client.keybind.KeyBinding;
|
||||
import client.keybind.MapleQuickslotBinding;
|
||||
import client.keybind.QuickslotBinding;
|
||||
import client.newyear.NewYearCardRecord;
|
||||
import client.processor.action.PetAutopotProcessor;
|
||||
import client.processor.npc.FredrickProcessor;
|
||||
@@ -193,7 +193,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private Map<Integer, MapleCoolDownValueHolder> coolDowns = new LinkedHashMap<>();
|
||||
private EnumMap<MapleDisease, Pair<MapleDiseaseValueHolder, MobSkill>> diseases = new EnumMap<>(MapleDisease.class);
|
||||
private byte[] m_aQuickslotLoaded;
|
||||
private MapleQuickslotBinding m_pQuickslotKeyMapped;
|
||||
private QuickslotBinding m_pQuickslotKeyMapped;
|
||||
private MapleDoor pdoor = null;
|
||||
private Map<MapleQuest, Long> questExpirations = new LinkedHashMap<>();
|
||||
private ScheduledFuture<?> dragonBloodSchedule;
|
||||
@@ -1212,7 +1212,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
public void changeQuickslotKeybinding(byte[] aQuickslotKeyMapped) {
|
||||
this.m_pQuickslotKeyMapped = new MapleQuickslotBinding(aQuickslotKeyMapped);
|
||||
this.m_pQuickslotKeyMapped = new QuickslotBinding(aQuickslotKeyMapped);
|
||||
}
|
||||
|
||||
public void broadcastStance(int newStance) {
|
||||
@@ -7433,7 +7433,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
try (final ResultSet pResultSet = pSelectQuickslotKeyMapped.executeQuery()) {
|
||||
if (pResultSet.next()) {
|
||||
ret.m_aQuickslotLoaded = LongTool.LongToBytes(pResultSet.getLong(1));
|
||||
ret.m_pQuickslotKeyMapped = new MapleQuickslotBinding(ret.m_aQuickslotLoaded);
|
||||
ret.m_pQuickslotKeyMapped = new QuickslotBinding(ret.m_aQuickslotLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8780,10 +8780,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
public void sendQuickmap() {
|
||||
// send quickslots to user
|
||||
MapleQuickslotBinding pQuickslotKeyMapped = this.m_pQuickslotKeyMapped;
|
||||
QuickslotBinding pQuickslotKeyMapped = this.m_pQuickslotKeyMapped;
|
||||
|
||||
if (pQuickslotKeyMapped == null) {
|
||||
pQuickslotKeyMapped = new MapleQuickslotBinding(MapleQuickslotBinding.DEFAULT_QUICKSLOTS);
|
||||
pQuickslotKeyMapped = new QuickslotBinding(QuickslotBinding.DEFAULT_QUICKSLOTS);
|
||||
}
|
||||
|
||||
this.sendPacket(PacketCreator.QuickslotMappedInit(pQuickslotKeyMapped));
|
||||
|
||||
@@ -5,34 +5,25 @@ import net.packet.OutPacket;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Shavit
|
||||
*/
|
||||
public class MapleQuickslotBinding
|
||||
{
|
||||
public class QuickslotBinding {
|
||||
public static final int QUICKSLOT_SIZE = 8;
|
||||
public static final byte[] DEFAULT_QUICKSLOTS = {0x2A, 0x52, 0x47, 0x49, 0x1D, 0x53, 0x4F, 0x51};
|
||||
|
||||
public static final byte[] DEFAULT_QUICKSLOTS =
|
||||
{
|
||||
0x2A, 0x52, 0x47, 0x49, 0x1D, 0x53, 0x4F, 0x51
|
||||
};
|
||||
|
||||
private byte[] m_aQuickslotKeyMapped;
|
||||
private final byte[] m_aQuickslotKeyMapped;
|
||||
|
||||
// Initializes quickslot object for the user.
|
||||
// aKeys' length has to be 8.
|
||||
public MapleQuickslotBinding(byte[] aKeys)
|
||||
{
|
||||
if(aKeys.length != QUICKSLOT_SIZE)
|
||||
{
|
||||
public QuickslotBinding(byte[] aKeys) {
|
||||
if (aKeys.length != QUICKSLOT_SIZE) {
|
||||
throw new IllegalArgumentException(String.format("aKeys' size should be %d", QUICKSLOT_SIZE));
|
||||
}
|
||||
|
||||
this.m_aQuickslotKeyMapped = aKeys.clone();
|
||||
}
|
||||
|
||||
public void encode(OutPacket p)
|
||||
{
|
||||
public void encode(OutPacket p) {
|
||||
// Quickslots are default.
|
||||
// The client will skip them and call CQuickslotKeyMappedMan::DefaultQuickslotKeyMap.
|
||||
if (Arrays.equals(this.m_aQuickslotKeyMapped, DEFAULT_QUICKSLOTS)) {
|
||||
@@ -42,16 +33,16 @@ public class MapleQuickslotBinding
|
||||
|
||||
p.writeBool(true);
|
||||
|
||||
for(byte nKey : this.m_aQuickslotKeyMapped) {
|
||||
for (byte nKey : this.m_aQuickslotKeyMapped) {
|
||||
// For some reason Nexon sends these as integers, similar to CFuncKeyMappedMan.
|
||||
// However there's no evidence any key can be above 0xFF anyhow.
|
||||
// Regardless, we need to encode an integer to avoid an error 38 crash; as CFuncKeyMapped::m_aQuickslotKeyMapped is int[8].
|
||||
p.writeInt(nKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] GetKeybindings() {
|
||||
return m_aQuickslotKeyMapped;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.server.channel.handlers;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.keybind.MapleQuickslotBinding;
|
||||
import client.keybind.QuickslotBinding;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
|
||||
@@ -15,16 +15,16 @@ public class QuickslotKeyMappedModifiedHandler extends AbstractPacketHandler
|
||||
public void handlePacket(InPacket p, MapleClient c)
|
||||
{
|
||||
// Invalid size for the packet.
|
||||
if(p.available() != MapleQuickslotBinding.QUICKSLOT_SIZE * Integer.BYTES ||
|
||||
if(p.available() != QuickslotBinding.QUICKSLOT_SIZE * Integer.BYTES ||
|
||||
// not logged in-game
|
||||
c.getPlayer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] aQuickslotKeyMapped = new byte[MapleQuickslotBinding.QUICKSLOT_SIZE];
|
||||
byte[] aQuickslotKeyMapped = new byte[QuickslotBinding.QUICKSLOT_SIZE];
|
||||
|
||||
for(int i = 0; i < MapleQuickslotBinding.QUICKSLOT_SIZE; i++)
|
||||
for(int i = 0; i < QuickslotBinding.QUICKSLOT_SIZE; i++)
|
||||
{
|
||||
aQuickslotKeyMapped[i] = (byte) p.readInt();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import client.MapleCharacter.SkillEntry;
|
||||
import client.inventory.*;
|
||||
import client.inventory.Equip.ScrollResult;
|
||||
import client.keybind.KeyBinding;
|
||||
import client.keybind.MapleQuickslotBinding;
|
||||
import client.keybind.QuickslotBinding;
|
||||
import client.newyear.NewYearCardRecord;
|
||||
import client.status.MonsterStatus;
|
||||
import client.status.MonsterStatusEffect;
|
||||
@@ -3484,7 +3484,7 @@ public class PacketCreator {
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Packet QuickslotMappedInit(MapleQuickslotBinding pQuickslot) {
|
||||
public static Packet QuickslotMappedInit(QuickslotBinding pQuickslot) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.QUICKSLOT_INIT);
|
||||
pQuickslot.encode(p);
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user