// Path: game-common/src/main/java/com/game/common/model/Map.java
// public abstract class Map {
// 	public static final int MAGIC_NUMBER = 0x4531;
// 
// 	protected final int width;
// 	protected final int height;
// 	protected final int sectorSize;
// 
// 	protected Map(int width, int height, int sectorSize) {
// 		this.width = width;
// 		this.height = height;
// 		this.sectorSize = sectorSize;
// 	}
// 
// 	public int getSectorSize() {
// 		return sectorSize;
// 	}
// 
// 	public int getWidth() {
// 		return width * sectorSize;
// 	}
// 
// 	public int getHeight() {
// 		return height * sectorSize;
// 	}
// 
// 	public abstract Tile getTile(int x, int y);
// 
// 	public abstract Tile getTile(Point p);
// 
// 	public Path generatePath(Point start, Point target) {
// 		PathFinder finder = new PathFinder(this, start);
// 
// 		return finder.generatePath(target);
// 	}
// 
// 	public boolean isValidStep(Point from, Point to) {
// 		// If the step is more than 1 tile away, it isn't valid
// 		if (from.distanceTo(to) >= 2)
// 			return false;
// 
// 		Tile fromTile = this.getTile(from);
// 		// This shouldn't happen!
// 		if (fromTile == null)
// 			return false;
// 
// 		Tile toTile = this.getTile(to);
// 		// If it isn't found in the map, or isn't walkable then skip it
// 		if (toTile == null || !toTile.isWalkable())
// 			return false;
// 
// 		// Moving left, check our old y
// 		if (from.x > to.x) {
// 			Tile toCheck = this.getTile(from.x, from.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 		// Moving right, check our old y
// 		else if (from.x < to.x) {
// 			Tile toCheck = this.getTile(from.x + 1, from.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 
// 		// Moving down, check our old x
// 		if (from.y > to.y){
// 			Tile toCheck = this.getTile(from.x, from.y - 1);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 		// Moving up, check our old x
// 		else if (from.y < to.y) {
// 			Tile toCheck = this.getTile(from.x, from.y);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 
// 		// We are moving straight, and aren't blocked
// 		if ((from.x == to.x) || (from.y == to.y))
// 			return true;
// 
// 		// We are moving diagonal, so we also need to check the destination tile isn't blocked
// 
// 		// Moving left, check our new y
// 		if (from.x > to.x) {
// 			Tile toCheck = this.getTile(to.x + 1, to.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 		// Moving right, check our new y
// 		else if (from.x < to.x) {
// 			Tile toCheck = this.getTile(to.x, to.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 
// 		// Moving down, check our new x
// 		if (from.y > to.y) {
// 			Tile toCheck = this.getTile(to.x, to.y);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 		// Moving up, check our new x
// 		else if (from.y < to.y) {
// 			Tile toCheck = this.getTile(to.x, to.y - 1);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "map[width = " + this.getWidth() + ", height = " + this.getHeight() + ", sectorSize = " + this.getSectorSize() + "]";
// 	}
// }
// 
// Path: game-common/src/main/java/com/game/common/model/Point.java
// public class Point implements Serializable {
// 	private static final long serialVersionUID = 1L;
// 
// 	public static final Point ZERO = new Point(0, 0);
// 
// 	public int x;
// 	public int y;
// 
// 	@SuppressWarnings("unused")
// 	private Point() { } // For hibernate
// 
// 	public Point(int x, int y) {
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public void set(Point location) {
// 		this.x = location.x;
// 		this.y = location.y;
// 	}
// 
// 	public double distanceTo(Point p) {
// 		// Euclidean distance
// 		return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return x << 16 | y;
// 	}
// 
// 	@Override
// 	public boolean equals(Object o) {
// 		if (!(o instanceof Point))
// 			return false;
// 
// 		Point p = (Point) o;
// 		return x == p.x && y == p.y;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "(" + x + ", " + y + ")";
// 	}
// }


import java.io.DataInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.game.common.model.Map;
import com.game.common.model.Point;
package com.game.client.model;




public class LocalMapSector {
	private static final Logger log = LoggerFactory.getLogger(LocalMapSector.class);

// Path: game-common/src/main/java/com/game/common/model/Map.java
// public abstract class Map {
// 	public static final int MAGIC_NUMBER = 0x4531;
// 
// 	protected final int width;
// 	protected final int height;
// 	protected final int sectorSize;
// 
// 	protected Map(int width, int height, int sectorSize) {
// 		this.width = width;
// 		this.height = height;
// 		this.sectorSize = sectorSize;
// 	}
// 
// 	public int getSectorSize() {
// 		return sectorSize;
// 	}
// 
// 	public int getWidth() {
// 		return width * sectorSize;
// 	}
// 
// 	public int getHeight() {
// 		return height * sectorSize;
// 	}
// 
// 	public abstract Tile getTile(int x, int y);
// 
// 	public abstract Tile getTile(Point p);
// 
// 	public Path generatePath(Point start, Point target) {
// 		PathFinder finder = new PathFinder(this, start);
// 
// 		return finder.generatePath(target);
// 	}
// 
// 	public boolean isValidStep(Point from, Point to) {
// 		// If the step is more than 1 tile away, it isn't valid
// 		if (from.distanceTo(to) >= 2)
// 			return false;
// 
// 		Tile fromTile = this.getTile(from);
// 		// This shouldn't happen!
// 		if (fromTile == null)
// 			return false;
// 
// 		Tile toTile = this.getTile(to);
// 		// If it isn't found in the map, or isn't walkable then skip it
// 		if (toTile == null || !toTile.isWalkable())
// 			return false;
// 
// 		// Moving left, check our old y
// 		if (from.x > to.x) {
// 			Tile toCheck = this.getTile(from.x, from.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 		// Moving right, check our old y
// 		else if (from.x < to.x) {
// 			Tile toCheck = this.getTile(from.x + 1, from.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 
// 		// Moving down, check our old x
// 		if (from.y > to.y){
// 			Tile toCheck = this.getTile(from.x, from.y - 1);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 		// Moving up, check our old x
// 		else if (from.y < to.y) {
// 			Tile toCheck = this.getTile(from.x, from.y);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 
// 		// We are moving straight, and aren't blocked
// 		if ((from.x == to.x) || (from.y == to.y))
// 			return true;
// 
// 		// We are moving diagonal, so we also need to check the destination tile isn't blocked
// 
// 		// Moving left, check our new y
// 		if (from.x > to.x) {
// 			Tile toCheck = this.getTile(to.x + 1, to.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 		// Moving right, check our new y
// 		else if (from.x < to.x) {
// 			Tile toCheck = this.getTile(to.x, to.y);
// 			if (toCheck == null || toCheck.isBlockedVertically())
// 				return false;
// 		}
// 
// 		// Moving down, check our new x
// 		if (from.y > to.y) {
// 			Tile toCheck = this.getTile(to.x, to.y);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 		// Moving up, check our new x
// 		else if (from.y < to.y) {
// 			Tile toCheck = this.getTile(to.x, to.y - 1);
// 			if (toCheck == null || toCheck.isBlockedHorizontally())
// 				return false;
// 		}
// 
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "map[width = " + this.getWidth() + ", height = " + this.getHeight() + ", sectorSize = " + this.getSectorSize() + "]";
// 	}
// }
// 
// Path: game-common/src/main/java/com/game/common/model/Point.java
// public class Point implements Serializable {
// 	private static final long serialVersionUID = 1L;
// 
// 	public static final Point ZERO = new Point(0, 0);
// 
// 	public int x;
// 	public int y;
// 
// 	@SuppressWarnings("unused")
// 	private Point() { } // For hibernate
// 
// 	public Point(int x, int y) {
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public void set(Point location) {
// 		this.x = location.x;
// 		this.y = location.y;
// 	}
// 
// 	public double distanceTo(Point p) {
// 		// Euclidean distance
// 		return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return x << 16 | y;
// 	}
// 
// 	@Override
// 	public boolean equals(Object o) {
// 		if (!(o instanceof Point))
// 			return false;
// 
// 		Point p = (Point) o;
// 		return x == p.x && y == p.y;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "(" + x + ", " + y + ")";
// 	}
// }


// Path: game-client/src/main/java/com/game/client/model/LocalMapSector.java
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.game.common.model.Map;
import com.game.common.model.Point;

package com.game.client.model;




public class LocalMapSector {
	private static final Logger log = LoggerFactory.getLogger(LocalMapSector.class);

	public static LocalMapSector load(URL path, Point offset) {