From c78a6aac7ef22daf0cd262fa0016abbb9d844c89 Mon Sep 17 00:00:00 2001 From: totemo Date: Fri, 9 Oct 2015 08:09:11 +1030 Subject: [PATCH] Fix crashes loading files and clearing edits, apparently caused by changes to how 1.8 uses threads. --- Changes.md | 4 ++ build/build_watson.xml | 2 +- build/buildnumber.txt | 4 +- res/litemod.json | 4 +- src/watson/db/BlockEditSet.java | 112 +++++++++++--------------------- 5 files changed, 48 insertions(+), 78 deletions(-) diff --git a/Changes.md b/Changes.md index b3fcbd9..c3fcfbc 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,9 @@ Change History ============== +0.12.1.132-mc1.8.0 +------------------ +* Fix crashes loading files and clearing edits, apparently caused by changes to how 1.8 uses threads. + 0.12.0.130-mc1.8.0 ------------------ * Added key bindings to show a Watson in-game GUI, teleport to next or previous ore (/w tp next|prev) and queries of edits before and after the selection (/w pre|post). diff --git a/build/build_watson.xml b/build/build_watson.xml index 342da4d..ebda0e2 100644 --- a/build/build_watson.xml +++ b/build/build_watson.xml @@ -17,7 +17,7 @@ - + diff --git a/build/buildnumber.txt b/build/buildnumber.txt index 88ad0c6..8316683 100644 --- a/build/buildnumber.txt +++ b/build/buildnumber.txt @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Tue Sep 22 18:53:31 ACST 2015 -build.number=131 +#Fri Oct 09 08:04:08 ACDT 2015 +build.number=133 diff --git a/res/litemod.json b/res/litemod.json index 59ee2db..2fb1d45 100644 --- a/res/litemod.json +++ b/res/litemod.json @@ -4,8 +4,8 @@ "name": "watson", "mcversion": "1.8.0", - "version": "0.12.0.130-mc1.8.0", - "revision": "130", + "version": "0.12.1.132-mc1.8.0", + "revision": "132", "author": "totemo", "description": "A 3-D log visualisation tool.", "classTransformerClasses": [ "watson.transformer.WatsonTransformer" ] diff --git a/src/watson/db/BlockEditSet.java b/src/watson/db/BlockEditSet.java index 7d7cfbb..7fee47f 100644 --- a/src/watson/db/BlockEditSet.java +++ b/src/watson/db/BlockEditSet.java @@ -15,11 +15,6 @@ import java.util.regex.Pattern; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; - -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - import watson.Configuration; import watson.Controller; import watson.DisplaySettings; @@ -45,11 +40,11 @@ public BlockEditSet() // -------------------------------------------------------------------------- /** * Load additional entries from the specified file. - * + * * @param file the file to load. * @return the number of edits loaded. */ - public int load(File file) + public synchronized int load(File file) throws Exception { BufferedReader reader = new BufferedReader(new FileReader(file)); @@ -84,7 +79,7 @@ public int load(File file) int z = Integer.parseInt(edit.group(13)); BlockType type = BlockTypeRegistry.instance.getBlockTypeByIdData(id, - data); + data); blockEdit = new BlockEdit(time.getTimeInMillis(), player, created, x, y, z, type); addBlockEdit(blockEdit); @@ -121,20 +116,20 @@ public int load(File file) // -------------------------------------------------------------------------- /** * Save all {@link BlockEdit}s to the specified file. - * + * * Each line is of the form: - * + * *
    * YYYY-MM-DD|hh:mm:ss|action|id|data|x|y|z
    * 
