Ejemplo n.º 1
0
        public LoginServerDLG()
        {
            KODatabase db = new KODatabase();
            foreach(VERSION lstVersion in db.VERSION)
            {
                version = version > lstVersion.sVersion ? version : lstVersion.sVersion;
                PatchList.Add(lstVersion);
            }

            Console.WriteLine("Login Versiyon : " + version);

            INIReader ini = new INIReader(Environment.CurrentDirectory + "/LogInServer.ini");
            FTP_URL = ini.Read("DOWNLOAD", "URL");
            FTP_PATH = ini.Read("DOWNLOAD", "PATH");

            int ServerCount = ini.GetInt("SERVER_LIST", "COUNT");

            for(int i=0; i<ServerCount; i++)
            {
                SERVER_INFO info = new SERVER_INFO();
                info.strServerIP = ini.GetString("SERVER_LIST", string.Format("SERVER_{0}", i.ToString("00")));
                info.strLanIP = ini.GetString("SERVER_LIST", string.Format("LANIP_{0}", i.ToString("00")));
                info.strServerName = ini.GetString("SERVER_LIST", string.Format("NAME_{0}", i.ToString("00")));
                info.sServerID = ini.GetShort("SERVER_LIST", string.Format("ID_{0}", i.ToString("00")));
                info.sGroupID = ini.GetShort("SERVER_LIST", string.Format("GROUPID_{0}", i.ToString("00")));
                info.sPlayerCap = ini.GetShort("SERVER_LIST", string.Format("PREMLIMIT_{0}", i.ToString("00")));
                info.sFreePlayerCap = ini.GetShort("SERVER_LIST", string.Format("FREELIMIT_{0}", i.ToString("00")));
                info.strKarusKingName = ini.GetString("SERVER_LIST", string.Format("KING1_{0}", i.ToString("00")));
                info.strElMoradKingName = ini.GetString("SERVER_LIST", string.Format("KING2_{0}", i.ToString("00")));
                info.strKarusNotice = ini.GetString("SERVER_LIST", string.Format("KINGMSG1_{0}", i.ToString("00")));
                info.strElMoradNotice = ini.GetString("SERVER_LIST", string.Format("KINGMSG2_{0}", i.ToString("00")));
                ServerList.Add(info);
            }
        }
Ejemplo n.º 2
0
        internal static void SelectNation(ref Packet result, byte nation, string strUserID)
        {
            KODatabase db = new KODatabase();

            ACCOUNT_CHAR aChar = db.ACCOUNT_CHAR.Where(acc => acc.strAccountID == strUserID).FirstOrDefault();
            WAREHOUSE wHouse = db.WAREHOUSE.Where(wh => wh.strAccountID == strUserID).FirstOrDefault();

            if (wHouse == null)
            {
                wHouse = new WAREHOUSE();
                wHouse.strAccountID = strUserID;
                wHouse.nMoney = 0;
                wHouse.dwTime = 0;
                wHouse.WarehouseData = new byte[1536];
                wHouse.strSerial = new byte[1536];
                wHouse.WarehouseDataTime = new byte[1536];

                db.WAREHOUSE.Add(wHouse);
                
                Debug.WriteLine("WAREHOUSE hesabı bulunamadığından yeni WAREHOUSE eklendi.");
            }

            if (aChar == null)
            {
                aChar = new ACCOUNT_CHAR();
                aChar.strAccountID = strUserID;
                aChar.bNation = nation;
                aChar.strCharID1 = null;
                aChar.strCharID2 = null;
                aChar.strCharID3 = null;
                db.ACCOUNT_CHAR.Add(aChar);
                Debug.WriteLine("Hesap bulunamadığından yeni account eklendi.");
            }
            else
            {
                nation = aChar.bNation;
                Debug.WriteLine("Hesap bilgileri alındı. Seçilen ırk {0}", nation);
            }

            db.SaveChanges();

            if (nation != KARUS && nation != ELMORAD)
            {
                result.SetByte(0);
                return;
            }

            result.SetByte(nation);
            
        }
