changeset 8175:bf5d1da56ecd

Basic support for random playing (-rnd and -nornd)
author albeu
date Tue, 12 Nov 2002 23:41:32 +0000
parents 014e0ea85bdb
children 15fa4667cddf
files parser-mpcmd.c
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/parser-mpcmd.c	Tue Nov 12 23:39:35 2002 +0000
+++ b/parser-mpcmd.c	Tue Nov 12 23:41:32 2002 +0000
@@ -177,6 +177,8 @@
       {
 	play_tree_t* entry = play_tree_new();
 	UNSET_GLOBAL;
+	if(last_parent->flags & PLAY_TREE_RND)
+	  entry->flags |= PLAY_TREE_RND;
 	if(last_entry == NULL) {
 	  play_tree_set_child(last_parent,entry);
 	} else {
@@ -222,6 +224,16 @@
 	    pt->loop = l;
 	    tmp = 1;
 	  }
+	} else if(strcasecmp(opt,"rnd") == 0) {
+	  if(last_entry && last_entry->child)
+	    last_entry->flags |= PLAY_TREE_RND;
+	  else
+	    last_parent->flags |= PLAY_TREE_RND;
+	} else if(strcasecmp(opt,"nornd") == 0) {
+	  if(last_entry && last_entry->child)
+	    last_entry->flags &= ~PLAY_TREE_RND;
+	  else
+	    last_parent->flags &= ~PLAY_TREE_RND;
 	} else {
 	  m_option_t* mp_opt = NULL;
 	  play_tree_t* entry = NULL;
@@ -230,6 +242,8 @@
 	  if(tmp > 0)  { // It's an entry
 	    if(entry) {
 	      add_entry(entry);
+	      if((last_parent->flags & PLAY_TREE_RND) && entry->child)
+		entry->flags |= PLAY_TREE_RND;
 	      UNSET_GLOBAL;
 	    } else if(mode == LOCAL) // Entry is empty we have to drop his params
 	      mode = DROP_LOCAL;