Crossfire Client, Trunk  R20507
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
client.h File Reference

Includes various dependencies header files needed by most everything. More...

#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"
Include dependency graph for client.h:
This graph shows which files directly or indirectly include this file:

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_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_CACHE   5
 
#define CONFIG_CWINDOW   4
 
#define CONFIG_DARKNESS   22
 
#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_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_NUMS   32
 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_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   31
 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_NORMAL   0
 
#define SOL_TCP   IPPROTO_TCP
 
#define STRINGCOMMAND   0
 
#define VERSION_CS   1023
 
#define VERSION_SC   1029
 

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...
 
void 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...
 

Variables

Animations animations [MAXANIM]
 
const char * cache_dir
 
Race_Class_Infoclasses
 
const char * config_dir
 
const char *const config_names [CONFIG_NUMS]
 See common/init.c - number mapping used when loading/saving the values. More...
 
Client_Player cpl
 Player object. More...
 
ClientSocket csocket
 
guint64 * exp_table
 
guint16 exp_table_max
 
Face_Information face_info
 
TextManagerfirstTextManager
 
int last_used_skills [MAX_SKILL+1]
 maps position to skill id with trailing zero as stop mark. More...
 
int maxfd
 
char * meta_server
 
char * motd
 
char * news
 
int num_classes
 
int num_races
 
PlayerPosition pl_pos
 
Race_Class_Inforaces
 
int replyinfo_last_face
 
int replyinfo_status
 
int requestinfo_sent
 
NameMapping resist_mapping [NUM_RESISTS]
 
const char *const resists_name [NUM_RESISTS]
 
char * rules
 
int serverloginmethod
 
NameMapping skill_mapping [MAX_SKILL]
 
char * skill_names [MAX_SKILL]
 
char * sound_server
 
Starting_Map_Infostarting_map_info
 
int starting_map_number
 
struct Stat_Mapping stat_mapping [NUM_NEW_CHAR_STATS]
 
int stat_maximum
 
int stat_min
 
int stat_points
 
guint32 tick
 
gint16 use_config [CONFIG_NUMS]
 
int used_classes
 
int used_races
 
char VERSION_INFO [256]
 
gint16 want_config [CONFIG_NUMS]
 
int wantloginmethod
 

Detailed Description

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.

Macro Definition Documentation

#define BIG_BUF   1024

Definition at line 41 of file client.h.

Referenced by keybindings_init(), parse_keys_file(), and update_login_info().

#define CLIENT_ERROR   client_error_quark()

Definition at line 638 of file client.h.

Referenced by SockList_ReadPacket().

#define CLIENT_TYPES_H

Definition at line 13 of file client.h.

#define COMMAND_WINDOW   10

Do not send more than this many outstanding commands to the server this is only a default value.

Definition at line 76 of file client.h.

Referenced by init_config(), and set_command_window().

#define DEFPORT   "13327"

Definition at line 65 of file client.h.

#define EPORT   13327

Definition at line 62 of file client.h.

Referenced by init_config(), and parse_meta().

#define MAP_MAX_SIZE   31

Map size the client will request the map to be.

The bigger it is, more memory it will use.

Definition at line 475 of file client.h.

Referenced by config_check(), and map_check_resize().

#define MAX_BUF   256
#define MAX_MAP_OFFSET   8

How many spaces an object might extend off the map.

E.g. For bigimage stuff, the head of the image may be off the the map edge. This is the most it may be off. This is needed To cover case of need_recenter_map routines.

Definition at line 491 of file client.h.

#define MAX_SKILL   CS_NUM_SKILLS

How many skill types server supports/client will get sent to it.

If more skills are added to server, this needs to get increased.

Definition at line 84 of file client.h.

Referenced by client_init(), client_reset(), draw_stats(), get_skill_info(), reset_player_data(), script_process_cmd(), update_skill_information(), and update_stat_mapping().

#define MAX_TIME   100000

Definition at line 59 of file client.h.

#define MAXANIM   2000

Definition at line 86 of file client.h.

Referenced by AnimCmd(), and mapdata_animation().

#define MAXPIXMAPNUM   10000
#define MIN (   X__,
  Y__ 
)    ( (X__)<(Y__)?(X__):(Y__) )

Definition at line 624 of file client.h.

#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.

Definition at line 484 of file client.h.

#define NUM_NEW_CHAR_STATS   7
#define NUM_RESISTS   18

Translation of the STAT_RES names into printable names, in matching order.

Definition at line 451 of file client.h.

Referenced by draw_stats(), and update_stat_mapping().

#define SOL_TCP   IPPROTO_TCP

Definition at line 37 of file client.h.

Referenced by client_connect(), and read_config_dialog().

#define STRINGCOMMAND   0

Definition at line 78 of file client.h.

#define VERSION_CS   1023

Definition at line 67 of file client.h.

Referenced by ms_check_version(), SendVersion(), and VersionCmd().

#define VERSION_SC   1029

Definition at line 68 of file client.h.

Referenced by ms_check_version(), SendVersion(), and VersionCmd().

Typedef Documentation

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)

Definition at line 45 of file client.h.

One struct that holds most of the image related data to reduce danger of namespace collision.

typedef struct FaceSets_struct FaceSets
typedef struct Spell_struct Spell
typedef struct Stat_struct Stats
typedef struct TextManager TextManager

Enumeration Type Documentation

Enumerator
CLIENT_ERROR_TOOBIG 

Definition at line 644 of file client.h.

