Compare commits

...

4 Commits

Author SHA1 Message Date
Alexis King
ee34e6ca82 Miscellaneous code cleanup 2023-04-30 18:01:54 -05:00
Alexis King
d87d18287a 0.1.1-SNAPSHOT 2023-04-30 17:26:27 -05:00
Alexis King
f430e7fd3c 0.1.0 2023-04-30 17:24:00 -05:00
Alexis King
f8c19df4af Fix a minor bug that caused a crash early in the tutorial 2023-04-30 17:20:54 -05:00
29 changed files with 164 additions and 179 deletions

View File

@ -1,3 +1,7 @@
## 0.1.0 (2023-04-30)
* Fixed a small bug that caused a crash early in the tutorial.
## 0.0.7 (2022-12-13)
* Several improvements have been made to the tactical overlay:

View File

@ -9,13 +9,13 @@ Shattered Plans is a turn-based strategy game by [Jagex Ltd.][jagex] It was orig
Running Shattered Plans requires [Java 17 or newer][download-java] and [the latest version of the game JAR][download-shattered-plans]. You can then run the game by running the following command:
```sh
java -jar shatteredplans-0.0.7.jar --local-server
java -jar shatteredplans-0.1.0.jar --local-server
```
As the name suggests, passing the `--local-server` flag will run a Shattered Plans server locally, allowing you to play the game in singleplayer mode. Other players can connect to your server by running
```sh
java -jar shatteredplans-0.0.7.jar --host <HOST>
java -jar shatteredplans-0.1.0.jar --host <HOST>
```
replacing `<HOST>` with your IP address. By default, the server runs on port 43594, but you can specify a different port using the `--port` flag. A few other options are also available, pass `--help` to see them all.
@ -31,7 +31,7 @@ Limited support for adjusting the UI scale is available by setting one or both o
For example, the following command will force the game to render at 1.5× standard height using a widescreen aspect ratio:
```sh
java -Dfunorb.shatteredplans.client.uiScale=1.5 -Dfunorb.shatteredplans.client.aspectRatio=16:9 -jar shatteredplans-0.0.7.jar
java -Dfunorb.shatteredplans.client.uiScale=1.5 -Dfunorb.shatteredplans.client.aspectRatio=16:9 -jar shatteredplans-0.1.0.jar
```
In-game, the result looks like this:
@ -69,7 +69,7 @@ If youd like to find people to play with, or if you have any further question
Shattered Plans and FunOrb are the property of [Jagex Ltd.][jagex] This project is a fan effort to keep a wonderful, creative game from being permanently lost. I do not commercially benefit from this project in any way, and it does not compete in any way with any of Jagexs current commercial offerings, none of which are even remotely similar to Shattered Plans.
[download-java]: https://www.oracle.com/java/technologies/downloads/
[download-shattered-plans]: https://github.com/lexi-lambda/shattered-plans/releases/download/v0.0.7/shatteredplans-0.0.7.jar
[download-shattered-plans]: https://github.com/lexi-lambda/shattered-plans/releases/download/v0.1.0/shatteredplans-0.1.0.jar
[FunOrb]: https://en.wikipedia.org/wiki/FunOrb
[funorb-discord]: https://discord.gg/MGfDrDf
[funorb-wiki:shattered-plans]: https://funorb.fandom.com/wiki/Shattered_Plans

View File

@ -6,7 +6,7 @@
<groupId>net.alterorb</groupId>
<artifactId>shatteredplans</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<name>Shattered Plans</name>
<url>https://alterorb.net</url>

View File

