text:
package com.jagex.runescape;

/*
 * This file is part of the RuneScape client
 * revision 317, which was publicly released
 * on the 13th of June 2005.
 *
 * This file has been refactored in order to
 * restore readability to the codebase for
 * educational purposes, primarility to those
 * with an interest in game development.
 *
 * It may be a criminal offence to run this
 * file. This file is the intellectual property
 * of Jagex Ltd.
 */

/*
 * This file was renamed as part of the 317refactor project.
 */

final class Region {

	private static int randomiserHue = (int) (Math.random() * 17D) - 8;

	static int plane;

	private static int randomiserLightness = (int) (Math.random() * 33D) - 16;

	private static final int FACE_OFFSET_X[] = { 1, 0, -1, 0 };

	private static final int WALL_CORNER_ORIENTATION[] = { 16, 32, 64, 128 };

	private static final int FACE_OFFSET_Y[] = { 0, -1, 0, 1 };

	static int lowestPlane = 99;

	static boolean lowMemory = true;

	private static final int POWERS_OF_TWO[] = { 1, 2, 4, 8 };

	private final int[] blendedHue;

	private final int[] blendedSaturation;

	private final int[] blendedLightness;

	private final int[] blendedHueDivisor;

	private final int[] blendDirectionTracker;

	private final int[][][] vertexHeights;

	private final byte[][][] overlayFloorIds;

	private final byte[][][] tileShadowIntensity;

	private final int[][][] tileCullingBitsets;

	private final byte[][][] overlayClippingPaths;

	private final int[][] tileLightIntensity;

	private final byte[][][] underlayFloorIds;

	private final int regionSizeX;

	private final int regionSizeY;
	private final byte[][][] overlayOrientations;
	private final byte[][][] renderRuleFlags;

	public Region(byte renderRuleFlags[][][], int vertexHeights[][][]) {
		lowestPlane = 99;
		regionSizeX = 104;
		regionSizeY = 104;
		this.vertexHeights = vertexHeights;
		this.renderRuleFlags = renderRuleFlags;
		underlayFloorIds = new byte[4][regionSizeX][regionSizeY];
		overlayFloorIds = new byte[4][regionSizeX][regionSizeY];
		overlayClippingPaths = new byte[4][regionSizeX][regionSizeY];
		overlayOrientations = new byte[4][regionSizeX][regionSizeY];
		tileCullingBitsets = new int[4][regionSizeX + 1][regionSizeY + 1];
		tileShadowIntensity = new byte[4][regionSizeX + 1][regionSizeY + 1];
		tileLightIntensity = new int[regionSizeX + 1][regionSizeY + 1];
		blendedHue = new int[regionSizeY];
		blendedSaturation = new int[regionSizeY];
		blendedLightness = new int[regionSizeY];
		blendedHueDivisor = new int[regionSizeY];
		blendDirectionTracker = new int[regionSizeY];
	}

