Exemplo n.º 1
0
        public void Test_DeleteOriginalMapFileBackup_Folder_Exists_DeletesCorrectly()
        {
            SessionPath.ToSession = "D:\\Session_Modding\\Session_Experiment";
            UnpackUtils.DeleteOriginalMapFileBackup();

            Assert.IsFalse(Directory.Exists(SessionPath.ToOriginalSessionMapFiles));
        }
Exemplo n.º 2
0
        private void LoadMapInBackgroundAndContinueWith(Action <Task> continuationTask)
        {
            if (SessionPath.IsSessionPathValid() == false)
            {
                System.Windows.MessageBox.Show("You have selected an incorrect path to Session. Make sure the directory you choose has the folders 'Engine' and 'SessionGame'.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }



            if (EzPzPatcher.IsGamePatched() == false && ViewModel.IsSessionUnpacked())
            {
                if (ViewModel.IsOriginalMapFilesBackedUp() == false)
                {
                    System.Windows.MessageBox.Show("The original Session game map files have not been backed up yet. Click OK to backup the files then click 'Load Map' again.",
                                                   "Notice!",
                                                   MessageBoxButton.OK,
                                                   MessageBoxImage.Information);

                    ViewModel.BackupOriginalMapFiles();
                    return;
                }
            }

            if (lstMaps.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Select a map to load first!",
                                               "Notice!",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Information);
                return;
            }


            MapListItem selectedItem = lstMaps.SelectedItem as MapListItem;

            if (selectedItem.IsValid == false)
            {
                System.Windows.MessageBox.Show("This map is missing the required Game Mode Override 'PBP_InGameSessionGameMode'.\n\nAdd a Game Mode to your map in UE4: '/Content/Data/PBP_InGameSessionGameMode.uasset'.\nThen reload the list of available maps.",
                                               "Error!",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Error);
                return;
            }

            ViewModel.UserMessage          = $"Loading {selectedItem.MapName} ...";
            ViewModel.InputControlsEnabled = false;

            Task t = Task.Run(() => ViewModel.LoadSelectedMap(selectedItem));

            t.ContinueWith(continuationTask);
        }
Exemplo n.º 3
0
        private void BtnImportMap_Click(object sender, RoutedEventArgs e)
        {
            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            importContextMenu.IsOpen = true;
        }
Exemplo n.º 4
0
        public void Test_DeleteOriginalMapFileBackup_Folder_Exists_DeletesCorrectly()
        {
            SessionPath.ToSession = TestPaths.ToSessionTestFolder;
            Directory.CreateDirectory(SessionPath.ToOriginalSessionMapFiles); // ensure direct exists before testing delete


            UnpackUtils.DeleteOriginalMapFileBackup();

            Assert.IsFalse(Directory.Exists(SessionPath.ToOriginalSessionMapFiles));
        }
Exemplo n.º 5
0
        private void BtnApplySettings_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.InputControlsEnabled == false)
            {
                return;
            }

            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (GameSettingsManager.DoesObjectPlacementFileExist() == false)
            {
                MessageBoxResult promptResult = System.Windows.MessageBox.Show("The required file is missing and must be extracted before object count can be modified.\n\nClick 'Yes' to extract the file (UnrealPak and crypto.json will be downloaded if it is not installed locally).",
                                                                               "Warning - Cannot Modify Object Count!",
                                                                               MessageBoxButton.YesNo,
                                                                               MessageBoxImage.Information,
                                                                               MessageBoxResult.Yes);

                if (promptResult == MessageBoxResult.Yes)
                {
                    ViewModel.StartPatching(skipPatching: true, skipUnpacking: false, unrealPathFromRegistry: RegistryHelper.GetPathToUnrealEngine());
                    return;
                }
            }


            bool didSet = ViewModel.UpdateGameSettings();


            if (didSet)
            {
                ViewModel.UserMessage = "Game settings updated!";

                if (SessionPath.IsSessionRunning())
                {
                    ViewModel.UserMessage += " Restart the game for changes to take effect.";
                }
            }
        }
