Crossfire Client, Trunk
|
#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 "sound.h"
#include "gtk2proto.h"
Go to the source code of this file.
Functions | |
static void | auto_afk () |
void | client_tick (guint32 tick) |
static gboolean | do_network (GObject *stream, 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) |
void | hide_main_client () |
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) |
static void | on_auto_afk_response (GtkDialog *self, gint response_id, gpointer user_data) |
void | on_window_destroy_event (GtkWidget *object, gpointer user_data) |
static void | parse_args (int argc, char *argv[]) |
static gboolean | redraw (gpointer data) |
static gboolean | script_launch (const gchar *option_name, const gchar *value, gpointer data, GError **error) |
void | show_main_client () |
Variables | |
static const char *const | colorname [NUM_COLORS] |
static char * | connect_server = NULL |
GtkWidget * | connect_window |
bool | debug_protocol |
GtkBuilder * | dialog_xml |
bool | is_afk |
time_t | last_command_sent |
GtkWidget * | magic_map |
GtkNotebook * | main_notebook |
int | MINLOG |
static GOptionEntry | options [] |
bool | profile_latency |
GdkColor | root_color [NUM_COLORS] |
bool | time_map_redraw |
static gboolean | updatekeycodes = FALSE |
GtkWidget * | window_root |
GtkBuilder * | window_xml |
char | window_xml_file [MAX_BUF] |
Client startup and main loop.
Definition in file main.c.
|
static |
Definition at line 171 of file main.c.
References on_auto_afk_response(), send_command(), and window_root.
Referenced by client_tick().
void client_tick | ( | guint32 | tick | ) |
Called whenever the server sends a tick command.
Definition at line 186 of file main.c.
References auto_afk(), CONFIG_AUTO_AFK, cpl, info_buffer_tick(), inventory_tick(), is_afk, last_command_sent, magic_map_flash_pos(), MAGIC_MAP_PAGE, map_notebook, mapdata_animation(), redraw(), Player_Struct::showmagic, Player_Struct::spells_updated, update_spell_information(), and use_config.
Referenced by TickCmd().
|
static |
Callback from the event loop triggered when server input is available.
Definition at line 222 of file main.c.
References client_is_connected(), client_run(), LOG(), LOG_ERROR, LOG_INFO, maxfd, script_fdset(), and script_process().
Referenced by event_loop().
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 314 of file main.c.
Referenced by client_run(), event_loop(), and init_ui().
|
static |
Set up, enter, and exit event loop. Blocks until event loop returns.
Definition at line 254 of file main.c.
References client_disconnect(), client_get_source(), do_network(), error_dialog(), LOG(), and LOG_DEBUG.
Referenced by main().
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 579 of file main.c.
Referenced by image_update_download_status(), and save_winpos().
void hide_main_client | ( | ) |
Called if event_loop() exits, or whenever the character selection window comes up (before logging in, or after having applied a bed).
Definition at line 477 of file main.c.
References cf_play_music(), connect_window, cpl, locate_item(), Player_Struct::ob, remove_item_inventory(), and window_root.
Referenced by choose_character_init(), create_new_character_failure(), and main().
|
static |
|
static |
Definition at line 363 of file main.c.
References colorname, config_init(), connect_window, DEFAULT_UI, DIALOG_FILENAME, dialog_xml, error_dialog(), focusoutfunc(), info_init(), init_create_character_window(), init_menu_items(), init_theme(), init_ui_layout(), inventory_init(), keyfunc(), keyrelfunc(), keys_init(), load_theme(), load_window_positions(), LOG(), LOG_DEBUG, magic_map, main_notebook, metaserver_ui_init(), msgctrl_init(), NUM_COLORS, on_drawingarea_magic_map_expose_event(), on_window_destroy_event(), pickup_init(), root_color, stats_init(), window_root, window_xml, and window_xml_file.
Referenced by main().
|
static |
Load the UI from the given path. On success, store path in window_xml_file.
Definition at line 351 of file main.c.
References window_xml, and window_xml_file.
Referenced by init_ui().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Main client entry point.
Definition at line 493 of file main.c.
References account_show_login(), client_connect(), client_init(), client_negotiate(), client_reset(), config_check(), config_load(), CONFIG_SOUND, connect_server, connect_window, cpl, csocket, event_loop(), ClientSocket::fd, FULL_VERSION, global_time, hide_main_client(), init_image_cache_data(), init_sockets(), init_sounds(), init_ui(), Player_Struct::input_state, LOG(), LOG_DEBUG, LOG_ERROR, MAX_BUF, metaserver_show_prompt(), parse_args(), Playing, reset_image_data(), serverloginmethod, show_main_client(), use_config, VERSION_INFO, want_config, and window_xml_file.
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.
|
static |
Definition at line 146 of file main.c.
References CONFIG_AUTO_AFK, config_check(), is_afk, save_defaults(), send_command(), and want_config.
Referenced by auto_afk().
void on_window_destroy_event | ( | GtkWidget * | object, |
gpointer | user_data | ||
) |
Handles client shutdown.
Definition at line 213 of file main.c.
References LOG(), LOG_DEBUG, and script_killall().
Referenced by init_ui(), and on_button_metaserver_quit_pressed().
|
static |
parse_args: Parses command line options, and does variable initialization.
argc | |
argv | Parse command-line arguments and store settings in want_config. |
This function should be called after config_load().
Definition at line 284 of file main.c.
References LOG(), LOG_DEBUG, MINLOG, options, and VERSION_INFO.
Referenced by main().
|
static |
Redraw the map. Do a full redraw if there are new images to show. Return false to unregister this event source after one redraw.
Definition at line 129 of file main.c.
References client_is_connected(), Player_Struct::container, cpl, draw_lists(), draw_map(), have_new_image, item_struct::inv_updated, and Player_Struct::ob.
Referenced by client_tick(), display_map_doneupdate(), draw_stats(), and StatsCmd().
|
static |
Definition at line 116 of file main.c.
References script_init().
void show_main_client | ( | ) |
Show main client window. Called after connect if server does not support new loginmethod, or after character is selected.
Definition at line 466 of file main.c.
References clear_stat_mapping(), hide_all_login_windows(), map_init(), and window_root.
Referenced by AddMeSuccess(), main(), on_button_cc_done(), and on_button_play_character_clicked().
|
static |
GtkWidget * connect_window |
Definition at line 103 of file main.c.
Referenced by hide_all_login_windows(), hide_main_client(), init_create_character_window(), init_ui(), and main().
bool debug_protocol |
Definition at line 61 of file main.c.
Referenced by client_run(), and SockList_Send().
GtkBuilder* dialog_xml |
Definition at line 102 of file main.c.
Referenced by config_init(), init_account_password_window(), init_add_character_window(), init_choose_char_window(), init_create_account_window(), init_create_character_window(), init_login_window(), init_new_character_window(), init_ui(), keys_init(), menu_about(), metaserver_ui_init(), msgctrl_init(), on_skills_activate(), on_spells_activate(), and update_skill_information().
bool is_afk |
Best guess whether or not we are currently AFK or not.
Definition at line 46 of file player.c.
Referenced by client_tick(), new_player(), on_auto_afk_response(), and send_command().
time_t last_command_sent |
Time when last command was sent. Used to keep track of auto-AFK.
Definition at line 49 of file player.c.
Referenced by client_tick(), new_player(), and send_command().
GtkWidget * magic_map |
Definition at line 103 of file main.c.
Referenced by draw_magic_map(), init_ui(), and magic_map_flash_pos().
GtkNotebook* main_notebook |
Definition at line 104 of file main.c.
Referenced by account_show_login(), choose_char_window_show(), init_ui(), metaserver_show_prompt(), on_button_account_password_cancel_clicked(), on_button_account_password_clicked(), on_button_add_character_clicked(), on_button_create_account_clicked(), on_button_new_cancel_clicked(), on_button_return_character_select_clicked(), and on_button_return_login_clicked().
int MINLOG |
Log level, or the threshold below which messages are suppressed.
Definition at line 34 of file misc.c.
Referenced by LOG(), and parse_args().
|
static |
Command line options, descriptions, and parameters.
Definition at line 68 of file main.c.
Referenced by on_spell_cast_clicked(), on_spell_invoke_clicked(), and parse_args().
bool profile_latency |
Definition at line 36 of file player.c.
Referenced by CompleteCmd(), and send_command().
GdkColor root_color[NUM_COLORS] |
Definition at line 100 of file main.c.
Referenced by draw_magic_map(), init_ui(), and magic_map_flash_pos().
GtkWidget* window_root |
In main.c
Definition at line 103 of file main.c.
Referenced by auto_afk(), hide_main_client(), image_update_download_status(), init_create_character_window(), init_new_character_window(), init_ui(), load_window_positions(), save_winpos(), and show_main_client().
GtkBuilder * window_xml |
Definition at line 102 of file main.c.
Referenced by info_init(), init_menu_items(), init_ui(), init_ui_layout(), inventory_init(), keys_init(), load_window_positions(), map_init(), pickup_init(), save_winpos(), and stats_init().
char window_xml_file[MAX_BUF] |
Path to the current UI file.
Definition at line 98 of file main.c.
Referenced by config_load(), config_load_legacy(), init_ui(), init_ui_layout(), main(), read_config_dialog(), save_defaults(), setup_config_dialog(), and ui_name().