Merge branch 'BuddyFriendGuy/fixVolumeReset' into 'master'

fix volume value preservation bug in NexuizDemoRecorder

Symptom: In the original code, the user's original volume value is not preserved (the default behavior is to mute the volume during fast forward) so the program fails to set the correct volume value back -- in fact it sets it to an illegal variable name.

Code problem: This bug happens in the case of user choosing to record the demo early on, i.e. the loop enters the second stage right away, so injectAtStart was never executed. Besides, srvLoop and firstLoop seem to do the same thing.

Fix: Make sure injectAtStart is executed exactly once.

See merge request !12
This commit is contained in:
Ant Zucaro 2015-06-23 12:56:37 +00:00
commit 97c6fdd825
3 changed files with 17 additions and 21 deletions

View File

@ -4,7 +4,7 @@
<groupId>NexuizDemoRecorder</groupId>
<artifactId>NexuizDemoRecorder</artifactId>
<packaging>jar</packaging>
<version>0.3</version>
<version>0.3.1</version>
<name>NexuizDemoRecorder</name>
<url>http://maven.apache.org</url>
<dependencies>

View File

@ -63,7 +63,6 @@ public class DemoCutter {
boolean endIsReached = false;
boolean finalInjectionDone = false;
boolean disconnectIssued = false;
int svcLoops = 0;
float firstSvcTime = -1;
float lastSvcTime = -1;
@ -96,42 +95,39 @@ public class DemoCutter {
}
lastSvcTime = svctime;
if (firstLoop) {
injectBuffer = "\011\n" + injectAtStart + ";slowmo " + ffwSpeedFirstStage + "\n\000";
firstLoop = false;
}
if (demoStarted < 1 && svctime > (startTime - 50)) {
if (svcLoops == 0) {
//make sure that for short demos (duration less than 50 sec)
//the injectAtStart is still honored
injectBuffer = "\011\n" + injectAtStart + ";slowmo " + ffwSpeedSecondStage + "\n\000";
} else {
injectBuffer = "\011\nslowmo " + ffwSpeedSecondStage + "\n\000";
}
injectBuffer = "slowmo " + ffwSpeedSecondStage;
demoStarted = 1;
}
if (demoStarted < 2 && svctime > (startTime - 5)) {
injectBuffer = "\011\nslowmo 1;" + injectBeforeCap +"\n\000";
injectBuffer = "slowmo 1;" + injectBeforeCap;
demoStarted = 2;
}
if (demoStarted < 3 && svctime > startTime) {
injectBuffer = "\011\ncl_capturevideo 1\n\000";
injectBuffer = "cl_capturevideo 1";
demoStarted = 3;
}
if (!endIsReached && svctime > endTime) {
injectBuffer = "\011\ncl_capturevideo 0\n\000";
injectBuffer = "cl_capturevideo 0";
endIsReached = true;
}
if (endIsReached && !finalInjectionDone && svctime > (endTime + 1)) {
injectBuffer = "\011\n" + injectAfterCap + "\n\000";
injectBuffer = injectAfterCap;
finalInjectionDone = true;
}
if (finalInjectionDone && !disconnectIssued && svctime > (endTime + 2)) {
injectBuffer = "\011\ndisconnect\n\000";
injectBuffer = "disconnect";
disconnectIssued = true;
}
svcLoops++;
// ensure injectAtStart runs exactly once, before everything else
if (firstLoop) {
injectBuffer = injectAtStart + ";slowmo " + ffwSpeedFirstStage + ";" + injectBuffer;
firstLoop = false;
}
// add Buffer head and tail
if (injectAtStart.length() > 0) {
injectBuffer = "\011\n" + checkInjectString(injectBuffer) + "\n\000";
}
}
byte[] injectBufferAsBytes = null;

View File

@ -144,7 +144,7 @@ public class SwingGUI extends JFrame implements WindowListener, DemoRecorderUI {
private static final String mainHelpSetName = "help/DemoRecorderHelp.hs";
public SwingGUI(DemoRecorderApplication appLayer) {
super("Nexuiz Demo Recorder v0.3");
super("Nexuiz Demo Recorder v0.3.1");
addWindowListener(this);
this.appLayer = appLayer;