Crossfire Server, Trunk  1.75.0
sockproto.h
Go to the documentation of this file.
1 /* image.c */
2 int is_valid_faceset(int fsn);
3 void set_face_mode_cmd(char *buf, int len, socket_struct *ns);
4 void send_face_cmd(char *buff, int len, socket_struct *ns);
5 void esrv_send_face(socket_struct *ns, const Face *face, int nocache);
7 void send_image_sums(socket_struct *ns, char *params);
8 /* info.c */
9 void print_ext_msg(socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message);
10 void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message);
11 void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format, ...) PRINTF_ARGS(6, 7);
12 void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1);
13 void ext_info_map_except(int color, const mapstruct *map, const object *op, uint8_t type, uint8_t subtype, const char *str1);
14 void ext_info_map_except2(int color, const mapstruct *map, const object *op1, const object *op2, int type, int subtype, const char *str1);
15 void rangetostring(const object *pl, char *obuf, size_t len);
16 void set_title(const object *pl, char *buf, size_t len);
17 void magic_mapping_mark(object *pl, char *map_mark, int strength);
18 void draw_magic_map(object *pl);
19 /* init.c */
20 void init_connection(socket_struct *ns, const char *from_ip);
22 void init_server(void);
23 void free_all_newserver(void);
25 void final_free_player(player *pl);
26 /* item.c */
27 void esrv_draw_look(object *pl);
28 void esrv_send_inventory(object *pl, object *op);
29 void esrv_update_item(int flags, object *pl, object *op);
30 void esrv_send_item(object *pl, object *op);
31 void esrv_del_item(player *pl, object *ob);
32 void examine_cmd(char *buf, int len, player *pl);
33 void apply_cmd(char *buf, int len, player *pl);
34 void lock_item_cmd(uint8_t *data, int len, player *pl);
35 void mark_item_cmd(uint8_t *data, int len, player *pl);
36 void look_at(object *op, int dx, int dy);
37 void look_at_cmd(char *buf, int len, player *pl);
38 void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof);
39 void inscribe_scroll_cmd(char *buf, int len, player *pl);
40 /* loop.c */
41 void request_info_cmd(char *buf, int len, socket_struct *ns);
42 bool handle_client(socket_struct *ns, player *pl);
43 void watchdog(void);
44 void do_server(void);
45 void update_players(void);
46 /* lowlevel.c */
47 void SockList_Init(SockList *sl);
48 void SockList_Term(SockList *sl);
49 void SockList_Reset(SockList *sl);
51 void SockList_AddChar(SockList *sl, unsigned char c);
52 void SockList_AddShort(SockList *sl, uint16_t data);
53 void SockList_AddInt(SockList *sl, uint32_t data);
54 void SockList_AddInt64(SockList *sl, uint64_t data);
55 size_t SockList_Avail(const SockList *sl);
56 void SockList_AddString(SockList *sl, const char *data);
57 void SockList_AddData(SockList *sl, const void *data, size_t len);
58 void SockList_AddLen8Data(SockList *sl, const void *data, size_t len);
59 void SockList_AddLen16Data(SockList *sl, const void *data, size_t len);
60 void SockList_AddPrintf(SockList *sl, const char *format, ...);
63 int GetInt_String(const unsigned char *data);
64 short GetShort_String(const unsigned char *data);
65 int SockList_ReadPacket(int fd, SockList *sl, int len);
67 void reset_stats(struct CS_Stats *stats);
68 void write_cs_stats(void);
69 /* metaserver.c */
70 int count_players(void);
71 void metaserver_update(void);
72 int metaserver2_init(void);
73 void metaserver2_exit();
74 /* request.c */
75 void set_up_cmd(char *buf, int len, socket_struct *ns);
76 void add_me_cmd(char *buf, int len, socket_struct *ns);
77 void toggle_extended_infos_cmd(char *buf, int len, socket_struct *ns);
78 void toggle_extended_text_cmd(char *buf, int len, socket_struct *ns);
79 void ask_smooth_cmd(char *buf, int len, socket_struct *ns);
80 void new_player_cmd(uint8_t *buf, int len, player *pl);
81 void reply_cmd(char *buf, int len, player *pl);
82 void version_cmd(char *buf, int len, socket_struct *ns);
83 void set_sound_cmd(char *buf, int len, socket_struct *ns);
85 void move_cmd(char *buf, int len, player *pl);
86 void send_query(socket_struct *ns, uint8_t flags, const char *text);
87 void esrv_update_stats(player *pl);
88 void esrv_new_player(player *pl, uint32_t weight);
89 void esrv_send_animation(socket_struct *ns, const Animations *anim);
90 void draw_client_map(object *pl);
91 void esrv_map_scroll(socket_struct *ns, int dx, int dy);
92 void send_plugin_custom_message(object *pl, char *buf);
94 void send_skill_info(socket_struct *ns, char *params);
95 void send_skill_extra(socket_struct *ns, char *params);
98 void send_race_info(socket_struct *ns, char *params);
100 void send_class_info(socket_struct *ns, char *params);
101 void esrv_update_spells(player *pl);
102 void esrv_remove_spell(player *pl, object *spell);
103 void esrv_send_pickup(player *pl);
104 void esrv_add_spells(player *pl, object *spell);
105 void send_tick(player *pl);
106 void send_file(socket_struct *ns, const char *file);
107 void account_login_cmd(char *buf, int len, socket_struct *ns);
108 void account_new_cmd(char *buf, int len, socket_struct *ns);
109 void account_add_player_cmd(char *buf, int len, socket_struct *ns);
110 void account_play_cmd(char *buf, int len, socket_struct *ns);
112 void create_player_cmd(char *buf, int len, socket_struct *ns);
113 void account_password(char *buf, int len, socket_struct *ns);
114 /* requestinfo.c */
116 void send_map_info(socket_struct *ns);
117 /* sounds.c */
118 void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action);
119 void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action);
120 void send_background_music(player *pl, const char *music);
121 void player_update_bg_music(object *player);
Face
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
send_image_info
void send_image_info(socket_struct *ns)
Sends the number of images, checksum of the face file, and the image_info file information.
Definition: image.cpp:113
SockList_AddInt
void SockList_AddInt(SockList *sl, uint32_t data)
Adds a 32 bit value.
Definition: lowlevel.cpp:127
send_image_sums
void send_image_sums(socket_struct *ns, char *params)
Sends requested face information.
Definition: image.cpp:138
reply_cmd
void reply_cmd(char *buf, int len, player *pl)
This is a reply to a previous query.
Definition: request.cpp:589
print_ext_msg
void print_ext_msg(socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message)
Draws an extended message on the client.
Definition: info.cpp:62
SockList_AddInt64
void SockList_AddInt64(SockList *sl, uint64_t data)
Adds a 64 bit value.
Definition: lowlevel.cpp:140
init_connection
void init_connection(socket_struct *ns, const char *from_ip)
Initializes a connection.
Definition: init.cpp:96
request_info_cmd
void request_info_cmd(char *buf, int len, socket_struct *ns)
request_info_cmd is sort of a meta command.
Definition: loop.cpp:136
player
One player.
Definition: player.h:105
esrv_map_scroll
void esrv_map_scroll(socket_struct *ns, int dx, int dy)
Definition: request.cpp:1708
socket_struct
Socket structure, represents a client-server connection.
Definition: newserver.h:89
init_server
void init_server(void)
This sets up the listening socket.
Definition: init.cpp:283
esrv_new_player
void esrv_new_player(player *pl, uint32_t weight)
Tells the client that here is a player it should start using.
Definition: request.cpp:1008
esrv_send_inventory
void esrv_send_inventory(object *pl, object *op)
Sends inventory of a container.
Definition: item.cpp:316
c
static event_registration c
Definition: citylife.cpp:422
SockList_AddString
void SockList_AddString(SockList *sl, const char *data)
Adds a string without length.
Definition: lowlevel.cpp:157
PRINTF_ARGS
#define PRINTF_ARGS(x, y)
Used for printf-like functions, mostly LOG and draw_ext_info_format.
Definition: global.h:46
do_server
void do_server(void)
This checks the sockets for input and exceptions, does the right thing.
Definition: loop.cpp:524
esrv_send_pickup
void esrv_send_pickup(player *pl)
Sends the "pickup" state to pl if client wants it requested.
Definition: request.cpp:1835
mark_item_cmd
void mark_item_cmd(uint8_t *data, int len, player *pl)
Client wants to mark some object.
Definition: item.cpp:767
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
play_sound_player_only
void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
Plays a sound for specified player only.
Definition: sounds.cpp:51
send_new_char_info
void send_new_char_info(socket_struct *ns)
Sends information related to creating a new character to the client.
Definition: requestinfo.cpp:520
free_all_newserver
void free_all_newserver(void)
Free's all the memory that ericserver allocates.
Definition: init.cpp:401
play_sound_map
void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action)
Plays a sound on a map.
Definition: sounds.cpp:113
flags
static const flag_definition flags[]
Flag mapping.
Definition: gridarta-types-convert.cpp:101
send_map_info
void send_map_info(socket_struct *ns)
Send information on available start maps.
Definition: requestinfo.cpp:441
esrv_update_spells
void esrv_update_spells(player *pl)
This looks for any spells the player may have that have changed their stats.
Definition: main.cpp:386
send_exp_table
void send_exp_table(socket_struct *ns)
This sends the experience table the sever is using.
Definition: requestinfo.cpp:158
send_account_players
void send_account_players(socket_struct *ns)
Upon successful login/account creation, we send a list of characters associated with the account to t...
Definition: request.cpp:2058
esrv_add_spells
void esrv_add_spells(player *pl, object *spell)
This tells the client to add the spell *spell, if spell is NULL, then add all spells in the player's ...
Definition: request.cpp:1949
SockList_AddLen16Data
void SockList_AddLen16Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 16 bit length field.
Definition: lowlevel.cpp:191
toggle_extended_infos_cmd
void toggle_extended_infos_cmd(char *buf, int len, socket_struct *ns)
SockList_Reset
void SockList_Reset(SockList *sl)
Resets the length of the stored data for writing.
Definition: lowlevel.cpp:74
buf
StringBuffer * buf
Definition: readable.cpp:1565
esrv_send_item
void esrv_send_item(object *pl, object *op)
Sends item's info to player.
Definition: main.cpp:354
SockList_Avail
size_t SockList_Avail(const SockList *sl)
Returns the available bytes in a SockList instance.
Definition: lowlevel.cpp:246
GetShort_String
short GetShort_String(const unsigned char *data)
Definition: lowlevel.cpp:258
account_password
void account_password(char *buf, int len, socket_struct *ns)
Handles the account password change.
Definition: request.cpp:3052
send_skill_info
void send_skill_info(socket_struct *ns, char *params)
This sends the skill number to name mapping.
Definition: requestinfo.cpp:71
account_login_cmd
void account_login_cmd(char *buf, int len, socket_struct *ns)
Handles the account login.
Definition: request.cpp:2185
look_at_cmd
void look_at_cmd(char *buf, int len, player *pl)
Client wants to look at some object.
Definition: item.cpp:869
set_title
void set_title(const object *pl, char *buf, size_t len)
Sets player title.
Definition: info.cpp:334
esrv_remove_spell
void esrv_remove_spell(player *pl, object *spell)
Definition: request.cpp:1812
final_free_player
void final_free_player(player *pl)
Sends the 'goodbye' command to the player, and closes connection.
Definition: init.cpp:453
esrv_send_face
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
Sends a face to a client if they are in pixmap mode, nothing gets sent in bitmap mode.
Definition: image.cpp:72
esrv_update_stats
void esrv_update_stats(player *pl)
Sends a statistics update.
Definition: request.cpp:866
ext_info_map_except2
void ext_info_map_except2(int color, const mapstruct *map, const object *op1, const object *op2, int type, int subtype, const char *str1)
Writes to everyone on the map except op1 and op2.
Definition: info.cpp:245
handle_client
bool handle_client(socket_struct *ns, player *pl)
Handle commands from a client.
Definition: loop.cpp:257
SockList_AddShort
void SockList_AddShort(SockList *sl, uint16_t data)
Adds a 16 bit value.
Definition: lowlevel.cpp:116
ext_info_map
void void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the specified map.
Definition: main.cpp:334
SockList_AddChar
void SockList_AddChar(SockList *sl, unsigned char c)
Adds an 8 bit value.
Definition: lowlevel.cpp:106
metaserver2_init
int metaserver2_init(void)
This initializes the metaserver2 logic - it reads the metaserver2 file, storing the values away.
Definition: metaserver.cpp:331
message
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
Definition: survival-guide.txt:34
send_background_music
void send_background_music(player *pl, const char *music)
Sends background music to client.
Definition: sounds.cpp:150
draw_magic_map
void draw_magic_map(object *pl)
Creates and sends magic map to player.
Definition: info.cpp:474
send_tick
void send_tick(player *pl)
Definition: request.cpp:2003
spell
with a maximum of six This is not so if you are wearing plate you receive no benefit Armour is additive with all the supplementry forms of which means that it lasts until the next semi permanent spell effect is cast upon the character spell
Definition: tome-of-magic.txt:44
set_sound_cmd
void set_sound_cmd(char *buf, int len, socket_struct *ns)
ask_smooth_cmd
void ask_smooth_cmd(char *buf, int len, socket_struct *ns)
Tells client the picture it has to use to smooth a picture number given as argument.
Definition: request.cpp:503
account_add_player_cmd
void account_add_player_cmd(char *buf, int len, socket_struct *ns)
Handle accountaddplayer from server (add a character to this account).
Definition: request.cpp:2398
tag_t
uint32_t tag_t
Object tag, unique during the whole game.
Definition: object.h:14
create_player_cmd
void create_player_cmd(char *buf, int len, socket_struct *ns)
We have received a createplayer command.
Definition: request.cpp:2632
new_player_cmd
void new_player_cmd(uint8_t *buf, int len, player *pl)
This handles the commands issued by the player (ie, north, fire, cast, etc.).
Definition: request.cpp:527
account_play_cmd
void account_play_cmd(char *buf, int len, socket_struct *ns)
We have received an accountplay command.
Definition: request.cpp:2527
SockList_Init
void SockList_Init(SockList *sl)
Initializes the SockList instance.
Definition: lowlevel.cpp:55
weight
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your and press< Return > You can also use say if you feel like typing a little extra Other NPCs may not speak to but display intelligence with their movement Some monsters can be and may attack the nearest of your enemies Others can be in that they follow you around and help you in your quest to kill enemies and find treasure SPECIAL ITEMS There are many special items which can be found in of these the most important may be the signs all a player must do is apply the handle In the case of the player must move items over the button to hold it down Some of the larger buttons may need very large items to be moved onto before they can be activated Gates and locked but be for you could fall down into a pit full of ghosts or dragons and not be able to get back out Break away sometimes it may be worth a player s time to test the walls of a map for secret doors Fire such as missile weapons and spells you will notice them going up in smoke ! So be careful not to destroy valuable items Spellbooks sometimes a player can learn the other times they cannot There are many different types of books and scrolls out there Improve item have lower weight
Definition: survival-guide.txt:100
move_cmd
void move_cmd(char *buf, int len, player *pl)
Moves an object (typically, container to inventory).
Definition: request.cpp:708
send_class_info
void send_class_info(socket_struct *ns, char *params)
Send information on the specified class.
Definition: requestinfo.cpp:413
look_at
void look_at(object *op, int dx, int dy)
Prints items on the specified square.
Definition: item.cpp:798
esrv_del_item
void esrv_del_item(player *pl, object *ob)
Tells the client to delete an item.
Definition: main.cpp:381
version_cmd
void version_cmd(char *buf, int len, socket_struct *ns)
Client tells its version.
Definition: request.cpp:651
send_plugin_custom_message
void send_plugin_custom_message(object *pl, char *buf)
GROS: The following one is used to allow a plugin to send a generic cmd to a player.
Definition: request.cpp:1746
SockList_Term
void SockList_Term(SockList *sl)
Frees all resources allocated by a SockList instance.
Definition: lowlevel.cpp:65
metaserver2_exit
void metaserver2_exit()
Stop metaserver updates.
Definition: metaserver.cpp:492
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
set_face_mode_cmd
void set_face_mode_cmd(char *buf, int len, socket_struct *ns)
send_race_list
void send_race_list(socket_struct *ns)
Send the list of player races to the client.
Definition: requestinfo.cpp:326
to
**Media tags please refer to the protocol file in doc Developers protocol Quick for your pleasure an example[/b][i] This is an old full of dirt and partially destroyed[hand] My dear as you two years i had to leave quickly Words have come to me of powerful magic scrolls discovered in an old temple by my uncle I have moved to study them I not forgot your knowledge in ancient languages I need your help for[print][b] Some parts of document are to damaged to be readable[/b][arcane] Arghis[color=Red] k h[color=dark slate blue] ark[color=#004000] fido[/color][hand] please come as fast as possible my friend[print][b] The bottom of letter seems deliberatly shredded What is but not limited to
Definition: media-tags.txt:30
esrv_send_animation
void esrv_send_animation(socket_struct *ns, const Animations *anim)
Need to send an animation sequence to the client.
Definition: request.cpp:1038
free_newsocket
void free_newsocket(socket_struct *ns)
Frees a socket.
Definition: init.cpp:418
ext_info_map_except
void ext_info_map_except(int color, const mapstruct *map, const object *op, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the map except *op.
Definition: info.cpp:219
inscribe_scroll_cmd
void inscribe_scroll_cmd(char *buf, int len, player *pl)
Definition: item.cpp:964
SockList_AddData
void SockList_AddData(SockList *sl, const void *data, size_t len)
Adds a data block.
Definition: lowlevel.cpp:167
esrv_move_object
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
Move an object to a new location.
Definition: item.cpp:899
send_class_list
void send_class_list(socket_struct *ns)
Sends the list of classes to the client.
Definition: requestinfo.cpp:392
toggle_extended_text_cmd
void toggle_extended_text_cmd(char *buf, int len, socket_struct *ns)
metaserver_update
void metaserver_update(void)
Updates our info in the metaserver Note that this is used for both metaserver1 and metaserver2 - for ...
Definition: metaserver.cpp:80
mapstruct
This is a game-map.
Definition: map.h:315
write_cs_stats
void write_cs_stats(void)
Animations
This represents one animation.
Definition: face.h:25
update_players
void update_players(void)
Send updates to players.
Definition: loop.cpp:674
SockList_AddLen8Data
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 8 bit length field.
Definition: lowlevel.cpp:179
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: main.cpp:359
esrv_draw_look
void esrv_draw_look(object *pl)
Send the look window.
Definition: item.cpp:193
reset_stats
void reset_stats(struct CS_Stats *stats)
send_file
void send_file(socket_struct *ns, const char *file)
Sends the desired file to the client.
Definition: requestinfo.cpp:479
examine_cmd
void examine_cmd(char *buf, int len, player *pl)
Client wants to examine some object.
Definition: item.cpp:646
magic_mapping_mark
void magic_mapping_mark(object *pl, char *map_mark, int strength)
Creates magic map for player.
Definition: info.cpp:427
text
**Media tags please refer to the protocol file in doc Developers protocol Quick for your pleasure an example[/b][i] This is an old full of dirt and partially destroyed[hand] My dear as you two years i had to leave quickly Words have come to me of powerful magic scrolls discovered in an old temple by my uncle I have moved to study them I not forgot your knowledge in ancient languages I need your help for[print][b] Some parts of document are to damaged to be readable[/b][arcane] Arghis[color=Red] k h[color=dark slate blue] ark[color=#004000] fido[/color][hand] please come as fast as possible my friend[print][b] The bottom of letter seems deliberatly shredded What is but not limited book signs rules Media tags are made of with inside them the name of tag and optional parameters for the tag Unlike html or there is no notion of opening and closing tag A client not able to understand a tag is supposed to ignore it when server is communicating with and old client that does not understand a a specific extended text
Definition: media-tags.txt:35
SockList_ResetRead
void SockList_ResetRead(SockList *sl)
Resets the length of the stored data for reading.
Definition: lowlevel.cpp:83
send_skill_extra
void send_skill_extra(socket_struct *ns, char *params)
Send extra skill information.
Definition: requestinfo.cpp:102
send_spell_paths
void send_spell_paths(socket_struct *ns)
This sends the spell path to name mapping.
Definition: requestinfo.cpp:132
account_new_cmd
void account_new_cmd(char *buf, int len, socket_struct *ns)
Handles the account creation This function shares a fair amount of the same logic as account_login_cm...
Definition: request.cpp:2284
watchdog
void watchdog(void)
map_newmap_cmd
void map_newmap_cmd(socket_struct *ns)
Sound related function.
Definition: request.cpp:687
stats
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various stats
Definition: stats.txt:2
data
====Textual A command containing textual data has data fields separated by one ASCII space character. word::A sequence of ASCII characters that does not contain the space or nul character. This is to distinguish it from the _string_, which may contain space characters. Not to be confused with a machine word. int::A _word_ containing the textual representation of an integer. Not to be confused with any of the binary integers in the following section. Otherwise known as the "string value of integer data". Must be parsed, e.g. using `atoi()` to get the actual integer value. string::A sequence of ASCII characters. This must only appear at the end of a command, since spaces are used to separate fields of a textual message.=====Binary All multi-byte integers are transmitted in network byte order(MSB first). int8::1-byte(8-bit) integer int16::2-byte(16-bit) integer int32::4-byte(32-bit) integer lstring::A length-prefixed string, which consists of an `int8` followed by that many bytes of the actual string. This is used to transmit a string(that may contain spaces) in the middle of binary data. l2string::Like _lstring_, but is prefixed with an `int16` to support longer strings Implementation Notes ~~~~~~~~~~~~~~~~~~~~ - Typical implementations read two bytes to determine the length of the subsequent read for the actual message, then read and parse the data from each message according to the commands described below. To send a message, the sender builds the message in a buffer, counts the length of the message, sends the length, and finally sends the actual message. TIP:Incorrectly transmitting or receiving the `length` field can lead to apparent "no response" issues as the client or server blocks to read the entire length of the message. - Since the protocol is highly interactive, it may be useful to set `TCP_NODELAY` on both the client and server. - If you are using a language with a buffered output stream, remember to flush the stream after a complete message. - If the connection is lost(which will also happen if the output buffer overflowing), the player is saved and the server cleans up. This does open up some abuses, but there is no perfect solution here. - The server only reads data from the socket if the player has an action. This isn 't really good, since many of the commands below might not be actual commands for the player. The alternative is to look at the data, and if it is a player command and there isn 't time, store it away to be processed later. But this increases complexity, in that the server must start buffering the commands. Fortunately, for now, there are few such client commands. Commands -------- In the documentation below, `S->C` represents a message to the client from the server, and `C->S` represents a message to the server from the client. Commands are documented in a brief format like:C->S:version< csval >[scval[vinfo]] Fields are enclosed like `< this >`. Optional fields are denoted like `[this]`. Spaces that appear in the command are literal, i.e. the<< _version > > command above uses spaces to separate its fields, but the command below does not:C->S:accountlogin< name >< password > As described in<< _messages > >, if a command contains data, then the command is separated from the data by a literal space. Many of the commands below refer to 'object tags'. Whenever the server creates an object, it creates a unique tag for that object(starting at 1 when the server is first run, and ever increasing.) Tags are unique, but are not consistent between runs. Thus, the client can not store tags when it exits and hope to re-use them when it joins the server at a later time - tags are only valid for the current connection. The protocol commands are broken into various sections which based somewhat on what the commands are for(ie, item related commands, map commands, image commands, etc.) In this way, all the commands related to similar functionality is in the same place. Initialization ~~~~~~~~~~~~~~ version ^^^^^^^ C->S:version< csval >[scval[vinfo]] S->C:version< csval >[scval[vinfo]] Used by the client and server to exchange which version of the Crossfire protocol they understand. Neither send this in response to the other - they should both send this shortly after a connection is established. csval::int, version level of C->S communications scval::int, version level of S->C communications vinfo::string, that is purely for informative that general client/server info(ie, javaclient, x11client, winclient, sinix server, etc). It is purely of interest of server admins who can see what type of clients people are using.=====Version ID If a new command is added to the protocol in the C->S direction, then the version number in csval will get increased. Likewise, the same is true for the scval. The version are currently integers, in the form ABCD. A=1, and will likely for quite a while. This will only really change if needed from rollover of B. B represents major protocol changes - if B mismatches, the clients will be totally unusable. Such an example would be change of map or item sending commands(either new commands or new format.) C represents more minor but still significant changes - clients might still work together, but some features that used to work may now fail due to the mismatch. An example may be a change in the meaning of some field in some command - providing the field is the same size, it still should be decoded properly, but the meaning won 't be processed properly. D represents very minor changes or new commands. Things should work no worse if D does not match, however if they do match, some new features might be included. An example of the would be the C->S mark command to mark items. Server not understanding this just means that the server can not process it, and will ignore it.=====Handling As far as the client is concerned, its _scval_ must be at least equal to the server, and its _csval_ should not be newer than the server. The server does not care about the version command it receives right now - all it currently does is log mismatches. In theory, the server should keep track of what the client has, and adjust the commands it sends respectively in the S->C direction. The server is resilant enough that it won 't crash with a version mismatch(however, client may end up sending commands that the server just ignores). It is really up to the client to enforce versioning and quit if the versions don 't match. NOTE:Since all packets have the length as the first 2 bytes, all that either the client or server needs to be able to do is look at the first string and see if it understands it. If not, it knows how many bytes it can skip. As such, exact version matches should not be necessary for proper operation - however, both the client and server needs to be coded to handle such cases.=====History _scval_ and _vinfo_ were added in version 1020. Before then, there was only one version sent in the version command. NOTE:For the most part, this has been obsoleted by the setup command which always return status and whether it understood the command or not. However there are still some cases where using this versioning is useful - an example it the addition of the requestinfo/replyinfo commands - the client wants to wait for acknowledge of all the replyinfo commands it has issued before sending the addme command. However, if the server doesn 't understand these options, the client will never get a response. With the versioning, the client can look at the version and know if it should wait for a response or if the server will never send back. setup ^^^^^ C->S, S->C:setup< option1 >< value1 >< option2 >< value2 > ... Sent by the client to request protocol option changes. This can be at any point during the life of a connection, but usually sent at least once right after the<< _version > > command. The server responds with a message in the same format confirming what configuration options were set. The server only sends a setup command in response to one from the client. The sc_version should be updated in the server if commands have been obsoleted such that old clients may not be able to play. option::word, name of configuration option value::word, value of configuration option. May need further parsing according to the setup options below=====Setup Options There are really 2 set of setup commands here:. Those that control preferences of the client(how big is the map, what faceset to use, etc). . Those that describe capabilities of the client(client supports this protocol command or that) .Setup Options[options="autowidth,header"]|===========================|Command|Description|beat|Ask the server to enable heartbeat support. When heartbeat is enabled, the client must send the server a command every three seconds. If no commands need to be sent, use the `beat` no-op command. Clients that do not contact the server within the interval are assumed to have a temporary connection failure.|bot(0/1 value)|If set to 1, the client will not be considered a player when updating information to the metaserver. This is to avoid having a server with many bots appear more crowded than others.|darkness(0/1 value)|If set to 1(default), the server will send darkness information in the map protocol commands. If 0, the server will not include darkness, thus saving a minor amount of bandwidth. Since the client is free to ignore the darkness information, this does not allow the client to cheat. In the case of the old 'map' protocol command, turning darkness off will result in the masking faces not getting sent to the client.|extended_stats(0/1 value)|If set to 1, the server will send the CS_STAT_RACE_xxx and CS_STAT_BASE_xxx values too, so the client can display various status related to statistics. Default is 0.|facecache(0/1)|Determines if the client is caching images(1) or wants the images sent to it without caching them(0). Default is 0. This replaces the setfacemode command.|faceset(8 bit)|Faceset the client wishes to use. If the faceset is not valid, the server returns the faceset the client will be using(default 0).|loginmethod(8 bit)|Client sends this to server to note login support. This is basically used as a subset of the csversion/scversion to find out what level of login support the server and client support. Current defined values:0:no advanced support - only legacy login method 1:account based login(described more below) 2:new character creation support This list may grow - for example, advanced character creation could become a feature.|map2cmd:(1)|This indicates client support for the map2 protocol command. See the map2 protocol details above for the main differences. Obsolete:This is the only supported mode now, but many clients use it as a sanity check for protocol versions, so the server still replies. It doesn 't do anything with the data|mapsize(int x) X(int y)|Sets the map size to x X y. Note the spaces here are only for clarity - there should be no spaces when actually sent(it should be 11x11 or 25x25). The default map size unless changed is 11x11. The minimum map size the server will allow is 9x9(no technical reason this could be smaller, but I don 't think the game would be smaller). The maximum map size supported in the current protocol is 63x63. However, each server can have its maximum map size sent to most any value. If the client sends an invalid mapsize command or a mapsize of 0x0, the server will respond with a mapsize that is the maximum size the server supports. Thus, if the client wants to know the maximum map size, it can just do a 'mapsize 0x0' or 'mapsize' and it will get the maximum size back. The server will constrain the provided mapsize x &y to the configured minumum and maximums. For example, if the maximum map size is 25x25, the minimum map size is 9x9, and the client sends a 31x7 mapsize request, the mapsize will be set to 25x9 and the server will send back a mapsize 25x9 setup command. When the values are valid, the server will send back a mapsize XxY setup command. Note that this is from its parsed values, so it may not match stringwise with what the client sent, but will match 0 wise. For example, the client may send a 'mapsize 025X025' command, in which case the server will respond with a 'mapsize 25x25' command - the data is functionally the same. The server will send an updated map view when this command is sent.|notifications(int value)|Value indicating what notifications the client accepts. It is incremental, a value means "all notifications till this level". The following levels are supported:1:quest-related notifications("addquest" and "updquest") 2:knowledge-related notifications("addknowledge") 3:character status flags(overloaded, blind,...)|num_look_objects(int value)|The maximum number of objects shown in the ground view. If more objects are present, fake objects are created for selecting the previous/next group of items. Defaults to 50 if not set. The server may adjust the given value to a suitable one data
Definition: protocol.txt:379
GetInt_String
int GetInt_String(const unsigned char *data)
Basically does the reverse of SockList_AddInt, but on strings instead.
Definition: lowlevel.cpp:254
lock_item_cmd
void lock_item_cmd(uint8_t *data, int len, player *pl)
Client wants to apply some object.
Definition: item.cpp:708
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.cpp:308
SockList_AddStringBuffer
void SockList_AddStringBuffer(SockList *sl, StringBuffer *sb)
Deallocates string buffer instance and appends its contents.
Definition: lowlevel.cpp:225
count_players
int count_players(void)
Definition: metaserver.cpp:48
is_valid_faceset
int is_valid_faceset(int fsn)
Checks specified faceset is valid.
Definition: image.cpp:117
SockList_ReadPacket
int SockList_ReadPacket(int fd, SockList *sl, int len)
This reads from fd and puts the data in sl.
Definition: lowlevel.cpp:275
set_up_cmd
void set_up_cmd(char *buf, int len, socket_struct *ns)
This is the Setup cmd - easy first implementation.
Definition: request.cpp:143
send_race_info
void send_race_info(socket_struct *ns, char *params)
Sends information on specified race to the client.
Definition: requestinfo.cpp:347
CS_Stats
Statistics for the last CS_LOGTIME seconds on the server.
Definition: newclient.h:697
add_me_cmd
void add_me_cmd(char *buf, int len, socket_struct *ns)
The client has requested to be added to the game.
Definition: request.cpp:415
draw_client_map
void draw_client_map(object *pl)
Draws client map.
Definition: request.cpp:1647
send_query
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Asks the client to query the user.
Definition: request.cpp:745
Send_With_Handling
void Send_With_Handling(socket_struct *ns, SockList *sl)
Calls Write_To_Socket to send data to the client.
Definition: lowlevel.cpp:447
SockList
Contains the base information we use to make up a packet we want to send.
Definition: newclient.h:684
apply_cmd
void apply_cmd(char *buf, int len, player *pl)
Client wants to apply some object.
Definition: item.cpp:668
SockList_NullTerminate
void SockList_NullTerminate(SockList *sl)
Adds a NUL byte without changing the length.
Definition: lowlevel.cpp:237
send_face_cmd
void send_face_cmd(char *buff, int len, socket_struct *ns)
Client has requested pixmap that it somehow missed getting.
Definition: image.cpp:45
rangetostring
void rangetostring(const object *pl, char *obuf, size_t len)
Get player's current range attack in obuf.
Definition: info.cpp:264
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
SockList_AddPrintf
void SockList_AddPrintf(SockList *sl, const char *format,...)
Adds a printf like formatted string.
Definition: lowlevel.cpp:202
face
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single or trs file and the graphics into a face(metadata) and .tar(bitmaps) file
player_update_bg_music
void player_update_bg_music(object *player)
Definition: sounds.cpp:170
init_listening_socket
void init_listening_socket(socket_struct *ns)
This opens *ns for listening to connections.
Definition: init.cpp:192