Go to the documentation of this file.
37 #ifdef HAVE_GIO_GNETWORKING_H
38 #include <gio/gnetworking.h>
71 static GInputStream *
in;
74 "armor",
"magic",
"fire",
"elec",
75 "cold",
"conf",
"acid",
"drain",
76 "ghit",
"pois",
"slow",
"para",
77 "t undead",
"fear",
"depl",
"death",
81 typedef void (*
CmdProc)(
unsigned char *,
int len);
167 #define NCOMMANDS ((int)(sizeof(commands)/sizeof(struct CmdMapping)))
176 LOG(
LOG_DEBUG,
"close_server_connection",
"Closing server connection");
177 g_io_stream_close(G_IO_STREAM(
csocket.
fd), NULL, NULL);
187 char *buf = (
char *)malloc(len+1);
189 memcpy(buf, data, len);
190 for (
int i = 0; i < len; i++) {
191 if (!isprint(buf[i])) {
193 }
else if (buf[i] ==
'\n' || buf[i] ==
'\r') {
218 if (inbuf.
len == 0) {
226 inbuf.
buf[inbuf.
len] =
'\0';
227 unsigned char* data = inbuf.
buf + 2;
233 while ((*data !=
' ') && (*data !=
'\0')) {
240 len = inbuf.
len - (data - inbuf.
buf);
250 const char *cmdin = (
char *)inbuf.
buf + 2;
253 if (data_print != NULL) {
254 LOG(
LOG_INFO,
"S->C",
"len=%d cmd=%s |%s|", len, cmdin, data_print);
276 LOG(
LOG_ERROR,
"client_run",
"Unrecognized command from server (%s)\n",
279 "The server sent an unrecognized command. "
280 "Crossfire Client will now disconnect."
281 "\n\nIf this problem persists with a particular "
282 "character, try playing another character, and without "
283 "disconnecting, playing the problematic character again.");
290 GSocketClient *sclient = g_socket_client_new();
299 csocket.
fd = g_socket_client_connect_to_host(
301 g_object_unref(sclient);
306 GSocket *socket = g_socket_connection_get_socket(
csocket.
fd);
307 int i = 1, fd = g_socket_get_fd(socket);
309 #ifdef HAVE_GIO_GNETWORKING_H
311 if (setsockopt(fd,
SOL_TCP, TCP_NODELAY, &i,
sizeof(i)) == -1) {
312 perror(
"TCP_NODELAY");
317 in = g_io_stream_get_input_stream(G_IO_STREAM(
csocket.
fd));
325 return g_pollable_input_stream_create_source(
326 G_POLLABLE_INPUT_STREAM(
in), NULL);
351 LOG (
LOG_ERROR,
"common::negotiate_connection",
"Connection timed out");
358 LOG (
LOG_WARNING,
"common::negotiate_connection",
"Server does not support PNG images, yet that is all this client");
359 LOG (
LOG_WARNING,
"common::negotiate_connection",
"supports. Either the server needs to be upgraded, or you need to");
360 LOG (
LOG_WARNING,
"common::negotiate_connection",
"downgrade your client.");
379 "map2cmd 1 tick 1 sound2 %d darkness %d spellmon 1 spellmon 2 "
380 "faceset %d facecache %d want_pickup 1 loginmethod %d newmapcmd 1 extendedTextInfos 1",
409 int last_end=0, last_start=-99;
474 snprintf(buf,
sizeof(buf),
"Download of images complete. Found %d locally, downloaded %d from server\n",
void DeleteSpell(unsigned char *data, int len)
bool SockList_ReadPacket(GSocketConnection c[static 1], SockList sl[static 1], size_t len, GError **error)
@ LOG_INFO
Minor, non-harmful issues.
void script_watch(const char *cmd, const guint8 *data_initial, const int data_len, const enum CmdFormat format)
void TickCmd(guint8 *data, int len)
@ LOG_WARNING
Warning that something might not work.
void(* CmdProc)(unsigned char *, int len)
void GoodbyeCmd(char *data, int len)
struct CmdMapping commands[]
void DeleteItem(unsigned char *data, int len)
void handle_query(char *data, int len)
NameMapping resist_mapping[NUM_RESISTS]
Face_Information face_info
void DrawExtInfoCmd(char *data, int len)
void ReplyInfoCmd(unsigned char *buf, int len)
bool client_is_connected()
void AddMeFail(char *data, int len)
const char *const resists_name[NUM_RESISTS]
void PlayerCmd(unsigned char *data, int len)
void SmoothCmd(unsigned char *data, int len)
void client_connect(const char hostname[static 1])
void MapExtendedCmd(unsigned char *data, int len)
char VERSION_INFO[MAX_BUF]
NameMapping skill_mapping[MAX_SKILL]
void SinkCmd(unsigned char *data, int len)
void NewmapCmd(unsigned char *data, int len)
int last_used_skills[MAX_SKILL+1]
void FailureCmd(char *buf, int len)
GSource * client_get_source()
void SendAddMe(ClientSocket csock)
void MusicCmd(const char *data, int len)
void image_update_download_status(int start, int end, int total)
void Map2Cmd(unsigned char *data, int len)
void PickupCmd(guint8 *data, int len)
void(* cmdproc)(unsigned char *, int)
void map_scrollCmd(char *data, int len)
void LOG(LogLevel level, const char *origin, const char *format,...)
GQuark client_error_quark()
int cs_print_string(GSocketConnection *fd, const char *str,...)
void DrawInfoCmd(char *data, int len)
gint16 want_config[CONFIG_NUMS]
void draw_ext_info(int orig_color, int type, int subtype, const char *message)
void Face2Cmd(guint8 *data, int len)
void StatsCmd(unsigned char *data, int len)
void SendVersion(ClientSocket csock)
void UpdspellCmd(unsigned char *data, int len)
char * printable(void *data, int len)
@ LOG_ERROR
Warning that something definitely didn't work.
void Image2Cmd(guint8 *data, int len)
#define MSG_TYPE_CLIENT_CONFIG
void Item2Cmd(unsigned char *data, int len)
void AddMeSuccess(char *data, int len)
void MagicMapCmd(unsigned char *data, int len)
void error_dialog(char *error, char *message)
void AddspellCmd(unsigned char *data, int len)
void AnimCmd(unsigned char *data, int len)
gint16 use_config[CONFIG_NUMS]
void AccountPlayersCmd(char *buf, int len)
void DeleteInventory(unsigned char *data, int len)
void Sound2Cmd(unsigned char *data, int len)
unsigned char buf[MAXSOCKBUF]
void SetupCmd(char *buf, int len)
char * skill_names[MAX_SKILL]
@ LOG_DEBUG
Useful debugging information.
void VersionCmd(char *data, int len)
void client_mapsize(int width, int height)
void UpdateItemCmd(unsigned char *data, int len)
void CompleteCmd(unsigned char *data, int len)
void client_negotiate(int sound)