MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SaveCustomPlaylist

Method SaveCustomPlaylist

src/music_gui.cpp:428–446  ·  view source on GitHub ↗

* Save a custom playlist to settings after modification. * @param pl Playlist to store back */

Source from the content-addressed store, hash-verified

426 * @param pl Playlist to store back
427 */
428void MusicSystem::SaveCustomPlaylist(PlaylistChoices pl)
429{
430 uint8_t *settings_pl;
431 if (pl == PLCH_CUSTOM1) {
432 settings_pl = _settings_client.music.custom_1;
433 } else if (pl == PLCH_CUSTOM2) {
434 settings_pl = _settings_client.music.custom_2;
435 } else {
436 return;
437 }
438
439 size_t num = 0;
440 std::fill_n(settings_pl, NUM_SONGS_PLAYLIST, 0);
441
442 for (const auto &song : this->standard_playlists[pl]) {
443 /* Music set indices in the settings playlist are 1-based, 0 means unused slot */
444 settings_pl[num++] = (uint8_t)song.set_index + 1;
445 }
446}
447
448
449/**

Callers 3

PlaylistAddMethod · 0.95
PlaylistRemoveMethod · 0.95
PlaylistClearMethod · 0.95

Calls 1

fill_nFunction · 0.85

Tested by

no test coverage detected