mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 04:13:44 +07:00
Fixed GWT compile errors and server thread crashes
This commit is contained in:
parent
6083db5bd6
commit
5b25d94a3e
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.anuke.mindustry"
|
||||
android:versionCode="62"
|
||||
android:versionName="3.3b123" >
|
||||
android:versionCode="63"
|
||||
android:versionName="3.3b14" >
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
@ -22,7 +22,7 @@ allprojects {
|
||||
appName = "Mindustry"
|
||||
gdxVersion = '1.9.8'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = '4dee898'
|
||||
uCoreVersion = '82c0091'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -97,7 +97,6 @@ public class Vars{
|
||||
public static NetCommon netCommon;
|
||||
public static NetServer netServer;
|
||||
public static NetClient netClient;
|
||||
public static ServerControl serverControl;
|
||||
|
||||
public static Player player;
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class KryoServer implements ServerProvider {
|
||||
try {
|
||||
server.close();
|
||||
try {
|
||||
if (webServer != null) webServer.stop(1); //please die, right now
|
||||
if (webServer != null) webServer.stop(1);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -251,12 +251,11 @@ public class KryoServer implements ServerProvider {
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
Log.info("Disposing server.");
|
||||
try {
|
||||
if(serverThread != null) serverThread.interrupt();
|
||||
server.dispose();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Log.err(e);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -269,8 +268,9 @@ public class KryoServer implements ServerProvider {
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Log.err(e);
|
||||
}
|
||||
Log.info("Disposed server.");
|
||||
}
|
||||
|
||||
private void handleException(Exception e){
|
||||
|
@ -6,6 +6,16 @@ sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher"
|
||||
project.ext.assetsDir = new File("../core/assets");
|
||||
|
||||
ext.getDeployVersion = {
|
||||
if(project.gradle.startParameter.taskNames.size() == 0 || !project.gradle.startParameter.taskNames.first().contains("deploy")) return;
|
||||
|
||||
if(!project.hasProperty("deployversion")){
|
||||
throw new InvalidUserDataException("No version set. Set version with -Pdeployversion=name");
|
||||
}
|
||||
|
||||
return deployversion;
|
||||
}
|
||||
|
||||
task run(dependsOn: classes, type: JavaExec) {
|
||||
main = project.mainClassName
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
@ -37,4 +47,12 @@ task dist(type: Jar) {
|
||||
}
|
||||
}
|
||||
|
||||
task deploy(type: Copy){
|
||||
dependsOn "dist"
|
||||
|
||||
from "build/libs/server-release.jar"
|
||||
into "../deploy/";
|
||||
rename ("server-release.jar", appName + "-server-" + getDeployVersion() + ".jar");
|
||||
}
|
||||
|
||||
dist.dependsOn classes
|
||||
|
@ -1,6 +1,9 @@
|
||||
package io.anuke.mindustry;
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.core.Logic;
|
||||
import io.anuke.mindustry.core.NetCommon;
|
||||
import io.anuke.mindustry.core.NetServer;
|
||||
import io.anuke.mindustry.core.World;
|
||||
import io.anuke.mindustry.io.BlockLoader;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.ucore.modules.ModuleCore;
|
||||
@ -20,6 +23,6 @@ public class MindustryServer extends ModuleCore {
|
||||
module(world = new World());
|
||||
module(netServer = new NetServer());
|
||||
module(netCommon = new NetCommon());
|
||||
module(serverControl = new ServerControl());
|
||||
module(new ServerControl());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import com.badlogic.gdx.ApplicationLogger;
|
||||
import com.badlogic.gdx.Gdx;
|
@ -3,11 +3,7 @@ package io.anuke.mindustry.server;
|
||||
import com.badlogic.gdx.backends.headless.HeadlessApplication;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.MindustryServer;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ServerLauncher{
|
||||
|
||||
@ -16,42 +12,15 @@ public class ServerLauncher{
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
HeadlessApplication app = new HeadlessApplication(new MindustryServer()){
|
||||
@Override
|
||||
public boolean executeRunnables() {
|
||||
try {
|
||||
return super.executeRunnables();
|
||||
}catch(Throwable e) {
|
||||
Log.err(e);
|
||||
System.exit(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
new HeadlessApplication(new MindustryServer());
|
||||
|
||||
Method method = app.getClass().getDeclaredMethod("mainLoop");
|
||||
method.setAccessible(true);
|
||||
|
||||
//kill default libGDX thread
|
||||
//find and handle uncaught exceptions in libGDX thread
|
||||
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
||||
if(thread.getName().equals("\"HeadlessApplication\"")){
|
||||
thread.interrupt();
|
||||
if(thread.getName().equals("HeadlessApplication")){
|
||||
thread.setUncaughtExceptionHandler((t, throwable) -> System.exit(-1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//replace it with my own
|
||||
Thread mainLoopThread = new Thread("HeadlessApplication") {
|
||||
@Override
|
||||
public void run () {
|
||||
try {
|
||||
method.invoke(app);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
};
|
||||
mainLoopThread.start();
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user