Exemplo n.º 1
0
        public IntPtr LoadAudioStreamFromUrl(string url, string cacheDirectory)
        {
            lock (audioUrlStreamLoaderLockObject) {
                lock (audioDataCache) {
                    if (audioDataCache.ContainsKey(url))
                    {
                        return(audioDataCache[url].AudioStreamPointer);
                    }
                }
                AudioDataCache dataCache = new AudioDataCache();

                dataCache.CachePath   = cacheDirectory + Path.GetFileName(url);
                dataCache.CacheStream = new FileStream(dataCache.CachePath + ".tmp", FileMode.Create, FileAccess.Write);

                dataCache.CallbackDelegate = new DownloadCallbackDelegate(AudioDownloadCallback);

                IntPtr urlPtr = Marshal.StringToHGlobalUni(url);
                lock (audioDataCache) {
                    if (audioDataCache.ContainsKey(url) == false)
                    {
                        audioDataCache.Add(url, dataCache);
                    }
                    else
                    {
                        dataCache.CallbackDelegate = null;
                        if (urlPtr != IntPtr.Zero)
                        {
                            Marshal.FreeHGlobal(urlPtr);
                            urlPtr = IntPtr.Zero;
                        }
                    }
                }

                dataCache.AudioStreamPointer = Bass.BASS_StreamCreateURL(url, 0, 0, dataCache.CallbackDelegate, urlPtr);

                if (dataCache.AudioStreamPointer == IntPtr.Zero)
                {
                    // Uh oh! We couldn't play the sfx stream!
                    lock (audioDataCache) {
                        if (audioDataCache.ContainsKey(url))
                        {
                            audioDataCache.RemoveAtKey(url);
                        }
                        if (urlPtr != IntPtr.Zero)
                        {
                            Marshal.FreeHGlobal(urlPtr);
                            urlPtr = IntPtr.Zero;
                        }
                    }
                    dataCache.CacheStream.Close();
                    File.Delete(dataCache.CachePath + ".tmp");
                    dataCache.CachePath = null;
                }

                return(dataCache.AudioStreamPointer);
            }
        }
Exemplo n.º 2
0
 public ThreadedTimer GetTimer(string timerID)
 {
     if (timers.ContainsKey(timerID))
     {
         return(timers[timerID]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public void AddGnpClient(TClientID clientID, GnpClient gnpClient)
 {
     if (clients.ContainsKey(clientID) == false)
     {
         // If the collection does not contain a client with the same ID, add it
         clients.Add(clientID, gnpClient);
     }
 }
Exemplo n.º 4
0
 public IPlayer this[string connectionID] {
     get {
         lock (lockObject) {
             if (players.ContainsKey(connectionID) == false)
             {
                 return(null);
             }
             else
             {
                 return(players[connectionID]);
             }
         }
     }
     set {
         lock (lockObject) {
             players[connectionID] = value;
         }
     }
 }
Exemplo n.º 5
0
        public static void LoadCharacterParty(Client client)
        {
            Party partyData = null;

            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                partyData = LoadCharacterParty(dbConnection.Database, client.Player.CharID);
            }

            if (partyData != null)
            {
                if (!parties.ContainsKey(partyData.PartyID))
                {
                    parties.Add(partyData.PartyID, partyData);
                }
                client.Player.PartyID = partyData.PartyID;
                //party.SwitchOutExtraMembers();
            }
        }
Exemplo n.º 6
0
 public bool ContainsItem(int itemNum)
 {
     return(items.ContainsKey(itemNum));
 }
Exemplo n.º 7
0
 public bool ContainsKey(int slot)
 {
     return(items.ContainsKey(slot));
 }