gnoemoe/gm-app.c: added default userlist options, added default logging options
gnoemoe/gm-world.[ch]: fixed const, added gm_world_status, world specific log settings gnoemoe/gm-scripts.c: added World.status function gnoemoe/gm-pixbuf.c: added NULL filename checks
This commit is contained in:
parent
65d460b3ee
commit
7fa44d1bbb
|
@ -1,3 +1,11 @@
|
||||||
|
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
* gnoemoe/gm-app.c: added default userlist options,
|
||||||
|
added default logging options
|
||||||
|
* gnoemoe/gm-world.[ch]: fixed const, added gm_world_status, world
|
||||||
|
specific log settings
|
||||||
|
* gnoemoe/gm-scripts.c: added World.status function
|
||||||
|
* gnoemoe/gm-pixbuf.c: added NULL filename checks
|
||||||
|
|
||||||
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
* gnoemoe/mcp/gm-mcp-icecrew-playerdb.c: max version to 1.1
|
* gnoemoe/mcp/gm-mcp-icecrew-playerdb.c: max version to 1.1
|
||||||
* gnoemoe/mcp/gm-mcp.c: fixed version check
|
* gnoemoe/mcp/gm-mcp.c: fixed version check
|
||||||
|
|
|
@ -283,6 +283,8 @@ gm_app_create_settings(GmApp *app) {
|
||||||
gm_options_set(app->priv->options, "logging_mcp_in", "0");
|
gm_options_set(app->priv->options, "logging_mcp_in", "0");
|
||||||
gm_options_set(app->priv->options, "logging_mcp_out", "0");
|
gm_options_set(app->priv->options, "logging_mcp_out", "0");
|
||||||
gm_options_set(app->priv->options, "logging_mcp_status", "0");
|
gm_options_set(app->priv->options, "logging_mcp_status", "0");
|
||||||
|
gm_options_set(app->priv->options, "logging_add_timestamp", "1");
|
||||||
|
gm_options_set(app->priv->options, "logging_add_log_type", "1");
|
||||||
|
|
||||||
// Default logging filter settings
|
// Default logging filter settings
|
||||||
gm_options_set(app->priv->options, "logging_filter_in", "1");
|
gm_options_set(app->priv->options, "logging_filter_in", "1");
|
||||||
|
@ -291,6 +293,12 @@ gm_app_create_settings(GmApp *app) {
|
||||||
gm_options_set(app->priv->options, "logging_filter_mcp_in", "0");
|
gm_options_set(app->priv->options, "logging_filter_mcp_in", "0");
|
||||||
gm_options_set(app->priv->options, "logging_filter_mcp_out", "0");
|
gm_options_set(app->priv->options, "logging_filter_mcp_out", "0");
|
||||||
gm_options_set(app->priv->options, "logging_filter_mcp_status", "0");
|
gm_options_set(app->priv->options, "logging_filter_mcp_status", "0");
|
||||||
|
|
||||||
|
// Default userlist settings
|
||||||
|
gm_options_set(app->priv->options, "userlist_sort_type", "0");
|
||||||
|
gm_options_set(app->priv->options, "userlist_show_object_number", "0");
|
||||||
|
gm_options_set(app->priv->options, "userlist_show_status", "1");
|
||||||
|
gm_options_set(app->priv->options, "userlist_use_state_icon", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -521,6 +529,8 @@ gm_app_new(int argc, char *argv[]) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,10 @@ gchar *
|
||||||
gm_pixbuf_find(const gchar *filename) {
|
gm_pixbuf_find(const gchar *filename) {
|
||||||
GList *elem;
|
GList *elem;
|
||||||
|
|
||||||
|
if (filename == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
|
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
|
||||||
return g_strdup(filename);
|
return g_strdup(filename);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +153,7 @@ gm_pixbuf_create(const gchar * filename, int width, int height) {
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!filename || strlen(filename) == 0) {
|
if (!filename || *filename == '\0') {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +189,10 @@ gm_pixbuf_get_at_size(const gchar *filename, int width, int height) {
|
||||||
GList *elem;
|
GList *elem;
|
||||||
GmPixbufInfo *i;
|
GmPixbufInfo *i;
|
||||||
|
|
||||||
|
if (filename == NULL || *filename == '\0') {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (elem = gm_pixbufs; elem; elem = elem->next) {
|
for (elem = gm_pixbufs; elem; elem = elem->next) {
|
||||||
i = (GmPixbufInfo *) (elem->data);
|
i = (GmPixbufInfo *) (elem->data);
|
||||||
|
|
||||||
|
|
|
@ -500,6 +500,20 @@ gm_scripts_add_file(GmScripts *scripts, const gchar *uri) {
|
||||||
GList *f;
|
GList *f;
|
||||||
GmScript *script;
|
GmScript *script;
|
||||||
gchar *msg;
|
gchar *msg;
|
||||||
|
gchar *ext;
|
||||||
|
|
||||||
|
// Only .rb files
|
||||||
|
ext = strrchr(uri, '.');
|
||||||
|
|
||||||
|
if (ext == NULL || strncmp(ext, ".rb", 2) != 0) {
|
||||||
|
msg = g_strdup_printf(_("File `%s' is not a valid ruby file"), uri);
|
||||||
|
|
||||||
|
gm_debug_msg(DEBUG_DEFAULT, "GmScripts.AddFile: %s", msg);
|
||||||
|
g_signal_emit(scripts, gm_scripts_signals[ERROR], 0, msg);
|
||||||
|
|
||||||
|
g_free(msg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
for (f = scripts->priv->files; f; f = f->next) {
|
for (f = scripts->priv->files; f; f = f->next) {
|
||||||
script = (GmScript *)(f->data);
|
script = (GmScript *)(f->data);
|
||||||
|
@ -599,8 +613,15 @@ gm_scripts_load(GmScripts *scripts) {
|
||||||
|
|
||||||
path = g_strconcat(gm_app_path(gm_app_instance()), "/scripts", NULL);
|
path = g_strconcat(gm_app_path(gm_app_instance()), "/scripts", NULL);
|
||||||
|
|
||||||
|
// Make user dir if it doesn't exist
|
||||||
|
if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
|
||||||
|
mkdir(path, 0750);
|
||||||
|
}
|
||||||
|
|
||||||
gm_scripts_load_dir(scripts, path);
|
gm_scripts_load_dir(scripts, path);
|
||||||
gm_scripts_load_dir(scripts, GM_SCRIPTS_GLOBAL);
|
gm_scripts_load_dir(scripts, GM_SCRIPTS_GLOBAL);
|
||||||
|
|
||||||
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
|
@ -664,6 +685,19 @@ gm_scripts_rb_world_writeln(VALUE self, VALUE str) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
gm_scripts_rb_world_status(VALUE self, VALUE str) {
|
||||||
|
GmWorld *world;
|
||||||
|
gchar *strVal;
|
||||||
|
|
||||||
|
Data_Get_Struct(self, GmWorld, world);
|
||||||
|
strVal = rb_string_value_cstr(&str);
|
||||||
|
|
||||||
|
gm_world_status(world, strVal);
|
||||||
|
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
gm_scripts_rb_world_sendln(VALUE self, VALUE str) {
|
gm_scripts_rb_world_sendln(VALUE self, VALUE str) {
|
||||||
GmWorld *world;
|
GmWorld *world;
|
||||||
|
@ -850,6 +884,7 @@ gm_scripts_rb_world_class_init() {
|
||||||
|
|
||||||
rb_define_method(rb_world_class, "writeln", gm_scripts_rb_world_writeln, 1);
|
rb_define_method(rb_world_class, "writeln", gm_scripts_rb_world_writeln, 1);
|
||||||
rb_define_method(rb_world_class, "println", gm_scripts_rb_world_writeln, 1);
|
rb_define_method(rb_world_class, "println", gm_scripts_rb_world_writeln, 1);
|
||||||
|
rb_define_method(rb_world_class, "status", gm_scripts_rb_world_status, 1);
|
||||||
rb_define_method(rb_world_class, "sendln", gm_scripts_rb_world_sendln, 1);
|
rb_define_method(rb_world_class, "sendln", gm_scripts_rb_world_sendln, 1);
|
||||||
rb_define_method(rb_world_class, "input", gm_scripts_rb_world_input, 1);
|
rb_define_method(rb_world_class, "input", gm_scripts_rb_world_input, 1);
|
||||||
rb_define_method(rb_world_class, "quit", gm_scripts_rb_world_quit, 0);
|
rb_define_method(rb_world_class, "quit", gm_scripts_rb_world_quit, 0);
|
||||||
|
|
|
@ -664,9 +664,17 @@ gm_world_prepare_disconnect(GmWorld *world) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gm_world_log_allowed(GmLogType type) {
|
gm_world_log_allowed(GmWorld *world, GmLogType type) {
|
||||||
GmOptions *options = gm_app_options(gm_app_instance());
|
GmOptions *options = gm_app_options(gm_app_instance());
|
||||||
|
|
||||||
|
if (!gm_options_get_int(options, "logging_enable")) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gm_options_get_int(world->priv->options, "logging_override")) {
|
||||||
|
options = world->priv->options;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LOG_IN:
|
case LOG_IN:
|
||||||
return gm_options_get_int(options, "logging_in");
|
return gm_options_get_int(options, "logging_in");
|
||||||
|
@ -693,26 +701,27 @@ gm_world_log_allowed(GmLogType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_world_log(GmWorld *world, GmLogType type, gchar *text) {
|
gm_world_log(GmWorld *world, GmLogType type, gchar const *text) {
|
||||||
GString *s;
|
GString *s;
|
||||||
gchar *start, *log, *no_ansi;
|
gchar *start, *log, *no_ansi;
|
||||||
struct tm *timet;
|
struct tm *timet;
|
||||||
time_t timer;
|
time_t timer;
|
||||||
gint len;
|
gint len;
|
||||||
|
GmOptions *options;
|
||||||
|
|
||||||
if (type == LOG_NONE) {
|
if (type == LOG_NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether to log at all
|
// Check whether to log this type
|
||||||
if (!gm_options_get_int(gm_app_options(gm_app_instance()),
|
if (!gm_world_log_allowed(world, type)) {
|
||||||
"logging_enable")) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether to log this type
|
options = gm_app_options(gm_app_instance());
|
||||||
if (!gm_world_log_allowed(type)) {
|
|
||||||
return;
|
if (gm_options_get_int(world->priv->options, "logging_override")) {
|
||||||
|
options = world->priv->options;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = time(0);
|
timer = time(0);
|
||||||
|
@ -737,36 +746,42 @@ gm_world_log(GmWorld *world, GmLogType type, gchar *text) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start = g_strdup_printf("[%02d:%02d:%02d] ", timet->tm_hour, timet->tm_min,
|
if (gm_options_get_int(options, "logging_add_timestamp")) {
|
||||||
timet->tm_sec);
|
start = g_strdup_printf("[%02d:%02d:%02d] ", timet->tm_hour,
|
||||||
|
timet->tm_min, timet->tm_sec);
|
||||||
s = g_string_new(start);
|
s = g_string_new(start);
|
||||||
g_free(start);
|
g_free(start);
|
||||||
|
} else {
|
||||||
switch (type) {
|
s = g_string_new("");
|
||||||
case LOG_IN:
|
}
|
||||||
s = g_string_append_c(s, '<');
|
|
||||||
break;
|
if (gm_options_get_int(options, "logging_add_log_type")) {
|
||||||
case LOG_OUT:
|
switch (type) {
|
||||||
s = g_string_append_c(s, '>');
|
case LOG_IN:
|
||||||
break;
|
s = g_string_append_c(s, '<');
|
||||||
case LOG_STATUS:
|
break;
|
||||||
s = g_string_append_c(s, '#');
|
case LOG_OUT:
|
||||||
break;
|
s = g_string_append_c(s, '>');
|
||||||
case LOG_MCP_IN:
|
break;
|
||||||
s = g_string_append(s, "[MCP] <");
|
case LOG_STATUS:
|
||||||
break;
|
s = g_string_append_c(s, '#');
|
||||||
case LOG_MCP_OUT:
|
break;
|
||||||
s = g_string_append(s, "[MCP] >");
|
case LOG_MCP_IN:
|
||||||
break;
|
s = g_string_append(s, "[MCP] <");
|
||||||
case LOG_MCP_STATUS:
|
break;
|
||||||
s = g_string_append(s, "[MCP] #");
|
case LOG_MCP_OUT:
|
||||||
break;
|
s = g_string_append(s, "[MCP] >");
|
||||||
default:
|
break;
|
||||||
break;
|
case LOG_MCP_STATUS:
|
||||||
|
s = g_string_append(s, "[MCP] #");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = g_string_append_c(s, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
s = g_string_append(s, " ");
|
|
||||||
s = g_string_append(s, text);
|
s = g_string_append(s, text);
|
||||||
|
|
||||||
no_ansi = gm_ansi_strip(g_strdup(s->str));
|
no_ansi = gm_ansi_strip(g_strdup(s->str));
|
||||||
|
@ -1042,7 +1057,7 @@ gm_world_process_line(GmWorld *world, gchar *line, gint len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_world_process_input(GmWorld *world, gchar *text) {
|
gm_world_process_input(GmWorld *world, gchar const *text) {
|
||||||
#ifdef HAVE_RUBY
|
#ifdef HAVE_RUBY
|
||||||
gchar *space, *script, *argstr;
|
gchar *space, *script, *argstr;
|
||||||
gboolean script_ran = FALSE;
|
gboolean script_ran = FALSE;
|
||||||
|
@ -1080,7 +1095,17 @@ gm_world_process_input(GmWorld *world, gchar *text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_world_writeln(GmWorld *world, gchar *text) {
|
gm_world_status(GmWorld *world, gchar const *text) {
|
||||||
|
gchar *line = g_strconcat("\x1B[1;33m# ", text, "\x1B[0m", NULL);
|
||||||
|
|
||||||
|
gm_world_writeln(world, line);
|
||||||
|
gm_world_log(world, LOG_STATUS, line);
|
||||||
|
|
||||||
|
g_free(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gm_world_writeln(GmWorld *world, gchar const *text) {
|
||||||
gchar *newline = g_strconcat(text, "\n", NULL);
|
gchar *newline = g_strconcat(text, "\n", NULL);
|
||||||
g_signal_emit(world, world_signals[TEXT_RECEIVED], 0, newline);
|
g_signal_emit(world, world_signals[TEXT_RECEIVED], 0, newline);
|
||||||
|
|
||||||
|
@ -1107,7 +1132,7 @@ gm_world_add_editor(GmWorld *world, GmEditor *editor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_world_sendln_log(GmWorld *world, gchar *text, GmLogType logtype) {
|
gm_world_sendln_log(GmWorld *world, gchar const *text, GmLogType logtype) {
|
||||||
gchar *normal;
|
gchar *normal;
|
||||||
|
|
||||||
// Convert text from utf-8 to the correct locale
|
// Convert text from utf-8 to the correct locale
|
||||||
|
@ -1128,7 +1153,7 @@ gm_world_sendln_log(GmWorld *world, gchar *text, GmLogType logtype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_world_sendln(GmWorld *world, gchar *text) {
|
gm_world_sendln(GmWorld *world, gchar const *text) {
|
||||||
world->priv->last_command = time(0);
|
world->priv->last_command = time(0);
|
||||||
gm_world_sendln_log(world, text, LOG_OUT);
|
gm_world_sendln_log(world, text, LOG_OUT);
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1262,7 @@ on_gm_world_editor_save(GmEditor *editor, GmWorld *world) {
|
||||||
gm_world_sendln(world, ".");
|
gm_world_sendln(world, ".");
|
||||||
gm_editor_saved(editor);
|
gm_editor_saved(editor);
|
||||||
} else {
|
} else {
|
||||||
gm_world_writeln(world, _("# Could not save editor text, world is "
|
gm_world_status(world, _("Could not save editor text, world is "
|
||||||
"not connected at the moment"));
|
"not connected at the moment"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1299,7 @@ on_gm_world_net_state_changing(GmNet *net, GmNetState state, GmWorld *world) {
|
||||||
|
|
||||||
world->priv->reconnect_id = g_timeout_add(3000,
|
world->priv->reconnect_id = g_timeout_add(3000,
|
||||||
(GSourceFunc)gm_world_reconnect, world);
|
(GSourceFunc)gm_world_reconnect, world);
|
||||||
gm_world_writeln(world, _("# Reconnecting in 3 seconds..."));
|
gm_world_status(world, _("Reconnecting in 3 seconds..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,11 +130,12 @@ void gm_world_disconnect(GmWorld *world);
|
||||||
void gm_world_prepare_disconnect(GmWorld *world);
|
void gm_world_prepare_disconnect(GmWorld *world);
|
||||||
void gm_world_add_editor(GmWorld *world, GmEditor *editor);
|
void gm_world_add_editor(GmWorld *world, GmEditor *editor);
|
||||||
void gm_world_remove_editor(GmWorld *world, GmEditor *editor);
|
void gm_world_remove_editor(GmWorld *world, GmEditor *editor);
|
||||||
void gm_world_sendln_log(GmWorld *world, gchar *text, GmLogType logtype);
|
void gm_world_sendln_log(GmWorld *world, gchar const *text, GmLogType logtype);
|
||||||
void gm_world_sendln(GmWorld *world, gchar *text);
|
void gm_world_sendln(GmWorld *world, gchar const *text);
|
||||||
void gm_world_writeln(GmWorld *world, gchar *text);
|
void gm_world_writeln(GmWorld *world, gchar const *text);
|
||||||
void gm_world_process_input(GmWorld *world, gchar *text);
|
void gm_world_status(GmWorld *world, gchar const *text);
|
||||||
void gm_world_log(GmWorld *world, GmLogType type, gchar *text);
|
void gm_world_process_input(GmWorld *world, gchar const *text);
|
||||||
|
void gm_world_log(GmWorld *world, GmLogType type, gchar const *text);
|
||||||
void gm_world_apply_trigger(GmWorld *world, GmTrigger *trigger,
|
void gm_world_apply_trigger(GmWorld *world, GmTrigger *trigger,
|
||||||
gchar const *text, regmatch_t *matches, gint nummatches);
|
gchar const *text, regmatch_t *matches, gint nummatches);
|
||||||
|
|
||||||
|
|
Reference in New Issue