/// <summary> /// Updates a title from it's GPD /// </summary> /// <param name="xTitle"></param> /// <returns></returns> public bool UpdateTitle(GameGPD xTitle) { if (!ParseCheck()) { return(false); } if (xTitle.TitleID == 0 || xTitle.TitleID == 0xFFFE07D1 || // Dash xTitle.TitleID == 0xFFFE07DE) // Avatar? { return(xActive = false); } try { xTitle.FCAC(); bool xfound = false; foreach (TitlePlayedEntry x in xTitlesPlayed) { if (x.TitleID != xTitle.TitleID) { continue; } x.EarnedCount = xTitle.CalculateUnlockCount(); x.EarnedWorth = xTitle.CalculateTotalCred(); x.PossibleWorth = xTitle.CalculatePossibleCred(); x.xUpdate(); xfound = true; break; } if (!xfound) { return(xActive = false); } return(xUpdateGS(xCalcGST()) & !(xActive = false)); } catch { return(false); } }
/// <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); } }