Exemplo n.º 6
0
    ///////////////////////////// executable code ////////////////////////////////


    // This function reads data from the specified stream in search of a valid
    // WavPack 4.0 audio block. If this fails in 1 megabyte (or an invalid or
    // unsupported WavPack block is encountered) then an appropriate message is
    // copied to "error" and NULL is returned, otherwise a pointer to a
    // WavpackContext structure is returned (which is used to call all other
    // functions in this module). This can be initiated at the beginning of a
    // WavPack file, or anywhere inside a WavPack file. To determine the exact
    // position within the file use WavpackGetSampleIndex().  Also,
    // this function will not handle "correction" files, plays only the first
    // two channels of multi-channel files, and is limited in resolution in some
    // large integer or floating point files (but always provides at least 24 bits
    // of resolution).

    public static WavpackContext WavpackOpenFileInput(System.IO.BinaryReader infile)
    {
        WavpackContext wpc = new WavpackContext();
        WavpackStream  wps = wpc.stream;

        wpc.infile        = infile;
        wpc.total_samples = -1;
        wpc.norm_offset   = 0;
        wpc.open_flags    = 0;


        // open the source file for reading and store the size

        while (wps.wphdr.block_samples == 0)
        {
            wps.wphdr = read_next_header(wpc.infile, wps.wphdr);

            if (wps.wphdr.status == 1)
            {
                wpc.error_message = "not compatible with this version of WavPack file!";
                wpc.error         = true;
                return(wpc);
            }

            if (wps.wphdr.block_samples > 0 && wps.wphdr.total_samples != -1)
            {
                wpc.total_samples = wps.wphdr.total_samples;
            }

            // lets put the stream back in the context

            wpc.stream = wps;

            if ((UnpackUtils.unpack_init(wpc)) == Defines.FALSE)
            {
                wpc.error = true;
                return(wpc);
            }
        }         // end of while

        wpc.config.flags = wpc.config.flags & ~0xff;
        wpc.config.flags = wpc.config.flags | (wps.wphdr.flags & 0xff);

        wpc.config.bytes_per_sample = (int)((wps.wphdr.flags & Defines.BYTES_STORED) + 1);
        wpc.config.float_norm_exp   = wps.float_norm_exp;

        wpc.config.bits_per_sample = (int)((wpc.config.bytes_per_sample * 8) - ((wps.wphdr.flags & Defines.SHIFT_MASK) >> Defines.SHIFT_LSB));

        if ((wpc.config.flags & Defines.FLOAT_DATA) > 0)
        {
            wpc.config.bytes_per_sample = 3;
            wpc.config.bits_per_sample  = 24;
        }

        if (wpc.config.sample_rate == 0)
        {
            if (wps.wphdr.block_samples == 0 || (wps.wphdr.flags & Defines.SRATE_MASK) == Defines.SRATE_MASK)
            {
                wpc.config.sample_rate = 44100;
            }
            else
            {
                wpc.config.sample_rate = sample_rates[(int)((wps.wphdr.flags & Defines.SRATE_MASK) >> Defines.SRATE_LSB)];
            }
        }

        if (wpc.config.num_channels == 0)
        {
            if ((wps.wphdr.flags & Defines.MONO_FLAG) > 0)
            {
                wpc.config.num_channels = 1;
            }
            else
            {
                wpc.config.num_channels = 2;
            }

            wpc.config.channel_mask = 0x5 - wpc.config.num_channels;
        }

        if ((wps.wphdr.flags & Defines.FINAL_BLOCK) == 0)
        {
            if ((wps.wphdr.flags & Defines.MONO_FLAG) != 0)
            {
                wpc.reduced_channels = 1;
            }
            else
            {
                wpc.reduced_channels = 2;
            }
        }

        return(wpc);
    }
Exemplo n.º 7
0
    // Unpack the specified number of samples from the current file position.
    // Note that "samples" here refers to "complete" samples, which would be
    // 2 longs for stereo files. The audio data is returned right-justified in
    // 32-bit longs in the endian mode native to the executing processor. So,
    // if the original data was 16-bit, then the values returned would be
    // +/-32k. Floating point data will be returned as 24-bit integers (and may
    // also be clipped). The actual number of samples unpacked is returned,
    // which should be equal to the number requested unless the end of fle is
    // encountered or an error occurs.

    internal static long WavpackUnpackSamples(WavpackContext wpc, int[] buffer, long samples)
    {
        WavpackStream wps = wpc.stream;
        long          samples_unpacked = 0, samples_to_unpack;
        int           num_channels = wpc.config.num_channels;
        int           bcounter     = 0;

        int buf_idx        = 0;
        int bytes_returned = 0;

        while (samples > 0)
        {
            if (wps.wphdr.block_samples == 0 || (wps.wphdr.flags & Defines.INITIAL_BLOCK) == 0 || wps.sample_index >= wps.wphdr.block_index + wps.wphdr.block_samples)
            {
                wps.wphdr = read_next_header(wpc.infile, wps.wphdr);

                if (wps.wphdr.status == 1)
                {
                    break;
                }

                if (wps.wphdr.block_samples == 0 || wps.sample_index == wps.wphdr.block_index)
                {
                    if ((UnpackUtils.unpack_init(wpc)) == Defines.FALSE)
                    {
                        break;
                    }
                }
            }

            if (wps.wphdr.block_samples == 0 || (wps.wphdr.flags & Defines.INITIAL_BLOCK) == 0 || wps.sample_index >= wps.wphdr.block_index + wps.wphdr.block_samples)
            {
                continue;
            }

            if (wps.sample_index < wps.wphdr.block_index)
            {
                samples_to_unpack = wps.wphdr.block_index - wps.sample_index;

                if (samples_to_unpack > samples)
                {
                    samples_to_unpack = samples;
                }

                wps.sample_index += samples_to_unpack;
                samples_unpacked += samples_to_unpack;
                samples          -= samples_to_unpack;

                if (wpc.reduced_channels > 0)
                {
                    samples_to_unpack *= wpc.reduced_channels;
                }
                else
                {
                    samples_to_unpack *= num_channels;
                }

                bcounter = buf_idx;

                while (samples_to_unpack > 0)
                {
                    buffer[bcounter] = 0;
                    bcounter++;
                    samples_to_unpack--;
                }
                buf_idx = bcounter;

                continue;
            }

            samples_to_unpack = wps.wphdr.block_index + wps.wphdr.block_samples - wps.sample_index;

            if (samples_to_unpack > samples)
            {
                samples_to_unpack = samples;
            }

            UnpackUtils.unpack_samples(wpc, buffer, samples_to_unpack, buf_idx);

            if (wpc.reduced_channels > 0)
            {
                bytes_returned = (int)(samples_to_unpack * wpc.reduced_channels);
            }
            else
            {
                bytes_returned = (int)(samples_to_unpack * num_channels);
            }

            buf_idx += bytes_returned;

            samples_unpacked += samples_to_unpack;
            samples          -= samples_to_unpack;

            if (wps.sample_index == wps.wphdr.block_index + wps.wphdr.block_samples)
            {
                if (UnpackUtils.check_crc_error(wpc) > 0)
                {
                    wpc.crc_errors++;
                }
            }

            if (wps.sample_index == wpc.total_samples)
            {
                break;
            }
        }

        return(samples_unpacked);
    }
Exemplo n.º 8
0
    internal static int process_metadata(WavpackContext wpc, WavpackMetadata wpmd)
    {
        WavpackStream wps = wpc.stream;

        switch (wpmd.id)
        {
        case Defines.ID_DUMMY:
        {
            return(Defines.TRUE);
        }


        case Defines.ID_DECORR_TERMS:
        {
            return(UnpackUtils.read_decorr_terms(wps, wpmd));
        }


        case Defines.ID_DECORR_WEIGHTS:
        {
            return(UnpackUtils.read_decorr_weights(wps, wpmd));
        }


        case Defines.ID_DECORR_SAMPLES:
        {
            return(UnpackUtils.read_decorr_samples(wps, wpmd));
        }


        case Defines.ID_ENTROPY_VARS:
        {
            return(WordsUtils.read_entropy_vars(wps, wpmd));
        }


        case Defines.ID_HYBRID_PROFILE:
        {
            return(WordsUtils.read_hybrid_profile(wps, wpmd));
        }


        case Defines.ID_FLOAT_INFO:
        {
            return(FloatUtils.read_float_info(wps, wpmd));
        }


        case Defines.ID_INT32_INFO:
        {
            return(UnpackUtils.read_int32_info(wps, wpmd));
        }


        case Defines.ID_CHANNEL_INFO:
        {
            return(UnpackUtils.read_channel_info(wpc, wpmd));
        }


        case Defines.ID_SAMPLE_RATE:
        {
            return(UnpackUtils.read_sample_rate(wpc, wpmd));
        }


        case Defines.ID_CONFIG_BLOCK:
        {
            return(UnpackUtils.read_config_info(wpc, wpmd));
        }


        case Defines.ID_WV_BITSTREAM:
        {
            return(UnpackUtils.init_wv_bitstream(wpc, wpmd));
        }


        case Defines.ID_SHAPING_WEIGHTS:
        case Defines.ID_WVC_BITSTREAM:
        case Defines.ID_WVX_BITSTREAM:
        {
            return(Defines.TRUE);
        }


        default:
        {
            if ((wpmd.id & Defines.ID_OPTIONAL_DATA) != 0)
            {
                return(Defines.TRUE);
            }
            else
            {
                return(Defines.FALSE);
            }
        }
        break;
        }
    }