Exemplo n.º 1
0
        /// <summary>
        /// classes should call getUid to get a new unique SceUID </summary>
        public static int getNewUid(object purpose)
        {
            SceUid uid = new SceUid(purpose, uidNext++);

            uidMap[uid.Uid] = uid;
            return(uid.Uid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// classes should call checkUidPurpose before using a SceUID </summary>
        /// <returns> true is the uid is ok.  </returns>
        public static bool checkUidPurpose(int uid, object purpose, bool allowUnknown)
        {
            SceUid found = uidMap[uid];

            if (found == null)
            {
                if (!allowUnknown)
                {
                    Emulator.Console.WriteLine("Attempt to use unknown SceUID (purpose='" + purpose.ToString() + "')");
                    return(false);
                }
            }
            else if (!purpose.Equals(found.Purpose))
            {
                Emulator.Console.WriteLine("Attempt to use SceUID for different purpose (purpose='" + purpose.ToString() + "',original='" + found.Purpose.ToString() + "')");
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// classes should call releaseUid when they are finished with a SceUID </summary>
        /// <returns> true on success.  </returns>
        public static bool releaseUid(int uid, object purpose)
        {
            SceUid found = uidMap[uid];

            if (found == null)
            {
                Emulator.Console.WriteLine("Attempt to release unknown SceUID (purpose='" + purpose.ToString() + "')");
                return(false);
            }

            if (purpose.Equals(found.Purpose))
            {
                uidMap.Remove(uid);
            }
            else
            {
                Emulator.Console.WriteLine("Attempt to release SceUID for different purpose (purpose='" + purpose.ToString() + "',original='" + found.Purpose.ToString() + "')");
                return(false);
            }

            return(true);
        }