fixed some undo and redo bugs

This commit is contained in:
Lexi Quinn 2023-07-25 21:30:55 +10:00
parent 0812d68dd1
commit 47369a86e9

View File

@ -149,6 +149,7 @@ void add_event(enum event_type t)
offset_timespec(timerOffset, &run[runMarker].time); offset_timespec(timerOffset, &run[runMarker].time);
runMarker++; runMarker++;
runMarker2 = runMarker; runMarker2 = runMarker;
hasUndoneAtLeastOnce = false;
} }
void reset_timer() void reset_timer()
@ -251,11 +252,12 @@ void subtractPauseTime()
void undo() void undo()
{ {
if (!timerActive) return;
if (runMarker > 0) { if (runMarker > 0) {
runMarker--; runMarker--;
if (run[runMarker].type == STOP) if (run[runMarker].type == STOP) {
timerActive = true; timerActive = true;
runUnsaved = false;
}
if (run[runMarker].type == START) if (run[runMarker].type == START)
timerActive = false; timerActive = false;
if (run[runMarker].type == PAUSE) if (run[runMarker].type == PAUSE)
@ -273,8 +275,11 @@ void redo()
if (!timerActive) return; if (!timerActive) return;
if (runMarker < runMarker2) { if (runMarker < runMarker2) {
runMarker++; runMarker++;
if (run[runMarker - 1].type == STOP) if (run[runMarker - 1].type == STOP) {
timerActive = false; timerActive = false;
runUnsaved = true;
finish = run[runMarker - 1].time;
}
if (run[runMarker - 1].type == START) if (run[runMarker - 1].type == START)
timerActive = true; timerActive = true;
if (run[runMarker - 1].type == PAUSE) if (run[runMarker - 1].type == PAUSE)
@ -283,7 +288,8 @@ void redo()
paused = false; paused = false;
addPauseTime(); addPauseTime();
} }
} else { }
if (runMarker == runMarker2) {
hasUndoneAtLeastOnce = false; hasUndoneAtLeastOnce = false;
} }
} }
@ -546,70 +552,49 @@ void doprocessing (int sock)
exit(1); exit(1);
} }
if (!strcmp(token, "current_time")) { if (!strcmp(token, "current_time")) {
//printf("Recieved time command\n");
sendInt(sock, current_ms()); sendInt(sock, current_ms());
} else if (!strcmp(token, "start")) { } else if (!strcmp(token, "start")) {
printf("Recieved start command\n");
start(); start();
} else if (!strcmp(token, "stop")) { } else if (!strcmp(token, "stop")) {
printf("Recieved stop command\n");
stop(); stop();
} else if (!strcmp(token, "kill")) { } else if (!strcmp(token, "kill")) {
printf("Recieved kill command\n");
alive = false; alive = false;
} else if (!strcmp(token, "split")) { } else if (!strcmp(token, "split")) {
printf("Recieved split command\n");
split(); split();
} else if (!strcmp(token, "skip")) { } else if (!strcmp(token, "skip")) {
printf("Recieved skip command\n");
skip(); skip();
} else if (!strcmp(token, "pause")) { } else if (!strcmp(token, "pause")) {
printf("Recieved pause command\n");
pause_timer(); pause_timer();
} else if (!strcmp(token, "resume")) { } else if (!strcmp(token, "resume")) {
printf("Recieved resume command\n");
resume(); resume();
} else if (!strcmp(token, "undo")) { } else if (!strcmp(token, "undo")) {
printf("Recieved undo command\n");
undo(); undo();
} else if (!strcmp(token, "redo")) { } else if (!strcmp(token, "redo")) {
printf("Recieved redo command\n");
redo(); redo();
} else if (!strcmp(token, "save")) { } else if (!strcmp(token, "save")) {
printf("Recieved save command\n");
appendRunToFile(); appendRunToFile();
} else if (!strcmp(token, "run_count")) { } else if (!strcmp(token, "run_count")) {
printf("Recieved request for run count\n");
sendInt(sock, run_count); sendInt(sock, run_count);
} else if (!strcmp(token, "segment_count")) { } else if (!strcmp(token, "segment_count")) {
printf("Recieved request for segment count\n");
sendInt(sock, segment_count); sendInt(sock, segment_count);
} else if (!strcmp(token, "start_split_stop")) { } else if (!strcmp(token, "start-split-stop")) {
printf("Recieved start_split_stop command\n");
start_split_stop(); start_split_stop();
} else if (!strcmp(token, "pause_resume")) { } else if (!strcmp(token, "pause-resume")) {
printf("Recieved pause_resume command\n");
pause_resume(); pause_resume();
} else if (!strcmp(token, "start-stop")) { } else if (!strcmp(token, "start-stop")) {
printf("Recieved start-stop command\n");
start_stop(); start_stop();
} else if (!strcmp(token, "start-split")) { } else if (!strcmp(token, "start-split")) {
printf("Recieved start-split command\n");
start_split(); start_split();
} else if (!strcmp(token, "split-stop")) { } else if (!strcmp(token, "split-stop")) {
printf("Recieved split-stop command\n");
split_stop(); split_stop();
} else if (!strcmp(token, "undo-redo")) { } else if (!strcmp(token, "undo-redo")) {
printf("Recieved undo-redo command\n");
undo_redo(); undo_redo();
} else if (!strcmp(token, "segment_name")) { } else if (!strcmp(token, "segment_name")) {
token = strtok(NULL, " "); token = strtok(NULL, " ");
int x = atoi(token); int x = atoi(token);
printf("Recieved request for segment %s's name: %s\n", token, segments[x].shortname);
sendString(sock, segments[x].shortname); sendString(sock, segments[x].shortname);
} else if (!strcmp(token, "meta")) { } else if (!strcmp(token, "meta")) {
token = strtok(NULL, " "); token = strtok(NULL, " ");
printf("Recieved request for [%s] meta-data tag\n", token);
sendValue(sock, token); sendValue(sock, token);
} else { } else {
printf("Recieved invalid command, ignoring...\n"); printf("Recieved invalid command, ignoring...\n");