52
52
import java .net .InetAddress ;
53
53
import java .net .Socket ;
54
54
55
- public class Main extends GameShell {
55
+ public class Game {
56
56
57
57
/**
58
58
* The codec currently in use to encode and decode packets.
@@ -116,6 +116,8 @@ public static int getMinimapRotation() {
116
116
public static int currentPort ;
117
117
private static int drawCount = 0 ;
118
118
119
+ private GameErrorHandler errorHandler ;
120
+
119
121
/**
120
122
* This method is used to draw interfaces on the client. It uses the parent of -1,
121
123
* which means it will render the widget on the top most level. It takes in a widget ID
@@ -673,67 +675,6 @@ else if (MovedStatics.anInt2613 > 256)
673
675
}
674
676
}
675
677
676
- public static void main (String [] args ) {
677
- Configuration .read ();
678
- Native .username = Configuration .getUsername ();
679
- Native .password = Configuration .getPassword ();
680
- String [] params = new String []{"1" , "live" , "live" , "highmem" , "members" };
681
- if (args .length != 0 ) {
682
- params = args ;
683
- }
684
- try {
685
- if (params .length != 5 )
686
- printHelp ();
687
-
688
- Player .worldId = Integer .parseInt (params [0 ]);
689
-
690
- // Location argument (to set server IP based on JMod location?)
691
- if (params [1 ].equals ("live" )) {
692
- modewhere = 0 ;
693
- } else if (params [1 ].equals ("office" )) {
694
- modewhere = 1 ;
695
- } else if (params [1 ].equals ("local" )) {
696
- modewhere = 2 ;
697
- } else {
698
- printHelp ();
699
- }
700
-
701
- if (params [2 ].equals ("live" ))
702
- modewhat = 0 ;
703
- else if (!params [2 ].equals ("rc" )) {
704
- if (params [2 ].equals ("wip" ))
705
- modewhat = 2 ;
706
- else
707
- printHelp ();
708
- } else
709
- modewhat = 1 ;
710
-
711
- // Memory argument
712
- if (params [3 ].equals ("lowmem" )) {
713
- Class59 .setLowMemory ();
714
- } else if (params [3 ].equals ("highmem" )) {
715
- MovedStatics .setHighMemory ();
716
- } else {
717
- printHelp ();
718
- }
719
-
720
- // Player membership argument
721
- if (params [4 ].equals ("free" )) {
722
- MovedStatics .membersWorld = false ;
723
- } else if (params [4 ].equals ("members" )) {
724
- MovedStatics .membersWorld = true ;
725
- } else {
726
- printHelp ();
727
- }
728
-
729
- Main main = new Main ();
730
- main .openClientApplet ("client435" , 13 , 32 + modewhat , InetAddress .getByName (Configuration .SERVER_ADDRESS ), 435 );
731
-
732
- } catch (Exception exception ) {
733
- exception .printStackTrace ();
734
- }
735
- }
736
-
737
678
738
679
public static void setConfigToDefaults () {
739
680
aLong1203 = 0L ;
@@ -764,7 +705,7 @@ public static void setConfigToDefaults() {
764
705
SoundSystem .reset ();
765
706
widgetSelected = 0 ;
766
707
// TODO is this necessary? or should it be removed alongside other randomisation
767
- Main .playerCamera .setYaw (0x7ff & -10 + (int ) (20.0 * Math .random ()));
708
+ Game .playerCamera .setYaw (0x7ff & -10 + (int ) (20.0 * Math .random ()));
768
709
Minimap .minimapState = 0 ;
769
710
Player .localPlayerCount = 0 ;
770
711
Class55 .destinationY = 0 ;
@@ -825,7 +766,7 @@ public static void method353() {
825
766
MovedStatics .renderProjectiles ();
826
767
MovedStatics .renderSpotAnims ();
827
768
if (!Player .cutsceneActive ) {
828
- int pitch = Main .playerCamera .getPitch ();
769
+ int pitch = Game .playerCamera .getPitch ();
829
770
if (SceneCamera .cameraTerrainMinScaledPitch / 256 > pitch ) {
830
771
pitch = SceneCamera .cameraTerrainMinScaledPitch / 256 ;
831
772
}
@@ -834,7 +775,7 @@ public static void method353() {
834
775
pitch = 128 + SceneCamera .customCameraAmplitude [4 ];
835
776
}
836
777
837
- Main .playerCamera .setPitch (pitch );
778
+ Game .playerCamera .setPitch (pitch );
838
779
}
839
780
840
781
int i ;
@@ -916,7 +857,7 @@ public static void method353() {
916
857
* Get the currently active camera.
917
858
*/
918
859
public static Camera getActiveCamera () {
919
- return Player .cutsceneActive ? Main .cutsceneCamera : Main .playerCamera ;
860
+ return Player .cutsceneActive ? Game .cutsceneCamera : Game .playerCamera ;
920
861
}
921
862
922
863
public static void method357 (CacheArchive arg0 , CacheArchive arg2 ) {
@@ -1209,7 +1150,7 @@ public static void method164() {
1209
1150
1210
1151
public static void moveTowardsTarget () {
1211
1152
// TODO (James) this moves the cutscene camera towards its target, we should move this into the CutsceneCamera class
1212
- CutsceneCamera camera = Main .cutsceneCamera ;
1153
+ CutsceneCamera camera = Game .cutsceneCamera ;
1213
1154
1214
1155
int i = camera .getMoveTo ().y ;
1215
1156
int i_3_ = camera .getMoveTo ().x ;
@@ -1428,8 +1369,8 @@ else if(x > 764)
1428
1369
InteractiveObject .anInt487 = 20 ;
1429
1370
MovedStatics .aBoolean565 = false ;
1430
1371
SceneCluster .packetBuffer .putPacket (58 );
1431
- SceneCluster .packetBuffer .putShortBE (Main .playerCamera .getYaw ());
1432
- SceneCluster .packetBuffer .putShortBE (Main .playerCamera .getPitch ());
1372
+ SceneCluster .packetBuffer .putShortBE (Game .playerCamera .getYaw ());
1373
+ SceneCluster .packetBuffer .putShortBE (Game .playerCamera .getPitch ());
1433
1374
}
1434
1375
if (MovedStatics .aBoolean571 && !aBoolean1735 ) {
1435
1376
aBoolean1735 = true ;
@@ -2061,7 +2002,7 @@ public void updateStatusText() {
2061
2002
if (MovedStatics .aBoolean1575 ) {
2062
2003
MovedStatics .method311 (MouseHandler .gameCanvas );
2063
2004
Class55 .method965 (32 , MouseHandler .gameCanvas );
2064
- this .setCanvas ();
2005
+ // this.setCanvas();
2065
2006
GameInterface .method642 (MouseHandler .gameCanvas );
2066
2007
RSRuntimeException .method1056 (MouseHandler .gameCanvas );
2067
2008
}
@@ -2170,7 +2111,19 @@ public void connectUpdateServer() {
2170
2111
}
2171
2112
}
2172
2113
2173
- public void method24 () {
2114
+ public void setErrorHandler (GameErrorHandler errorHandler ) {
2115
+ this .errorHandler = errorHandler ;
2116
+ }
2117
+
2118
+ private void openErrorPage (String error ) {
2119
+ if (this .errorHandler == null ) {
2120
+ return ;
2121
+ }
2122
+
2123
+ this .errorHandler .handleGameError (error );
2124
+ }
2125
+
2126
+ public void close () {
2174
2127
if (mouseCapturer != null )
2175
2128
mouseCapturer .aBoolean913 = false ;
2176
2129
mouseCapturer = null ;
0 commit comments