summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-03-19 22:58:24 -0400
committerStarla Insigna <hatkirby@fourisland.com>2009-03-19 22:58:24 -0400
commitfc3afd1d6460b2aa453167498979bbf7a636ef45 (patch)
tree390d5003901ec8b6e951dae2daedb485033c8b6e /src
parent0ebc2f2c92e4b51069f497aca9f715198010bdf2 (diff)
downloadfourpuzzle-fc3afd1d6460b2aa453167498979bbf7a636ef45.tar.gz
fourpuzzle-fc3afd1d6460b2aa453167498979bbf7a636ef45.tar.bz2
fourpuzzle-fc3afd1d6460b2aa453167498979bbf7a636ef45.zip
Engine: Fixed many potential bugs
Identified by FindBugs. http://findbugs.sourceforge.net/
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/Display.java12
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/PuzzleApplication.java18
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/SaveFile.java8
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java4
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java6
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java6
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java4
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java34
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java30
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java3
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java3
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java3
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/MovingViewpoint.java2
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/ShakingViewpoint.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/transition/SlideTransition.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/util/Interval.java13
-rw-r--r--src/com/fourisland/fourpuzzle/util/MidiParser.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/util/ObjectLoader.java10
-rw-r--r--src/com/fourisland/fourpuzzle/util/PauseTimer.java4
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/window/ChoiceWindow.java8
-rw-r--r--src/com/fourisland/fourpuzzle/window/Window.java2
24 files changed, 128 insertions, 54 deletions
diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index c8d17d9..b7569aa 100755 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java
@@ -42,8 +42,7 @@ import org.jdesktop.application.ResourceMap;
42 */ 42 */
43public class Display { 43public class Display {
44 44
45 public static int tileAnimationFrame = 0; 45 private static int tileAnimationFrame = 0;
46
47 private static List<Renderable> renderables = new CopyOnWriteArrayList<Renderable>(); 46 private static List<Renderable> renderables = new CopyOnWriteArrayList<Renderable>();
48 47
49 public static void render(Component gameFrame) 48 public static void render(Component gameFrame)
@@ -229,10 +228,10 @@ public class Display {
229 return; 228 return;
230 } catch (RuntimeException ex) 229 } catch (RuntimeException ex)
231 { 230 {
232 PuzzleApplication.INSTANCE.reportError(ex); 231 PuzzleApplication.reportError(ex);
233 } catch (Error ex) 232 } catch (Error ex)
234 { 233 {
235 PuzzleApplication.INSTANCE.reportError(ex); 234 PuzzleApplication.reportError(ex);
236 } 235 }
237 } 236 }
238 }; 237 };
@@ -331,4 +330,9 @@ public class Display {
331 return cachePoint; 330 return cachePoint;
332 } 331 }
333 332
333 public int getTileAnimationFrame()
334 {
335 return tileAnimationFrame;
336 }
337
334} 338}
diff --git a/src/com/fourisland/fourpuzzle/PuzzleApplication.java b/src/com/fourisland/fourpuzzle/PuzzleApplication.java index f88b0ad..88236f9 100755 --- a/src/com/fourisland/fourpuzzle/PuzzleApplication.java +++ b/src/com/fourisland/fourpuzzle/PuzzleApplication.java
@@ -28,10 +28,8 @@ import org.jdesktop.application.Application;
28 */ 28 */
29public class PuzzleApplication extends Application { 29public class PuzzleApplication extends Application {
30 30
31 public static PuzzleApplication INSTANCE; 31 private static boolean stretchScreen = true;
32 public static boolean debugSpeed = false; 32 private static boolean gameSleep = false;
33 public static boolean stretchScreen = true;
34 public static boolean gameSleep = false;
35 private static JDialog gameDialog = new JDialog(new JFrame(), false); 33 private static JDialog gameDialog = new JDialog(new JFrame(), false);
36 private static Semaphore gameDialogHandler = new Semaphore(1); 34 private static Semaphore gameDialogHandler = new Semaphore(1);
37 35
@@ -101,9 +99,9 @@ public class PuzzleApplication extends Application {
101 { 99 {
102 /* If debug mode is enabled, holding Shift down should put 100 /* If debug mode is enabled, holding Shift down should put
103 * the game into hyperactive mode */ 101 * the game into hyperactive mode */
104 if (INSTANCE.getContext().getResourceMap().getBoolean("debugMode")) 102 if (getInstance().getContext().getResourceMap().getBoolean("debugMode"))
105 { 103 {
106 debugSpeed = true; 104 Interval.setDebugSpeed(true);
107 } 105 }
108 } else if (e.getKeyCode() == KeyEvent.VK_F12) 106 } else if (e.getKeyCode() == KeyEvent.VK_F12)
109 { 107 {
@@ -125,7 +123,7 @@ public class PuzzleApplication extends Application {
125 if (e.getKeyCode() == KeyEvent.VK_SHIFT) 123 if (e.getKeyCode() == KeyEvent.VK_SHIFT)
126 { 124 {
127 // If Shift is let go of, hyperactive mode should end 125 // If Shift is let go of, hyperactive mode should end
128 debugSpeed = false; 126 Interval.setDebugSpeed(false);
129 } else { 127 } else {
130 KeyboardInput.getKey().letGo(); 128 KeyboardInput.getKey().letGo();
131 } 129 }
@@ -140,8 +138,6 @@ public class PuzzleApplication extends Application {
140 @Override 138 @Override
141 protected void startup() 139 protected void startup()
142 { 140 {
143 INSTANCE = this;
144
145 // Create the game form 141 // Create the game form
146 initGameDialog(true); 142 initGameDialog(true);
147 143
@@ -197,10 +193,10 @@ public class PuzzleApplication extends Application {
197 193
198 public String getGamePackage() 194 public String getGamePackage()
199 { 195 {
200 return INSTANCE.getContext().getResourceMap().getString("Application.package"); 196 return getInstance().getContext().getResourceMap().getString("Application.package");
201 } 197 }
202 198
203 public void reportError(Throwable ex) 199 public static void reportError(Throwable ex)
204 { 200 {
205 if ((ex instanceof Exception) && !(ex instanceof RuntimeException)) 201 if ((ex instanceof Exception) && !(ex instanceof RuntimeException))
206 { 202 {
diff --git a/src/com/fourisland/fourpuzzle/SaveFile.java b/src/com/fourisland/fourpuzzle/SaveFile.java index 44b3cdd..7a9c6cf 100755 --- a/src/com/fourisland/fourpuzzle/SaveFile.java +++ b/src/com/fourisland/fourpuzzle/SaveFile.java
@@ -23,6 +23,8 @@ import java.util.logging.Logger;
23 */ 23 */
24public class SaveFile implements Serializable { 24public class SaveFile implements Serializable {
25 25
26 private static final long serialVersionUID = 234503257;
27
26 /** 28 /**
27 * Creates a new SaveFile 29 * Creates a new SaveFile
28 */ 30 */
@@ -31,7 +33,7 @@ public class SaveFile implements Serializable {
31 switches = new HashMap<String, Boolean>(); 33 switches = new HashMap<String, Boolean>();
32 party = Database.createParty(); 34 party = Database.createParty();
33 variables = new HashMap<String, Integer>(); 35 variables = new HashMap<String, Integer>();
34 currentMap = new String(); 36 currentMap = "";
35 hero = new HeroEvent(); 37 hero = new HeroEvent();
36 } 38 }
37 39
@@ -43,7 +45,7 @@ public class SaveFile implements Serializable {
43 */ 45 */
44 public SaveFile(int file) throws IOException 46 public SaveFile(int file) throws IOException
45 { 47 {
46 InputStream is = PuzzleApplication.INSTANCE.getContext().getLocalStorage().openInputFile("Save" + file + ".sav"); 48 InputStream is = PuzzleApplication.getInstance().getContext().getLocalStorage().openInputFile("Save" + file + ".sav");
47 ObjectInputStream ois = new ObjectInputStream(is); 49 ObjectInputStream ois = new ObjectInputStream(is);
48 SaveFile temp = null; 50 SaveFile temp = null;
49 try { 51 try {
@@ -63,7 +65,7 @@ public class SaveFile implements Serializable {
63 65
64 public void saveGame(int file) throws IOException 66 public void saveGame(int file) throws IOException
65 { 67 {
66 OutputStream os = PuzzleApplication.INSTANCE.getContext().getLocalStorage().openOutputFile("Save" + file + ".sav"); 68 OutputStream os = PuzzleApplication.getInstance().getContext().getLocalStorage().openOutputFile("Save" + file + ".sav");
67 ObjectOutputStream oos = new ObjectOutputStream(os); 69 ObjectOutputStream oos = new ObjectOutputStream(os);
68 oos.writeObject(this); 70 oos.writeObject(this);
69 oos.close(); 71 oos.close();
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java index a4d7ac3..e6af66d 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java
@@ -52,7 +52,7 @@ public class ChipSet {
52 52
53 public static void initalize(String name) 53 public static void initalize(String name)
54 { 54 {
55 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 55 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
56 InputStream cs = null; 56 InputStream cs = null;
57 57
58 if (rm.getClassLoader().getResource(rm.getResourcesDir() + "chipset/" + name + ".tsx") == null) 58 if (rm.getClassLoader().getResource(rm.getResourcesDir() + "chipset/" + name + ".tsx") == null)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index 89fac99..d3bd101 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
@@ -83,7 +83,7 @@ public class MapViewGameState implements GameState {
83 * walkthrough flag so the Hero can walk through stuff */ 83 * walkthrough flag so the Hero can walk through stuff */
84 if (key.isCtrlDown() && !debugWalkthrough) 84 if (key.isCtrlDown() && !debugWalkthrough)
85 { 85 {
86 if (PuzzleApplication.INSTANCE.getContext().getResourceMap().getBoolean("debugMode")) 86 if (PuzzleApplication.getInstance().getContext().getResourceMap().getBoolean("debugMode"))
87 { 87 {
88 debugWalkthrough = true; 88 debugWalkthrough = true;
89 } 89 }
@@ -188,7 +188,7 @@ public class MapViewGameState implements GameState {
188 { 188 {
189 /* If debug mode is enabled and F11 is pressed, cancel any running 189 /* If debug mode is enabled and F11 is pressed, cancel any running
190 * events */ 190 * events */
191 if ((key.getKey() == KeyEvent.VK_F11) && (PuzzleApplication.INSTANCE.getContext().getResourceMap().getBoolean("debugMode"))) 191 if ((key.getKey() == KeyEvent.VK_F11) && (PuzzleApplication.getInstance().getContext().getResourceMap().getBoolean("debugMode")))
192 { 192 {
193 for (LayerEvent ev : currentMap.getEvents()) 193 for (LayerEvent ev : currentMap.getEvents())
194 { 194 {
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java index 76582e3..55dc6d0 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AnimationType.java
@@ -26,7 +26,7 @@ public enum AnimationType {
26 */ 26 */
27 CommonWithStepping(true, true) 27 CommonWithStepping(true, true)
28 { 28 {
29 Interval in = Interval.createTickInterval(2); 29 transient Interval in = Interval.createTickInterval(2);
30 30
31 @Override 31 @Override
32 public void tick(PossibleEvent pe) 32 public void tick(PossibleEvent pe)
@@ -56,7 +56,7 @@ public enum AnimationType {
56 */ 56 */
57 TurnLeft(true, true) 57 TurnLeft(true, true)
58 { 58 {
59 Interval in = Interval.createTickInterval(2); 59 transient Interval in = Interval.createTickInterval(2);
60 60
61 @Override 61 @Override
62 public void tick(PossibleEvent pe) 62 public void tick(PossibleEvent pe)
@@ -73,7 +73,7 @@ public enum AnimationType {
73 */ 73 */
74 TurnRight(true, true) 74 TurnRight(true, true)
75 { 75 {
76 Interval in = Interval.createTickInterval(2); 76 transient Interval in = Interval.createTickInterval(2);
77 77
78 @Override 78 @Override
79 public void tick(PossibleEvent pe) 79 public void tick(PossibleEvent pe)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java index edfdb8f..9c5bf14 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/CommonEvent.java
@@ -51,11 +51,13 @@ public class CommonEvent {
51 this.callback = callback; 51 this.callback = callback;
52 } 52 }
53 53
54 public EventCallTime getCalltime() { 54 public EventCallTime getCalltime()
55 {
55 return calltime; 56 return calltime;
56 } 57 }
57 58
58 public void setCalltime(EventCallTime calltime) { 59 public void setCalltime(EventCallTime calltime)
60 {
59 this.calltime = calltime; 61 this.calltime = calltime;
60 } 62 }
61 63
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java index e24b79c..9cb67ba 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java
@@ -59,10 +59,10 @@ public class EventHandler {
59 * Also reset the viewpoint in case the viewpoint was 59 * Also reset the viewpoint in case the viewpoint was
60 * fixed during the thread */ 60 * fixed during the thread */
61 61
62 SpecialEvent.mapView.setViewpoint(new AutomaticViewpoint(SpecialEvent.mapView.getCurrentMap())); 62 new SpecialEvent().ResetViewpoint();
63 } catch (ResourceNotFoundException ex) 63 } catch (ResourceNotFoundException ex)
64 { 64 {
65 PuzzleApplication.INSTANCE.reportError(ex); 65 PuzzleApplication.reportError(ex);
66 } 66 }
67 } 67 }
68 }; 68 };
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java index 7120a91..d790195 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java
@@ -14,6 +14,8 @@ import java.util.Vector;
14 */ 14 */
15public class EventList extends Vector<LayerEvent> { 15public class EventList extends Vector<LayerEvent> {
16 16
17 private static final long serialVersionUID = 765438545;
18
17 public EventList(Map parentMap) 19 public EventList(Map parentMap)
18 { 20 {
19 setParentMap(parentMap); 21 setParentMap(parentMap);
@@ -62,7 +64,7 @@ public class EventList extends Vector<LayerEvent> {
62 return super.add(o); 64 return super.add(o);
63 } 65 }
64 66
65 private Map parentMap = null; 67 private transient Map parentMap = null;
66 public Map getParentMap() 68 public Map getParentMap()
67 { 69 {
68 return parentMap; 70 return parentMap;
@@ -77,4 +79,34 @@ public class EventList extends Vector<LayerEvent> {
77 } 79 }
78 } 80 }
79 81
82 @Override
83 public int hashCode()
84 {
85 int hash = 3;
86 hash = 59 * hash + (this.parentMap != null ? this.parentMap.hashCode() : 0);
87 return hash;
88 }
89
90 @Override
91 public boolean equals(Object obj)
92 {
93 if (obj == null)
94 {
95 return false;
96 }
97
98 if (getClass() != obj.getClass())
99 {
100 return false;
101 }
102
103 final EventList other = (EventList) obj;
104 if (this.parentMap != other.parentMap && (this.parentMap == null || !this.parentMap.equals(other.parentMap)))
105 {
106 return false;
107 }
108
109 return true;
110 }
111
80} 112}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java index 5db87a0..1f5607e 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/HeroEvent.java
@@ -14,12 +14,18 @@ import com.fourisland.fourpuzzle.database.GameCharacter;
14import com.fourisland.fourpuzzle.gamestate.mapview.Map; 14import com.fourisland.fourpuzzle.gamestate.mapview.Map;
15import com.fourisland.fourpuzzle.gamestate.mapview.MapViewGameState; 15import com.fourisland.fourpuzzle.gamestate.mapview.MapViewGameState;
16import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; 16import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic;
17import java.io.IOException;
18import java.io.ObjectInputStream;
19import java.io.ObjectOutputStream;
20import java.io.Serializable;
17 21
18/** 22/**
19 * 23 *
20 * @author hatkirby 24 * @author hatkirby
21 */ 25 */
22public class HeroEvent extends AbstractEvent implements Event { 26public class HeroEvent extends AbstractEvent implements Event, Serializable {
27
28 private static final long serialVersionUID = 402340890;
23 29
24 public HeroEvent() 30 public HeroEvent()
25 { 31 {
@@ -73,5 +79,27 @@ public class HeroEvent extends AbstractEvent implements Event {
73 { 79 {
74 return ((MapViewGameState) Game.getGameState()).getCurrentMap(); 80 return ((MapViewGameState) Game.getGameState()).getCurrentMap();
75 } 81 }
82
83 /**
84 * Serialize this HeroEvent instance
85 *
86 * When serializing a HeroEvent, the only information that is really
87 * necessary is the Hero's location and direction, because all other
88 * important information is serialized by SaveFile.
89 *
90 * @serialData The Hero's location (as a Point object) is emitted, followed
91 * by the a Direction object representing the Hero's direction.
92 */
93 private void writeObject(ObjectOutputStream s) throws IOException
94 {
95 s.writeObject(getLocation());
96 s.writeObject(getDirection());
97 }
98
99 private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
100 {
101 setLocation((Point) s.readObject());
102 setDirection((Direction) s.readObject());
103 }
76 104
77} 105}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java index b722b68..7bd0c42 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java
@@ -26,7 +26,7 @@ public final class ImmutableEvent
26 26
27 public String getLabel() 27 public String getLabel()
28 { 28 {
29 return new String(ev.getLabel()); 29 return ev.getLabel();
30 } 30 }
31 31
32 public Point getLocation() 32 public Point getLocation()
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 2db33f7..30db7a2 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
@@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch;
30 */ 30 */
31public class SpecialEvent { 31public class SpecialEvent {
32 32
33 protected static MapViewGameState mapView = null; 33 private static MapViewGameState mapView = null;
34 public static void setMapView(MapViewGameState mapView) 34 public static void setMapView(MapViewGameState mapView)
35 { 35 {
36 SpecialEvent.mapView = mapView; 36 SpecialEvent.mapView = mapView;
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java index 78dd991..a63feda 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/movement/CustomMovementType.java
@@ -7,6 +7,7 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.movement;
7 7
8import com.fourisland.fourpuzzle.Direction; 8import com.fourisland.fourpuzzle.Direction;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.ImmutableEvent; 9import com.fourisland.fourpuzzle.gamestate.mapview.event.ImmutableEvent;
10import java.util.Arrays;
10 11
11/** 12/**
12 * CustomMovementEvent takes an array of Directions and directions the event 13 * CustomMovementEvent takes an array of Directions and directions the event
@@ -22,7 +23,7 @@ public class CustomMovementType implements MovementType {
22 23
23 public CustomMovementType(Direction[] moves) 24 public CustomMovementType(Direction[] moves)
24 { 25 {
25 this.moves = moves; 26 this.moves = Arrays.copyOf(moves, moves.length);
26 } 27 }
27 28
28 public Direction nextMovement(ImmutableEvent ev) 29 public Direction nextMovement(ImmutableEvent ev)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java index 02744d0..daceffd 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java
@@ -7,6 +7,7 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove;
7 7
8import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; 8import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
9import java.awt.Point; 9import java.awt.Point;
10import java.util.Arrays;
10 11
11/** 12/**
12 * LoopUntilCollisionMoveEvent takes an array of <b>MoveEvent</b>s and repeatedly 13 * LoopUntilCollisionMoveEvent takes an array of <b>MoveEvent</b>s and repeatedly
@@ -24,7 +25,7 @@ public class LoopUntilCollisionMoveEvent implements MoveEvent {
24 25
25 public LoopUntilCollisionMoveEvent(MoveEvent[] moves) 26 public LoopUntilCollisionMoveEvent(MoveEvent[] moves)
26 { 27 {
27 this.moves = moves; 28 this.moves = Arrays.copyOf(moves, moves.length);
28 } 29 }
29 30
30 public void doAction(Event ev) 31 public void doAction(Event ev)
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java index d05a3d8..dae49cb 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java
@@ -9,6 +9,7 @@ import com.fourisland.fourpuzzle.Game;
9import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; 9import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;
10import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; 10import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent;
11import java.util.ArrayList; 11import java.util.ArrayList;
12import java.util.Arrays;
12import java.util.List; 13import java.util.List;
13import java.util.Vector; 14import java.util.Vector;
14import java.util.concurrent.ExecutorService; 15import java.util.concurrent.ExecutorService;
@@ -34,7 +35,7 @@ public class MoveEventThread implements Runnable {
34 public MoveEventThread(Event ev, MoveEvent[] actions) 35 public MoveEventThread(Event ev, MoveEvent[] actions)
35 { 36 {
36 this.ev = ev; 37 this.ev = ev;
37 this.actions = actions; 38 this.actions = Arrays.copyOf(actions, actions.length);
38 } 39 }
39 40
40 public void start() 41 public void start()
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/MovingViewpoint.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/MovingViewpoint.java index e6db32b..edaa580 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/MovingViewpoint.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/MovingViewpoint.java
@@ -39,7 +39,7 @@ public class MovingViewpoint implements Viewpoint {
39 this.sy = sy; 39 this.sy = sy;
40 this.dx = dx; 40 this.dx = dx;
41 this.dy = dy; 41 this.dy = dy;
42 this.speed = length / Game.FPS; 42 this.speed = length / (double) Game.FPS;
43 this.xdist = dx - sx; 43 this.xdist = dx - sx;
44 this.ydist = dy - sy; 44 this.ydist = dy - sy;
45 this.callback = callback; 45 this.callback = callback;
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/ShakingViewpoint.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/ShakingViewpoint.java index f2b40e7..80d36b3 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/ShakingViewpoint.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/ShakingViewpoint.java
@@ -28,7 +28,7 @@ public class ShakingViewpoint implements Viewpoint {
28 this.length = length; 28 this.length = length;
29 this.x = x; 29 this.x = x;
30 this.y = y; 30 this.y = y;
31 this.in = Interval.createMillisInterval(1000 / speed.getSpeed()); 31 this.in = Interval.createMillisInterval(1000F / speed.getSpeed());
32 this.speed = speed; 32 this.speed = speed;
33 this.callback = callback; 33 this.callback = callback;
34 this.start = System.currentTimeMillis(); 34 this.start = System.currentTimeMillis();
diff --git a/src/com/fourisland/fourpuzzle/transition/SlideTransition.java b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java index aa91061..c7b7ad2 100755 --- a/src/com/fourisland/fourpuzzle/transition/SlideTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java
@@ -42,7 +42,7 @@ public class SlideTransition implements MultidirectionalTransition {
42 way = SlideDirection.SideToSide; 42 way = SlideDirection.SideToSide;
43 } 43 }
44 44
45 wait = Math.round(max / (Game.FPS/2)); 45 wait = max / (Game.FPS/2);
46 } 46 }
47 47
48 public TransitionDirection getDirection() 48 public TransitionDirection getDirection()
diff --git a/src/com/fourisland/fourpuzzle/util/Interval.java b/src/com/fourisland/fourpuzzle/util/Interval.java index 1e5e8f3..0b0125d 100755 --- a/src/com/fourisland/fourpuzzle/util/Interval.java +++ b/src/com/fourisland/fourpuzzle/util/Interval.java
@@ -33,7 +33,7 @@ public class Interval {
33 private long last = System.nanoTime(); 33 private long last = System.nanoTime();
34 public boolean isElapsed() 34 public boolean isElapsed()
35 { 35 {
36 if (PuzzleApplication.debugSpeed) 36 if (Interval.getDebugSpeed())
37 { 37 {
38 return true; 38 return true;
39 } 39 }
@@ -47,5 +47,16 @@ public class Interval {
47 47
48 return false; 48 return false;
49 } 49 }
50
51 private static boolean debugSpeed = false;
52 public static void setDebugSpeed(boolean debugSpeed)
53 {
54 Interval.debugSpeed = debugSpeed;
55 }
56
57 public static boolean getDebugSpeed()
58 {
59 return debugSpeed;
60 }
50 61
51} 62}
diff --git a/src/com/fourisland/fourpuzzle/util/MidiParser.java b/src/com/fourisland/fourpuzzle/util/MidiParser.java index 3d6c06b..408ea75 100644 --- a/src/com/fourisland/fourpuzzle/util/MidiParser.java +++ b/src/com/fourisland/fourpuzzle/util/MidiParser.java
@@ -27,7 +27,7 @@ public class MidiParser {
27 27
28 public Sequence parse() throws InvalidMidiDataException 28 public Sequence parse() throws InvalidMidiDataException
29 { 29 {
30 Sequence temp = temp = new Sequence(seq.getDivisionType(), seq.getResolution()); 30 Sequence temp = new Sequence(seq.getDivisionType(), seq.getResolution());
31 31
32 for (Track t : seq.getTracks()) 32 for (Track t : seq.getTracks())
33 { 33 {
diff --git a/src/com/fourisland/fourpuzzle/util/ObjectLoader.java b/src/com/fourisland/fourpuzzle/util/ObjectLoader.java index f1cb157..efeec7e 100755 --- a/src/com/fourisland/fourpuzzle/util/ObjectLoader.java +++ b/src/com/fourisland/fourpuzzle/util/ObjectLoader.java
@@ -55,7 +55,7 @@ public class ObjectLoader {
55 { 55 {
56 if (!imageCache.containsKey(type + "/" + name)) 56 if (!imageCache.containsKey(type + "/" + name))
57 { 57 {
58 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 58 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
59 String filename = getFilename(type, name, "png"); 59 String filename = getFilename(type, name, "png");
60 InputStream str = rm.getClassLoader().getResourceAsStream(filename); 60 InputStream str = rm.getClassLoader().getResourceAsStream(filename);
61 BufferedImage bImg = null; 61 BufferedImage bImg = null;
@@ -75,7 +75,7 @@ public class ObjectLoader {
75 { 75 {
76 if (!imageCache.containsKey(type + "/" + name)) 76 if (!imageCache.containsKey(type + "/" + name))
77 { 77 {
78 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 78 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
79 String filename = getFilename(type, name, "png"); 79 String filename = getFilename(type, name, "png");
80 InputStream str = rm.getClassLoader().getResourceAsStream(filename); 80 InputStream str = rm.getClassLoader().getResourceAsStream(filename);
81 BufferedImage bImg = null; 81 BufferedImage bImg = null;
@@ -107,7 +107,7 @@ public class ObjectLoader {
107 { 107 {
108 if (!musicCache.containsKey(name)) 108 if (!musicCache.containsKey(name))
109 { 109 {
110 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 110 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
111 String filename = getFilename("Music", name, "mid"); 111 String filename = getFilename("Music", name, "mid");
112 InputStream str = rm.getClassLoader().getResourceAsStream(filename); 112 InputStream str = rm.getClassLoader().getResourceAsStream(filename);
113 Sequence seq = null; 113 Sequence seq = null;
@@ -136,7 +136,7 @@ public class ObjectLoader {
136 { 136 {
137 if (!soundCache.containsKey("Sound/" + name)) 137 if (!soundCache.containsKey("Sound/" + name))
138 { 138 {
139 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 139 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
140 String filename = getFilename("Sound", name, "wav"); 140 String filename = getFilename("Sound", name, "wav");
141 InputStream soundFile = rm.getClassLoader().getResourceAsStream(filename); 141 InputStream soundFile = rm.getClassLoader().getResourceAsStream(filename);
142 AudioInputStream ais = null; 142 AudioInputStream ais = null;
@@ -173,7 +173,7 @@ public class ObjectLoader {
173 173
174 public static String getFilename(String type, String name, String ex) 174 public static String getFilename(String type, String name, String ex)
175 { 175 {
176 ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); 176 ResourceMap rm = PuzzleApplication.getInstance().getContext().getResourceManager().getResourceMap();
177 String f = rm.getResourcesDir() + type.toLowerCase() + "/" + name + "." + ex; 177 String f = rm.getResourcesDir() + type.toLowerCase() + "/" + name + "." + ex;
178 URL fu = rm.getClassLoader().getResource(f); 178 URL fu = rm.getClassLoader().getResource(f);
179 179
diff --git a/src/com/fourisland/fourpuzzle/util/PauseTimer.java b/src/com/fourisland/fourpuzzle/util/PauseTimer.java index f26f105..c3df5df 100644 --- a/src/com/fourisland/fourpuzzle/util/PauseTimer.java +++ b/src/com/fourisland/fourpuzzle/util/PauseTimer.java
@@ -5,8 +5,6 @@
5 5
6package com.fourisland.fourpuzzle.util; 6package com.fourisland.fourpuzzle.util;
7 7
8import com.fourisland.fourpuzzle.PuzzleApplication;
9
10/** 8/**
11 * 9 *
12 * @author hatkirby 10 * @author hatkirby
@@ -22,7 +20,7 @@ public class PauseTimer {
22 Interval in = Interval.createTickInterval(1); 20 Interval in = Interval.createTickInterval(1);
23 public boolean isElapsed() 21 public boolean isElapsed()
24 { 22 {
25 if (PuzzleApplication.debugSpeed) 23 if (Interval.getDebugSpeed())
26 { 24 {
27 return true; 25 return true;
28 } 26 }
diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index 8dce753..2dbd605 100755 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
@@ -61,18 +61,15 @@ public class ChoiceWindow implements Renderable, Inputable {
61 } 61 }
62 62
63 private List<String> choices; 63 private List<String> choices;
64 int numChoices;
65 boolean center; 64 boolean center;
66 private int width; 65 private int width;
67 private int height; 66 private int height;
68 BufferedImage cacheBase; 67 BufferedImage cacheBase;
69 int x; 68 int x;
70 int y; 69 int y;
71 String clickSound;
72 private ChoiceWindow(Builder builder) 70 private ChoiceWindow(Builder builder)
73 { 71 {
74 this.choices = builder.choices; 72 this.choices = builder.choices;
75 numChoices = choices.size();
76 this.center = builder.center; 73 this.center = builder.center;
77 74
78 for (String choice : choices) 75 for (String choice : choices)
@@ -211,6 +208,7 @@ public class ChoiceWindow implements Renderable, Inputable {
211 } 208 }
212 } 209 }
213 210
211 Object hasInputLock = new Object();
214 Boolean hasInput = false; 212 Boolean hasInput = false;
215 PauseTimer pt = new PauseTimer(0); 213 PauseTimer pt = new PauseTimer(0);
216 public void processInput(KeyInput key) 214 public void processInput(KeyInput key)
@@ -231,7 +229,7 @@ public class ChoiceWindow implements Renderable, Inputable {
231 } 229 }
232 } else if (key.isActionDown()) 230 } else if (key.isActionDown())
233 { 231 {
234 synchronized (hasInput) 232 synchronized (hasInputLock)
235 { 233 {
236 hasInput = true; 234 hasInput = true;
237 } 235 }
@@ -240,7 +238,7 @@ public class ChoiceWindow implements Renderable, Inputable {
240 238
241 public boolean hasInput() 239 public boolean hasInput()
242 { 240 {
243 synchronized (hasInput) 241 synchronized (hasInputLock)
244 { 242 {
245 return hasInput; 243 return hasInput;
246 } 244 }
diff --git a/src/com/fourisland/fourpuzzle/window/Window.java b/src/com/fourisland/fourpuzzle/window/Window.java index db1bfab..661f4a2 100644 --- a/src/com/fourisland/fourpuzzle/window/Window.java +++ b/src/com/fourisland/fourpuzzle/window/Window.java
@@ -26,7 +26,7 @@ public enum Window
26 }, 26 },
27 Selector(64) 27 Selector(64)
28 { 28 {
29 Interval in = Interval.createTickInterval(4); 29 transient Interval in = Interval.createTickInterval(4);
30 boolean isFlashing = false; 30 boolean isFlashing = false;
31 31
32 @Override 32 @Override