	public static void forceRenderObject(WorldController worldController, int face, int y, int type, int plane,
			CollisionMap collisionMap, int groundArray[][][], int x, int objectId, int z) {
		int vertexHeightSW = groundArray[plane][x][y];
		int vertexHeightSE = groundArray[plane][x + 1][y];
		int vertexHeightNE = groundArray[plane][x + 1][y + 1];
		int vertexHeightNW = groundArray[plane][x][y + 1];
		int drawHeight = vertexHeightSW + vertexHeightSE + vertexHeightNE + vertexHeightNW >> 2;
		GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId);
		int hash = x + (y << 7) + (objectId << 14) + 0x40000000;
		if (!definition.hasActions)
			hash += 0x80000000;
		byte config = (byte) ((face << 6) + type);
		if (type == 22) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(22, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 22, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addGroundDecoration(x, y, z, drawHeight, hash, ((animable)), config);
			if (definition.solid && definition.hasActions)
				collisionMap.markBlocked(x, y);
			return;
		}
		if (type == 10 || type == 11) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(10, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 10, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			if (animable != null) {
				int rotation = 0;
				if (type == 11)
					rotation += 256;
				int sizeX;
				int sizeY;
				if (face == 1 || face == 3) {
					sizeX = definition.sizeY;
					sizeY = definition.sizeX;
				} else {
					sizeX = definition.sizeX;
					sizeY = definition.sizeY;
				}
				worldController.addEntityB(x, y, z, drawHeight, rotation, sizeY, sizeX, hash, ((animable)), config);
			}
			if (definition.solid)
				collisionMap.markSolidOccupant(x, y, definition.sizeX, definition.sizeY, face, definition.walkable);
			return;
		}
		if (type >= 12) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, ((animable)), config);
			if (definition.solid)
				collisionMap.markSolidOccupant(x, y, definition.sizeX, definition.sizeY, face, definition.walkable);
			return;
		}
		if (type == 0) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(0, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 0, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallObject(x, y, z, drawHeight, POWERS_OF_TWO[face], 0, hash, ((animable)), null,
					config);
			if (definition.solid)
				collisionMap.markWall(y, face, x, type, definition.walkable);
			return;
		}
		if (type == 1) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(1, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 1, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallObject(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, ((animable)),
					null, config);
			if (definition.solid)
				collisionMap.markWall(y, face, x, type, definition.walkable);
			return;
		}
		if (type == 2) {
			int _face = face + 1 & 3;
			Animable animable1;
			Animable animable2;
			if (definition.animationId == -1 && definition.childIds == null) {
				animable1 = definition.getModelAt(2, 4 + face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
				animable2 = definition.getModelAt(2, _face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			} else {
				animable1 = new GameObject(objectId, 4 + face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
				animable2 = new GameObject(objectId, _face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			}
			worldController.addWallObject(x, y, z, drawHeight, POWERS_OF_TWO[face], POWERS_OF_TWO[_face], hash,
					((animable1)), ((animable2)), config);
			if (definition.solid)
				collisionMap.markWall(y, face, x, type, definition.walkable);
			return;
		}
		if (type == 3) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(3, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 3, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallObject(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, ((animable)),
					null, config);
			if (definition.solid)
				collisionMap.markWall(y, face, x, type, definition.walkable);
			return;
		}
		if (type == 9) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, ((animable)), config);
			if (definition.solid)
				collisionMap.markSolidOccupant(x, y, definition.sizeX, definition.sizeY, face, definition.walkable);
			return;
		}
		if (definition.adjustToTerrain)
			if (face == 1) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightNE;
				vertexHeightNE = vertexHeightSE;
				vertexHeightSE = vertexHeightSW;
				vertexHeightSW = temp;
			} else if (face == 2) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightSE;
				vertexHeightSE = temp;
				temp = vertexHeightNE;
				vertexHeightNE = vertexHeightSW;
				vertexHeightSW = temp;
			} else if (face == 3) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightSW;
				vertexHeightSW = vertexHeightSE;
				vertexHeightSE = vertexHeightNE;
				vertexHeightNE = temp;
			}
		if (type == 4) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
						-1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallDecoration(x, y, z, drawHeight, 0, 0, face * 512, hash, ((animable)), config,
					POWERS_OF_TWO[face]);
			return;
		}
		if (type == 5) {
			int offsetAmplifier = 16;
			int objectHash = worldController.getWallObjectHash(x, y, z);
			if (objectHash > 0)
				offsetAmplifier = GameObjectDefinition.getDefinition(objectHash >> 14 & 0x7fff).offsetAmplifier;
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
						-1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallDecoration(x, y, z, drawHeight, FACE_OFFSET_X[face] * offsetAmplifier,
					FACE_OFFSET_Y[face] * offsetAmplifier, face * 512, hash, ((animable)), config, POWERS_OF_TWO[face]);
			return;
		}
		if (type == 6) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
						-1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, ((animable)), config, 256);
			return;
		}
		if (type == 7) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
						-1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, ((animable)), config, 512);
			return;
		}
		if (type == 8) {
			Animable animable;
			if (definition.animationId == -1 && definition.childIds == null)
				animable = definition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
						-1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, definition.animationId, true);
			worldController.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, ((animable)), config, 768);
		}
	}

	public static boolean modelTypeCached(int objectId, int type) {
		GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId);
		if (type == 11)
			type = 10;
		if (type >= 5 && type <= 8)
			type = 4;
		return definition.modelTypeCached(type);
	}

	public static void passivelyRequestGameObjectModels(Buffer stream, OnDemandFetcher onDemandFetcher) {
		start: {
			int objectId = -1;
			do {
				int objectIdOffset = stream.getSmartB();
				if (objectIdOffset == 0)
					break start;
				objectId += objectIdOffset;
				GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId);
				definition.passivelyRequestModels(onDemandFetcher);
				do {
					int terminate = stream.getSmartB();
					if (terminate == 0)
						break;
					stream.getUnsignedByte();
				} while (true);
			} while (true);
		}
	}

	public static boolean regionCached(int regionX, int regionY, byte[] objectData) {
		boolean cached = true;
		Buffer objectDataStream = new Buffer(objectData);
		int objectId = -1;
		do {
			int objectIdIncrement = objectDataStream.getSmartB();
			if (objectIdIncrement == 0)
				break;
			objectId += objectIdIncrement;
			int pos = 0;
			boolean readSecondValue = false;
			do {
				if (readSecondValue) {
					int secondValue = objectDataStream.getSmartB();
					if (secondValue == 0)
						break;
					objectDataStream.getUnsignedByte();
				} else {
					int positionOffset = objectDataStream.getSmartB();
					if (positionOffset == 0)
						break;
					pos += positionOffset - 1;
					int regionOffsetY = pos & 0x3f;
					int regionOffsetX = pos >> 6 & 0x3f;
					int objectType = objectDataStream.getUnsignedByte() >> 2;
					int objectX = regionOffsetX + regionX;
					int objectY = regionOffsetY + regionY;
					if (objectX > 0 && objectY > 0 && objectX < 103 && objectY < 103) {
						GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId);
						if (objectType != 22 || !lowMemory || definition.hasActions || definition.unknownAttribute) {
							cached &= definition.modelCached();
							readSecondValue = true;
						}
					}
				}
			} while (true);
		} while (true);

		return cached;
	}

	private static int calculateNoise(int x, int seed) {
		int n = x + seed * 57;
		n = n << 13 ^ n;
		int noise = n * (n * n * 15731 + 0xc0ae5) + 0x5208dd0d & 0x7fffffff;
		return noise >> 19 & 0xff;
	}

	private static int calculateVertexHeight(int x, int y) {
		int vertexHeight = (method176(x + 45365, y + 0x16713, 4) - 128)
				+ (method176(x + 10294, y + 37821, 2) - 128 >> 1) + (method176(x, y, 1) - 128 >> 2);
		vertexHeight = (int) (vertexHeight * 0.29999999999999999D) + 35;
		if (vertexHeight < 10)
			vertexHeight = 10;
		else if (vertexHeight > 60)
			vertexHeight = 60;
		return vertexHeight;
	}

	private static int interpolate(int a, int b, int delta, int deltaScale) {
		int f = 0x10000 - Rasterizer.COSINE[(delta * 1024) / deltaScale] >> 1;
		return (a * (0x10000 - f) >> 16) + (b * f >> 16);
	}

	private static int method176(int deltaX, int deltaY, int deltaScale) {
		int x = deltaX / deltaScale;
		int deltaPrimary = deltaX & deltaScale - 1;
		int y = deltaY / deltaScale;
		int deltaSecondary = deltaY & deltaScale - 1;
		int noiseSW = randomNoiseWeighedSum(x, y);
		int noiseSE = randomNoiseWeighedSum(x + 1, y);
		int noiseNE = randomNoiseWeighedSum(x, y + 1);
		int noiseNW = randomNoiseWeighedSum(x + 1, y + 1);
		int interpolationA = interpolate(noiseSW, noiseSE, deltaPrimary, deltaScale);
		int interpolationB = interpolate(noiseNE, noiseNW, deltaPrimary, deltaScale);
		return interpolate(interpolationA, interpolationB, deltaSecondary, deltaScale);
	}

	private static int mixLightness(int hsl, int lightness) {
		if (hsl == -1)
			return 0xbc614e;
		lightness = (lightness * (hsl & 0x7f)) / 128;
		if (lightness < 2)
			lightness = 2;
		else if (lightness > 126)
			lightness = 126;
		return (hsl & 0xff80) + lightness;
	}

	private static int randomNoiseWeighedSum(int x, int y) {
		int vDist2 = calculateNoise(x - 1, y - 1) + calculateNoise(x + 1, y - 1) + calculateNoise(x - 1, y + 1)
				+ calculateNoise(x + 1, y + 1);
		int vDist1 = calculateNoise(x - 1, y) + calculateNoise(x + 1, y) + calculateNoise(x, y - 1)
				+ calculateNoise(x, y + 1);
		int vLocal = calculateNoise(x, y);
		return vDist2 / 16 + vDist1 / 8 + vLocal / 4;
	}

	public final void createRegion(CollisionMap collisionMap[], WorldController worldController) {
		for (int plane = 0; plane < 4; plane++) {
			for (int x = 0; x < 104; x++) {
				for (int y = 0; y < 104; y++) {
					if ((renderRuleFlags[plane][x][y] & 1) == 1) {
						int markingPlane = plane;
						if ((renderRuleFlags[1][x][y] & 2) == 2)
							markingPlane--;
						if (markingPlane >= 0)
							collisionMap[markingPlane].markBlocked(x, y);
					}
				}
			}
		}
		randomiserHue += (int) (Math.random() * 5D) - 2;
		if (randomiserHue < -8)
			randomiserHue = -8;
		if (randomiserHue > 8)
			randomiserHue = 8;
		randomiserLightness += (int) (Math.random() * 5D) - 2;
		if (randomiserLightness < -16)
			randomiserLightness = -16;
		if (randomiserLightness > 16)
			randomiserLightness = 16;
		for (int _plane = 0; _plane < 4; _plane++) {
			byte shadowIntensity[][] = tileShadowIntensity[_plane];
			int directionalLightIntensityInitial = 96;
			int specularDistributionFactor = 768;
			int directionalLightX = -50;
			int directionalLightZ = -10;
			int directionalLightY = -50;
			int directionalLightLength = (int) Math.sqrt(directionalLightX * directionalLightX
					+ directionalLightZ * directionalLightZ + directionalLightY * directionalLightY);
			int specularDistribution = specularDistributionFactor * directionalLightLength >> 8;
			for (int y = 1; y < regionSizeY - 1; y++) {
				for (int x = 1; x < regionSizeX - 1; x++) {
					int heightDifferenceX = vertexHeights[_plane][x + 1][y] - vertexHeights[_plane][x - 1][y];
					int heightDifferenceY = vertexHeights[_plane][x][y + 1] - vertexHeights[_plane][x][y - 1];
					int normalisedLength = (int) Math.sqrt(
							heightDifferenceX * heightDifferenceX + 0x10000 + heightDifferenceY * heightDifferenceY);
					int normalisedX = (heightDifferenceX << 8) / normalisedLength;
					int normalisedZ = 0x10000 / normalisedLength;
					int normalisedY = (heightDifferenceY << 8) / normalisedLength;
					int directionalLightIntensity = directionalLightIntensityInitial + (directionalLightX * normalisedX
							+ directionalLightZ * normalisedZ + directionalLightY * normalisedY) / specularDistribution;
					int weightedShadowIntensity = (shadowIntensity[x - 1][y] >> 2) + (shadowIntensity[x + 1][y] >> 3)
							+ (shadowIntensity[x][y - 1] >> 2) + (shadowIntensity[x][y + 1] >> 3)
							+ (shadowIntensity[x][y] >> 1);
					tileLightIntensity[x][y] = directionalLightIntensity - weightedShadowIntensity;
				}
			}

			for (int y = 0; y < regionSizeY; y++) {
				blendedHue[y] = 0;
				blendedSaturation[y] = 0;
				blendedLightness[y] = 0;
				blendedHueDivisor[y] = 0;
				blendDirectionTracker[y] = 0;
			}

			for (int x = -5; x < regionSizeX + 5; x++) {
				for (int y = 0; y < regionSizeY; y++) {
					int positiveX = x + 5;
					if (positiveX >= 0 && positiveX < regionSizeX) {
						int floorId = underlayFloorIds[_plane][positiveX][y] & 0xff;
						if (floorId > 0) {
							FloorDefinition definition = FloorDefinition.cache[floorId - 1];
							blendedHue[y] += definition.hue;
							blendedSaturation[y] += definition.saturation;
							blendedLightness[y] += definition.lightness;
							blendedHueDivisor[y] += definition.hueDivisor;
							blendDirectionTracker[y]++;
						}
					}
					int negativeX = x - 5;
					if (negativeX >= 0 && negativeX < regionSizeX) {
						int floorId = underlayFloorIds[_plane][negativeX][y] & 0xff;
						if (floorId > 0) {
							FloorDefinition definition = FloorDefinition.cache[floorId - 1];
							blendedHue[y] -= definition.hue;
							blendedSaturation[y] -= definition.saturation;
							blendedLightness[y] -= definition.lightness;
							blendedHueDivisor[y] -= definition.hueDivisor;
							blendDirectionTracker[y]--;
						}
					}
				}

				if (x >= 1 && x < regionSizeX - 1) {
					int hue = 0;
					int saturation = 0;
					int lightness = 0;
					int hueDivisor = 0;
					int direction = 0;
					for (int y = -5; y < regionSizeY + 5; y++) {
						int positiveY = y + 5;
						if (positiveY >= 0 && positiveY < regionSizeY) {
							hue += blendedHue[positiveY];
							saturation += blendedSaturation[positiveY];
							lightness += blendedLightness[positiveY];
							hueDivisor += blendedHueDivisor[positiveY];
							direction += blendDirectionTracker[positiveY];
						}
						int negativeY = y - 5;
						if (negativeY >= 0 && negativeY < regionSizeY) {
							hue -= blendedHue[negativeY];
							saturation -= blendedSaturation[negativeY];
							lightness -= blendedLightness[negativeY];
							hueDivisor -= blendedHueDivisor[negativeY];
							direction -= blendDirectionTracker[negativeY];
						}
						if (y >= 1 && y < regionSizeY - 1
								&& (!lowMemory || (renderRuleFlags[0][x][y] & 2) != 0
										|| (renderRuleFlags[_plane][x][y] & 0x10) == 0
												&& getVisibilityPlane(y, _plane, x) == plane)) {
							if (_plane < lowestPlane)
								lowestPlane = _plane;
							int underlayFloorId = underlayFloorIds[_plane][x][y] & 0xff;
							int overlayFloorId = overlayFloorIds[_plane][x][y] & 0xff;
							if (underlayFloorId > 0 || overlayFloorId > 0) {
								int vertexHeightSW = vertexHeights[_plane][x][y];
								int vertexHeightSE = vertexHeights[_plane][x + 1][y];
								int vertexHeightNE = vertexHeights[_plane][x + 1][y + 1];
								int vertexHeightNW = vertexHeights[_plane][x][y + 1];
								int lightIntensitySW = tileLightIntensity[x][y];
								int lightIntensitySE = tileLightIntensity[x + 1][y];
								int lightIntensityNE = tileLightIntensity[x + 1][y + 1];
								int lightIntensityNW = tileLightIntensity[x][y + 1];
								int hslBitsetOriginal = -1;
								int hslBitsetRandomised = -1;
								if (underlayFloorId > 0) {
									int h = (hue * 256) / hueDivisor;
									int s = saturation / direction;
									int l = lightness / direction;
									hslBitsetOriginal = generateHSLBitset(h, s, l);
									h = h + randomiserHue & 0xff;
									l += randomiserLightness;
									if (l < 0)
										l = 0;
									else if (l > 255)
										l = 255;
									hslBitsetRandomised = generateHSLBitset(h, s, l);
								}
								if (_plane > 0) {
									boolean hideUnderlay = true;
									if (underlayFloorId == 0 && overlayClippingPaths[_plane][x][y] != 0)
										hideUnderlay = false;
									if (overlayFloorId > 0 && !FloorDefinition.cache[overlayFloorId - 1].occlude)
										hideUnderlay = false;
									if (hideUnderlay && vertexHeightSW == vertexHeightSE
											&& vertexHeightSW == vertexHeightNE && vertexHeightSW == vertexHeightNW)
										tileCullingBitsets[_plane][x][y] |= 0x924;
								}
								int underlayMinimapColour = 0;
								if (hslBitsetOriginal != -1)
									underlayMinimapColour = Rasterizer.HSL_TO_RGB[mixLightness(hslBitsetRandomised,
											96)];
								if (overlayFloorId == 0) {
									worldController.renderTile(_plane, x, y, 0, 0, -1, vertexHeightSW, vertexHeightSE,
											vertexHeightNE, vertexHeightNW,
											mixLightness(hslBitsetOriginal, lightIntensitySW),
											mixLightness(hslBitsetOriginal, lightIntensitySE),
											mixLightness(hslBitsetOriginal, lightIntensityNE),
											mixLightness(hslBitsetOriginal, lightIntensityNW), 0, 0, 0, 0,
											underlayMinimapColour, 0);
								} else {
									int clippingPath = overlayClippingPaths[_plane][x][y] + 1;
									byte clippingPathRotation = overlayOrientations[_plane][x][y];
									FloorDefinition definition = FloorDefinition.cache[overlayFloorId - 1];
									int textureId = definition.textureId;
									int hslBitset;
									int overlayMinimapColour;
									if (textureId >= 0) {
										overlayMinimapColour = Rasterizer.getAverageTextureColour(textureId);
										hslBitset = -1;
									} else if (definition.rgbColour == 0xff00ff) {
										overlayMinimapColour = 0;
										hslBitset = -2;
										textureId = -1;
									} else {
										hslBitset = generateHSLBitset(definition.hue2, definition.saturation,
												definition.lightness);
										overlayMinimapColour = Rasterizer.HSL_TO_RGB[mixLightnessSigned(definition.hsl,
												96)];
									}
									worldController.renderTile(_plane, x, y, clippingPath, clippingPathRotation,
											textureId, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW,
											mixLightness(hslBitsetOriginal, lightIntensitySW),
											mixLightness(hslBitsetOriginal, lightIntensitySE),
											mixLightness(hslBitsetOriginal, lightIntensityNE),
											mixLightness(hslBitsetOriginal, lightIntensityNW),
											mixLightnessSigned(hslBitset, lightIntensitySW),
											mixLightnessSigned(hslBitset, lightIntensitySE),
											mixLightnessSigned(hslBitset, lightIntensityNE),
											mixLightnessSigned(hslBitset, lightIntensityNW), underlayMinimapColour,
											overlayMinimapColour);
								}
							}
						}
					}

				}
			}

			for (int y = 1; y < regionSizeY - 1; y++) {
				for (int x = 1; x < regionSizeX - 1; x++)
					worldController.setTileLogicHeight(x, y, _plane, getVisibilityPlane(y, _plane, x));

			}

		}

		worldController.shadeModels(-10, -50, -50);
		for (int x = 0; x < regionSizeX; x++) {
			for (int y = 0; y < regionSizeY; y++)
				if ((renderRuleFlags[1][x][y] & 2) == 2)
					worldController.applyBridgeMode(x, y);

		}

		int renderRule1 = 1;
		int renderRule2 = 2;
		int renderRule3 = 4;
		for (int plane = 0; plane < 4; plane++) {
			if (plane > 0) {
				renderRule1 <<= 3;
				renderRule2 <<= 3;
				renderRule3 <<= 3;
			}
			for (int _plane = 0; _plane <= plane; _plane++) {
				for (int y = 0; y <= regionSizeY; y++) {
					for (int x = 0; x <= regionSizeX; x++) {
						if ((tileCullingBitsets[_plane][x][y] & renderRule1) != 0) {
							int lowestOcclusionY = y;
							int highestOcclusionY = y;
							int lowestOcclusionPlane = _plane;
							int highestOcclusionPlane = _plane;
							for (; lowestOcclusionY > 0 && (tileCullingBitsets[_plane][x][lowestOcclusionY - 1]
									& renderRule1) != 0; lowestOcclusionY--)
								;
							for (; highestOcclusionY < regionSizeY
									&& (tileCullingBitsets[_plane][x][highestOcclusionY + 1]
											& renderRule1) != 0; highestOcclusionY++)
								;
							findLowestOcclusionPlane: for (; lowestOcclusionPlane > 0; lowestOcclusionPlane--) {
								for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
									if ((tileCullingBitsets[lowestOcclusionPlane - 1][x][occludedY] & renderRule1) == 0)
										break findLowestOcclusionPlane;

							}

							findHighestOcclusionPlane: for (; highestOcclusionPlane < plane; highestOcclusionPlane++) {
								for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
									if ((tileCullingBitsets[highestOcclusionPlane + 1][x][occludedY]
											& renderRule1) == 0)
										break findHighestOcclusionPlane;
							}

							int occlusionSurface = ((highestOcclusionPlane + 1) - lowestOcclusionPlane)
									* ((highestOcclusionY - lowestOcclusionY) + 1);
							if (occlusionSurface >= 8) {
								int highestOcclusionVertexHeightOffset = 240;
								int highestOcclusionVertexHeight = vertexHeights[highestOcclusionPlane][x][lowestOcclusionY]
										- highestOcclusionVertexHeightOffset;
								int lowestOcclusionVertexHeight = vertexHeights[lowestOcclusionPlane][x][lowestOcclusionY];
								WorldController.createCullingCluster(plane, x * 128, x * 128,
										highestOcclusionY * 128 + 128, lowestOcclusionY * 128,
										highestOcclusionVertexHeight, lowestOcclusionVertexHeight, 1);
								for (int occludedPlane = lowestOcclusionPlane; occludedPlane <= highestOcclusionPlane; occludedPlane++) {
									for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
										tileCullingBitsets[occludedPlane][x][occludedY] &= ~renderRule1;

								}

							}
						}

						if ((tileCullingBitsets[plane][x][y] & renderRule2) != 0) {
							int lowestOcclusionX = x;
							int highestOcclusionX = x;
							int lowestocclusionPlane = plane;
							int highestocclusionPlane = plane;
							for (; lowestOcclusionX > 0 && (tileCullingBitsets[plane][lowestOcclusionX - 1][y]
									& renderRule2) != 0; lowestOcclusionX--)
								;
							for (; highestOcclusionX < regionSizeX
									&& (tileCullingBitsets[plane][highestOcclusionX + 1][y]
											& renderRule2) != 0; highestOcclusionX++)
								;
							findLowestocclusionPlane: for (; lowestocclusionPlane > 0; lowestocclusionPlane--) {
								for (int occludedX = lowestOcclusionX; occludedX <= highestOcclusionX; occludedX++)
									if ((tileCullingBitsets[lowestocclusionPlane - 1][occludedX][y] & renderRule2) == 0)
										break findLowestocclusionPlane;
							}
							findHighestocclusionPlane: for (; highestocclusionPlane < plane; highestocclusionPlane++) {
								for (int occludedX = lowestOcclusionX; occludedX <= highestOcclusionX; occludedX++)
									if ((tileCullingBitsets[highestocclusionPlane + 1][occludedX][y]
											& renderRule2) == 0)
										break findHighestocclusionPlane;

							}

							int occlusionSurface = ((highestocclusionPlane + 1) - lowestocclusionPlane)
									* ((highestOcclusionX - lowestOcclusionX) + 1);
							if (occlusionSurface >= 8) {
								int highestOcclusionVertexHeightOffset = 240;
								int highestOcclusionVertexHeight = vertexHeights[highestocclusionPlane][lowestOcclusionX][y]
										- highestOcclusionVertexHeightOffset;
								int lowestOcclusionVertexHeight = vertexHeights[lowestocclusionPlane][lowestOcclusionX][y];
								WorldController.createCullingCluster(plane, highestOcclusionX * 128 + 128,
										lowestOcclusionX * 128, y * 128, y * 128, highestOcclusionVertexHeight,
										lowestOcclusionVertexHeight, 2);
								for (int occludedPlane = lowestocclusionPlane; occludedPlane <= highestocclusionPlane; occludedPlane++) {
									for (int occludedX = lowestOcclusionX; occludedX <= highestOcclusionX; occludedX++)
										tileCullingBitsets[occludedPlane][occludedX][y] &= ~renderRule2;

								}

							}
						}
						if ((tileCullingBitsets[plane][x][y] & renderRule3) != 0) {
							int lowestOcclusionX = x;
							int highestOcclusionX = x;
							int lowestOcclusionY = y;
							int highestOcclusionY = y;
							for (; lowestOcclusionY > 0 && (tileCullingBitsets[plane][x][lowestOcclusionY - 1]
									& renderRule3) != 0; lowestOcclusionY--)
								;
							for (; highestOcclusionY < regionSizeY
									&& (tileCullingBitsets[plane][x][highestOcclusionY + 1]
											& renderRule3) != 0; highestOcclusionY++)
								;
							findLowestOcclusionX: for (; lowestOcclusionX > 0; lowestOcclusionX--) {
								for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
									if ((tileCullingBitsets[plane][lowestOcclusionX - 1][occludedY] & renderRule3) == 0)
										break findLowestOcclusionX;

							}

							findHighestOcclusionX: for (; highestOcclusionX < regionSizeX; highestOcclusionX++) {
								for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
									if ((tileCullingBitsets[plane][highestOcclusionX + 1][occludedY]
											& renderRule3) == 0)
										break findHighestOcclusionX;

							}

							if (((highestOcclusionX - lowestOcclusionX) + 1)
									* ((highestOcclusionY - lowestOcclusionY) + 1) >= 4) {
								int lowestOcclusionVertexHeight = vertexHeights[plane][lowestOcclusionX][lowestOcclusionY];
								WorldController.createCullingCluster(plane, highestOcclusionX * 128 + 128,
										lowestOcclusionX * 128, highestOcclusionY * 128 + 128, lowestOcclusionY * 128,
										lowestOcclusionVertexHeight, lowestOcclusionVertexHeight, 4);
								for (int occludedX = lowestOcclusionX; occludedX <= highestOcclusionX; occludedX++) {
									for (int occludedY = lowestOcclusionY; occludedY <= highestOcclusionY; occludedY++)
										tileCullingBitsets[plane][occludedX][occludedY] &= ~renderRule3;

								}

							}

						}
					}

				}

			}

		}

	}

	public final void initiateVertexHeights(int startY, int countY, int countX, int startX) {
		for (int y = startY; y <= startY + countY; y++) {
			for (int x = startX; x <= startX + countX; x++)
				if (x >= 0 && x < regionSizeX && y >= 0 && y < regionSizeY) {
					tileShadowIntensity[0][x][y] = 127;
					if (x == startX && x > 0)
						vertexHeights[0][x][y] = vertexHeights[0][x - 1][y];
					if (x == startX + countX && x < regionSizeX - 1)
						vertexHeights[0][x][y] = vertexHeights[0][x + 1][y];
					if (y == startY && y > 0)
						vertexHeights[0][x][y] = vertexHeights[0][x][y - 1];
					if (y == startY + countY && y < regionSizeY - 1)
						vertexHeights[0][x][y] = vertexHeights[0][x][y + 1];
				}

		}
	}

	public final void loadObjectBlock(int blockX, CollisionMap collisionMap[], int blockY,
			WorldController worldController, byte blockData[]) {
		start: {
			Buffer stream = new Buffer(blockData);
			int objectId = -1;
			do {
				int objectIdOffset = stream.getSmartB();
				if (objectIdOffset == 0)
					break start;
				objectId += objectIdOffset;
				int position = 0;
				do {
					int positionOffset = stream.getSmartB();
					if (positionOffset == 0)
						break;
					position += positionOffset - 1;
					int tileY = position & 0x3f;
					int tileX = position >> 6 & 0x3f;
					int tilePlane = position >> 12;
					int hash = stream.getUnsignedByte();
					int type = hash >> 2;
					int orientation = hash & 3;
					int x = tileX + blockX;
					int y = tileY + blockY;
					if (x > 0 && y > 0 && x < 103 && y < 103) {
						int markingPlane = tilePlane;
						if ((renderRuleFlags[1][x][y] & 2) == 2)
							markingPlane--;
						CollisionMap collisionMap_ = null;
						if (markingPlane >= 0)
							collisionMap_ = collisionMap[markingPlane];
						renderObject(y, worldController, collisionMap_, type, tilePlane, x, objectId, orientation);
					}
				} while (true);
			} while (true);
		}
	}

	public final void loadObjectSubblock(CollisionMap collisionMap[], WorldController worldController, int i, int j,
			int k, int objectPlane, byte blockData[], int i1, int rotation, int k1) {
		start: {
			Buffer stream = new Buffer(blockData);
			int objectId = -1;
			do {
				int objectIdOffset = stream.getSmartB();
				if (objectIdOffset == 0)
					break start;
				objectId += objectIdOffset;
				int position = 0;
				do {
					int positionOffset = stream.getSmartB();
					if (positionOffset == 0)
						break;
					position += positionOffset - 1;
					int regionY = position & 0x3f;
					int regionX = position >> 6 & 0x3f;
					int plane = position >> 12;
					int hash = stream.getUnsignedByte();
					int type = hash >> 2;
					int orientation = hash & 3;
					if (plane == i && regionX >= i1 && regionX < i1 + 8 && regionY >= k && regionY < k + 8) {
						GameObjectDefinition objectDefinition = GameObjectDefinition.getDefinition(objectId);
						int x = j + TiledUtils.getRotatedLandscapeChunkX(rotation, objectDefinition.sizeY, regionX & 7,
								regionY & 7, objectDefinition.sizeX);
						int y = k1 + TiledUtils.getRotatedLandscapeChunkY(regionY & 7, objectDefinition.sizeY, rotation,
								objectDefinition.sizeX, regionX & 7);
						if (x > 0 && y > 0 && x < 103 && y < 103) {
							int markingPlane = plane;
							if ((renderRuleFlags[1][x][y] & 2) == 2)
								markingPlane--;
							CollisionMap collisionMap_ = null;
							if (markingPlane >= 0)
								collisionMap_ = collisionMap[markingPlane];
							renderObject(y, worldController, collisionMap_, type, objectPlane, x, objectId,
									orientation + rotation & 3);
						}
					}
				} while (true);
			} while (true);
		}
	}

	public final void loadTerrainBlock(byte blockData[], int blockY, int blockX, int k, int l,
			CollisionMap collisionMap[]) {
		for (int plane = 0; plane < 4; plane++) {
			for (int tileX = 0; tileX < 64; tileX++) {
				for (int tileY = 0; tileY < 64; tileY++)
					if (blockX + tileX > 0 && blockX + tileX < 103 && blockY + tileY > 0 && blockY + tileY < 103)
						collisionMap[plane].clippingData[blockX + tileX][blockY + tileY] &= 0xfeffffff;

			}

		}

		Buffer stream = new Buffer(blockData);
		for (int plane = 0; plane < 4; plane++) {
			for (int tileX = 0; tileX < 64; tileX++) {
				for (int tileY = 0; tileY < 64; tileY++)
					loadTerrainTile(tileY + blockY, l, stream, tileX + blockX, plane, 0, k);

			}

		}
	}

	public final void loadTerrainSubblock(int subBlockZ, int rotation, CollisionMap collisionMap[], int mapRegionX,
			int subBlockX, byte terrainData[], int subBlockY, int blockPlane, int mapRegionY) {
		for (int regionX = 0; regionX < 8; regionX++) {
			for (int regionY = 0; regionY < 8; regionY++)
				if (mapRegionX + regionX > 0 && mapRegionX + regionX < 103 && mapRegionY + regionY > 0
						&& mapRegionY + regionY < 103)
					collisionMap[blockPlane].clippingData[mapRegionX + regionX][mapRegionY + regionY] &= 0xfeffffff;

		}
		Buffer terrainDataStream = new Buffer(terrainData);
		for (int plane = 0; plane < 4; plane++) {
			for (int regionX = 0; regionX < 64; regionX++) {
				for (int regionY = 0; regionY < 64; regionY++)
					if (plane == subBlockZ && regionX >= subBlockX && regionX < subBlockX + 8 && regionY >= subBlockY
							&& regionY < subBlockY + 8)
						loadTerrainTile(mapRegionY + TiledUtils.getRotatedMapChunkY(regionY & 7, rotation, regionX & 7),
								0, terrainDataStream,
								mapRegionX + TiledUtils.getRotatedMapChunkX(rotation, regionY & 7, regionX & 7),
								blockPlane, rotation, 0);
					else
						loadTerrainTile(-1, 0, terrainDataStream, -1, 0, 0, 0);

			}
		}
	}

	private int generateHSLBitset(int h, int s, int l) {
		if (l > 179)
			s /= 2;
		if (l > 192)
			s /= 2;
		if (l > 217)
			s /= 2;
		if (l > 243)
			s /= 2;
		return (h / 4 << 10) + (s / 32 << 7) + l / 2;
	}

	private int getVisibilityPlane(int y, int plane, int x) {
		if ((renderRuleFlags[plane][x][y] & 8) != 0)
			return 0;
		if (plane > 0 && (renderRuleFlags[1][x][y] & 2) != 0)
			return plane - 1;
		else
			return plane;
	}

	private void loadTerrainTile(int tileY, int offsetY, Buffer stream, int tileX, int tileZ, int i1, int offsetX) {
		if (tileX >= 0 && tileX < 104 && tileY >= 0 && tileY < 104) {
			renderRuleFlags[tileZ][tileX][tileY] = 0;
			do {
				int value = stream.getUnsignedByte();
				if (value == 0)
					if (tileZ == 0) {
						vertexHeights[0][tileX][tileY] = -calculateVertexHeight(0xe3b7b + tileX + offsetX,
								0x87cce + tileY + offsetY) * 8;
						return;
					} else {
						vertexHeights[tileZ][tileX][tileY] = vertexHeights[tileZ - 1][tileX][tileY] - 240;
						return;
					}
				if (value == 1) {
					int height = stream.getUnsignedByte();
					if (height == 1)
						height = 0;
					if (tileZ == 0) {
						vertexHeights[0][tileX][tileY] = -height * 8;
						return;
					} else {
						vertexHeights[tileZ][tileX][tileY] = vertexHeights[tileZ - 1][tileX][tileY] - height * 8;
						return;
					}
				}
				if (value <= 49) {
					overlayFloorIds[tileZ][tileX][tileY] = stream.get();
					overlayClippingPaths[tileZ][tileX][tileY] = (byte) ((value - 2) / 4);
					overlayOrientations[tileZ][tileX][tileY] = (byte) ((value - 2) + i1 & 3);
				} else if (value <= 81)
					renderRuleFlags[tileZ][tileX][tileY] = (byte) (value - 49);
				else
					underlayFloorIds[tileZ][tileX][tileY] = (byte) (value - 81);
			} while (true);
		}
		do {
			int value = stream.getUnsignedByte();
			if (value == 0)
				break;
			if (value == 1) {
				stream.getUnsignedByte();
				return;
			}
			if (value <= 49)
				stream.getUnsignedByte();
		} while (true);
	}

	private int mixLightnessSigned(int hsl, int lightness) {
		if (hsl == -2)
			return 0xbc614e;
		if (hsl == -1) {
			if (lightness < 0)
				lightness = 0;
			else if (lightness > 127)
				lightness = 127;
			lightness = 127 - lightness;
			return lightness;
		}
		lightness = (lightness * (hsl & 0x7f)) / 128;
		if (lightness < 2)
			lightness = 2;
		else if (lightness > 126)
			lightness = 126;
		return (hsl & 0xff80) + lightness;
	}

	private void renderObject(int y, WorldController worldController, CollisionMap collisionMap, int type, int plane,
			int x, int objectId, int face) {
		if (lowMemory && (renderRuleFlags[0][x][y] & 2) == 0) {
			if ((renderRuleFlags[plane][x][y] & 0x10) != 0)
				return;
			if (getVisibilityPlane(y, plane, x) != Region.plane)
				return;
		}
		if (plane < lowestPlane)
			lowestPlane = plane;
		int vertexHeightSW = vertexHeights[plane][x][y];
		int vertexHeightSE = vertexHeights[plane][x + 1][y];
		int vertexHeightNE = vertexHeights[plane][x + 1][y + 1];
		int vertexHeightNW = vertexHeights[plane][x][y + 1];
		int drawHeight = vertexHeightSW + vertexHeightSE + vertexHeightNE + vertexHeightNW >> 2;
		GameObjectDefinition objectDefinition = GameObjectDefinition.getDefinition(objectId);
		int hash = x + (y << 7) + (objectId << 14) + 0x40000000;
		if (!objectDefinition.hasActions)
			hash += 0x80000000;
		byte config = (byte) ((face << 6) + type);
		if (type == 22) {
			if (lowMemory && !objectDefinition.hasActions && !objectDefinition.unknownAttribute)
				return;
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(22, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 22, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addGroundDecoration(x, y, plane, drawHeight, hash, ((animable)), config);
			if (objectDefinition.solid && objectDefinition.hasActions && collisionMap != null)
				collisionMap.markBlocked(x, y);
			return;
		}
		if (type == 10 || type == 11) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(10, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 10, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			if (animable != null) {
				int rotation = 0;
				if (type == 11)
					rotation += 256;
				int sizeX;
				int sizeY;
				if (face == 1 || face == 3) {
					sizeX = objectDefinition.sizeY;
					sizeY = objectDefinition.sizeX;
				} else {
					sizeX = objectDefinition.sizeX;
					sizeY = objectDefinition.sizeY;
				}
				if (worldController.addEntityB(x, y, plane, drawHeight, rotation, sizeY, sizeX, hash, ((animable)),
						config) && objectDefinition.castsShadow) {
					Model model;
					if (animable instanceof Model)
						model = (Model) animable;
					else
						model = objectDefinition.getModelAt(10, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
								vertexHeightNW, -1);
					if (model != null) {
						for (int _x = 0; _x <= sizeX; _x++) {
							for (int _y = 0; _y <= sizeY; _y++) {
								int intensity = model.diagonal2DAboveOrigin / 4;
								if (intensity > 30)
									intensity = 30;
								if (intensity > tileShadowIntensity[plane][x + _x][y + _y])
									tileShadowIntensity[plane][x + _x][y + _y] = (byte) intensity;
							}

						}

					}
				}
			}
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markSolidOccupant(x, y, objectDefinition.sizeX, objectDefinition.sizeY, face,
						objectDefinition.walkable);
			return;
		}
		if (type >= 12) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addEntityB(x, y, plane, drawHeight, 0, 1, 1, hash, ((animable)), config);
			if (type >= 12 && type <= 17 && type != 13 && plane > 0)
				tileCullingBitsets[plane][x][y] |= 0x924;
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markSolidOccupant(x, y, objectDefinition.sizeX, objectDefinition.sizeY, face,
						objectDefinition.walkable);
			return;
		}
		if (type == 0) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(0, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 0, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallObject(x, y, plane, drawHeight, POWERS_OF_TWO[face], 0, hash, ((animable)), null,
					config);
			if (face == 0) {
				if (objectDefinition.castsShadow) {
					tileShadowIntensity[plane][x][y] = 50;
					tileShadowIntensity[plane][x][y + 1] = 50;
				}
				if (objectDefinition.wall)
					tileCullingBitsets[plane][x][y] |= 0x249;
			} else if (face == 1) {
				if (objectDefinition.castsShadow) {
					tileShadowIntensity[plane][x][y + 1] = 50;
					tileShadowIntensity[plane][x + 1][y + 1] = 50;
				}
				if (objectDefinition.wall)
					tileCullingBitsets[plane][x][y + 1] |= 0x492;
			} else if (face == 2) {
				if (objectDefinition.castsShadow) {
					tileShadowIntensity[plane][x + 1][y] = 50;
					tileShadowIntensity[plane][x + 1][y + 1] = 50;
				}
				if (objectDefinition.wall)
					tileCullingBitsets[plane][x + 1][y] |= 0x249;
			} else if (face == 3) {
				if (objectDefinition.castsShadow) {
					tileShadowIntensity[plane][x][y] = 50;
					tileShadowIntensity[plane][x + 1][y] = 50;
				}
				if (objectDefinition.wall)
					tileCullingBitsets[plane][x][y] |= 0x492;
			}
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markWall(y, face, x, type, objectDefinition.walkable);
			if (objectDefinition.offsetAmplifier != 16)
				worldController.method290(y, objectDefinition.offsetAmplifier, x, plane);
			return;
		}
		if (type == 1) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(1, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 1, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallObject(x, y, plane, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, ((animable)),
					null, config);
			if (objectDefinition.castsShadow)
				if (face == 0)
					tileShadowIntensity[plane][x][y + 1] = 50;
				else if (face == 1)
					tileShadowIntensity[plane][x + 1][y + 1] = 50;
				else if (face == 2)
					tileShadowIntensity[plane][x + 1][y] = 50;
				else if (face == 3)
					tileShadowIntensity[plane][x][y] = 50;
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markWall(y, face, x, type, objectDefinition.walkable);
			return;
		}
		if (type == 2) {
			int orientation = face + 1 & 3;
			Animable animable1;
			Animable animable2;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null) {
				animable1 = objectDefinition.getModelAt(2, 4 + face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
				animable2 = objectDefinition.getModelAt(2, orientation, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			} else {
				animable1 = new GameObject(objectId, 4 + face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
				animable2 = new GameObject(objectId, orientation, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			}
			worldController.addWallObject(x, y, plane, drawHeight, POWERS_OF_TWO[face], POWERS_OF_TWO[orientation],
					hash, ((animable1)), ((animable2)), config);
			if (objectDefinition.wall)
				if (face == 0) {
					tileCullingBitsets[plane][x][y] |= 0x249;
					tileCullingBitsets[plane][x][y + 1] |= 0x492;
				} else if (face == 1) {
					tileCullingBitsets[plane][x][y + 1] |= 0x492;
					tileCullingBitsets[plane][x + 1][y] |= 0x249;
				} else if (face == 2) {
					tileCullingBitsets[plane][x + 1][y] |= 0x249;
					tileCullingBitsets[plane][x][y] |= 0x492;
				} else if (face == 3) {
					tileCullingBitsets[plane][x][y] |= 0x492;
					tileCullingBitsets[plane][x][y] |= 0x249;
				}
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markWall(y, face, x, type, objectDefinition.walkable);
			if (objectDefinition.offsetAmplifier != 16)
				worldController.method290(y, objectDefinition.offsetAmplifier, x, plane);
			return;
		}
		if (type == 3) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(3, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, 3, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallObject(x, y, plane, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, ((animable)),
					null, config);
			if (objectDefinition.castsShadow)
				if (face == 0)
					tileShadowIntensity[plane][x][y + 1] = 50;
				else if (face == 1)
					tileShadowIntensity[plane][x + 1][y + 1] = 50;
				else if (face == 2)
					tileShadowIntensity[plane][x + 1][y] = 50;
				else if (face == 3)
					tileShadowIntensity[plane][x][y] = 50;
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markWall(y, face, x, type, objectDefinition.walkable);
			return;
		}
		if (type == 9) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addEntityB(x, y, plane, drawHeight, 0, 1, 1, hash, ((animable)), config);
			if (objectDefinition.solid && collisionMap != null)
				collisionMap.markSolidOccupant(x, y, objectDefinition.sizeX, objectDefinition.sizeY, face,
						objectDefinition.walkable);
			return;
		}
		if (objectDefinition.adjustToTerrain)
			if (face == 1) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightNE;
				vertexHeightNE = vertexHeightSE;
				vertexHeightSE = vertexHeightSW;
				vertexHeightSW = temp;
			} else if (face == 2) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightSE;
				vertexHeightSE = temp;
				temp = vertexHeightNE;
				vertexHeightNE = vertexHeightSW;
				vertexHeightSW = temp;
			} else if (face == 3) {
				int temp = vertexHeightNW;
				vertexHeightNW = vertexHeightSW;
				vertexHeightSW = vertexHeightSE;
				vertexHeightSE = vertexHeightNE;
				vertexHeightNE = temp;
			}
		if (type == 4) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallDecoration(x, y, plane, drawHeight, 0, 0, face * 512, hash, ((animable)), config,
					POWERS_OF_TWO[face]);
			return;
		}
		if (type == 5) {
			int offsetAmplifier = 16;
			int hash_ = worldController.getWallObjectHash(x, y, plane);
			if (hash_ > 0)
				offsetAmplifier = GameObjectDefinition.getDefinition(hash_ >> 14 & 0x7fff).offsetAmplifier;
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallDecoration(x, y, plane, drawHeight, FACE_OFFSET_X[face] * offsetAmplifier,
					FACE_OFFSET_Y[face] * offsetAmplifier, face * 512, hash, ((animable)), config, POWERS_OF_TWO[face]);
			return;
		}
		if (type == 6) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallDecoration(x, y, plane, drawHeight, 0, 0, face, hash, ((animable)), config, 256);
			return;
		}
		if (type == 7) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallDecoration(x, y, plane, drawHeight, 0, 0, face, hash, ((animable)), config, 512);
			return;
		}
		if (type == 8) {
			Animable animable;
			if (objectDefinition.animationId == -1 && objectDefinition.childIds == null)
				animable = objectDefinition.getModelAt(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE,
						vertexHeightNW, -1);
			else
				animable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW,
						vertexHeightNW, objectDefinition.animationId, true);
			worldController.addWallDecoration(x, y, plane, drawHeight, 0, 0, face, hash, ((animable)), config, 768);
		}
	}

}


