Crossfire Client, Trunk  R20612
main.c File Reference
#include "client.h"
#include <errno.h>
#include <gtk/gtk.h>
#include <stdbool.h>
#include <signal.h>
#include "client-vala.h"
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "metaserver.h"
#include "script.h"
#include "gtk2proto.h"
+ Include dependency graph for main.c:

Go to the source code of this file.

Functions

void client_tick (guint32 tick)
 
static gboolean do_network (GObject *stream, gpointer data)
 
static gboolean do_timeout (gpointer data)
 
void error_dialog (char *error, char *message)
 
static void event_loop ()
 
void get_window_coord (GtkWidget *win, int *x, int *y, int *wx, int *wy, int *w, int *h)
 
static void init_sockets ()
 
static void init_ui ()
 
static char * init_ui_layout (const char *name)
 
int main (int argc, char *argv[])
 
void my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
 
void on_window_destroy_event (GtkObject *object, gpointer user_data)
 
static void parse_args (int argc, char *argv[])
 
static gboolean redraw (gpointer data)
 

Variables

static const char *const colorname [NUM_COLORS]
 
GtkBuilder * dialog_xml
 
GtkWidget * magic_map
 
int MINLOG
 
bool next_tick = false
 
static GOptionEntry options []
 
GdkColor root_color [NUM_COLORS]
 
SoundServer * server
 
int time_map_redraw
 
static gboolean updatekeycodes = FALSE
 
GtkWidget * window_root
 
GtkBuilder * window_xml
 
char window_xml_file [MAX_BUF]
 

Detailed Description

Client startup and main loop.

Definition in file main.c.

Function Documentation

void client_tick ( guint32  tick)

X11 client doesn't care about this

Definition at line 156 of file main.c.

References info_buffer_tick(), inventory_tick(), mapdata_animation(), and next_tick.

Referenced by TickCmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static gboolean do_network ( GObject *  stream,
gpointer  data 
)
static

Callback from the event loop triggered when server input is available.

Definition at line 177 of file main.c.

References client_is_connected(), client_run(), draw_lists(), maxfd, script_fdset(), and script_process().

Referenced by event_loop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static gboolean do_timeout ( gpointer  data)
static

Map, spell, and inventory maintenance.

Returns
TRUE

Definition at line 103 of file main.c.

References cpl, inventory_tick(), magic_map_flash_pos(), MAGIC_MAP_PAGE, map_notebook, mapdata_animation(), Player_Struct::showmagic, Player_Struct::spells_updated, tick, and update_spell_information().

Referenced by event_loop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void error_dialog ( char *  error,
char *  message 
)

Display an error message dialog. The dialog contains a multi-line, bolded heading that includes the client version information, an error description, and information relevant to the error condition.

Definition at line 263 of file main.c.

Referenced by init_login_window(), and init_ui().

+ Here is the caller graph for this function:

static void event_loop ( )
static

Set up, enter, and exit event loop. Blocks until event loop returns.

Definition at line 203 of file main.c.

References client_get_source(), do_network(), do_timeout(), LOG(), LOG_DEBUG, and redraw().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void get_window_coord ( GtkWidget *  win,
int *  x,
int *  y,
int *  wx,
int *  wy,
int *  w,
int *  h 
)

Gets the coordinates of a specified window.

Parameters
winPass in a GtkWidget pointer to get its coordinates.
xParent-relative window x coordinate
yParent-relative window y coordinate
wx?
wy?
wWindow width
hWindow height

Definition at line 484 of file main.c.

Referenced by image_update_download_status(), and save_winpos().

+ Here is the caller graph for this function:

static void init_sockets ( )
static

Definition at line 291 of file main.c.

References maxfd, and wantloginmethod.

Referenced by main().

+ Here is the caller graph for this function:

static char* init_ui_layout ( const char *  name)
static

Load the UI from the given path. On success, store path in window_xml_file.

Definition at line 310 of file main.c.

References window_xml, and window_xml_file.

Referenced by init_ui().

+ Here is the caller graph for this function:

void my_log_handler ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
)

This goes with the g_log_set_handler below in main(). I leave it here since it may be useful - basically, it can prove handy to try and track down error messages like:

