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