Web compilation fix, new logging, cleanup

This commit is contained in:
Anuken
2018-01-24 18:48:59 -05:00
parent 3900258b6c
commit 8b2f63ecb6
15 changed files with 43 additions and 35 deletions

View File

@@ -21,7 +21,7 @@ allprojects {
appName = "Mindustry" appName = "Mindustry"
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = 'ee4b46a'; uCoreVersion = '0eb75cc';
} }
repositories { repositories {

View File

@@ -16,6 +16,7 @@ text.about.button=About
text.name=Name: text.name=Name:
text.public=Public text.public=Public
text.players={0} players online text.players={0} players online
text.server.nomap=Loading custom maps not supported on web.
text.server.player.host={0} (host) text.server.player.host={0} (host)
text.players.single={0} player online text.players.single={0} player online
text.server.mismatch=Packet error: possible client/server version mismatch.\nMake sure you and the host have the\nlatest version of Mindustry! text.server.mismatch=Packet error: possible client/server version mismatch.\nMake sure you and the host have the\nlatest version of Mindustry!

View File

@@ -41,6 +41,7 @@ public class Mindustry extends ModuleCore {
@Override @Override
public void dispose() { public void dispose() {
GameState.set(State.menu);
platforms.onGameExit(); platforms.onGameExit();
Net.dispose(); Net.dispose();
super.dispose(); super.dispose();
@@ -73,7 +74,7 @@ public class Mindustry extends ModuleCore {
Locale locale = Locale.ENGLISH; Locale locale = Locale.ENGLISH;
Core.bundle = I18NBundle.createBundle(handle, locale); Core.bundle = I18NBundle.createBundle(handle, locale);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); UCore.error(e);
platforms.showError("Failed to find bundle!\nMake sure you have bundle.properties in the same directory\nas the jar file.\n\nIf the problem persists, try running it through the command prompt:\n" + platforms.showError("Failed to find bundle!\nMake sure you have bundle.properties in the same directory\nas the jar file.\n\nIf the problem persists, try running it through the command prompt:\n" +
"Hold left-shift, then right click and select 'open command prompt here'.\nThen, type in 'java -jar mindustry.jar' without quotes."); "Hold left-shift, then right click and select 'open command prompt here'.\nThen, type in 'java -jar mindustry.jar' without quotes.");
Gdx.app.exit(); Gdx.app.exit();

View File

@@ -103,6 +103,7 @@ public class NetClient extends Module {
}); });
Net.handle(CustomMapPacket.class, packet -> { Net.handle(CustomMapPacket.class, packet -> {
//custom map is always sent before world data //custom map is always sent before world data
Pixmap pixmap = NetworkIO.loadMap(packet.stream); Pixmap pixmap = NetworkIO.loadMap(packet.stream);
@@ -242,7 +243,7 @@ public class NetClient extends Module {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); UCore.error(e);
//do nothing else... //do nothing else...
//TODO fix //TODO fix
} }

View File

@@ -217,7 +217,7 @@ public class NetServer extends Module{
p.android = player.isAndroid; p.android = player.isAndroid;
Net.sendTo(dest, p, SendMode.tcp); Net.sendTo(dest, p, SendMode.tcp);
Gdx.app.error("Mindustry", "Replying to entity request (" + id + "): player, " + id); log("Replying to entity request (" + id + "): player, " + id);
} else if (Vars.control.enemyGroup.getByID(id) != null) { } else if (Vars.control.enemyGroup.getByID(id) != null) {
Enemy enemy = Vars.control.enemyGroup.getByID(id); Enemy enemy = Vars.control.enemyGroup.getByID(id);
EnemySpawnPacket e = new EnemySpawnPacket(); EnemySpawnPacket e = new EnemySpawnPacket();
@@ -229,7 +229,7 @@ public class NetServer extends Module{
e.type = enemy.type.id; e.type = enemy.type.id;
e.health = (short) enemy.health; e.health = (short) enemy.health;
Net.sendTo(dest, e, SendMode.tcp); Net.sendTo(dest, e, SendMode.tcp);
Gdx.app.error("Mindustry", "Replying to entity request(" + id + "): enemy, " + id); log("Replying to entity request(" + id + "): enemy, " + id);
} else { } else {
Gdx.app.error("Mindustry", "Entity request target not found!"); Gdx.app.error("Mindustry", "Entity request target not found!");
} }

View File

@@ -107,9 +107,9 @@ public class World extends Module{
} }
public Tile tile(int x, int y){ public Tile tile(int x, int y){
//if(tiles == null){ if(tiles == null){
// return null; return null;
//} }
if(!Mathf.inBounds(x, y, tiles)) return null; if(!Mathf.inBounds(x, y, tiles)) return null;
return tiles[x][y]; return tiles[x][y];
} }

View File

@@ -8,9 +8,9 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.*; import com.badlogic.gdx.utils.*;
import com.badlogic.gdx.utils.Json.Serializer; import com.badlogic.gdx.utils.Json.Serializer;
import com.badlogic.gdx.utils.JsonWriter.OutputType; import com.badlogic.gdx.utils.JsonWriter.OutputType;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.world.Map; import io.anuke.mindustry.world.Map;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Settings;
import io.anuke.ucore.graphics.Pixmaps; import io.anuke.ucore.graphics.Pixmaps;
@@ -154,7 +154,7 @@ public class Maps implements Disposable{
} }
return true; return true;
}catch(Exception e){ }catch(Exception e){
if(!Vars.android) e.printStackTrace(); if(!Vars.android) UCore.error(e);
Gdx.app.error("Mindustry-Maps", "Failed loading map file: " + file); Gdx.app.error("Mindustry-Maps", "Failed loading map file: " + file);
return false; return false;
} }

