Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/training-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
tonihele committed Jan 7, 2024
2 parents b7614af + 781712b commit 4f067ee
Show file tree
Hide file tree
Showing 68 changed files with 216 additions and 378 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ public void close() {
*/
public final void embed(MediaInformation information) {
if (information != null) {
for (Map.Entry<String, Object> entry : information.entrySet()) {
put(entry.getKey(), entry.getValue());
}
this.putAll(information);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ private int getInt() {
* @param b the input array
* @return the integer value
*/
protected final static int getShortInt(byte b[]) {
protected static int getShortInt(byte b[]) {
return b[0] << 16 & 0xFF0000 | b[1] << 8 & 0xFF00 | b[2] & 0xFF;
}

Expand Down
10 changes: 5 additions & 5 deletions src/toniarts/openkeeper/audio/plugins/decoder/Output.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ abstract class Output extends Initializer {
int counter;
private float[] frameBufferZeroValues;
private byte[] buffer, zeroBuffer;
private int obuffersize;
private int frameBufferAnalyzerSize;
private final int obuffersize;
private final int frameBufferAnalyzerSize;
private int readPos, size;
private int flushCount = 0;
private boolean frequencyMode;
private boolean switched;
private boolean bigEndian;
private final boolean bigEndian;

/**
* Constructs an instance of
Expand Down Expand Up @@ -144,9 +144,9 @@ abstract class Output extends Initializer {
private void setNumberOfOccupiedSubbands() {
Frame i = (Frame) information;

int frequency = ((Integer) i.get(AudioInformation.I_SAMPLE_RATE)).intValue();
int frequency = (Integer) i.get(AudioInformation.I_SAMPLE_RATE);

int deviceFrequencyLimit = ((Integer) info.get(AudioInformation.I_DEVICE_SAMPLE_RATE)).intValue();
int deviceFrequencyLimit = (Integer) info.get(AudioInformation.I_DEVICE_SAMPLE_RATE);

if (deviceFrequencyLimit >= frequency) {
return;
Expand Down
17 changes: 6 additions & 11 deletions src/toniarts/openkeeper/audio/plugins/decoder/tag/TagContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class TagContent extends HashMap<String, Object> implements Information {
public final static String BA_SUBTYPE_BINARY = "byte[] subtypeBinary", BA_CONTENT_BINARY = "byte[] contentBinary";

/**
* Constructs a new, empty
* <code>TagContent</code> with the specified initial capacity.
* Constructs a new
* <code>TagContent</code> with the specified contents.
*
* @param initialCapacity the initial number of buckets
* @param m existing mappings
*/
public TagContent(int initialCapacity) {
super(initialCapacity);
public TagContent(Map<String, Object> m) {
super(m);
}

/**
Expand Down Expand Up @@ -236,12 +236,7 @@ public byte[] getBinaryContent() {
*/
@Override
public Object clone() {
TagContent clone = new TagContent(size());

for (Map.Entry<String, Object> entry : this.entrySet()) {
clone.put(entry.getKey(), entry.getValue());
}
return clone;
return new TagContent(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ public ID3v1(InputStream stream) throws IOException {
}

private void buildKeyMapTable() {
if (!title.trim().equals("")) {
if (!title.trim().isEmpty()) {
put(S_TITLE, title);
}
if (!artist.trim().equals("")) {
if (!artist.trim().isEmpty()) {
put(S_ARTIST, artist);
}
if (!album.trim().equals("")) {
if (!album.trim().isEmpty()) {
put(S_ALBUM, album);
}
if (!year.trim().equals("")) {
if (!year.trim().isEmpty()) {
put(S_YEAR, year);
}
if (!comment.trim().equals("")) {
if (!comment.trim().isEmpty()) {
put(S_COMMENT, comment);
}
if (genre >= 0 && genre < GENRE.length) {
Expand All @@ -101,7 +101,7 @@ private void buildKeyMapTable() {
t[0] = (byte) track;
String buffer = new String(t);

if (!buffer.trim().equals("")) {
if (!buffer.trim().isEmpty()) {
put(S_TRACK, buffer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ final class Frame {
private byte encryptionId;
private int frameLength;
private int skippedDataLength;
private int version;
private final int version;
private int unflatedFrameLength;
private int state;
private ID3v2 tag;
private final ID3v2 tag;

Frame(InputStream stream, ID3v2 tag, int version) throws IOException, TagException {
skippedDataLength = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@
final class Header {

private final static int MAXIMUM_TAGSIZE = 256000000;
private boolean unsynchronizated;
private final boolean unsynchronizated;
private boolean extendedHeader;
private boolean experimental;
private boolean footer;
private boolean tagIsUpdate;
private boolean tagRestrictions;
private int version;
private int tagSize;
private final int version;
private final int tagSize;
private int extendedHeaderTagSize;
private int paddingSize;
private boolean protection;
private long crc;
private int skippedDataLength;
private ID3v2 tag;
private final ID3v2 tag;

// Checks an ID3v2 header from an input stream.
Header(InputStream stream, ID3v2 tag) throws TagException, IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public final class ID3v2 extends Tag {
private int tagSize;
private int version;
private int skippedDataLength;
private MpxReader info;
private final MpxReader info;

/**
* Provides access to ID3v2 tag.
Expand Down
2 changes: 1 addition & 1 deletion src/toniarts/openkeeper/common/EntityInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public String toString() {
* construction?)<br>
* The order is "natural", starting from origin
*/
private final class PointComparator implements Comparator<Point> {
private static final class PointComparator implements Comparator<Point> {

@Override
public int compare(Point o1, Point o2) {
Expand Down
32 changes: 8 additions & 24 deletions src/toniarts/openkeeper/game/MapSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,39 +165,23 @@ public GameMapContainer getMap(String map) {
/**
* Compares the maps by their name
*/
private class MapComparator implements Comparator<GameMapContainer> {
private static class MapComparator implements Comparator<GameMapContainer> {

@Override
public int compare(GameMapContainer o1, GameMapContainer o2) {
return o1.getMapName().compareToIgnoreCase(o2.getMapName());
return o1.mapName().compareToIgnoreCase(o2.mapName());
}

}

/**
* Small container class that holds the actual map data and the name
*/
public class GameMapContainer {

private final KwdFile map;
private final String mapName;

public GameMapContainer(KwdFile map, String mapName) {
this.map = map;
this.mapName = mapName;
}

public KwdFile getMap() {
return map;
}

public String getMapName() {
return mapName;
}
* Small container class that holds the actual map data and the name
*/
public record GameMapContainer(KwdFile map, String mapName) {

@Override
public String toString() {
return mapName;
public String toString() {
return mapName;
}
}
}
}
12 changes: 4 additions & 8 deletions src/toniarts/openkeeper/game/controller/CreaturesController.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,29 +192,25 @@ public EntityId spawnCreature(Thing.Creature creature, Vector2f position) {
Thing.HeroParty.Objective objective = null;
short objectiveTargetPlayerId = 0;
int objectiveTargetActionPointId = 0;
if (creature instanceof Thing.GoodCreature) {
Thing.GoodCreature goodCreature = (Thing.GoodCreature) creature;
if (creature instanceof Thing.GoodCreature goodCreature) {
triggerId = goodCreature.getTriggerId();
healthPercentage = goodCreature.getInitialHealth();
level = goodCreature.getLevel();
ownerId = Player.GOOD_PLAYER_ID;
objective = goodCreature.getObjective();
objectiveTargetPlayerId = goodCreature.getObjectiveTargetPlayerId();
objectiveTargetActionPointId = goodCreature.getObjectiveTargetActionPointId();
} else if (creature instanceof Thing.NeutralCreature) {
Thing.NeutralCreature neutralCreature = (Thing.NeutralCreature) creature;
} else if (creature instanceof Thing.NeutralCreature neutralCreature) {
triggerId = neutralCreature.getTriggerId();
healthPercentage = neutralCreature.getInitialHealth();
level = neutralCreature.getLevel();
ownerId = Player.NEUTRAL_PLAYER_ID;
} else if (creature instanceof Thing.KeeperCreature) {
Thing.KeeperCreature keeperCreature = (Thing.KeeperCreature) creature;
} else if (creature instanceof Thing.KeeperCreature keeperCreature) {
triggerId = keeperCreature.getTriggerId();
healthPercentage = keeperCreature.getInitialHealth();
level = keeperCreature.getLevel();
ownerId = keeperCreature.getPlayerId();
} else if (creature instanceof Thing.DeadBody) {
Thing.DeadBody deadBody = (Thing.DeadBody) creature;
} else if (creature instanceof Thing.DeadBody deadBody) {
ownerId = deadBody.getPlayerId();
}
return loadCreature(creature.getCreatureId(), ownerId, level, position.getX(), position.getY(), 0f, healthPercentage, creature.getGoldHeld(),
Expand Down
4 changes: 2 additions & 2 deletions src/toniarts/openkeeper/game/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public class GameController implements IGameLogicUpdatable, AutoCloseable, IGame
public static final int LEVEL_TIMER_MAX_COUNT = 16;
private static final int LEVEL_FLAG_MAX_COUNT = 128;

private String level;
private final String level;
private KwdFile kwdFile;
private toniarts.openkeeper.game.data.Level levelObject;
private final toniarts.openkeeper.game.data.Level levelObject;

private final SortedMap<Short, Keeper> players = new TreeMap<>();
private final Map<Short, IPlayerController> playerControllers = HashMap.newHashMap(6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class PlayerDoorControl extends AbstractResearchablePlayerControl<Door, ResearchableEntity, PlayerDoorListener> /*implements RoomListener*/ {

private int doorCount = 0;
private final int doorCount = 0;

public PlayerDoorControl(Keeper keeper, List<Door> doors) {
super(keeper, keeper.getAvailableDoors(), doors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class PlayerTrapControl extends AbstractResearchablePlayerControl<Trap, ResearchableEntity, PlayerTrapListener> /*implements RoomListener*/ {

private int trapCount = 0;
private final int trapCount = 0;

public PlayerTrapControl(Keeper keeper, List<Trap> traps) {
super(keeper, keeper.getAvailableTraps(), traps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public Set<EntityId> getWallFurniture() {
* @param roomId the room ID
* @return the object ID for the room pillar or {@code null} if not found
*/
protected final static Short getPillarObject(short roomId) {
protected static Short getPillarObject(short roomId) {

// FIXME: Is this data available somewhere??
switch (roomId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class DungeonHeartConstruction implements IGameLogicUpdatable {

private static final float GRAVITY = 9.81f;
private float velocity = 7f;
private final float velocity = 7f;
private final EntityData entityData;
private final Set<EntityId> dungeonHeartPlugs;
private final Map<EntityId, Set<PlugPiece>> dungeonHeartPlugPieces;
Expand Down Expand Up @@ -164,7 +164,7 @@ private void showStepsAndArches(EntityId entityId) {
}
}

private class PlugPiece {
private static class PlugPiece {

public PlugPiece() {
}
Expand Down
2 changes: 1 addition & 1 deletion src/toniarts/openkeeper/game/map/MapRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MapRoom implements Savable {

private int health;
private int maxHealth;
private boolean destroyed = false;
private final boolean destroyed = false;
private short ownerId;
private short roomId;
private List<Point> tiles;
Expand Down
2 changes: 1 addition & 1 deletion src/toniarts/openkeeper/game/network/ClientListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Deprecated
public class ClientListener implements MessageListener<Client> {

private NetworkClient client;
private final NetworkClient client;

public ClientListener(NetworkClient client) {
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class LocalServerSearch {
private int port = 7575;
private final ServerQuery[] threads;
private final LinkedList<NetworkServer> queue;
private List<NetworkServer> servers = new ArrayList();
private final List<NetworkServer> servers = new ArrayList();

public LocalServerSearch(int port) {
this.port = port;
Expand Down
6 changes: 2 additions & 4 deletions src/toniarts/openkeeper/game/network/ServerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ public void messageReceived(HostedConnection source, Message message) {
// source.getServer().broadcast(message);
//
// } else
if (message instanceof MessageTime) {
if (message instanceof MessageTime msg) {
// Send the latest game time back
MessageTime msg = (MessageTime) message;
long time = host.getGameTime();
source.send(msg.updateGameTime(time).setReliable(true));

} else if (message instanceof MessagePlayerInfo) {
MessagePlayerInfo msg = (MessagePlayerInfo) message;
} else if (message instanceof MessagePlayerInfo msg) {

// Send a message back to the player with their entity ID
source.send(new MessagePlayerInfo(msg.getName(), msg.getMemory()).setReliable(true));
Expand Down
2 changes: 1 addition & 1 deletion src/toniarts/openkeeper/game/network/ServerQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class ServerQuery extends Thread {

private static final Logger logger = System.getLogger(ServerQuery.class.getName());

private LinkedList<NetworkServer> queue;
private final LinkedList<NetworkServer> queue;

public ServerQuery(LinkedList queue) {
this.queue = queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ protected void postMessage(ChatSessionImpl from, String message) {
*/
private class ChatSessionImpl implements ChatSession, ChatSessionListener {

private HostedConnection conn;
private final HostedConnection conn;
private ChatSessionListener callback;
private String name;
private final String name;

public ChatSessionImpl(HostedConnection conn, String name) {
this.conn = conn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ public ClientMessageListener() {

@Override
public void messageReceived(Client source, Message message) {
if (message instanceof GameLoadProgressData) {
GameLoadProgressData data = (GameLoadProgressData) message;
if (message instanceof GameLoadProgressData data) {
logger.log(Level.TRACE, "onLoadStatusUpdate({0},{1})", new Object[]{data.getProgress(), data.getKeeperId()});
for (GameSessionListener l : listeners.getArray()) {
l.onLoadStatusUpdate(data.getProgress(), data.getKeeperId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,7 @@ public ServerMessageListener() {
public void messageReceived(HostedConnection source, Message message) {
ClientInfo clientInfo = playersByConnection.get(source);

if (message instanceof GameLoadProgressData) {
GameLoadProgressData data = (GameLoadProgressData) message;
if (message instanceof GameLoadProgressData data) {
logger.log(Level.TRACE, "onLoadStatus({0},{1})", new Object[]{data.getProgress(), clientInfo.getKeeper().getId()});

clientInfo.setLoadingProgress(data.getProgress());
Expand Down
Loading

0 comments on commit 4f067ee

Please sign in to comment.