@ -14,8 +14,8 @@ public final class MidiPlayer extends AudioSource {
private static final double P9_TURNS_TO_RADIANS = 0.01227184630308513D;
private static final double P8_NOTE_TO_OCTAVE = 3.255208333333333E-4D;
public static final int FLAG_SUSTAIN = 0x0001;
public static final int FLAG_PORTAMENTO = 0x0002;
private static final int FLAG_SUSTAIN = 0x0001;
private static final int FLAG_PORTAMENTO = 0x0002;
public static final int FLAG_GENERAL_6 = 0x0004;
public final int[] chStartOffset_p6 = new int[16]; // GP controller 1
@ -101,7 +101,7 @@ public final class MidiPlayer extends AudioSource {
relNote_p8 += (int) (vibrato_p8 * Math.sin((note.vibratoPhase_p9 & 0x1ff) * P9_TURNS_TO_RADIANS));
}
int speed_p8 = (int)(
final int speed_p8 = (int)(
(double)(256 * note.sampleData.sampleRate)
* Math.pow(2.0D, P8_NOTE_TO_OCTAVE * relNote_p8) / (double) SampledAudioChannelS16.SAMPLE_RATE
+ 0.5D);
@ -435,13 +435,13 @@ public final class MidiPlayer extends AudioSource {
}
if (controller == 6) { // data entry msb
int rpn = this.chRpn[channel];
final int rpn = this.chRpn[channel];
if (rpn == 0x4000) {
this.chPitchBendRange[channel] = (this.chPitchBendRange[channel] & 0xffffc07f) + (value << 7);
}
}
if (controller == 38) { // data entry lsb
int rpn = this.chRpn[channel];
final int rpn = this.chRpn[channel];
if (rpn == 0x4000) {
this.chPitchBendRange[channel] = value + (this.chPitchBendRange[channel] & 0xffffff80);
}

View File

@ -5,10 +5,10 @@ import funorb.io.Buffer;
import java.util.Arrays;
public final class MidiReader {
public static final int EVENT_SYSEX = 0;
private static final int EVENT_SYSEX = 0;
public static final int EVENT_TRACK_END = 1;
public static final int EVENT_TEMPO_CHANGE = 2;
public static final int EVENT_UNKNOWN_META = 3;
private static final int EVENT_TEMPO_CHANGE = 2;
private static final int EVENT_UNKNOWN_META = 3;
private static final byte[] STATUS_BYTE_TO_DATA_BYTE_COUNT = new byte[] {
// channel voice messages
@ -162,19 +162,13 @@ public final class MidiReader {
if (statusByte == 0xf7 && sysexLength > 0) {
final int firstSysexByte = this.midi.data[this.midi.pos] & 0xff;
switch (firstSysexByte) {
case 241:
case 242:
case 243:
case 246:
case 248:
case 250:
case 252:
case 254:
case 241, 242, 243, 246, 248, 250, 252, 254 -> {
++this.midi.pos;
this.lastTrackStatusByte[track] = firstSysexByte;
return this.readNextTrackEventWithStatus(track, firstSysexByte);
default:
break;
}
default -> {
}
}
}

View File

@ -50,7 +50,7 @@ public final class RawSamplePlayer extends AudioSource {
if (sample.data_s8 == null || sample.data_s8.length == 0) {
return null;
}
int speed_p8 = (int) ((long) sample.sampleRate * 256L * (long) 100 / (100L * SampledAudioChannelS16.SAMPLE_RATE));
final int speed_p8 = (int) ((long) sample.sampleRate * 256L * (long) 100 / (100L * SampledAudioChannelS16.SAMPLE_RATE));
return new RawSamplePlayer(sample, speed_p8, vol_p8 << 6, 0x2000);
}
@ -581,14 +581,12 @@ public final class RawSamplePlayer extends AudioSource {
if (this.updateAmpRate()) {
return dstLen;
}
} else {
if (this.speed_p8 == 256 && (this.playhead_p8 & 255) == 0) {
return Xfer.fwd(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14, this.ampR_p14,
} else if (this.speed_p8 == 256 && (this.playhead_p8 & 255) == 0) {
return Xfer.fwd(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14, this.ampR_p14,
dstLen, srcEnd_p8, this);
} else {
return Xfer.fwdPitched(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14,
} else {
return Xfer.fwdPitched(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14,
this.ampR_p14, dstLen, srcEnd_p8, this, this.speed_p8, stitch_s8);
}
}
}
}
@ -624,14 +622,12 @@ public final class RawSamplePlayer extends AudioSource {
if (this.updateAmpRate()) {
return dstLen;
}
} else {
if (this.speed_p8 == -256 && (this.playhead_p8 & 255) == 0) {
return Xfer.back(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14, this.ampR_p14,
} else if (this.speed_p8 == -256 && (this.playhead_p8 & 255) == 0) {
return Xfer.back(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14, this.ampR_p14,
dstLen, srcEnd_p8, this);
} else {
return Xfer.backPitched(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14,
} else {
return Xfer.backPitched(this.rawSample.data_s8, dest_s16p8, this.playhead_p8, dstOff, this.ampL_p14,
this.ampR_p14, dstLen, srcEnd_p8, this, this.speed_p8, stitch_s8);
}
}
}
@ -704,22 +700,22 @@ public final class RawSamplePlayer extends AudioSource {
return false;
}
private static class Xfer {
private static final class Xfer {
private static int fwd(
final byte[] src_s8,
final int[] dst_s16p8,
int srcOff_p8,
int dstOff,
int ampL_p14,
int ampR_p14,
final int dstLen,
int srcEnd_p8,
final RawSamplePlayer player
final byte[] src_s8,
final int[] dst_s16p8,
final int srcOff_p8,
int dstOff,
final int ampL_p14,
final int ampR_p14,
final int dstLen,
final int srcEnd_p8,
final RawSamplePlayer player
) {
int srcOff = srcOff_p8 >> 8;
int srcEnd = srcEnd_p8 >> 8;
int ampL_p16 = ampL_p14 << 2;
int ampR_p16 = ampR_p14 << 2;
final int srcEnd = srcEnd_p8 >> 8;
final int ampL_p16 = ampL_p14 << 2;
final int ampR_p16 = ampR_p14 << 2;
int dstEnd = dstOff + srcEnd - srcOff;
if (dstEnd > dstLen) {
dstEnd = dstLen;
@ -757,24 +753,24 @@ public final class RawSamplePlayer extends AudioSource {
}
private static int fwdRamped(
final byte[] src_s8,
final int[] dst_s16p8,
int playhead_p8,
int dstOff,
int ampL_p14,
int ampR_p14,
int ampRateL_p14,
int ampRateR_p14,
final int dstLen,
int srcEnd_p8,
final RawSamplePlayer playback
final byte[] src_s8,
final int[] dst_s16p8,
final int playhead_p8,
int dstOff,
final int ampL_p14,
final int ampR_p14,
final int ampRateL_p14,
final int ampRateR_p14,
final int dstLen,
final int srcEnd_p8,
final RawSamplePlayer playback
) {
int playhead = playhead_p8 >> 8;
int srcEnd = srcEnd_p8 >> 8;
final int srcEnd = srcEnd_p8 >> 8;
int ampL_p16 = ampL_p14 << 2;
int ampR_p16 = ampR_p14 << 2;
int ampRateL_p16 = ampRateL_p14 << 2;
int ampRateR_p16 = ampRateR_p14 << 2;
final int ampRateL_p16 = ampRateL_p14 << 2;
final int ampRateR_p16 = ampRateR_p14 << 2;
int dstEnd = dstOff + srcEnd - playhead;
if (dstEnd > dstLen) {
@ -843,7 +839,7 @@ public final class RawSamplePlayer extends AudioSource {
final int stitch_s8
) {
int dstEnd = dstOff + (srcEnd_p8 - playhead_p8 + speed_p8 - 257) / speed_p8;
if (speed_p8 == 0 || dstEnd > dstLen) {
if (dstEnd > dstLen) {
dstEnd = dstLen;
}
@ -862,14 +858,14 @@ public final class RawSamplePlayer extends AudioSource {
playhead_p8 += speed_p8;
}
dstEnd = (dstOff >> 1) + (srcEnd_p8 - playhead_p8 + speed_p8 - 1) / speed_p8;
if (speed_p8 == 0 || dstEnd > dstLen) {
dstEnd = dstLen;
int dstEnd2 = (dstOff >> 1) + (srcEnd_p8 - playhead_p8 + speed_p8 - 1) / speed_p8;
if (dstEnd2 > dstLen) {
dstEnd2 = dstLen;
}
dstEnd <<= 1;
dstEnd2 <<= 1;
while (dstOff < dstEnd) {
while (dstOff < dstEnd2) {
src = src_s8[playhead_p8 >> 8];
out_s16 = (src << 8) + (stitch_s8 - src) * (playhead_p8 & 255);
dst_s16p8[dstOff++] += out_s16 * ampL_p14 >> 6;

View File

@ -87,8 +87,8 @@ public final class SongData {
+ nPolyAftertouchDeltas);
midiSize += nChannelAftertouchDeltas + nPatchChangeDeltas;
int startOfTicksTable = input.pos;
int numEvents =
final int startOfTicksTable = input.pos;
final int numEvents =
numTracks
+ nTempos
+ nCommands

View File

@ -115,7 +115,7 @@ public final class Synth {
for (int harm_idk = 0; harm_idk < 5; ++harm_idk) {
if (this.harmVol_idk[harm_idk] != 0) {
int index = i + harmDelScaled_idk[harm_idk];
final int index = i + harmDelScaled_idk[harm_idk];
if (index < len) {
buf[index] += this.sample(
this.envBaseFreq.waveform,

View File

@ -2,6 +2,8 @@ package funorb.audio;
import funorb.util.BitMath;
import java.util.stream.IntStream;
public final class VorbisCodebook {
public final int cbDim;
private final int cbSize;
@ -39,11 +41,11 @@ public final class VorbisCodebook {
this.initHuffmanTree();
int lookupTableType = VorbisFormat.readBits(4);
final int lookupTableType = VorbisFormat.readBits(4);
if (lookupTableType > 0) {
final float cbMinValue = VorbisFormat.float32Unpack(VorbisFormat.readBits(32));
final float cbDeltaValue = VorbisFormat.float32Unpack(VorbisFormat.readBits(32));
int cbValueBits = VorbisFormat.readBits(4) + 1;
final int cbValueBits = VorbisFormat.readBits(4) + 1;
final boolean cbSequenceP = VorbisFormat.readBit() != 0;
final int lookupValues;
@ -53,10 +55,7 @@ public final class VorbisCodebook {
lookupValues = this.cbSize * this.cbDim;
}
final int[] cbMultiplicands = new int[lookupValues];
for (int i = 0; i < lookupValues; ++i) {
cbMultiplicands[i] = VorbisFormat.readBits(cbValueBits);
}
final int[] cbMultiplicands = IntStream.range(0, lookupValues).map(i -> VorbisFormat.readBits(cbValueBits)).toArray();
this.vectors = new float[this.cbSize][this.cbDim];
float last;
@ -139,7 +138,7 @@ public final class VorbisCodebook {
final int var6 = var2[cwLength];
var1[entry] = var6;
int var9;
int var7;
final int var7;
if ((var6 & bitMask) == 0) {
var7 = var6 | bitMask;
@ -149,7 +148,7 @@ public final class VorbisCodebook {
break;
}
int var10 = 1 << 32 - j;
final int var10 = 1 << 32 - j;
if ((var9 & var10) != 0) {
var2[j] = var2[j - 1];
break;
@ -175,16 +174,16 @@ public final class VorbisCodebook {
int var11 = 0;
for (int entry = 0; entry < this.cbSize; ++entry) {
int cwLength = this.cwLengths[entry];
final int cwLength = this.cwLengths[entry];
if (cwLength == 0) {
continue;
}
int var5 = var1[entry];
final int var5 = var1[entry];
int var6 = 0;
for (int bit = 0; bit < cwLength; ++bit) {
int var8 = Integer.MIN_VALUE >>> bit;
final int var8 = Integer.MIN_VALUE >>> bit;
if ((var5 & var8) == 0) {
++var6;
} else {
@ -197,9 +196,7 @@ public final class VorbisCodebook {
if (var6 >= this.tree.length) {
final int[] newTree = new int[this.tree.length * 2];
for (int k = 0; k < this.tree.length; ++k) {
newTree[k] = this.tree[k];
}
System.arraycopy(this.tree, 0, newTree, 0, this.tree.length);
this.tree = newTree;
}
}

View File

@ -2,6 +2,8 @@ package funorb.audio;
import funorb.util.BitMath;
import java.util.stream.IntStream;
public final class VorbisFloor1 {
private static final float[] INVERSE_DB_TABLE = new float[]{
1.0649863E-7F, 1.1341951E-7F, 1.2079015E-7F, 1.2863978E-7F,
@ -98,7 +100,7 @@ public final class VorbisFloor1 {
int maxClassPlusOne = 0;
for (int i = 0; i < numPartitions; ++i) {
int cls = VorbisFormat.readBits(4);
final int cls = VorbisFormat.readBits(4);
this.partitionClasses[i] = cls;
if (cls >= maxClassPlusOne) {
maxClassPlusOne = cls + 1;
@ -127,20 +129,16 @@ public final class VorbisFloor1 {
}
this.multiplier = VorbisFormat.readBits(2) + 1;
int rangeBits = VorbisFormat.readBits(4);
int xListSize = 2;
for (int i = 0; i < numPartitions; ++i) {
xListSize += this.classDims[this.partitionClasses[i]];
}
final int rangeBits = VorbisFormat.readBits(4);
final int xListSize = 2 + IntStream.range(0, numPartitions).map(i -> this.classDims[this.partitionClasses[i]]).sum();
this.xList = new int[xListSize];
this.xList[0] = 0;
this.xList[1] = 1 << rangeBits;
int values = 2;
for (int i = 0; i < numPartitions; ++i) {
int cls = this.partitionClasses[i];
final int cls = this.partitionClasses[i];
for (int j = 0; j < this.classDims[cls]; ++j) {
this.xList[values++] = VorbisFormat.readBits(rangeBits);
}
@ -190,11 +188,9 @@ public final class VorbisFloor1 {
return false;
}
for (int i = 0; i < this.xList.length; ++i) {
floorX[i] = this.xList[i];
}
System.arraycopy(this.xList, 0, floorX, 0, this.xList.length);
int range = FLOOR_MULTIPLIER_LOOKUP[this.multiplier - 1];
final int range = FLOOR_MULTIPLIER_LOOKUP[this.multiplier - 1];
final int yBits = BitMath.lastSet(range - 1);
floorY[0] = VorbisFormat.readBits(yBits);
floorY[1] = VorbisFormat.readBits(yBits);
@ -278,7 +274,7 @@ public final class VorbisFloor1 {
final int adx = hx - lx;
int ady = dy < 0 ? -dy : dy;
final int base = dy / adx;
int x = lx;
int x;
int y = ly;
int err = 0;
final int sy = dy < 0 ? base - 1 : base + 1;
@ -310,19 +306,22 @@ public final class VorbisFloor1 {
step2Flag[1] = true;
for (int i = 2; i < numValues; ++i) {
int lowOffset = lowNeighbor(floorX, i);
int highOffset = highNeighbor(floorX, i);
int predicted = this.renderPoint(
final int lowOffset = lowNeighbor(floorX, i);
final int highOffset = highNeighbor(floorX, i);
final int predicted = this.renderPoint(
floorX[lowOffset],
floorY[lowOffset],
floorX[highOffset],
floorY[highOffset],
floorX[i]
);
int val = floorY[i];
final int val = floorY[i];
final int highroom = range - predicted;
final int room = (Math.min(highroom, predicted)) << 1;
if (val != 0) {
if (val == 0) {
VorbisFloor1.step2Flag[i] = false;
floorY[i] = predicted;
} else {
final boolean[] var14 = VorbisFloor1.step2Flag;
VorbisFloor1.step2Flag[highOffset] = true;
var14[lowOffset] = true;
@ -332,9 +331,6 @@ public final class VorbisFloor1 {
} else {
floorY[i] = (val & 1) != 0 ? predicted - (val + 1) / 2 : predicted + val / 2;
}
} else {
VorbisFloor1.step2Flag[i] = false;
floorY[i] = predicted;
}
}
@ -346,8 +342,8 @@ public final class VorbisFloor1 {
if (!VorbisFloor1.step2Flag[i]) {
continue;
}
int hx = floorX[i];
int hy = floorY[i] * this.multiplier;
final int hx = floorX[i];
final int hy = floorY[i] * this.multiplier;
this.renderLinePremultiplied(lx, ly, hx, hy, floor, n);
if (hx >= n) {
return;

View File

@ -72,10 +72,10 @@ public final class VorbisFormat {
window = new float[blocksize1];
for (int i = 0; i < 2; ++i) {
int n = i == 0 ? blocksize0 : blocksize1;
int n2 = n >> 1;
int n4 = n >> 2;
int n8 = n >> 3;
final int n = i == 0 ? blocksize0 : blocksize1;
final int n2 = n >> 1;
final int n4 = n >> 2;
final int n8 = n >> 3;
final float[] tbl1 = new float[n2];
for (int j = 0; j < n4; ++j) {
@ -111,36 +111,36 @@ public final class VorbisFormat {
}
}
int numCodebooks = readBits(8) + 1;
final int numCodebooks = readBits(8) + 1;
codebooks = new VorbisCodebook[numCodebooks];
for (int i = 0; i < numCodebooks; ++i) {
codebooks[i] = new VorbisCodebook();
}
int numVorbisTimes = readBits(6) + 1;
final int numVorbisTimes = readBits(6) + 1;
for (int i = 0; i < numVorbisTimes; ++i) {
readBits(16);
}
int numFloors = readBits(6) + 1;
final int numFloors = readBits(6) + 1;
floors = new VorbisFloor1[numFloors];
for (int i = 0; i < numFloors; ++i) {
floors[i] = new VorbisFloor1();
}
int numResidues = readBits(6) + 1;
final int numResidues = readBits(6) + 1;
residues = new VorbisResidue[numResidues];
for (int i = 0; i < numResidues; ++i) {
residues[i] = new VorbisResidue();
}
int numMappings = readBits(6) + 1;
final int numMappings = readBits(6) + 1;
mappings = new VorbisMapping[numMappings];
for (int i = 0; i < numMappings; ++i) {
mappings[i] = new VorbisMapping();
}
int numModes = readBits(6) + 1;
final int numModes = readBits(6) + 1;
modeBlockFlag = new boolean[numModes];
modeMapping = new int[numModes];
@ -283,7 +283,7 @@ public final class VorbisFormat {
readBit(); // packet type (assumed audio)
final int modeNumber = readBits(BitMath.lastSet(modeMapping.length - 1));
final boolean isLongWindow = VorbisFormat.modeBlockFlag[modeNumber];
final boolean isLongWindow = modeBlockFlag[modeNumber];
final int n = isLongWindow ? blocksize1 : blocksize0;
boolean prevWindowFlag = false;
@ -376,7 +376,7 @@ public final class VorbisFormat {
v[4 * i + 1] = (b - d) * e + (a - c) * f;
}
int bits = BitMath.lastSet(n - 1);
final int bits = BitMath.lastSet(n - 1);
for (int i = 0; i < bits - 3; ++i) {
final int nI = n >> i + 2;
@ -493,7 +493,7 @@ public final class VorbisFormat {
}
}
float[] tmp = this.lastWindow;
final float[] tmp = this.lastWindow;
this.lastWindow = window;
window = tmp;

View File

@ -65,7 +65,7 @@ public final class VorbisResidue {
}
for (int dim = 0; dim < cbDim; ++dim) {
int cls = classes[part];
final int cls = classes[part];
final int bookIndex = this.books[cls * 8 + pass];
if (bookIndex >= 0) {
@ -73,7 +73,7 @@ public final class VorbisResidue {
final VorbisCodebook book = VorbisFormat.codebooks[bookIndex];
if (this.type == 0) {
int step = this.partitionSize / book.cbDim;
final int step = this.partitionSize / book.cbDim;
for (int i = 0; i < step; ++i) {
final float[] vector = book.decodeVector();
for (int j = 0; j < book.cbDim; ++j) {

View File

@ -25,7 +25,7 @@ public final class BufferedPageCache {
@Override
public String toString() {
return "" + this.pageId;
return String.valueOf(this.pageId);
}
public byte[] read(final int groupId) {

View File

@ -162,7 +162,7 @@ public final class PageLoader {
private @Nullable WorkItem tryLoadGroup(final @NotNull LoadMethod how, final int groupId) {
WorkItem item = this.dataItems.get(groupId);
if (how == LoadMethod.TRY_CACHE_ELSE_FETCH
&& item instanceof CacheWorker.WorkItem cacheItem
&& item instanceof final CacheWorker.WorkItem cacheItem
&& !cacheItem.isTryWithoutWrite
&& !item.isLoaded()) {
this.dataItems.remove(groupId);
@ -186,7 +186,7 @@ public final class PageLoader {
}
final byte[] data = item.getData();
if (item instanceof CacheWorker.WorkItem cacheItem) {
if (item instanceof final CacheWorker.WorkItem cacheItem) {
try {
if (data == null || data.length <= 2) {
throw new RuntimeException();

View File

@ -97,9 +97,9 @@ public final class ResourceLoader {
private static byte[] asBytes(final Object o) {
if (o == null) {
return null;
} else if (o instanceof byte[] bs) {
} else if (o instanceof final byte[] bs) {
return bs;
} else if (o instanceof ByteContainer bc) {
} else if (o instanceof final ByteContainer bc) {
return bc.toByteArray();
} else {
throw new IllegalArgumentException();

View File

@ -1233,7 +1233,7 @@ public final class JagexLogoIntroAnimation {
return var4;
} else {
throw new IllegalStateException("" + var1);
throw new IllegalStateException(String.valueOf(var1));
}
}

View File

@ -99,7 +99,7 @@ public class AbstractTextField extends Button {
private void j423() {
if (this._M) {
if (this.renderer instanceof ITextRenderer var2) {
if (this.renderer instanceof final ITextRenderer var2) {
final AbstractTextLayout var3 = var2.updateLayout(this);
final int var4 = var3.getWidth();
final int var5 = var2.getAvailableWidth(this);
@ -137,7 +137,7 @@ public class AbstractTextField extends Button {
public final void draw(final int x, final int y) {
if (this.renderer != null) {
this.renderer.draw(this, x, y, this.enabled);
if (this.renderer instanceof ITextRenderer var5) {
if (this.renderer instanceof final ITextRenderer var5) {
if (this._H != this._N) {
var5.a132(this._N, y, x, this._H, this);
}
@ -275,7 +275,7 @@ public class AbstractTextField extends Button {
super.tick(x, y, root);
this.j423();
if (this.mouseButtonClicked == MouseState.Button.LEFT) {
if (this.renderer instanceof ITextRenderer var5) {
if (this.renderer instanceof final ITextRenderer var5) {
int var6 = var5.a242(x, JagexApplet.mouseX, y, this, JagexApplet.mouseY);
if (var6 != -1) {
if (this._P && this._R > var6 && var6 > this._N) {
@ -353,7 +353,7 @@ public class AbstractTextField extends Button {
}
private void handleEnterKey() {
if (this.listener instanceof TextFieldListener l) {
if (this.listener instanceof final TextFieldListener l) {
l.handleTextFieldEnterPressed(this);
}
}

View File

@ -42,7 +42,7 @@ public class Component {
}
public final void pack() {
if (this.renderer instanceof ITextRenderer textRenderer) {
if (this.renderer instanceof final ITextRenderer textRenderer) {
this.width = textRenderer.getPreferredWidth(this);
this.height = textRenderer.getPreferredHeight(this);
}

View File

@ -4,6 +4,8 @@ import funorb.commonui.Component;
import funorb.commonui.Resources;
import funorb.graphics.Font;
import java.util.Arrays;
public final class PasswordFieldRenderer extends TextFieldRenderer {
private PasswordFieldRenderer(final Font font) {
super(font);
@ -17,11 +19,7 @@ public final class PasswordFieldRenderer extends TextFieldRenderer {
protected String getText(final Component component) {
final int var1 = component.text.length();
final char[] var21 = new char[var1];
for (int var3 = 0; var3 < var1; ++var3) {
var21[var3] = '*';
}
Arrays.fill(var21, '*');
return new String(var21);
}
}

View File

@ -235,7 +235,7 @@ public final class HuffmanCoder {
final int var10 = this._a[byteToEncode];
final byte var11 = this.codes[byteToEncode];
if (var11 == 0) {
throw new RuntimeException("" + byteToEncode);
throw new RuntimeException(String.valueOf(byteToEncode));
}
int destPos = var8 >> 3;

View File

@ -2513,7 +2513,7 @@ public final class GameUI {
this.processMouseInput(this.components);
if (this.mouseDownComponent != null) {
for (final UIComponent<?> var4 : this.components) {
if (var4 instanceof FloatingPanel<?> var5) {
if (var4 instanceof final FloatingPanel<?> var5) {
if (var5.visible && var5.hasChild(this.mouseDownComponent)) {
this.a690(var5);
var5.flashing = false;
@ -2543,7 +2543,7 @@ public final class GameUI {
}
if (this.clickedComponent != null) {
if (this.clickedComponent.data instanceof FloatingPanel<?> clickedTarget2) {
if (this.clickedComponent.data instanceof final FloatingPanel<?> clickedTarget2) {
clickedTarget2.visible = false;
if (clickedTarget2 == this.productionPanel) {
this.productionButton.tooltip = StringConstants.TOOLTIP_PRODUCTION_BUTTON_SHOW;
@ -3308,10 +3308,10 @@ public final class GameUI {
* Like {@link Label}, but highlighted green while placing a terraforming
* project if the resource is a surplus resource.
*/
private class ResourceProductionLabel extends Label {
private final class ResourceProductionLabel extends Label {
private final boolean isSurplus;
protected ResourceProductionLabel(final int x, final int y, final int width, final int height, final String text, final boolean isSurplus) {
private ResourceProductionLabel(final int x, final int y, final int width, final int height, final String text, final boolean isSurplus) {
super(x, y, width, height, text);
this.isSurplus = isSurplus;
}

View File

@ -240,7 +240,6 @@ public abstract class JagexApplet extends JagexBaseApplet {
}
protected static Frame createFullScreenFrame() {
int bitDepth = 0;
final DisplayMode[] modes = listDisplayModes();
DisplayMode foundMode = null;
@ -350,7 +349,7 @@ public abstract class JagexApplet extends JagexBaseApplet {
return;
}
final MailboxMessage var4 = MessagePumpThread.instance.sendOpenUrlStreamMessage(new URL(_eic.getCodeBase(), "clienterror.ws?c=" + getInstance().gameCrc + "&u=" + "" + _coo + "&v1=" + MessagePumpThread.JAVA_VENDOR + "&v2=" + MessagePumpThread.JAVA_VERSION + "&e=" + var3));
final MailboxMessage var4 = MessagePumpThread.instance.sendOpenUrlStreamMessage(new URL(_eic.getCodeBase(), "clienterror.ws?c=" + getInstance().gameCrc + "&u=" + _coo + "&v1=" + MessagePumpThread.JAVA_VENDOR + "&v2=" + MessagePumpThread.JAVA_VERSION + "&e=" + var3));
while (var4.status == MailboxMessage.Status.PENDING) {
JagexBaseApplet.maybeSleep(1L);

View File

@ -159,16 +159,17 @@ public abstract class AbstractGameView {
public final void setMap(final Map map) {
this.map = map;
this.maxUnitScalingFactor = (float) (this.map.drawingWidth * 300 / 450);
final SystemHighlight[] var3 = new SystemHighlight[this.map.systems.length];
final boolean[] var4 = new boolean[this.map.systems.length];
final SystemHighlight[] highlightedSystems = new SystemHighlight[this.map.systems.length];
Arrays.fill(highlightedSystems, SystemHighlight.NONE);
final boolean[] retreatTargets = new boolean[this.map.systems.length];
for (int i = 0; i < this.highlightedSystems.length; ++i) {
var3[i] = this.highlightedSystems[i];
var4[i] = this.retreatTargets[i];
highlightedSystems[i] = this.highlightedSystems[i];
retreatTargets[i] = this.retreatTargets[i];
}
this.highlightedSystems = var3;
this.retreatTargets = var4;
this.highlightedSystems = highlightedSystems;
this.retreatTargets = retreatTargets;
this.a487();
}
@ -382,11 +383,11 @@ public abstract class AbstractGameView {
}
for (final TurnEventLog.Event var10 : turnEvents) {
if (var10 instanceof BuildFleetsEvent var16) {
if (var10 instanceof final BuildFleetsEvent var16) {
this.clonedRemainingGarrisons[var16.system.index] += var16.quantity;
} else if (var10 instanceof StellarBombEvent var15) {
} else if (var10 instanceof final StellarBombEvent var15) {
this.clonedRemainingGarrisons[var15.target.index] -= var15.kill;
} else if (var10 instanceof MoveFleetsOrder var14) {
} else if (var10 instanceof final MoveFleetsOrder var14) {
this.clonedRemainingGarrisons[var14.source.index] -= var14.quantity;
}
}
@ -394,7 +395,7 @@ public abstract class AbstractGameView {
this.gameUI.setActionHint(StringConstants.TEXT_ANIMATING_MOVES);
} else if (phase == AnimationPhase.COMBAT) {
for (final TurnEventLog.Event var4 : turnEvents) {
if (var4 instanceof MoveFleetsOrder var5) {
if (var4 instanceof final MoveFleetsOrder var5) {
final int var6 = var5.target.index;
if (var5.player == this.systemOwners[var6]) {
this.clonedRemainingGarrisons[var6] += var5.quantity;
@ -417,7 +418,7 @@ public abstract class AbstractGameView {
}
for (final TurnEventLog.Event var10 : turnEvents) {
if (var10 instanceof CombatEngagementLog var12) {
if (var10 instanceof final CombatEngagementLog var12) {
for (final CombatLogEvent var7 : var12.events) {
if (var7.source != null && var7.source.owner == var7.player) {
@ -430,7 +431,7 @@ public abstract class AbstractGameView {
this.gameUI.setActionHint(StringConstants.SHOWING_COMBAT_RESULTS);
} else if (phase == AnimationPhase.RETREAT) {
for (final TurnEventLog.Event var4 : turnEvents) {
if (var4 instanceof FleetRetreatEvent var11) {
if (var4 instanceof final FleetRetreatEvent var11) {
final int var6 = var11.source.index;
this.clonedSystemOwners[var6] = null;
this.clonedRemainingGarrisons[var6] = 0;
@ -507,7 +508,7 @@ public abstract class AbstractGameView {
this.clearTurnEvents();
for (final TurnEventLog.Event event : eventLog.events) {
if (event instanceof MoveFleetsOrder moveOrder) {
if (event instanceof final MoveFleetsOrder moveOrder) {
if (moveOrder.player == null) {
errorOccurred = true;
errorMessage.append("Fleet from ").append(moveOrder.source.name)
@ -518,7 +519,7 @@ public abstract class AbstractGameView {
this.largestFleetMovement = moveOrder.quantity;
}
}
} else if (event instanceof CombatEngagementLog combatLog) {
} else if (event instanceof final CombatEngagementLog combatLog) {
this.combatEngagements.add(new CombatEngagementAnimationState(combatLog));
for (final CombatLogEvent combatEvent : combatLog.events) {
@ -530,7 +531,7 @@ public abstract class AbstractGameView {
}
}
}
} else if (event instanceof ProjectOrder projectEvent) {
} else if (event instanceof final ProjectOrder projectEvent) {
if (projectEvent.type == GameState.ResourceType.METAL) {
this.addBuildProjectEvent(projectEvent.target, projectEvent.player, GameState.ResourceType.METAL);
} else if (projectEvent.type == GameState.ResourceType.BIOMASS) {
@ -538,9 +539,9 @@ public abstract class AbstractGameView {
} else if (projectEvent.type == GameState.ResourceType.EXOTICS) {
this.addBuildTannhauserEvent(projectEvent.player, projectEvent.source, projectEvent.target);
}
} else if (event instanceof StellarBombEvent bombEvent) {
} else if (event instanceof final StellarBombEvent bombEvent) {
this.addBuildProjectEvent(bombEvent.target, bombEvent.player, GameState.ResourceType.ENERGY);
} else if (event instanceof FleetRetreatEvent retreatEvent) {
} else if (event instanceof final FleetRetreatEvent retreatEvent) {
if (retreatEvent.targets != null) {
for (int i = 0; i < retreatEvent.targets.length; ++i) {
final MoveFleetsOrder moveOrder = new MoveFleetsOrder(retreatEvent.source.lastOwner, retreatEvent.source, retreatEvent.targets[i], retreatEvent.quantities[i]);
@ -556,7 +557,7 @@ public abstract class AbstractGameView {
}
for (final TurnEventLog.Event event : eventLog.events) {
if (event instanceof BuildFleetsEvent buildEvent) {
if (event instanceof final BuildFleetsEvent buildEvent) {
if (buildEvent.player == null) {
errorOccurred = true;
errorMessage.append("Build event at ").append(buildEvent.system.name).append(" has no owner.\n");

View File

@ -951,13 +951,13 @@ public final class ClientGameSession extends GameSession {
if (this.turnEventLog != null) {
for (final TurnEventLog.Event event : this.turnEventLog.events) {
if (event instanceof BuildFleetsEvent buildEvent) {
if (event instanceof final BuildFleetsEvent buildEvent) {
if (buildEvent.player != null) {
var7[buildEvent.player.index] += buildEvent.quantity;
}
}
if (event instanceof CombatEngagementLog combatLog) {
if (event instanceof final CombatEngagementLog combatLog) {
for (int i = 0; i < this.gameState.playerCount; ++i) {
var8[i] += combatLog.playerKills[i];
}
@ -995,16 +995,16 @@ public final class ClientGameSession extends GameSession {
}
}
if (event instanceof StellarBombEvent bombEvent) {
if (event instanceof final StellarBombEvent bombEvent) {
var8[bombEvent.player.index] += bombEvent.kill;
++bombEvent.player.stats._s;
}
if (event instanceof ProjectOrder projectOrder) {
if (event instanceof final ProjectOrder projectOrder) {
++projectOrder.player.stats._s;
}
if (event instanceof MoveFleetsOrder moveOrder) {
if (event instanceof final MoveFleetsOrder moveOrder) {
moveOrder.player.stats._t++;
moveOrder.player.stats._i += moveOrder.quantity;
var9[moveOrder.player.index] += moveOrder.quantity;

View File

@ -74,7 +74,7 @@ public final class GameView extends AbstractGameView {
public boolean _Gb;
public boolean _Ab;
public MoveFleetsOrder _rb;
protected TacticalAnalysis tacticalAnalysis;
private TacticalAnalysis tacticalAnalysis;
private Sprite[] _Mb;
private ArgbSprite _K;
private double _wb;
@ -3705,7 +3705,7 @@ public final class GameView extends AbstractGameView {
}
}
public final void setTacticalAnalysis(final TacticalAnalysis tacticalAnalysis) {
public void setTacticalAnalysis(final TacticalAnalysis tacticalAnalysis) {
this.tacticalAnalysis = tacticalAnalysis;
}
}

View File

@ -766,7 +766,7 @@ public final class TutorialState {
private static CombatEngagementLog a471tl(final StarSystem var1) {
if (session.turnEventLog != null) {
for (final TurnEventLog.Event var2 : session.turnEventLog.events) {
if (var2 instanceof CombatEngagementLog var3) {
if (var2 instanceof final CombatEngagementLog var3) {
if (var1 == var3.system) {
final Player[] var4 = var3.players;

View File

@ -668,9 +668,9 @@ public final class TaskAI implements AI {
private void satisfyCombatTasks(final boolean var1) {
for (final AITask task : this.combatTasks) {
if (task instanceof DefenseTask defenseTask) {
if (task instanceof final DefenseTask defenseTask) {
this.satisfyDefenseTask(defenseTask, var1);
} else if (task instanceof CaptureTask captureTask) {
} else if (task instanceof final CaptureTask captureTask) {
this.satisfyCaptureTask(captureTask, var1);
} else {
throw new RuntimeException("prioritizedTasks contains invalid task for Star " + task.system.name + ".");

View File

@ -42,7 +42,7 @@ public final class ClientHandler extends ChannelDuplexHandler {
public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
boolean release = true;
try {
if (msg instanceof ByteBuf buf) {
if (msg instanceof final ByteBuf buf) {
this.channelRead0(ctx, buf);
} else {
release = false;
@ -57,7 +57,7 @@ public final class ClientHandler extends ChannelDuplexHandler {
@Override
public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) throws Exception {
if (msg instanceof Packet packet) {
if (msg instanceof final Packet packet) {
final ByteBuf header = ctx.alloc().buffer(1 + packet.lengthType.length);
if (packet.typeIsCiphered) {
header.writeByte(packet.type + this.client.s2cCipher.nextInt());

View File

@ -21,7 +21,7 @@ public final class FOEventQueue extends EventQueue {
}
private static MouseEvent fixEvent(final MouseEvent me) {
if (me instanceof MouseWheelEvent mwe) {
if (me instanceof final MouseWheelEvent mwe) {
return new MouseWheelEvent(me.getComponent(), me.getID(), me.getWhen(), modifiers(me),
me.getX(), me.getY(), me.getXOnScreen(), me.getYOnScreen(), me.getClickCount(),
me.isPopupTrigger(), mwe.getScrollType(), mwe.getScrollAmount(),
@ -74,7 +74,7 @@ public final class FOEventQueue extends EventQueue {
@Override
protected void dispatchEvent(final AWTEvent event) {
if (event instanceof MouseEvent me) {
if (event instanceof final MouseEvent me) {
final MouseEvent fake = fixEvent(me);
super.dispatchEvent(fake);
if (fake.isConsumed()) me.consume();