]> git.sesse.net Git - pkanalytics/blobdiff - main.cpp
Backdate substitutions so that they're a bit easier to deal with.
[pkanalytics] / main.cpp
index f6d289d201d97616bf7d2501eb176a29796210e7..46a0d1c666a02aa401e40dc25784ab486cf2c36f 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -208,32 +208,11 @@ void MainWindow::delete_current_event()
 void MainWindow::make_substitution()
 {
        QItemSelectionModel *select = ui->player_view->selectionModel();
-
-       // FIXME: we should backdate t to start of point (last goal, or 0) if:
-       // - no players we're removing have had actions yet
-       // - there have been no other in/out events
-       //
-       // ...but if so, we might need to modify in/out events that are already there
-       // (perhaps just overwrite them all?)
-       uint64_t t = video->position();
-
-       set<int> old_team = events->get_team_at(t);
        set<int> new_team;
-
        for (QModelIndex row : select->selectedRows()) {
                new_team.insert(players->get_player_id(row.row()));
        }
-
-       for (int player_id : old_team) {
-               if (!new_team.count(player_id)) {
-                       events->insert_event(t, player_id, "out");
-               }
-       }
-       for (int player_id : new_team) {
-               if (!old_team.count(player_id)) {
-                       events->insert_event(t, player_id, "in");
-               }
-       }
+       events->set_team_at(video->position(), new_team);
 }
 
 void MainWindow::update_ui_from_time(uint64_t t)