⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agesbasehttp.java

📁 手机游戏 SEGA《PuyoPuyo》 J2ME源代码+详细注释
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi

import java.io.*;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;

public abstract class AgesBaseHttp extends AgesBase
{

    private static boolean isUseFirstTime;
    public static int state;
    private static int regCredit;
    private static byte bufReg[];
    private static int counter;
    private static long regTime;
    static int key_down = 0;

    public AgesBaseHttp()
    {
    }

    protected final void drawLoad(int i)
    {
        if((counter += i) > 256)
            counter = 256;
        gc.setColor(0x7f7f7f);
        gc.fillRect(offsetX, offsetY, 150, 150);
        gc.drawImage(logo, 75 + offsetX, offsetY + 25, 3);
        drawCenter(0xffffff, "SEGA CORPORATION", 30 + offsetY);
        drawCenter(0xffffff, "Now Loading...", 85 + offsetY);
        drawCenter(0xffffff, "CREDIT " + regCredit, 110 + offsetY);
        gc.fillRect(42 + offsetX, offsetY + 75, 66, 10);
        gc.setColor(0xff8040);
        gc.fillRect(43 + offsetX, offsetY + 75 + 1, (counter * 64) / 256, 8);
    }

    protected final void drawCheckRegistration()
    {
        String as[][] = {
            {
                "Now connecting..."
            }, {
                ""
            }, {
                "Please renew your", "subscription."
            }, {
                "Latest version is", "now available."
            }, {
                "Please download", "the newest version."
            }, {
                "Unable to connect", "game server."
            }, {
                ""
            }
        };
        gc.setColor(0);
        gc.fillRect(offsetX, offsetY, 150, 150);
        if(state == 0 || state == 7 || state == 8)
            return;
        int i = as[state - 1].length;
        for(int j = i - 1; j >= 0; j--)
            drawCenter(0xffffff, as[state - 1][j], ((45 + j * 16) - (i - 1) * 8) + offsetY);

    }

    private static final void addCredit()
    {
        regCredit = Integer.parseInt(midlet.getAppProperty("AGES-CREDIT"));
        regTime = System.currentTimeMillis() + Long.parseLong(midlet.getAppProperty("AGES-TIME"));
    }

    private static final void saveCredit()
    {
        setInteger(bufReg, 0, regCredit);
        setInteger(bufReg, 4, (int)(regTime >> 32));
        setInteger(bufReg, 8, (int)regTime);
        writeSram("p", bufReg, isUseFirstTime);
        isUseFirstTime = false;
    }

    protected static final byte[] postHttpData(String s, byte abyte0[], int i)
    {
        try{
            int j;
            byte abyte1[];
            j = 0;
            abyte1 = new byte[i];
            HttpConnection httpconnection = (HttpConnection) Connector.open(s);
            httpconnection.setRequestMethod("POST");
            httpconnection.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            OutputStream outputstream = httpconnection.openOutputStream();
            outputstream.write(abyte0);
            outputstream.flush();
            outputstream.close();
            InputStream inputstream = httpconnection.openInputStream();
            do {
                int k = inputstream.read(abyte1, j, i - j);
                if (k <= 0)
                    break;
                j += k;
            } while (j < i);
            inputstream.close();
            httpconnection.close();
            if (j != i) {
                abyte0 = abyte1;
                abyte1 = new byte[j];
                System.arraycopy(abyte0, 0, abyte1, 0, j);
            }
            return abyte1;
        }catch(Exception e){
//        Exception exception;
//        exception;
            System.out.println(e.toString());
            return null;
        }
    }

    private static final int checkRegistration()
    {
        byte abyte0[] = ("cpid=10&cppwd=ga89e&service_ref=78&game_ref=" + midlet.getAppProperty("AGES-GAMEREF") + "&version=" + midlet.getAppProperty("MIDlet-Version")).getBytes();
        abyte0 = postHttpData("http://download.smartone.com.hk/sticker/servlet/checkSubStatus", abyte0, 1);
        if(abyte0 == null)
            return 6;
        if(bufReg == null)
            bufReg = new byte[4];
        switch((new String(abyte0)).charAt(0))
        {
        case 89: // 'Y'
            return 2;

        case 78: // 'N'
            return 3;

        case 79: // 'O'
            key_down = 0;
            return 4;

        case 77: // 'M'
            return 5;
        }
        return 6;
    }

    protected static final boolean doCheckRegistration()
    {
        switch(state)
        {
        case 3: // '\003'
        case 5: // '\005'
        case 6: // '\006'
        default:
            break;

        case 0: // '\0'
            bufReg = readSram("p");
            isUseFirstTime = bufReg == null;
            if(!isUseFirstTime)
            {
                regCredit = getInteger(bufReg, 0);
                for(int i = 0; i < 8; i++)
                    regTime = (regTime << 8) + (long)(bufReg[4 + i] & 0xff);

            }
            state = regCredit > 0 && regTime != 0L ? 7 : 1;
            break;

        case 1: // '\001'
            state = checkRegistration();
            break;

        case 2: // '\002'
            addCredit();
            state = 7;
            break;

        case 4: // '\004'
            if(key_down == 35)
            {
                addCredit();
                state = 7;
            }
            break;

        case 7: // '\007'
            regCredit--;
            if(regTime < System.currentTimeMillis() || regTime - Long.parseLong(midlet.getAppProperty("AGES-TIME")) >= System.currentTimeMillis())
                regTime = 0L;
            saveCredit();
            state = 8;
            bufReg = null;
            break;
        }
        return state == 8;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -