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