- * + * * Where action is c (created) or d (destroyed) and id is the numeric block * type. - * + * * @param file the file to save. * @return the number of edits saved. */ - public int save(File file) + public synchronized int save(File file) throws IOException { PrintWriter writer = new PrintWriter(new BufferedWriter( @@ -152,7 +147,7 @@ public int save(File file) for (Annotation annotation : _annotations) { writer.format("#%d|%d|%d|%s\n", annotation.getX(), annotation.getY(), - annotation.getZ(), annotation.getText()); + annotation.getZ(), annotation.getText()); } return editCount; } @@ -166,7 +161,7 @@ public int save(File file) /** * Remove all entries from the list. */ - public void clear() + public synchronized void clear() { _playerEdits.clear(); _annotations.clear(); @@ -176,14 +171,14 @@ public void clear() // -------------------------------------------------------------------------- /** * Find an edit with the specified coordinates and, optionally, player. - * + * * @param x the x coordinate of the block * @param y the y coordinate of the block * @param z the z coordinate of the block * @param player the player name (can be null for a wildcard). * @return the matching edit, or null if not found. */ - public BlockEdit findEdit(int x, int y, int z, String player) + public synchronized BlockEdit findEdit(int x, int y, int z, String player) { if (player != null) { @@ -208,14 +203,14 @@ public BlockEdit findEdit(int x, int y, int z, String player) // -------------------------------------------------------------------------- /** * Add the specified edit to the list. - * + * * State variables describing the most recent edit (player, time, etc.) are * updated. - * + * * @param edit the BlockEdit describing an edit to add. * @return true if the edit passes the currently set filters. */ - public boolean addBlockEdit(BlockEdit edit) + public synchronized boolean addBlockEdit(BlockEdit edit) { return addBlockEdit(edit, true); } @@ -223,12 +218,12 @@ public boolean addBlockEdit(BlockEdit edit) // -------------------------------------------------------------------------- /** * Add the specified edit to the list. - * + * * @param edit the BlockEdit describing an edit to add. * @param updateVariables update the state variables for the most recent edit. * @return true if the edit passes the currently set filters. */ - public boolean addBlockEdit(BlockEdit edit, boolean updateVariables) + public synchronized boolean addBlockEdit(BlockEdit edit, boolean updateVariables) { if (Controller.instance.getFilters().isAcceptedPlayer(edit.player)) { @@ -269,7 +264,7 @@ public boolean addBlockEdit(BlockEdit edit, boolean updateVariables) * List the number and visibility of stored edits on a per player basis in the * dimension to which this BlockEditSet applies. */ - public void listEdits() + public synchronized void listEdits() { if (_playerEdits.size() == 0) { @@ -281,9 +276,9 @@ public void listEdits() for (PlayerEditSet editsByPlayer : _playerEdits.values()) { Chat.localOutput(String.format(Locale.US, - " %s - %d edits %s", editsByPlayer.getPlayer(), - editsByPlayer.getBlockEditCount(), - (editsByPlayer.isVisible() ? "shown" : "hidden"))); + " %s - %d edits %s", editsByPlayer.getPlayer(), + editsByPlayer.getBlockEditCount(), + (editsByPlayer.isVisible() ? "shown" : "hidden"))); } } } // listEdits @@ -291,11 +286,11 @@ public void listEdits() // -------------------------------------------------------------------------- /** * Set the visibility of the edits for the specified player. - * + * * @param player the name of the player. * @param visible if true, edits are shown. */ - public void setEditVisibility(String player, boolean visible) + public synchronized void setEditVisibility(String player, boolean visible) { player = player.toLowerCase(); PlayerEditSet editsByPlayer = _playerEdits.get(player); @@ -303,14 +298,14 @@ public void setEditVisibility(String player, boolean visible) { editsByPlayer.setVisible(visible); Chat.localOutput(String.format(Locale.US, - "%d edits by %s are now %s.", editsByPlayer.getBlockEditCount(), - editsByPlayer.getPlayer(), (editsByPlayer.isVisible() ? "shown" - : "hidden"))); + "%d edits by %s are now %s.", editsByPlayer.getBlockEditCount(), + editsByPlayer.getPlayer(), (editsByPlayer.isVisible() ? "shown" + : "hidden"))); } else { Chat.localError(String.format(Locale.US, - "There are no stored edits for %s.", player)); + "There are no stored edits for %s.", player)); } } // setEditVisibility @@ -318,7 +313,7 @@ public void setEditVisibility(String player, boolean visible) /** * @param player the name of the player. */ - public void removeEdits(String player) + public synchronized void removeEdits(String player) { player = player.toLowerCase(); PlayerEditSet editsByPlayer = _playerEdits.get(player); @@ -327,13 +322,13 @@ public void removeEdits(String player) _playerEdits.remove(player.toLowerCase()); getOreDB().removeDeposits(player); Chat.localOutput(String.format(Locale.US, - "%d edits by %s were removed.", editsByPlayer.getBlockEditCount(), - editsByPlayer.getPlayer())); + "%d edits by %s were removed.", editsByPlayer.getBlockEditCount(), + editsByPlayer.getPlayer())); } else { Chat.localError(String.format(Locale.US, - "There are no stored edits for %s.", player)); + "There are no stored edits for %s.", player)); } } // removeEdits @@ -341,7 +336,7 @@ public void removeEdits(String player) /** * Draw wireframe outlines of all blocks. */ - public void drawOutlines() + public synchronized void drawOutlines() { if (Controller.instance.getDisplaySettings().isOutlineShown()) { @@ -356,7 +351,7 @@ public void drawOutlines() /** * Draw direction vectors indicating motion of the miner. */ - public void drawVectors() + public synchronized void drawVectors() { DisplaySettings settings = Controller.instance.getDisplaySettings(); if (settings.areVectorsShown()) @@ -374,7 +369,7 @@ public void drawVectors() /** * Draw all of the annotations associated with this BlockEditSet. */ - public void drawAnnotations() + public synchronized void drawAnnotations() { DisplaySettings settings = Controller.instance.getDisplaySettings(); if (settings.areAnnotationsShown() && !_annotations.isEmpty()) @@ -386,30 +381,10 @@ public void drawAnnotations() } // if drawing annotations } // drawAnnotations - // -------------------------------------------------------------------------- - /** - * Experimental: draw a HUD overlay listing ores. - */ - public void drawHUD() - { - try - { - GlStateManager.pushMatrix(); - - Minecraft mc = Minecraft.getMinecraft(); - ScaledResolution scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - - } - finally - { - GlStateManager.popMatrix(); - } - } // drawHUD - // -------------------------------------------------------------------------- /** * Return the list of {@link Annotation}s. - * + * * @return the list of {@link Annotation}s. */ public ArrayList getAnnotations() @@ -420,7 +395,7 @@ public ArrayList getAnnotations() // -------------------------------------------------------------------------- /** * Return the spatial database of ore deposits. - * + * * @return the spatial database of ore deposits. */ public OreDB getOreDB() @@ -428,16 +403,6 @@ public OreDB getOreDB() return _oreDB; } - // -------------------------------------------------------------------------- - /** - * Start animating all of the edits in the list. - */ - public void startAnimating() - { - // Record current time as start time. - // Set cursor in _edits to oldest edit position. - } - // -------------------------------------------------------------------------- /** * A map from lowercase player name to {@link PlayerEditSet} containing that @@ -460,8 +425,9 @@ public void startAnimating() * The cycle of colours used to draw vectors for different players. */ protected static final ARGB[] _vectorColours = { - // Formatters... - new ARGB(204, 255, 255, 140), // Pale yellow. + + new ARGB(204, 255, 255, 140), // Pale + // yellow. new ARGB(204, 140, 158, 255), // Light blue. new ARGB(204, 255, 140, 140), // Salmon. new ARGB(204, 121, 255, 140), // Mint.