|
Crossfire Client, Trunk
R18666
|
#include <client.h>#include <external.h>#include <assert.h>#include <ctype.h>#include "mapdata.h"
Go to the source code of this file.
Defines | |
| #define | ASSERT_LEN(function, curpos, buflen) |
| #define | NUM_STATS 7 |
| #define | NUM_LAYERS (MAP1_LAYERS-1) |
Functions | |
| void | free_all_starting_map_info () |
| void | free_all_race_class_info (Race_Class_Info *data, int num_entries) |
| void | ReplyInfoCmd (uint8 *buf, int len) |
| void | SetupCmd (char *buf, int len) |
| void | AddMeFail (char *data, int len) |
| void | AddMeSuccess (char *data, int len) |
| void | GoodbyeCmd (char *data, int len) |
| void | AnimCmd (unsigned char *data, int len) |
| void | SmoothCmd (unsigned char *data, int len) |
| void | DrawInfoCmd (char *data, int len) |
| void | setTextManager (int type, ExtTextManager callback) |
| void | DrawExtInfoCmd (char *data, int len) |
| void | use_skill (int skill_id) |
| void | StatsCmd (unsigned char *data, int len) |
| void | handle_query (char *data, int len) |
| void | send_reply (const char *text) |
| void | PlayerCmd (unsigned char *data, int len) |
| void | item_actions (item *op) |
| void | Item2Cmd (unsigned char *data, int len) |
| void | UpdateItemCmd (unsigned char *data, int len) |
| void | DeleteItem (unsigned char *data, int len) |
| void | DeleteInventory (unsigned char *data, int len) |
| void | AddspellCmd (unsigned char *data, int len) |
| void | UpdspellCmd (unsigned char *data, int len) |
| void | DeleteSpell (unsigned char *data, int len) |
| void | NewmapCmd (unsigned char *data, int len) |
| void | Map2Cmd (unsigned char *data, int len) |
| void | map_scrollCmd (char *data, int len) |
| int | ExtSmooth (unsigned char *data, int len, int x, int y, int layer) |
| void | MapExtendedCmd (unsigned char *data, int len) |
| void | MagicMapCmd (unsigned char *data, int len) |
| void | SinkCmd (unsigned char *data, int len) |
| void | TickCmd (uint8 *data, int len) |
| void | PickupCmd (uint8 *data, int len) |
| void | FailureCmd (char *buf, int len) |
| void | AccountPlayersCmd (char *buf, int len) |
Variables | |
| const char *const | rcsid_common_commands_c = "$Id: commands.c 18221 2012-06-15 17:13:53Z ryo_saeba $" |
| int | mapupdatesent = 0 |
| char * | news = NULL |
| char * | motd = NULL |
| char * | rules = NULL |
| int | spellmon_level = 0 |
| int | num_races = 0 |
| int | used_races = 0 |
| int | num_classes = 0 |
| int | used_classes = 0 |
| int | stat_points = 0 |
| int | stat_min = 0 |
| int | stat_maximum = 0 |
| int | starting_map_number = 0 |
| Race_Class_Info * | races = NULL |
| Race_Class_Info * | classes = NULL |
| Starting_Map_Info * | starting_map_info = NULL |
| const char *const | short_stat_name [NUM_STATS] |
| struct Stat_Mapping | stat_mapping [NUM_NEW_CHAR_STATS] |
| Animations | animations [MAXANIM] |
| TextManager * | firstTextManager = NULL |
Handles server->client commands; See player.c for client->server commands.
Not necessarily all commands are handled - some might be in other files (like init.c)
This file contains most of the commands for the dispatch loop. Most of the functions are self-explanatory.
pixmap/bitmap : receive the picture, and display it. drawinfo : draws a string in the info window. stats : updates the local copy of the stats and displays it. handle_query : prompts the user for input. send_reply : sends off the reply for the input. player : gets the player information. MapScroll : scrolls the map on the client by some amount. MapCmd : displays the map with layer packing or stack packing. packing/unpacking is best understood by looking at the server code (server/ericserver.c) stack packing: for every map entry that changed, we pack 1 byte for the x/y location, 1 byte for the count, and 2 bytes per face in the stack. layer packing is harder, but I seem to remember more efficient: first we pack in a list of all map cells that changed and are now empty. The end of this list is a 255, which is bigger that 121, the maximum packed map location. For each changed location we also pack in a list of all the faces and X/Y coordinates by layer, where the layer is the depth in the map. This essentially takes slices through the map rather than stacks. Then for each layer, (max is MAXMAPCELLFACES, a bad name) we start packing the layer into the message. First we pack in a face, then for each place on the layer with the same face, we pack in the x/y location. We mark the last x/y location with the high bit on (11*11 = 121 < 128). We then continue on with the next face, which is why the code marks the faces as -1 if they are finished. Finally we mark the last face in the layer again with the high bit, clearly limiting the total number of faces to 32767, the code comments it's 16384, I'm not clear why, but the second bit may be used somewhere else as well. The unpacking routines basically perform the opposite operations.
Definition in file commands.c.
| #define ASSERT_LEN | ( | function, | |
| curpos, | |||
| buflen | |||
| ) |
if (curpos > buflen) { \ LOG(LOG_WARNING, function, "Data goes beyond length of buffer (%d>%d)", curpos, buflen); \ break; \ }
Definition at line 85 of file commands.c.
| #define NUM_STATS 7 |
Definition at line 114 of file commands.c.
| void AccountPlayersCmd | ( | char * | buf, |
| int | len | ||
| ) |
This handles the accountplayers command
Definition at line 2256 of file commands.c.

