Crossfire Server, Trunk  R20513
Macros | Functions
item.c File Reference

Client/server logic. More...

#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "newserver.h"
#include "object.h"
#include "shared/newclient.h"
#include "sproto.h"
Include dependency graph for item.c:

Go to the source code of this file.

Macros

#define MAXITEMLEN   300
 This is the maximum number of bytes we expect any one item to take up. More...
 

Functions

static void add_object_to_socklist (socket_struct *ns, SockList *sl, object *head)
 Used in the send_look to put object head into SockList sl for socket ns. More...
 
void apply_cmd (char *buf, int len, player *pl)
 Client wants to apply some object. More...
 
void esrv_del_item (player *pl, object *ob)
 Tells the client to delete an item. More...
 
void esrv_draw_look (object *pl)
 Send the look window. More...
 
static objectesrv_get_ob_from_count (object *pl, tag_t count)
 Takes a player and object count (tag) and returns the actual object pointer, or null if it can't be found. More...
 
void esrv_move_object (object *pl, tag_t to, tag_t tag, long nrof)
 Move an object to a new location. More...
 
void esrv_send_inventory (object *pl, object *op)
 Sends inventory of a container. More...
 
void esrv_send_item (object *pl, object *op)
 Sends item's info to player. More...
 
void esrv_update_item (int flags, object *pl, object *op)
 Updates object *op for player *pl. More...
 
void examine_cmd (char *buf, int len, player *pl)
 Client wants to examine some object. More...
 
void inscribe_scroll_cmd (char *buf, int len, player *pl)
 
void lock_item_cmd (uint8_t *data, int len, player *pl)
 Client wants to apply some object. More...
 
void look_at (object *op, int dx, int dy)
 Prints items on the specified square. More...
 
void look_at_cmd (char *buf, int len, player *pl)
 Client wants to look at some object. More...
 
void mark_item_cmd (uint8_t *data, int len, player *pl)
 Client wants to mark some object. More...
 
static unsigned int query_flags (const object *op)
 This is a similar to query_name, but returns flags to be sended to client. More...
 

Detailed Description

Client/server logic.

Date
2003-12-02

This containes item logic for client/server. It doesn't contain the actual commands that send the data, but does contain the logic for what items should be sent.

Definition in file item.c.

Macro Definition Documentation

#define MAXITEMLEN   300

This is the maximum number of bytes we expect any one item to take up.

Definition at line 36 of file item.c.

Referenced by esrv_draw_look(), and esrv_send_inventory().

Function Documentation

static void add_object_to_socklist ( socket_struct ns,
SockList sl,
object head 
)
static
void apply_cmd ( char *  buf,
int  len,
player pl 
)
void esrv_del_item ( player pl,
object ob 
)

Tells the client to delete an item.

Uses the item command with a -1 location.

Definition at line 550 of file item.c.

References obj::container, obj::count, obj::env, pl::ob, Send_With_Handling(), pl::socket, SockList_AddInt(), SockList_AddString(), SockList_Init(), SockList_Term(), and socket_struct::update_inventory.

Here is the call graph for this function:

void esrv_draw_look ( object pl)
static object* esrv_get_ob_from_count ( object pl,
tag_t  count 
)
static

Takes a player and object count (tag) and returns the actual object pointer, or null if it can't be found.

Definition at line 576 of file item.c.

References CONTAINER, obj::container, obj::contr, obj::count, FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, HEAD, obj::map, pl::transport, obj::x, and obj::y.

Referenced by apply_cmd(), esrv_move_object(), examine_cmd(), inscribe_scroll_cmd(), lock_item_cmd(), and mark_item_cmd().

Here is the caller graph for this function:

void esrv_move_object ( object pl,
tag_t  to,
tag_t  tag,
long  nrof 
)

Move an object to a new location.

Definition at line 843 of file item.c.

References CONTAINER, obj::contr, pl::count, obj::count, drop_object(), obj::env, esrv_get_ob_from_count(), esrv_update_item(), FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, obj::inv, llevDebug, LOG(), obj::map, obj::name, object_can_pick(), pick_up(), put_object_in_sack(), QUERY_FLAG, sack_can_hold(), pl::transport, transport_can_hold(), obj::type, and UPD_WEIGHT.

Referenced by move_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void esrv_send_inventory ( object pl,
object op 
)

Sends inventory of a container.

If pl == op, then the whole contents are sent, else the contents is sent with "next group" and "prev group" arrows if required.

Parameters
plwho to send to.
opwhat item's contents to send.