View File

@@ -13,6 +13,7 @@ import io.anuke.mindustry.world.ColorMapper.BlockPair;
import io.anuke.mindustry.world.Map; import io.anuke.mindustry.world.Map;
import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.Blocks;
import io.anuke.mindustry.world.blocks.SpecialBlocks; import io.anuke.mindustry.world.blocks.SpecialBlocks;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Core;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
@@ -61,7 +62,7 @@ public class MapEditorDialog extends Dialog{
} }
}catch (Exception e){ }catch (Exception e){
Vars.ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false))); Vars.ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
e.printStackTrace(); UCore.error(e);
} }
Vars.ui.loadfrag.hide(); Vars.ui.loadfrag.hide();
}); });
@@ -78,7 +79,7 @@ public class MapEditorDialog extends Dialog{
Pixmaps.write(editor.pixmap(), result); Pixmaps.write(editor.pixmap(), result);
}catch (Exception e){ }catch (Exception e){
Vars.ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false))); Vars.ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
if(!Vars.android) e.printStackTrace(); if(!Vars.android) UCore.error(e);
} }
Vars.ui.loadfrag.hide(); Vars.ui.loadfrag.hide();
}); });

View File

@@ -8,7 +8,10 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.resource.Upgrade; import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.ColorMapper;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.WorldGenerator;
import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.Blocks;
import io.anuke.mindustry.world.blocks.types.BlockPart; import io.anuke.mindustry.world.blocks.types.BlockPart;
import io.anuke.mindustry.world.blocks.types.Rock; import io.anuke.mindustry.world.blocks.types.Rock;
@@ -23,7 +26,7 @@ public class NetworkIO {
public static void writeMap(Pixmap map, OutputStream os){ public static void writeMap(Pixmap map, OutputStream os){
try(DataOutputStream stream = new DataOutputStream(os)){ try(DataOutputStream stream = new DataOutputStream(os)){
ByteBuffer buffer = map.getPixels(); ByteBuffer buffer = (ByteBuffer) map.getPixels();
UCore.log("Buffer position: " + buffer.position()); UCore.log("Buffer position: " + buffer.position());
stream.writeShort(map.getWidth()); stream.writeShort(map.getWidth());
stream.writeShort(map.getHeight()); stream.writeShort(map.getHeight());
@@ -44,12 +47,19 @@ public class NetworkIO {
short width = stream.readShort(); short width = stream.readShort();
short height = stream.readShort(); short height = stream.readShort();
Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
ByteBuffer buffer = pixmap.getPixels(); if(!Vars.gwt) {
buffer.position(0); ByteBuffer buffer = (ByteBuffer) pixmap.getPixels();
buffer.position(0);
for(int i = 0; i < width * height; i ++){ for (int i = 0; i < width * height; i++) {
byte id = stream.readByte(); byte id = stream.readByte();
buffer.putInt(ColorMapper.getColorByID(id)); buffer.putInt(ColorMapper.getColorByID(id));
}
}else{
for(int i = 0; i < width * height; i++){
byte id = stream.readByte();
pixmap.drawPixel(i % width, i /width, ColorMapper.getColorByID(id));
}
} }
return pixmap; return pixmap;

View File

@@ -5,6 +5,7 @@ import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.net.Host; import io.anuke.mindustry.net.Host;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.style.Drawable; import io.anuke.ucore.scene.style.Drawable;
@@ -235,7 +236,7 @@ public class JoinDialog extends FloatingDialog {
Vars.ui.showError(Bundles.format("text.connectfail", error)); Vars.ui.showError(Bundles.format("text.connectfail", error));
Vars.ui.loadfrag.hide(); Vars.ui.loadfrag.hide();
e.printStackTrace(); UCore.error(e);
} }
}); });
} }

