Skip to content

Commit

Permalink
Merge branch 'develop' into fix/ConditionAction-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert authored Oct 27, 2024
2 parents 5e6879f + 13ba6db commit ffcccca
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

17 changes: 7 additions & 10 deletions engine-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,31 @@ dependencies {
implementation(project(":engine"))

// Dependency not provided for modules, but required for module-tests
implementation("com.google.code.gson:gson:2.8.6")
implementation(libs.gson)
implementation("org.codehaus.plexus:plexus-utils:3.0.16")
implementation("com.google.protobuf:protobuf-java:3.16.1")
implementation("com.google.protobuf:protobuf-java:${libs.versions.protobuf.get().toString()}")
implementation("org.terasology:reflections:0.9.12-MB")

implementation("com.github.zafarkhaja:java-semver:0.10.2")

annotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")
testAnnotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")
annotationProcessor(libs.gestalt.injectjava)
testAnnotationProcessor(libs.gestalt.injectjava)

implementation("org.terasology.joml-ext:joml-test:0.1.0")

testImplementation("ch.qos.logback:logback-classic:1.4.14") {
testImplementation(libs.logback) {
because("implementation: a test directly uses logback.classic classes")
}


// Test lib dependencies
implementation(platform("org.junit:junit-bom:5.10.1")) {
// junit-bom will set version numbers for the other org.junit dependencies.
}
api("org.junit.jupiter:junit-jupiter-api") {
api(libs.junit.api) {
because("we export jupiter Extensions for module tests")
}
api("com.google.truth:truth:1.1.3") {
because("we provide some helper classes")
}
implementation("org.mockito:mockito-core:5.6.0") {
implementation(libs.mockito.core) {
because("classes like HeadlessEnvironment use mocks")
}
constraints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void testRunWhileTimeout() {
}

@Test
@Tag("flaky")
public void testSendEvent() throws IOException {
Context clientContext = helper.createClient();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.google.common.collect.Lists;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class DelayManagerTest {
Time time;

@Test
@Tag("flaky")
public void delayedActionIsTriggeredTest(ModuleTestingHelper helper) throws IOException {
helper.createClient();
helper.runWhile(() -> Lists.newArrayList(entityManager.getEntitiesWith(ClientComponent.class)).isEmpty());
Expand Down
33 changes: 17 additions & 16 deletions engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ configurations.configureEach {
// Primary dependencies definition
dependencies {
// Storage and networking
api("com.google.guava:guava:31.0-jre")
api("com.google.code.gson:gson:2.8.6")
api(libs.guava)
api(libs.gson)
api("net.sf.trove4j:trove4j:3.0.3")
implementation("io.netty:netty-all:4.1.77.Final")
implementation("com.google.protobuf:protobuf-java:3.22.0")
implementation("com.google.protobuf:protobuf-java:${libs.versions.protobuf.get().toString()}")
implementation("org.lz4:lz4-java:1.8.0")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
// Javax for protobuf due to @Generated - needed on Java 9 or newer Javas
Expand All @@ -73,7 +73,7 @@ dependencies {
api("org.codehaus.plexus:plexus-utils:3.0.16")

// Java magic
implementation("net.java.dev.jna:jna-platform:5.6.0")
implementation(libs.jna.platform)
implementation("org.terasology:reflections:0.9.12-MB")
implementation("com.esotericsoftware:reflectasm:1.11.9")

Expand All @@ -100,10 +100,10 @@ dependencies {
implementation("de.matthiasmann.twl:PNGDecoder:1111")

// Logging
implementation("org.slf4j:slf4j-api:2.0.11") {
implementation(libs.slf4j.api) {
because("a backend-independent Logger")
}
implementation("ch.qos.logback:logback-classic:1.4.14") {
implementation(libs.logback) {
because("telemetry implementation uses logback to send to logstash " +
"and we bundle org.terasology.logback for the regex filter")
}
Expand All @@ -124,21 +124,21 @@ dependencies {
implementation("com.github.zafarkhaja:java-semver:0.10.2")

// Our developed libs
api("org.terasology.gestalt:gestalt-asset-core:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-module:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-entity-system:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-util:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-inject:8.0.0-SNAPSHOT")
api(libs.gestalt.core)
api(libs.gestalt.module)
api(libs.gestalt.entitysystem)
api(libs.gestalt.util)
api(libs.gestalt.inject)

annotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")
annotationProcessor(libs.gestalt.injectjava)

api("org.terasology:TeraMath:1.5.0")
api("org.terasology:splash-screen:1.1.1")
api("org.terasology.jnlua:JNLua:0.1.0-SNAPSHOT")
api("org.terasology.jnbullet:JNBullet:1.0.4")
api("org.terasology.nui:nui:4.0.0-SNAPSHOT")
api("org.terasology.nui:nui-reflect:4.0.0-SNAPSHOT")
api("org.terasology.nui:nui-gestalt:4.0.0-SNAPSHOT")
api(libs.terasology.nui)
api(libs.terasology.nuireflect)
api(libs.terasology.nuigestalt)


// Wildcard dependency to catch any libs provided with the project (remote repo preferred instead)
Expand All @@ -152,7 +152,8 @@ dependencies {

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.22.0"
// See https://github.com/google/protobuf-gradle-plugin/issues/563
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get().toString()}"
}
plugins {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/**
* Configures the underlying logback logging framework.
*/
@SuppressWarnings("PMD.SystemPrintln")
public final class LoggingContext {

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ public static void initialize(Path logFileFolder) {
try {
deleteLogFiles(logFileFolder, Duration.ofDays(5).getSeconds());
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace(); //NOPMD
}

// Unfortunately, setting context-based variables works only after initialization
Expand Down
10 changes: 5 additions & 5 deletions engine/src/main/java/org/terasology/engine/core/PathManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ private static Path findInstallPath() {
}
}

System.err.printf(
"Native library installation directory not found. %n" +
"Things will almost certainly crash as a result, %n" +
"unless something else installed everything to java.library.path. %n" +
"Searched: %s%n", installationSearchPaths
LOGGER.error(
"Native library installation directory not found. /n" +
"Things will almost certainly crash as a result, /n" +
"unless something else installed everything to java.library.path. /n" +
"Searched: {}/n", installationSearchPaths
);
return currentDirectory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private Map<URI, Path> getDownloadUrls(Iterable<Module> modules) {
try {
uri = RemoteModuleExtension.getDownloadUrl(metadata).toURI();
} catch (URISyntaxException e) {
e.printStackTrace();
logger.error("Couldn't get download URL: ", e);
}
String fileName = String.format("%s-%s.jar", id, version);
Path folder = PathManager.getInstance().getHomeModPath().normalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.core.module.rendering;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.context.annotation.API;
import org.terasology.engine.context.Context;
import org.terasology.engine.rendering.dag.ModuleRendering;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;

import javax.annotation.Nullable;
Expand All @@ -20,6 +22,7 @@

@API
public class RenderingModuleRegistry {
private static final Logger LOGGER = LoggerFactory.getLogger(RenderingModuleRegistry.class);

private List<ModuleRendering> orderedModuleRenderingInstances = new ArrayList<>();

Expand Down Expand Up @@ -126,7 +129,7 @@ private Set<ModuleRendering> fetchRenderingModules(ModuleEnvironment moduleEnvir
Constructor<?> constructor = renderingClass.getConstructor(Context.class);
moduleRenderingInstance = (ModuleRendering) constructor.newInstance(context);
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
LOGGER.error("Couldn't get constructor: ", e);
}
}
if (moduleRenderingInstance != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,24 @@ public class DebugCallback implements org.lwjgl.opengl.GLDebugMessageCallbackI {
@Override
public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) {
String logFormat = "[{}] [{}] [{}] {}";
Object[] args = new Object[]{
"0x" + Integer.toHexString(id).toUpperCase(Locale.ROOT),
getSourceString(source),
getTypeString(type),
MemoryUtil.memASCII(message).trim()
};
String idString = "0x" + Integer.toHexString(id).toUpperCase(Locale.ROOT);
String sourceString = getSourceString(source);
String typeString = getTypeString(type);
String messageString = MemoryUtil.memASCII(message).trim();

switch (severity) {
case GL_DEBUG_SEVERITY_HIGH:
logger.error(logFormat, args);
logger.error(logFormat, idString, sourceString, typeString, messageString);
break;
case GL_DEBUG_SEVERITY_MEDIUM:
logger.warn(logFormat, args);
logger.warn(logFormat, idString, sourceString, typeString, messageString);
break;
case GL_DEBUG_SEVERITY_LOW:
logger.debug(logFormat, args);
logger.debug(logFormat, idString, sourceString, typeString, messageString);
break;
default:
case GL_DEBUG_SEVERITY_NOTIFICATION:
logger.trace(logFormat, args);
logger.trace(logFormat, idString, sourceString, typeString, messageString);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,15 @@ private Component getNext() {
if (componentsToAdd.containsKey(result.getClass())) {
throw new IllegalStateException("Requested to add component that was already defined for this entity");
}
if (componentsToRemove.contains(result.getClass())) {
continue;
if (!componentsToRemove.contains(result.getClass())) {
return result;
}
return result;
}
while (addedIterator.hasNext()) {
final Component result = addedIterator.next();
if (componentsToRemove.contains(result.getClass())) {
continue;
if (!componentsToRemove.contains(result.getClass())) {
return result;
}
return result;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @see Group
*/
@API
@SuppressWarnings("PMD.AvoidPrintStackTrace")
public class GroupBuilder {

private GroupData groupData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public String playerEyeHeight(@Sender EntityRef client, @CommandParam("eye-heigh
}
return "";
} catch (NullPointerException e) {
e.printStackTrace();
logger.error("Couldn't set player eye height: e");
return "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ protected Vector3f findSpawnPosition(World world, Vector2i pos, int searchRadius
// nothing above sea level found
for (Vector2ic test : spiral) {
Optional<Float> val = getWorld.apply(test);
if (!val.isPresent()) {
continue;
if (val.isPresent()) {
return new Vector3f(test.x(), TeraMath.floorToInt(val.get()), test.y());
}
return new Vector3f(test.x(), TeraMath.floorToInt(val.get()), test.y());
}

throw new IllegalStateException("No spawn location found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void saveLists() {
whitelistWriter.close();
}
} catch (IOException e) {
e.printStackTrace();
logger.error("Couldn't save lists: ", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ private void applyCommonDataDelta(EntityData.Prefab delta, PrefabData result) {
}

private void deserializeCommonData(EntityData.Prefab prefabData, PrefabData result) {
result.setPersisted((prefabData.hasPersisted()) ? prefabData.getPersisted() : true);
result.setAlwaysRelevant(prefabData.hasAlwaysRelevant() ? prefabData.getAlwaysRelevant() : false);
result.setPersisted(!prefabData.hasPersisted() || prefabData.getPersisted());
result.setAlwaysRelevant(prefabData.hasAlwaysRelevant() && prefabData.getAlwaysRelevant());
if (prefabData.hasParentName()) {
Prefab parent = Assets.get(prefabData.getParentName(), Prefab.class).orElse(null);
result.setParent(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class BulletConvexHullShape extends BulletCollisionShape implements Conve

public BulletConvexHullShape(List<Vector3f> vertices) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(vertices.size() * 3);
for (int i = 0; i < vertices.size(); i++) {
Vector3f vertex = vertices.get(i);
for (Vector3f vertex : vertices) {
buffer.put(vertex.x);
buffer.put(vertex.y);
buffer.put(vertex.z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private StandardMeshData processData(List<Vector3f> rawVertices, List<Vector3f>
List<Vector2f> rawTexCoords, List<Vector3i[]> rawIndices) throws IOException {
int numIndices = 0;
int numVerts = 0;
for (int x = 0; x < rawIndices.size(); x++) {
numIndices += (rawIndices.get(x).length - 2) * 3;
numVerts += rawIndices.get(x).length;
for (Vector3i[] rawIndex : rawIndices) {
numIndices += (rawIndex.length - 2) * 3;
numVerts += rawIndex.length;
}

StandardMeshData result = new StandardMeshData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;


public class SkeletalMeshData implements AssetData {
Expand Down Expand Up @@ -172,10 +174,8 @@ public AABBf getStaticAABB() {
private void calculateNormals() {
// TODO: Better algorithm (take into account triangle size and angles
List<Vector3f> vertices = getBindPoseVertexPositions();
List<Vector3f> normals = Lists.newArrayListWithCapacity(vertices.size());
for (int i = 0; i < vertices.size(); ++i) {
normals.add(new Vector3f());
}
List<Vector3f> normals = IntStream.range(0, vertices.size()).mapToObj(i -> new Vector3f()).collect(Collectors.toCollection(() ->
Lists.newArrayListWithCapacity(vertices.size())));
Vector3f v1 = new Vector3f();
Vector3f v2 = new Vector3f();
Vector3f norm = new Vector3f();
Expand Down
Loading

0 comments on commit ffcccca

Please sign in to comment.