Merge branch 'master' into Textures
This commit is contained in:
@ -39,7 +39,6 @@ public class ProgressiaLauncher {
|
||||
CrashReports.registerProvider(new OpenALContextProvider());
|
||||
CrashReports.registerProvider(new ArgsContextProvider());
|
||||
CrashReports.registerProvider(new LanguageContextProvider());
|
||||
CrashReports.registerProvider(new StackTraceProvider());
|
||||
// Analyzers
|
||||
CrashReports.registerAnalyzer(new OutOfMemoryAnalyzer());
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
package ru.windcorp.progressia.client;
|
||||
|
||||
import ru.windcorp.progressia.Proxy;
|
||||
import ru.windcorp.progressia.client.audio.AudioSystem;
|
||||
import ru.windcorp.progressia.client.graphics.backend.GraphicsBackend;
|
||||
import ru.windcorp.progressia.client.graphics.backend.RenderTaskQueue;
|
||||
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
||||
@ -47,6 +48,8 @@ public class ClientProxy implements Proxy {
|
||||
|
||||
Atlases.loadAllAtlases();
|
||||
|
||||
AudioSystem.initialize();
|
||||
|
||||
ServerState.startServer();
|
||||
ClientState.connectToLocalServer();
|
||||
}
|
||||
|
@ -18,12 +18,10 @@
|
||||
package ru.windcorp.progressia.client;
|
||||
|
||||
import ru.windcorp.progressia.ProgressiaLauncher;
|
||||
import ru.windcorp.progressia.test.ALTest;
|
||||
|
||||
public class ProgressiaClientMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ALTest.execute();
|
||||
ProgressiaLauncher.launch(args, new ClientProxy());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
package ru.windcorp.progressia.client.audio;
|
||||
|
||||
public class AudioSystem {
|
||||
static public void initialize() {
|
||||
AudioManager.initAL();
|
||||
Thread shutdownHook = new Thread(AudioManager::closeAL, "AL Shutdown Hook");
|
||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||
loadAudioData();
|
||||
}
|
||||
|
||||
static void loadAudioData() {
|
||||
AudioManager.loadSound("assets/sounds/block_destroy_clap.ogg",
|
||||
"Progressia:BlockDestroy",
|
||||
AudioFormat.MONO);
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
package ru.windcorp.progressia.common.util;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
public class FloatMathUtils {
|
||||
|
||||
public static final float PI_F = (float) Math.PI;
|
||||
|
||||
public static float floor(float x) {
|
||||
return (float) FastMath.floor(x);
|
||||
return (float) Math.floor(x);
|
||||
}
|
||||
|
||||
public static float normalizeAngle(float a) {
|
||||
|
@ -2,14 +2,11 @@ package ru.windcorp.progressia.common.util.crash;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.core.util.StringBuilderWriter;
|
||||
|
||||
import ru.windcorp.jputil.chars.StringUtil;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -88,6 +85,8 @@ public class CrashReports {
|
||||
* @return {@code null}, although this method never returns normally. Provided for convenience.
|
||||
*/
|
||||
public static RuntimeException crash(Throwable throwable, String messageFormat, Object... args) {
|
||||
final StackTraceElement[] reportStackTrace;
|
||||
|
||||
if (throwable instanceof ReportedException) {
|
||||
ReportedException reportedException = (ReportedException) throwable;
|
||||
|
||||
@ -95,6 +94,10 @@ public class CrashReports {
|
||||
throwable = reportedException.getCause();
|
||||
messageFormat = reportedException.getMessageFormat();
|
||||
args = reportedException.getArgs();
|
||||
|
||||
reportStackTrace = reportedException.getStackTrace();
|
||||
} else {
|
||||
reportStackTrace = getCurrentStackTrace();
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
@ -127,7 +130,9 @@ public class CrashReports {
|
||||
|
||||
appendMessageFormat(output, messageFormat, args);
|
||||
|
||||
appendStackTrace(output, throwable);
|
||||
appendStackTrace(output, reportStackTrace, "Reported at:");
|
||||
output.append('\n');
|
||||
appendThrowable(output, throwable);
|
||||
|
||||
export(output.toString());
|
||||
|
||||
@ -135,7 +140,14 @@ public class CrashReports {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void appendContextProviders(StringBuilder output) {
|
||||
private static StackTraceElement[] getCurrentStackTrace() {
|
||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
final int trim = 3;
|
||||
|
||||
return Arrays.copyOfRange(stackTrace, trim, stackTrace.length);
|
||||
}
|
||||
|
||||
private static void appendContextProviders(StringBuilder output) {
|
||||
|
||||
// Do a local copy to avoid deadlocks -OLEGSHA
|
||||
ContextProvider[] localProvidersCopy = PROVIDERS.toArray(new ContextProvider[PROVIDERS.size()]);
|
||||
@ -225,22 +237,22 @@ public class CrashReports {
|
||||
addSeparator(output);
|
||||
}
|
||||
|
||||
private static void appendStackTrace(StringBuilder output, Throwable throwable) {
|
||||
output.append("Stacktrace: \n");
|
||||
|
||||
private static void appendThrowable(StringBuilder output, Throwable throwable) {
|
||||
if (throwable == null) {
|
||||
output.append("no Throwable provided").append("\n");
|
||||
output.append("No Throwable provided").append("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Formatting to a human-readable string
|
||||
Writer sink = new StringBuilderWriter(output);
|
||||
try {
|
||||
throwable.printStackTrace(new PrintWriter(sink));
|
||||
} catch (Exception e) {
|
||||
// PLAK
|
||||
|
||||
output.append("Reported Throwable:\n");
|
||||
appendStackTrace(output, throwable.getStackTrace(), throwable.toString());
|
||||
}
|
||||
|
||||
private static void appendStackTrace(StringBuilder output, StackTraceElement[] stackTrace, String header) {
|
||||
output.append(header).append('\n');
|
||||
|
||||
for (StackTraceElement element : stackTrace) {
|
||||
output.append('\t').append(element).append('\n');
|
||||
}
|
||||
output.append("\n");
|
||||
}
|
||||
|
||||
private static void export(String report) {
|
||||
|
@ -1,24 +0,0 @@
|
||||
package ru.windcorp.progressia.common.util.crash.providers;
|
||||
|
||||
import ru.windcorp.progressia.common.util.crash.ContextProvider;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class StackTraceProvider implements ContextProvider {
|
||||
@Override
|
||||
public void provideContext(Map<String, String> output) {
|
||||
StackTraceElement[] stackTraceBuffer = Thread.currentThread().getStackTrace();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("\n");
|
||||
for (int i = 4; i < stackTraceBuffer.length; i++) {
|
||||
sb.append('\t').append(stackTraceBuffer[i].toString()).append("\n");
|
||||
}
|
||||
|
||||
output.put("Reported from " + Thread.currentThread().getName(), sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Stack Trace Context Provider";
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package ru.windcorp.progressia.test;
|
||||
|
||||
import ru.windcorp.progressia.client.audio.AudioFormat;
|
||||
import ru.windcorp.progressia.client.audio.AudioManager;
|
||||
import ru.windcorp.progressia.client.audio.Music;
|
||||
|
||||
public class ALTest {
|
||||
static private void initializeAL() {
|
||||
AudioManager.initAL();
|
||||
}
|
||||
|
||||
static void loadALData() {
|
||||
AudioManager.loadSound("assets/sounds/sample_stereo.ogg",
|
||||
"Progressia:SampleStereo",
|
||||
AudioFormat.STEREO);
|
||||
AudioManager.loadSound("assets/sounds/block_destroy_clap.ogg",
|
||||
"Progressia:BlockDestroy",
|
||||
AudioFormat.MONO);
|
||||
Music music = new Music("Progressia:SampleStereo");
|
||||
music.setGain(0.5f);
|
||||
//music.play(false);
|
||||
}
|
||||
|
||||
public static void execute() {
|
||||
initializeAL();
|
||||
Thread shutdownHook = new Thread(AudioManager::closeAL, "AL Shutdown Hook");
|
||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||
loadALData();
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user