Definition at line 307 of file item.c.

References add_object_to_socklist(), socket_struct::container_position, obj::contr, obj::count, empty_face, FOR_INV_FINISH, FOR_INV_PREPARE, HEAD, LOOK_OBJ, MAX, MAX_BUF, MAXITEMLEN, MIN, socket_struct::num_look_objects, new_face_struct::number, Send_With_Handling(), snprintf, pl::socket, SockList_AddChar(), SockList_AddInt(), SockList_AddLen8Data(), SockList_AddPrintf(), SockList_AddShort(), SockList_AddString(), SockList_Avail(), SockList_Init(), SockList_Reset(), and SockList_Term().

Referenced by apply_cmd(), apply_container(), apply_race_and_class(), check_login(), command_possess(), do_server(), key_change_class(), player_changer_type_process(), save_player(), and use_alchemy().

Here is the call graph for this function:

Here is the caller graph for this function:

void esrv_send_item ( object pl,
object op 
)
void esrv_update_item ( int  flags,
object pl,
object op 
)
void examine_cmd ( char *  buf,
int  len,
player pl 
)

Client wants to examine some object.

So lets do so.

Definition at line 612 of file item.c.

References esrv_get_ob_from_count(), examine(), llevDebug, LOG(), obj::name, and pl::ob.

Here is the call graph for this function:

void inscribe_scroll_cmd ( char *  buf,
int  len,
player pl 
)
void lock_item_cmd ( uint8_t data,
int  len,
player pl 
)

Client wants to apply some object.

Lets do so.

Definition at line 671 of file item.c.

References CLEAR_FLAG, draw_ext_info(), obj::env, esrv_get_ob_from_count(), esrv_update_item(), FLAG_INV_LOCKED, GetInt_String(), llevDebug, LOG(), obj::map, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, obj::name, NDI_UNIQUE, pl::ob, object_merge(), SET_FLAG, and UPD_FLAGS.

Here is the call graph for this function:

void look_at ( object op,
int  dx,
int  dy 
)

Prints items on the specified square.

[ removed EARTHWALL check and added check for containers inventory. Tero..nosp@m.Haat.nosp@m.anen@.nosp@m.lut..nosp@m.fi ]

Definition at line 754 of file item.c.

References obj::above, CONTAINER, obj::count, draw_ext_info(), draw_ext_info_format(), FLAG_IS_FLOOR, FLAG_WIZ, FLESH, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, get_map_from_coord(), GET_MAP_OB, HEAD, inventory(), obj::invisible, obj::map, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, out_of_map(), QUERY_FLAG, query_name(), obj::type, obj::x, and obj::y.

Referenced by look_at_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void look_at_cmd ( char *  buf,
int  len,
player pl 
)

Client wants to look at some object.

Lets do so.

Definition at line 819 of file item.c.

References pl::blocked_los, FABS, llevDebug, LOG(), look_at(), MAP_CLIENT_X, MAP_CLIENT_Y, socket_struct::mapx, socket_struct::mapy, obj::name, pl::ob, and pl::socket.

Here is the call graph for this function:

void mark_item_cmd ( uint8_t data,
int  len,
player pl 
)

Client wants to mark some object.

Lets do so.

Parameters
dataobject tag (4 chars).
lendata size.
plplayer.

Definition at line 723 of file item.c.

References obj::count, draw_ext_info(), draw_ext_info_format(), esrv_get_ob_from_count(), GetInt_String(), llevDebug, LOG(), pl::mark, pl::mark_count, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, obj::name, NDI_UNIQUE, pl::ob, and query_name().

Here is the call graph for this function:

static unsigned int query_flags ( const object op)
static

This is a similar to query_name, but returns flags to be sended to client.

Definition at line 49 of file item.c.

References a_active, a_applied, a_readied, a_wielded, a_worn, AMULET, ARMOUR, BOOTS, BOW, BRACERS, CLOAK, CONTAINER, obj::container, obj::env, F_BLESSED, F_CURSED, F_DAMNED, F_LOCKED, F_MAGIC, F_OPEN, F_UNIDENTIFIED, F_UNPAID, FLAG_APPLIED, FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_INV_LOCKED, FLAG_KNOWN_BLESSED, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLAG_UNPAID, flags, GIRDLE, GLOVES, HELMET, need_identify(), QUERY_FLAG, RING, ROD, SHIELD, SKILL, obj::type, WAND, and WEAPON.

Referenced by add_object_to_socklist(), and esrv_update_item().

Here is the call graph for this function:

Here is the caller graph for this function: