bygfoot/src/debug.c

68 lines
1.8 KiB
C
Raw Normal View History

2005-05-13 20:20:47 +02:00
#include "debug.h"
#include "game_gui.h"
#include "option.h"
2005-06-20 16:24:54 +02:00
#include "support.h"
2005-05-13 20:20:47 +02:00
#include "user.h"
#include "variables.h"
/** Take some debug action depending on the text and the value. */
void
debug_action(const gchar *text, gint value)
{
gchar message[SMALL];
if(g_str_has_prefix(text, "deb"))
{
opt_set_int("int_opt_debug", value);
sprintf(message, "Debug value set to %d.", value);
}
else if(g_str_has_prefix(text, "cap"))
{
current_user.tm->stadium.capacity += value;
2005-06-20 14:46:57 +02:00
sprintf(message, "Stadium capacity changed by %d. New: %d.", value,
current_user.tm->stadium.capacity);
2005-05-13 20:20:47 +02:00
}
else if(g_str_has_prefix(text, "saf"))
{
current_user.tm->stadium.safety += ((gfloat)value / 100);
current_user.tm->stadium.safety =
CLAMP(current_user.tm->stadium.safety, 0, 1);
2005-06-20 14:46:57 +02:00
sprintf(message, "Stadium safety changed by %d. New: %.2f", value,
current_user.tm->stadium.safety);
2005-05-13 20:20:47 +02:00
}
else if(g_str_has_prefix(text, "mon"))
{
current_user.money += value;
2005-06-20 14:46:57 +02:00
sprintf(message, "Money changed by %d. New: %d.", value,
current_user.money);
2005-05-13 20:20:47 +02:00
}
2005-05-28 12:41:53 +02:00
else if(g_str_has_prefix(text, "suc"))
{
current_user.counters[COUNT_USER_SUCCESS] += value;
2005-06-20 14:46:57 +02:00
sprintf(message, "Success counter changed by %d. New: %d.", value,
current_user.counters[COUNT_USER_SUCCESS]);
2005-05-28 12:41:53 +02:00
}
else if(g_str_has_prefix(text, "help"))
{
printf("Debug options:\n"
"deb \t set debug value\n"
"cap \t change stadium capacity\n"
"saf \t change stadium safety\n"
"mon \t change money\n"
"suc \t change success counter\n"
"help \t display this help\n");
strcpy(message, "");
}
2005-05-13 20:20:47 +02:00
game_gui_print_message(message);
2005-06-20 16:24:54 +02:00
setsav0;
2005-05-13 20:20:47 +02:00
}
gboolean
debug_reset_counter(gpointer data)
{
counters[COUNT_SHOW_DEBUG] = 0;
return FALSE;
}