Functions

server/player_shop.c File Reference

#include <global.h>

Go to the source code of this file.

Functions

static void player_shop_send_items (player *pl, player *seller)
static void player_shop_close_interface (player *pl)
static void player_shop_free_structure (player *pl, int send_close)
static int shop_player_in_range (object *op, object *seller)
void player_shop_open (char *data, player *pl)
void player_shop_close (player *pl)
void player_shop_load (char *data, player *pl)
void player_shop_examine (char *data, player *pl)
void player_shop_buy (char *data, player *pl)

Detailed Description

Controls player shop related functions.

Definition in file player_shop.c.


Function Documentation

void player_shop_buy ( char *  data,
player pl 
)

Buy a player shop item.

Parameters:
data The data buffer. Includes seller's name, the object's tag ID we're buying, and the nrof of objects to buy.
pl The player buying the item

Definition at line 485 of file player_shop.c.

void player_shop_close ( player pl  ) 

Close a player shop. If the player has shop items (is selling), free them, but do not send close command to the client, as the client should take care of that.

Parameters:
pl The player to close the shop for

Definition at line 366 of file player_shop.c.

static void player_shop_close_interface ( player pl  )  [static]

Send a player shop socket command to the player's client to close a shop interface.

Parameters:
pl The player to send the command to

Definition at line 175 of file player_shop.c.

void player_shop_examine ( char *  data,
player pl 
)

Examine a player shop item.

Parameters:
data The data buffer sent from the client. Contains the seller name and the object's tag ID.
pl The player examining the item

Definition at line 423 of file player_shop.c.

static void player_shop_free_structure ( player pl,
int  send_close 
) [static]

Free a shop structure from player.

Parameters:
pl The player
send_close If nonzero, send a close command to the client.

Definition at line 188 of file player_shop.c.

void player_shop_load ( char *  data,
player pl 
)

Load a player shop of other player.

Parameters:
data The player name of the shop owner to open
pl The player to load the shop for

Definition at line 383 of file player_shop.c.

void player_shop_open ( char *  data,
player pl 
)

Open a player shop.

The data passed includes the items, ie, their tags, nrof, price, etc.

Format:

item_tag:nrof:price|item_tag:nrof:price|...

Example:

25984:10:10000|28549:1:20200|27859:3:10010
Parameters:
data Data, with the shop items in it separated by | characters.
pl The player opening the shop

Definition at line 250 of file player_shop.c.

static void player_shop_send_items ( player pl,
player seller 
) [static]

Loop through seller's items on sale, and send the item tags to buyer's shop inventory so they can be displayed and animated properly.

Will also send all the data about the shop items to the buyer.

Parameters:
pl The player to send the items to
seller The selling player

Definition at line 44 of file player_shop.c.

static int shop_player_in_range ( object op,
object seller 
) [static]

Check if player that wants to buy from someones player shop is in range to actually initiate the shop interface.

Uses get_rangevector() to calculate the distance.

Parameters:
op Pointer to the buying player's object
seller Pointer to the selling player's object
Returns:
1 if the buyer is in range, 0 otherwise
See also:
PLAYER_SHOP_MAX_DISTANCE

Definition at line 225 of file player_shop.c.