![]() |
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 |
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. More... | |
struct | ClientSocket |
Basic support for socket communications, including the file descriptor, input buffer, server, server, version, etc. More... | |
struct | Face_Information_struct |
One struct that holds most of the image related data to reduce danger of namespace collision. More... | |
struct | FaceSets_struct |
struct | Msg_Type_Names |
struct | NameMapping |
Holds the names that correspond to skill and resistance numbers. More... | |
struct | Player_Struct |
struct | PlayerPosition |
struct | Race_Class_Info |
struct | RC_Choice |
For classes & races, the server can present some number of choices, eg, the character gets to choose 1 skill from a choice of many. More... | |
struct | Spell_struct |
struct | Starting_Map_Info |
struct | Stat_Mapping |
The usage of the stat_mapping is to simplify the code and make it easier to expand. More... | |
struct | Stat_struct |
struct | TextManager |
Macros | |
#define | BIG_BUF 1024 |
#define | CFG_DM_OPENGL 2 |
#define | CFG_DM_PIXMAP 0 |
#define | CFG_DM_SDL 1 |
#define | CFG_LT_NONE 0 |
#define | CFG_LT_PIXEL 2 |
#define | CFG_LT_PIXEL_BEST 3 |
#define | CFG_LT_TILE 1 |
#define | CLIENT_ERROR client_error_quark() |
#define | CLIENT_TYPES_H |
#define | COMMAND_MAX 255 |
Largest ncom command number to send before wrapping. More... | |
#define | COMMAND_WINDOW 10 |
Do not send more than this many outstanding commands to the server this is only a default value. More... | |
#define | CONFIG_APPLY_CONTAINER 28 |
Reapply container. More... | |
#define | CONFIG_AUTO_AFK 32 |
#define | CONFIG_CACHE 5 |
#define | CONFIG_CWINDOW 4 |
#define | CONFIG_DARKNESS 22 |
#define | CONFIG_DEBOUNCE 36 |
#define | CONFIG_DISPLAYMODE 10 |
#define | CONFIG_DOWNLOAD 1 |
#define | CONFIG_ECHO 2 |
#define | CONFIG_FASTTCP 3 |
#define | CONFIG_FOGWAR 6 |
#define | CONFIG_FOODBEEP 21 |
#define | CONFIG_GRAD_COLOR 24 |
#define | CONFIG_ICONSCALE 7 |
#define | CONFIG_INV_MENU 33 |
#define | CONFIG_LIGHTING 17 |
#define | CONFIG_MAPHEIGHT 20 |
#define | CONFIG_MAPSCALE 8 |
#define | CONFIG_MAPSCROLL 29 |
Use bitmap operations for map scrolling. More... | |
#define | CONFIG_MAPWIDTH 19 |
#define | CONFIG_MUSIC_VOL 34 |
#define | CONFIG_NUMS 37 |
This should always be the last value in the CONFIG_xxx list. More... | |
#define | CONFIG_POPUPS 9 |
#define | CONFIG_PORT 23 |
Is this useful any more? More... | |
#define | CONFIG_RESISTS 25 |
#define | CONFIG_SERVER_TICKS 35 |
#define | CONFIG_SHOWGRID 16 |
#define | CONFIG_SHOWICON 11 |
#define | CONFIG_SIGNPOPUP 30 |
#define | CONFIG_SMOOTH 26 |
#define | CONFIG_SOUND 13 |
#define | CONFIG_SPLASH 27 |
#define | CONFIG_SPLITINFO 14 |
#define | CONFIG_SPLITWIN 15 |
#define | CONFIG_TIMESTAMP 31 |
#define | CONFIG_TOOLTIPS 12 |
#define | CONFIG_TRIMINFO 18 |
#define | DEFPORT "13327" |
#define | EPORT 13327 |
#define | INFO_MOTD 2 |
#define | INFO_NEWS 1 |
#define | INFO_RULES 3 |
#define | MAP_MAX_SIZE 25 |
Map size the client will request the map to be. More... | |
#define | MAX_BUF 256 |
#define | MAX_FACE_SETS 20 |
#define | MAX_IMAGE_SIZE 320 |
Maximum size of image in each direction. More... | |
#define | MAX_MAP_OFFSET 8 |
How many spaces an object might extend off the map. More... | |
#define | MAX_SKILL CS_NUM_SKILLS |
How many skill types server supports/client will get sent to it. More... | |
#define | MAX_TIME 100000 |
#define | MAXANIM 2000 |
#define | MAXPIXMAPNUM 10000 |
#define | MIN(X__, Y__) ( (X__)<(Y__)?(X__):(Y__) ) |
#define | MIN_ALLOCATED_MAP_SIZE MAP_MAX_SIZE * 2 |
This is the smallest the map structure used for the client can be. More... | |
#define | NUM_NEW_CHAR_STATS 7 |
#define | NUM_RESISTS 18 |
Translation of the STAT_RES names into printable names, in matching order. More... | |
#define | RI_IMAGE_INFO 0x1 |
#define | RI_IMAGE_SUMS 0x2 |
#define | SC_ALWAYS 2 |
#define | SC_FIRERUN 1 |
#define | SC_MOVETO 3 |
#define | SC_NORMAL 0 |
#define | SOL_TCP IPPROTO_TCP |
#define | STRINGCOMMAND 0 |
#define | VERSION_CS 1023 |
#define | VERSION_SC 1030 |
Typedefs | |
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. More... | |
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. More... | |
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) |
Open a socket to the given hostname and store connection information. More... | |
void | client_disconnect (void) |
Closes the connection to the server. More... | |
GQuark | client_error_quark () |
GSource * | client_get_source (void) |
Return a source triggered when input from the server is available. More... | |
bool | client_is_connected (void) |
void | client_mapsize (int width, int height) |
Ask the server for the given map size. More... | |
bool | client_negotiate (int sound) |
This function negotiates the characteriistics of a connection to the server. More... | |
void | client_run (void) |
Read available packets from the server and handle commands until there are no more, or if a socket error occurs. More... | |
bool | client_write (const void *buf, int len) |
Write the given data to the server. More... | |
char * | printable (void *data, int len) |
Replace the non-printable characters in 'data' with a dot ('. More... | |
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 37 |
#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(), 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 325 of file client.c.
References in.
Referenced by event_loop().
bool client_is_connected | ( | void | ) |
Definition at line 321 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().
bool 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 330 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_SERVER_TICKS, 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, debug_protocol, error_dialog(), in, 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 1156 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 611 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_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(), toggle_locked(), and VersionCmd().
bool debug_protocol |
Definition at line 65 of file main.c.
Referenced by client_run(), Map2Cmd(), 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 1245 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 549 of file client.h.
Referenced by client_reset(), ReplyInfoCmd(), and update_login_info().
char * news |
Definition at line 548 of file client.h.
Referenced by client_reset(), and update_login_info().
int num_classes |
Definition at line 550 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(), Map2Cmd(), mapdata_add_label(), mapdata_animation(), mapdata_bigface(), mapdata_clear(), 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 548 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(), SetupCmd(), 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 551 of file client.h.
Referenced by new_char_window_update_info(), and reset_vars_common().
int stat_min |
Definition at line 551 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 245 of file client.h.
Referenced by client_connect(), client_negotiate(), 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(), 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(), on_music_volume_changed(), pl_mpos(), script_process_cmd(), self_tick(), send_command(), set_command_window(), set_music_volume(), SetupCmd(), Sound2Cmd(), and update_stat().
int used_classes |
Definition at line 550 of file client.h.
Referenced by client_reset(), and new_char_window_update_info().
int used_races |
Definition at line 550 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 44 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(), on_music_volume_changed(), read_config_dialog(), reset_image_cache_data(), reset_image_data(), save_defaults(), self_tick(), set_command_window(), setup_config_dialog(), and SetupCmd().