Beispiel #1
0
        private bool HasAtLeastOneValidSave(byte[] bytes)
        {
            for (int i = 0; i < 15; i++)
            {
                if (Savegame.IsValidPSPGame(bytes, (int)(i * Savegame.saveFileSize)))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        private void TryReadFile(byte[] bytes)
        {
            try
            {
                bool validGameFound = false;
                for (int i = 0; (i < 15) && (((i + 1) * Savegame.saveFileSize) < bytes.Length); i++)
                {
                    if (Savegame.IsValidPSPGame(bytes, (int)(i * Savegame.saveFileSize)))
                    {
                        usingGME       = false;
                        validGameFound = true;
                        byte[] saveData = new byte[Savegame.saveFileSize];
                        Array.Copy(bytes, i * Savegame.saveFileSize, saveData, 0, Savegame.saveFileSize);

                        games[i] = new Savegame(saveData);
                        gameSelector.Items.Add(games[i]);
                    }
                    else
                    {
                        games[i] = null;
                    }
                }

                //if (!validGameFound)
                // TODO: fix GME importing
                if (false)
                {
                    // Try GME...
                    usingGME = true;
                    foreach (int i in ValidateGMEFile(bytes))
                    {
                        byte[] saveData = new byte[0x2000];
                        if ((bytes.Length + 1) < 0x2F40 + i * 0x2000)
                        {
                            break;
                        }
                        Array.Copy(bytes, 0x2F40 + i * 0x2000, saveData, 0, 0x2000);

                        games[i] = new Savegame(saveData);
                        gameSelector.Items.Add(games[i]);
                    }
                }
            }
            catch (Exception)
            {
                // Fail silently!!
            }
        }
Beispiel #3
0
        private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button == openButton)
            {
                DialogResult result = openFileDialog.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    System.IO.FileStream stream = new System.IO.FileStream(openFileDialog.FileName, System.IO.FileMode.Open);

                    byte[] bytes = new byte[stream.Length];
                    stream.Read(bytes, 0, (int)stream.Length);
                    stream.Close();

                    games     = new List <List <Character> >();
                    gameNames = new List <string>();

                    gameSelector.Items.Clear();

                    try
                    {
                        bool validGameFound = false;
                        for (int i = 0; (i < 15) && (((i + 1) * Savegame.saveFileSize) < bytes.Length); i++)
                        {
                            if (Savegame.IsValidPSPGame(bytes, (int)(i * Savegame.saveFileSize)))
                            {
                                validGameFound = true;
                                byte[] saveData = new byte[Savegame.saveFileSize];
                                Array.Copy(bytes, i * Savegame.saveFileSize, saveData, 0, Savegame.saveFileSize);

                                Savegame g = new Savegame(saveData);
                                gameNames.Add(g.ToString());
                                games.Add(g.Characters);
                            }
                        }

                        if (!validGameFound)
                        {
                            // Try GME...
                            foreach (int i in MainForm.ValidateGMEFile(bytes))
                            {
                                byte[] saveData = new byte[0x2000];
                                if ((bytes.Length + 1) < 0x2F40 + i * 0x2000)
                                {
                                    break;
                                }
                                Array.Copy(bytes, 0x2F40 + i * 0x2000, saveData, 0, 0x2000);

                                Savegame g = new Savegame(saveData);
                                gameNames.Add(g.ToString());
                                games.Add(g.Characters);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // Fail silently!!
                    }

                    gameSelector.Items.AddRange(gameNames.ToArray());

                    if (gameSelector.Items.Count > 0)
                    {
                        gameSelector.SelectedIndex = 0;
                    }

                    gameSelector.Enabled = true;
                }
            }
        }