Java Code Examples for javolution.util.FastList#size()

The following examples show how to use javolution.util.FastList#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Storage.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
boolean decreaseByItemId(int itemId, long count, QuestStatus questStatus, Player actor) {
	FastList<Item> items = itemStorage.getItemsById(itemId);
	if (items.size() == 0) {
		return false;
	}

	for (Item item : items) {
		if (count == 0) {
			break;
		}
		count = decreaseItemCount(item, count, ItemUpdateType.DEC_ITEM_USE, questStatus, actor);
	}

	FastList.recycle(items);
	return count == 0;
}
 
Example 2
Source File: Storage.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public long getItemCountByItemId(int itemId) {
	FastList<Item> temp = this.itemStorage.getItemsById(itemId);
	if (temp.size() == 0) {
		return 0;
	}

	long cnt = 0;
	for (Item item : temp) {
		cnt += item.getItemCount();
	}

	return cnt;
}
 
Example 3
Source File: RewardService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void verify(Player player) {
	FastList<RewardEntryItem> list = dao.getAvailable(player.getObjectId());
	if (list.size() == 0 || player.getMailbox() == null) {
		return;
	}

	FastList<Integer> rewarded = FastList.newInstance();

	for (RewardEntryItem item : list) {
		if (DataManager.ITEM_DATA.getItemTemplate(item.id) == null) {
			log.warn("[RewardController][" + item.unique + "] null template for item " + item.id + " on player " + player.getObjectId() + ".");
			continue;
		}

		try {
			if (!SystemMailService.getInstance().sendMail("$$CASH_ITEM_MAIL", player.getName(), item.id + ", " + item.count, "0, " + (System.currentTimeMillis() / 1000) + ",", item.id, (int) item.count, 0, LetterType.BLACKCLOUD)) {
				continue;
			}
			log.info("[RewardController][" + item.unique + "] player " + player.getName() + " has received (" + item.count + ")" + item.id + ".");
			rewarded.add(item.unique);
		}
		catch (Exception e) {
			log.error("[RewardController][" + item.unique + "] failed to add item (" + item.count + ")" + item.id + " to " + player.getObjectId(), e);
			continue;
		}
	}

	if (rewarded.size() > 0) {
		dao.uncheckAvailable(rewarded);

		FastList.recycle(rewarded);
		FastList.recycle(list);
	}
}
 
Example 4
Source File: SM_UPDATE_PLAYER_APPEARANCE.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public SM_UPDATE_PLAYER_APPEARANCE(int playerId, FastList<Item> items) {
	this.playerId = playerId;
	this.items = items;
	this.size = items.size();
}
 
Example 5
Source File: BIHNode.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param col
 * @param results
 */
public final int intersectWhere(Collidable col, BoundingBox box, Matrix4f worldMatrix, BIHTree tree, CollisionResults results) {

	FastList<BIHStackData> stack = FastList.newInstance();

	float[] minExts = { box.getCenter().x - box.getXExtent(), box.getCenter().y - box.getYExtent(), box.getCenter().z - box.getZExtent() };

	float[] maxExts = { box.getCenter().x + box.getXExtent(), box.getCenter().y + box.getYExtent(), box.getCenter().z + box.getZExtent() };

	stack.add(new BIHStackData(this, 0, 0));

	Triangle t = new Triangle();
	int cols = 0;

	stackloop: while (stack.size() > 0) {
		BIHNode node = stack.remove(stack.size() - 1).node;

		while (node.axis != 3) {
			int a = node.axis;

			float maxExt = maxExts[a];
			float minExt = minExts[a];

			if (node.leftPlane < node.rightPlane) {
				// means there's a gap in the middle
				// if the box is in that gap, we stop there
				if (minExt > node.leftPlane && maxExt < node.rightPlane) {
					continue stackloop;
				}
			}

			if (maxExt < node.rightPlane) {
				node = node.left;
			}
			else if (minExt > node.leftPlane) {
				node = node.right;
			}
			else {
				stack.add(new BIHStackData(node.right, 0, 0));
				node = node.left;
			}
		}

		for (int i = node.leftIndex; i <= node.rightIndex; i++) {
			tree.getTriangle(i, t.get1(), t.get2(), t.get3());
			if (worldMatrix != null) {
				worldMatrix.mult(t.get1(), t.get1());
				worldMatrix.mult(t.get2(), t.get2());
				worldMatrix.mult(t.get3(), t.get3());
			}

			/*
			 * Original code had this int added = col.collideWith(t, results, 1); if (added > 0) { cols += added; }
			 */
		}
	}
	FastList.recycle(stack);
	return cols;
}
 
Example 6
Source File: BIHNode.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param sceneMin
 * @param sceneMax
 */
public final int intersectBrute(Ray r, Matrix4f worldMatrix, BIHTree tree, float sceneMin, float sceneMax, CollisionResults results) {
	float tHit = Float.POSITIVE_INFINITY;

	Vector3f v1 = new Vector3f(), v2 = new Vector3f(), v3 = new Vector3f();

	int cols = 0;

	FastList<BIHStackData> stack = FastList.newInstance();
	stack.clear();
	stack.add(new BIHStackData(this, 0, 0));
	while (stack.size() > 0) {

		BIHStackData data = stack.remove(stack.size() - 1);
		BIHNode node = data.node;

		while (node.axis != 3) { // while node is not a leaf
			BIHNode nearNode, farNode;
			nearNode = node.left;
			farNode = node.right;

			stack.add(new BIHStackData(farNode, 0, 0));
			node = nearNode;
		}

		// a leaf
		for (int i = node.leftIndex; i <= node.rightIndex; i++) {
			tree.getTriangle(i, v1, v2, v3);

			if (worldMatrix != null) {
				worldMatrix.mult(v1, v1);
				worldMatrix.mult(v2, v2);
				worldMatrix.mult(v3, v3);
			}

			float t = r.intersects(v1, v2, v3);
			if (t < tHit) {
				tHit = t;
				Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
				CollisionResult cr = new CollisionResult(contactPoint, tHit);
				results.addCollision(cr);
				cols++;
			}
		}
	}
	FastList.recycle(stack);
	return cols;
}