text:
import { colors, themeManager, getMuiTheme } from 'material-ui/styles';
import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import { defaultsDeep as deep } from 'lodash';

export let NIGHT  = deep( {
	palette: {
		primary1Color: '#223E77',
		textColor: colors.blueGrey200,
		alternateTextColor: colors.lightBlue50,
		primary2Color: '#3B71E2',
		canvasColor: '#303234',
		accent1Color: colors.blueGrey50,
		accent2Color: colors.blueGrey400,
		accent3Color: "#FA905C",
		disabledColor: colors.grey600,
	},
	appBar: {
		buttonColor: colors.blueGrey200
	},
}, darkBaseTheme);

export let LIGHT  = deep( {
	palette: {
		primary1Color: '#FFFFFF',
		textColor: colors.blueGrey600,
		alternateTextColor: colors.blueGrey600,
		primary2Color: '#3B71E2',
		canvasColor: '#FFFFFF',
		accent1Color: colors.blueGrey50,
		accent2Color: colors.blueGrey500,
		accent3Color: "#FA905C",
		disabledColor: colors.grey600,
	}
}, lightBaseTheme);

export let CREAM  = deep( {
	palette: {
		primary1Color: 'initial',
		primary2Color: colors.lightBlue700,
		textColor: colors.grey700,
		accent1Color: colors.blueGrey50,
		accent2Color: colors.blueGrey500,
		accent3Color: colors.lightBlack,
		alternateTextColor: colors.blueGrey600,
	}
}, lightBaseTheme);

