Crossfire Server  1.75.0
item.cpp 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"

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 objectob_if_can_find (object *op, object *ob)
 Return object 'ob' if player 'op' can find it, otherwise return NULL. More...
 
bool player_can_find (object *op, object *ob)
 Return true if player 'op' can see object 'op' for purpose of locating items for partial item matching or searching by tag. More...
 
static bool player_can_see (player *pl, int dx, int dy)
 
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.cpp.

Macro Definition Documentation

◆ MAXITEMLEN

#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.cpp.

Referenced by esrv_draw_look(), and esrv_send_inventory().

Function Documentation

◆ add_object_to_socklist()

◆ apply_cmd()

◆ esrv_del_item()

void esrv_del_item ( player pl,
object ob 
)

◆ esrv_draw_look()

◆ esrv_get_ob_from_count()

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 610 of file item.cpp.

References CONTAINER, object::container, object::contr, object::count, FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, HEAD, object::map, ob_if_can_find(), player::transport, object::x, and object::y.

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

◆ esrv_move_object()

◆ esrv_send_inventory()

void esrv_send_inventory ( object pl,
object op 
)

◆ esrv_send_item()

◆ esrv_update_item()

void esrv_update_item ( int  flags,
object pl,
object op 
)

Updates object *op for player *pl.

flags is a list of values to update to the client (as defined in newclient.h - might as well use the same value both places.

Definition at line 414 of file item.cpp.

References object::anim_speed, object::animation, object::contr, object::count, CUSTOM_NAME_FIELD, object::env, esrv_send_face(), FABS, object::face, socket_struct::faces_sent, FLAG_ANIMATE, FLAG_CLIENT_SENT, FLAG_NO_PICK, HEAD, player::last_weight, LOOK_OBJ, MAX_BUF, object::nrof, NS_FACESENT_FACE, Animations::num, Face::number, object_get_value(), query_base_name(), QUERY_FLAG, query_flags(), Send_With_Handling(), player::socket, SockList_AddChar(), SockList_AddInt(), SockList_AddLen8Data(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Term(), object::speed, strlcpy(), UPD_ANIM, UPD_ANIMSPEED, UPD_FACE, UPD_FLAGS, UPD_LOCATION, UPD_NAME, UPD_NROF, UPD_WEIGHT, and WEIGHT.

Referenced by animate_weapon(), apply_container(), apply_race_and_class(), apply_special(), book_type_apply(), cancellation(), cast_identify(), cast_item_curse_or_bless(), cfapi_object_set_property(), command_drop(), command_dropall(), command_insert_into(), command_lock_item(), command_rename_item(), command_take(), detect_curse_on_item(), detect_magic_on_item(), do_auto_apply(), drain_wand_charge(), drop_object(), empty_container(), esrv_move_object(), god_enchants_weapon(), god_removes_curse(), hit_with_one_attacktype(), identify(), improve_armour(), improve_weapon(), improve_weapon_magic(), insert_objects(), key_change_class(), lock_item_cmd(), object_decrease_nrof(), object_increase_nrof(), object_remove(), object_update(), pick_up_object(), player_changer_type_process(), power_crystal_type_apply(), prepare_weapon(), put_object_in_sack(), remove_curse(), sell_item(), send_changed_object(), send_updates(), shop_pay_unpaid_callback(), spellbook_type_apply(), unapply_special(), and weapon_improver_type_apply().

◆ examine_cmd()

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

Client wants to examine some object.

So lets do so.

Definition at line 646 of file item.cpp.

References do_dump(), esrv_get_ob_from_count(), examine(), FLAG_WIZ, llevDebug, LOG(), object::name, player::ob, and QUERY_FLAG.

◆ inscribe_scroll_cmd()

◆ lock_item_cmd()

◆ look_at()

◆ look_at_cmd()

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

Client wants to look at some object.

Lets do so.

Definition at line 869 of file item.cpp.

References draw_ext_info(), FABS, llevDebug, LOG(), look_at(), MAP_CLIENT_X, MAP_CLIENT_Y, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, object::name, NDI_UNIQUE, player::ob, and player_can_see().

◆ mark_item_cmd()

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 767 of file item.cpp.

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

◆ ob_if_can_find()

static object* ob_if_can_find ( object op,
object ob 
)
static

Return object 'ob' if player 'op' can find it, otherwise return NULL.

Definition at line 597 of file item.cpp.

References player_can_find().

Referenced by esrv_get_ob_from_count().

◆ player_can_find()

bool player_can_find ( object op,
object ob 
)

Return true if player 'op' can see object 'op' for purpose of locating items for partial item matching or searching by tag.

Definition at line 590 of file item.cpp.

References FLAG_WIZ, object::invisible, and QUERY_FLAG.

Referenced by find_best_apply_object_match(), and ob_if_can_find().

◆ player_can_see()

static bool player_can_see ( player pl,
int  dx,
int  dy 
)
static

◆ query_flags()