Skip to content

Commit

Permalink
Merge branch 'develop' into feat/bytebuffer-serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWeird authored Nov 10, 2021
2 parents 505e7ff + 984d9e9 commit addbff5
Show file tree
Hide file tree
Showing 40 changed files with 619 additions and 545 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/kevint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Terasology.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ properties([

pipeline {
agent {
label 'ts-engine && heavy && java8'
label 'ts-engine && heavy && java11'
}
stages {
// declarative pipeline does `checkout scm` automatically when hitting first stage
stage('Setup') {
steps {
echo 'Automatically checked out the things!'
sh 'chmod +x gradlew'
sh './gradlew --version'
}
}

Expand Down
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ For more information about playing, like hot keys or server hosting, see the [de

#### Alternative Installation Methods

If you already have Java Runtime Environment (JRE) installed, you may use a direct download release as an alternative to using the [launcher](https://github.com/MovingBlocks/TerasologyLauncher/releases). Java versions 8 and 11 are supported.
If you already have Java Runtime Environment (JRE) installed, you may use a direct download release as an alternative to using the [launcher](https://github.com/MovingBlocks/TerasologyLauncher/releases). Java version 11 is supported.

Direct download stable builds are uploaded to [our release section here on GitHub](https://github.com/MovingBlocks/Terasology/releases) while the cutting-edge develop version can be downloaded direct [here from our Jenkins](https://jenkins.terasology.io/teraorg/job/Terasology/job/Omega/job/master/lastSuccessfulBuild/artifact/distros/omega/build/distributions/TerasologyOmega.zip)
Direct download stable builds are uploaded to [our release section here on GitHub](https://github.com/MovingBlocks/Terasology/releases) while the cutting-edge develop version can be downloaded direct [here from our Jenkins](https://jenkins.terasology.io/teraorg/job/Terasology/job/Omega/job/master/lastSuccessfulBuild/artifact/distros/omega/build/distributions/TerasologyOmega.zip).


## Developing
Expand Down
9 changes: 9 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ repositories {
@Suppress("UnstableApiUsage")
isAllowInsecureProtocol = true // 😱
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = URI("http://artifactory.terasology.org/artifactory/terasology-snapshot-local")
@Suppress("UnstableApiUsage")
isAllowInsecureProtocol = true // 😱
}
}

dependencies {
Expand Down
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/facade.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ dependencies {
// Make sure all module dependencies are available to the game in cacheModules.
"modules"(project(":modules"))
}

tasks.register<Test>("unitTest") {
group = "Verification"
description = "Runs unit tests (fast)"

useJUnitPlatform {
excludeTags("MteTest", "TteTest")
}
systemProperty("junit.jupiter.execution.timeout.default", "1m")
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ repositories {
isAllowInsecureProtocol = true // 😱
}
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = URI("http://artifactory.terasology.org/artifactory/terasology-snapshot-local")
isAllowInsecureProtocol = true // 😱
}
}
23 changes: 19 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ buildscript {
url = "http://artifactory.terasology.org/artifactory/virtual-repo-live"
allowInsecureProtocol = true // 😱
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = "http://artifactory.terasology.org/artifactory/terasology-snapshot-local"
allowInsecureProtocol = true // 😱
}
}

dependencies {
Expand Down Expand Up @@ -54,11 +62,18 @@ import org.jetbrains.gradle.ext.ActionDelegationConfig
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Test for right version of Java in use for running this script
assert org.gradle.api.JavaVersion.current().isJava8Compatible()
// Check for Java 8
if(!(JavaVersion.current() == JavaVersion.VERSION_1_8 || JavaVersion.current() == JavaVersion.VERSION_11)) {
assert org.gradle.api.JavaVersion.current().isJava11Compatible()
if(!(JavaVersion.current() == JavaVersion.VERSION_11)) {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Compiling with a JDK not 8 nor 11. While some other Javas may be safe to use any newer than 11 may cause issues. If you encounter oddities try Java 8 or 11. See https://github.com/MovingBlocks/Terasology/issues/3976. Current detected Java version is ${JavaVersion.current()} from vendor ${System.getProperty("java.vendor")} located at ${System.getProperty("java.home")}")
out.withStyle(Style.FailureHeader).println("""
WARNING: Compiling with a JDK of not version 11. While some other Javas may be
safe to use, any newer than 11 may cause issues.
If you encounter oddities try Java 11.
See https://github.com/MovingBlocks/Terasology/issues/3976.
Current detected Java version is ${JavaVersion.current()}
from vendor ${System.getProperty("java.vendor")}
located at ${System.getProperty("java.home")}
""")
}

// Declare "extra properties" (variables) for the project (and subs) - a Gradle thing that makes them special.
Expand Down
5 changes: 3 additions & 2 deletions config/gradle/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ apply plugin: 'org.sonarqube'

apply plugin: 'terasology-repositories'

sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_11
}

javadoc.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.terasology.engine.core.SimpleUri;
import org.terasology.engine.i18n.assets.TranslationData;
import org.terasology.engine.i18n.assets.TranslationFormat;
import org.terasology.gestalt.assets.ResourceUrn;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void testEmptyDataGenRoot() throws IOException, InvalidAssetFilenameExcep
ResourceUrn urn = createUrnFromFile(format, assetDataFile);

TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
assertEquals(new SimpleUri("engine:menu"), data.getProjectUri());
assertEquals(new ResourceUrn("engine:menu"), data.getProjectUrn());
assertEquals(Locale.ROOT, data.getLocale());
}

Expand Down
5 changes: 3 additions & 2 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ dependencies {
implementation "org.lwjgl:lwjgl-openal"
api "org.lwjgl:lwjgl-opengl"
implementation "org.lwjgl:lwjgl-stb"

api group: 'io.projectreactor', name: 'reactor-core', version: '3.4.7'

api group: 'io.projectreactor', name: 'reactor-core', version: '3.4.11'
api group: 'io.projectreactor.addons', name: 'reactor-extra', version: '3.4.5'
api group: 'org.joml', name: 'joml', version: '1.10.0'
api group: 'org.terasology.joml-ext', name: 'joml-geometry', version: '0.1.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Locale.Category;
import java.util.Optional;

import static java.lang.Math.max;
import static org.terasology.engine.config.flexible.SettingArgument.constraint;
import static org.terasology.engine.config.flexible.SettingArgument.defaultValue;
import static org.terasology.engine.config.flexible.SettingArgument.name;
Expand All @@ -31,7 +32,7 @@ public class SystemConfig extends AutoConfig {

public final Setting<Integer> maxThreads = setting(
type(Integer.class),
defaultValue(Runtime.getRuntime().availableProcessors() - 1),
defaultValue(max(1, Runtime.getRuntime().availableProcessors() - 1)),
name("Max threads(not yet)"),
constraint(new NumberRangeConstraint<>(0, Integer.MAX_VALUE, false, false))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import com.google.common.collect.Lists;
import org.terasology.engine.config.flexible.Setting;
import org.terasology.engine.config.flexible.constraints.LocaleConstraint;
import org.terasology.engine.core.SimpleUri;
import org.terasology.engine.i18n.TranslationProject;
import org.terasology.engine.i18n.TranslationSystem;
import org.terasology.engine.rendering.nui.layers.mainMenu.settings.LocaleRenderer;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.nui.UIWidget;
import org.terasology.nui.databinding.Binding;
import org.terasology.nui.widgets.UIDropdownScrollable;
Expand Down Expand Up @@ -58,8 +58,8 @@ public void set(Locale value) {
};

UIDropdownScrollable<Locale> dropdownScrollable = new UIDropdownScrollable<>();
SimpleUri menuUri = new SimpleUri("engine:menu");
TranslationProject menuProject = translationSystem.getProject(menuUri);
ResourceUrn menuUrn = new ResourceUrn("engine:menu");
TranslationProject menuProject = translationSystem.getProject(menuUrn);
List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
for (Locale languageExcluded : languagesExcluded) {
locales.remove(languageExcluded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.terasology.engine.monitoring.PerformanceMonitor;
import org.terasology.engine.rendering.assets.material.Material;
import org.terasology.engine.rendering.cameras.Camera;
import org.terasology.engine.rendering.cameras.SubmersibleCamera;
import org.terasology.engine.rendering.dag.RenderGraph;
import org.terasology.engine.rendering.world.WorldRenderer;
import org.terasology.engine.rendering.world.viewDistance.ViewDistance;
Expand All @@ -35,7 +34,7 @@ public class HeadlessWorldRenderer implements WorldRenderer {
private WorldProvider worldProvider;
private ChunkProvider chunkProvider;

private Camera noCamera = new NullCamera(null, null);
private Camera noCamera = new NullCamera();

/* CHUNKS */
private boolean pendingChunks;
Expand Down Expand Up @@ -76,8 +75,8 @@ public void onChunkUnloaded(Vector3ic pos) {
}

@Override
public SubmersibleCamera getActiveCamera() {
return (SubmersibleCamera) noCamera;
public Camera getActiveCamera() {
return noCamera;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.core.subsystem.headless.renderer;

import org.terasology.engine.config.RenderingConfig;
import org.terasology.engine.rendering.cameras.SubmersibleCamera;
import org.terasology.engine.world.WorldProvider;
import org.terasology.engine.rendering.cameras.Camera;

public final class NullCamera extends SubmersibleCamera {
public NullCamera(WorldProvider worldProvider, RenderingConfig renderingConfig) {
super(worldProvider, renderingConfig);
public final class NullCamera extends Camera {
public NullCamera() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package org.terasology.engine.i18n;

import org.terasology.engine.core.Uri;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.nui.translate.Translator;

Expand All @@ -22,7 +22,7 @@ public interface TranslationSystem extends Translator {
* @param name
* @return the project or <code>null</code>.
*/
TranslationProject getProject(Uri name);
TranslationProject getProject(ResourceUrn name);

/**
* If no perfect match is found for the default locale, fallback strategies will attempt to find the closest match.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.slf4j.LoggerFactory;
import org.terasology.engine.config.SystemConfig;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.SimpleUri;
import org.terasology.engine.core.Uri;
import org.terasology.engine.i18n.assets.Translation;
import org.terasology.engine.persistence.TemplateEngine;
import org.terasology.engine.persistence.TemplateEngineImpl;
Expand All @@ -32,7 +30,7 @@ public class TranslationSystemImpl implements TranslationSystem {
private static final Logger logger = LoggerFactory.getLogger(TranslationSystemImpl.class);

private final List<Consumer<TranslationProject>> changeListeners = new CopyOnWriteArrayList<>();
private final Map<Uri, TranslationProject> projects = new HashMap<>();
private final Map<ResourceUrn, TranslationProject> projects = new HashMap<>();

private final SystemConfig systemConfig;

Expand All @@ -55,21 +53,21 @@ public void refresh() {
Optional<Translation> asset = assetManager.getAsset(urn, Translation.class);
if (asset.isPresent()) {
Translation trans = asset.get();
Uri uri = trans.getProjectUri();
if (uri.isValid()) {
TranslationProject proj = projects.computeIfAbsent(uri, e -> new StandardTranslationProject());
ResourceUrn projectUrn = trans.getProjectUrn();
if (!projectUrn.getModuleName().isEmpty() && !projectUrn.getResourceName().isEmpty()) {
TranslationProject proj = projects.computeIfAbsent(projectUrn, e -> new StandardTranslationProject());
proj.add(trans);
trans.subscribe(this::onAssetChanged);
logger.info("Discovered " + trans);
} else {
logger.warn("Ignoring invalid project uri: {}", uri);
logger.warn("Ignoring invalid project projectUrn: {}", projectUrn);
}
}
}
}

@Override
public TranslationProject getProject(Uri name) {
public TranslationProject getProject(ResourceUrn name) {
return projects.get(name);
}

Expand All @@ -82,7 +80,7 @@ public String translate(String id) {
public String translate(String text, Locale otherLocale) {
TemplateEngine templateEngine = new TemplateEngineImpl(id -> {
ResourceUrn uri = new ResourceUrn(id);
SimpleUri projectUri = new SimpleUri(uri.getModuleName(), uri.getResourceName());
ResourceUrn projectUri = new ResourceUrn(uri.getModuleName(), uri.getResourceName());
TranslationProject project = getProject(projectUri);
if (project != null) {
Optional<String> opt = project.translate(uri.getFragmentName(), otherLocale);
Expand Down Expand Up @@ -112,7 +110,7 @@ public void unsubscribe(Consumer<TranslationProject> reloadListener) {
}

private void onAssetChanged(Translation trans) {
Uri uri = trans.getProjectUri();
ResourceUrn uri = trans.getProjectUrn();
TranslationProject project = projects.get(uri);
if (trans.isDisposed()) {
project.remove(trans);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import org.terasology.engine.core.Uri;
import org.terasology.gestalt.assets.Asset;
import org.terasology.gestalt.assets.AssetType;
import org.terasology.gestalt.assets.DisposableResource;
Expand All @@ -27,7 +26,7 @@ public class Translation extends Asset<TranslationData> {

private Map<String, String> dictionary = new HashMap<>();
private Locale locale;
private Uri projectUri;
private ResourceUrn projectUrn;

private final DisposalAction disposalAction;

Expand Down Expand Up @@ -57,8 +56,8 @@ public static Translation create(ResourceUrn urn, AssetType<?, TranslationData>
/**
* @return the uri of the project this instance is part of
*/
public Uri getProjectUri() {
return projectUri;
public ResourceUrn getProjectUrn() {
return projectUrn;
}
/**
* @return the locale of the translation data
Expand Down Expand Up @@ -101,14 +100,14 @@ public String toString() {
protected void doReload(TranslationData data) {
Preconditions.checkArgument(data != null);

boolean isEqual = Objects.equal(data.getProjectUri(), projectUri)
boolean isEqual = Objects.equal(data.getProjectUrn(), projectUrn)
&& Objects.equal(data.getLocale(), locale)
&& Objects.equal(data.getTranslations(), dictionary);

if (!isEqual) {
this.dictionary.clear();
this.dictionary.putAll(data.getTranslations());
this.projectUri = data.getProjectUri();
this.projectUrn = data.getProjectUrn();
this.locale = data.getLocale();

for (Consumer<Translation> listener : disposalAction.changeListeners) {
Expand Down
Loading

0 comments on commit addbff5

Please sign in to comment.