export let GRAPHITE  = deep( {
	palette: {
		primary1Color: 'initial',
		primary2Color: colors.lightBlue700,
		textColor: colors.blueGrey200,
		accent1Color: colors.blueGrey50,
		accent2Color: colors.blueGrey400,
		accent3Color: "#FA905C",
		alternateTextColor: colors.blueGrey200,
	},
	appBar: {
		textColor: colors.blueGrey200,
		buttonColor: colors.blueGrey400
	},
}, darkBaseTheme);

export let BLUE  = deep( {
	palette: {
		primary1Color: '#0C87C1',
		textColor: colors.blueGrey700,
		alternateTextColor: '#fff',
	},
	appBar: {
		textColor: '#fff',
		buttonColor: '#bbb'
	}
}, lightBaseTheme);

export let DEFAULT  = lightBaseTheme;

export let DARK  = darkBaseTheme;

export let Styles = {
	Colors: colors,
	getMuiTheme: getMuiTheme,
	ThemeManager: themeManager,
	DarkRawTheme: darkBaseTheme,
	LightRawTheme: lightBaseTheme,
	DARK,
	DEFAULT,
	BLUE,
	GRAPHITE,
	LIGHT,
	NIGHT,
	CREAM
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Modules\Necrolab\Controllers\Api\Players\Player\Leaderboards\Daily;

use \Modules\Necrolab\Controllers\Api\Necrolab;
use \Modules\Necrolab\Models\Leaderboards\Database\Leaderboards as LeaderboardsModel;

class Daily
extends Necrolab {
    public function init() {
        $this->cached_response_prefix_name = "player:leaderboards:daily";

        $this->setSteamidFromRequest();

        $this->setReleaseFromRequest();

        $this->setModeFromRequest();
    }

    protected function getResultSet() {
        return LeaderboardsModel::getSteamUserDailyDatesResultset($this->steamid, $this->release_id, $this->mode_id);
    }

    public function formatResponse($data) {
        $processed_data = array();

        if(!empty($data)) {
            $processed_data = array_column($data, 'daily_date');

            rsort($processed_data);
        }

        return $processed_data;
    }
}


text:
# JSDocParser
Lightweight simple JSDoc documentation parser for .NET

Purpose: Read javascript files and parse JSDoc style documentation (within code), available in a .NET (C# project).

# Quick mini-doc (before doing it for real)
```C#
var js = new JSDocParser();
var parsed = js.Parse("test1.js");
```

This js code:
```javascript
/**
 * createTile
 *
 * @param {string} text Text to display on the tile.
 * @param {float} durationSeconds Duration to display the tile, in seconds. Defaults to 10.
 *
 */

function createTile(text, durationSeconds = 10) {
...
}
```
would result in this result from js.Parse(...):

```C#
parsed.Function.Count == 1
parsed.Function[0].Name == "createTile"
parsed.Function[0].Parameters.Count == 2
parsed.Function[0].Parameters[0].Name == "text"
parsed.Function[0].Parameters[0].Type == "string"
parsed.Function[0].Parameters[0].Description == "Text to display on the tile."
parsed.Function[0].Parameters[1].Default == "10" //retrieved from signature line, not from docs
```


text:
package com.blazebit.persistence.view.filter;

import com.blazebit.persistence.view.AttributeFilter;
import com.blazebit.persistence.view.AttributeFilterProvider;
import com.blazebit.persistence.view.SubqueryProvider;

/**
 * A placeholder for a filter implementation that implements a less than filter.
 * This placeholder can be used in a {@link AttributeFilter} annotation.
 *
 * A less than filter accepts a class and an object. The class is interpreted as the expected type. This is used to convert the
 * object parameter. The following conversion are done based on the expected type in the right order.
 *
 *

 *
If the value is a {@link SubqueryProvider}, the filter will create a subquery restriction.

 *
If the value is an instance of the expected type, the value will be used in the restriction as is.

 *
If the parsing of the {@linkplain Object#toString()} representation of the object to the expected type is successful,
 * the parsed value will be used in the restriction.

 *
If the parsing of the object fails, an {@link IllegalArgumentException} is thrown.

 *

 *
 * @param <FilterValue> The type of the filter value i.e. the attribute type
 * @author Christian Beikov
 * @since 1.0.0
 */
public abstract class LessThanFilter<FilterValue> extends AttributeFilterProvider<FilterValue> {

}


text:
import Vue, { PluginFunction, VueConstructor } from 'vue'

declare class DynamicSelect {
  focus(): void
  static install: PluginFunction<never>;
}

declare module 'vue/types/vue' {
  interface Vue {
    /**
     * Global attribute for DynamicSelect
     */
    $dynamicSelect: DynamicSelect
  }

  interface VueConstructor {
    /**
     * Global attribute for DynamicSelect
     */
    $dynamicSelect: DynamicSelect
  }
}

declare module 'vue/types/options' {
  interface ComponentOptions<V extends Vue> {
      $dynamicSelect?: DynamicSelect;
  }
}

export default DynamicSelect


text:
<!DOCTYPE html>

		<title>Star wars</title>
    !<meta charset="UTF-8">
		<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />

<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/styles1.css">

 - preparez-vous Jedi -

Le Prochain combat va bientôt commencer

Partager cette expérience

Tweet

Gallery

équipe


text:
namespace Gu.Reactive.Demo
{
    public class CanStart : AndCondition
    {
        public CanStart()
#pragma warning disable IDISP004 // Don't ignore created IDisposable.
            : base(new IsAnyDoorOpen().Negate(), new HasFuel(), new IsMotorRunning().Negate())
#pragma warning restore IDISP004 // Don't ignore created IDisposable.
        {
        }
    }
}


text:
package net.stack3.listviewsample.customlistitem;

import java.util.ArrayList;

import net.stack3.listviewsample.R;
import net.stack3.listviewsample.model.CustomListItem;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

public class CustomListItemActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_list_view_activity);
        setTitle("CustomListItem");

        ArrayList<CustomListItem> items = new ArrayList<CustomListItem>();
        for (int i = 0; i < 100; i++) {
            CustomListItem item = new CustomListItem();
            item.setTitle(String.format("Item %d", i));
            item.setDescription(String.format("Description %d", i));
            items.add(item);
        }

        CustomListItemAdapter adapter = new CustomListItemAdapter(this, items);
        ListView listView = (ListView)findViewById(R.id.listView);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(onItemClickListener);
    }

    private AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CustomListItem item = (CustomListItem)parent.getAdapter().getItem(position);
            Log.d(getClass().getName(), item.toString());
        }
    };
}


