Skip to content

Commit

Permalink
Beta 2, bugfixes and more verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Labreezy committed Aug 21, 2017
1 parent e480e9c commit 111bb84
Showing 1 changed file with 117 additions and 67 deletions.
184 changes: 117 additions & 67 deletions GGXrdWakeupDPUtil/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ private void MainWindow_Closed(object sender, EventArgs e)
{
idsource.Cancel();
}
if (session != null)
if (script != null)
{
script.Post("{\"type\": \"quit\"}");
script.Post("{\"type\": \"playback\"}");
script.Unload();
session.Detach();
}
}
Expand All @@ -196,41 +199,13 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e)
msggprocess = new MemorySharp(System.Diagnostics.Process.GetProcessesByName(ggprocname).First());
try
{
readAnimString(1);

checkAndSetFallbacks();
}
catch (Exception)
catch (AccessViolationException ex)
{
try
{
readFallbackAnimString(1);
fallbackp1 = true;
}
catch (Exception)
{
MessageBox.Show("You have GG open but are not in training mode! Open it up and pause the game before starting this program. This program will now close.");
Application.Current.Shutdown();
return;
}
}
try
{
readAnimString(2);

}
catch (Exception)
{
try
{
readFallbackAnimString(2);
fallbackp2 = true;
}
catch (Exception)
{
MessageBox.Show("You have GG open but are not in training mode! Open it up and pause the game before starting this program. This program will now close.");
Application.Current.Shutdown();
return;
}
MessageBox.Show(ex.Message);
Application.Current.Shutdown();
return;
}
setDummyID();
}
Expand Down Expand Up @@ -278,6 +253,43 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e)
Task.Run(() => updateIDLoop());
}

private void checkAndSetFallbacks()
{
try
{
readAnimString(1);
}
catch (Exception)
{
try
{
readFallbackAnimString(1);
fallbackp1 = true;
}
catch (Exception)
{
throw new AccessViolationException("P1 Animation Address Broke. (for future use) This program will now close.");
}
}
try
{
readAnimString(2);
}
catch (Exception)
{
try
{
readFallbackAnimString(2);
fallbackp2 = true;
}
catch (Exception)
{
throw new AccessViolationException("P2 Animation Address Broke. This program will now close.");
}
}
}


private void Script_Message(object sender, Frida.ScriptMessageEventArgs e)
{
var senderscript = (Frida.Script)sender;
Expand Down Expand Up @@ -319,7 +331,7 @@ private string readAnimString(int player)
return "";
}
private string readFallbackAnimString(int player)
{
{
if (player == 1)
{
var addr = (IntPtr)(msggprocess.Read<int>((IntPtr)P1AnimOffsets_fallback[0]));
Expand All @@ -340,6 +352,7 @@ private string readFallbackAnimString(int player)
}
return msggprocess.ReadString(IntPtr.Add(addr, P2AnimOffsets_fallback[6]), false, 32);
}

return "";
}
private void setDummyID()
Expand Down Expand Up @@ -407,6 +420,15 @@ private void enableButton_Click(object sender, RoutedEventArgs e)
Slot2R.IsEnabled = false;
Slot3R.IsEnabled = false;
disableButton.IsEnabled = true;
try
{
checkAndSetFallbacks();
} catch (AccessViolationException ex)
{
MessageBox.Show(ex.Message);
Application.Current.Shutdown();
return;
}
session = localdev.Attach((uint)msggprocess.Pid);
script = session.CreateScript(scriptsrc);
script.Message += Script_Message;
Expand Down Expand Up @@ -441,58 +463,85 @@ private void enableLoop(bool useFallback, int wakeupframeidx)
{
while (!token.IsCancellationRequested)
{
int wakeuptiming = 0;
if (facedown == readFallbackAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceDownFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
else if (faceup == readFallbackAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceUpFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
if (wakeuptiming == 0)
try
{
continue;
int wakeuptiming = 0;
if (facedown == readFallbackAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceDownFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
else if (faceup == readFallbackAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceUpFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
if (wakeuptiming == 0)
{
continue;
}
else
{
script.Post("{\"type\": \"playback\"}");
}
}
else
catch (Exception)
{
MessageBox.Show("P2's animation address broke/has changed while enabled (using fallback address). This program will now shut down. If this issue persists, contact me.");
script.Post("{\"type\": \"quit\"}");
script.Post("{\"type\": \"playback\"}");
script.Unload();
session.Detach();
Application.Current.Shutdown();
return;
}
}
}
else
{
while (!token.IsCancellationRequested)
{
int wakeuptiming = 0;
if (facedown == readAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceDownFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
else if (faceup == readAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceUpFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
if (wakeuptiming == 0)
try
{
continue;
int wakeuptiming = 0;
if (facedown == readAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceDownFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
else if (faceup == readAnimString(2))
{
wakeuptiming = nameWakeupDataList[currentDummyId].faceUpFrames;
Task framewait = Task.Run(() => waitFrames(wakeuptiming - wakeupframeidx - 1));
framewait.Wait();
}
if (wakeuptiming == 0)
{
continue;
}
else
{
script.Post("{\"type\": \"playback\"}");
}
}
else
catch (Exception)
{
MessageBox.Show("P2's animation address broke/has changed while enabled. This program will now shut down. If this issue persists, contact me.");
script.Post("{\"type\": \"quit\"}");
script.Post("{\"type\": \"playback\"}");
script.Unload();
session.Detach();
Application.Current.Shutdown();
return;
}
}
}
idsource = new CancellationTokenSource();
idtoken = idsource.Token;
Task.Run(() => updateIDLoop());
}


Expand All @@ -510,6 +559,7 @@ private void disableButton_Click(object sender, RoutedEventArgs e)
source.Cancel();
source.Dispose();
script.Post("{\"type\": \"quit\"}");
script.Post("{\"type\": \"playback\"}");
script.Unload();
session.Detach();
enableButton.IsEnabled = true;
Expand Down

0 comments on commit 111bb84

Please sign in to comment.