Ejemplo n.º 3
0
        internal static byte GameLogin(string accountID, string strPassword, ref Packet result)
        {
            KODatabase db = new KODatabase();

            int nRet = db.TB_USER.Where(usr => usr.strAccountID == accountID && usr.strPasswd == strPassword).Count();

            if (nRet < 1)
                return 0;

            ACCOUNT_CHAR Account = db.ACCOUNT_CHAR.Where(acc => acc.strAccountID == accountID).FirstOrDefault();

            if (Account == null)
                return 0;

            return Account.bNation;
        }
Ejemplo n.º 4
0
        public static bool LoadCoefficient(ref List<COEFFICIENT> m_CoefficientArray)
        {
            try
            {
                KODatabase db = new KODatabase();

                foreach (COEFFICIENT coeff in db.COEFFICIENT)
                {
                    m_CoefficientArray.Add(coeff);
                }

            }
            catch
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 5
0
        private void HandleLogin(Packet pkt)
        {
            KODatabase db = new KODatabase();
            string AccountID = pkt.GetString(), Passwd = pkt.GetString();
            short resultCode = 1;

            if (AccountID == string.Empty || AccountID.Length >= Define.MAX_ID_SIZE ||
                Passwd == string.Empty || Passwd.Length >= Define.MAX_PW_SIZE)
                resultCode = 2;
            else
                resultCode = db.TB_USER.Where(u=> u.strAccountID == AccountID && u.strPasswd == Passwd).Count() > 0 ? (short)1 : (short)2 ;

            Packet result = new Packet((byte)LogonOpcodes.LS_LOGIN_REQ);
            result.SetByte((byte)resultCode);
            if (resultCode == 1)
            {
                result.SetShort((short)db.ACCOUNT_PREMIUM(AccountID));
                result.SetString(AccountID);
            }

            Send(result);

            Debug.WriteLine("Kullanıcı girişi : {1} - {0}", resultCode, AccountID);
        }
Ejemplo n.º 6
0
 private void button2_Click(object sender, EventArgs e)
 {
     KODatabase db = new KODatabase();
     int result = db.CREATE_NEW_CHAR("fkose3", 3, "teswet2", 1, 10, 1, 1, 60,60,60,60,60);
     MessageBox.Show(result.ToString());
 }
Ejemplo n.º 7
0
        internal void GetServerList(ref Packet result)
        {
            KODatabase db = new KODatabase();
            short CurrentUserCount = (short)db.CURRENTUSER.Count();
            result.SetByte((byte)ServerList.Count);

            foreach(SERVER_INFO server in ServerList)
            {
                result.SetString(server.strServerIP);
                result.SetString(server.strLanIP);
                result.SetString(server.strServerName);

                if (CurrentUserCount <= server.sPlayerCap)
                    result.SetShort(CurrentUserCount);
                else
                    result.SetShort(-1);

                result.SetShort(server.sServerID);
                result.SetShort(server.sGroupID);

                result.SetShort(server.sPlayerCap);
                result.SetShort(server.sFreePlayerCap);

                result.SetByte(0);

                result.SetString(server.strKarusKingName);
                result.SetString(server.strKarusNotice);
                result.SetString(server.strElMoradKingName);
                result.SetString(server.strElMoradNotice);
            }
        }
Ejemplo n.º 8
0
        internal static bool GetLetterList(string strAccountID, ref Packet result, bool isHistory)
        {
            try {
                KODatabase db = new KODatabase();

                byte bType = isHistory ? (byte)2 : (byte)1;

                var letterlist = db.MAIL_BOX.Where(i => i.strRecipientID == strAccountID && i.bStatus == bType && !i.bDeleted).Take(10);
                byte Count = (byte)letterlist.Count();

                result.SetByte(1).SetByte(bType);

                foreach (MAIL_BOX letter in letterlist)
                {
                    result.SetDword(letter.nLetterID)
                        .SetByte(letter.bStatus)
                        .SetString(letter.strSubject)
                        .SetString(letter.strSenderID)
                        .SetByte(letter.bType);

                    if (letter.bType == 2)
                        result.SetDword(letter.nItemID).SetShort(letter.sCount).SetDword(letter.nCoins);

                    int DayDiff = (Int32)UNIXTIME - (Int32)(letter.dtSendDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

                    byte RemainDays = (byte)(DayDiff / 60 / 60 / 24);
                    result.SetDword((int)UNIXTIME).SetByte(RemainDays);
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 9
0
        public static bool LoadUserData(string AccountID, string strCharID, ref User pUser)
        {
            KODatabase db = new KODatabase();
            try
            {
                USERDATA pData = db.USERDATA.Where(user => user.strUserID == strCharID).FirstOrDefault();

                if (pData == null)
                    return false;

                pUser.m_bNation = pData.Nation;
                pUser.m_bRace   = pData.Race   ;
                pUser.m_sClass  = pData.Class  ;
                pUser.m_nHair   = pData.HairRGB;
                pUser.m_bRank   = pData.Rank   ;
                pUser.m_bTitle  = pData.Title  ;
                pUser.m_bLevel  = pData.Level  ;
                pUser.m_iExp    = pData.Exp    ;
                pUser.m_iLoyalty= pData.Loyalty;
                pUser.m_bFace   = pData.Face   ;
                pUser.m_bCity   = (sbyte)pData.City   ;
                pUser.m_bKnights= pData.Knights;
                pUser.m_bFame   = pData.Fame   ;
                pUser.m_sHp     = pData.Hp     ;
                pUser.m_sMp     = pData.Mp     ;
                pUser.m_sSp     = pData.Sp     ;
                pUser.m_bStats[(int)StatType.STAT_STR] = pData.Strong;
                pUser.m_bStats[(int)StatType.STAT_STA] = pData.Sta;
                pUser.m_bStats[(int)StatType.STAT_DEX] = pData.Dex;
                pUser.m_bStats[(int)StatType.STAT_INT] = pData.Intel;
                pUser.m_bStats[(int)StatType.STAT_CHA] = pData.Cha;
                pUser.m_bAuthority= pData.Authority;
                pUser.m_sPoints   = pData.Points   ;
                pUser.m_iGold     = pData.Gold     ;
                pUser.m_bZone     = pData.Zone     ;
                pUser.m_sBind     = (long)pData.Bind;

                pUser.m_curx = (float)(pData.PX / 100.0f);
                pUser.m_curz = (float)(pData.PZ / 100.0f);
                pUser.m_cury = (float)(pData.PY / 100.0f);
                pUser.m_oldx = pUser.m_curx;
                pUser.m_oldy = pUser.m_cury;
                pUser.m_oldz = pUser.m_curz;

                pUser.m_dwTime = pData.dwTime;

                pUser.m_bstrSkill = pData.strSkill.ToCharArray();

                Packet itemBuffer = new Packet(pData.strItem);
                Packet serialBuffer = new Packet(pData.strSerial);
                Packet itemTimeBuffer = new Packet(pData.strItemTime);
                for (int i = 0; i < INVENTORY_TOTAL; i++)
                {
                    Int64 nSerialNum;
                    Int32 nItemID;
                    Int16 sDurability, sCount, nRentalTime;
                    Int32 nItemTime;

                    nItemID = itemBuffer.GetDWORD();
                    sDurability = itemBuffer.GetShort();
                    sCount = itemBuffer.GetShort();
                    nSerialNum = serialBuffer.GetInt64();
                    nItemTime = itemTimeBuffer.GetDWORD();
                    nRentalTime = itemTimeBuffer.GetShort();

                    _ITEM_DATA pItem = new _ITEM_DATA();

                    pItem.nNum = nItemID;
                    pItem.sCount = sCount;
                    pItem.sDuration = sDurability;
                    pItem.nSerialNum = nSerialNum;
                    pItem.nExpirationTime = nItemTime;
                    pItem.sRemainingRentalTime = nRentalTime;

                    pUser.m_sItemArray[i] = pItem;
                }

                return true;
            }
            catch(Exception ex)
            {
                Debug.WriteLine("Karakter bilgileri alınırken özel durum oluştu : " + ex.Message);

                return false; 
            }
        }
Ejemplo n.º 10
0
        internal static byte GetUnreadLetter(string strAccountID)
        {
            KODatabase db = new KODatabase();

            return (byte)db.MAIL_BOX.Where(i => i.strRecipientID == strAccountID && i.bStatus == 1 && !i.bDeleted).Count();
        }
Ejemplo n.º 11
0
        public static bool LoadItemTable(ref List<_ITEM_TABLE> m_ItemTable)
        {
            try
            {
                KODatabase db = new KODatabase();

                foreach(ITEM item in db.ITEM)
                {
                    _ITEM_TABLE pItem = new _ITEM_TABLE();

                    pItem.m_iNum = item.Num;
                    pItem.m_sName = item.strName;
                    pItem.m_bKind = item.Kind;
                    pItem.m_bSlot = item.Slot;
                    pItem.m_bRace = item.Race;
                    pItem.m_bClass = item.Class;
                    pItem.m_sDamage = item.Damage;
                    pItem.m_sDelay = item.Delay;
                    pItem.m_sRange = item.Range;
                    pItem.m_sWeight = item.Weight;
                    pItem.m_sDuration = item.Duration;
                    pItem.m_iBuyPrice = item.BuyPrice;
                    pItem.m_iSellPrice = item.SellPrice;
                    pItem.m_sAc = item.Ac;
                    pItem.m_bCountable = item.Countable;
                    pItem.m_iEffect1 = item.Effect1;
                    pItem.m_iEffect2 = item.Effect2;
                    pItem.m_bReqLevel = item.ReqLevel;
                    pItem.m_bReqLevelMax = item.ReqLevelMax;
                    pItem.m_bReqRank = item.ReqRank;
                    pItem.m_bReqTitle = item.ReqTitle;
                    pItem.m_bReqStr = item.ReqStr;
                    pItem.m_bReqSta = item.ReqSta;
                    pItem.m_bReqDex = item.ReqDex;
                    pItem.m_bReqIntel = item.ReqIntel;
                    pItem.m_bReqCha = item.ReqCha;
                    pItem.m_bSellingGroup = item.SellingGroup;
                    pItem.m_ItemType = item.ItemType;
                    pItem.m_sHitrate = item.Hitrate;
                    pItem.m_sEvarate = item.Evasionrate;
                    pItem.m_sDaggerAc = item.DaggerAc;
                    pItem.m_sSwordAc = item.SwordAc;
                    pItem.m_sMaceAc = item.MaceAc;
                    pItem.m_sAxeAc = item.AxeAc;
                    pItem.m_sSpearAc = item.SpearAc;
                    pItem.m_sBowAc = item.BowAc;
                    pItem.m_bFireDamage = item.FireDamage;
                    pItem.m_bIceDamage = item.IceDamage;
                    pItem.m_bLightningDamage = item.LightningDamage;
                    pItem.m_bPoisonDamage = item.PoisonDamage;
                    pItem.m_bHPDrain = item.HPDrain;
                    pItem.m_bMPDamage = item.MPDamage;
                    pItem.m_bMPDrain = item.MPDrain;
                    pItem.m_bMirrorDamage = item.MirrorDamage;
                    pItem.m_sStrB = item.StrB;
                    pItem.m_sStaB = item.StaB;
                    pItem.m_sDexB = item.DexB;
                    pItem.m_sIntelB = item.IntelB;
                    pItem.m_sChaB = item.ChaB;
                    pItem.m_MaxHpB = item.MaxHpB;
                    pItem.m_MaxMpB = item.MaxMpB;
                    pItem.m_bFireR = item.FireR;
                    pItem.m_bColdR = item.ColdR;
                    pItem.m_bLightningR = item.LightningR;
                    pItem.m_bMagicR = item.MagicR;
                    pItem.m_bPoisonR = item.PoisonR;
                    pItem.m_bCurseR = item.CurseR;
                    pItem.ItemClass = (short)item.ItemClass;
                    pItem.ItemExt = (short)item.ItemExt;

                    m_ItemTable.Add(pItem);
                }
            }catch
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 12
0
        public static bool LoadLevelUp(ref List<LEVEL_UP> m_arLevelUp)
        {
            try
            {
                KODatabase db = new KODatabase();

                foreach (LEVEL_UP level in db.LEVEL_UP)
                {
                    m_arLevelUp.Add(level);
                }

            }
            catch
            {
                return false;
            }
            return true;
        }