Fixed a bunch of potential bugs.

This commit is contained in:
ceikry
2021-07-25 23:52:34 -05:00
parent d96fd7b283
commit ae3d9e93b5
45 changed files with 129 additions and 253 deletions
@@ -100,10 +100,6 @@ public class BZip2Decompressor {
i1++; i1++;
j1--; j1--;
} while (true); } while (true);
if (j1 == 0) {
i = 1;
break;
}
abyte0[i1] = byte4; abyte0[i1] = byte4;
i1++; i1++;
j1--; j1--;
+3 -1
View File
@@ -140,7 +140,9 @@ public class Definition<T extends Node> {
if (examine == null) { if (examine == null) {
try { try {
examine = handlers.get("examine").toString(); examine = handlers.get("examine").toString();
} catch (Exception e){} } catch (Exception e){
e.printStackTrace();
}
if(examine == null) { if(examine == null) {
if (name.length() > 0) { if (name.length() > 0) {
examine = "It's a" + (StringUtils.isPlusN(name) ? "n " : " ") + name + "."; examine = "It's a" + (StringUtils.isPlusN(name) ? "n " : " ") + name + ".";
+3 -1
View File
@@ -3,6 +3,8 @@ package core.cache.def.impl;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.FileWriter; import java.io.FileWriter;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -71,7 +73,7 @@ public final class CS2Mapping {
*/ */
public static void main(String... args) throws Throwable { public static void main(String... args) throws Throwable {
GameWorld.prompt(false); GameWorld.prompt(false);
BufferedWriter bw = new BufferedWriter(new FileWriter("./cs2.txt")); BufferedWriter bw = Files.newBufferedWriter(Paths.get("./cs2.txt"));
for (int i = 0; i < 10000; i++) { for (int i = 0; i < 10000; i++) {
CS2Mapping mapping = forId(i); CS2Mapping mapping = forId(i);
if (mapping == null) { if (mapping == null) {
@@ -48,7 +48,7 @@ public class GraphicDefinition {
if (def != null) { if (def != null) {
return def; return def;
} }
byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 735411752, gfxId & 0xff); byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 8, gfxId & 0xff);
def = new GraphicDefinition(); def = new GraphicDefinition();
def.graphicsId = gfxId; def.graphicsId = gfxId;
if (data != null) { if (data != null) {
@@ -57,10 +57,10 @@ public final class NPCDefinition extends Definition<NPC> {
*/ */
public boolean isVisibleOnMap; public boolean isVisibleOnMap;
/** /* *//**
* The examine option value * The examine option value
*/ *//*
public String examine; public String examine;*/
/** /**
* The drop tables. * The drop tables.
@@ -201,7 +201,7 @@ public final class NPCDefinition extends Definition<NPC> {
NPCDefinition def = DEFINITIONS.get(id); NPCDefinition def = DEFINITIONS.get(id);
if (def == null) { if (def == null) {
def = new NPCDefinition(id); def = new NPCDefinition(id);
byte[] data = Cache.getIndexes()[18].getFileData(id >>> 134238215, id & 0x7f); byte[] data = Cache.getIndexes()[18].getFileData(id >>> 7, id & 0x7f);
if (data == null) { if (data == null) {
if (id != -1) { if (id != -1) {
// System.out.println("Failed loading NPC " + id + "."); // System.out.println("Failed loading NPC " + id + ".");
@@ -6,6 +6,7 @@ import core.cache.misc.buffer.ByteBufferUtils;
import core.game.interaction.OptionHandler; import core.game.interaction.OptionHandler;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.object.Scenery; import core.game.node.object.Scenery;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import rs09.game.system.SystemLogger; import rs09.game.system.SystemLogger;
import rs09.game.world.GameWorld; import rs09.game.world.GameWorld;
@@ -1670,6 +1671,6 @@ public class SceneryDefinition extends Definition<Scenery> {
* @return The container id. * @return The container id.
*/ */
public static int getContainerId(int id) { public static int getContainerId(int id) {
return id >>> 1998118472; return id >>> 8;
} }
} }
+1 -1
View File
@@ -7,7 +7,7 @@ public class GZipDecompressor {
private static final Inflater inflaterInstance = new Inflater(true); private static final Inflater inflaterInstance = new Inflater(true);
public static final void decompress(ByteBuffer buffer, byte data[]) { public static final void decompress(ByteBuffer buffer, byte[] data) {
synchronized (inflaterInstance) { synchronized (inflaterInstance) {
if (~buffer.get(buffer.position()) != -32 || buffer.get(buffer.position() + 1) != -117) { if (~buffer.get(buffer.position()) != -32 || buffer.get(buffer.position() + 1) != -117) {
data = null; data = null;
@@ -2,6 +2,7 @@ package core.cache.misc.buffer;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
/** /**
* Holds utility methods for reading/writing a byte buffer. * Holds utility methods for reading/writing a byte buffer.
@@ -29,7 +30,7 @@ public final class ByteBufferUtils {
* @param buffer The byte buffer. * @param buffer The byte buffer.
*/ */
public static void putString(String s, ByteBuffer buffer) { public static void putString(String s, ByteBuffer buffer) {
buffer.put(s.getBytes()).put((byte) 0); buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0);
} }
/** /**
@@ -521,7 +521,7 @@ public class Container {
int id = buffer.getShort() & 0xFFFF; int id = buffer.getShort() & 0xFFFF;
int amount = buffer.getInt(); int amount = buffer.getInt();
int charge = buffer.getInt(); int charge = buffer.getInt();
if (id >= ItemDefinition.getDefinitions().size() || id < 0 || slot >= items.length || slot < 0) { if (id >= ItemDefinition.getDefinitions().size() || slot >= items.length || slot < 0) {
continue; continue;
} }
Item item = items[slot] = new Item(id, amount, charge); Item item = items[slot] = new Item(id, amount, charge);
@@ -69,12 +69,4 @@ public enum DuelRule {
public int getEquipmentSlot() { public int getEquipmentSlot() {
return equipmentSlot; return equipmentSlot;
} }
/**
* Sets the equipmentSlot.
* @param equipmentSlot the equipmentSlot to set
*/
public void setEquipmentSlot(int equipmentSlot) {
this.equipmentSlot = equipmentSlot;
}
} }
@@ -305,7 +305,7 @@ public class AlchemistZone extends MTAZone {
int alchIndex = indexer + index; int alchIndex = indexer + index;
if (indexer != 0) { if (indexer != 0) {
if (indexer >= 4 && index < 4) { if (indexer >= 4 && index < 4) {
if (indexer == 4 && indexer - index < 4 || indexer - index < 4) { if (indexer == 4 && indexer - index < 4) {
return null; return null;
} }
if (indexer == 4) { if (indexer == 4) {
@@ -430,7 +430,7 @@ public class AlchemistZone extends MTAZone {
* Sets the cost. * Sets the cost.
* @param cost the cost to set. * @param cost the cost to set.
*/ */
public void setCost(int cost) { private void setCost(int cost) {
this.cost = cost; this.cost = cost;
} }
@@ -56,7 +56,6 @@ public abstract class PyramidPlunderNPC extends AbstractNPC {
public PyramidPlunderNPC(int id, Location location, Player player) { public PyramidPlunderNPC(int id, Location location, Player player) {
super(id, location); super(id, location);
this.player = player; this.player = player;
this.quotes = quotes;
this.endTime = (int) (GameWorld.getTicks() + (1000 / 0.6)); this.endTime = (int) (GameWorld.getTicks() + (1000 / 0.6));
} }
@@ -138,12 +138,12 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin {
// Become the Champion of the Fight Pits // Become the Champion of the Fight Pits
if (lastVictor != null) { if (lastVictor != null) {
lastVictor.getAchievementDiaryManager().finishTask(lastVictor, DiaryType.KARAMJA, 2, 0); lastVictor.getAchievementDiaryManager().finishTask(lastVictor, DiaryType.KARAMJA, 2, 0);
}
addTokkul(lastVictor); addTokkul(lastVictor);
lastVictor.getAppearance().setSkullIcon(SKULL_ID); lastVictor.getAppearance().setSkullIcon(SKULL_ID);
lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor)); lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor));
lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0); lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0);
resetDamagePulse(lastVictor); resetDamagePulse(lastVictor);
}
RegionManager.forId(9552).getPlanes()[0].getNpcs().get(0).setAttribute("fp_champn", getChampionName()); RegionManager.forId(9552).getPlanes()[0].getNpcs().get(0).setAttribute("fp_champn", getChampionName());
} }
minutes = 0; minutes = 0;
@@ -181,7 +181,9 @@ public final class AnimationRoom extends MapZone implements Plugin<Object> {
} }
} }
} }
if(set != null) {
animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set); animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set);
}
return true; return true;
} }
@@ -392,7 +392,7 @@ public final class DBRCutscenePlugin extends CutscenePlugin {
getWiseOldMan().animate(CAST_ANIMATION); getWiseOldMan().animate(CAST_ANIMATION);
getWiseOldMan().graphics(new Graphics(433)); getWiseOldMan().graphics(new Graphics(433));
if (target instanceof Entity) { if (target instanceof Entity) {
Projectile.create(getWiseOldMan(), target instanceof Entity ? ((Entity) target) : null, 434).send(); Projectile.create(getWiseOldMan(), (Entity) target, 434).send();
} else { } else {
Projectile projectile = Projectile.create(getWiseOldMan(), null, 434, 30, 30, 41, 140, 0, 0); Projectile projectile = Projectile.create(getWiseOldMan(), null, 434, 30, 30, 41, 140, 0, 0);
projectile.setEndLocation((Location) target); projectile.setEndLocation((Location) target);
@@ -150,7 +150,7 @@ public final class DragonSlayerPlugin extends OptionHandler {
InteractionListeners.run(node.getId(),0,"equip",player,node); InteractionListeners.run(node.getId(),0,"equip",player,node);
break; break;
case 742: case 742:
if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) {
player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for");
player.getPacketDispatch().sendMessage("your reward!"); player.getPacketDispatch().sendMessage("your reward!");
return true; return true;
@@ -169,7 +169,7 @@ public final class DragonSlayerPlugin extends OptionHandler {
movement.run(player, 10); movement.run(player, 10);
return true; return true;
} }
if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) {
player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for");
player.getPacketDispatch().sendMessage("your reward!"); player.getPacketDispatch().sendMessage("your reward!");
return true; return true;
@@ -318,7 +318,7 @@ public final class DragonSlayerPlugin extends OptionHandler {
case 2604: case 2604:
switch (option) { switch (option) {
case "search": case "search":
if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE) && !player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) { if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) {
if (!player.getInventory().add(DragonSlayer.MAZE_PIECE)) { if (!player.getInventory().add(DragonSlayer.MAZE_PIECE)) {
GroundItemManager.create(DragonSlayer.MAZE_PIECE, player); GroundItemManager.create(DragonSlayer.MAZE_PIECE, player);
} }
@@ -148,7 +148,7 @@ public final class ElvargNPC extends AbstractNPC {
return super.isAttackable(entity, style); return super.isAttackable(entity, style);
} }
final Player player = (Player) entity; final Player player = (Player) entity;
if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) {
player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for");
player.getPacketDispatch().sendMessage("your reward!"); player.getPacketDispatch().sendMessage("your reward!");
return true; return true;
@@ -80,7 +80,7 @@ public final class RestlessGhostPlugin extends OptionHandler {
switch (option) { switch (option) {
case "open": case "open":
switch (id) { switch (id) {
case 2145: default:
toggleCoffin(player, object); toggleCoffin(player, object);
break; break;
} }
@@ -967,10 +967,9 @@ public enum TutorialStage {
/** /**
* Represents if it is a login stage. * Represents if it is a login stage.
* @param login the login value. * @param login the login value.
* @return {@code True} if so.
*/ */
public boolean isLogin(boolean login) { public void isLogin(boolean login) {
return this.login = login; this.login = login;
} }
/** /**
@@ -2,6 +2,7 @@ package core.game.ge;
import core.game.node.item.Item; import core.game.node.item.Item;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -75,20 +76,12 @@ public enum GEItemSet {
return itemId; return itemId;
} }
/**
* Sets the itemId.
* @param itemId The itemId to set.
*/
public void setItemId(int itemId) {
this.itemId = itemId;
}
/** /**
* Gets the components. * Gets the components.
* @return The components. * @return The components.
*/ */
public int[] getComponents() { public int[] getComponents() {
return components; return Arrays.copyOf(components, components.length);
} }
/** /**
@@ -104,6 +97,6 @@ public enum GEItemSet {
* @return The item array. * @return The item array.
*/ */
public static Item[] getItemArray() { public static Item[] getItemArray() {
return itemArray; return Arrays.copyOf(itemArray, itemArray.length);
} }
} }
@@ -185,14 +185,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin {
return button; return button;
} }
/**
* Sets the button.
* @param button The button to set.
*/
public void setButton(int button) {
this.button = button;
}
/** /**
* Gets the bolt. * Gets the bolt.
* @return The bolt. * @return The bolt.
@@ -201,14 +193,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin {
return bolt; return bolt;
} }
/**
* Sets the bolt.
* @param bolt The bolt to set.
*/
public void setBolt(int bolt) {
this.bolt = bolt;
}
/** /**
* Gets the level. * Gets the level.
* @return The level. * @return The level.
@@ -217,14 +201,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin {
return level; return level;
} }
/**
* Sets the level.
* @param level The level to set.
*/
public void setLevel(int level) {
this.level = level;
}
/** /**
* Gets the runes. * Gets the runes.
* @return The runes. * @return The runes.
@@ -115,7 +115,7 @@ public class TormentedDemonNPC extends AbstractNPC {
@Override @Override
public void checkImpact(BattleState state) { public void checkImpact(BattleState state) {
if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) { if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) {
shieldDelay = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60); shieldDelay = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60);
fireShield = false; fireShield = false;
setAttribute("shield-player", state.getAttacker()); setAttribute("shield-player", state.getAttacker());
@@ -55,7 +55,7 @@ public final class MinotaurFamiliarNPC implements Plugin<Object> {
familiar.sendFamiliarHit(target, RandomFunction.random(maxHit)); familiar.sendFamiliarHit(target, RandomFunction.random(maxHit));
Projectile.magic(familiar, target, 1497, 80, 36, 70, 10).send(); Projectile.magic(familiar, target, 1497, 80, 36, 70, 10).send();
familiar.visualize(Animation.create(8026), Graphics.create(1496)); familiar.visualize(Animation.create(8026), Graphics.create(1496));
if (!(familiar instanceof BronzeMinotaurNPC && familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) { if (!(familiar instanceof BronzeMinotaurNPC || familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) {
final int ticks = 2 + (int) Math.floor(familiar.getLocation().getDistance(target.getLocation()) * 0.5); final int ticks = 2 + (int) Math.floor(familiar.getLocation().getDistance(target.getLocation()) * 0.5);
GameWorld.getPulser().submit(new Pulse(ticks) { GameWorld.getPulser().submit(new Pulse(ticks) {
@Override @Override
@@ -406,7 +406,7 @@ public final class AssistSession extends Pulse implements RequestModule {
if (getPlayer() != p) { if (getPlayer() != p) {
int index = getSkillIndex(slot); int index = getSkillIndex(slot);
if (index != -1) { if (index != -1) {
if (index != -1 && !isRestricted()) { if (!isRestricted()) {
int level = p.getSkills().getLevel(slot); int level = p.getSkills().getLevel(slot);
int pLevel = player.getSkills().getLevel(slot); int pLevel = player.getSkills().getLevel(slot);
if (pLevel < level) { if (pLevel < level) {
@@ -114,7 +114,7 @@ public final class PKScoreBoard {
int score = player.getSavedData().getSpawnData().getKills(); int score = player.getSavedData().getSpawnData().getKills();
int myScore = 0; int myScore = 0;
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
if (names[i].equals(player.getName()) || names[i].equals(player.getName())) { if (names[i].equals(player.getName())) {
myScore = scores[i]; myScore = scores[i];
break; break;
} }
@@ -152,13 +152,13 @@ public final class PKScoreBoard {
if (scores[index] == score) { if (scores[index] == score) {
return; return;
} }
if (names[index].equals(player.getName()) || names[index].equals(player.getName())) { if (names[index].equals(player.getName())) {
scores[index] = score; scores[index] = score;
return; return;
} }
for (int i = SIZE - 2; i >= index; i--) { for (int i = SIZE - 2; i >= index; i--) {
String name = names[i]; String name = names[i];
if (name.equals(player.getName()) || name.equals(player.getName())) { if (name.equals(player.getName())) {
name = names[--i]; name = names[--i];
} }
scores[i + 1] = scores[i]; scores[i + 1] = scores[i];
@@ -103,9 +103,9 @@ public final class AgilityHandler {
public static void fail(final Player player, int delay, final Location dest, Animation anim, final int hit, final String message) { public static void fail(final Player player, int delay, final Location dest, Animation anim, final int hit, final String message) {
if (anim != null) { if (anim != null) {
ContentAPI.animate(player, anim, true); ContentAPI.animate(player, anim, true);
}
ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) { ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) {
boolean dmg = false; boolean dmg = false;
@Override @Override
public boolean pulse() { public boolean pulse() {
ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT);
@@ -125,6 +125,7 @@ public final class AgilityHandler {
} }
}); });
} }
}
/** /**
* Walks across an obstacle using the force movement update mask. * Walks across an obstacle using the force movement update mask.
@@ -134,7 +134,9 @@ public final class MovingBlockNPC extends AbstractNPC {
} }
player.lock(4); player.lock(4);
player.setAttribute("block-move", GameWorld.getTicks() + 4); player.setAttribute("block-move", GameWorld.getTicks() + 4);
if(dest != null) {
AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH); AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH);
}
return true; return true;
} }
}); });
@@ -375,7 +375,7 @@ public enum BuildHotspot {
/** /**
* The linked hotspots * The linked hotspots
*/ */
private static List<BuildHotspot[]> linkedHotspots = new ArrayList<BuildHotspot[]>(); private static final List<BuildHotspot[]> linkedHotspots = new ArrayList<BuildHotspot[]>();
/** /**
* Configures hotspots. * Configures hotspots.
@@ -494,6 +494,9 @@ public final class HouseManager {
chunkY = 7 - chunkY; chunkY = 7 - chunkY;
break; break;
} }
default: {
}
} }
for (Hotspot h : room.getHotspots()) { for (Hotspot h : room.getHotspots()) {
if ((h.getChunkX() == chunkX || h.getChunkX2() == chunkX) && (h.getChunkY() == chunkY || h.getChunkY2() == chunkY) && h.getHotspot().getObjectId(style) == object.getId()) { if ((h.getChunkX() == chunkX || h.getChunkX2() == chunkX) && (h.getChunkY() == chunkY || h.getChunkY2() == chunkY) && h.getHotspot().getObjectId(style) == object.getId()) {
@@ -47,6 +47,7 @@ public class StewRecipe extends Recipe {
public void mix(Player player, NodeUsageEvent event) { public void mix(Player player, NodeUsageEvent event) {
Item first = event.getUsedItem(); Item first = event.getUsedItem();
Item second = event.getBaseItem(); Item second = event.getBaseItem();
if(first != null && second != null) {
if (player.getInventory().remove(first) && player.getInventory().remove(second)) { if (player.getInventory().remove(first) && player.getInventory().remove(second)) {
if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) {
player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null);
@@ -56,6 +57,7 @@ public class StewRecipe extends Recipe {
player.getPacketDispatch().sendMessage(getMixMessage(event)); player.getPacketDispatch().sendMessage(getMixMessage(event));
} }
} }
}
@Override @Override
public Item getBase() { public Item getBase() {
@@ -68,9 +68,6 @@ public final class GemCutPulse extends SkillPulse<Item> {
@Override @Override
public boolean reward() { public boolean reward() {
if (++ticks % 1 != 0) {
return false;
}
if (player.getInventory().remove(gem.getUncut())) { if (player.getInventory().remove(gem.getUncut())) {
final Item item = gem.getGem(); final Item item = gem.getGem();
player.getInventory().add(item); player.getInventory().add(item);
@@ -46,6 +46,7 @@ public class ClanEntry {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if(o == null) return false;
ClanEntry e = (ClanEntry) o; ClanEntry e = (ClanEntry) o;
if (name != null && !name.equals(e.name)) { if (name != null && !name.equals(e.name)) {
return false; return false;
@@ -1,98 +0,0 @@
package core.game.system.monitor;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
/**
* Handles exception logging.
* @author Emperor
*/
public final class ExceptionLog extends PrintStream {
/**
* The logger.
*/
private final PrintStream logger;
/**
* Constructs a new {@code ExceptionLog} {@code Object}
* @param file The output file directory.
* @throws IOException When an I/O exception occurs.
*/
public ExceptionLog(String file) throws IOException {
super(new File(file));
this.logger = System.err;
}
@Override
public void println(String message) {
logger.println(message);
}
@Override
public PrintStream printf(String message, Object... objects) {
logger.printf(message, objects);
return super.printf(message, objects);
}
@Override
public void println(boolean message) {
logger.println(message);
}
@Override
public void println(int message) {
logger.println(message);
}
@Override
public void println(double message) {
logger.println(message);
}
@Override
public void println(char message) {
logger.println(message);
}
@Override
public void println(long message) {
logger.println(message);
}
@Override
public void println(Object message) {
logger.println(message);
}
@Override
public void print(boolean message) {
logger.print(message);
}
@Override
public void print(int message) {
logger.print(message);
}
@Override
public void print(double message) {
logger.print(message);
}
@Override
public void print(char message) {
logger.print(message);
}
@Override
public void print(long message) {
logger.print(message);
}
@Override
public void print(Object message) {
logger.print(message);
}
}
@@ -21,7 +21,7 @@ public class MessageLog {
/** /**
* The date format used. * The date format used.
*/ */
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
/** /**
* The messages. * The messages.
@@ -14,6 +14,7 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.util.*; import java.util.*;
/** /**
@@ -105,7 +106,7 @@ public final class ScriptCompiler {
*/ */
public static ScriptContext parseRaw(File file) throws Throwable { public static ScriptContext parseRaw(File file) throws Throwable {
loadInstructions(); loadInstructions();
BufferedReader br = new BufferedReader(new FileReader(file)); BufferedReader br = Files.newBufferedReader(file.toPath());
lineId = -1; lineId = -1;
String line; String line;
builder = null; builder = null;
@@ -190,7 +190,7 @@ public class EncryptionManager {
* @return the decoded value of x * @return the decoded value of x
*/ */
private static byte char64(char x) { private static byte char64(char x) {
if ((int) x < 0 || (int) x > index_64.length) if ((int) x > index_64.length)
return -1; return -1;
return index_64[(int) x]; return index_64[(int) x];
} }
@@ -507,14 +507,6 @@ public class Region {
this.loaded = loaded; this.loaded = loaded;
} }
/**
* Gets the viewAmount.
* @return The viewAmount.
*/
public int getViewAmount() {
return viewAmount;
}
/** /**
* Sets the viewAmount. * Sets the viewAmount.
* @param viewAmount The viewAmount to set. * @param viewAmount The viewAmount to set.
@@ -33,7 +33,7 @@ object RegionManager {
*/ */
@JvmStatic @JvmStatic
fun forId(regionId: Int): Region { fun forId(regionId: Int): Region {
LOCK.tryLock(10000, TimeUnit.MILLISECONDS) if(LOCK.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) {
var region = REGION_CACHE[regionId] var region = REGION_CACHE[regionId]
if (region == null) { if (region == null) {
region = Region((regionId shr 8) and 0xFF, regionId and 0xFF) region = Region((regionId shr 8) and 0xFF, regionId and 0xFF)
@@ -45,15 +45,18 @@ object RegionManager {
LOCK.unlock() LOCK.unlock()
return REGION_CACHE[regionId]!! return REGION_CACHE[regionId]!!
} }
SystemLogger.logErr("UNABLE TO OBTAIN LOCK WHEN GETTING REGION BY ID. RETURNING BLANK REGION.")
return Region(0,0)
}
/** /**
* Pulses the active regions. * Pulses the active regions.
*/ */
@JvmStatic @JvmStatic
fun pulse() { fun pulse() {
LOCK.tryLock(10000,TimeUnit.MILLISECONDS) if(LOCK.tryLock() || LOCK.tryLock(10000,TimeUnit.MILLISECONDS)) {
for (r in REGION_CACHE.values) { for (r in REGION_CACHE.values) {
if (r != null && r.isActive) { if (r.isActive) {
for (p in r.planes) { for (p in r.planes) {
p.pulse() p.pulse()
} }
@@ -61,6 +64,7 @@ object RegionManager {
} }
LOCK.unlock() LOCK.unlock()
} }
}
/** /**
* Gets the clipping flag on the given location. * Gets the clipping flag on the given location.
@@ -788,10 +792,11 @@ object RegionManager {
@JvmStatic @JvmStatic
fun addRegion(id: Int, region: Region){ fun addRegion(id: Int, region: Region){
LOCK.tryLock(10000, TimeUnit.MILLISECONDS) if(lock.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) {
REGION_CACHE[id] = region REGION_CACHE[id] = region
LOCK.unlock() LOCK.unlock()
} }
}
/** /**
* Gets the regionCache. * Gets the regionCache.
@@ -45,7 +45,9 @@ public final class LandscapeParser {
int type = configuration >> 2; int type = configuration >> 2;
int z = location >> 12; int z = location >> 12;
r.setObjectCount(r.getObjectCount() + 1); r.setObjectCount(r.getObjectCount() + 1);
if (x >= 0 && y >= 0 && x < 64 && y < 64) { if (x < 0 || y < 0 || x >= 64 || y >= 64) {
System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z);
} else {
if ((mapscape[1][x][y] & 0x2) == 2) { if ((mapscape[1][x][y] & 0x2) == 2) {
z--; z--;
} }
@@ -53,8 +55,6 @@ public final class LandscapeParser {
Scenery object = new Scenery(objectId, Location.create((r.getX() << 6) + x, (r.getY() << 6) + y, z), type, rotation); Scenery object = new Scenery(objectId, Location.create((r.getX() << 6) + x, (r.getY() << 6) + y, z), type, rotation);
flagScenery(r.getPlanes()[z], x, y, object, true, storeObjects); flagScenery(r.getPlanes()[z], x, y, object, true, storeObjects);
} }
} else {
System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z);
} }
} }
} }
@@ -183,7 +183,7 @@ public abstract class Pathfinder {
*/ */
public static boolean canDecorationInteract(int curX, int curY, int size, int destX, int destY, int rotation, int type, int z, ClipMaskSupplier clipMaskSupplier) { public static boolean canDecorationInteract(int curX, int curY, int size, int destX, int destY, int rotation, int type, int z, ClipMaskSupplier clipMaskSupplier) {
if (size != 1) { if (size != 1) {
if (destX >= curX && destX <= (curX + size) - 1 && destY >= destY && destY <= (destY + size) - 1) { if (destX >= curX && destX <= (curX + size) - 1 && destY <= (destY + size) - 1) {
return true; return true;
} }
} else if (destX == curX && curY == destY) { } else if (destX == curX && curY == destY) {
@@ -307,7 +307,7 @@ public abstract class Pathfinder {
*/ */
public static boolean canDoorInteract(int curX, int curY, int size, int destX, int destY, int type, int rotation, int z, ClipMaskSupplier clipMaskSupplier) { public static boolean canDoorInteract(int curX, int curY, int size, int destX, int destY, int type, int rotation, int z, ClipMaskSupplier clipMaskSupplier) {
if (size != 1) { if (size != 1) {
if (destX >= curX && destX <= size + curX - 1 && destY >= destY && destY <= destY + size - 1) { if (destX >= curX && destX <= size + curX - 1 && destY <= destY + size - 1) {
return true; return true;
} }
} else if (curX == destX && destY == curY) { } else if (curX == destX && destY == curY) {
@@ -6,6 +6,8 @@ import core.game.world.update.flag.context.ChatMessage;
import core.net.packet.IoBuffer; import core.net.packet.IoBuffer;
import core.tools.StringUtils; import core.tools.StringUtils;
import java.nio.charset.StandardCharsets;
/** /**
* Handles the chat flag. * Handles the chat flag.
* @author Emperor * @author Emperor
@@ -24,7 +26,7 @@ public class ChatFlag extends UpdateFlag<ChatMessage> {
public void write(IoBuffer buffer) { public void write(IoBuffer buffer) {
byte[] chatStr = new byte[256]; byte[] chatStr = new byte[256];
chatStr[0] = (byte) context.getText().length(); chatStr[0] = (byte) context.getText().length();
int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes()); int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes(StandardCharsets.UTF_8));
buffer.putLEShort(context.getEffects()); // 0x8000 does something (you'd buffer.putLEShort(context.getEffects()); // 0x8000 does something (you'd
// need to send something // need to send something
// extra. // extra.
@@ -21,6 +21,9 @@ import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
/** /**
* Handles server info tab. * Handles server info tab.
@@ -314,7 +317,7 @@ public class StatisticsTab extends ConsoleTab {
* @param file The file to log to. * @param file The file to log to.
*/ */
protected static void logQueues(File file) { protected static void logQueues(File file) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) { try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8, StandardOpenOption.APPEND)) {
bw.append("/////////////////////////////////////////////////////////////////////////"); bw.append("/////////////////////////////////////////////////////////////////////////");
bw.newLine(); bw.newLine();
bw.append("/////////////////////////////////////////////////////////////////////////"); bw.append("/////////////////////////////////////////////////////////////////////////");
@@ -329,16 +329,16 @@ public final class StringUtils {
try { try {
i_27_ += i_25_; i_27_ += i_25_;
int i_29_ = 0; int i_29_ = 0;
int i_30_ = i_26_ << -2116795453; int i_30_ = i_26_ << 3;
for (; i_27_ > i_25_; i_25_++) { for (; i_27_ > i_25_; i_25_++) {
int i_31_ = 0xff & is_28_[i_25_]; int i_31_ = 0xff & is_28_[i_25_];
int i_32_ = anIntArray233[i_31_]; int i_32_ = anIntArray233[i_31_];
int i_33_ = aByteArray235[i_31_]; int i_33_ = aByteArray235[i_31_];
int i_34_ = i_30_ >> -1445887805; int i_34_ = i_30_ >> 3;
int i_35_ = i_30_ & 0x7; int i_35_ = i_30_ & 0x7;
i_29_ &= (-i_35_ >> 473515839); i_29_ &= (-i_35_ >> 31);
i_30_ += i_33_; i_30_ += i_33_;
int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_; int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_;
i_35_ += 24; i_35_ += 24;
is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_))); is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_)));
if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) { if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) {
@@ -362,7 +362,7 @@ public final class StringUtils {
} }
} }
} }
return -i_26_ + ((7 + i_30_) >> -662855293); return -i_26_ + ((7 + i_30_) >> 3);
} catch (RuntimeException runtimeexception) { } catch (RuntimeException runtimeexception) {
} }
return 0; return 0;
@@ -75,7 +75,7 @@ public class PVPAIPActions {
pvp_players.remove(bot); pvp_players.remove(bot);
return true; return true;
} }
if (!pvp_players.contains(target) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) { if (!pvp_players.contains(target[0]) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) {
target[0] = pvp_players.get(RandomFunction.getRandom(pvp_players.size() - 1)); target[0] = pvp_players.get(RandomFunction.getRandom(pvp_players.size() - 1));
} }
attackTarget(player, bot, target[0]); attackTarget(player, bot, target[0]);
@@ -132,6 +132,7 @@ object OfferManager {
} }
} }
} catch (e: IOException) { } catch (e: IOException) {
GE_OFFER_LOCK.unlock()
SystemLogger.logWarn("Unable to load bot offers. Perhaps it doesn't exist?") SystemLogger.logWarn("Unable to load bot offers. Perhaps it doesn't exist?")
} }
} }
@@ -216,7 +217,7 @@ object OfferManager {
return false return false
} }
OFFER_MAPPING.remove(offer.uid) OFFER_MAPPING.remove(offer.uid)
OFFERS_BY_ITEMID[offer.itemID]!!.remove(offer) OFFERS_BY_ITEMID[offer.itemID]?.remove(offer)
GE_OFFER_LOCK.unlock() GE_OFFER_LOCK.unlock()
return true return true
} }
@@ -227,7 +228,7 @@ object OfferManager {
if (!OFFERS_BY_ITEMID.containsKey(offer.itemID)) { if (!OFFERS_BY_ITEMID.containsKey(offer.itemID)) {
OFFERS_BY_ITEMID[offer.itemID] = mutableListOf() OFFERS_BY_ITEMID[offer.itemID] = mutableListOf()
} }
OFFERS_BY_ITEMID[offer.itemID]!!.add(offer) OFFERS_BY_ITEMID[offer.itemID]?.add(offer)
GE_OFFER_LOCK.unlock() GE_OFFER_LOCK.unlock()
} }
@@ -326,6 +327,7 @@ object OfferManager {
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
GE_OFFER_LOCK.unlock()
} }
GE_OFFER_LOCK.unlock() GE_OFFER_LOCK.unlock()
} }