예제 #1
0
        public void LoadBaseData(string pName = null)
        {
            using (var result = MySQL_Connection.Instance.RunQuery("SELECT id, internal_id, userid, world_id, name FROM characters" + (pName != null ? " WHERE name = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(pName) + "'" : "")) as MySql.Data.MySqlClient.MySqlDataReader)
            {
                while (result.Read())
                {
                    CharacterCacheInfo ch = new CharacterCacheInfo();
                    ch.Initialize(result);

                    KnownCharlist.Add(ch.InternalID, ch);
                }
            }
        }
예제 #2
0
        public void LoadInventoryHashes(int?pInternalID = null, bool reload = false)
        {
            if (pInternalID != null && reload)
            {
                var character = GetCharInfoByInternalID(pInternalID.Value);
                if (character != null)
                {
                    character.SlotHashes.Clear();
                }
            }

            using (var result = MySQL_Connection.Instance.RunQuery("SELECT character_id, inventory, slot, `checksum` FROM items" + (pInternalID.HasValue ? " WHERE character_id = " + pInternalID.Value : "") + " ORDER BY character_id") as MySql.Data.MySqlClient.MySqlDataReader)
            {
                CharacterCacheInfo ch = null;
                int lastid            = 0;
                while (result.Read())
                {
                    if (lastid != result.GetInt32("character_id"))
                    {
                        lastid = result.GetInt32("character_id");
                        ch     = GetCharInfoByInternalID(lastid);
                        if (ch == null)
                        {
                            lastid = 0;
                            continue;
                        }
                    }

                    ushort inventory = result.GetUInt16("inventory");
                    if (!ch.SlotHashes.ContainsKey(inventory))
                    {
                        ch.SlotHashes.Add(inventory, new Dictionary <short, int>());
                    }

                    ch.SlotHashes[inventory].Add(result.GetInt16("slot"), result.GetInt32("checksum"));
                }
            }
        }
예제 #3
0
        public static int AddOrUpdateCharacter(
            ClientConnection pConnection, int pID, string pName, int pUserID, byte pWorldID, byte pChannelID, byte pLevel,
            short pJob, short pStr, short pDex, short pInt, short pLuk,
            int pHP, int pMaxHP, int pMP, int pMaxMP, short pAP, short pSP,
            long pEXP, int pFame, int pMap, byte pMapPos,
            int pHonourLevel, int pHonourEXP, long pMesos, int pDemonMark,
            byte pGender, byte pSkin,
            int pEyes, int pHair,

            byte[] pSlots, string pBoF, string pBoE, string pUE,
            long[] pPetIDs, int[] pTraits,
            string pMarriedWith
            )
        {
            CharacterCacheInfo cci = AccountDataCache.Instance.GetCharInfoByIDAndWorldID(pID, pWorldID);

            if (cci != null)
            {
                int internal_id = cci.InternalID;
                using (UpdateQueryBuilder query = new UpdateQueryBuilder("characters"))
                {
                    query.SetColumn("name", pName);
                    query.SetColumn("userid", pUserID);
                    query.SetColumn("world_id", pWorldID);
                    query.SetColumn("channel_id", pChannelID);
                    query.SetColumn("level", pLevel);
                    query.SetColumn("job", pJob);
                    query.SetColumn("str", pStr);
                    query.SetColumn("dex", pDex);
                    query.SetColumn("int", pInt);
                    query.SetColumn("luk", pLuk);
                    query.SetColumn("chp", pHP);
                    query.SetColumn("mhp", pMaxHP);
                    query.SetColumn("cmp", pMP);
                    query.SetColumn("mmp", pMaxMP);
                    query.SetColumn("ap", pAP);
                    query.SetColumn("sp", pSP);
                    query.SetColumn("exp", pEXP);
                    query.SetColumn("fame", pFame);
                    query.SetColumn("map", pMap);
                    query.SetColumn("pos", pMapPos);
                    query.SetColumn("gender", pGender);
                    query.SetColumn("skin", pSkin);
                    query.SetColumn("eyes", pEyes);
                    query.SetColumn("hair", pHair);
                    query.SetColumn("last_update", MySQL_Connection.NOW);

                    query.SetColumn("honourlevel", pHonourLevel);
                    query.SetColumn("honourexp", pHonourEXP);
                    query.SetColumn("mesos", pMesos);
                    query.SetColumn("demonmark", pDemonMark);

                    query.SetColumn("eqp_slots", pSlots[0]);
                    query.SetColumn("use_slots", pSlots[1]);
                    query.SetColumn("setup_slots", pSlots[2]);
                    query.SetColumn("etc_slots", pSlots[3]);
                    query.SetColumn("cash_slots", pSlots[4]);

                    query.SetColumn("blessingoffairy", pBoF);
                    query.SetColumn("blessingofempress", pBoE);
                    query.SetColumn("ultimateexplorer", pUE);

                    query.SetColumn("petcashid1", pPetIDs[0]);
                    query.SetColumn("petcashid2", pPetIDs[1]);
                    query.SetColumn("petcashid3", pPetIDs[2]);

                    query.SetColumn("trait_charisma", pTraits[0]);
                    query.SetColumn("trait_insight", pTraits[1]);
                    query.SetColumn("trait_willpower", pTraits[2]);
                    query.SetColumn("trait_craft_dili", pTraits[3]);
                    query.SetColumn("trait_empathy", pTraits[4]);
                    query.SetColumn("trait_charm", pTraits[5]);

                    query.SetColumn("married_with", pMarriedWith);

                    query.SetWhereColumn("internal_id", internal_id);

                    int result = query.RunQuery("sql_addorupdate.sql");

                    if (result >= 1)
                    {
                        //pConnection.Logger_WriteLine("Updated character info: {0}", internal_id);
                        return(cci.InternalID);
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to update character info: " + query.ToString());
                    }
                }
            }
            else
            {
                using (InsertQueryBuilder query = new InsertQueryBuilder("characters"))
                {
                    query.OnDuplicateUpdate = false;
                    query.AddColumnWithValue("internal_id", null);

                    query.AddColumnWithValue("id", pID, false);
                    query.AddColumnWithValue("name", pName);
                    query.AddColumnWithValue("userid", pUserID);
                    query.AddColumnWithValue("world_id", pWorldID);
                    query.AddColumnWithValue("channel_id", pChannelID);
                    query.AddColumnWithValue("level", pLevel);
                    query.AddColumnWithValue("job", pJob);
                    query.AddColumnWithValue("str", pStr);
                    query.AddColumnWithValue("dex", pDex);
                    query.AddColumnWithValue("int", pInt);
                    query.AddColumnWithValue("luk", pLuk);
                    query.AddColumnWithValue("chp", pHP);
                    query.AddColumnWithValue("mhp", pMaxHP);
                    query.AddColumnWithValue("cmp", pMP);
                    query.AddColumnWithValue("mmp", pMaxMP);
                    query.AddColumnWithValue("ap", pAP);
                    query.AddColumnWithValue("sp", pSP);
                    query.AddColumnWithValue("exp", pEXP);
                    query.AddColumnWithValue("fame", pFame);
                    query.AddColumnWithValue("map", pMap);
                    query.AddColumnWithValue("pos", pMapPos);
                    query.AddColumnWithValue("gender", pGender);
                    query.AddColumnWithValue("skin", pSkin);
                    query.AddColumnWithValue("eyes", pEyes);
                    query.AddColumnWithValue("hair", pHair);
                    query.AddColumnWithValue("last_update", MySQL_Connection.NOW);

                    query.AddColumnWithValue("honourlevel", pHonourLevel);
                    query.AddColumnWithValue("honourexp", pHonourEXP);
                    query.AddColumnWithValue("mesos", pMesos);
                    query.AddColumnWithValue("demonmark", pDemonMark);

                    query.AddColumnWithValue("eqp_slots", pSlots[0]);
                    query.AddColumnWithValue("use_slots", pSlots[1]);
                    query.AddColumnWithValue("setup_slots", pSlots[2]);
                    query.AddColumnWithValue("etc_slots", pSlots[3]);
                    query.AddColumnWithValue("cash_slots", pSlots[4]);

                    query.AddColumnWithValue("blessingoffairy", pBoF);
                    query.AddColumnWithValue("blessingofempress", pBoE);
                    query.AddColumnWithValue("ultimateexplorer", pUE);


                    query.AddColumnWithValue("petcashid1", pPetIDs[0]);
                    query.AddColumnWithValue("petcashid2", pPetIDs[1]);
                    query.AddColumnWithValue("petcashid3", pPetIDs[2]);

                    query.AddColumnWithValue("trait_charisma", pTraits[0]);
                    query.AddColumnWithValue("trait_insight", pTraits[1]);
                    query.AddColumnWithValue("trait_willpower", pTraits[2]);
                    query.AddColumnWithValue("trait_craft_dili", pTraits[3]);
                    query.AddColumnWithValue("trait_empathy", pTraits[4]);
                    query.AddColumnWithValue("trait_charm", pTraits[5]);

                    query.AddColumnWithValue("married_with", pMarriedWith);

                    string q = query.ToString();

                    System.IO.File.WriteAllText("sql_addorupdate_insert.sql", q);

                    int result = (int)MySQL_Connection.Instance.RunQuery(q);

                    if (result >= 1)
                    {
                        int internalid = MySQL_Connection.Instance.GetLastInsertId();
                        pConnection.Logger_WriteLine("Inserted character info: {0}", internalid);
                        return(internalid);
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to insert character info: " + q);
                    }
                }
            }

            Logger.WriteLine("ERROR WHILE ADDING OR UPDATING CHARACTER");

            return(-1);
        }
예제 #4
0
        public void LoadBaseData(string pName = null)
        {
            using (var result = MySQL_Connection.Instance.RunQuery("SELECT id, internal_id, userid, world_id, name FROM characters" + (pName != null ? " WHERE name = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(pName) + "'" : "")) as MySql.Data.MySqlClient.MySqlDataReader)
            {
                while (result.Read())
                {
                    CharacterCacheInfo ch = new CharacterCacheInfo();
                    ch.Initialize(result);

                    KnownCharlist.Add(ch.InternalID, ch);
                }
            }

        }