Crossfire Client, Branches  R11627
main.c File Reference
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include "main.h"
#include "client.h"
#include "image.h"
#include "gtk2proto.h"
#include "script.h"
#include "metaserver.h"
#include "mapdata.h"
+ Include dependency graph for main.c:

Go to the source code of this file.

Functions

void cleanup_connection (void)
 
void client_tick (uint32 tick)
 
void do_network (void)
 
int do_timeout (void)
 
static void error_dialog (char *description, char *information)
 
void event_loop (void)
 
void get_window_coord (GtkWidget *win, int *x, int *y, int *wx, int *wy, int *w, int *h)
 
int main (int argc, char *argv[])
 
void on_window_destroy_event (GtkObject *object, gpointer user_data)
 
int parse_args (int argc, char **argv)
 
static void sigpipe_handler (int sig)
 
static void usage (char *progname)
 

Variables

const char *const colorname [NUM_COLORS]
 
gint csocket_fd =0
 
GladeXML * dialog_xml
 
char dialog_xml_file [MAX_BUF] = DIALOG_XML_FILENAME
 
char dialog_xml_path [MAX_BUF] = ""
 
GtkWidget * magic_map
 
int maxfd
 
const char *const rcsid_gtk2_main_c = "$Id: main.c 10739 2008-11-26 19:50:37Z kbulgrien $"
 
GdkColor root_color [NUM_COLORS]
 
int time_map_redraw
 
struct timeval timeout
 
static uint8 updatekeycodes =FALSE
 
const char *const usercolorname [NUM_COLORS]
 
GtkWidget * window_root
 
GladeXML * window_xml
 
char window_xml_file [MAX_BUF] = WINDOW_XML_FILENAME
 
char window_xml_path [MAX_BUF] = ""
 

Detailed Description

Implements client startup functions. Command-line parameters are parsed and handled. Libglade XML layout files are loaded. Windows and dialogs are initialized. The server connection is managed. The main.c file originally was generated by glade-2, but is now manually maintained.

Definition in file main.c.

Function Documentation

void cleanup_connection ( void  )

Called from disconnect command - that closes the socket - we just need to do the gtk cleanup.

Definition at line 150 of file main.c.

References csocket_fd.

void client_tick ( uint32  tick)

X11 client doesn't care about this

Definition at line 139 of file main.c.

References draw_map(), inventory_tick(), and mapdata_animation().

+ Here is the call graph for this function:

void do_network ( void  )

main loop iteration related stuff

Definition at line 176 of file main.c.

References CFG_DM_OPENGL, CFG_DM_SDL, CONFIG_DISPLAYMODE, csocket, csocket_fd, DoClient(), draw_lists(), draw_map(), FALSE, ClientSocket::fd, LOG(), LOG_WARNING, maxfd, opengl_gen_map(), script_fdset(), script_process(), sdl_gen_map(), timeout, and use_config.

Referenced by event_loop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int do_timeout ( void  )

Map, spell, and inventory maintenance.

Returns
TRUE

Definition at line 125 of file main.c.

References cpl, display_map_doneupdate(), draw_info_windows(), FALSE, inventory_tick(), magic_map_flash_pos(), mapdata_animation(), redraw_needed, Player_Struct::showmagic, Player_Struct::spells_updated, tick, TRUE, update_spell_information(), update_spell_list(), and updatelock.

Referenced by event_loop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void error_dialog ( char *  description,
char *  information 
)
static

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.

Parameters
descriptionA C-string, displayed in bold text, that describes the type of the error condition.
informationA C-string, displayed in normal text, that provides additional information about the error condition.

Definition at line 636 of file main.c.

References VERSION_INFO.

Referenced by main().

+ Here is the caller graph for this function:

void event_loop ( void  )

event loop iteration stuff

Definition at line 234 of file main.c.

Referenced by main().

+ 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 886 of file main.c.

Referenced by configdialog(), image_update_download_status(), and save_winpos().

+ Here is the caller graph for this function:

void on_window_destroy_event ( GtkObject *  object,
gpointer  user_data 
)

Handles client shutdown.

Definition at line 162 of file main.c.

References LOG(), and LOG_INFO.

Referenced by get_metaserver(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void sigpipe_handler ( int  sig)
static

Handler for SIGPIPE. We may receive this signal while piping data to a sound server or to a script. In both cases, we ignore the signal because the failure will be reported by the system call that tried to send the data.

Parameters
sigThe signal number.

Definition at line 286 of file main.c.

Referenced by main().

+ Here is the caller graph for this function:

static void usage ( char *  progname)
static

Usage routine. All clients should support server, port and display options, with -pix and -xpm also suggested. -split does not need to be supported - it is in this copy because the old code supported it.

Parameters
*prognameNot used, but should be.

Definition at line 298 of file main.c.

Referenced by parse_args().

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 60 of file main.c.

Referenced by main().

gint csocket_fd =0

Definition at line 107 of file main.c.

Referenced by cleanup_connection(), do_network(), event_loop(), keyfunc(), and on_disconnect_activate().

GladeXML* dialog_xml

Definition at line 57 of file main.c.

Referenced by config_init(), get_metaserver(), keys_init(), main(), menu_about(), and on_spells_activate().

char dialog_xml_file[MAX_BUF] = DIALOG_XML_FILENAME

Definition at line 96 of file main.c.

Referenced by main().

char dialog_xml_path[MAX_BUF] = ""

Dialog layout file with path.

Definition at line 97 of file main.c.

Referenced by main(), and parse_args().

GtkWidget * magic_map

main.c - drawing area for the magic map

Definition at line 56 of file main.c.

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

int maxfd

Definition at line 68 of file client.c.

Referenced by do_network(), event_loop(), and main().

const char* const rcsid_gtk2_main_c = "$Id: main.c 10739 2008-11-26 19:50:37Z kbulgrien $"

Definition at line 1 of file main.c.

GdkColor root_color[NUM_COLORS]

Definition at line 104 of file main.c.

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

int time_map_redraw

Definition at line 203 of file gx11.c.

Referenced by gtk_draw_map(), init_windows(), and parse_args().

struct timeval timeout

Definition at line 105 of file main.c.

Referenced by do_network(), and event_loop().

uint8 updatekeycodes =FALSE
static

Definition at line 108 of file main.c.

Referenced by parse_args().

const char* const usercolorname[NUM_COLORS]
Initial value:
= {
"black",
"white",
"darkblue",
"red",
"orange",
"lightblue",
"darkorange",
"green",
"darkgreen",
"grey",
"brown",
"yellow",
"tan"
}

Definition at line 80 of file main.c.

Referenced by add_to_textbuf(), info_get_styles(), and message_callback().

GtkWidget* window_root
GladeXML * window_xml

Definition at line 57 of file main.c.

Referenced by main().

char window_xml_file[MAX_BUF] = WINDOW_XML_FILENAME

The file name of the window layout in use by the client. The base name, without dot extention, is re-used when saving the window positions.

Definition at line 98 of file main.c.

Referenced by load_defaults(), load_window_positions(), main(), read_config_window(), save_defaults(), save_winpos(), and setup_config_window().

char window_xml_path[MAX_BUF] = ""

Window layout file with path.

Definition at line 103 of file main.c.

Referenced by main(), and parse_args().