text:
using System.Threading;
using System.Threading.Tasks;
using GogoKit.Models.Request;
using GogoKit.Models.Response;

namespace GogoKit.Clients
{
    public interface IUserClient
    {
        Task<User> GetAsync();
        Task<User> GetAsync(UserRequest request);
        Task<User> GetAsync(UserRequest request, CancellationToken cancellationToken);
        Task<User> UpdateAsync(UserUpdate userUpdate);
    }
}


text:
// Copyright 2011 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview A wrapper for the HTML5 FileWriter object.
 *
 * When adding or modifying functionality in this namespace, be sure to update
 * the mock counterparts in goog.testing.fs.
 *
 */

goog.provide('goog.fs.FileWriter');

goog.require('goog.fs.Error');
goog.require('goog.fs.FileSaver');

/**
 * An object for monitoring the saving of files, as well as other fine-grained
 * writing operations.
 *
 * This should not be instantiated directly. Instead, it should be accessed via
 * {@link goog.fs.FileEntry#createWriter}.
 *
 * @param {!FileWriter} writer The underlying FileWriter object.
 * @constructor
 * @extends {goog.fs.FileSaver}
 * @final
 */
goog.fs.FileWriter = function(writer) {
  goog.base(this, writer);

  /**
   * The underlying FileWriter object.
   *
   * @type {!FileWriter}
   * @private
   */
  this.writer_ = writer;
};
goog.inherits(goog.fs.FileWriter, goog.fs.FileSaver);

