Преобразуване(Компилиране)

kzteam

Registered
Код:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov. 
// Jad home page: http://kpdus.tripod.com/jad.html 
// Decompiler options: packimports(3) 
// Source File Name:   StartServer.java 

import java.io.*; 
import java.net.*; 
import java.util.*; 

public class StartServer 
{ 

    public static void broadcast(String s) 
    { 
        for(int i = 0; i < maxusers; i++) 
            if(info[i] != null) 
            { 
                info[i].send("14,Admin :: " + s); 
                info[i].send("13,Admin :: " + s); 
            } 

    } 

    public static void setup() 
    { 
        System.out.println("Rillafunkaspora (v " + version + ") server started"); 
        Config.setupLogStreams(); 
        RemoteAdmin.UpdateVars(); 
        for(int i = 0; i < logIPs.size(); i++) 
        { 
            LogReason l = (LogReason)logIPs.elementAt(i); 
            if(l.sIP != null) 
                System.out.println(l.sIP + " " + l.bWholeWord); 
            else 
                System.out.println(l.sCharName + " " + l.bWholeWord); 
        } 

        for(int i = 0; i < logCharNames.size(); i++) 
        { 
            LogReason l = (LogReason)logCharNames.elementAt(i); 
            if(l.sIP != null) 
                System.out.println(l.sIP + " " + l.bWholeWord); 
            else 
                System.out.println(l.sCharName + " " + l.bWholeWord); 
        } 

        System.out.print("Connecting to config database..."); 
        DatabaseWrapper.SetSource("DDiasDb.mdb"); 
        DatabaseWrapper.InitConnection(); 
        AiDatabaseWrapper.SetSource("AiDb.mdb"); 
        AiDatabaseWrapper.InitConnection(); 
        System.out.println("Done"); 
        System.out.print("Database consistency checking..."); 
        System.out.println("Done"); 
        System.out.print("Initialising ship names..."); 
        DataLoader.LoadMakeNames(); 
        DataLoader.LoadClassNames(); 
        System.out.println("Done"); 
        System.out.print("Initialising gun db..."); 
        DataLoader.LoadGunDb(); 
        nullGun = new Gun(); 
        nullGun.id = -1; 
        nullGun.name = ""; 
        nullGun.acc = 0; 
        nullGun.dmg = 0; 
        nullGun.cost = 0; 
        nullGun.iMakeNr = 0; 
        nullGun.rof = 0; 
        nullGun.iDamageType = 1; 
        System.out.println("Done"); 
        System.out.print("Initialising missile db..."); 
        DataLoader.LoadMissileDb(); 
        nullMissile = new Missile(); 
        nullMissile.id = -1; 
        System.out.println("Done"); 
        System.out.print("Initialising equipment db..."); 
        DataLoader.LoadEquipmentDb(); 
        nullEquip = new Equipment(); 
        nullEquip.iId = -1; 
        nullEquip.iIncreasement = 0; 
        nullEquip.sMakeName = "MK1"; 
        nullEquip.sName = ""; 
        System.out.println("Done"); 
        System.out.print("Initialising ship db..."); 
        DataLoader.LoadShipDb(); 
        System.out.println("Done"); 
        for(int i = 0; i < 5; i++) 
        { 
            for(int j = 0; j < 6; j++) 
                defaultRights[i][j] = false; 

        } 

        defaultRights[1][5] = true; 
        defaultRanks[0] = "Follower"; 
        defaultRanks[1] = "Soldier"; 
        defaultRanks[2] = "Captain"; 
        defaultRanks[3] = "Commander"; 
        defaultRanks[4] = "Admiral"; 
        defaultRanks[5] = "Founder"; 
        System.out.print("Initialising guild db..."); 
        DataLoader.LoadGuildDb(); 
        System.out.println("Done"); 
        System.out.print("Initialising bars..."); 
        bar = new Bar(); 
        bar.name = "Diaspora Bar"; 
        System.out.println("Done"); 
        System.out.print("Initialising nodes and planets..."); 
        DataLoader.LoadMap(); 
        trade = new TradePriceUpdater(); 
        trade.start(); 
        System.out.println("Done"); 
        System.out.println("Starting server listen engine (port 10000)"); 
        try 
        { 
            DataLoader.InitAIHashtables(); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
    } 

    public static boolean checkHD(String hd) 
    { 
        String s = hd; 
        System.out.println(s); 
        for(int i = 0; i < bannedHDs.size(); i++) 
            if(s.indexOf((String)bannedHDs.elementAt(i) + "|") != -1) 
                return false; 

        return true; 
    } 

    public static synchronized int getnextcid() 
    { 
        for(int i = 1; i < maxusers; i++) 
            if(info[i] == null) 
            { 
                info[i] = new Info(); 
                numusers++; 
                return i; 
            } 

        return -1; 
    } 

    public static void InitSat(int zone, int n, int lvl) 
    { 
        node[zone][n].sat = new Info(true); 
        node[zone][n].sat.satlvl = lvl; 
        node[zone][n].sat.satEngageList = new Vector(); 
        node[zone][n].sat.name = "satellite"; 
        node[zone][n].sat.bIsSat = true; 
        node[zone][n].sat.basehull = getsathull(node[zone][n].sat.satlvl); 
        node[zone][n].sat.maxhull = node[zone][n].sat.getmaxhull(node[zone][n].sat.basehull, 0); 
        node[zone][n].sat.hull = node[zone][n].sat.maxhull; 
        node[zone][n].sat.shield = 95; 
        node[zone][n].sat.numguns = getsatnumguns(node[zone][n].sat.satlvl); 
        node[zone][n].sat.guntype = gunTypes[19]; 
        node[zone][n].sat.landed = false; 
        node[zone][n].sat.gunThread = new GunFireThread(node[zone][n].sat, null); 
    } 

    public StartServer() 
    { 
    } 

    public static boolean NoAsciiInString(String s) 
    { 
        byte b[] = s.getBytes(); 
        for(int i = 0; i < b.length; i++) 
            if(b[i] < 32 || b[i] > 126) 
                return false; 

        return true; 
    } 

    public static void printallclientinfo() 
    { 
        for(int i = 1; i <= numusers; i++) 
            if(info[i] != null) 
                System.out.println("Client" + i + " LP: " + info[i].login + "/" + info[i].pass); 

    } 

    public static int gunfire(int hull, int evasion, int acc, int gundmg, int numguns) 
    { 
        Random rnd = new Random(); 
        double d = rnd.nextDouble(); 
        double e = (double)evasion / 100D; 
        double f = (double)acc / 100D; 
        if(d < e) 
            return hull; 
        if(d > f) 
        { 
            return hull; 
        } else 
        { 
            double shieldmod = 1.0D; 
            int dmg = (int)(damageMod * shieldmod * (double)gundmg * (double)numguns); 
            int newhull = hull - dmg; 
            return newhull; 
        } 
    } 

    public static int findname(String s) 
    { 
        for(int i = 0; i < info.length; i++) 
            if(info[i] != null) 
                try 
                { 
                    if(info[i].name != null && info[i].name.equalsIgnoreCase(s)) 
                        return i; 
                } 
                catch(Exception e) 
                { 
                    Config.logerror(e, "findname"); 
                } 

        return -1; 
    } 

    public static int getsathull(int i) 
    { 
        return i * 10000; 
    } 

    public static boolean checkIP(InetAddress I) 
    { 
        String s = I.toString().toLowerCase(); 
        for(int i = 0; i < bannedIPs.size(); i++) 
            if(s.indexOf((String)bannedIPs.elementAt(i)) != -1) 
                return false; 

        return true; 
    } 

    public static int getsatnumguns(int i) 
    { 
        return i + 7; 
    } 

    public static String getValidMsg(String s) 
    { 
        if(s.length() < 23) 
            return s; 
        String s1 = s + " "; 
        s = ""; 
        while(s1.indexOf(" ") != -1) 
        { 
            int i = s1.indexOf(" "); 
            if(i > 23) 
            { 
                s = s + s1.substring(0, 23) + " "; 
                s1 = s1.substring(23); 
            } else 
            { 
                s = s + s1.substring(0, i) + " "; 
                s1 = s1.substring(i + 1); 
            } 
        } 
        return s; 
    } 

    public static void gunTest() 
    { 
        for(int i = 0; i < 17; i++) 
        { 
            int make = 5; 
            int cls = 7; 
            Ship s = ships[make][cls]; 
            Gun g = gunTypes[i]; 
            int numguns = 14; 
            boolean flag = true; 
            int shots = 0; 
            int hull = s.iMaxHull; 
            while(flag) 
            { 
                hull = gunfire(hull, s.iEvasion, g.acc, g.dmg, numguns); 
                shots++; 
                if(hull < 0) 
                    flag = false; 
            } 
            System.out.println(makeNames[make] + " " + classNames[cls] + " killed by " + numguns + " " + g.name + " in " + shots + " shots (" + (shots * g.rof * 50) / 1000 + "s)"); 
        } 

    } 

    public static void main(String args[]) 
    { 
        try 
        { 
            date = new Date(); 
            File f = new File("alog.txt"); 
            FileOutputStream fos = new FileOutputStream(f.getAbsolutePath(), true); 
            PrintStream ps = new PrintStream(fos); 
            ps.println(""); 
            ps.println(date.toGMTString()); 
            System.setErr(ps); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
        setup(); 
        try 
        { 
            listen_socket = new ServerSocket(10000); 
        } 
        catch(IOException e) 
        { 
            System.err.println("Failed to create listen socket."); 
            e.printStackTrace(); 
            System.exit(-1); 
            return; 
        } 
        do 
            try 
            { 
                Socket socket = listen_socket.accept(); 
                System.out.println("New connection from " + socket.getInetAddress()); 
                if(!checkIP(socket.getInetAddress())) 
                { 
                    socket.close(); 
                    System.out.println("Connection closed: BANNED! - " + socket.getInetAddress()); 
                    Config.logIP(new String((new Date()).toGMTString() + " BANNED: " + socket.getInetAddress())); 
                } else 
                { 
                    new Server(socket); 
                } 
            } 
            catch(IOException e) 
            { 
                e.printStackTrace(); 
            } 
        while(true); 
    } 

    public static long randomExtra() 
    { 
        randomExtra++; 
        return randomExtra; 
    } 

    public static int tonum(String s) 
    { 
        Integer integer = Integer.valueOf(s); 
        int i = integer.intValue(); 
        return i; 
    } 

    public static synchronized void removeplayer(int i, String s, ActiveChecker a) 
    { 
        if(bar.findname(info[i].name) != -1) 
            bar.leave(info[i]); 
        if(i == -1) 
        { 
            System.out.println(i); 
            return; 
        } 
        if(info[i] != null && info[i].bLoggedIn) 
        { 
            if(!info[i].landed) 
            { 
                node[info[i].zone][info[i].loc].leave(info[i].name); 
                try 
                { 
                    Thread.sleep(100L); 
                } 
                catch(Exception e) { } 
                info[i].loc = info[i].lastPlanetN; 
                info[i].zone = info[i].lastPlanetZ; 
            } 
            try 
            { 
                info[i].sellAllCargo(); 
            } 
            catch(Exception e) 
            { 
                System.err.println("SellCargo error"); 
                e.printStackTrace(); 
            } 
            try 
            { 
                System.out.println(info[i].LogonTime); 
                long l = System.currentTimeMillis() - info[i].LogonTime; 
                System.out.println(l); 
                double d = l / 60000L; 
                int ii = tonum(String.valueOf(d).substring(0, String.valueOf(d).indexOf("."))); 
                System.out.println(ii); 
                info[i].MinsOnline += ii; 
                DataLoader.SaveCharacter(info[i]); 
            } 
            catch(Exception e) 
            { 
                System.err.println("SaveChar error"); 
                e.printStackTrace(); 
            } 
            try 
            { 
                if(info[i].shipsMake != null && info[i].shipsMake.length != 0) 
                { 
                    info[i].saveShip(info[i].iCurrentShip); 
                    DataLoader.SaveHangar(info[i]); 
                } 
            } 
            catch(Exception e) 
            { 
                System.err.println("SaveHangar error: " + info[i].name + " (" + info[i].iCurrentShip + ") | " + (new Date()).toGMTString()); 
                e.printStackTrace(); 
            } 
        } 
        System.out.println("Disconnected: " + s); 
        numusers--; 
        info[i].bLoggedOut = true; 
        try 
        { 
            info[i].socket.close(); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
        String ss = "Discon: " + info[i].name; 
        System.err.println("." + info[i].name); 
        if(active[i] != null && !a.equals(active[i])) 
        { 
            active[i].stop(); 
            active[i].clientnum = -1; 
            active[i].info = null; 
            active[i] = null; 
        } 
        if(info[i].server.active != null && !a.equals(info[i].server.active)) 
        { 
            info[i].server.active.stop(); 
            info[i].server.active.clientnum = -1; 
            info[i].server.active.info = null; 
            info[i].server.active = null; 
        } 
        info[i] = null; 
        System.gc(); 
        getNumChars(); 
        if(active[i] != null) 
            active[i].stop(); 
        active[i] = null; 
        a.stop(); 
        a = null; 
        System.gc(); 
    } 

    public static void ParseIpLog() 
    { 
        try 
        { 
            DataInputStream dis = new DataInputStream(new FileInputStream(new File("log_IP.txt"))); 
            PrintStream ps = new PrintStream(new FileOutputStream("output.txt")); 
            Vector names = new Vector(); 
            Vector ips = new Vector(); 
            int money = 0; 
            boolean running = true; 
            while(running) 
            { 
                Vector words = new Vector(); 
                String s = dis.readLine(); 
                if(s == null || s.equals("null")) 
                { 
                    running = false; 
                } else 
                { 
                    boolean flag = true; 
                    while(flag) 
                    { 
                        int i = s.indexOf(" "); 
                        if(i == -1) 
                        { 
                            i = s.length(); 
                            flag = false; 
                        } 
                        words.addElement(new String(s.substring(0, i))); 
                        s = s.substring(s.indexOf(" ") + 1); 
                    } 
                    String name = ""; 
                    for(int i = 5; i < words.size() - 1; i++) 
                    { 
                        String tmp = ""; 
                        if(i != 5) 
                            tmp = " "; 
                        name = name + tmp + (String)words.elementAt(i); 
                    } 

                    if(!names.contains(name)) 
                    { 
                        names.addElement(name); 
                        String ip = (String)words.elementAt(words.size() - 1); 
                        ips.addElement(ip); 
                        System.out.println(name + " " + ip); 
                        if(ip.indexOf("qld.optusnet.com.au") != -1) 
                        { 
                            ps.println("Char deleted: " + name + " (sony's ip)"); 
                            int i = DataLoader.GetMoney(name); 
                            if(i > 0) 
                                money += i; 
                        } 
                    } 
                } 
            } 
            System.out.println("Total money frozen: " + money); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
    } 

    public static String getNumChars() 
    { 
        int c = 0; 
        int a = 0; 
        for(int i = 0; i < info.length; i++) 
            if(info[i] != null) 
                if(info[i].bIsAi) 
                    a++; 
                else 
                    c++; 

        if(c >= 100) 
            PlayerLimitReached = false; 
        else 
            PlayerLimitReached = false; 
        String s = c + " (plus " + a + " AI)"; 
        return s; 
    } 

    public static boolean updateWebsite(String ip, String numchars) 
    { 
        numchars = Replace(numchars, " ", "%20"); 
        String httpUpdate = "GET /wuked/countplayers.php?Online=" + numchars; 
        try 
        { 
            Socket sock = new Socket(ip, 80); 
            PrintStream ps = new PrintStream(sock.getOutputStream()); 
            DataInputStream dis = new DataInputStream(sock.getInputStream()); 
            ps.print(httpUpdate); 
            ps.println(""); 
            ps.println(""); 
            ps.close(); 
            dis.close(); 
            sock.close(); 
            return true; 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
        return false; 
    } 

    public static void gunTest2() 
    { 
        for(int i = 0; i < gunTypes.length; i++) 
        { 
            Gun g = gunTypes[i]; 
            double d = ((double)g.dmg * damageMod * ((double)g.acc * evasMod)) / (double)g.rof; 
            System.out.println(g.name + " : " + d); 
        } 

    } 

    public static synchronized String GetSessionS() 
    { 
        Random r = new Random(); 
        String s; 
        for(s = "\\"; s.indexOf("\\") != -1 || s.indexOf(",") != -1 || s.indexOf(" ") != -1 || s.indexOf("\t") != -1 || s.indexOf("\n") != -1;) 
        { 
            s = ""; 
            int l; 
            for(l = 0; l < 6; l = (int)(r.nextDouble() * 11D) + 1); 
            if(l > 11) 
                l = 11; 
            for(int i = 0; i < l; i++) 
            { 
                int j = (int)(r.nextDouble() * 93D) + 1 + 33; 
                s = s + (char)j; 
            } 

        } 

        return s; 
    } 

    public static boolean checkICQ(String icq) 
    { 
        String s = icq; 
        for(int i = 0; i < bannedICQs.size(); i++) 
            if(s.indexOf((String)bannedICQs.elementAt(i) + "|") != -1) 
                return false; 

        return true; 
    } 

    public static String Replace(String s, String old, String n) 
    { 
        String s1; 
        String s2; 
        for(; s.indexOf(old) != -1; s = s1 + n + s2) 
        { 
            s1 = s.substring(0, s.indexOf(old)); 
            s2 = s.substring(s.indexOf(old) + old.length()); 
        } 

        return s; 
    } 

    static ServerSocket listen_socket; 
    public static String version = "1.44"; 
    public static long iTimeBetweenIncrements = 60L; 
    public static long iNumber = 0L; 
    public static long randomExtra = 0L; 
    public static int TimeoutSecs = 60; 
    public static final boolean RELEASE = false; 
    public static final boolean USEDLL = false; 
    public static final boolean FixedGRewards = false; 
    public static boolean bExpNeededForShips = false; 
    public static boolean bServerSideGunfire = true; 
    public static boolean bKickForHashcodes = false; 
    public static final int PROTOCOLL = 1; 
    public static final int MapStringLength = 2; 
    public static boolean bWriteTradePricesToHtml = true; 
    public static int iMaxWrongHashcodes = 4; 
    public static String clientVersion = "v3.0"; 
    public static String websiteURL = "apathy.d2g.com"; 
    public static int SatMaxLvl = 5; 
    public static final int PLAYERLIMIT = 100; 
    public static boolean PlayerLimitReached = false; 
    public static double ROFtolerance = 100D; 
    public static double ROFlog = 90D; 
    public static int jumpTol = 0; 
    public static long guildReward1 = 1000L; 
    public static long guildReward2 = 2000L; 
    public static long guildReward3 = 2000L; 
    public static double tradeAmountMod; 
    public static double damageMod; 
    public static double shieldMod; 
    public static double evasMod; 
    public static boolean genField = true; 
    public static boolean newChars = true; 
    public static boolean AllowASCIILogins = true; 
    public static Date date; 
    public static Vector bannedIPs = new Vector(); 
    public static Vector bannedICQs = new Vector(); 
    public static Vector bannedHDs = new Vector(); 
    public static Vector logIPs = new Vector(); 
    public static Vector logCharNames = new Vector(); 
    public static TradePriceUpdater trade; 
    public static Bar bar; 
    public static Guild g; 
    public static Gun guns[] = new Gun[20]; 
    public static Gun nullGun; 
    public static Equipment nullEquip; 
    public static Missile nullMissile; 
    public static Node node[][]; 
    public static int maxusers; 
    public static int numusers = 0; 
    public static int currentuser; 
    public static ActiveChecker active[]; 
    public static Info info[]; 
    public static String nodeinfos[]; 
    public static String planetinfo = "Gen Pelein,1,Gen Grayl,5,Gen Irium,9,Gen Gate 1,13,Gen Gate 2,18,Gen Gate 3,25,Laius Metis,6,Seejen,118,Tyros,25,Jen Cando,58,Crontas,63,Jen Kayle,68,Hy Syng,56,Daynow,92,Naykon,81,Velic Gate 1,17,Velic Gate 2,22,Velic Gate 3,27,Velic Cardan,1,Velic Grindow,5,Velic Vel,9,EndyStation,100,Dysilica,127,Helliathin,137,Kaydarin,177,Renos Brin,98,"; 
    public static String tradeInfo = "1,12,23,34,45,56,67,78,"; 
    public static boolean defaultRights[][] = new boolean[5][6]; 
    public static String defaultRanks[] = new String[6]; 
    public static String makeNames[]; 
    public static String classNames[]; 
    public static Gun gunTypes[]; 
    public static Missile missiles[]; 
    public static Equipment equipment[]; 
    public static Ship ships[][]; 
    public static Hashtable guildNameMap; 
    public static Hashtable guildIdMap; 
    public static int startplanet = 20; 

    static 
    { 
        maxusers = 150; 
        active = new ActiveChecker[maxusers + 1]; 
        info = new Info[maxusers + 1]; 
    } 
}


Искам да го преобразувам във startserver.class но незнам със каква програма мога да го компилирам пробвах със DJ не става може ли линк към програма за да го компилирам отгоре сам дал Source Code
 

Back
Горе