From 067f8b172ccc3d1a63788ef61cfc80a61723af8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 21 Apr 2014 16:32:28 +0200 Subject: [PATCH] del nullresource --- src/mightypork/gamecore/audio/NullAudio.java | 24 ------------------- src/mightypork/gamecore/audio/SoundBank.java | 11 ++------- .../gamecore/loading/AsyncResourceLoader.java | 1 - .../gamecore/loading/DeferredResource.java | 6 +---- .../gamecore/loading/NullResource.java | 12 ---------- 5 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 src/mightypork/gamecore/audio/NullAudio.java delete mode 100644 src/mightypork/gamecore/loading/NullResource.java diff --git a/src/mightypork/gamecore/audio/NullAudio.java b/src/mightypork/gamecore/audio/NullAudio.java deleted file mode 100644 index a73f0b3..0000000 --- a/src/mightypork/gamecore/audio/NullAudio.java +++ /dev/null @@ -1,24 +0,0 @@ -package mightypork.gamecore.audio; - - -import mightypork.gamecore.loading.NullResource; -import mightypork.util.logging.LogAlias; - - -/** - * Placeholder for cases where no matching audio is found and - * {@link NullPointerException} has to be avoided. - * - * @author MightyPork - */ -@LogAlias(name = "NullAudio") -public class NullAudio extends DeferredAudio implements NullResource { - - /** - * new null audio - */ - public NullAudio() - { - super(null); - } -} diff --git a/src/mightypork/gamecore/audio/SoundBank.java b/src/mightypork/gamecore/audio/SoundBank.java index 22223af..d8d6fe6 100644 --- a/src/mightypork/gamecore/audio/SoundBank.java +++ b/src/mightypork/gamecore/audio/SoundBank.java @@ -8,7 +8,6 @@ import mightypork.gamecore.audio.players.EffectPlayer; import mightypork.gamecore.audio.players.LoopPlayer; import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAdapter; -import mightypork.util.logging.Log; /** @@ -18,10 +17,6 @@ import mightypork.util.logging.Log; */ public class SoundBank extends AppAdapter { - private static final DeferredAudio NO_SOUND = new NullAudio(); - private static final LoopPlayer NULL_LOOP = new LoopPlayer(NO_SOUND, 0, 0, null); - private static final EffectPlayer NULL_EFFECT = new EffectPlayer(NO_SOUND, 0, 0, null); - private final Map effects = new HashMap<>(); private final Map loops = new HashMap<>(); @@ -76,8 +71,7 @@ public class SoundBank extends AppAdapter { { final LoopPlayer p = loops.get(key); if (p == null) { - Log.w("Requesting unknown sound loop \"" + key + "\"."); - return NULL_LOOP; + throw new RuntimeException("Unknown sound loop \"" + key + "\"."); } return p; } @@ -93,8 +87,7 @@ public class SoundBank extends AppAdapter { { final EffectPlayer p = effects.get(key); if (p == null) { - Log.w("Requesting unknown sound effect \"" + key + "\"."); - return NULL_EFFECT; + throw new RuntimeException("Unknown sound effect \"" + key + "\"."); } return p; } diff --git a/src/mightypork/gamecore/loading/AsyncResourceLoader.java b/src/mightypork/gamecore/loading/AsyncResourceLoader.java index 66cf9e3..b4c43c0 100644 --- a/src/mightypork/gamecore/loading/AsyncResourceLoader.java +++ b/src/mightypork/gamecore/loading/AsyncResourceLoader.java @@ -64,7 +64,6 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L public void loadResource(final Deferred resource) { if (resource.isLoaded()) return; - if (resource instanceof NullResource) return; // textures & fonts needs to be loaded in main thread if (resource.getClass().isAnnotationPresent(MustLoadInMainThread.class)) { diff --git a/src/mightypork/gamecore/loading/DeferredResource.java b/src/mightypork/gamecore/loading/DeferredResource.java index 28b08b7..058e6a0 100644 --- a/src/mightypork/gamecore/loading/DeferredResource.java +++ b/src/mightypork/gamecore/loading/DeferredResource.java @@ -7,9 +7,7 @@ import mightypork.util.logging.LogAlias; /** - * Deferred resource abstraction.
- * Resources implementing {@link NullResource} will be treated as fake and not - * attempted to load. + * Deferred resource abstraction. * * @author MightyPork */ @@ -42,8 +40,6 @@ public abstract class DeferredResource implements Deferred, Destroyable { loadFailed = false; - if (this instanceof NullResource) return; // don't even try - try { if (resource == null) { throw new NullPointerException("Resource string cannot be null for non-null resource."); diff --git a/src/mightypork/gamecore/loading/NullResource.java b/src/mightypork/gamecore/loading/NullResource.java deleted file mode 100644 index 7df2d11..0000000 --- a/src/mightypork/gamecore/loading/NullResource.java +++ /dev/null @@ -1,12 +0,0 @@ -package mightypork.gamecore.loading; - - -/** - * Resource that is used as a placeholder instead of an actual resource; this - * resource should not be attempted to be loaded. - * - * @author MightyPork - */ -public interface NullResource { - -}