(long long unsigned)int_sqrt(statistics.num_played_qd / n));
}
+/**
+ * Close the current mood.
+ *
+ * Free all resources of the current mood which were allocated during
+ * mood_open().
+ */
+void close_current_mood(void)
+{
+ destroy_mood(current_mood);
+ current_mood = NULL;
+ memset(&statistics, 0, sizeof(statistics));
+}
+
+
/**
* Change the current mood.
*
ret = load_mood(row, &m);
if (ret < 0)
return ret;
- destroy_mood(current_mood);
+ close_current_mood();
current_mood = m;
} else {
- destroy_mood(current_mood);
+ close_current_mood();
current_mood = alloc_new_mood("dummy");
}
aa.m = current_mood;
goto out;
}
PARA_NOTICE_LOG("score add complete\n");
- ret = 1;
+ ret = statistics.num;
out:
free(aa.array);
return ret;
}
-
-/**
- * Close the current mood.
- *
- * Free all resources of the current mood which were allocated during
- * mood_open().
- */
-static void close_current_mood(void)
-{
- destroy_mood(current_mood);
- current_mood = NULL;
- memset(&statistics, 0, sizeof(statistics));
-}
-
/**
* Close and re-open the current mood.
*
int reload_current_mood(void)
{
int ret;
- char *mood_name;
+ char *mood_name = NULL;
PARA_NOTICE_LOG("reloading current mood\n");
if (!current_mood)
if (current_mood->name)
mood_name = para_strdup(current_mood->name);
close_current_mood();
- ret = clear_score_table();
- if (ret < 0)
- return ret;
ret = change_current_mood(mood_name);
free(mood_name);
return ret;
}
-int moods_event_handler(enum afs_events event, struct para_buffer *pb,
+int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb,
void *data)
{
switch(event) {