Crossfire Client, Trunk  R18666
Defines | Functions | Variables
/home/leaf/crossfire/client/trunk/common/commands.c File Reference
#include <client.h>
#include <external.h>
#include <assert.h>
#include <ctype.h>
#include "mapdata.h"
Include dependency graph for commands.c:

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_Inforaces = NULL
Race_Class_Infoclasses = NULL
Starting_Map_Infostarting_map_info = NULL
const char *const short_stat_name [NUM_STATS]
struct Stat_Mapping stat_mapping [NUM_NEW_CHAR_STATS]
Animations animations [MAXANIM]
TextManagerfirstTextManager = NULL

Detailed Description

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 Documentation

#define ASSERT_LEN (   function,
  curpos,
  buflen 
)
Value:
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.


Function Documentation

void AccountPlayersCmd ( char *  buf,
int  len 
)

This handles the accountplayers command

Definition at line 2256 of file commands.c.

Here is the call graph for this function:

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.

Parameters:
data
len

Definition at line 1044 of file commands.c.

Here is the call graph for this function:

void AddMeSuccess ( char *  data,
int  len 
)

This is really a throwaway command - there really isn't any reason to send addme_success commands.

Parameters:
data
len

Definition at line 1059 of file commands.c.

Here is the call graph for this function:

void AnimCmd ( unsigned char *  data,
int  len 
)
Parameters:
data
len

Definition at line 1092 of file commands.c.

Here is the call graph for this function:

void DeleteInventory ( unsigned char *  data,
int  len 
)
Parameters:
data
len

Definition at line 1665 of file commands.c.

Here is the call graph for this function:

void DeleteItem ( unsigned char *  data,
int  len 
)
Parameters:
data
len

Definition at line 1641 of file commands.c.

Here is the call graph for this function:

void DrawExtInfoCmd ( char *  data,
int  len 
)

We must extract color, type, subtype and dispatch to callback

Parameters:
data
len

Definition at line 1216 of file commands.c.

Here is the call graph for this function:

void DrawInfoCmd ( char *  data,
int  len 
)

Draws a string in the info window.

Parameters:
data
len

Definition at line 1155 of file commands.c.

Here is the call graph for this function:

void FailureCmd ( char *  buf,
int  len 
)

Handles a failure return from the server.

Parameters:
bufbuffer sent by server.
lenlength of data.

Definition at line 2212 of file commands.c.

Here is the call graph for this function:

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.

Parameters:
dataarray to clear
num_entriessize of the array.

Definition at line 410 of file commands.c.

Here is the caller graph for this function:

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 
)
Parameters:
data
len

Definition at line 1073 of file commands.c.

Here is the call graph for this function:

void handle_query ( char *  data,
int  len 
)

Prompts the user for input.

Parameters:
data
len

Definition at line 1389 of file commands.c.

Here is the call graph for this function:

void Item2Cmd ( unsigned char *  data,
int  len 
)
Parameters:
data
len

Definition at line 1547 of file commands.c.

void item_actions ( item op)
Parameters:
op

Definition at line 1483 of file commands.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void PickupCmd ( uint8 data,
int  len 
)

Server gives us current player's pickup.

Parameters:
databuffer sent by server.
lenlength of data.

Definition at line 2199 of file commands.c.

Here is the call graph for this function:

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.

Parameters:
data
len

Definition at line 1460 of file commands.c.

Here is the call graph for this function:

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.

Parameters:
buf
len

Definition at line 747 of file commands.c.

Here is the call graph for this function:

void send_reply ( const char *  text)

Sends a reply to the server. This function basically just packs the stuff up.

Parameters:
textcontains the null terminated string of text to send.

Definition at line 1444 of file commands.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void setTextManager ( int  type,
ExtTextManager  callback 
)
Parameters:
type
callback

Definition at line 1178 of file commands.c.

Here is the caller graph for this function:

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.

Parameters:
buf
len

Definition at line 868 of file commands.c.

Here is the call graph for this function:

void SinkCmd ( unsigned char *  data,
int  len 
)
Parameters:
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.

Parameters:
data
len

Definition at line 1136 of file commands.c.

Here is the call graph for this function:

void StatsCmd ( unsigned char *  data,
int  len 
)

Updates the local copy of the stats and displays it.

Parameters:
data
len

Definition at line 1291 of file commands.c.

Here is the call graph for this function:

void TickCmd ( uint8 data,
int  len 
)

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.

Parameters:
data
len

Definition at line 2183 of file commands.c.

Here is the call graph for this function:

void UpdateItemCmd ( unsigned char *  data,
int  len 
)

Updates some attributes of an item

Parameters:
data
len

Definition at line 1557 of file commands.c.

Here is the call graph for this function:

void use_skill ( int  skill_id)

Maintain the last_used_skills LRU list for displaying the recently used skills first.

Parameters:
skill_id

Definition at line 1267 of file commands.c.

Here is the caller graph for this function:


Variable Documentation

Definition at line 1085 of file commands.c.

Definition at line 107 of file commands.c.

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.

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]
Initial value:
 {
    "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.

Definition at line 108 of file commands.c.

Definition at line 105 of file commands.c.

Initial value:
 {
    {"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.