From: ChadF <ch...@us...> - 2007-01-31 01:57:43
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/pathfinder In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7544/src/games/stendhal/server/pathfinder Modified Files: Path.java StendhalNavigable.java Log Message: Try.. try.. again. Better sheep food fix (I hope). This should allow Creature.getNearestEnemy() to be changed back to using the old searchPath(Entity, Entity) call, which now does the right thing. Index: Path.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/pathfinder/Path.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Path.java 20 Jan 2007 17:57:24 -0000 1.21 --- Path.java 31 Jan 2007 01:57:41 -0000 1.22 *************** *** 236,241 **** /** ! * Finds a path for the Entity <code>entity</code> to the other Entity ! * <code>dest</code>. * * @param entity --- 236,241 ---- /** ! * Finds a path for the Entity <code>entity</code> to (or next to) ! * the other Entity <code>dest</code>. * * @param entity *************** *** 246,251 **** */ public static List<Node> searchPath(Entity entity, Entity dest) { ! return searchPath(entity, entity.getX(), entity.getY(), dest.getArea( ! dest.getX(), dest.getY())); } --- 246,250 ---- */ public static List<Node> searchPath(Entity entity, Entity dest) { ! return searchPath(entity, dest, -1.0); } *************** *** 264,293 **** public static List<Node> searchPath(Entity entity, Entity dest, double maxDistance) { ! ! Rectangle2D rect = entity.getArea(entity.getX(), entity.getY()); ! ! List<Node> res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! dest.getX(), dest.getY(), 1, 1), maxDistance); ! if (((res == null) || res.isEmpty()) && (rect.getWidth() > 1)) { ! ! logger.debug("trying 2: " + (entity.getX() + (int) rect.getWidth() - 1)); ! ! res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! dest.getX() - (int) rect.getWidth() + 1, dest.getY(), 1, 1), maxDistance); ! if (((res == null) || res.isEmpty()) && (rect.getHeight() > 1)) { ! logger.debug("trying 3"); ! res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! dest.getX(), dest.getY() - (int) rect.getHeight() + 1, 1, 1), maxDistance); ! if (((res == null) || res.isEmpty()) && (rect.getWidth() > 1) && (rect.getHeight() > 1)) { ! logger.debug("trying 4"); ! res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! dest.getX() - (int) rect.getWidth() + 1, dest.getY() - (int) rect.getHeight() + 1, 1, 1), maxDistance); ! } ! } ! } ! // logger.debug(!res.isEmpty()); ! return res; } --- 263,308 ---- public static List<Node> searchPath(Entity entity, Entity dest, double maxDistance) { ! Rectangle2D area = dest.getArea(dest.getX(), dest.getY()); ! /* ! * Expand area by surounding tiles. ! */ ! return searchPath(entity, entity.getX(), entity.getY(), ! new Rectangle( ! ((int) area.getX()) - 1, ! ((int) area.getY()) - 1, ! ((int) area.getWidth()) + 2, ! ((int) area.getHeight()) + 2), ! maxDistance); ! // ! // OLD CODE: ! // ! // Rectangle2D rect = entity.getArea(entity.getX(), entity.getY()); ! // ! // ! // List<Node> res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! // dest.getX(), dest.getY(), 1, 1), maxDistance); ! // ! // if (((res == null) || res.isEmpty()) && (rect.getWidth() > 1)) { ! // ! // logger.debug("trying 2: " + (entity.getX() + (int) rect.getWidth() - 1)); ! // ! // res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! // dest.getX() - (int) rect.getWidth() + 1, dest.getY(), 1, 1), maxDistance); ! // if (((res == null) || res.isEmpty()) && (rect.getHeight() > 1)) { ! // logger.debug("trying 3"); ! // ! // res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! // dest.getX(), dest.getY() - (int) rect.getHeight() + 1, 1, 1), maxDistance); ! // if (((res == null) || res.isEmpty()) && (rect.getWidth() > 1) && (rect.getHeight() > 1)) { ! // logger.debug("trying 4"); ! // res = searchPath(entity, entity.getX(), entity.getY(), new Rectangle( ! // dest.getX() - (int) rect.getWidth() + 1, dest.getY() - (int) rect.getHeight() + 1, 1, 1), maxDistance); ! // } ! // } ! // } ! // // logger.debug(!res.isEmpty()); ! // return res; } Index: StendhalNavigable.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/pathfinder/StendhalNavigable.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** StendhalNavigable.java 27 Jan 2007 19:14:20 -0000 1.10 --- StendhalNavigable.java 31 Jan 2007 01:57:41 -0000 1.11 *************** *** 92,102 **** */ public boolean isValid(Pathfinder.Node node) { - /* - * Treat our target spot as accessable (even if it's not). - * The entity should stop walking when it hits a blocked area. - */ - if(goal.contains(node.x, node.y)) - return true; - return !zone.simpleCollides(entity, node.x, node.y); // return !zone.collides(entity, node.x,node.y); --- 92,95 ---- |