From 73eebd1d06f99f9813d08c32c9bfed27312f7fb3 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 21 Aug 2014 18:56:23 +0100 Subject: [PATCH] Fixed some long-term buff issues. We've had a completely incorrect buff structure in baselines for the last year due to some small misinterpretations of its structure. It worked because there was the right amount of bytes, but otherwise the structure wasn't right and variables have been in the wrong place. Specifically, we interpreted the stack variable (which comes last) to be the beginning of all buffs except the first, assumed there was an abnormal starting buff, and treated the final stack variable as an unknown variable that comes after the buff list. This is most likely also why it didn't work without this "default buff". The structure has been correct in Buff.getBytes() and buff deltas for a while but has been incorrect for baselines. --- src/resources/objects/creature/CreatureObject.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 691781d5..eb22ce5a 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -51,7 +51,6 @@ import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.skills.SkillMod; import resources.buffs.Buff; -import resources.buffs.BuffList; import resources.buffs.DamageOverTime; import resources.common.OutOfBand; import resources.datatables.Difficulty; @@ -104,7 +103,6 @@ public class CreatureObject extends TangibleObject implements IPersistent { getMaxAttribs().add(0); getMaxAttribs().add(300); getMaxAttribs().add(0); - getBuffList().put(0, new Buff("", getObjectID())); // Initial Default Buff } public CreatureObject() { @@ -189,7 +187,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { baseline.put("equipmentList", new SWGList(this, 6, 23, false)); baseline.put("appearance", ""); baseline.put("visible", true); - baseline.put("buffList", new BuffList(new SWGMap(this, 6, 26, false))); + baseline.put("buffList", new SWGMap(this, 6, 26, true)); baseline.put("performing", false); baseline.put("difficulty", Difficulty.NORMAL); baseline.put("hologramColor", -1); @@ -967,8 +965,9 @@ public class CreatureObject extends TangibleObject implements IPersistent { setVisible(!cloaked); } + @SuppressWarnings("unchecked") public SWGMap getBuffList() { - return ((BuffList) getBaseline(6).get("buffList")).getList(); + return (SWGMap) getBaseline(6).get("buffList"); } public Buff getBuffByName(String buffName) { @@ -982,8 +981,12 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public void addBuff(Buff buff) { + if (buff == null) { + System.err.println("CreatureObject:addBuff(): Attempting to add a null Buff object. Something is wrong in BuffService!"); + } + synchronized(objectMutex) { - PlayerObject player = (PlayerObject) this.getSlottedObject("ghost"); + PlayerObject player = (PlayerObject) getSlottedObject("ghost"); buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000)); }