summary refs log tree commit diff stats
path: root/src/com
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-16 12:22:38 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-16 12:22:38 -0500
commit112d6b869467e4d5756227e4a5bfc8359bd5d884 (patch)
tree8acfe29de4601747d00f2eb23703da6bed1437cb /src/com
parent63de51fec9a46ffa6e30a6f6e5cf2f91058e90cb (diff)
downloadfourpuzzle-112d6b869467e4d5756227e4a5bfc8359bd5d884.tar.gz
fourpuzzle-112d6b869467e4d5756227e4a5bfc8359bd5d884.tar.bz2
fourpuzzle-112d6b869467e4d5756227e4a5bfc8359bd5d884.zip
Engine: Fixed EventCall bug
Previously, if ObjectLoader threw a ResourceNotFoundException in an event thread, the event would not catch it and the event would simply end (and most likely restart if the user was still holding the action key).
Diffstat (limited to 'src/com')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java2
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java22
2 files changed, 21 insertions, 3 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java index f577cc2..7214528 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java
@@ -11,7 +11,7 @@ import java.util.concurrent.Future;
11 * 11 *
12 * @author hatkirby 12 * @author hatkirby
13 */ 13 */
14public abstract class EventCall extends SpecialEvent implements Runnable { 14public abstract class EventCall extends SpecialEvent {
15 15
16 public static EventCall getEmptyEventCall() 16 public static EventCall getEmptyEventCall()
17 { 17 {
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java index 05997e0..a8a626f 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java
@@ -5,6 +5,8 @@
5 5
6package com.fourisland.fourpuzzle.gamestate.mapview.event; 6package com.fourisland.fourpuzzle.gamestate.mapview.event;
7 7
8import com.fourisland.fourpuzzle.PuzzleApplication;
9import com.fourisland.fourpuzzle.util.ResourceNotFoundException;
8import java.util.concurrent.ExecutorService; 10import java.util.concurrent.ExecutorService;
9import java.util.concurrent.Executors; 11import java.util.concurrent.Executors;
10import java.util.concurrent.Future; 12import java.util.concurrent.Future;
@@ -32,13 +34,29 @@ public class EventHandler {
32 34
33 public static Future runEvent(EventCall callback) 35 public static Future runEvent(EventCall callback)
34 { 36 {
35 eventAction = eventExecutorService.submit(callback); 37 eventAction = eventExecutorService.submit(eventThread(callback));
36 return eventAction; 38 return eventAction;
37 } 39 }
38 40
39 public static Future runParallel(EventCall callback) 41 public static Future runParallel(EventCall callback)
40 { 42 {
41 return parallelExecutorService.submit(callback); 43 return parallelExecutorService.submit(eventThread(callback));
44 }
45
46 private static Runnable eventThread(final EventCall callback)
47 {
48 return new Runnable() {
49 public void run()
50 {
51 try
52 {
53 callback.run();
54 } catch (ResourceNotFoundException ex)
55 {
56 PuzzleApplication.INSTANCE.reportError(ex);
57 }
58 }
59 };
42 } 60 }
43 61
44 public static boolean isRunningEvent() 62 public static boolean isRunningEvent()