| void AddMeFail | ( | char * | data, |
| int | len | ||
| ) |
Handles when the server says we can't be added. In reality, we need to close the connection and quit out, because the client is going to close us down anyways.
| data | |
| len |
Definition at line 1044 of file commands.c.

| void AddMeSuccess | ( | char * | data, |
| int | len | ||
| ) |
This is really a throwaway command - there really isn't any reason to send addme_success commands.
| data | |
| len |
Definition at line 1059 of file commands.c.

| void AnimCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 1092 of file commands.c.

| void DeleteInventory | ( | unsigned char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 1665 of file commands.c.

| void DeleteItem | ( | unsigned char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 1641 of file commands.c.

| void DrawExtInfoCmd | ( | char * | data, |
| int | len | ||
| ) |
We must extract color, type, subtype and dispatch to callback
| data | |
| len |
Definition at line 1216 of file commands.c.

| void DrawInfoCmd | ( | char * | data, |
| int | len | ||
| ) |
Draws a string in the info window.
| data | |
| len |
Definition at line 1155 of file commands.c.

| void FailureCmd | ( | char * | buf, |
| int | len | ||
| ) |
Handles a failure return from the server.
| buf | buffer sent by server. |
| len | length of data. |
Definition at line 2212 of file commands.c.

| void free_all_race_class_info | ( | Race_Class_Info * | data, |
| int | num_entries | ||
| ) |
This function clears the data from the Race_Class_Info array. Because the structure itself contains data that is allocated, some work needs to be done to clear that data.
| data | array to clear |
| num_entries | size of the array. |
Definition at line 410 of file commands.c.

| void free_all_starting_map_info | ( | ) |
This function clears the data from the Race_Class_Info array. Because the structure itself contains data that is allocated, some work needs to be done to clear that data.
Definition at line 143 of file commands.c.
| void GoodbyeCmd | ( | char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 1073 of file commands.c.

| void handle_query | ( | char * | data, |
| int | len | ||
| ) |
Prompts the user for input.
| data | |
| len |
Definition at line 1389 of file commands.c.

| void Item2Cmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 1547 of file commands.c.
| void item_actions | ( | item * | op | ) |
| op |
Definition at line 1483 of file commands.c.


Server gives us current player's pickup.
| data | buffer sent by server. |
| len | length of data. |
Definition at line 2199 of file commands.c.

| void PlayerCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
Gets the player information. This function copies relevant data from the archetype to the object. Only copies data that was not set in the object structure.
| data | |
| len |
Definition at line 1460 of file commands.c.

| void ReplyInfoCmd | ( | uint8 * | buf, |
| int | len | ||
| ) |
Handles the response from a 'requestinfo' command. This function doesn't do much itself other than dispatch to other functions.
| buf | |
| len |
Definition at line 747 of file commands.c.

| void send_reply | ( | const char * | text | ) |
Sends a reply to the server. This function basically just packs the stuff up.
| text | contains the null terminated string of text to send. |
Definition at line 1444 of file commands.c.


| void setTextManager | ( | int | type, |
| ExtTextManager | callback | ||
| ) |
| type | |
| callback |
Definition at line 1178 of file commands.c.

| void SetupCmd | ( | char * | buf, |
| int | len | ||
| ) |
Received a response to a setup from the server. This function is basically the same as the server side function - we just do some different processing on the data.
| buf | |
| len |
Definition at line 868 of file commands.c.

| void SinkCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
| data | |
| len |
Definition at line 2173 of file commands.c.
| void SmoothCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
Receives the smooth mapping from the server. Because this information is reference a lot, the smoothing face is stored in the pixmap data - this makes access much faster than searching an array of data for the face to use.
| data | |
| len |
Definition at line 1136 of file commands.c.

| void StatsCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
Updates the local copy of the stats and displays it.
| data | |
| len |
Definition at line 1291 of file commands.c.

Got a tick from the server. We currently don't care what tick number it is, but just have the code in case at some time we do.
| data | |
| len |
Definition at line 2183 of file commands.c.

| void UpdateItemCmd | ( | unsigned char * | data, |
| int | len | ||
| ) |
Updates some attributes of an item
| data | |
| len |
Definition at line 1557 of file commands.c.

| void use_skill | ( | int | skill_id | ) |
Maintain the last_used_skills LRU list for displaying the recently used skills first.
| skill_id |
Definition at line 1267 of file commands.c.

Definition at line 1085 of file commands.c.
| Race_Class_Info * classes = NULL |
Definition at line 107 of file commands.c.
| TextManager* firstTextManager = NULL |
Definition at line 1171 of file commands.c.
| int mapupdatesent = 0 |
Definition at line 66 of file commands.c.
| char * motd = NULL |
Definition at line 91 of file commands.c.
| char* news = NULL |
Definition at line 91 of file commands.c.
| int num_classes = 0 |
Definition at line 99 of file commands.c.
| int num_races = 0 |
Definition at line 96 of file commands.c.
| Race_Class_Info* races = NULL |
Definition at line 107 of file commands.c.
| const char* const rcsid_common_commands_c = "$Id: commands.c 18221 2012-06-15 17:13:53Z ryo_saeba $" |
Definition at line 1 of file commands.c.
| char * rules = NULL |
Definition at line 91 of file commands.c.
| const char* const short_stat_name[NUM_STATS] |
{
"Str", "Dex", "Con",
"Wis", "Cha", "Int",
"Pow"
}
Short name of stats.
Definition at line 116 of file commands.c.
| int spellmon_level = 0 |
Keeps track of what spellmon command is supported by the server.
Definition at line 93 of file commands.c.
| Starting_Map_Info* starting_map_info = NULL |
Definition at line 108 of file commands.c.
| int starting_map_number = 0 |
Definition at line 105 of file commands.c.
{
{"str", CS_STAT_STR, 0},
{"con", CS_STAT_CON, 1},
{"dex", CS_STAT_DEX, 2},
{"int", CS_STAT_INT, 3},
{"wis", CS_STAT_WIS, 4},
{"pow", CS_STAT_POW, 5},
{"cha", CS_STAT_CHA, 6}
}
Definition at line 127 of file commands.c.
| int stat_maximum = 0 |
Definition at line 104 of file commands.c.
| int stat_min = 0 |
Definition at line 103 of file commands.c.
| int stat_points = 0 |
Definition at line 102 of file commands.c.
| int used_classes = 0 |
Definition at line 100 of file commands.c.
| int used_races = 0 |
Definition at line 97 of file commands.c.
1.7.6.1