Merge branch 'quality_assurance' of bitbucket.org:projectswg/holocore into quality_assurance

This commit is contained in:
Obique PSWG
2016-10-31 09:50:15 -05:00
8 changed files with 88 additions and 9 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
function executeCommand(galacticManager, player, target, args) {
var ClientOpenContainerMessage = Java.type("network.packets.swg.zone.ClientOpenContainerMessage");
player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), args));
player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), ""));
}
@@ -114,6 +114,13 @@ public class TransferItemCallback implements ICmdCallback {
return;
}
}
// Check the players level, if they're too low of a level, don't allow them to wear it
short reqlevel = Short.parseShort(target.getAttribute("required_combat_level"));
if (actor.getLevel() < Short.parseShort(target.getAttribute("required_combat_level"))) {
new ChatBroadcastIntent(player, "@base_player:level_too_low").broadcast();
return;
}
switch (target.moveToContainer(actor, newContainer)) {
case SUCCESS:
@@ -0,0 +1,54 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package resources.containers;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
class AdminPermissions extends DefaultPermissions {
@Override
public boolean canView(SWGObject requester, SWGObject container) {
return isAdmin(requester);
}
@Override
public boolean canEnter(SWGObject requester, SWGObject container) {
return isAdmin(requester);
}
private boolean isAdmin(SWGObject requester) {
if (requester == null)
return false;
if (!(requester instanceof CreatureObject)) {
return false;
}
return ((CreatureObject) requester).hasAbility("admin");
}
}
@@ -31,7 +31,8 @@ import resources.objects.SWGObject;
public enum ContainerPermissionsType {
DEFAULT (new DefaultPermissions()),
INVENTORY (new InventoryPermissions());
INVENTORY (new InventoryPermissions()),
ADMIN (new AdminPermissions());
private final ContainerPermissions permissions;
+1 -2
View File
@@ -655,8 +655,7 @@ public abstract class SWGObject extends BaselineObject implements Comparable<SWG
public void createObject(SWGObject target, boolean ignoreSnapshotChecks) {
if (target == null)
return;
if (!target.isVisible(this)) {
Log.w(this, target + " doesn't have permission to view " + this + " -- skipping packet sending");
if (!isVisible(target)) {
return;
}
Set<Player> observers = target.getAwareness().getChildObservers();
+17
View File
@@ -218,6 +218,9 @@ public class CombatManager extends Manager {
CreatureObject source = intent.getSource();
SWGObject target = intent.getTarget();
// Regardless of HitType, the command might have action cost
addActionCost(source, c);
// TODO implement support for remaining HitTypes
switch (c.getHitType()) {
case ATTACK: handleAttack(source, target, c); break;
@@ -520,6 +523,20 @@ public class CombatManager extends Manager {
return CombatStatus.UNKNOWN;
}
private void addActionCost(CreatureObject source, CombatCommand command) {
double actionCost = command.getActionCost();
int currentAction = source.getAction();
if (actionCost <= 0 || actionCost > currentAction) {
return;
}
synchronized (regeneratingActionCreatures) {
source.setAction((int) (currentAction - actionCost));
regeneratingActionCreatures.add(source);
}
}
private int calculateWeaponDamage(CreatureObject source, CombatCommand command) {
WeaponObject weapon = source.getEquippedWeapon();
int minDamage = weapon.getMinDamage();
+4 -5
View File
@@ -311,7 +311,6 @@ public final class StaticItemService extends Service {
public final String getIffTemplate() {
return iffTemplate;
}
}
private static class WearableAttributes extends ObjectAttributes {
@@ -347,15 +346,15 @@ public final class StaticItemService extends Service {
} else {
requiredFaction = "@pvp_factions:" + requiredFaction;
}
// Load mods
String modsString = resultSet.getString("skill_mods");
// If this wearable is supposed to have mods, then load 'em!
mods = parseSkillMods(modsString);
String buffNameCell = resultSet.getString("buff_name");
if(!buffNameCell.equals("-")) {
buffName = "@ui_buff:" + buffNameCell;
}
@@ -368,7 +367,7 @@ public final class StaticItemService extends Service {
object.addAttribute("class_required", requiredProfession);
object.addAttribute("required_combat_level", requiredLevel);
object.addAttribute("faction_restriction", requiredFaction);
// Apply the mods!
for(Map.Entry<String, String> modEntry : mods.entrySet())
object.addAttribute(modEntry.getKey(), modEntry.getValue());
+2
View File
@@ -42,6 +42,7 @@ import resources.Location;
import resources.PvpFlag;
import resources.Terrain;
import resources.config.ConfigFile;
import resources.containers.ContainerPermissionsType;
import resources.control.Intent;
import resources.control.Service;
import resources.objects.building.BuildingObject;
@@ -203,6 +204,7 @@ public final class SpawnerService extends Service {
SpawnerType spawnerType = SpawnerType.valueOf(set.getString("spawner_type"));
SWGObject egg = ObjectCreator.createObjectFromTemplate(spawnerType.getObjectTemplate());
egg.setContainerPermissions(ContainerPermissionsType.ADMIN);
egg.setLocation(loc);
egg.moveToContainer(parent);
new ObjectCreatedIntent(egg).broadcast();