# HG changeset patch # User albeu # Date 1037144492 0 # Node ID bf5d1da56ecddf1f3ae84f4dec7db751db3e349b # Parent 014e0ea85bdb356011cc8aa614ce759b7cee4fba Basic support for random playing (-rnd and -nornd) diff -r 014e0ea85bdb -r bf5d1da56ecd parser-mpcmd.c --- 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;