Enumerator
Playing 
Reply_One 
Reply_Many 
Configure_Keys 
Command_Mode 
Metaserver_Select 

Definition at line 139 of file client.h.

enum LogLevel
Enumerator
LOG_DEBUG 

Useful debugging information.

LOG_INFO 

Minor, non-harmful issues.

LOG_WARNING 

Warning that something might not work.

LOG_ERROR 

Warning that something definitely didn't work.

LOG_CRITICAL 

Fatal crash-worthy error.

Definition at line 440 of file client.h.

enum rangetype
Enumerator
range_bottom 
range_none 
range_bow 
range_magic 
range_wand 
range_rod 
range_scroll 
range_horn 
range_steal 
range_size 

Definition at line 144 of file client.h.

Function Documentation

void client_connect ( const char *  hostname)

Open a socket to the given hostname and store connection information.

Parameters
hostnameHost 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 180 of file client.c.

References 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().

Here is the call graph for this function:

Here is the caller graph for this function:

GQuark client_error_quark ( )
inline

Definition at line 640 of file client.h.

GSource* client_get_source ( void  )

Return a source triggered when input from the server is available.

Definition at line 293 of file client.c.

References in.

Referenced by event_loop().

Here is the caller graph for this function:

bool client_is_connected ( void  )

Definition at line 289 of file client.c.

References ClientSocket::fd.

Referenced by do_network(), and on_disconnect_activate().

Here is the caller graph for this function:

void client_mapsize ( int  width,
int  height 
)

Ask the server for the given map size.

Definition at line 170 of file client.c.

References CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, cs_print_string(), ClientSocket::fd, height, mapdata_set_size(), use_config, and width.

Referenced by client_negotiate(), and map_check_resize().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
soundNon-zero to ask for sound and music commands.

Definition at line 298 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, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 187 of file client.c.

References SockList::buf, client_disconnect(), CmdMapping::cmdformat, CmdMapping::cmdname, CmdMapping::cmdproc, ClientSocket::fd, SockList::len, LOG(), LOG_ERROR, MAXSOCKBUF, NCOMMANDS, script_watch(), and SockList_ReadPacket().

Referenced by client_negotiate(), and do_network().

Here is the call graph for this function:

Here is the caller graph for this function:

bool client_write ( const void *  buf,
int  len 
)

Write the given data to the server.

Variable Documentation

Animations animations[MAXANIM]
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
const char * config_dir
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().

ClientSocket csocket
guint64* exp_table

Definition at line 64 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 63 of file client.c.

Referenced by client_init(), draw_message_window(), get_exp_info(), and update_skill_information().

Face_Information face_info
TextManager* firstTextManager

Definition at line 1216 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 init_sockets().

char* meta_server
char * motd

Definition at line 555 of file client.h.

Referenced by client_reset(), ReplyInfoCmd(), and update_login_info().

char * news

Definition at line 555 of file client.h.

Referenced by client_reset(), ReplyInfoCmd(), and update_login_info().

int num_classes

Definition at line 90 of file commands.c.

Referenced by client_reset(), get_class_info(), new_char_window_update_info(), and ReplyInfoCmd().

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().

int replyinfo_last_face

Definition at line 58 of file client.c.

Referenced by client_negotiate(), and get_image_sums().

int replyinfo_status

Definition at line 57 of file client.c.

Referenced by client_negotiate(), and get_image_info().

int requestinfo_sent

Definition at line 57 of file client.c.

Referenced by client_negotiate().

NameMapping resist_mapping[NUM_RESISTS]

Definition at line 66 of file client.c.

Referenced by draw_stats(), and update_stat_mapping().

const char* const resists_name[NUM_RESISTS]

Definition at line 72 of file client.c.

Referenced by update_stat_mapping().

char * rules

Definition at line 555 of file client.h.

Referenced by client_reset(), ReplyInfoCmd(), and update_login_info().

int serverloginmethod
NameMapping skill_mapping[MAX_SKILL]

Definition at line 66 of file client.c.

Referenced by draw_stats(), update_skill_information(), and update_stat_mapping().

char* skill_names[MAX_SKILL]
char* sound_server

Definition at line 51 of file client.c.

Referenced by init_sounds().

Starting_Map_Info* starting_map_info
int starting_map_number
struct Stat_Mapping stat_mapping[NUM_NEW_CHAR_STATS]
int stat_maximum

Definition at line 95 of file commands.c.

Referenced by get_new_char_info(), new_char_window_update_info(), and reset_vars_common().

int stat_min

Definition at line 94 of file commands.c.

Referenced by get_new_char_info(), new_char_window_update_info(), and reset_vars_common().

int stat_points
guint32 tick

Definition at line 61 of file client.c.

Referenced by animate_inventory(), animate_look(), do_timeout(), and TickCmd().

gint16 use_config[CONFIG_NUMS]
int used_classes

Definition at line 91 of file commands.c.

Referenced by client_reset(), get_class_info(), new_char_window_update_info(), and ReplyInfoCmd().

int used_races

Definition at line 88 of file commands.c.

Referenced by client_reset(), get_race_info(), new_char_window_update_info(), and ReplyInfoCmd().

char VERSION_INFO[256]

Definition at line 48 of file client.c.

Referenced by main(), parse_args(), and SendVersion().

gint16 want_config[CONFIG_NUMS]
int wantloginmethod

Definition at line 59 of file client.c.

Referenced by client_negotiate(), and init_sockets().