file gtklabel.c: line 1845: assertion `GTK_IS_LABEL (label)' failed

In the debugger, you can set a breakpoint in this function, and then see the stacktrace on what is trying to access a widget that isn't set or otherwise having issues.

Definition at line 286 of file main.c.

void on_window_destroy_event ( GtkObject *  object,
gpointer  user_data 
)

Handles client shutdown.

Definition at line 165 of file main.c.

References LOG(), and LOG_DEBUG.

Referenced by init_ui(), metaserver_ui_init(), and on_button_metaserver_quit_pressed().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void parse_args ( int  argc,
char *  argv[] 
)
static

parse_args: Parses command line options, and does variable initialization.

Parameters
argc
argvParse command-line arguments and store settings in want_config.

This function should be called after config_load().

Definition at line 233 of file main.c.

References LOG(), LOG_DEBUG, MINLOG, options, and VERSION_INFO.

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static gboolean redraw ( gpointer  data)
static

Redraw the map. Do a full redraw if there are new images to show.

Definition at line 128 of file main.c.

References Player_Struct::container, cpl, draw_lists(), draw_map(), have_new_image, item_struct::inv_updated, next_tick, and Player_Struct::ob.

Referenced by event_loop(), and StatsCmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const char* const colorname[NUM_COLORS]
static
Initial value:
= {
"Black",
"White",
"Navy",
"Red",
"Orange",
"DodgerBlue",
"DarkOrange2",
"SeaGreen",
"DarkSeaGreen",
"Grey50",
"Sienna",
"Gold",
"Khaki"
}

Definition at line 38 of file main.c.

Referenced by init_ui().

GtkWidget * magic_map

Definition at line 87 of file main.c.

Referenced by draw_magic_map(), init_ui(), and magic_map_flash_pos().

int MINLOG

Log level, or the threshold below which messages are suppressed.

Definition at line 32 of file misc.c.

Referenced by LOG(), and parse_args().

bool next_tick = false

Track whether the client has received a trick since the last redraw.

Definition at line 90 of file main.c.

Referenced by client_tick(), and redraw().

GOptionEntry options[]
static
Initial value:
= {
{ "cache", 0, 0, G_OPTION_ARG_NONE, &want_config[CONFIG_CACHE],
"Cache images", NULL },
{ "prefetch", 0, 0, G_OPTION_ARG_NONE, &want_config[CONFIG_DOWNLOAD],
"Download images before playing", NULL },
{ "faceset", 0, 0, G_OPTION_ARG_STRING, &face_info.want_faceset,
"Use the given faceset (if available)", "FACESET" },
{ "sound_server", 0, 0, G_OPTION_ARG_FILENAME, &sound_server,
"Path to the sound server", "PATH" },
{ "updatekeycodes", 0, 0, G_OPTION_ARG_NONE, &updatekeycodes,
"Update the saved bindings for this keyboard", NULL },
{ "time-redraw", 't', 0, G_OPTION_ARG_NONE, &time_map_redraw,
"Print map redraw times to stdout", NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_INT, &MINLOG,
"Set verbosity (0 is the most verbose)", "LEVEL" },
{ NULL }
}
int MINLOG
Definition: misc.c:32
Face_Information face_info
Definition: image.c:169
int time_map_redraw
Definition: map.c:50
#define CONFIG_CACHE
Definition: client.h:189
gint16 want_config[CONFIG_NUMS]
Definition: init.c:40
#define CONFIG_DOWNLOAD
Definition: client.h:185
char * sound_server
Definition: client.c:51
static gboolean updatekeycodes
Definition: main.c:54

Command line options, descriptions, and parameters.

Definition at line 62 of file main.c.

Referenced by on_spell_cast_clicked(), on_spell_invoke_clicked(), on_spell_treeview_row_activated(), and parse_args().

GdkColor root_color[NUM_COLORS]

Definition at line 84 of file main.c.

Referenced by draw_magic_map(), init_ui(), and magic_map_flash_pos().

SoundServer* server

Definition at line 25 of file sound.c.

Referenced by init_sounds(), main(), MusicCmd(), and Sound2Cmd().

int time_map_redraw

Definition at line 50 of file map.c.

Referenced by draw_map().

gboolean updatekeycodes = FALSE
static

Definition at line 54 of file main.c.