]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
Kill loading of first available mood.
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index 9074581c6c8d40741a99c3c1772716381e03f2a4..08c2c222e84f69bd794ea7c4598b83fe0051ac06 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -523,35 +523,6 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m)
        return 1;
 }
 
-/*
- * Calls load_mood() and reverts its error value: It returns -E_MOOD_LOADED
- * on _success_, and 1 on errors. This way the loop over all moods stops at the
- * first valid mood.
- */
-static int load_mood_loop_func(struct osl_row *mood_row, void *data)
-{
-       struct mood **m = data;
-       int ret = load_mood(mood_row, m);
-       if (ret < 0) {
-               if (ret != -E_DUMMY_ROW)
-                       PARA_NOTICE_LOG("invalid mood (%d), trying next mood\n", ret);
-               return 1;
-       }
-       return -E_MOOD_LOADED;
-}
-
-static int load_first_available_mood(struct mood **m)
-{
-       int ret = osl_rbtree_loop(moods_table, BLOBCOL_NAME, m,
-               load_mood_loop_func);
-       if (ret == -E_MOOD_LOADED) /* success */
-               return 1;
-       if (ret < 0)
-               return ret; /* error */
-       PARA_NOTICE_LOG("no valid mood found\n");
-       return -E_NO_MOOD;
-}
-
 static int check_mood(struct osl_row *mood_row, void *data)
 {
        struct para_buffer *pb = data;
@@ -946,10 +917,8 @@ static void log_statistics(void)
  *
  * \param mood_name The name of the mood to open.
  *
- * There are two special cases: If \a mood_name is \a NULL, load the
- * first available mood. If \a mood_name is the empty string "", load
- * the dummy mood that accepts every audio file and uses a scoring method
- * based only on the \a last_played information.
+ * If \a mood_name is \a NULL, load the dummy mood that accepts every audio file
+ * and uses a scoring method based only on the \a last_played information.
  *
  * If there is already an open mood, it will be closed first.
  *
@@ -967,14 +936,7 @@ int change_current_mood(char *mood_name)
                .array = NULL
        };
 
-       if (!mood_name) {
-               struct mood *m;
-               ret = load_first_available_mood(&m);
-               if (ret < 0)
-                       return ret;
-               destroy_mood(current_mood);
-               current_mood = m;
-       } else if (*mood_name) {
+       if (mood_name) {
                struct mood *m;
                struct osl_row *row;
                struct osl_object obj = {
@@ -1050,7 +1012,8 @@ int reload_current_mood(void)
        PARA_NOTICE_LOG("reloading current mood\n");
        if (!current_mood)
                return 1;
-       mood_name = para_strdup(current_mood->name);
+       if (current_mood->name)
+               mood_name = para_strdup(current_mood->name);
        close_current_mood();
        ret = clear_score_table();
        if (ret < 0)