コード例 #1
0
        public void RemoveInfo(RestartInfo pInfo)
        {
            if (pInfo == null)
            {
                return;
            }
            using (DeleteQueryBuilder dqb = new DeleteQueryBuilder("session_restarts"))
            {
                dqb.SetWhereColumn("character_id", pInfo.CharacterID);
                dqb.SetWhereColumn("world_id", pInfo.WorldID);
                dqb.SetWhereColumn("ip", pInfo.IP);
                dqb.SetWhereColumn("machine_id", pInfo.MachineID);

                dqb.RunQuery();
            }

            Cache.Remove(pInfo);
        }
コード例 #2
0
        public void TryRestartSession(ClientConnection pConnection, int pCharacterID, byte[] pMachineID)
        {
            RestartInfo restartInfo = Cache.Find((i) => { return(i.CharacterID == pCharacterID && i.CompareMachineID(pMachineID) && i.IP == pConnection.IP); });

            if (restartInfo != null)
            {
                // Found character
                // NOTE:
                // When a player/IP has 2 characters with the same ID on 2 different worlds
                // And the connection resets. And the player changes to the other character.
                // And a blue moon. Then worlds collide and apocalypse

                var info = AccountDataCache.Instance.GetCharInfoByIDAndWorldID(pCharacterID, restartInfo.WorldID);

                if (info != null)
                {
                    if (info.AccountID != pConnection.AccountID)
                    {
                        pConnection.Logger_WriteLine("Unable to restore session for {0} (IP: {1})! Account id not the same! (Trying to hack it?)", pCharacterID, pConnection.IP);
                        return;
                    }
                    // Okay. We got this
                    pConnection.WorldID = info.WorldID;
                    pConnection.UserID  = info.UserID;
                    // Do not set the IDs of the character
                    // pConnection.CharacterInternalID = info.InternalID;

                    pConnection.Logger_WriteLine("Restored session for characterid {0} world {1} (IP: {2})", pCharacterID, info.WorldID, pConnection.IP);

                    // Scratch him off the cache list
                    Cache.Remove(restartInfo);
                }
                else
                {
                    pConnection.Logger_WriteLine("Unable to restore session for {0} (IP: {1})! Not found in Internal Storage.", pCharacterID, pConnection.IP);
                }
            }
            else
            {
                pConnection.Logger_WriteLine("No info found for character id {0} (IP: {1})", pCharacterID, pConnection.IP);
            }
        }
コード例 #3
0
        public void RemoveInfo(RestartInfo pInfo)
        {
            if (pInfo == null) return;
            using (DeleteQueryBuilder dqb = new DeleteQueryBuilder("session_restarts"))
            {
                dqb.SetWhereColumn("character_id", pInfo.CharacterID);
                dqb.SetWhereColumn("world_id", pInfo.WorldID);
                dqb.SetWhereColumn("ip", pInfo.IP);
                dqb.SetWhereColumn("machine_id", pInfo.MachineID);

                dqb.RunQuery();
            }

            Cache.Remove(pInfo);
        }