/**
 * @return {number} The byte offset at which the next write will occur.
 */
goog.fs.FileWriter.prototype.getPosition = function() {
  return this.writer_.position;
};

/**
 * @return {number} The length of the file.
 */
goog.fs.FileWriter.prototype.getLength = function() {
  return this.writer_.length;
};

/**
 * Write data to the file.
 *
 * @param {!Blob} blob The data to write.
 */
goog.fs.FileWriter.prototype.write = function(blob) {
  try {
    this.writer_.write(blob);
  } catch (e) {
    throw new goog.fs.Error(e.code, 'writing file');
  }
};

/**
 * Set the file position at which the next write will occur.
 *
 * @param {number} offset An absolute byte offset into the file.
 */
goog.fs.FileWriter.prototype.seek = function(offset) {
  try {
    this.writer_.seek(offset);
  } catch (e) {
    throw new goog.fs.Error(e.code, 'seeking in file');
  }
};

/**
 * Changes the length of the file to that specified.
 *
 * @param {number} size The new size of the file, in bytes.
 */
goog.fs.FileWriter.prototype.truncate = function(size) {
  try {
    this.writer_.truncate(size);
  } catch (e) {
    throw new goog.fs.Error(e.code, 'truncating file');
  }
};


text:
import { object } from "klassified";

/**
 * Route match result are used as the answer of matching a url against a route.
 *
 * @param {{}} [spec]
 * @param {{}} spec.url Matched URL
 * @param {{}} spec.route Matched Route
 * @param {{}} spec.values Hash with matched parameter names as keys and matching url segment values.
 *
 * @returns {routeMatchResult}
 */
var routeMatchResult = object.subclass(function(that, my) {

	var url;
	var route;
	var urlParameters;
	var routeParameters;
	var parameters;

	my.initialize = function(spec) {
		my.super(spec);
		url = spec.url;
		route = spec.route;

		urlParameters = (url && url.getQuery && url.getQuery()) || {};
		routeParameters = spec.values || {};
		parameters = mergeParameters(routeParameters, urlParameters);
	};

	//
	// Public
	//

	/**
	 * Matched route
	 *
	 * @returns {route}
	 */
	that.getRoute = function() {
		return route;
	};

	/**
	 * Matched URL
	 *
	 * @returns {url}
	 */
	that.getUrl = function() {
		return url;
	};

	/**
	 * Answers true if route match URL
	 *
	 * @returns {boolean}
	 */
	that.isMatch = function() {
		return true;
	};

	/**
	 * Values for parameters in route
	 *
	 * @returns {{}}
	 */
	that.getRouteParameters = function() {
		return routeParameters;
	};

	/**
	 * Values for parameters in query
	 *
	 * @returns {{}}
	 */
	that.getQueryParameters = function() {
		return url.getQuery();
	};

	/**
	 * All matched parameters
	 *
	 * @returns {{}}
	 */
	that.getParameters = function() {
		return parameters;
	};

	/**
	 * Constructs an array with all parameters in same order as in route pattern with
	 * query parameter as the last value.
	 *
	 * @returns {Array}
	 */
	that.getActionArguments = function() {
		var actionArguments = Object.keys(routeParameters).map(function(parameterName) {
			return routeParameters[parameterName];
		});
		actionArguments.push(url.getQuery());
		return actionArguments;
	};

	//
	// Private
	//

	function mergeParameters(routeParameters, queryParameters) {
		var allValues = {};

		// Fill with route parameters
		for (var parameterName in routeParameters) {
			if (Object.prototype.hasOwnProperty.call(routeParameters, parameterName)) {
				allValues[parameterName] = routeParameters[parameterName];
			}
		}

		// Fill with query parameters
		for (var queryParameterName in queryParameters) {
			if (Object.prototype.hasOwnProperty.call(queryParameters, queryParameterName)) {
				allValues[queryParameterName] = queryParameters[queryParameterName];
			}
		}

		return allValues;

	}
});

routeMatchResult.class(function(that) {

	/**
	 * Result to use when match does not match url
	 */
	that.routeNoMatchResult = (function() {

		/** @typedef {routeMatchResult} routeNoMatchResult */
		var instance = that();

		instance.isMatch = function() {
			return false;
		};

		return instance;
	})();
});

export default routeMatchResult;


text:
<!---
Copyright 2017 The AMP HTML Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# 24smi

