Allow specific puzzles to override the default sync setting and force a sync.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3215 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2004-11-12 20:03:35 +00:00
parent 57d8d7a703
commit 39fcb381e2
@@ -1,5 +1,5 @@
// //
// $Id: PuzzleController.java,v 1.19 2004/10/29 16:32:10 mdb Exp $ // $Id: PuzzleController.java,v 1.20 2004/11/12 20:03:35 ray Exp $
// //
// Narya library - tools for developing networked games // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -733,6 +733,15 @@ public abstract class PuzzleController extends GameController
return _events.size(); return _events.size();
} }
/**
* Are we syncing boards for this puzzle?
* By default, we defer to the PuzzlePanel and its runtime config.
*/
protected boolean isSyncingBoards ()
{
return PuzzlePanel.isSyncingBoards();
}
/** /**
* Adds the given progress event and a snapshot of the supplied board * Adds the given progress event and a snapshot of the supplied board
* state to the set of progress events and associated board states for * state to the set of progress events and associated board states for
@@ -749,7 +758,7 @@ public abstract class PuzzleController extends GameController
} }
_events.add(new Integer(event)); _events.add(new Integer(event));
if (PuzzlePanel.isSyncingBoards()) { if (isSyncingBoards()) {
_states.add((board == null) ? null : board.clone()); _states.add((board == null) ? null : board.clone());
if (board == null) { if (board == null) {
Log.warning("Added progress event with no associated board " + Log.warning("Added progress event with no associated board " +
@@ -780,12 +789,11 @@ public abstract class PuzzleController extends GameController
// create an array of the board states that correspond with those // create an array of the board states that correspond with those
// events (if state syncing is enabled) // events (if state syncing is enabled)
if (PuzzlePanel.isSyncingBoards()) { int numStates = _states.size();
int scount = _states.size(); if (numStates == size) { // ie, if we have a board to match every event
Board[] states = new Board[scount]; Board[] states = new Board[numStates];
for (int ii = 0; ii < scount; ii++) { _states.toArray(states);
states[ii] = (Board)_states.remove(0); _states.clear();
}
// send the update progress request // send the update progress request
_puzobj.puzzleGameService.updateProgressSync( _puzobj.puzzleGameService.updateProgressSync(