Rename and clean up MapleMount

This commit is contained in:
P0nk
2021-09-09 21:22:04 +02:00
parent 3e1b5b93d5
commit f4f5e12a50
6 changed files with 24 additions and 21 deletions

View File

@@ -160,7 +160,7 @@ public class Character extends AbstractCharacterObject {
private MapleMessenger messenger = null; private MapleMessenger messenger = null;
private MapleMiniGame miniGame; private MapleMiniGame miniGame;
private MapleRockPaperScissor rps; private MapleRockPaperScissor rps;
private MapleMount maplemount; private Mount maplemount;
private MapleParty party; private MapleParty party;
private final Pet[] pets = new Pet[3]; private final Pet[] pets = new Pet[3];
private MaplePlayerShop playerShop = null; private MaplePlayerShop playerShop = null;
@@ -5372,7 +5372,7 @@ public class Character extends AbstractCharacterObject {
return bookCover; return bookCover;
} }
public MapleMount getMount() { public Mount getMount() {
return maplemount; return maplemount;
} }
@@ -7424,9 +7424,9 @@ public class Character extends AbstractCharacterObject {
final int mountid = ret.getJobType() * 10000000 + 1004; final int mountid = ret.getJobType() * 10000000 + 1004;
if (ret.getInventory(InventoryType.EQUIPPED).getItem((short) -18) != null) { if (ret.getInventory(InventoryType.EQUIPPED).getItem((short) -18) != null) {
ret.maplemount = new MapleMount(ret, ret.getInventory(InventoryType.EQUIPPED).getItem((short) -18).getItemId(), mountid); ret.maplemount = new Mount(ret, ret.getInventory(InventoryType.EQUIPPED).getItem((short) -18).getItemId(), mountid);
} else { } else {
ret.maplemount = new MapleMount(ret, 0, mountid); ret.maplemount = new Mount(ret, 0, mountid);
} }
ret.maplemount.setExp(mountexp); ret.maplemount.setExp(mountexp);
ret.maplemount.setLevel(mountlevel); ret.maplemount.setLevel(mountlevel);
@@ -7540,8 +7540,8 @@ public class Character extends AbstractCharacterObject {
} }
} }
public MapleMount mount(int id, int skillid) { public Mount mount(int id, int skillid) {
MapleMount mount = maplemount; Mount mount = maplemount;
mount.setItemId(id); mount.setItemId(id);
mount.setSkillId(skillid); mount.setSkillId(skillid);
return mount; return mount;

View File

@@ -24,7 +24,7 @@ package client;
/** /**
* @author PurpleMadness < Patrick :O > * @author PurpleMadness < Patrick :O >
*/ */
public class MapleMount { public class Mount {
private int itemid; private int itemid;
private int skillid; private int skillid;
private int tiredness; private int tiredness;
@@ -33,7 +33,7 @@ public class MapleMount {
private Character owner; private Character owner;
private boolean active; private boolean active;
public MapleMount(Character owner, int id, int skillid) { public Mount(Character owner, int id, int skillid) {
this.itemid = id; this.itemid = id;
this.skillid = skillid; this.skillid = skillid;
this.tiredness = 0; this.tiredness = 0;
@@ -63,6 +63,7 @@ public class MapleMount {
* 1902010 - Frog * 1902010 - Frog
* 1902011 - Turtle * 1902011 - Turtle
* 1902012 - Yeti * 1902012 - Yeti
*
* @return the id * @return the id
*/ */
public int getId() { public int getId() {
@@ -90,7 +91,7 @@ public class MapleMount {
tiredness = 0; tiredness = 0;
} }
} }
public int incrementAndGetTiredness() { public int incrementAndGetTiredness() {
this.tiredness++; this.tiredness++;
return this.tiredness; return this.tiredness;
@@ -107,7 +108,7 @@ public class MapleMount {
public void setItemId(int newitemid) { public void setItemId(int newitemid) {
this.itemid = newitemid; this.itemid = newitemid;
} }
public void setSkillId(int newskillid) { public void setSkillId(int newskillid) {
this.skillid = newskillid; this.skillid = newskillid;
} }
@@ -119,9 +120,11 @@ public class MapleMount {
public boolean isActive() { public boolean isActive() {
return active; return active;
} }
public void empty() { public void empty() {
if(owner != null) owner.getClient().getWorldServer().unregisterMountHunger(owner); if (owner != null) {
owner.getClient().getWorldServer().unregisterMountHunger(owner);
}
this.owner = null; this.owner = null;
} }
} }

View File

@@ -345,7 +345,7 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
} }
} }
MapleMount mount = player.getMount(); // thanks Ari for noticing a scenario where Silver Mane quest couldn't be started Mount mount = player.getMount(); // thanks Ari for noticing a scenario where Silver Mane quest couldn't be started
if (mount.getItemId() != 0) { if (mount.getItemId() != 0) {
player.sendPacket(PacketCreator.updateMount(player.getId(), mount, false)); player.sendPacket(PacketCreator.updateMount(player.getId(), mount, false));
} }

View File

@@ -23,7 +23,7 @@ package net.server.channel.handlers;
import client.Character; import client.Character;
import client.Client; import client.Client;
import client.MapleMount; import client.Mount;
import client.inventory.Inventory; import client.inventory.Inventory;
import client.inventory.InventoryType; import client.inventory.InventoryType;
import client.inventory.Item; import client.inventory.Item;
@@ -45,7 +45,7 @@ public final class UseMountFoodHandler extends AbstractPacketHandler {
int itemid = p.readInt(); int itemid = p.readInt();
Character chr = c.getPlayer(); Character chr = c.getPlayer();
MapleMount mount = chr.getMount(); Mount mount = chr.getMount();
Inventory useInv = chr.getInventory(InventoryType.USE); Inventory useInv = chr.getInventory(InventoryType.USE);
if (c.tryacquireClient()) { if (c.tryacquireClient()) {

View File

@@ -1223,7 +1223,7 @@ public class MapleStatEffect {
int localDuration = getBuffLocalDuration(); int localDuration = getBuffLocalDuration();
int localsourceid = sourceid; int localsourceid = sourceid;
int seconds = localDuration / 1000; int seconds = localDuration / 1000;
MapleMount givemount = null; Mount givemount = null;
if (isMonsterRiding()) { if (isMonsterRiding()) {
int ridingMountId = 0; int ridingMountId = 0;
Item mount = applyfrom.getInventory(InventoryType.EQUIPPED).getItem((short) -18); Item mount = applyfrom.getInventory(InventoryType.EQUIPPED).getItem((short) -18);

View File

@@ -1850,7 +1850,7 @@ public class PacketCreator {
// Monster Riding // Monster Riding
Integer bv = chr.getBuffedValue(BuffStat.MONSTER_RIDING); Integer bv = chr.getBuffedValue(BuffStat.MONSTER_RIDING);
if (bv != null) { if (bv != null) {
MapleMount mount = chr.getMount(); Mount mount = chr.getMount();
if (mount != null) { if (mount != null) {
p.writeInt(mount.getItemId()); p.writeInt(mount.getItemId());
p.writeInt(mount.getSkillId()); p.writeInt(mount.getSkillId());
@@ -2712,7 +2712,7 @@ public class PacketCreator {
Item mount; //mounts can potentially crash the client if the player's level is not properly checked Item mount; //mounts can potentially crash the client if the player's level is not properly checked
if (chr.getMount() != null && (mount = chr.getInventory(InventoryType.EQUIPPED).getItem((short) -18)) != null && MapleItemInformationProvider.getInstance().getEquipLevelReq(mount.getItemId()) <= chr.getLevel()) { if (chr.getMount() != null && (mount = chr.getInventory(InventoryType.EQUIPPED).getItem((short) -18)) != null && MapleItemInformationProvider.getInstance().getEquipLevelReq(mount.getItemId()) <= chr.getLevel()) {
MapleMount mmount = chr.getMount(); Mount mmount = chr.getMount();
p.writeByte(mmount.getId()); //mount p.writeByte(mmount.getId()); //mount
p.writeInt(mmount.getLevel()); //level p.writeInt(mmount.getLevel()); //level
p.writeInt(mmount.getExp()); //exp p.writeInt(mmount.getExp()); //exp
@@ -2792,7 +2792,7 @@ public class PacketCreator {
* @param mount * @param mount
* @return * @return
*/ */
public static Packet showMonsterRiding(int cid, MapleMount mount) { //Gtfo with this, this is just giveForeignBuff public static Packet showMonsterRiding(int cid, Mount mount) { //Gtfo with this, this is just giveForeignBuff
final OutPacket p = OutPacket.create(SendOpcode.GIVE_FOREIGN_BUFF); final OutPacket p = OutPacket.create(SendOpcode.GIVE_FOREIGN_BUFF);
p.writeInt(cid); p.writeInt(cid);
p.writeLong(BuffStat.MONSTER_RIDING.getValue()); p.writeLong(BuffStat.MONSTER_RIDING.getValue());
@@ -4556,7 +4556,7 @@ public class PacketCreator {
return p; return p;
} }
public static Packet updateMount(int charid, MapleMount mount, boolean levelup) { public static Packet updateMount(int charid, Mount mount, boolean levelup) {
final OutPacket p = OutPacket.create(SendOpcode.SET_TAMING_MOB_INFO); final OutPacket p = OutPacket.create(SendOpcode.SET_TAMING_MOB_INFO);
p.writeInt(charid); p.writeInt(charid);
p.writeInt(mount.getLevel()); p.writeInt(mount.getLevel());