Skip to content

Commit

Permalink
Merge branch 'develop' into chore/qaplug-findings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert authored Nov 11, 2023
2 parents 971c853 + 8545be0 commit 08bd7ea
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 82 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<h3 align="center"><b>
<a href="#community">Community</a> |
<a href="#knowledge-base">Knowledge Base</a> |
<a href="#installation">Installation</a> |
<a href="#development">Development</a> |
<a href="#license">License</a>
Expand Down Expand Up @@ -69,6 +70,11 @@ We are present in nearly the complete round-up of social networks. Follow/friend
</p>


## Knowledge Base

Find documentation, instructions, and helpful references in our [Terasology Knowledge Base](http://terasology.org/Terasology/#/), formerly known as the Terasology Engine wiki.


## Installation

<table>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@
import org.joml.Vector3i;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.Time;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.integrationenvironment.jupiter.IntegrationEnvironment;
import org.terasology.engine.logic.players.LocalPlayer;
import org.terasology.engine.logic.players.event.ResetCameraEvent;
import org.terasology.engine.network.ClientComponent;
import org.terasology.engine.network.NetworkMode;
import org.terasology.engine.registry.In;
import org.terasology.engine.world.WorldProvider;
import org.terasology.engine.world.block.BlockManager;
import org.terasology.unittest.stubs.DummyEvent;

import java.io.IOException;

@IntegrationEnvironment(networkMode = NetworkMode.LISTEN_SERVER)
public class ExampleTest {
private static final Logger logger = LoggerFactory.getLogger(ExampleTest.class);

@In
private WorldProvider worldProvider;
Expand All @@ -34,6 +37,13 @@ public class ExampleTest {
@In
private ModuleTestingHelper helper;

@Test
public void testClientCreation() {
logger.info("Starting test 'testClientCreation'");
Assertions.assertDoesNotThrow(helper::createClient);
logger.info("Done with test 'testClientCreation'");
}

@Test
public void testClientConnection() throws IOException {
int currentClients = Lists.newArrayList(entityManager.getEntitiesWith(ClientComponent.class)).size();
Expand Down Expand Up @@ -65,7 +75,7 @@ public void testSendEvent() throws IOException {
Context clientContext = helper.createClient();

// send an event to a client's local player just for fun
clientContext.get(LocalPlayer.class).getClientEntity().send(new ResetCameraEvent());
clientContext.get(LocalPlayer.class).getClientEntity().send(new DummyEvent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
import org.terasology.engine.config.flexible.constraints.LocaleConstraint;
import org.terasology.engine.config.flexible.constraints.NumberRangeConstraint;

import java.util.Arrays;
import java.util.Locale;
import java.util.Locale.Category;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.Math.max;
import static org.terasology.engine.config.flexible.SettingArgument.constraint;
Expand Down Expand Up @@ -81,13 +86,34 @@ public class SystemConfig extends AutoConfig {

public final Setting<Locale> locale = setting(
type(Locale.class),
defaultValue(Locale.getDefault(Category.DISPLAY)),
defaultValue(getAdjustedLocale()),
name("${engine:menu#settings-language}"),
constraint(new LocaleConstraint(Locale.getAvailableLocales())) // TODO provide translate project's locales (Pirate lang don't works)
constraint(new LocaleConstraint(
// Locale.getAvailableLocales() + non-standard "pr" (pirate) tag
Stream.concat(Arrays.stream(Locale.getAvailableLocales()), Stream.of(Locale.forLanguageTag("pr")))
.collect(Collectors.toSet())))
);

@Override
public String getName() {
return "${engine:menu#system-settings-title}";
}

private static Locale getAdjustedLocale() {
Locale systemLocale = Locale.getDefault(Category.DISPLAY);

// Matches unusual locales on Mac OS created from the user's language and location, e.g. en_UA
if (!Arrays.asList(Locale.getAvailableLocales()).contains(systemLocale)) {
final Pattern langRegionPattern = Pattern.compile("[a-z]{2}_[A-Z]{2}");

String input = systemLocale.toString();
Matcher matcher = langRegionPattern.matcher(input);

// If the locale is like that, convert it to just the language, e.g. en_UA -> en
if (matcher.find()) {
systemLocale = Locale.forLanguageTag(systemLocale.getLanguage());
}
}
return systemLocale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Optional<AutoConfig> deserialize(PersistedData data) {
}
return Optional.of(config);
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
logger.error("Cannot create type [" + typeInfo + "] for deserialization", e);
logger.error("Cannot create type [{}] for deserialization", typeInfo, e);
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public boolean set(T newValue) {
Preconditions.checkNotNull(newValue, "The value of a setting cannot be null.");

if (override.get().isPresent()) {
LOGGER.warn("An attempt was made to overwrite the value specified in the System property." +
" This will give nothing while the System Property value is supplied");
LOGGER.warn("An attempt was made to overwrite the value specified in the System property."
+ " This will give nothing while the System Property value is supplied");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void register(ComponentSystem object) {
context.get(EntityManager.class).getEventSystem().registerEventHandler(object);

if (initialised) {
logger.warn("System " + object.getClass().getName() + " registered post-init.");
logger.warn("System {} registered post-init.", object.getClass().getName());
initialiseSystem(object);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void readFile(String filename, Consumer<InputStream> consumer) {
// consumer to read the file, if it exists
consumer.accept(moduleInputStream);
} catch (IOException e) {
logger.error("Could not read the file: " + filename, e);
logger.error("Could not read the file: {}", filename, e);
}

return null;
Expand Down Expand Up @@ -109,7 +109,7 @@ public void writeFile(String filename, Consumer<OutputStream> consumer) {
// consumer to write the file
consumer.accept(moduleInputStream);
} catch (IOException e) {
logger.error("Could not write the file: " + filename, e);
logger.error("Could not write the file: {}", filename, e);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public void initialise(GameEngine engine, Context rootContext) {
if (rootContext.get(SystemConfig.class).monitoringEnabled.get()) {
advancedMonitor = new AdvancedMonitor();
advancedMonitor.setVisible(true);
initMicrometerMetrics(rootContext.get(Time.class));
}

initMicrometerMetrics(rootContext.get(Time.class));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ public BehaviorState modify(Actor actor, BehaviorState result) {
}
return BehaviorState.SUCCESS;
} catch (ClassNotFoundException e) {
logger.error("Class not found. " +
"Does the Component specified exist?", e);
logger.error("Class not found. Does the Component specified exist?", e);
} catch (NoSuchFieldException e) {
logger.error("Field not found. " +
"Does the field specified in 'values' (publicly) exist in the Component specified in 'componentPresent'?", e);
logger.error("Field not found. "
+ "Does the field specified in 'values' (publicly) exist in the Component specified in 'componentPresent'?", e);
} catch (IllegalAccessException e) {
logger.error("Illegal access. " +
"Do we have access to the Component in question?", e);
logger.error("Illegal access. Do we have access to the Component in question?", e);
}
return BehaviorState.FAILURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ public boolean addOutputBufferPairConnection(int id, BufferPair bufferPair) {

// set data for all connected connections
if (!localBufferPairConnection.getConnectedConnections().isEmpty()) {
logger.debug("Propagating bufferPair data to all connected connections of " + localBufferPairConnection + ": ");
logger.debug("Propagating bufferPair data to all connected connections of {}: ", localBufferPairConnection);
localBufferPairConnection.getConnectedConnections().forEach((k, v) -> {
logger.debug("setting data for: " + v.toString() + " ,");
logger.debug("setting data for: {} ,", v);
v.setData(bufferPair);
});
logger.debug("data propagated.\n");
}

if (localBufferPairConnection.getData() != null) {
logger.warn("Adding output buffer pair to slot id " + id
+ " of " + this.nodeUri + "node overwrites data of existing connection: " + localBufferPairConnection.toString());
logger.warn("Adding output buffer pair to slot id {} of {} node overwrites data of existing connection: {}",
id, this.nodeUri, localBufferPairConnection);
}
localBufferPairConnection.setData(bufferPair);
success = true;
Expand All @@ -232,17 +232,17 @@ public boolean addOutputBufferPairConnection(int id, BufferPairConnection from)

// set data for all connected connections
if (!localBufferPairConnection.getConnectedConnections().isEmpty()) {
logger.info("Propagating data from " + from.toString() + " to all connected connections of " + localBufferPairConnection + ": ");
logger.info("Propagating data from {} to all connected connections of {}: ", from.toString(), localBufferPairConnection);
localBufferPairConnection.getConnectedConnections().forEach((k, v) -> {
logger.info("setting data for: " + v.toString() + " ,");
logger.info("setting data for: {} ,", v);
v.setData(from.getData());
});
logger.info("data propagated.\n");
}

if (localBufferPairConnection.getData() != null) {
logger.warn("Adding output buffer pair connection " + from.toString() + "\n to slot id " + id
+ " of " + this.nodeUri + "node overwrites data of existing connection: " + localBufferPairConnection.toString());
logger.warn("Adding output buffer pair connection to slot id {} of {} node overwrites data of existing connection: {}",
id, this.nodeUri, localBufferPairConnection);
}
localBufferPairConnection.setData(from.getData());

Expand Down Expand Up @@ -303,16 +303,16 @@ protected boolean addOutputFboConnection(int id, FBO fboData) {
FboConnection fboConnection = (FboConnection) outputConnections.get(connectionUri);

if (fboConnection.getData() != null) {
logger.warn("Adding output fbo data to slot id " + id
+ " of " + this.nodeUri + "node overwrites data of existing connection: " + fboConnection.toString());
logger.warn("Adding output fbo data to slot id {} of {} node overwrites data of existing connection: {}",
id, this.nodeUri, fboConnection);
}
fboConnection.setData(fboData);

// set data for all connected connections
if (!fboConnection.getConnectedConnections().isEmpty()) {
logger.info("Propagating fbo data to all connected connections of " + fboConnection + ": ");
logger.info("Propagating fbo data to all connected connections of {}: ", fboConnection);
fboConnection.getConnectedConnections().forEach((k, v) -> {
logger.info("setting data for: " + v.toString() + " ,");
logger.info("setting data for: {} ,", v);
v.setData(fboData);
});
logger.info("data propagated.\n");
Expand Down Expand Up @@ -443,9 +443,7 @@ public int getNumberOfOutputConnections() {
public DependencyConnection getInputConnection(String name) {
DependencyConnection connection = inputConnections.get(name);
if (connection == null) {
String errorMessage = String.format("Getting input connection named %s returned null." +
" No such input connection in %s", name, this.toString());
logger.error(errorMessage);
logger.error("Getting input connection named {} returned null. No such input connection in {}", name, this);
// throw new NullPointerException(errorMessage);
}
return connection;
Expand All @@ -455,9 +453,7 @@ public DependencyConnection getInputConnection(String name) {
public DependencyConnection getOutputConnection(String name) {
DependencyConnection connection = outputConnections.get(name);
if (connection == null) {
String errorMessage = String.format("Getting output connection named %s returned null." +
" No such output connection in %s", name, this.toString());
logger.error(errorMessage);
logger.error("Getting output connection named {} returned null. No such output connection in {}.", name, this);
// throw new NullPointerException(errorMessage);
}
return connection;
Expand Down Expand Up @@ -513,7 +509,7 @@ protected FBO requiresFbo(FboConfig fboConfig, BaseFboManager fboManager) {
if (!fboUsages.containsKey(fboName)) {
fboUsages.put(fboName, fboManager);
} else {
logger.warn("FBO " + fboName + " is already requested.");
logger.warn("FBO {} is already requested.", fboName);
fbo = fboManager.get(fboName);
this.addInputFboConnection(inputConnections.size() + 1, fbo);
return fbo;
Expand Down
Loading

0 comments on commit 08bd7ea

Please sign in to comment.