Crossfire Client, Trunk
|
#include "config.h"
#include <fcntl.h>
#include <glib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <gio/gio.h>
#include "item.h"
#include "shared/newclient.h"
#include "version.h"
#include "proto.h"
Go to the source code of this file.
Data Structures | |
struct | Animations |
struct | Cache_Entry |
struct | ClientSocket |
struct | Face_Information_struct |
struct | FaceSets_struct |
struct | Msg_Type_Names |
struct | NameMapping |
struct | Player_Struct |
struct | PlayerPosition |
struct | Race_Class_Info |
struct | RC_Choice |
struct | Spell_struct |
struct | Starting_Map_Info |
struct | Stat_Mapping |
struct | Stat_struct |
struct | TextManager |
Typedefs | |
typedef struct Animations | Animations |
typedef struct Cache_Entry | Cache_Entry |
typedef struct Player_Struct | Client_Player |
typedef void(* | ExtTextManager) (int flag, int type, int subtype, char *message) |
typedef struct Face_Information_struct | Face_Information |
typedef struct FaceSets_struct | FaceSets |
typedef struct Msg_Type_Names | Msg_Type_Names |
typedef struct PlayerPosition | PlayerPosition |
typedef struct Race_Class_Info | Race_Class_Info |
typedef struct Spell_struct | Spell |
typedef struct Starting_Map_Info | Starting_Map_Info |
typedef struct Stat_struct | Stats |
typedef struct TextManager | TextManager |
Enumerations | |
enum | ClientError { CLIENT_ERROR_TOOBIG } |
enum | Input_State { Playing, Reply_One, Reply_Many, Configure_Keys, Command_Mode, Metaserver_Select } |
enum | LogLevel { LOG_DEBUG = 0, LOG_INFO = 1, LOG_WARNING = 2, LOG_ERROR = 3, LOG_CRITICAL = 4 } |
enum | rangetype { range_bottom = -1, range_none = 0, range_bow = 1, range_magic = 2, range_wand = 3, range_rod = 4, range_scroll = 5, range_horn = 6, range_steal = 7, range_size = 8 } |
Functions | |
void | client_connect (const char *hostname) |
void | client_disconnect (void) |
GQuark | client_error_quark () |
GSource * | client_get_source (void) |
bool | client_is_connected (void) |
void | client_mapsize (int width, int height) |
void | client_negotiate (int sound) |
void | client_run (void) |
bool | client_write (const void *buf, int len) |
char * | printable (void *data, int len) |
Includes various dependencies header files needed by most everything. It also declares structures and other variables that the GUI portion needs.
Definition in file client.h.
#define CLIENT_ERROR client_error_quark() |
#define COMMAND_MAX 255 |
#define COMMAND_WINDOW 10 |
#define CONFIG_DISPLAYMODE 10 |
#define CONFIG_LIGHTING 17 |
#define CONFIG_MAPSCROLL 29 |
#define CONFIG_NUMS 34 |
#define MAP_MAX_SIZE 25 |
#define MAX_IMAGE_SIZE 320 |
#define MAX_MAP_OFFSET 8 |
#define MAX_SKILL CS_NUM_SKILLS |
#define MIN_ALLOCATED_MAP_SIZE MAP_MAX_SIZE * 2 |
This is the smallest the map structure used for the client can be. It needs to be bigger than the MAP_MAX_SIZE simply because we have to deal with off map big images, Also, the center point is moved around within this map, so that if the player moves one space, we don't have to move around all the data.
#define NUM_RESISTS 18 |
typedef struct Animations Animations |
typedef struct Cache_Entry Cache_Entry |
Used mostly in the cache.c file, however, it can be returned to the graphic side of things so that they can update the image_data field. Since the common side has no idea what data the graphic side will point to, we use a void pointer for that - it is completely up to the graphic side to allocate/deallocate and cast that pointer as needed.
typedef struct Player_Struct Client_Player |
typedef void(* ExtTextManager) (int flag, int type, int subtype, char *message) |
typedef struct Face_Information_struct Face_Information |
One struct that holds most of the image related data to reduce danger of namespace collision.
typedef struct FaceSets_struct FaceSets |
typedef struct Msg_Type_Names Msg_Type_Names |
typedef struct PlayerPosition PlayerPosition |
typedef struct Race_Class_Info Race_Class_Info |
typedef struct Spell_struct Spell |
typedef struct Starting_Map_Info Starting_Map_Info |
typedef struct Stat_struct Stats |
typedef struct TextManager TextManager |
enum ClientError |
enum Input_State |
enum LogLevel |
enum rangetype |
void client_connect | ( | const char * | hostname | ) |
Open a socket to the given hostname and store connection information.
hostname | Host name or address of the server |
void client_disconnect | ( | void | ) |
Closes the connection to the server. It seems better to have it one place here than the same logic sprinkled about in half a dozen locations. It is also useful in that if this logic does change, there is just one place to update it.
Definition at line 175 of file client.c.
References csocket, ClientSocket::fd, LOG(), and LOG_DEBUG.
Referenced by client_negotiate(), client_run(), do_disconnect(), event_loop(), keyfunc(), on_button_go_metaserver_clicked(), on_disconnect_activate(), and SetupCmd().
GSource* client_get_source | ( | void | ) |
Return a source triggered when input from the server is available.
Definition at line 324 of file client.c.
References in.
Referenced by event_loop().
bool client_is_connected | ( | void | ) |
Definition at line 320 of file client.c.
References csocket, and ClientSocket::fd.
Referenced by do_network(), on_disconnect_activate(), and redraw().
void client_mapsize | ( | int | width, |
int | height | ||
) |
Ask the server for the given map size.
Definition at line 171 of file client.c.
References cs_print_string(), csocket, ClientSocket::fd, height, and width.
Referenced by client_negotiate(), map_check_resize(), and SetupCmd().
void client_negotiate | ( | int | sound | ) |
This function negotiates the characteriistics of a connection to the server. Negotiation consists of asking the server for commands it wants, and checking protocol version for compatibility. Serious incompatibilities abort the connection.
sound | Non-zero to ask for sound and music commands. |
Definition at line 329 of file client.c.
References Face_Information_struct::cache_hits, Face_Information_struct::cache_misses, client_disconnect(), client_mapsize(), client_run(), CONFIG_CACHE, CONFIG_DOWNLOAD, CONFIG_LIGHTING, CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, CONFIG_SMOOTH, cs_print_string(), ClientSocket::cs_version, csocket, draw_ext_info(), face_info, Face_Information_struct::faceset, ClientSocket::fd, image_update_download_status(), LOG(), LOG_ERROR, LOG_WARNING, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_GOLD, Face_Information_struct::num_images, replyinfo_last_face, replyinfo_status, requestinfo_sent, RI_IMAGE_INFO, RI_IMAGE_SUMS, ClientSocket::sc_version, SendAddMe(), SendVersion(), serverloginmethod, use_config, want_config, Face_Information_struct::want_faceset, and wantloginmethod.
Referenced by main().
void client_run | ( | void | ) |
Read available packets from the server and handle commands until there are no more, or if a socket error occurs.
Definition at line 202 of file client.c.
References SockList::buf, client_disconnect(), CmdMapping::cmdformat, CmdMapping::cmdname, CmdMapping::cmdproc, commands, csocket, debug_protocol, error_dialog(), ClientSocket::fd, SockList::len, LOG(), LOG_ERROR, LOG_INFO, MAXSOCKBUF, NCOMMANDS, printable(), script_watch(), and SockList_ReadPacket().
Referenced by client_negotiate(), and do_network().
bool client_write | ( | const void * | buf, |
int | len | ||
) |
Write the given data to the server.
char* printable | ( | void * | data, |
int | len | ||
) |
Replace the non-printable characters in 'data' with a dot ('.') in a newly allocated, NUL-terminated string. Caller must free the result.
Definition at line 186 of file client.c.
Referenced by client_run(), and SockList_Send().
Animations animations[MAXANIM] |
Definition at line 1155 of file commands.c.
Referenced by animate_inventory(), animate_look(), animate_objects(), AnimCmd(), draw_inv_table(), mapdata_animation(), and mapdata_set_anim_layer().
const char* cache_dir |
Definition at line 53 of file client.c.
Referenced by cache_newpng(), finish_face_cmd(), init_common_cache_data(), and init_paths().
Race_Class_Info * classes |
Definition at line 608 of file client.h.
Referenced by client_reset(), create_character_window_show(), new_char_window_update_info(), on_combobox_rcs_changed(), and send_create_player_to_server().
const char* const config_names[CONFIG_NUMS] |
See common/init.c - number mapping used when loading/saving the values.
Definition at line 30 of file init.c.
Referenced by config_load(), config_load_legacy(), and save_defaults().
Client_Player cpl |
Player object.
Definition at line 69 of file client.c.
Referenced by AddspellCmd(), animate_objects(), bind_key(), client_init(), client_tick(), command_take(), configure_keys(), DeleteSpell(), do_inv(), draw_inv(), draw_inv_list(), draw_inv_table(), draw_lists(), draw_look_list(), draw_magic_map(), draw_message_window(), draw_stats(), drawingarea_inventory_table_expose_event(), extended_command(), fire_dir(), focusoutfunc(), get_item_env(), gtk_command_history(), handle_query(), hide_main_client(), item_actions(), item_event_item_deleting(), keybindings_init(), keyfunc(), list_item_drop(), load_theme(), locate_item(), magic_map_flash_pos(), MagicMapCmd(), main(), metaserver_connect_to(), metaserver_show_prompt(), new_player(), on_count_changed(), on_entry_commands_activate(), on_switch_page(), parse_key(), parse_key_release(), redraw(), remove_item(), reset_player_data(), reset_vars_common(), save_keys(), script_init(), script_process_cmd(), send_command(), send_reply(), show_item_menu(), StatsCmd(), stop_fire(), toggle_keybind_scope(), update_skill_information(), update_spell_information(), UpdspellCmd(), and x_set_echo().
ClientSocket csocket |
Definition at line 70 of file client.c.
Referenced by add_character_to_account(), client_connect(), client_disconnect(), client_is_connected(), client_mapsize(), client_negotiate(), client_run(), client_send_apply(), client_send_examine(), client_send_move(), cmd_raw(), command_take(), CompleteCmd(), config_check(), create_character_window_show(), create_new_character(), do_account_change(), do_account_create(), do_account_login(), draw_stats(), get_image_info(), get_new_char_info(), inscribe_magical_scroll(), keybindings_init(), keyfunc(), look_at(), main(), map_check_resize(), mapdata_newmap(), metaserver_connect_to(), play_character(), ReplyInfoCmd(), requestface(), reset_vars_common(), save_keys(), script_init(), script_process_cmd(), send_command(), send_create_player_to_server(), send_mark_obj(), send_reply(), set_item_values(), SetupCmd(), SockList_ReadPacket(), toggle_locked(), and VersionCmd().
bool debug_protocol |
Definition at line 61 of file main.c.
Referenced by client_run(), and SockList_Send().
guint64* exp_table |
Definition at line 65 of file client.c.
Referenced by client_init(), draw_message_window(), get_exp_info(), and update_skill_information().
guint16 exp_table_max |
Definition at line 64 of file client.c.
Referenced by client_init(), draw_message_window(), get_exp_info(), and update_skill_information().
Face_Information face_info |
Definition at line 169 of file image.c.
Referenced by cache_newpng(), client_init(), client_negotiate(), client_reset(), config_load(), config_load_legacy(), get_image_info(), load_image(), map_init(), read_config_dialog(), requestface(), reset_vars_common(), save_defaults(), setup_config_dialog(), and SetupCmd().
TextManager* firstTextManager |
Definition at line 1244 of file commands.c.
Referenced by getTextManager(), and setTextManager().
int last_used_skills[MAX_SKILL+1] |
maps position to skill id with trailing zero as stop mark.
Definition at line 55 of file client.c.
Referenced by client_init(), and use_skill().
int maxfd |
Definition at line 58 of file client.c.
Referenced by do_network(), and script_fdset().
char* meta_server |
char * motd |
Definition at line 546 of file client.h.
Referenced by client_reset(), ReplyInfoCmd(), and update_login_info().
char * news |
Definition at line 545 of file client.h.
Referenced by client_reset(), and update_login_info().
int num_classes |
Definition at line 547 of file client.h.
Referenced by client_reset(), and new_char_window_update_info().
int num_races |
Definition at line 87 of file commands.c.
Referenced by client_reset(), get_race_info(), new_char_window_update_info(), and ReplyInfoCmd().
PlayerPosition pl_pos |
Position of the player on the internal map. Internal to the client.
Definition at line 30 of file mapdata.c.
Referenced by expand_clear_bigface(), expand_set_bigface(), ExtSmooth(), gtk_map_redraw(), mapdata_animation(), mapdata_bigface(), mapdata_clear_old(), mapdata_clear_space(), mapdata_face(), mapdata_init(), mapdata_scroll(), mapdata_set_anim_layer(), mapdata_set_check_space(), mapdata_set_darkness(), mapdata_set_face_layer(), mapdata_set_size(), mapdata_set_smooth(), pl_mpos(), recenter_virtual_map_view(), and script_process_cmd().
Race_Class_Info* races |
Definition at line 98 of file commands.c.
Referenced by client_reset(), create_character_window_show(), get_race_info(), new_char_window_update_info(), on_combobox_rcs_changed(), ReplyInfoCmd(), and send_create_player_to_server().
int replyinfo_status |
Definition at line 57 of file client.c.
Referenced by client_negotiate(), and get_image_info().
NameMapping resist_mapping[NUM_RESISTS] |
const char* const resists_name[NUM_RESISTS] |
Definition at line 73 of file client.c.
Referenced by update_stat_mapping().
char * rules |
Definition at line 545 of file client.h.
Referenced by client_reset(), and update_login_info().
int serverloginmethod |
Definition at line 62 of file client.c.
Referenced by client_negotiate(), client_reset(), main(), on_button_create_character_clicked(), and start_login().
NameMapping skill_mapping[MAX_SKILL] |
Definition at line 67 of file client.c.
Referenced by draw_stats(), update_skill_information(), and update_stat_mapping().
char* skill_names[MAX_SKILL] |
Definition at line 50 of file client.c.
Referenced by AddspellCmd(), client_init(), client_reset(), draw_stats(), get_skill_info(), script_process_cmd(), and update_stat_mapping().
Starting_Map_Info* starting_map_info |
Definition at line 99 of file commands.c.
Referenced by free_all_starting_map_info(), get_starting_map_info(), on_combobox_starting_map_changed(), send_create_player_to_server(), and starting_map_update_info().
int starting_map_number |
Definition at line 96 of file commands.c.
Referenced by character_data_ok(), create_character_set_sensitive(), free_all_starting_map_info(), get_starting_map_info(), send_create_player_to_server(), and starting_map_update_info().
struct Stat_Mapping stat_mapping[NUM_NEW_CHAR_STATS] |
Definition at line 118 of file commands.c.
Referenced by init_create_character_window(), on_combobox_rcs_changed(), process_race_class_info(), and send_create_player_to_server().
int stat_maximum |
Definition at line 548 of file client.h.
Referenced by new_char_window_update_info(), and reset_vars_common().
int stat_min |
Definition at line 548 of file client.h.
Referenced by new_char_window_update_info(), and reset_vars_common().
int stat_points |
Definition at line 93 of file commands.c.
Referenced by character_data_ok(), create_character_window_show(), get_new_char_info(), new_char_window_update_info(), reset_vars_common(), and update_all_stats().
gint16 use_config[CONFIG_NUMS] |
Definition at line 242 of file client.h.
Referenced by client_connect(), client_negotiate(), client_tick(), command_foodbeep(), config_check(), config_load(), coord_to_tile(), create_and_rescale_image_from_data(), display_newpng(), draw_darkness(), draw_map(), draw_message_window(), Face2Cmd(), get_map_image_size(), gtk_map_redraw(), IS_DIFFERENT(), keyfunc(), list_item_action(), main(), map_check_resize(), map_draw_layer(), map_init(), mapcell_darkness(), MusicCmd(), on_entry_commands_activate(), pl_mpos(), script_process_cmd(), send_command(), set_command_window(), SetupCmd(), Sound2Cmd(), and update_stat().
int used_classes |
Definition at line 547 of file client.h.
Referenced by client_reset(), and new_char_window_update_info().
int used_races |
Definition at line 547 of file client.h.
Referenced by client_reset(), and new_char_window_update_info().
char VERSION_INFO[256] |
Definition at line 48 of file client.c.
Referenced by main(), parse_args(), and SendVersion().
gint16 want_config[CONFIG_NUMS] |
Definition at line 41 of file init.c.
Referenced by client_negotiate(), command_foodbeep(), config_check(), config_load(), config_load_legacy(), do_set_mapscale(), draw_ext_info(), init_common_cache_data(), init_config(), IS_DIFFERENT(), main(), map_check_resize(), mapdata_scroll(), on_auto_afk_response(), read_config_dialog(), reset_image_cache_data(), reset_image_data(), save_defaults(), set_command_window(), setup_config_dialog(), and SetupCmd().