Planeshift
psGUIInventoryMessage Class Reference

This message class deals with the inventory messages. More...

#include <messages.h>

Classes

struct  ItemDescription
 A small struct to hold item info after read out of message. More...
 

Public Types

enum  commands { LIST, REQUEST, UPDATE_REQUEST, UPDATE_LIST }
 

Public Member Functions

void AddEmptySlot (int containerID, int slotID)
 Add a newly emptied slot to output message buffer. More...
 
void AddItem (const char *name, const char *meshName, const char *materialName, int containerID, int slot, int stackcount, float weight, float size, const char *icon, int purifyStatus, csStringSet *msgstrings)
 Add an item to the output message buffer. More...
 
void AddMoney (const psMoney &money)
 Add money to the output message buffer. More...
 
 PSF_DECLARE_MSG_FACTORY ()
 
 psGUIInventoryMessage (uint8_t command=REQUEST, uint32_t size=0)
 Creates a message with a command and max size. More...
 
 psGUIInventoryMessage (uint32_t clientNum, uint8_t command, uint32_t totalItems, uint32_t totalEmptiedSlots, float maxWeight, uint32_t cache_version, size_t msgsize)
 Create a new message that will be used for an inventory list. More...
 
 psGUIInventoryMessage (MsgEntry *message, NetBase::AccessPointers *accessPointers)
 Crack open the message. More...
 
virtual csString ToString (NetBase::AccessPointers *accessPointers)
 Converts the message into human readable string. More...
 
- Public Member Functions inherited from psMessageCracker
void FireEvent ()
 Publishes the message to the local program. More...
 
virtual csString GetMessageTypeName () const =0
 Gets the name of the message type. More...
 
void Multicast (csArray< PublishDestination > &multi, uint32_t except, float range)
 Multicasts the message to all current connections. More...
 
 psMessageCracker ()
 
void SendMessage ()
 Sends the message to the client/server. More...
 
virtual ~psMessageCracker ()
 

Public Attributes

uint8_t command
 
csArray< ItemDescriptionitems
 
float maxWeight
 The total max weight the player can carry. More...
 
psMoney money
 
size_t totalEmptiedSlots
 
size_t totalItems
 
uint32 version
 
- Public Attributes inherited from psMessageCracker
int filterNumber
 
csRef< MsgEntrymsg
 
bool valid
 

Additional Inherited Members

- Static Public Attributes inherited from psMessageCracker
static MsgHandlermsghandler
 

Detailed Description

This message class deals with the inventory messages.

This deals with all the requests/incomming information that the player may need for the inventory screen. When the message is cracked open it fills some public data members with data from the message based on what the command is, so you should be aware of which data is valid for which commands.

When building the message the usual flow is:

  • Create the message with the right command
  • Use functions to add data to the message buffer.

When reading the message the usual flow is:

  • Crack message.
  • Read valid data members based on command.

Definition at line 1672 of file messages.h.

Member Enumeration Documentation

Enumerator
LIST 

This is a list of items.

REQUEST 

This is a request for entire inventory.

UPDATE_REQUEST 

This is a request for inventory updates.

UPDATE_LIST 

This is a list-update of items.

Definition at line 1675 of file messages.h.

Constructor & Destructor Documentation

psGUIInventoryMessage::psGUIInventoryMessage ( uint8_t  command = REQUEST,
uint32_t  size = 0 
)

Creates a message with a command and max size.

The default message constructed is a request for inventory which should normally be only done on the client.

Parameters
commandThe type that this inventory message is. Should be one of the defined enums. Default is request for inventory.
sizeThe max size of this message. Can be clipped when sent on the network.
psGUIInventoryMessage::psGUIInventoryMessage ( uint32_t  clientNum,
uint8_t  command,
uint32_t  totalItems,
uint32_t  totalEmptiedSlots,
float  maxWeight,
uint32_t  cache_version,
size_t  msgsize 
)

Create a new message that will be used for an inventory list.

This is usually done by the server to create a message to be sent to the client about the player's inventory. It needs to know totalItems so it can write that to the message first.

Parameters
clientNumClient destination.
commandShould be LIST.
totalItemsThe total items or item stacks.
totalEmptiedSlotsThe total number of slots been emptied.
maxWeightThe max weight the player can carry.
cache_versionInventory cache version we're gonna build in this message.
msgsizeThe size.
psGUIInventoryMessage::psGUIInventoryMessage ( MsgEntry message,
NetBase::AccessPointers accessPointers 
)

Crack open the message.

This is a switch statement that fills in particular data members depending on the command that is given.

Member Function Documentation

void psGUIInventoryMessage::AddEmptySlot ( int  containerID,
int  slotID 
)

Add a newly emptied slot to output message buffer.

void psGUIInventoryMessage::AddItem ( const char *  name,
const char *  meshName,
const char *  materialName,
int  containerID,
int  slot,
int  stackcount,
float  weight,
float  size,
const char *  icon,
int  purifyStatus,
csStringSet *  msgstrings 
)

Add an item to the output message buffer.

void psGUIInventoryMessage::AddMoney ( const psMoney money)

Add money to the output message buffer.

psGUIInventoryMessage::PSF_DECLARE_MSG_FACTORY ( )
virtual csString psGUIInventoryMessage::ToString ( NetBase::AccessPointers accessPointers)
virtual

Converts the message into human readable string.

Parameters
accessPointersA struct to a number of access pointers.
Returns
Return a human readable string for the message.

Implements psMessageCracker.

Member Data Documentation

uint8_t psGUIInventoryMessage::command

Definition at line 1684 of file messages.h.

csArray<ItemDescription> psGUIInventoryMessage::items

Definition at line 1777 of file messages.h.

float psGUIInventoryMessage::maxWeight

The total max weight the player can carry.

Definition at line 1780 of file messages.h.

psMoney psGUIInventoryMessage::money

Definition at line 1781 of file messages.h.

size_t psGUIInventoryMessage::totalEmptiedSlots

Definition at line 1779 of file messages.h.

size_t psGUIInventoryMessage::totalItems

Definition at line 1778 of file messages.h.

uint32 psGUIInventoryMessage::version

Definition at line 1782 of file messages.h.


The documentation for this class was generated from the following file: