Skip to content

Commit 4147698

Browse files
committed
Refactoring a lot of map drawing stuff
1 parent a206728 commit 4147698

File tree

9 files changed

+113
-103
lines changed

9 files changed

+113
-103
lines changed

src/main/java/org/runejs/client/Class24.java

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ public static IndexedImage[] method337(CacheArchive arg1, int arg2, int arg3) {
2020
return Class22_Sub2.method315();
2121
}
2222

23-
public static int method338(int arg0, boolean arg1, int arg2, int arg3) {
24-
arg0 &= 0x3;
23+
public static int getRotatedTileX(int rotation, boolean arg1, int x, int y) {
24+
rotation &= 0x3;
2525
if(arg1)
2626
return 68;
27-
if(arg0 == 0)
28-
return arg2;
29-
if(arg0 == 1)
30-
return arg3;
31-
if(arg0 == 2)
32-
return -arg2 + 7;
33-
return 7 + -arg3;
27+
if(rotation == 0)
28+
return x;
29+
if(rotation == 1)
30+
return y;
31+
if(rotation == 2)
32+
return -x + 7;
33+
return 7 + -y;
3434
}
3535

3636

@@ -39,64 +39,73 @@ public static boolean method340() {
3939

4040
}
4141

42-
public static void method341(int arg0, Scene arg1, int arg2, int arg3, int arg4, int arg5, byte[] arg6, int arg7, CollisionMap[] arg8, int arg9, int arg10) {
43-
do {
44-
Buffer class40_sub1 = new Buffer(arg6);
45-
int i = -1;
42+
public static void constructMapRegionObjects(int drawX, int drawY, int drawingPlane, int orientation, int x, int y, int plane, Scene scene, byte[] objectData, CollisionMap[] collisionMaps) {
43+
Buffer objectBuffer = new Buffer(objectData);
44+
int i = -1;
45+
for(; ; ) {
46+
int idOffset = objectBuffer.getSmart();
47+
if(idOffset == 0)
48+
break;
49+
int objectPositionInfo = 0;
50+
i += idOffset;
4651
for(; ; ) {
47-
int i_0_ = class40_sub1.getSmart();
48-
if(i_0_ == 0)
52+
int objectInfoOffset = objectBuffer.getSmart();
53+
if(objectInfoOffset == 0)
4954
break;
50-
int i_1_ = 0;
51-
i += i_0_;
52-
for(; ; ) {
53-
int i_2_ = class40_sub1.getSmart();
54-
if(i_2_ == 0)
55-
break;
56-
i_1_ += -1 + i_2_;
57-
int i_3_ = i_1_ >> 12;
58-
int i_4_ = 0x3f & i_1_ >> 6;
59-
int i_5_ = class40_sub1.getUnsignedByte();
60-
int i_6_ = i_5_ >> 2;
61-
int i_7_ = i_1_ & 0x3f;
62-
int i_8_ = i_5_ & 0x3;
63-
if(i_3_ == arg5 && arg0 <= i_4_ && i_4_ < 8 + arg0 && arg9 <= i_7_ && arg9 + 8 > i_7_) {
64-
GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i);
65-
int i_9_ = Main.method42(arg2 ^ 0x1, i_8_, gameObjectDefinition.sizeX, i_4_ & 0x7, gameObjectDefinition.sizeY, arg4, 0x7 & i_7_) + arg10;
66-
int i_10_ = method564(i_7_ & 0x7, gameObjectDefinition.sizeY, i_4_ & 0x7, gameObjectDefinition.sizeX, arg4, i_8_) + arg7;
67-
if(i_9_ > 0 && i_10_ > 0 && i_9_ < 103 && i_10_ < 103) {
68-
CollisionMap collisionMap = null;
69-
int i_11_ = arg3;
70-
if((OverlayDefinition.tile_flags[1][i_9_][i_10_] & 0x2) == 2)
71-
i_11_--;
72-
if(i_11_ >= 0)
73-
collisionMap = arg8[i_11_];
74-
Class40_Sub5_Sub17_Sub1.addObject(i, i_9_, i_10_, arg3, i_8_ + arg4 & 0x3, i_6_, arg1, collisionMap);
75-
}
55+
objectPositionInfo += -1 + objectInfoOffset;
56+
int objectPlane = objectPositionInfo >> 12;
57+
int objectX = 0x3f & objectPositionInfo >> 6;
58+
int objectMetadata = objectBuffer.getUnsignedByte();
59+
int objectType = objectMetadata >> 2;
60+
int objectY = objectPositionInfo & 0x3f;
61+
int originalOrientation = objectMetadata & 0x3;
62+
if(objectPlane == drawingPlane && drawX <= objectX && objectX < 8 + drawX && drawY <= objectY && drawY + 8 > objectY) {
63+
GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i);
64+
int tileX = getRotatedObjectX(objectX & 0x7, 0x7 & objectY, gameObjectDefinition.sizeX, gameObjectDefinition.sizeY, orientation, originalOrientation) + x;
65+
int tileY = getRotatedObjectY(objectX & 0x7, objectY & 0x7, gameObjectDefinition.sizeX, gameObjectDefinition.sizeY, orientation, originalOrientation) + y;
66+
if(tileX > 0 && tileY > 0 && tileX < 103 && tileY < 103) {
67+
CollisionMap collisionMap = null;
68+
int collisionMapPlane = plane;
69+
if((OverlayDefinition.tile_flags[1][tileX][tileY] & 0x2) == 2) // bridge tile, go down 1 level
70+
collisionMapPlane--;
71+
if(collisionMapPlane >= 0)
72+
collisionMap = collisionMaps[collisionMapPlane];
73+
Class40_Sub5_Sub17_Sub1.addObject(i, tileX, tileY, plane, originalOrientation + orientation & 0x3, objectType, scene, collisionMap);
7674
}
7775
}
7876
}
79-
if(arg2 == 0)
80-
break;
81-
aClass6_Sub1Array580 = null;
77+
}
78+
}
8279

83-
break;
84-
} while(false);
80+
public static int getRotatedObjectX(int x, int y, int sizeX, int sizeY, int orientation, int originalOrientation) {
81+
orientation &= 0x3;
82+
if ((originalOrientation & 0x1) == 1) {
83+
int i = sizeX;
84+
sizeX = sizeY;
85+
sizeY = i;
86+
}
87+
if (orientation == 0)
88+
return x;
89+
if (orientation == 1)
90+
return y;
91+
if (orientation == 2)
92+
return 7 - (x + sizeX) + 1;
93+
return 7 + -y + 1 + -sizeY;
8594
}
8695

87-
public static int method564(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) {
88-
arg4 &= 0x3;
89-
if((arg5 & 0x1) == 1) {
90-
int i = arg3;
91-
arg3 = arg1;
92-
arg1 = i;
96+
public static int getRotatedObjectY(int x, int y, int sizeX, int sizeY, int orientation, int originalOrientation) {
97+
orientation &= 0x3;
98+
if((originalOrientation & 0x1) == 1) {
99+
int i = sizeX;
100+
sizeX = sizeY;
101+
sizeY = i;
93102
}
94-
if(arg4 == 0)
95-
return arg0;
96-
if(arg4 == 1)
97-
return 1 + -arg3 + 7 - arg2;
98-
if(arg4 == 2)
99-
return -arg1 + 1 + -arg0 + 7;
100-
return arg2;
103+
if(orientation == 0)
104+
return y;
105+
if(orientation == 1)
106+
return 1 + -sizeX + 7 - x;
107+
if(orientation == 2)
108+
return -sizeY + 1 + -y + 7;
109+
return x;
101110
}
102111
}

src/main/java/org/runejs/client/Class33.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,17 @@ public static boolean menuHasAddFriend(byte arg0, int arg1) {
320320
return i == 45;
321321
}
322322

323-
public static int method410(int arg0, int arg1, int arg2, boolean arg3) {
324-
arg2 &= 0x3;
323+
public static int getRotatedTileY(int x, int y, int rotation, boolean arg3) {
324+
rotation &= 0x3;
325325
if(arg3)
326326
return -80;
327-
if(arg2 == 0)
328-
return arg1;
329-
if(arg2 == 1)
330-
return 7 + -arg0;
331-
if(arg2 == 2)
332-
return -arg1 + 7;
333-
return arg0;
327+
if(rotation == 0)
328+
return y;
329+
if(rotation == 1)
330+
return 7 + -x;
331+
if(rotation == 2)
332+
return -y + 7;
333+
return x;
334334

335335
}
336336

src/main/java/org/runejs/client/Landscape.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static void loadRegion() {
180180
int tileCoordinates = (tileX / 8 << 8) + tileY / 8;
181181
for(int i_38_ = 0; i_38_ < ISAAC.mapCoordinates.length; i_38_++) {
182182
if(tileCoordinates == ISAAC.mapCoordinates[i_38_] && GenericTile.objectData[i_38_] != null) {
183-
Class24.method341(8 * (tileX & 0x7), Npc.currentScene, 0, z, tileRotation, tileZ, GenericTile.objectData[i_38_], 8 * y, currentCollisionMap, 8 * (tileY & 0x7), x * 8);
183+
Class24.constructMapRegionObjects(8 * (tileX & 0x7), 8 * (tileY & 0x7), tileZ, tileRotation, x * 8, 8 * y, z, Npc.currentScene, GenericTile.objectData[i_38_], currentCollisionMap);
184184
break;
185185
}
186186
}
@@ -304,19 +304,19 @@ else if(arg4 < class40_sub2.anInt2003)
304304
}
305305

306306

307-
public static void loadTerrainSubblock(int arg0, int arg2, int arg3, int arg4, int x, int arg6, int arg7, byte[] arg8, CollisionMap[] arg9) {
307+
public static void loadTerrainSubblock(int y, int drawX, int drawingPlane, int currentPlane, int x, int drawY, int rotation, byte[] terrainData, CollisionMap[] collisionMaps) {
308308
for(int i = 0; i < 8; i++) {
309-
for(int y = 0; y < 8; y++) {
310-
if(x + i > 0 && i + x < 103 && arg0 + y > 0 && y + arg0 < 103)
311-
arg9[arg4].clippingData[x + i][y + arg0] = BitUtils.bitWiseAND(arg9[arg4].clippingData[x + i][y + arg0], -16777217);
309+
for(int yIdx = 0; yIdx < 8; yIdx++) {
310+
if(x + i > 0 && i + x < 103 && y + yIdx > 0 && yIdx + y < 103)
311+
collisionMaps[currentPlane].clippingData[x + i][yIdx + y] = BitUtils.bitWiseAND(collisionMaps[currentPlane].clippingData[x + i][yIdx + y], -16777217);
312312
}
313313
}
314-
Buffer class40_sub1 = new Buffer(arg8);
315-
for(int i = 0; i < 4; i++) {
316-
for(int i_1_ = 0; i_1_ < 64; i_1_++) {
317-
for(int i_2_ = 0; i_2_ < 64; i_2_++) {
318-
if(i == arg3 && i_1_ >= arg2 && 8 + arg2 > i_1_ && i_2_ >= arg6 && 8 + arg6 > i_2_)
319-
Class48.method922(x + Class24.method338(arg7, false, i_1_ & 0x7, i_2_ & 0x7), arg7, class40_sub1, arg0 + Class33.method410(i_1_ & 0x7, 0x7 & i_2_, arg7, false), 0, 0, arg4);
314+
Buffer class40_sub1 = new Buffer(terrainData);
315+
for(int plane = 0; plane < 4; plane++) {
316+
for(int tileX = 0; tileX < 64; tileX++) {
317+
for(int tileY = 0; tileY < 64; tileY++) {
318+
if(plane == drawingPlane && tileX >= drawX && 8 + drawX > tileX && tileY >= drawY && 8 + drawY > tileY)
319+
Class48.method922(x + Class24.getRotatedTileX(rotation, false, tileX & 0x7, tileY & 0x7), rotation, class40_sub1, y + Class33.getRotatedTileY(tileX & 0x7, 0x7 & tileY, rotation, false), 0, 0, currentPlane);
320320
else
321321
Class48.method922(-1, 0, class40_sub1, -1, 0, 0, 0);
322322
}

src/main/java/org/runejs/client/Main.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -693,22 +693,6 @@ else if (!params[2].equals("rc")) {
693693
}
694694

695695

696-
public static int method42(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {
697-
arg5 &= 0x3;
698-
if ((arg0 & arg1) == 1) {
699-
int i = arg2;
700-
arg2 = arg4;
701-
arg4 = i;
702-
}
703-
if (arg5 == 0)
704-
return arg3;
705-
if (arg5 == 1)
706-
return arg6;
707-
if (arg5 == 2)
708-
return 7 - (arg3 + arg2) + 1;
709-
return 7 + -arg6 + 1 + -arg4;
710-
}
711-
712696
public static void setConfigToDefaults() {
713697
Class51.aLong1203 = 0L;
714698
Class12.mouseCapturer.coord = 0;
@@ -1821,7 +1805,7 @@ public static void handleLoginScreenActions() {
18211805
MovedStatics.gameServerSocket.readDataToBuffer(0, IncomingPackets.incomingPacketSize, IncomingPackets.incomingPacketBuffer.buffer);
18221806
setConfigToDefaults();
18231807
Class51.regionX = -1;
1824-
FloorDecoration.method343(false, 5688);
1808+
FloorDecoration.constructMapRegion(false, 5688);
18251809
IncomingPackets.opcode = -1;
18261810
}
18271811
} else {

src/main/java/org/runejs/client/frame/console/Commands/ResizableCommand.java

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

88
public class ResizableCommand extends Command {
99
public ResizableCommand() {
10-
super("resizable", "toggles resiable mode");
10+
super(new String[]{ "resizable", "responsive" }, "toggles resiable mode");
1111
}
1212

1313
@Override

src/main/java/org/runejs/client/language/English.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ public class English {
1313
};
1414

1515
public static final String[] customLoginText = {
16-
16+
"An account is not required to play",
17+
"RuneJS, all you need to do is login",
18+
"with any username and password to",
19+
"create a character."
1720
};
1821

1922
public static final String newUser = "New User";

src/main/java/org/runejs/client/net/IncomingPackets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static boolean parseIncomingPackets() {
155155
return true;
156156
}
157157
if(opcode == 23) {
158-
FloorDecoration.method343(true, 5688);
158+
FloorDecoration.constructMapRegion(true, 5688);
159159
opcode = -1;
160160
return true;
161161
}
@@ -1094,7 +1094,7 @@ else if(fromPlayerRights == 1)
10941094
return true;
10951095
}
10961096
if(opcode == PacketType.SET_MAP_CHUNK.getOpcode()) {
1097-
FloorDecoration.method343(false, 5688);
1097+
FloorDecoration.constructMapRegion(false, 5688);
10981098
opcode = -1;
10991099
return true;
11001100
}

src/main/java/org/runejs/client/scene/tile/FloorDecoration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void method342(int arg1, Actor arg2) {
4343
Class22_Sub1.method312(arg1, arg2.worldY, arg2.worldX, 4976905);
4444
}
4545

46-
public static void method343(boolean arg0, int arg1) {
46+
public static void constructMapRegion(boolean arg0, int arg1) {
4747

4848
GroundItemTile.loadGeneratedMap = arg0;
4949
if(GroundItemTile.loadGeneratedMap) {

src/main/java/org/runejs/client/scene/tile/WallDecoration.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,28 @@ public static void drawLoadingScreen(TypeFace fontBold, TypeFace fontSmall) {
7979
if (Class51.gameStatusCode == 10) {
8080
Class40_Sub5_Sub15.loginScreenBox.drawImage(0, 0);
8181
if (Class26.loginScreenState == 0) {
82-
fontBold.drawShadowedStringCenter(English.welcomeTo, 180, 80, 16776960, true);
82+
/*fontBold.drawShadowedStringCenter(English.welcomeTo, 180, 80, 16776960, true);
8383
int drawX = 100;
8484
int drawY = 120;
8585
Class59.imgLoginScreenButton.drawImage(drawX - 73, drawY - 20);
8686
fontBold.drawText(English.newUser, drawX + -73, -20 + drawY, 144, 40, 16777215, true, 1, 1, 0);
8787
drawX = 260;
8888
Class59.imgLoginScreenButton.drawImage(drawX - 73, drawY + -20);
89-
fontBold.drawText(English.existingUser, drawX - 73, -20 + drawY, 144, 40, 16777215, true, 1, 1, 0);
89+
fontBold.drawText(English.existingUser, drawX - 73, -20 + drawY, 144, 40, 16777215, true, 1, 1, 0);*/
90+
91+
fontBold.drawShadowedStringCenter(English.welcomeTo, 180, 40, 16776960, true);
92+
int i = 180;
93+
int i_92_ = 150;
94+
int i_93_ = 65;
95+
96+
for(int textIndex = 0; textIndex < English.customLoginText.length; textIndex++) {
97+
fontBold.drawShadowedStringCenter(English.customLoginText[textIndex], 180, i_93_, 16777215, true);
98+
i_93_ += 15;
99+
}
100+
101+
Class59.imgLoginScreenButton.drawImage(-73 + i, i_92_ - 20);
102+
fontBold.drawShadowedStringCenter(English.login, i, 5 + i_92_, 16777215, true);
103+
90104
} else if (Class26.loginScreenState == 2) {
91105
int y1 = 40;
92106
int drawX = 100;

0 commit comments

Comments
 (0)