示例#1
0
 internal TitlePlayedEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
 internal int sortns(XDBFEntry Ee, XDBFEntry Er)
 {
     return ((byte)Ee.NS).CompareTo((byte)Er.NS);
 }
示例#3
0
 /// <summary>
 /// Adds a game via the GPD
 /// </summary>
 /// <param name="xTitle"></param>
 /// <returns></returns>
 public bool AddGameViaGPD(GameGPD xTitle)
 {
     if (!ParseCheck())
         return false;
     if (xTitle.TitleID == 0 ||
         xTitle.TitleID == 0xFFFE07D1 || // Dash
         xTitle.TitleID == 0xFFFE07DE) // Avatar?
         return (xActive = false);
     foreach (TitlePlayedEntry x in xTitlesPlayed)
     {
         if (xTitle.TitleID != x.TitleID)
             continue;
         xActive = false;
         throw GPDExcepts.HasID;
     }
     try
     {
         string xName = xTitle.GetStringByID((long)GPDIDs.ThisTitle);
         if (xName == null)
         {
             xActive = false;
             throw GPDExcepts.NameError;
         }
         if (!xTitle.xErase())
             return (xActive = false);
         int xsize = 0x28 + ((xName.Length + 1) * 2);
         int xPosition = AllocateData(xsize);
         if (xPosition == -1)
             return (xActive = false);
         XDBFEntry xEnt = new XDBFEntry(NameSpace.Title, xTitle.TitleID, xPosition, xsize, this);
         xIO.Position = xPosition + HeaderSize;
         xIO.Write(xTitle.TitleID);
         xIO.Write((uint)xTitle.xAchievements.Count);
         xIO.Write(xTitle.xCalcUT());
         xIO.Write(xTitle.xCalcGSP());
         xIO.Write(xTitle.xCalcGST());
         xIO.Write(new byte[0x14]);
         xIO.Write(xName, StringForm.Unicode);
         xIO.Write((short)0);
         xIO.Flush();
         TitlePlayedEntry z = new TitlePlayedEntry(xEnt);
         if (!z.LoadDetails())
             return (xActive = false);
         xTitlesPlayed.Add(z);
         Setting x = xGetSetting(GPDIDs.GCardTitlesPlayed, SettingType.UInt32);
         if (x == null)
             xAddSetting((long)GPDIDs.GCardTitlesPlayed, xTitlesPlayed.Count, true, SyncType.Locale);
         else
         {
             uint xdata = (uint)x.Data;
             xdata++;
             x.Data = xdata;
             x.xUpdate(SyncType.Locale);
         }
         UpdateSync(NameSpace.Title, xTitle.TitleID, SyncType.Server);
         return (UpdateHeader() &
         !(xActive = false));
     }
     catch { return (xActive = false); }
 }
 internal XDBFEntry(XDBFEntry xCopy)
 {
     xOffset = xCopy.xOffset;
     xSize = xCopy.xSize;
     xNS = xCopy.xNS;
     xID = xCopy.xID;
     xRef = xCopy.xRef;
 }
 public FreeSpaceEntry(XDBFEntry xent)
 {
     xRef = xent.xRef;
     Size = xent.Size;
     offset = xent.xOffset;
 }
 internal StringEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
 internal SyncEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
 internal RecordEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
 internal Setting(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
示例#10
0
 internal ImageEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
示例#11
0
 internal OtherEntry(XDBFEntry xEntry)
     : base(xEntry)
 {
 }
示例#12
0
 XDBFEntry[] SortID(XDBFEntry[] xIn)
 {
     List<XDBFEntry> xTemp = new List<XDBFEntry>();
     foreach (XDBFEntry x in xIn)
         xTemp.Add(x);
     xTemp.Sort(new Comparison<XDBFEntry>(sortbyid));
     return xTemp.ToArray();
 }
示例#13
0
 int sortbyid(XDBFEntry x1, XDBFEntry x2)
 {
     return x1.ID.CompareTo(x2.ID);
 }
示例#14
0
 bool ContainsOther(XDBFEntry xEnt)
 {
     for (int i = 0; i < xUnknownData.Count; i++)
     {
         if (xUnknownData[i].ID != xEnt.ID)
             continue;
         new FreeSpaceEntry(xEnt);
         PatchFree();
         return true;
     }
     return false;
 }
示例#15
0
        bool ContainsEntry(XDBFEntry xEnt)
        {
            switch (xEnt.NS)
            {
                case NameSpace.Image:
                    {
                        for (int i = 0; i < xImages.Count; i++)
                        {
                            if (xImages[i].ID != xEnt.ID)
                                continue;
                            new FreeSpaceEntry(xEnt);
                            PatchFree();
                            return true;
                        }
                        return false;
                    }

                case NameSpace.Setting:
                    {
                        for (int i = 0; i < xUserSettings.Count; i++)
                        {
                            if (xUserSettings[i].ID != xEnt.ID)
                                continue;
                            new FreeSpaceEntry(xEnt);
                            PatchFree();
                            return true;
                        }
                        return false;
                    }

                case NameSpace.Title:
                    {
                        for (int i = 0; i < xTitlesPlayed.Count; i++)
                        {
                            if (xTitlesPlayed[i].ID == xEnt.ID)
                            {
                                new FreeSpaceEntry(xEnt);
                                PatchFree();
                                return true;
                            }
                        }
                        return false;
                    }

                case NameSpace.String:
                    {
                        for (int i = 0; i < xStrings.Count; i++)
                        {
                            if (xStrings[i].ID != xEnt.ID)
                                continue;
                            new FreeSpaceEntry(xEnt);
                            PatchFree();
                            return true;
                        }
                        return false;
                    }

                default:
                    return false;
            }
        }
示例#16
0
        internal bool xAddSetting(long ID, object Data, bool AutomaticOverwrite, SyncType xSync)
        {
            try
            {
                int idx = ContainsSetting(ID);
                if (idx != -1 && !AutomaticOverwrite)
                    return false;
                int xSize = 0x18;
                long pos = 0;
                SettingType xType = SettingType.Null;
                for (int i = 0; i < 2; i++)
                {
                    switch (Data.GetType().ToString().ToLower())
                    {
                        case "system.single":
                            {
                                if (i == 0)
                                    xType = SettingType.Float;
                                else
                                {
                                    xIO.Write((float)Data);
                                    xIO.Write((int)0);
                                }
                            }
                            break;

                        case "system.double":
                            {
                                if (i == 0)
                                    xType = SettingType.Double;
                                else
                                    xIO.Write((double)Data);
                            }
                            break;

                        case "system.int32":
                            {
                                if (i == 0)
                                    xType = SettingType.UInt32;
                                else
                                {
                                    xIO.Write((int)Data);
                                    xIO.Write((int)0);
                                }
                            }
                            break;

                        case "system.uint32":
                            {
                                if (i == 0)
                                    xType = SettingType.UInt32;
                                else
                                {
                                    xIO.Write((uint)Data);
                                    xIO.Write((uint)0);
                                }
                            }
                            break;

                        case "system.int64":
                            {
                                if (i == 0)
                                    xType = SettingType.Int64;
                                else
                                    xIO.Write((long)Data);
                            }
                            break;

                        case "system.datetime":
                            {
                                if (i == 0)
                                    xType = SettingType.DateTime;
                                else
                                    xIO.Write(((DateTime)Data).ToFileTime());
                            }
                            break;

                        case "system.byte[]":
                            {
                                if (i == 0)
                                {
                                    xType = SettingType.Binary;
                                    byte[] xIn = (byte[])Data;
                                    xSize += xIn.Length;
                                }
                                else
                                {
                                    byte[] xIn = (byte[])Data;
                                    xIO.Write(xIn.Length);
                                    xIO.Write(new byte[4]);
                                    xIO.Write(xIn);
                                }
                            }
                            break;

                        case "system.string":
                            {
                                if (i == 0)
                                {
                                    xType = SettingType.Unicode;
                                    string xIn = (string)Data;
                                    xSize += ((xIn.Length + 1) * 2);
                                }
                                else
                                {
                                    string xIn = (string)Data;
                                    xIO.Write((xIn.Length + 1) * 2);
                                    xIO.Write(new byte[4]);
                                    xIO.Write(xIn, StringForm.Unicode);
                                    xIO.Write((short)0);
                                }
                            }
                            break;

                        default:
                            return (xActive = false);
                    }
                    if (i == 0)
                    {
                        if (xType == SettingType.Null)
                            return false;
                        pos = AllocateData(xSize);
                        if (pos == -1)
                            return false;
                        else if (idx != -1)
                        {
                            xFreeEnts.Add(new FreeSpaceEntry(xUserSettings[idx]));
                            PatchFree();
                            xUserSettings.RemoveAt(idx);
                        }
                        xIO.Position = pos + HeaderSize;
                        xIO.Write((uint)ID);
                        xIO.Write(new byte[4]);
                        xIO.Write((byte)xType);
                        xIO.Write(new byte[7]);
                    }
                    else
                        xIO.Flush();
                }
                XDBFEntry xent = new XDBFEntry(NameSpace.Setting, ID, (int)pos, xSize, this);
                if (!xent.Valid)
                    return false;
                xUserSettings.Add(new Setting(xent));
                xUserSettings[xUserSettings.Count - 1].LoadDetails();
                if (xSync != SyncType.None)
                    UpdateSync(NameSpace.Setting, ID, xSync);
                return UpdateHeader();
            }
            catch { return false; }
        }