View File

@@ -6,6 +6,7 @@ import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.Saves.SaveSlot; import io.anuke.mindustry.io.Saves.SaveSlot;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.ScrollPane; import io.anuke.ucore.scene.ui.ScrollPane;
@@ -173,7 +174,7 @@ public class LoadDialog extends FloatingDialog{
GameState.set(State.playing); GameState.set(State.playing);
Vars.ui.paused.hide(); Vars.ui.paused.hide();
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); UCore.error(e);
Vars.ui.paused.hide(); Vars.ui.paused.hide();
GameState.set(State.menu); GameState.set(State.menu);
Vars.control.reset(); Vars.control.reset();

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.distribution;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
public class TunnelConveyor extends Block{ public class TunnelConveyor extends Block{
@@ -34,7 +35,7 @@ public class TunnelConveyor extends Block{
try { try {
to.block().handleItem(item, to, tunnel); to.block().handleItem(item, to, tunnel);
}catch (NullPointerException e){ }catch (NullPointerException e){
e.printStackTrace(); UCore.error(e);
} }
}); });
} }

View File

@@ -11,7 +11,7 @@
V2.97a.20150601 V2.97a.20150601
*/ */
(function(h,g){function K(sb,K){function ha(b){return c.preferFlash&&H&&!c.ignoreFlash&&c.flash[b]!==g&&c.flash[b]}function r(b){return function(d){var e=this._s;e&&e._a?d=b.call(this,d):(e&&e.id?c._wD(e.id+": Ignoring "+d.type):c._wD("HTML5::Ignoring "+d.type),d=null);return d}}this.setupOptions={url:sb||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3, (function(h,g){function K(sb,K){function ha(b){return c.preferFlash&&H&&!c.ignoreFlash&&c.flash[b]!==g&&c.flash[b]}function r(b){return function(d){var e=this._s;e&&e._a?d=b.call(this,d):(e&&e.id?c._wD(e.id+": Ignoring "+d.type):c._wD("HTML5::Ignoring "+d.type),d=null);return d}}this.setupOptions={url:sb||null,flashVersion:8,debugMode:!1,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3,
wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,forceUseGlobalHTML5Audio:!1,ignoreMobileRestrictions:!1,html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null, wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,forceUseGlobalHTML5Audio:!1,ignoreMobileRestrictions:!1,html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,
usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1}, usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},
ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},opus:{type:["audio/ogg; codecs=opus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=K||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20150601";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock= ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},opus:{type:["audio/ogg; codecs=opus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=K||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20150601";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=

View File

@@ -156,6 +156,7 @@ public class KryoServer implements ServerProvider {
Thread thread = new Thread(() ->{ Thread thread = new Thread(() ->{
try { try {
server.close(); server.close();
UCore.log("Killing web server...");
try { try {
if (webServer != null) webServer.stop(1); //please die, right now if (webServer != null) webServer.stop(1); //please die, right now
}catch(Exception e){ }catch(Exception e){
@@ -167,6 +168,7 @@ public class KryoServer implements ServerProvider {
worker.interrupt(); worker.interrupt();
} }
} }
UCore.log("Killed web server.");
}catch (Exception e){ }catch (Exception e){
Gdx.app.postRunnable(() -> {throw new RuntimeException(e);}); Gdx.app.postRunnable(() -> {throw new RuntimeException(e);});
} }

View File

@@ -1,11 +0,0 @@
package io.anuke.kryonet;
import org.java_websocket.WebSocketServerFactory;
public class SSLGen {
public static WebSocketServerFactory getFactory(){
//TODO implement
return null;
}
}