Provides support for [24smi](https://partner.24smi.info/) widgets.

## Example

```html
<amp-embed width="250" height="250"
    type="24smi"
    src="https://jsn.24smi.net/c/2/11232.js">
</amp-embed>
```

## Configuration

For details on the configuration semantics, please contact [24smi](https://partner.24smi.info).

### Required parameters

- `src`


text:
// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit)
// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus
// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues
// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE
// More projects: http://www.zzzprojects.com/
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Z.EntityFramework.Plus;

namespace Z.Test.EntityFramework.Plus
{
    public partial class QueryCache_CacheKey
    {
        [TestMethod]
        public void Deferred_Constant()
        {
            TestContext.DeleteAll(x => x.Entity_Basics);
            TestContext.Insert(x => x.Entity_Basics, 3);

            using (var ctx = new TestContext())
            {
                var query1 = ctx.Entity_Basics.Where(x => x.ColumnInt > 0).DeferredCount();
                var query2 = ctx.Entity_Basics.Where(x => x.ColumnInt > 1).DeferredCount();

                var count1 = query1.FromCache();
                var count2 = query2.FromCache();

                // Cache key are different
                Assert.AreNotEqual(QueryCacheManager.GetCacheKey(query1, new string[0]), QueryCacheManager.GetCacheKey(query2, new string[0]));

                // Count are different
                Assert.AreEqual(2, count1);
                Assert.AreEqual(1, count2);
            }
        }
    }
}


text:
#include <log4cxx/logger.h>
#include <log4cxx/fileappender.h>
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/logmanager.h>
#include <log4cxx/level.h>
#include <log4cxx/hierarchy.h>
#include <log4cxx/spi/rootlogger.h>
#include <log4cxx/helpers/propertyresourcebundle.h>
#include "insertwide.h"
#include "testchar.h"
#include "logunit.h"
#include <log4cxx/helpers/locale.h>
#include "vectorappender.h"

using namespace log4cxx;
using namespace log4cxx::spi;
using namespace log4cxx::helpers;

class CountingAppender;
typedef helpers::ObjectPtrT<CountingAppender> CountingAppenderPtr;

class CountingAppender : public AppenderSkeleton
{
public:
        int counter;

        CountingAppender() : counter(0)
                {}

        void close()
                {}

        void append(const spi::LoggingEventPtr& /*event*/, Pool& /*p*/)
                { counter++; }

        bool requiresLayout() const
                { return true; }
};

LOGUNIT_CLASS(LoggerTestCase)
{
        LOGUNIT_TEST_SUITE(LoggerTestCase);
                LOGUNIT_TEST(testAppender1);
                LOGUNIT_TEST(testAppender2);
                LOGUNIT_TEST(testAdditivity1);
                LOGUNIT_TEST(testAdditivity2);
                LOGUNIT_TEST(testAdditivity3);
                LOGUNIT_TEST(testDisable1);
//    LOGUNIT_TEST(testRB1);
//    LOGUNIT_TEST(testRB2);  //TODO restore
//    LOGUNIT_TEST(testRB3);
                LOGUNIT_TEST(testExists);
                LOGUNIT_TEST(testHierarchy1);
                LOGUNIT_TEST(testTrace);
                LOGUNIT_TEST(testIsTraceEnabled);
        LOGUNIT_TEST_SUITE_END();

public:
        void setUp()
        {
        }

        void tearDown()
        {
                BasicConfigurator::resetConfiguration();
                a1 = 0;
                a2 = 0;
        logger = 0;
        }

        /**
        Add an appender and see if it can be retrieved.
        */
        void testAppender1()
        {
                logger = Logger::getLogger(LOG4CXX_TEST_STR("test"));
                a1 = new FileAppender();
                a1->setName(LOG4CXX_STR("testAppender1"));
                logger->addAppender(a1);

                AppenderList list = logger->getAllAppenders();
                AppenderPtr aHat = list.front();
                LOGUNIT_ASSERT_EQUAL(a1, aHat);
        }

        /**
        Add an appender X, Y, remove X and check if Y is the only
        remaining appender.
        */
        void testAppender2()
        {
                a1 = new FileAppender();
                a1->setName(LOG4CXX_STR("testAppender2.1"));
                a2 = new FileAppender();
                a2->setName(LOG4CXX_STR("testAppender2.2"));

                logger = Logger::getLogger(LOG4CXX_TEST_STR("test"));
                logger->addAppender(a1);
                logger->addAppender(a2);
                logger->removeAppender((LogString) LOG4CXX_STR("testAppender2.1"));

                AppenderList list = logger->getAllAppenders();
                AppenderPtr aHat = list.front();
                LOGUNIT_ASSERT_EQUAL(a2, aHat);
                LOGUNIT_ASSERT(list.size() == 1);
        }

        /**
        Test if LoggerPtr a.b inherits its appender from a.
        */
        void testAdditivity1()
        {
                LoggerPtr a = Logger::getLogger(LOG4CXX_TEST_STR("a"));
                LoggerPtr ab = Logger::getLogger(LOG4CXX_TEST_STR("a.b"));
                CountingAppenderPtr ca = new CountingAppender();
                a->addAppender(ca);

                LOGUNIT_ASSERT_EQUAL(ca->counter, 0);
                ab->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(ca->counter, 1);
                ab->info(MSG);
                LOGUNIT_ASSERT_EQUAL(ca->counter, 2);
                ab->warn(MSG);
                LOGUNIT_ASSERT_EQUAL(ca->counter, 3);
                ab->error(MSG);
                LOGUNIT_ASSERT_EQUAL(ca->counter, 4);
        }

        /**
        Test multiple additivity.
        */
        void testAdditivity2()
        {
                LoggerPtr a = Logger::getLogger(LOG4CXX_TEST_STR("a"));
                LoggerPtr ab = Logger::getLogger(LOG4CXX_TEST_STR("a.b"));
                LoggerPtr abc = Logger::getLogger(LOG4CXX_TEST_STR("a.b.c"));
                LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));

                CountingAppenderPtr ca1 = new CountingAppender();
                CountingAppenderPtr ca2 = new CountingAppender();

                a->addAppender(ca1);
                abc->addAppender(ca2);

                LOGUNIT_ASSERT_EQUAL(ca1->counter, 0);
                LOGUNIT_ASSERT_EQUAL(ca2->counter, 0);

                ab->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(ca1->counter, 1);
                LOGUNIT_ASSERT_EQUAL(ca2->counter, 0);

                abc->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(ca1->counter, 2);
                LOGUNIT_ASSERT_EQUAL(ca2->counter, 1);

                x->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(ca1->counter, 2);
                LOGUNIT_ASSERT_EQUAL(ca2->counter, 1);
        }

        /**
        Test additivity flag.
        */
        void testAdditivity3()
        {
                LoggerPtr root = Logger::getRootLogger();
                LoggerPtr a = Logger::getLogger(LOG4CXX_TEST_STR("a"));
                LoggerPtr ab = Logger::getLogger(LOG4CXX_TEST_STR("a.b"));
                LoggerPtr abc = Logger::getLogger(LOG4CXX_TEST_STR("a.b.c"));
                LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));

                CountingAppenderPtr caRoot = new CountingAppender();
                CountingAppenderPtr caA = new CountingAppender();
                CountingAppenderPtr caABC = new CountingAppender();

                root->addAppender(caRoot);
                a->addAppender(caA);
                abc->addAppender(caABC);

                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 0);
                LOGUNIT_ASSERT_EQUAL(caA->counter, 0);
                LOGUNIT_ASSERT_EQUAL(caABC->counter, 0);

                ab->setAdditivity(false);

                a->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caA->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caABC->counter, 0);

                ab->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caA->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caABC->counter, 0);

                abc->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caA->counter, 1);
                LOGUNIT_ASSERT_EQUAL(caABC->counter, 1);
        }

        void testDisable1()
        {
                CountingAppenderPtr caRoot = new CountingAppender();
                LoggerPtr root = Logger::getRootLogger();
                root->addAppender(caRoot);

                LoggerRepositoryPtr h = LogManager::getLoggerRepository();

                //h.disableDebug();
                h->setThreshold(Level::getInfo());
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 0);

                root->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 0);
                root->info(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 1);
                root->log(Level::getWarn(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 2);
                root->warn(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 3);

                //h.disableInfo();
                h->setThreshold(Level::getWarn());
                root->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 3);
                root->info(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 3);
                root->log(Level::getWarn(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 4);
                root->error(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 5);
                root->log(Level::getError(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);

                //h.disableAll();
                h->setThreshold(Level::getOff());
                root->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->info(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getWarn(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->error(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getFatal(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getFatal(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);

                //h.disable(Level::getFatalLevel());
                h->setThreshold(Level::getOff());
                root->debug(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->info(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getWarn(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->error(MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getWarn(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
                root->log(Level::getFatal(), MSG);
                LOGUNIT_ASSERT_EQUAL(caRoot->counter, 6);
        }

        ResourceBundlePtr getBundle(const LogString& lang, const LogString& region)
        {
             Locale l(lang, region);
             ResourceBundlePtr bundle(
                 PropertyResourceBundle::getBundle(LOG4CXX_STR("L7D"),l));
             LOGUNIT_ASSERT(bundle != 0);
             return bundle;
        }

        void testRB1()
        {
                ResourceBundlePtr rbUS(getBundle(LOG4CXX_STR("en"), LOG4CXX_STR("US")));
                ResourceBundlePtr rbFR(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("FR")));
                ResourceBundlePtr rbCH(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("CH")));

                LoggerPtr root = Logger::getRootLogger();
                root->setResourceBundle(rbUS);

                ResourceBundlePtr t = root->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);

                LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));
                LoggerPtr x_y = Logger::getLogger(LOG4CXX_TEST_STR("x.y"));
                LoggerPtr x_y_z = Logger::getLogger(LOG4CXX_TEST_STR("x.y.z"));

                t = x->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);
                t = x_y->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);
                t = x_y_z->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);
        }

        void testRB2()
        {
                LoggerPtr root = Logger::getRootLogger();
                ResourceBundlePtr rbUS(getBundle(LOG4CXX_STR("en"), LOG4CXX_STR("US")));
                ResourceBundlePtr rbFR(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("FR")));
                ResourceBundlePtr rbCH(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("CH")));

                root->setResourceBundle(rbUS);

                ResourceBundlePtr t = root->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);

                LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));
                LoggerPtr x_y = Logger::getLogger(LOG4CXX_TEST_STR("x.y"));
                LoggerPtr x_y_z = Logger::getLogger(LOG4CXX_TEST_STR("x.y.z"));

                x_y->setResourceBundle(rbFR);
                t = x->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);
                t = x_y->getResourceBundle();
                LOGUNIT_ASSERT(t == rbFR);
                t = x_y_z->getResourceBundle();
                LOGUNIT_ASSERT(t == rbFR);
        }

        void testRB3()
        {
                ResourceBundlePtr rbUS(getBundle(LOG4CXX_STR("en"), LOG4CXX_STR("US")));
                ResourceBundlePtr rbFR(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("FR")));
                ResourceBundlePtr rbCH(getBundle(LOG4CXX_STR("fr"), LOG4CXX_STR("CH")));

                LoggerPtr root = Logger::getRootLogger();
                root->setResourceBundle(rbUS);

                ResourceBundlePtr t = root->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);

                LoggerPtr x = Logger::getLogger(LOG4CXX_TEST_STR("x"));
                LoggerPtr x_y = Logger::getLogger(LOG4CXX_TEST_STR("x.y"));
                LoggerPtr x_y_z = Logger::getLogger(LOG4CXX_TEST_STR("x.y.z"));

                x_y->setResourceBundle(rbFR);
                x_y_z->setResourceBundle(rbCH);
                t = x->getResourceBundle();
                LOGUNIT_ASSERT(t == rbUS);
                t = x_y->getResourceBundle();
                LOGUNIT_ASSERT(t == rbFR);
                t = x_y_z->getResourceBundle();
                LOGUNIT_ASSERT(t == rbCH);
        }

        void testExists()
        {
                LoggerPtr a = Logger::getLogger(LOG4CXX_TEST_STR("a"));
                LoggerPtr a_b = Logger::getLogger(LOG4CXX_TEST_STR("a.b"));
                LoggerPtr a_b_c = Logger::getLogger(LOG4CXX_TEST_STR("a.b.c"));

                LoggerPtr t;
                t = LogManager::exists(LOG4CXX_TEST_STR("xx"));
                LOGUNIT_ASSERT(t == 0);
                t = LogManager::exists(LOG4CXX_TEST_STR("a"));
                LOGUNIT_ASSERT_EQUAL(a, t);
                t = LogManager::exists(LOG4CXX_TEST_STR("a.b"));
                LOGUNIT_ASSERT_EQUAL(a_b, t);
                t = LogManager::exists(LOG4CXX_TEST_STR("a.b.c"));
                LOGUNIT_ASSERT_EQUAL(a_b_c, t);
        }

        void testHierarchy1()
        {
                LoggerRepositoryPtr h = new Hierarchy();
                LoggerPtr root(h->getRootLogger());
                root->setLevel(Level::getError());
                LoggerPtr a0 = h->getLogger(LOG4CXX_STR("a"));
                LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("a"), a0->getName());
                LOGUNIT_ASSERT(a0->getLevel() == 0);
                LOGUNIT_ASSERT(Level::getError() == a0->getEffectiveLevel());

                LoggerPtr a11 = h->getLogger(LOG4CXX_STR("a"));
                LOGUNIT_ASSERT_EQUAL(a0, a11);
        }

        void compileTestForLOGCXX202() const {
           //
           //   prior to fix, these line would compile.
           //
           (*logger).info("Hello, World.");
           ((Logger*) logger)->info("Hello, World.");
           //
           //   this one would not.
           //
           logger->info("Hello, World.");
        }

  /**
   * Tests logger.trace(Object).
   *
   */
  void testTrace() {
      VectorAppenderPtr appender = new VectorAppender();
      LoggerPtr root = Logger::getRootLogger();
      root->addAppender(appender);
      root->setLevel(Level::getInfo());

      LoggerPtr tracer = Logger::getLogger("com.example.Tracer");
      tracer->setLevel(Level::getTrace());

      LOG4CXX_TRACE(tracer, "Message 1");
      LOG4CXX_TRACE(root, "Discarded Message");
      LOG4CXX_TRACE(root, "Discarded Message");

      std::vector<LoggingEventPtr> msgs(appender->vector);
      LOGUNIT_ASSERT_EQUAL((size_t) 1, msgs.size());
      LoggingEventPtr event = msgs[0];
      LOGUNIT_ASSERT_EQUAL((int) Level::TRACE_INT, event->getLevel()->toInt());
      LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("Message 1")), event->getMessage());
  }

    /**
     * Tests isTraceEnabled.
     *
     */
    void testIsTraceEnabled() {
        VectorAppenderPtr appender = new VectorAppender();
        LoggerPtr root = Logger::getRootLogger();
        root->addAppender(appender);
        root->setLevel(Level::getInfo());

        LoggerPtr tracer = Logger::getLogger("com.example.Tracer");
        tracer->setLevel(Level::getTrace());

        LOGUNIT_ASSERT_EQUAL(true, tracer->isTraceEnabled());
        LOGUNIT_ASSERT_EQUAL(false, root->isTraceEnabled());
    }

