Crossfire Client, Branch
R11627
|
Implements client startup functions. More...
#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"
Go to the source code of this file.
Functions | |
void | cleanup_connection (void) |
Called from disconnect command - that closes the socket - we just need to do the gtk cleanup. | |
void | client_tick (uint32 tick) |
X11 client doesn't care about this. | |
void | do_network (void) |
main loop iteration related stuff | |
int | do_timeout (void) |
Map, spell, and inventory maintenance. | |
static void | error_dialog (char *description, char *information) |
Display an error message dialog. | |
void | event_loop (void) |
event loop iteration stuff | |
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. | |
int | main (int argc, char *argv[]) |
The client entry point. | |
void | on_window_destroy_event (GtkObject *object, gpointer user_data) |
Handles client shutdown. | |
int | parse_args (int argc, char **argv) |
parse_args: Parses command line options, and does variable initialization. | |
static void | sigpipe_handler (int sig) |
Handler for SIGPIPE. | |
static void | usage (char *progname) |
Usage routine. | |
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] = "" |
Dialog layout file with path. | |
GtkWidget * | magic_map |
main.c - drawing area for the 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 |
In main.c. | |
GladeXML * | window_xml |
char | window_xml_file [MAX_BUF] = WINDOW_XML_FILENAME |
The file name of the window layout in use by the client. | |
char | window_xml_path [MAX_BUF] = "" |
Window layout file with path. |
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.
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().
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.
int do_timeout | ( | void | ) |
Map, spell, and inventory maintenance.
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().
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.
description | A C-string, displayed in bold text, that describes the type of the error condition. |
information | A 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().
void event_loop | ( | void | ) |
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.
win | Pass in a GtkWidget pointer to get its coordinates. |
x | Parent-relative window x coordinate |
y | Parent-relative window y coordinate |
wx | ? |
wy | ? |
w | Window width |
h | Window height |
Definition at line 886 of file main.c.
Referenced by configdialog(), image_update_download_status(), and save_winpos().
int main | ( | int | argc, |
char * | argv[] | ||
) |
The client entry point.
argc | |
argv |
Definition at line 658 of file main.c.
References SockList::buf, cached_server_file, clear_stat_mapping(), colorname, config_init(), CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, CONFIG_PORT, CONFIG_SOUND, cpl, ClientSocket::cs_version, csocket, dialog_xml, dialog_xml_file, dialog_xml_path, draw_look_list(), draw_splash(), enable_menu_items(), error_dialog(), event_loop(), FALSE, ClientSocket::fd, get_metaserver(), ClientSocket::inbuf, info_init(), init_cache_data(), init_client_vars(), init_connection(), init_sounds(), inventory_init(), keyfunc(), keyrelfunc(), keys_init(), SockList::len, load_theme(), load_window_positions(), locate_item(), LOG(), LOG_CRITICAL, magic_map, map_init(), mapdata_reset(), MAX_BUF, maxfd, MAXSOCKBUF, meta_port, meta_server, metaserver_get_info(), negotiate_connection(), NUM_COLORS, Player_Struct::ob, on_drawingarea_magic_map_expose_event(), on_window_destroy_event(), parse_args(), pickup_init(), remove_item_inventory(), reset_client_vars(), reset_image_data(), root_color, server, sigpipe_handler(), stats_init(), TRUE, use_config, want_config, window_root, window_xml, window_xml_file, window_xml_path, and XML_PATH_DEFAULT.
void on_window_destroy_event | ( | GtkObject * | object, |
gpointer | user_data | ||
) |
int parse_args | ( | int | argc, |
char ** | argv | ||
) |
parse_args: Parses command line options, and does variable initialization.
argc | |
argv |
Definition at line 350 of file main.c.
References CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_CACHE, CONFIG_DARKNESS, CONFIG_DISPLAYMODE, CONFIG_DOWNLOAD, CONFIG_ECHO, CONFIG_FASTTCP, CONFIG_FOGWAR, CONFIG_ICONSCALE, CONFIG_MAPHEIGHT, CONFIG_MAPSCALE, CONFIG_MAPWIDTH, CONFIG_NUMS, CONFIG_PORT, CONFIG_RESISTS, CONFIG_SHOWICON, CONFIG_SMOOTH, CONFIG_SOUND, CONFIG_SPLASH, CONFIG_SPLITINFO, CONFIG_SPLITWIN, CONFIG_TRIMINFO, DEFAULT_IMAGE_SIZE, dialog_xml_path, face_info, FALSE, FULL_VERSION, image_size, load_defaults(), LOG(), LOG_INFO, LOG_WARNING, map_image_half_size, map_image_size, MAP_MAX_SIZE, mapdata_init(), MAX_BUF, MINLOG, server, sound_server, time_map_redraw, TRUE, updatekeycodes, usage(), use_config, VERSION_INFO, want_config, Face_Information_struct::want_faceset, want_skill_exp, and window_xml_path.
Referenced by main().
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.
sig | The signal number. |
Definition at line 286 of file main.c.
Referenced by main().
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.
*progname | Not used, but should be. |
Definition at line 298 of file main.c.
Referenced by parse_args().
const char* const colorname[NUM_COLORS] |
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_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().
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 |
Definition at line 203 of file gx11.c.
Referenced by gtk_draw_map(), init_windows(), and parse_args().
uint8 updatekeycodes = FALSE [static] |
const char* const usercolorname[NUM_COLORS] |
{ "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 |
In main.c.
Definition at line 56 of file main.c.
Referenced by create_map_image(), enable_menu_items(), get_metaserver(), image_update_download_status(), init_cache_data(), main(), and save_winpos().
GladeXML * window_xml |
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().