]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
paraslash 0.7.3
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index 94ec3cd49ee3128348185d829acaa417fdbb5b5c..1e15ef0e081480381fcbc4fdad2179848f429c1f 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -134,6 +134,8 @@ static void destroy_mood(struct mood_instance *m)
        if (!m)
                return;
        mp_shutdown(m->parser_context);
+       if (m->score_table)
+               score_close(m->score_table);
        free(m->name);
        free(m);
 }
@@ -539,12 +541,15 @@ static char *get_statistics(struct mood_instance *m, int64_t sse)
                "loaded mood %s (%u files)\n"
                "last_played mean/sigma: %d/%d days\n"
                "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n"
+               "correction factor ratio: %.2lf\n"
        ,
                m->name? m->name : "(dummy)",
                n,
                mean_days, sigma_days,
                m->stats.num_played_sum / n,
-                       int_sqrt(m->stats.num_played_qd / n)
+               int_sqrt(m->stats.num_played_qd / n),
+               86400.0 * m->stats.last_played_correction /
+                       m->stats.num_played_correction
        );
 }
 
@@ -661,13 +666,11 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg)
                mood_unload(NULL);
                current_mood = aa.m;
        }
+       ret = 1;
 out:
        free(aa.array);
-       if (ret < 0) {
-               if (aa.m->score_table)
-                       score_close(aa.m->score_table);
+       if (ret <= 0) /* error, or no admissible files */
                destroy_mood(aa.m);
-       }
        return ret;
 }