Skip to content

Commit 40c94e6

Browse files
authored
Merge pull request #16 from gen0cide/version3
fixed server indexing and added new logo
2 parents 7c10839 + fd841f7 commit 40c94e6

3,467 files changed

Lines changed: 103038 additions & 1116 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.firescape</groupId>
66
<artifactId>firescape-client</artifactId>
7-
<version>2.0</version>
7+
<version>3.0</version>
88

99
<properties>
1010
<maven.compiler.source>9</maven.compiler.source>

client/src/main/java/org/firescape/client/GameConnection.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,15 @@ protected void checkConnection() {
354354
}
355355

356356
private void handlePacket(Command.Server opcode, int ptype, int psize) {
357-
System.out.println(String.format("[Packet] <<< %s(id=%d) size=%d\n%s",
358-
opcode.name(),
359-
ptype,
360-
psize,
361-
Utility.bytesToHex(Arrays.copyOfRange(incomingPacket, 0, psize))
362-
));
357+
String assetDumpEnabled = System.getenv("FIRESCAPE_DUMP_INCOMING_PACKETS");
358+
if (assetDumpEnabled != null) {
359+
System.out.println(String.format("[Packet] <<< %s(id=%d) size=%d\n%s",
360+
opcode.name(),
361+
ptype,
362+
psize,
363+
Utility.bytesToHex(Arrays.copyOfRange(incomingPacket, 0, psize))
364+
));
365+
}
363366
int offset = 1;
364367
if (opcode == Command.Server.SV_MESSAGE) {
365368
String s = new String(Arrays.copyOfRange(incomingPacket, 1, 1 + (psize - 1)));

client/src/main/java/org/firescape/client/Packet.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,17 @@ public void flushPacket() throws IOException {
209209
}
210210

211211
public void sendPacket() {
212-
byte[] packetDebug = Arrays.copyOfRange(packetData, packetStart + 2, packetEnd);
213-
System.out.println(String.format(
214-
"[Packet] >>> %s(id=%d) size=%d\n%s",
215-
Opcode.getClient(Version.CLIENT, packetData[packetStart + 2] & 0xff),
216-
packetData[packetStart + 2] & 0xff,
217-
packetDebug.length,
218-
Utility.bytesToHex(packetDebug)
219-
));
212+
String dumpPacketDebug = System.getenv("FIRESCAPE_DUMP_OUTGOING_PACKETS");
213+
if (dumpPacketDebug != null) {
214+
byte[] packetDebug = Arrays.copyOfRange(packetData, packetStart + 2, packetEnd);
215+
System.out.println(String.format(
216+
"[Packet] >>> %s(id=%d) size=%d\n%s",
217+
Opcode.getClient(Version.CLIENT, packetData[packetStart + 2] & 0xff),
218+
packetData[packetStart + 2] & 0xff,
219+
packetDebug.length,
220+
Utility.bytesToHex(packetDebug)
221+
));
222+
}
220223
if (isaacOutgoing != null) {
221224
int i = packetData[packetStart + 2] & 0xff;
222225
packetData[packetStart + 2] = (byte) (i + isaacOutgoing.getNextValue());

client/src/main/java/org/firescape/client/StreamAudioPlayer.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@
88
public class StreamAudioPlayer {
99

1010
// from sun.audio.AudioDevice.openChannel
11-
private static final AudioFormat pcmFormat = new AudioFormat(
12-
AudioFormat.Encoding.ULAW,
13-
8000, 8,
14-
1, 1,
15-
8000, true);
11+
private static final AudioFormat pcmFormat = new AudioFormat(AudioFormat.Encoding.ULAW, 8000, 8, 1, 1, 8000, true);
1612
// from com.sun.media.sound.Toolkit.getPCMConvertedAudioInputStream
17-
private static final AudioFormat lineFormat = new AudioFormat(
18-
AudioFormat.Encoding.PCM_SIGNED, 8000,
19-
16, 1, 2,
20-
8000, ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN);
13+
private static final AudioFormat lineFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
14+
8000,
15+
16,
16+
1,
17+
2,
18+
8000,
19+
ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN
20+
);
2121
private Clip clip;
2222

2323
public StreamAudioPlayer() throws LineUnavailableException {
2424
clip = AudioSystem.getClip();
2525
}
2626

27-
public void stopPlayer() {
28-
clip.stop();
29-
clip.flush();
30-
}
31-
3227
public void writeStream(byte buf[], int off, int len) throws IOException, LineUnavailableException {
3328
stopPlayer();
3429
clip.close();
@@ -38,4 +33,9 @@ public void writeStream(byte buf[], int off, int len) throws IOException, LineUn
3833
clip.open(audio);
3934
clip.start();
4035
}
36+
37+
public void stopPlayer() {
38+
clip.stop();
39+
clip.flush();
40+
}
4141
}

client/src/main/java/org/firescape/client/Surface.java

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package org.firescape.client;
22

3+
import javax.imageio.ImageIO;
34
import java.awt.*;
45
import java.awt.image.*;
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
import java.util.Set;
9+
import java.util.TreeSet;
510

611
public class Surface implements ImageProducer, ImageObserver {
712

@@ -460,6 +465,7 @@ public void clear() {
460465

461466
public void parseSprite(int spriteId, byte spriteData[], byte indexData[], int frameCount) {
462467
int indexOff = Utility.getUnsignedShort(spriteData, 0);
468+
int debugIndexOff = indexOff;
463469
int fullWidth = Utility.getUnsignedShort(indexData, indexOff);
464470
indexOff += 2;
465471
int fullHeight = Utility.getUnsignedShort(indexData, indexOff);
@@ -497,7 +503,6 @@ public void parseSprite(int spriteId, byte spriteData[], byte indexData[], int f
497503
spriteTranslate[id] = true;
498504
}
499505
}
500-
501506
} else if (unknown == 1) {
502507
for (int x = 0; x < spriteWidth[id]; x++) {
503508
for (int y = 0; y < spriteHeight[id]; y++) {
@@ -506,12 +511,54 @@ public void parseSprite(int spriteId, byte spriteData[], byte indexData[], int f
506511
spriteTranslate[id] = true;
507512
}
508513
}
509-
510514
}
515+
}
516+
InputStream inputstream = this.getClass()
517+
.getResourceAsStream("/org/firescape/client/conf/overwritten/" + id + ".png");
518+
if (inputstream != null) {
519+
System.out.println("Overwriting Sprite: " + id);
520+
overwriteSpritePixels(id, inputstream);
521+
}
522+
}
523+
}
511524

525+
public void overwriteSpritePixels(int id, InputStream inputstream) {
526+
BufferedImage sprite = loadNewSprite(inputstream);
527+
int[] pixelIndex = new int[sprite.getWidth() * sprite.getHeight()];
528+
for (int y = 0; y < sprite.getHeight(); y++) {
529+
for (int x = 0; x < sprite.getWidth(); x++) {
530+
int pixel = sprite.getRGB(x, y);
531+
if (pixel == 0) {
532+
pixel = 1;
533+
} else if (pixel == -65281) {
534+
pixel = 0;
535+
}
536+
pixelIndex[x + y * spriteWidth[id]] = pixel;
512537
}
513538
}
539+
Set<Integer> uniqueColors = new TreeSet<Integer>();
540+
uniqueColors.add(-65281);
541+
for (int i = 0; i < pixelIndex.length; i++) {
542+
uniqueColors.add(pixelIndex[i]);
543+
}
544+
545+
Integer[] colorList = uniqueColors.toArray(new Integer[uniqueColors.size()]);
546+
int[] colorArray = new int[colorList.length];
547+
for (int i = 0; i < colorList.length; i++) {
548+
colorArray[i] = colorList[i].intValue();
549+
}
550+
spriteColourList[id] = colorArray;
551+
spritePixels[id] = pixelIndex;
552+
}
514553

554+
public BufferedImage loadNewSprite(InputStream is) {
555+
try {
556+
BufferedImage logo = ImageIO.read(is);
557+
return logo;
558+
} catch (IOException e) {
559+
e.printStackTrace();
560+
}
561+
return null;
515562
}
516563

517564
public void readSleepWord(int spriteId, byte spriteData[]) {
@@ -638,22 +685,22 @@ public void loadSprite(int spriteId) {
638685
pixels[pixel] = colour;
639686
}
640687

641-
// int i = spriteId;
642-
// Sprite s = new Sprite(
643-
// spriteId,
644-
// spriteId,
645-
// spriteWidth[i],
646-
// spriteHeight[i],
647-
// spriteWidthFull[i],
648-
// spriteHeightFull[i],
649-
// spriteColourList[i].length,
650-
// spriteColourList[i],
651-
// spriteTranslateX[i],
652-
// spriteTranslateY[i],
653-
// spriteTranslate[i],
654-
// pixels
655-
// );
656-
// s.saveSprite();
688+
// int i = spriteId;
689+
// Sprite s = new Sprite(
690+
// spriteId,
691+
// spriteId,
692+
// spriteWidth[i],
693+
// spriteHeight[i],
694+
// spriteWidthFull[i],
695+
// spriteHeightFull[i],
696+
// spriteColourList[i].length,
697+
// spriteColourList[i],
698+
// spriteTranslateX[i],
699+
// spriteTranslateY[i],
700+
// spriteTranslate[i],
701+
// pixels
702+
// );
703+
// s.saveSprite();
657704

658705
spritePixels[spriteId] = pixels;
659706
spriteColoursUsed[spriteId] = null;

client/src/main/java/org/firescape/client/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Version {
44

5-
public static short FIRESCAPE_VERSION = 2;
5+
public static short FIRESCAPE_VERSION = 3;
66
public static int CLIENT = 204;
77
public static int CONFIG = 85;
88
public static int MAPS = 63;

client/src/main/java/org/firescape/client/mudclient.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,6 +5878,7 @@ private void menuItemClick(int i) {
58785878
int msrcidx = menuSourceIndex[i];
58795879
int mtargetindex = menuTargetIndex[i];
58805880
int mitemid = menuItemID[i];
5881+
System.out.println("mitemid = " + mitemid);
58815882
String mtext = menuTextVar[i];
58825883
if (mitemid == 200) {
58835884
walkToGroundItem(localRegionX, localRegionY, mx, my, true);
@@ -6107,6 +6108,7 @@ private void menuItemClick(int i) {
61076108
super.clientStream.sendPacket();
61086109
}
61096110
if (mitemid == 2810) {
6111+
System.out.println("SENDING TRADE TO PLAYER ID = " + midx);
61106112
super.clientStream.newPacket(Opcode.getClient(Version.CLIENT, Command.Client.CL_PLAYER_TRADE));
61116113
super.clientStream.putShort(midx);
61126114
super.clientStream.sendPacket();
@@ -7378,10 +7380,7 @@ private void renderLoginScreenViewports() {
73787380
scene.render();
73797381
surface.fade2black();
73807382
surface.fade2black();
7381-
surface.drawSprite(gameWidth / 2 - surface.spriteWidth[spriteMedia + 10] / 2,
7382-
gameHeight / 2 - 152,
7383-
spriteMedia + 10
7384-
); // runescape logo
7383+
surface.drawSprite(gameWidth / 2 - 245, gameHeight / 2 - 152, spriteMedia + 10); // runescape logo
73857384

73867385
surface.drawSprite(spriteLogo, 0, 0, gameWidth, gameHeight);
73877386
surface.drawWorld(spriteLogo);
@@ -7398,10 +7397,7 @@ private void renderLoginScreenViewports() {
73987397
scene.render();
73997398
surface.fade2black();
74007399
surface.fade2black();
7401-
surface.drawSprite(gameWidth / 2 - surface.spriteWidth[spriteMedia + 10] / 2,
7402-
gameHeight / 2 - 152,
7403-
spriteMedia + 10
7404-
);
7400+
surface.drawSprite(gameWidth / 2 - 245, gameHeight / 2 - 152, spriteMedia + 10);
74057401
surface.drawSprite(spriteLogo + 1, 0, 0, gameWidth, gameHeight); // h was 200
74067402
surface.drawWorld(spriteLogo + 1);
74077403

@@ -7427,10 +7423,7 @@ private void renderLoginScreenViewports() {
74277423
surface.fade2black();
74287424
surface.fade2black();
74297425

7430-
surface.drawSprite(gameWidth / 2 - surface.spriteWidth[spriteMedia + 10] / 2,
7431-
gameHeight / 2 - 152,
7432-
spriteMedia + 10
7433-
);
7426+
surface.drawSprite(gameWidth / 2 - 245, gameHeight / 2 - 152, spriteMedia + 10);
74347427
surface.drawSprite(spriteMedia + 10, 0, 0, gameWidth, gameHeight);
74357428
surface.drawWorld(spriteMedia + 10);
74367429
}
257 KB
Loading

conf/json/sprites/0.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"gson": {
3+
"DEFAULT_JSON_NON_EXECUTABLE": false,
4+
"DEFAULT_LENIENT": false,
5+
"DEFAULT_PRETTY_PRINT": false,
6+
"DEFAULT_ESCAPE_HTML": true,
7+
"DEFAULT_SERIALIZE_NULLS": false,
8+
"DEFAULT_COMPLEX_MAP_KEYS": false,
9+
"DEFAULT_SPECIALIZE_FLOAT_VALUES": false
10+
},
11+
"id": 0,
12+
"offset": 3254,
13+
"width": 16,
14+
"height": 18,
15+
"fullWidth": 64,
16+
"fullHeight": 102,
17+
"colorCount": 9,
18+
"colors": [
19+
16711935,
20+
10526880,
21+
8684676,
22+
6776679,
23+
16764365,
24+
16758197,
25+
9783611,
26+
2693144,
27+
16743548
28+
],
29+
"translateX": 24,
30+
"translateY": 9,
31+
"translate": true
32+
}

conf/json/sprites/1.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"gson": {
3+
"DEFAULT_JSON_NON_EXECUTABLE": false,
4+
"DEFAULT_LENIENT": false,
5+
"DEFAULT_PRETTY_PRINT": false,
6+
"DEFAULT_ESCAPE_HTML": true,
7+
"DEFAULT_SERIALIZE_NULLS": false,
8+
"DEFAULT_COMPLEX_MAP_KEYS": false,
9+
"DEFAULT_SPECIALIZE_FLOAT_VALUES": false
10+
},
11+
"id": 1,
12+
"offset": 3254,
13+
"width": 16,
14+
"height": 18,
15+
"fullWidth": 64,
16+
"fullHeight": 102,
17+
"colorCount": 9,
18+
"colors": [
19+
16711935,
20+
10526880,
21+
8684676,
22+
6776679,
23+
16764365,
24+
16758197,
25+
9783611,
26+
2693144,
27+
16743548
28+
],
29+
"translateX": 24,
30+
"translateY": 9,
31+
"translate": true
32+
}

0 commit comments

Comments
 (0)