Advertisement
Guest User

RSApplet.java

a guest
May 23rd, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.41 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3)
  4.  
  5. import java.applet.Applet;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Font;
  9. import java.awt.FontMetrics;
  10. import java.awt.Graphics;
  11. import java.awt.event.FocusEvent;
  12. import java.awt.event.FocusListener;
  13. import java.awt.event.KeyEvent;
  14. import java.awt.event.KeyListener;
  15. import java.awt.event.MouseEvent;
  16. import java.awt.event.MouseListener;
  17. import java.awt.event.MouseMotionListener;
  18. import java.awt.event.WindowEvent;
  19. import java.awt.event.WindowListener;
  20.  
  21. @SuppressWarnings("serial")
  22. public class RSApplet extends Applet implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener {
  23.  
  24.     final void createClientFrame(int i, int j) {
  25.         myWidth = j;
  26.         myHeight = i;
  27.         gameFrame = new RSFrame(this, myWidth, myHeight);
  28.         graphics = getGameComponent().getGraphics();
  29.         fullGameScreen = new RSImageProducer(myWidth, myHeight, getGameComponent());
  30.         startRunnable(this, 1);
  31.     }
  32.  
  33.     final void initClientFrame(int i, int j) {
  34.         myWidth = j;
  35.         myHeight = i;
  36.         graphics = getGameComponent().getGraphics();
  37.         fullGameScreen = new RSImageProducer(myWidth, myHeight, getGameComponent());
  38.         startRunnable(this, 1);
  39.     }
  40.  
  41.     @Override
  42.     public void run() {
  43.         getGameComponent().addMouseListener(this);
  44.         getGameComponent().addMouseMotionListener(this);
  45.         getGameComponent().addKeyListener(this);
  46.         getGameComponent().addFocusListener(this);
  47.         if (gameFrame != null) {
  48.             gameFrame.addWindowListener(this);
  49.         }
  50.         drawLoadingText(0, "Loading...");
  51.         startUp();
  52.         int i = 0;
  53.         int j = 256;
  54.         int k = 1;
  55.         int i1 = 0;
  56.         int j1 = 0;
  57.         for (int k1 = 0; k1 < 10; k1++) {
  58.             aLongArray7[k1] = System.currentTimeMillis();
  59.         }
  60.  
  61.         System.currentTimeMillis();
  62.         while (anInt4 >= 0) {
  63.             if (anInt4 > 0) {
  64.                 anInt4--;
  65.                 if (anInt4 == 0) {
  66.                     exit();
  67.                     return;
  68.                 }
  69.             }
  70.             int i2 = j;
  71.             int j2 = k;
  72.             j = 300;
  73.             k = 1;
  74.             long l1 = System.currentTimeMillis();
  75.             if (aLongArray7[i] == 0L) {
  76.                 j = i2;
  77.                 k = j2;
  78.             } else if (l1 > aLongArray7[i]) {
  79.                 j = (int) (2560 * delayTime / (l1 - aLongArray7[i]));
  80.             }
  81.             if (j < 25) {
  82.                 j = 25;
  83.             }
  84.             if (j > 256) {
  85.                 j = 256;
  86.                 k = (int) (delayTime - (l1 - aLongArray7[i]) / 10L);
  87.             }
  88.             if (k > delayTime) {
  89.                 k = delayTime;
  90.             }
  91.             aLongArray7[i] = l1;
  92.             i = (i + 1) % 10;
  93.             if (k > 1) {
  94.                 for (int k2 = 0; k2 < 10; k2++) {
  95.                     if (aLongArray7[k2] != 0L) {
  96.                         aLongArray7[k2] += k;
  97.                     }
  98.                 }
  99.  
  100.             }
  101.             if (k < minDelay) {
  102.                 k = minDelay;
  103.             }
  104.             try {
  105.                 Thread.sleep(k);
  106.             } catch (InterruptedException _ex) {
  107.                 j1++;
  108.             }
  109.             for (; i1 < 256; i1 += j) {
  110.                 clickMode3 = clickMode1;
  111.                 saveClickX = clickX;
  112.                 saveClickY = clickY;
  113.                 aLong29 = clickTime;
  114.                 clickMode1 = 0;
  115.                 processGameLoop();
  116.                 readIndex = writeIndex;
  117.             }
  118.  
  119.             i1 &= 0xff;
  120.             if (delayTime > 0) {
  121.                 fps = 1000 * j / (delayTime * 256);
  122.             }
  123.             processDrawing();
  124.             if (shouldDebug) {
  125.                 System.out.println("ntime:" + l1);
  126.                 for (int l2 = 0; l2 < 10; l2++) {
  127.                     int i3 = (i - l2 - 1 + 20) % 10;
  128.                     System.out.println("otim" + i3 + ":" + aLongArray7[i3]);
  129.                 }
  130.  
  131.                 System.out.println("fps:" + fps + " ratio:" + j + " count:" + i1);
  132.                 System.out.println("del:" + k + " deltime:" + delayTime + " mindel:" + minDelay);
  133.                 System.out.println("intex:" + j1 + " opos:" + i);
  134.                 shouldDebug = false;
  135.                 j1 = 0;
  136.             }
  137.         }
  138.         if (anInt4 == -1) {
  139.             exit();
  140.         }
  141.     }
  142.  
  143.     private void exit() {
  144.         anInt4 = -2;
  145.         cleanUpForQuit();
  146.         if (gameFrame != null) {
  147.             try {
  148.                 Thread.sleep(1000L);
  149.             } catch (Exception _ex) {
  150.             }
  151.             try {
  152.                 System.exit(0);
  153.             } catch (Throwable _ex) {
  154.             }
  155.         }
  156.     }
  157.  
  158.     final void method4(int i) {
  159.         delayTime = 1000 / i;
  160.     }
  161.  
  162.     @Override
  163.     public final void start() {
  164.         if (anInt4 >= 0) {
  165.             anInt4 = 0;
  166.         }
  167.     }
  168.  
  169.     @Override
  170.     public final void stop() {
  171.         if (anInt4 >= 0) {
  172.             anInt4 = 4000 / delayTime;
  173.         }
  174.     }
  175.  
  176.     @Override
  177.     public final void destroy() {
  178.         anInt4 = -1;
  179.         try {
  180.             Thread.sleep(5000L);
  181.         } catch (Exception _ex) {
  182.         }
  183.         if (anInt4 == -1) {
  184.             exit();
  185.         }
  186.     }
  187.  
  188.     @Override
  189.     public final void update(Graphics g) {
  190.         if (graphics == null) {
  191.             graphics = g;
  192.         }
  193.         shouldClearScreen = true;
  194.         raiseWelcomeScreen();
  195.     }
  196.  
  197.     @Override
  198.     public final void paint(Graphics g) {
  199.         if (graphics == null) {
  200.             graphics = g;
  201.         }
  202.         shouldClearScreen = true;
  203.         raiseWelcomeScreen();
  204.     }
  205.     public boolean mouseWheelDown;
  206.     int type = e.getButton();
  207.     @Override
  208.     public final void mousePressed(MouseEvent mouseevent) {
  209.         int i = mouseevent.getX();
  210.         int j = mouseevent.getY();
  211.         if (gameFrame != null) {
  212.             i -= 4;
  213.             j -= 22;
  214.         }
  215.         idleTime = 0;
  216.         clickX = i;
  217.         clickY = j;
  218.         clickTime = System.currentTimeMillis();
  219.         if (type == 2) {
  220.             mouseWheelDown = true;
  221.             mouseWheelX = x;
  222.             mouseWheelY = y;
  223.             return;
  224.         }
  225.         if (mouseevent.isMetaDown()) {
  226.             clickMode1 = 2;
  227.             clickMode2 = 2;
  228.         } else {
  229.             clickMode1 = 1;
  230.             clickMode2 = 1;
  231.         }
  232.     }
  233.  
  234.     @Override
  235.     public final void mouseReleased(MouseEvent mouseevent) {
  236.         clickType = RELEASED;
  237.         mouseWheelDown = false;
  238.         idleTime = 0;
  239.         clickMode2 = 0;
  240.     }
  241.  
  242.     @Override
  243.     public final void mouseClicked(MouseEvent mouseevent) {
  244.     }
  245.  
  246.     @Override
  247.     public final void mouseEntered(MouseEvent mouseevent) {
  248.     }
  249.  
  250.     @Override
  251.     public final void mouseExited(MouseEvent mouseevent) {
  252.         idleTime = 0;
  253.         mouseX = -1;
  254.         mouseY = -1;
  255.     }
  256.  
  257.     @Override
  258.     public final void mouseDragged(MouseEvent mouseevent) {
  259.         public int mouseWheelX;
  260.         public int mouseWheelY;
  261.         public final void mouseDragged(MouseEvent e) {
  262.             int x = e.getX();
  263.             int y = e.getY();
  264.             if(gameFrame != null) {
  265.                 Insets insets = gameFrame.getInsets();
  266.                 x -= insets.left;//4
  267.                 y -= insets.top;//22
  268.             }
  269.             if (mouseWheelDown) {
  270.                 y = mouseWheelX - e.getX();
  271.                 int k = mouseWheelY - e.getY();
  272.                 mouseWheelDragged(y, -k);
  273.                 mouseWheelX = e.getX();
  274.                 mouseWheelY = e.getY();
  275.                 return;
  276.             }
  277.             idleTime = 0;
  278.             mouseX = x;
  279.             mouseY = y;
  280.             clickType = DRAG;
  281.         }
  282.         void mouseWheelDragged(int param1, int param2) {
  283.  
  284.         }
  285.  
  286.     @Override
  287.     public final void mouseMoved(MouseEvent mouseevent) {
  288.         int i = mouseevent.getX();
  289.         int j = mouseevent.getY();
  290.         if (gameFrame != null) {
  291.             i -= 4;
  292.             j -= 22;
  293.         }
  294.         idleTime = 0;
  295.         mouseX = i;
  296.         mouseY = j;
  297.     }
  298.  
  299.     @Override
  300.     public final void keyPressed(KeyEvent keyevent) {
  301.         idleTime = 0;
  302.         int i = keyevent.getKeyCode();
  303.         int j = keyevent.getKeyChar();
  304.         if (j < 30) {
  305.             j = 0;
  306.         }
  307.         if (i == 37) {
  308.             j = 1;
  309.         }
  310.         if (i == 39) {
  311.             j = 2;
  312.         }
  313.         if (i == 38) {
  314.             j = 3;
  315.         }
  316.         if (i == 40) {
  317.             j = 4;
  318.         }
  319.         if (i == 17) {
  320.             j = 5;
  321.         }
  322.         if (i == 8) {
  323.             j = 8;
  324.         }
  325.         if (i == 127) {
  326.             j = 8;
  327.         }
  328.         if (i == 9) {
  329.             j = 9;
  330.         }
  331.         if (i == 10) {
  332.             j = 10;
  333.         }
  334.         if (i >= 112 && i <= 123) {
  335.             j = 1008 + i - 112;
  336.         }
  337.         if (i == 36) {
  338.             j = 1000;
  339.         }
  340.         if (i == 35) {
  341.             j = 1001;
  342.         }
  343.         if (i == 33) {
  344.             j = 1002;
  345.         }
  346.         if (i == 34) {
  347.             j = 1003;
  348.         }
  349.         if (j > 0 && j < 128) {
  350.             keyArray[j] = 1;
  351.         }
  352.         if (j > 4) {
  353.             charQueue[writeIndex] = j;
  354.             writeIndex = writeIndex + 1 & 0x7f;
  355.         }
  356.     }
  357.  
  358.     @Override
  359.     public final void keyReleased(KeyEvent keyevent) {
  360.         idleTime = 0;
  361.         int i = keyevent.getKeyCode();
  362.         char c = keyevent.getKeyChar();
  363.         if (c < '\036') {
  364.             c = '\0';
  365.         }
  366.         if (i == 37) {
  367.             c = '\001';
  368.         }
  369.         if (i == 39) {
  370.             c = '\002';
  371.         }
  372.         if (i == 38) {
  373.             c = '\003';
  374.         }
  375.         if (i == 40) {
  376.             c = '\004';
  377.         }
  378.         if (i == 17) {
  379.             c = '\005';
  380.         }
  381.         if (i == 8) {
  382.             c = '\b';
  383.         }
  384.         if (i == 127) {
  385.             c = '\b';
  386.         }
  387.         if (i == 9) {
  388.             c = '\t';
  389.         }
  390.         if (i == 10) {
  391.             c = '\n';
  392.         }
  393.         if (c > 0 && c < '\200') {
  394.             keyArray[c] = 0;
  395.         }
  396.     }
  397.  
  398.     @Override
  399.     public final void keyTyped(KeyEvent keyevent) {
  400.     }
  401.  
  402.     final int readChar(int dummy) {
  403.         while (dummy >= 0) {
  404.             for (int j = 1; j > 0; j++) {
  405.                 ;
  406.             }
  407.         }
  408.         int k = -1;
  409.         if (writeIndex != readIndex) {
  410.             k = charQueue[readIndex];
  411.             readIndex = readIndex + 1 & 0x7f;
  412.         }
  413.         return k;
  414.     }
  415.  
  416.     @Override
  417.     public final void focusGained(FocusEvent focusevent) {
  418.         awtFocus = true;
  419.         shouldClearScreen = true;
  420.         raiseWelcomeScreen();
  421.     }
  422.  
  423.     @Override
  424.     public final void focusLost(FocusEvent focusevent) {
  425.         awtFocus = false;
  426.         for (int i = 0; i < 128; i++) {
  427.             keyArray[i] = 0;
  428.         }
  429.  
  430.     }
  431.  
  432.     @Override
  433.     public final void windowActivated(WindowEvent windowevent) {
  434.     }
  435.  
  436.     @Override
  437.     public final void windowClosed(WindowEvent windowevent) {
  438.     }
  439.  
  440.     @Override
  441.     public final void windowClosing(WindowEvent windowevent) {
  442.         destroy();
  443.     }
  444.  
  445.     @Override
  446.     public final void windowDeactivated(WindowEvent windowevent) {
  447.     }
  448.  
  449.     @Override
  450.     public final void windowDeiconified(WindowEvent windowevent) {
  451.     }
  452.  
  453.     @Override
  454.     public final void windowIconified(WindowEvent windowevent) {
  455.     }
  456.  
  457.     @Override
  458.     public final void windowOpened(WindowEvent windowevent) {
  459.     }
  460.  
  461.     void startUp() {
  462.     }
  463.  
  464.     void processGameLoop() {
  465.     }
  466.  
  467.     void cleanUpForQuit() {
  468.     }
  469.  
  470.     void processDrawing() {
  471.     }
  472.  
  473.     void raiseWelcomeScreen() {
  474.     }
  475.  
  476.     Component getGameComponent() {
  477.         if (gameFrame != null) {
  478.             return gameFrame;
  479.         } else {
  480.             return this;
  481.         }
  482.     }
  483.  
  484.     public void startRunnable(Runnable runnable, int priority) {
  485.         Thread thread = new Thread(runnable);
  486.         thread.start();
  487.         thread.setPriority(priority);
  488.     }
  489.  
  490.     void drawLoadingText(int i, String s) {
  491.         while (graphics == null) {
  492.             graphics = getGameComponent().getGraphics();
  493.             try {
  494.                 getGameComponent().repaint();
  495.             } catch (Exception _ex) {
  496.             }
  497.             try {
  498.                 Thread.sleep(1000L);
  499.             } catch (Exception _ex) {
  500.             }
  501.         }
  502.         Font font = new Font("Helvetica", 1, 13);
  503.         FontMetrics fontmetrics = getGameComponent().getFontMetrics(font);
  504.         Font font1 = new Font("Helvetica", 0, 13);
  505.         getGameComponent().getFontMetrics(font1);
  506.         if (shouldClearScreen) {
  507.             graphics.setColor(Color.black);
  508.             graphics.fillRect(0, 0, myWidth, myHeight);
  509.             shouldClearScreen = false;
  510.         }
  511.         Color color = new Color(140, 17, 17);
  512.         int j = myHeight / 2 - 18;
  513.         graphics.setColor(color);
  514.         graphics.drawRect(myWidth / 2 - 152, j, 304, 34);
  515.         graphics.fillRect(myWidth / 2 - 150, j + 2, i * 3, 30);
  516.         graphics.setColor(Color.black);
  517.         graphics.fillRect(myWidth / 2 - 150 + i * 3, j + 2, 300 - i * 3, 30);
  518.         graphics.setFont(font);
  519.         graphics.setColor(Color.white);
  520.         graphics.drawString(s, (myWidth - fontmetrics.stringWidth(s)) / 2, j + 22);
  521.     }
  522.  
  523.     RSApplet() {
  524.         delayTime = 20;
  525.         minDelay = 1;
  526.         aLongArray7 = new long[10];
  527.         shouldDebug = false;
  528.         shouldClearScreen = true;
  529.         awtFocus = true;
  530.         keyArray = new int[128];
  531.         charQueue = new int[128];
  532.     }
  533.  
  534.     private int anInt4;
  535.     private int delayTime;
  536.     int minDelay;
  537.     private final long[] aLongArray7;
  538.     int fps;
  539.     boolean shouldDebug;
  540.     int myWidth;
  541.     int myHeight;
  542.     Graphics graphics;
  543.     RSImageProducer fullGameScreen;
  544.     RSFrame gameFrame;
  545.     private boolean shouldClearScreen;
  546.     boolean awtFocus;
  547.     int idleTime;
  548.     int clickMode2;
  549.     public int mouseX;
  550.     public int mouseY;
  551.     private int clickMode1;
  552.     private int clickX;
  553.     private int clickY;
  554.     private long clickTime;
  555.     int clickMode3;
  556.     int saveClickX;
  557.     int saveClickY;
  558.     long aLong29;
  559.     final int[] keyArray;
  560.     private final int[] charQueue;
  561.     private int readIndex;
  562.     private int writeIndex;
  563.     public static int anInt34;
  564. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement