예제 #1
0
            /// ------------------------------------------------------------------------------------
            public bool TryUpdate(SegmentChange newChange)
            {
                if (NewRange == newChange.OriginalRange && newChange.Type == SegmentChangeType.EndBoundaryMoved)
                {
                    NewRange = newChange.NewRange;
                    return(true);
                }
                if (newChange.Type == SegmentChangeType.Addition && Type == SegmentChangeType.AnnotationAdded &&
                    newChange.NewRange == OriginalRange)
                {
                    _type = SegmentChangeType.Addition;
                    Action <SegmentChange> originalUndoAction = UndoAction;
                    UndoAction = c => { originalUndoAction(c); newChange.UndoAction(c); };
                    return(true);
                }
                if (newChange.Type == SegmentChangeType.AnnotationDeleted && Type == SegmentChangeType.AnnotationDeleted &&
                    newChange.NewRange == OriginalRange)
                {
                    Action <SegmentChange> originalUndoAction = UndoAction;
                    UndoAction = c => { originalUndoAction(c); newChange.UndoAction(c); };
                    return(true);
                }
                if (newChange.Type == SegmentChangeType.Addition && Type == SegmentChangeType.AnnotationDeleted &&
                    newChange.NewRange.Start == OriginalRange.Start)
                {
                    Action <SegmentChange> originalUndoAction = UndoAction;
                    UndoAction = c => { originalUndoAction(c); newChange.UndoAction(c); };
                    return(true);
                }

                return(false);
            }
예제 #2
0
        private void PokeXenonPatch()
        {
            try
            {
                if (App.AssemblyStorage.AssemblySettings.Xbdm == null ||
                    String.IsNullOrEmpty(App.AssemblyStorage.AssemblySettings.Xbdm.DeviceIdent))
                {
                    MetroMessageBox.Show("No Xbox 360 Console Detected",
                                         "Make sure your xbox 360 console is turned on, and the IP is entered in the App.AssemblyStorage.AssemblySettings.");
                    return;
                }

                if (currentPatchToPoke.MetaChangesIndex >= 0)
                {
                    if (currentPatchToPoke.SegmentChanges.Count > 1)
                    {
                        if (MetroMessageBox.Show("Possible unexpected results ahead!",
                                                 "This patch contains edits to segments other than the meta, ie locales and the file header, it could crash if you continue. \n\nDo you wish to continue?",
                                                 MetroMessageBox.MessageBoxButtons.YesNo) == MetroMessageBox.MessageBoxResult.No)
                        {
                            return;
                        }
                    }

                    SegmentChange changes = currentPatchToPoke.SegmentChanges[currentPatchToPoke.MetaChangesIndex];
                    if (changes.OldSize != changes.NewSize)
                    {
                        // can't poke, patch injects meta
                        MetroMessageBox.Show("Unable to Poke Patch",
                                             "This patch contains meta that has been injected, and can't be poked.");
                        return;
                    }

                    foreach (DataChange change in changes.DataChanges)
                    {
                        App.AssemblyStorage.AssemblySettings.Xbdm.MemoryStream.Seek(currentPatchToPoke.MetaPokeBase + change.Offset,
                                                                                    SeekOrigin.Begin);
                        App.AssemblyStorage.AssemblySettings.Xbdm.MemoryStream.Write(change.Data, 0x00, change.Data.Length);
                    }
                }
                else if (currentPatchToPoke.MetaChanges.Count > 0)
                {
                    foreach (DataChange change in currentPatchToPoke.MetaChanges)
                    {
                        App.AssemblyStorage.AssemblySettings.Xbdm.MemoryStream.Seek(change.Offset, SeekOrigin.Begin);
                        App.AssemblyStorage.AssemblySettings.Xbdm.MemoryStream.Write(change.Data, 0x00, change.Data.Length);
                    }
                }

                MetroMessageBox.Show("Patch Poked!", "Your patch has been poked successfully. Have fun!");
            }
            catch (Exception ex)
            {
                MetroException.Show(ex);
            }
        }
예제 #3
0
 /// ------------------------------------------------------------------------------------
 public void Push(SegmentChange segmentChange)
 {
     if (!_inUndo)
     {
         if (_undoStack.Count == 0 || !_undoStack.Peek().TryUpdate(segmentChange))
         {
             _undoStack.Push(segmentChange);
         }
     }
 }
예제 #4
0
 public async Task <SegmentChange> Fetch(string name, long since)
 {
     try
     {
         segmentChange = await FetchFromBackend(name, since);
     }
     catch (Exception e)
     {
         Log.Error(string.Format("Exception caught executing fetch segment changes since={0}", since), e);
         segmentChange = null;
     }
     return(segmentChange);
 }
예제 #5
0
        private void PokePCPatch()
        {
            try
            {
                if (string.IsNullOrEmpty(currentPatchToPoke.BuildString))
                {
                    return;
                }

                var pokeInfo = App.AssemblyStorage.AssemblySettings.DefaultDatabase.FindEngineByVersion(currentPatchToPoke.BuildString);
                if (pokeInfo == null)
                {
                    MetroMessageBox.Show("Unsupported Build",
                                         "This patch is for a build (" + currentPatchToPoke.BuildString + ") that this installation of Assembly does not support. Make sure you are up to date or add a definition manually.");
                    return;
                }

                if (pokeInfo.Name.Contains("Vista"))
                {
                    MetroMessageBox.Show("Unsupported Build",
                                         "This patch is for Halo 2 Vista which cannot be poked at this time.");
                    return;
                }

                if (string.IsNullOrEmpty(pokeInfo.GameExecutable) || string.IsNullOrEmpty(pokeInfo.GameModule) || pokeInfo.Poking == null)
                {
                    MetroMessageBox.Show("Unsupported Build",
                                         "This patch is for a build (" + pokeInfo.Version + ") that this installation of Assembly does not have enough information for to poke patches.\r\n" +
                                         "This includes a gameExecutable and gameModule value and a poking definition which includes a pointer with the game version you are running.\r\n" +
                                         "Make sure you are up to date or add a definition manually.");
                    return;
                }



                var gameRTE    = new ThirdGenMCCRTEProvider(pokeInfo);
                var gameStream = gameRTE.GetMetaStream();

                if (currentPatchToPoke.MetaChangesIndex >= 0)
                {
                    if (currentPatchToPoke.SegmentChanges.Count > 1)
                    {
                        if (MetroMessageBox.Show("Possible unexpected results ahead!",
                                                 "This patch contains edits to segments other than the meta, ie locales and the file header, it could crash if you continue. \n\nDo you wish to continue?",
                                                 MetroMessageBox.MessageBoxButtons.YesNo) == MetroMessageBox.MessageBoxResult.No)
                        {
                            return;
                        }
                    }

                    SegmentChange changes = currentPatchToPoke.SegmentChanges[currentPatchToPoke.MetaChangesIndex];
                    if (changes.OldSize != changes.NewSize)
                    {
                        // can't poke, patch injects meta
                        MetroMessageBox.Show("Unable to Poke Patch",
                                             "This patch contains meta that has been injected, and can't be poked.");
                        return;
                    }

                    foreach (DataChange change in changes.DataChanges)
                    {
                        gameStream.BaseStream.Seek(currentPatchToPoke.MetaPokeBase + change.Offset,
                                                   SeekOrigin.Begin);
                        gameStream.BaseStream.Write(change.Data, 0x00, change.Data.Length);
                    }
                }
                else if (currentPatchToPoke.MetaChanges.Count > 0)
                {
                    foreach (DataChange change in currentPatchToPoke.MetaChanges)
                    {
                        gameStream.BaseStream.Seek(change.Offset, SeekOrigin.Begin);
                        gameStream.BaseStream.Write(change.Data, 0x00, change.Data.Length);
                    }
                }

                MetroMessageBox.Show("Patch Poked!", "Your patch has been poked successfully. Have fun!");
            }
            catch (Exception ex)
            {
                MetroException.Show(ex);
            }
        }
예제 #6
0
 /// ------------------------------------------------------------------------------------
 protected override void RevertNewSegment(SegmentChange change)
 {
     base.RevertNewSegment(change);
     NewSegmentEndBoundary = _endBoundary = GetEndOfLastSegment();
 }
예제 #7
0
 /// ------------------------------------------------------------------------------------
 protected virtual void RevertNewSegment(SegmentChange change)
 {
     DeleteBoundary(change.NewRange.End);
 }
예제 #8
0
 public void onSegmentChange(string entrySegemnt, string leaveSegment)
 {
     SegmentChange?.Invoke(this, new SegmentChangeEventArgs(entrySegemnt, leaveSegment));
 }
 private static void InvokeSegmentChangedEvent(MeshReconstructionServer.SegmentChangedDelegate onSegmentChanged, GridIndex gridIndex, SegmentChange changeType, double updateTime)
 {
     if (onSegmentChanged != null)
     {
         onSegmentChanged(gridIndex, changeType, updateTime);
     }
 }