From: Kimmo R. <ki...@us...> - 2013-07-20 19:57:16
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/mapstuff/block In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15648/src/games/stendhal/server/entity/mapstuff/block Modified Files: Tag: VERSION_01_RELEASE_09 Block.java Log Message: Backport of "Reset only to initial position if there is no colliding entity" Index: Block.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/mapstuff/block/Block.java,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -C2 -d -r1.25 -r1.25.2.1 *** Block.java 11 Jul 2013 10:22:07 -0000 1.25 --- Block.java 20 Jul 2013 19:57:11 -0000 1.25.2.1 *************** *** 36,39 **** --- 36,41 ---- static final int RESET_TIMEOUT_IN_SECONDS = 5 * MathHelper.SECONDS_IN_ONE_MINUTE; + + static final int RESET_AGAIN_DELAY = 10; private static final String Z_ORDER = "z"; *************** *** 252,257 **** int numberOfPlayersInZone = playersInZone.size(); if (numberOfPlayersInZone == 0 || numberOfPlayersInZone == 1 && playersInZone.contains(object)) { ! this.reset(); ! logger.debug("Block [" + this.getID().toString() + "] reset to (" + this.getX() + "," + this.getY() + ")."); } } --- 254,258 ---- int numberOfPlayersInZone = playersInZone.size(); if (numberOfPlayersInZone == 0 || numberOfPlayersInZone == 1 && playersInZone.contains(object)) { ! resetIfInitialPositionFree(); } } *************** *** 279,284 **** @Override public void onTurnReached(int currentTurn) { ! // Reset Block after a timeout to its initial position ! this.reset(); } --- 280,296 ---- @Override public void onTurnReached(int currentTurn) { ! resetIfInitialPositionFree(); ! } ! ! /** ! * Reset to initial position if no collision there, try again later if not possible ! */ ! private void resetIfInitialPositionFree() { ! if (!this.getZone().collides(this, this.getInt(START_X), this.getInt(START_Y))) { ! this.reset(); ! } else { ! // try again in a few moments ! SingletonRepository.getTurnNotifier().notifyInSeconds(RESET_AGAIN_DELAY, this); ! } } |