@@ -52,6 +52,12 @@ public class Landscape {
52
52
public static int randomiserHue = -8 + (int ) (17.0 * Math .random ());
53
53
private static int lowestPlane = 99 ;
54
54
55
+ private final Scene scene ;
56
+
57
+ public Landscape (Scene scene ) {
58
+ this .scene = scene ;
59
+ }
60
+
55
61
public void loadRegion () {
56
62
method364 (false );
57
63
Game .anInt874 = 0 ;
@@ -91,7 +97,7 @@ public void loadRegion() {
91
97
if (MovedStatics .anInt1634 != 0 )
92
98
MovedStatics .method940 (English .loadingPleaseWait , true , Native .percent100Parentheses );
93
99
Game .clearCaches ();
94
- Game . currentScene .initToNull ();
100
+ this . scene .initToNull ();
95
101
System .gc ();
96
102
for (int z = 0 ; z < 4 ; z ++)
97
103
currentCollisionMap [z ].reset ();
@@ -143,7 +149,7 @@ public void loadRegion() {
143
149
if (data != null ) {
144
150
int offsetX = -MovedStatics .baseX + (mapCoordinates [region ] >> 8 ) * 64 ;
145
151
int offsetY = 64 * (0xff & mapCoordinates [region ]) - MovedStatics .baseY ;
146
- loadObjectBlock (offsetX , Game . currentScene , currentCollisionMap , data , offsetY );
152
+ loadObjectBlock (offsetX , currentCollisionMap , data , offsetY );
147
153
} else {
148
154
System .out .println ("Missing map: " + objectDataIds [region ]);
149
155
}
@@ -194,7 +200,7 @@ public void loadRegion() {
194
200
int tileCoordinates = (tileX / 8 << 8 ) + tileY / 8 ;
195
201
for (int i_38_ = 0 ; i_38_ < mapCoordinates .length ; i_38_ ++) {
196
202
if (tileCoordinates == mapCoordinates [i_38_ ] && objectData [i_38_ ] != null ) {
197
- constructMapRegionObjects (8 * (tileX & 0x7 ), 8 * (tileY & 0x7 ), tileZ , tileRotation , x * 8 , 8 * y , z , Game . currentScene , objectData [i_38_ ], currentCollisionMap );
203
+ constructMapRegionObjects (8 * (tileX & 0x7 ), 8 * (tileY & 0x7 ), tileZ , tileRotation , x * 8 , 8 * y , z , objectData [i_38_ ], currentCollisionMap );
198
204
break ;
199
205
}
200
206
}
@@ -205,17 +211,17 @@ public void loadRegion() {
205
211
}
206
212
method364 (true );
207
213
Game .clearCaches ();
208
- createRegion (Game . currentScene , currentCollisionMap );
214
+ createRegion (currentCollisionMap );
209
215
method364 (true );
210
216
int z = lowestPlane ;
211
217
if (Player .worldLevel < z )
212
218
z = Player .worldLevel ;
213
219
if (z < -1 + Player .worldLevel )
214
220
z = -1 + Player .worldLevel ;
215
221
if (!VertexNormal .lowMemory )
216
- Game . currentScene .setPlane (0 );
222
+ this . scene .setPlane (0 );
217
223
else
218
- Game . currentScene .setPlane (lowestPlane );
224
+ this . scene .setPlane (lowestPlane );
219
225
for (int x = 0 ; x < 104 ; x ++) {
220
226
for (int y = 0 ; y < 104 ; y ++)
221
227
MovedStatics .spawnGroundItem (y , x );
@@ -297,7 +303,7 @@ private static int getRotatedTileY(int x, int y, int rotation) {
297
303
298
304
}
299
305
300
- private void constructMapRegionObjects (int drawX , int drawY , int drawingPlane , int orientation , int x , int y , int plane , Scene scene , byte [] objectData , CollisionMap [] collisionMaps ) {
306
+ private void constructMapRegionObjects (int drawX , int drawY , int drawingPlane , int orientation , int x , int y , int plane , byte [] objectData , CollisionMap [] collisionMaps ) {
301
307
Buffer objectBuffer = new Buffer (objectData );
302
308
int i = -1 ;
303
309
for (; ; ) {
@@ -328,7 +334,7 @@ private void constructMapRegionObjects(int drawX, int drawY, int drawingPlane, i
328
334
collisionMapPlane --;
329
335
if (collisionMapPlane >= 0 )
330
336
collisionMap = collisionMaps [collisionMapPlane ];
331
- addObject (i , tileX , tileY , plane , originalOrientation + orientation & 0x3 , objectType , scene , collisionMap );
337
+ addObject (i , tileX , tileY , plane , originalOrientation + orientation & 0x3 , objectType , collisionMap );
332
338
}
333
339
}
334
340
}
@@ -367,7 +373,7 @@ private static int getRotatedObjectY(int x, int y, int sizeX, int sizeY, int ori
367
373
return x ;
368
374
}
369
375
370
- private void createRegion (Scene scene , CollisionMap [] collisionMaps ) {
376
+ private void createRegion (CollisionMap [] collisionMaps ) {
371
377
for (int plane = 0 ; plane < 4 ; plane ++) {
372
378
for (int x = 0 ; x < 104 ; x ++) {
373
379
for (int y = 0 ; y < 104 ; y ++) {
@@ -546,29 +552,29 @@ else if(s > 255)
546
552
overlayMinimapColour = generateHslBitset (overlayDefinition .otherLightness , i_55_ , i_54_ );
547
553
rgb = Rasterizer3D .hsl2rgb [MovedStatics .mixLightnessSigned (overlayMinimapColour , 96 )];
548
554
}
549
- scene .addTile (_plane , x , y , shape , rotation , textureId , vertexHeightSW , vertexHeightSE , vertexHeightNE , vertexHeightNW , mixLightness (hslBitsetOriginal , lightIntensitySW ), mixLightness (hslBitsetOriginal , lightIntensitySE ), mixLightness (hslBitsetOriginal , lightIntensityNE ), mixLightness (hslBitsetOriginal , lightIntensityNW ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensitySW ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensitySE ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensityNE ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensityNW ), underlayMinimapColour , rgb );
555
+ this . scene .addTile (_plane , x , y , shape , rotation , textureId , vertexHeightSW , vertexHeightSE , vertexHeightNE , vertexHeightNW , mixLightness (hslBitsetOriginal , lightIntensitySW ), mixLightness (hslBitsetOriginal , lightIntensitySE ), mixLightness (hslBitsetOriginal , lightIntensityNE ), mixLightness (hslBitsetOriginal , lightIntensityNW ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensitySW ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensitySE ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensityNE ), MovedStatics .mixLightnessSigned (hslBitset , lightIntensityNW ), underlayMinimapColour , rgb );
550
556
} else
551
- scene .addTile (_plane , x , y , 0 , 0 , -1 , vertexHeightSW , vertexHeightSE , vertexHeightNE , vertexHeightNW , mixLightness (hslBitsetOriginal , lightIntensitySW ), mixLightness (hslBitsetOriginal , lightIntensitySE ), mixLightness (hslBitsetOriginal , lightIntensityNE ), mixLightness (hslBitsetOriginal , lightIntensityNW ), 0 , 0 , 0 , 0 , underlayMinimapColour , 0 );
557
+ this . scene .addTile (_plane , x , y , 0 , 0 , -1 , vertexHeightSW , vertexHeightSE , vertexHeightNE , vertexHeightNW , mixLightness (hslBitsetOriginal , lightIntensitySW ), mixLightness (hslBitsetOriginal , lightIntensitySE ), mixLightness (hslBitsetOriginal , lightIntensityNE ), mixLightness (hslBitsetOriginal , lightIntensityNW ), 0 , 0 , 0 , 0 , underlayMinimapColour , 0 );
552
558
}
553
559
}
554
560
}
555
561
}
556
562
}
557
563
for (int i_56_ = 1 ; i_56_ < 103 ; i_56_ ++) {
558
564
for (int i_57_ = 1 ; i_57_ < 103 ; i_57_ ++)
559
- scene .setDrawLevel (_plane , i_57_ , i_56_ , MovedStatics .getVisibilityPlaneFor (_plane , i_56_ , 0 , i_57_ ));
565
+ this . scene .setDrawLevel (_plane , i_57_ , i_56_ , MovedStatics .getVisibilityPlaneFor (_plane , i_56_ , 0 , i_57_ ));
560
566
}
561
567
tile_underlayids [_plane ] = null ;
562
568
tile_overlayids [_plane ] = null ;
563
569
tile_underlay_path [_plane ] = null ;
564
570
tile_overlay_rotation [_plane ] = null ;
565
571
tileShadowIntensity [_plane ] = null ;
566
572
}
567
- scene .buildModels (-50 , -10 , -50 );
573
+ this . scene .buildModels (-50 , -10 , -50 );
568
574
for (int i = 0 ; i < 104 ; i ++) {
569
575
for (int i_58_ = 0 ; i_58_ < 104 ; i_58_ ++) {
570
576
if ((MovedStatics .tile_flags [1 ][i ][i_58_ ] & 0x2 ) == 2 )
571
- scene .setTileBridge (i , i_58_ );
577
+ this . scene .setTileBridge (i , i_58_ );
572
578
}
573
579
}
574
580
int renderRule1 = 1 ;
@@ -613,7 +619,7 @@ else if(s > 255)
613
619
int i_72_ = 240 ;
614
620
int i_73_ = -i_72_ + tile_height [i_68_ ][x ][i_65_ ];
615
621
int i_74_ = tile_height [i_67_ ][x ][i_65_ ];
616
- Game . currentScene .createOccluder (plane , 1 , 128 * x , 128 * x , 128 * i_65_ , 128 + 128 * i_66_ , i_73_ , i_74_ );
622
+ this . scene .createOccluder (plane , 1 , 128 * x , 128 * x , 128 * i_65_ , 128 + 128 * i_66_ , i_73_ , i_74_ );
617
623
for (int i_75_ = i_67_ ; i_75_ <= i_68_ ; i_75_ ++) {
618
624
for (int i_76_ = i_65_ ; i_76_ <= i_66_ ; i_76_ ++)
619
625
tileCullingBitsets [i_75_ ][x ][i_76_ ] = BitUtils .bitWiseAND (tileCullingBitsets [i_75_ ][x ][i_76_ ], renderRule1 ^ 0xffffffff );
@@ -652,7 +658,7 @@ else if(s > 255)
652
658
int lowestOcclusionVertexHeight = tile_height [lowestOcclusionPlane ][lowestOcclusionX ][y ];
653
659
int highestOcclusionVertexHeightOffset = 240 ;
654
660
int highestOcclusionVertexHeight = tile_height [highestOcclusionPlane ][lowestOcclusionX ][y ] - highestOcclusionVertexHeightOffset ;
655
- Game . currentScene .createOccluder (plane , 2 , 128 * lowestOcclusionX , 128 * highestOcclusionX + 128 , 128 * y , y * 128 , highestOcclusionVertexHeight , lowestOcclusionVertexHeight );
661
+ this . scene .createOccluder (plane , 2 , 128 * lowestOcclusionX , 128 * highestOcclusionX + 128 , 128 * y , y * 128 , highestOcclusionVertexHeight , lowestOcclusionVertexHeight );
656
662
for (int occludedPlane = lowestOcclusionPlane ; highestOcclusionPlane >= occludedPlane ; occludedPlane ++) {
657
663
for (int occludedX = lowestOcclusionX ; occludedX <= highestOcclusionX ; occludedX ++)
658
664
tileCullingBitsets [occludedPlane ][occludedX ][y ] = BitUtils .bitWiseAND (tileCullingBitsets [occludedPlane ][occludedX ][y ], i_59_ ^ 0xffffffff );
@@ -688,7 +694,7 @@ else if(s > 255)
688
694
}
689
695
if ((-i_89_ + i_90_ + 1 ) * (1 + i_92_ - i_91_ ) >= 4 ) {
690
696
int i_95_ = tile_height [_plane ][i_89_ ][i_91_ ];
691
- Game . currentScene .createOccluder (plane , 4 , i_89_ * 128 , i_90_ * 128 + 128 , 128 * i_91_ , i_92_ * 128 + 128 , i_95_ , i_95_ );
697
+ this . scene .createOccluder (plane , 4 , i_89_ * 128 , i_90_ * 128 + 128 , 128 * i_91_ , i_92_ * 128 + 128 , i_95_ , i_95_ );
692
698
for (int i_96_ = i_89_ ; i_96_ <= i_90_ ; i_96_ ++) {
693
699
for (int i_97_ = i_91_ ; i_92_ >= i_97_ ; i_97_ ++)
694
700
tileCullingBitsets [_plane ][i_96_ ][i_97_ ] = BitUtils .bitWiseAND (tileCullingBitsets [_plane ][i_96_ ][i_97_ ], i_60_ ^ 0xffffffff );
@@ -770,7 +776,7 @@ private void method922(int x, int arg1, Buffer fileData, int y, int regionY, int
770
776
int opcode = fileData .getUnsignedByte ();
771
777
if (opcode == 0 ) {
772
778
if (level == 0 ) {
773
- tile_height [0 ][x ][y ] = -method888 (regionX + x + 932731 , regionY + 556238 + y ) * 8 ;
779
+ tile_height [0 ][x ][y ] = -getPerlinVertexHeight (regionX + x + 932731 , regionY + 556238 + y ) * 8 ;
774
780
} else {
775
781
tile_height [level ][x ][y ] = -240 + tile_height [level + -1 ][x ][y ];
776
782
}
@@ -811,8 +817,7 @@ private void method922(int x, int arg1, Buffer fileData, int y, int regionY, int
811
817
}
812
818
}
813
819
814
- public static void constructMapRegion (boolean generatedMap ) {
815
-
820
+ public void constructMapRegion (boolean generatedMap ) {
816
821
loadGeneratedMap = generatedMap ;
817
822
if (loadGeneratedMap ) {
818
823
int chunkLocalY = IncomingPackets .incomingPacketBuffer .getUnsignedShortBE ();
@@ -936,7 +941,7 @@ else if(lightness > 126)
936
941
return lightness + (hsl & 0xff80 );
937
942
}
938
943
939
- private void loadObjectBlock (int block_x , Scene scene , CollisionMap [] collisionMaps , byte [] block_data , int block_z ) {
944
+ private void loadObjectBlock (int block_x , CollisionMap [] collisionMaps , byte [] block_data , int block_z ) {
940
945
Buffer buffer = new Buffer (block_data );
941
946
int object_id = -1 ;
942
947
for (; ; ) {
@@ -965,13 +970,13 @@ private void loadObjectBlock(int block_x, Scene scene, CollisionMap[] collisionM
965
970
logic_y --;
966
971
if (logic_y >= 0 )
967
972
collisionMap = collisionMaps [logic_y ];
968
- addObject (object_id , object_x , object_z , tile_y , object_orientation , object_type , scene , collisionMap );
973
+ addObject (object_id , object_x , object_z , tile_y , object_orientation , object_type , collisionMap );
969
974
}
970
975
}
971
976
}
972
977
}
973
978
974
- public void addObject (int objectId , int localX , int localY , int plane , int face , int type , Scene scene , CollisionMap collisionMap ) {
979
+ public void addObject (int objectId , int localX , int localY , int plane , int face , int type , CollisionMap collisionMap ) {
975
980
if (!VertexNormal .lowMemory || (0x2 & MovedStatics .tile_flags [0 ][localX ][localY ]) != 0 || (0x10 & MovedStatics .tile_flags [plane ][localX ][localY ]) == 0 && MovedStatics .onBuildTimePlane == MovedStatics .getVisibilityPlaneFor (plane , localY , 0 , localX )) {
976
981
if (lowestPlane > plane )
977
982
lowestPlane = plane ;
@@ -1238,7 +1243,7 @@ else if(face == 3)
1238
1243
1239
1244
}
1240
1245
1241
- public static boolean method840 (byte [] arg1 , int arg2 , int arg3 ) {
1246
+ private boolean method840 (byte [] arg1 , int arg2 , int arg3 ) {
1242
1247
boolean bool = true ;
1243
1248
Buffer class40_sub1 = new Buffer (arg1 );
1244
1249
int i = -1 ;
@@ -1435,7 +1440,7 @@ public static void method789(int chunkLocalX, int chunkY, int chunkX, int chunkL
1435
1440
}
1436
1441
}
1437
1442
1438
- public static int method888 (int x , int y ) {
1443
+ private static int getPerlinVertexHeight (int x , int y ) {
1439
1444
int vertexHeight = -128 + perlinNoise (x + 45365 , 91923 + y , 4 ) - (-(perlinNoise (x + 10294 , 37821 + y , 2 ) - 128 >> 1 ) + -(-128 + perlinNoise (x , y , 1 ) >> 2 ));
1440
1445
vertexHeight = 35 + (int ) (0.3 * (double ) vertexHeight );
1441
1446
@@ -1448,21 +1453,21 @@ public static int method888(int x, int y) {
1448
1453
return vertexHeight ;
1449
1454
}
1450
1455
1451
- public static int interpolateForPerlin (int arg0 , int arg1 , int arg2 , boolean arg3 , int arg4 ) {
1456
+ private static int interpolateForPerlin (int arg0 , int arg1 , int arg2 , boolean arg3 , int arg4 ) {
1452
1457
if (!arg3 )
1453
1458
return -109 ;
1454
1459
int i = 65536 + -Rasterizer3D .cosinetable [1024 * arg4 / arg1 ] >> 1 ;
1455
1460
return ((65536 + -i ) * arg0 >> 16 ) + (arg2 * i >> 16 );
1456
1461
}
1457
1462
1458
- public static int randomNoiseWeightedSum (int arg1 , int arg2 ) {
1463
+ private static int randomNoiseWeightedSum (int arg1 , int arg2 ) {
1459
1464
int i = randomNoise (-1 + arg1 , -1 + arg2 ) + randomNoise (1 + arg1 , arg2 - 1 ) + randomNoise (-1 + arg1 , 1 + arg2 ) + randomNoise (1 + arg1 , arg2 + 1 );
1460
1465
int i_126_ = randomNoise (arg1 - 1 , arg2 ) + randomNoise (arg1 + 1 , arg2 ) - (-randomNoise (arg1 , arg2 - 1 ) + -randomNoise (arg1 , 1 + arg2 ));
1461
1466
int i_127_ = randomNoise (arg1 , arg2 );
1462
1467
return i / 16 - (-(i_126_ / 8 ) - i_127_ / 4 );
1463
1468
}
1464
1469
1465
- public static int perlinNoise (int x , int y , int scale ) {
1470
+ private static int perlinNoise (int x , int y , int scale ) {
1466
1471
int muX = x & -1 + scale ;
1467
1472
int scaledY = y / scale ;
1468
1473
int muY = scale - 1 & y ;
@@ -1476,7 +1481,7 @@ public static int perlinNoise(int x, int y, int scale) {
1476
1481
return interpolateForPerlin (i1 , scale , i2 , true , muY );
1477
1482
}
1478
1483
1479
- public static int randomNoise (int x , int y ) {
1484
+ private static int randomNoise (int x , int y ) {
1480
1485
int i = 57 * y + x ;
1481
1486
i ^= i << 13 ;
1482
1487
int i_2_ = 1376312589 + (i * i * 15731 + 789221 ) * i & 0x7fffffff ;
0 commit comments