Comment 2 for bug 1733778

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Fix would be:

   subscriber_ =
      Notifications::subscribe<NoteGameSettings>([this](const NoteGameSettings& note) {
- switch (note.action) {
- case NoteGameSettings::Action::kMap:
- // We don't care about map updates, since we receive enough notifications for the
- // slots.
- break;
- default:
- if (s->settings().players.empty()) {
- // No map/savegame yet
- return;
- }
- if (id_ == note.position ||
- s->settings().players[id_].state == PlayerSettings::State::kShared) {
- update();
- }
+ // We don't care about map updates,
+ // since we receive enough notifications for the slots.
+ if (note.action != NoteGameSettings::Action::kMap) {
+ const std::vector<PlayerSettings>& players = s->settings().players;
+ if (id_ < players.size()) { // cares for empty list, too
+ if (id_ == note.position ||
+ players[id_].state == PlayerSettings::State::kShared) {
+ update();
+ }
+ }
       }
    });