protected:
        static LogString MSG;
        LoggerPtr logger;
        AppenderPtr a1;
        AppenderPtr a2;
};

LogString LoggerTestCase::MSG(LOG4CXX_STR("M"));

LOGUNIT_TEST_SUITE_REGISTRATION(LoggerTestCase);


text:
import '../..';

import {assert} from '@ciscospark/test-helper-chai';
import CiscoSpark from '@ciscospark/spark-core';

describe(`plugin-phone`, () => {
  describe(`Phone`, () => {
    describe(`#isCallingSupported()`, () => {
      let spark;
      beforeEach(() => {
        spark = new CiscoSpark();
      });
      // This is sort of a silly test since we only actually run this test in
      // browsers that support calling...
      it(`returns true`, () => assert.becomes(spark.phone.isCallingSupported(), true));
    });
  });
});


text:
export { default as mockCredentials } from './data.credentials.json';
export { default as mockCredentialType } from './data.credential_type.json';


text:
'use strict';

const DI = require('@scola/di');
const MVA = require('@scola/mva');
const Storage = require('@scola/storage-browser');
const Validator = require('@scola/validator');

const I18n = require('./i18n');
const Model = require('./model');
const View = require('./view');

class Module extends DI.Module {
  configure() {
    this.addModule(MVA.Module);
    this.addModule(Validator.Module);

    this.addModule(I18n.Module);
    this.addModule(View.Module);

    this.inject(Model).with(
      this.instance(Validator.Validator),
      this.singleton(MVA.Helper.Messenger),
      this.singleton(Storage.Session),
      this.singleton(Storage.Local)
    );
  }
}

module.exports = {
  Model,
  Module,
  View
};


text:
import org.zeromq.ZMQ;
import java.util.Random;

/*
 * Lazy Pirate server
 * @author Zac Li
 * @email zac.li.cmu@gmail.com
 */

object lpserver{

    def main (args : Array[String]) {
        val rand = new Random(System.nanoTime())

        val context = ZMQ.context(1)
        val server = context.socket(ZMQ.REP)
        server.bind("tcp://*:5555")

        val cycles = 0;
        while (true) {
            val request = server.recvStr()
            cycles++

            //  Simulate various problems, after a few cycles
            if (cycles > 3 && rand.nextInt(3) == 0) {
                println("I: simulating a crash")
                break
            } else if (cycles > 3 && rand.nextInt(3) == 0) {
                println("I: simulating CPU overload")
                Thread.sleep(2000)
            }
            println(f"I: normal request (%s)\n", request)
            Thread.sleep(1000)
            server.send(request)
        }

        server close()
        context term()
    }
}


text:
package org.apache.rave.portal.model.impl;

import org.apache.rave.model.FriendRequestStatus;
import org.apache.rave.model.Person;
import org.apache.rave.model.PersonAsociation;

import java.io.Serializable;

/**
 * Created by Jhainey on 11/10/2014.
 */
public class PersonAsociationsImpl implements PersonAsociation, Serializable {

    private Long entityId;
    private Person follower;
    private Person followedby;
    private FriendRequestStatus status;

    @Override
    public Long getEntityId() {
        return entityId;
    }

    @Override
    public void setEntityId(Long entityId) {
        this.entityId=entityId;
    }

    @Override
    public Person getFollower() {
        return follower;
    }

    @Override
    public void setFollower(Person follower) {
        this.follower=follower;
    }

    @Override
    public Person getFollowedby() {
        return followedby;
    }

    @Override
    public void setFollowedby(Person followedby) {
        this.followedby=followedby;
    }

    @Override
    public FriendRequestStatus getStatus() {
        return status;
    }

    @Override
    public void setStatus(FriendRequestStatus status) {
        this.status=status;
    }
}


text:
package org.opensmartgridplatform.dto.valueobjects.smartmetering;

import java.io.Serializable;

public class NotificationDto implements Serializable {

    private static final long serialVersionUID = 4424128385545688694L;

    private String message;
    private String result;
    private String deviceIdentification;
    private String correlationUid;

    protected NotificationTypeDto notificationType;

    public NotificationDto(final String message, final String result, final String deviceIdentification,
            final String correlationUid, final NotificationTypeDto notificationType) {
        this.message = message;
        this.result = result;
        this.deviceIdentification = deviceIdentification;
        this.correlationUid = correlationUid;
        this.notificationType = notificationType;
    }

    public String getMessage() {
        return this.message;
    }

    public String getResult() {
        return this.result;
    }

    public String getDeviceIdentification() {
        return this.deviceIdentification;
    }

    public String getCorrelationUid() {
        return this.correlationUid;
    }

    public NotificationTypeDto getNotificationType() {
        return this.notificationType;
    }
}


text:
ALTER TABLE vs_request ADD role_request_id binary(16);
CREATE INDEX idx_vs_request_role_request_id ON vs_request (role_request_id);


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Products_Model extends CI_Model {

	public function get_all_products() {
		$products_query = "SELECT
						   products.id AS id,
						   products.manufacturer_id AS manufacturer_id,
						   products.name AS name,
						   products.price AS price,
						   products.description AS description,
						   manufacturers.manufacturer_name AS manufacturer_name,
						   products.created_at AS created_at
						   FROM products
	 			  		   LEFT JOIN manufacturers
						   ON products.manufacturer_id = manufacturers.id";
		return $this->db->query($products_query)->result_array();
	}

	public function get_product($id) {
		$query = "SELECT * FROM products WHERE id = ?";
		return $this->db->query($query, array($id))->row_array();
	}

	public function get_manufacturer() {
		$query = "SELECT * FROM manufacturers";
		return $this->db->query($query)->result_array();
	}

	public function delete_product($id) {
		$delete_query = "DELETE FROM products WHERE products.id = ?";
		return $this->db->query($delete_query, array($id));
	}

	public function create_product($post) {
		$manufacturer_id = $post['manufacturer'];
		$product_name = $post['product_name'];
		$price = $post['price'];
		$description = $post['description'];
		$query = "INSERT INTO products (manufacturer_id, name, price, description, created_at, updated_at)
				  VALUES (?,?,?,?, NOW(), NOW())";
		return $this->db->query($query, array($manufacturer_id, $product_name, $price, $description));
	}

	public function edit_product($post, $id) {
		$query = "UPDATE products SET name=?, description=?, price=?, updated_at=? WHERE products.id = ?";
		$values = array($post['product_name'], $post['description'], $post['price'], date('Y-m-d H:i:s'), $id);
		return $this->db->query($query, $values);
	}
}


text:
<?php

namespace Sylius\Bundle\ContentBundle\Form\Type;

use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;

/**
 * Reference block type.
 *
 * @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
 */
class ReferenceBlockType extends AbstractResourceType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('id', 'text', array(
                'label' => 'sylius.form.reference_block.id'
            ))
            ->add('title', 'text', array(
                'label' => 'sylius.form.reference_block.title'
            ))
            ->add('body', 'textarea', array(
                'required' => false,
                'label'    => 'sylius.form.reference_block.body',
            ))
        ;

    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'sylius_reference_block';
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>thobe.widgets.buttons</title>
<meta name="date" content="2015-04-06">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes

Package thobe.widgets.buttons

Class Summary

Class
Description

CancelButton

IconButton

Class representing an button having an Icon and no text, no margin etc.

SmallButton

Class representing an custom-style small button

TransparentIconButton

Class representing an button having an Icon and no text, no margin etc.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes