diff --git a/src/resources/control/Debugging.java b/src/resources/control/Debugging.java new file mode 100644 index 000000000..31a46c125 --- /dev/null +++ b/src/resources/control/Debugging.java @@ -0,0 +1,39 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package resources.control; + +public class Debugging { + + /** Enables broadcaster stack traces */ + private static final boolean DEBUG_INTENT = true; + + public static boolean isIntentDebugging() { + return DEBUG_INTENT; + } + +} diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 0e3080549..7916ae2f7 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -132,11 +132,11 @@ public class CreatureObject extends TangibleObject { creo6.removeAppearanceItem(obj, this); } - public boolean addSkill(String skillName) { - synchronized(skills) { - Assert.test(skills.add(skillName)); + public void addSkill(String ... skillList) { + synchronized (skills) { + for (String skillName : skillList) + Assert.test(skills.add(skillName)); skills.sendDeltaMessage(this); - return true; } } diff --git a/src/resources/objects/creature/CreatureObjectClientServerNP.java b/src/resources/objects/creature/CreatureObjectClientServerNP.java index 424246879..d407cd3c4 100644 --- a/src/resources/objects/creature/CreatureObjectClientServerNP.java +++ b/src/resources/objects/creature/CreatureObjectClientServerNP.java @@ -191,15 +191,16 @@ class CreatureObjectClientServerNP implements Persistable { } } - public void addAbility(SWGObject target, String ... abilities) { - synchronized (this.abilities) { - for (String abilityName : abilities) { - if (hasAbility(abilityName)) - this.abilities.put(abilityName, this.abilities.get(abilityName) + 1); + public void addAbility(SWGObject target, String ... abilityList) { + synchronized (abilities) { + for (String abilityName : abilityList) { + Integer count = abilities.get(abilityName); + if (count != null) + abilities.put(abilityName, count + 1); else - this.abilities.put(abilityName, 1); + abilities.put(abilityName, 1); } - this.abilities.sendDeltaMessage(target); + abilities.sendDeltaMessage(target); } } diff --git a/src/services/experience/SkillManager.java b/src/services/experience/SkillManager.java index f77f00af9..46b74e481 100644 --- a/src/services/experience/SkillManager.java +++ b/src/services/experience/SkillManager.java @@ -141,7 +141,7 @@ public final class SkillManager extends Manager { } private void handleGrantSkillIntent(GrantSkillIntent intent) { - if (intent.getIntentType() == GrantSkillIntent.IntentType.GIVEN) { + if (intent.getIntentType() != GrantSkillIntent.IntentType.GRANT) { return; } @@ -157,7 +157,7 @@ public final class SkillManager extends Manager { Log.i(this, "%s lacks required skill %s before being granted skill %s", target, parentSkillName, skillName); return; } - + grantSkill(skillData, skillName, target); } @@ -165,25 +165,24 @@ public final class SkillManager extends Manager { Packet packet = gpi.getPacket(); if (packet instanceof ChangeRoleIconChoice) { ChangeRoleIconChoice iconChoice = (ChangeRoleIconChoice) packet; - int chosenIcon = iconChoice.getIconChoice(); - CreatureObject creatureObject = gpi.getPlayer().getCreatureObject(); - - changeRoleIcon(creatureObject, chosenIcon); + changeRoleIcon(gpi.getPlayer().getCreatureObject(), iconChoice.getIconChoice()); } } private boolean hasRequiredSkills(SkillData skillData, CreatureObject creatureObject) { String[] requiredSkills = skillData.getRequiredSkills(); - - if (requiredSkills == null) { + if (requiredSkills == null) return true; - } - return creatureObject.getSkills().containsAll(Arrays.stream(requiredSkills).collect(Collectors.toSet())); + for (String required : requiredSkills) { + if (!creatureObject.hasSkill(required)) + return false; + } + return true; } private void grantParentSkills(SkillData skillData, String parentSkill, CreatureObject target) { - if (skillData == null || parentSkill.isEmpty()) { + if (skillData == null || parentSkill.isEmpty() || target.hasSkill(parentSkill)) { return; } @@ -194,27 +193,18 @@ public final class SkillManager extends Manager { private void grantRequiredSkills(SkillData skillData, CreatureObject target) { String[] requiredSkills = skillData.getRequiredSkills(); - - if (requiredSkills == null) { + if (requiredSkills == null) return; - } - for (String requiredSkill : requiredSkills) - target.addSkill(requiredSkill); + target.addSkill(requiredSkills); } private void grantSkill(SkillData skillData, String skillName, CreatureObject target) { - Assert.test(target.addSkill(skillName)); - + target.addSkill(skillName); target.addAbility(skillData.getCommands()); skillData.getSkillMods().forEach((skillModName, skillModValue) -> new SkillModIntent(skillModName, 0, skillModValue, target).broadcast()); - // Ziggy: These are disabled for now, since we don't have the structs in place for it. -// for(String schematic : skillData.schematics) { - // Add schematic to PlayerObject -// } - new GrantSkillIntent(GrantSkillIntent.IntentType.GIVEN, skillName, target, false).broadcast(); } @@ -222,7 +212,7 @@ public final class SkillManager extends Manager { Set qualifyingSkills = roleIconMap.get(chosenIcon); if (qualifyingSkills != null) { - for(String qualifyingSkill : qualifyingSkills) { + for (String qualifyingSkill : qualifyingSkills) { if (creature.hasSkill(qualifyingSkill)) { PlayerObject playerObject = creature.getPlayerObject();