Add player parameter to SetPlayList (#1084)

Controls
Sven Eberhardt 2014-08-07 17:33:36 +02:00
parent 144c8f8388
commit 9dd600c26b
2 changed files with 18 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<func>
<title>SetPlayList</title>
<category>Music</category>
<version>5.1 OC</version>
<version>4.2 OC</version>
<syntax>
<rtype>int</rtype>
<params>
@ -16,6 +16,12 @@
<desc>List of pieces of music to be played. The individual file names are separated with semicolons (";"). Wildcards are expanded. If the parameter is left out, the standard playlist is restored.</desc>
<optional />
</param>
<param>
<type>int</type>
<name>at_player</name>
<desc>The playlist is changed only on clients where the player with this player number is local. If left out or NO_OWNER, the playlist is changed for all clients. If the player number is invalid, no playlists are changed.</desc>
<optional />
</param>
</params>
</syntax>
<desc>Sets the play list of pieces of music to be played in random order, if music is activated. The actual number of pieces of music in the playlist is returned, or 0 in network mode.</desc>
@ -24,4 +30,5 @@
<related><funclink>Music</funclink></related>
</func>
<author>PeterW</author><date>2003-01</date>
<author>Sven2</author><date>2014-08</date>
</funcs>

View File

@ -522,11 +522,19 @@ static long FnMusicLevel(C4PropList * _this, long iLevel)
return Application.MusicSystem.SetVolume(iLevel);
}
static long FnSetPlayList(C4PropList * _this, C4String *szPlayList)
static long FnSetPlayList(C4PropList * _this, C4String *szPlayList, Nillable<long> iAtPlayer)
{
// If a player number is provided, set play list for clients where given player is local only
if (!iAtPlayer.IsNil() && iAtPlayer != NO_OWNER)
{
C4Player *at_plr = ::Players.Get(iAtPlayer);
if (!at_plr) return 0;
if (!at_plr->LocalControl) return 0;
}
// Set playlist; count entries
long iFilesInPlayList = Application.MusicSystem.SetPlayList(FnStringPar(szPlayList));
Game.PlayList.Copy(FnStringPar(szPlayList));
// network/record/replay: return 0
// network/record/replay: return 0 for sync reasons
if (::Control.SyncMode()) return 0;
return iFilesInPlayList;
}