Atrinik Server  4.0
Data Structures | Macros | Typedefs | Functions
bank.c File Reference
#include <global.h>
#include <toolkit/string.h>
#include <arch.h>
#include <player.h>
#include <object.h>

Go to the source code of this file.

Data Structures

struct  bank_info
 

Macros

#define BANK_STRING_NONE   0
 
#define BANK_STRING_AMOUNT   1
 
#define BANK_STRING_ALL   -1
 

Typedefs

typedef struct bank_info bank_info_t
 

Functions

static void bank_parse_string (const char *str, bank_info_t *info)
 
static uint32_t bank_get_coins_num (object *op, archetype_t *at)
 
static int64_t bank_remove_coins (object *op, archetype_t *at, uint32_t nrof)
 
static void bank_insert_coins (object *op, archetype_t *at, uint32_t nrof)
 
objectbank_find_info (object *op)
 
static objectbank_create_info (object *op)
 
static objectbank_get_info (object *op)
 
int64_t bank_get_balance (object *op)
 
int bank_deposit (object *op, const char *text, int64_t *value)
 
int bank_withdraw (object *op, const char *text, int64_t *value)
 

Detailed Description

Bank related code.

Author
Alex Tokar

Definition in file bank.c.

Typedef Documentation

typedef struct bank_info bank_info_t

Used for depositing/withdrawing coins from the bank, and using string to get information about how many coins to deposit/withdraw.

Function Documentation

static object* bank_create_info ( object op)
static

Create a new bank player info object and insert it to 'op'.

Parameters
opPlayer.
Returns
The created player info object.

Definition at line 246 of file bank.c.

int bank_deposit ( object op,
const char *  text,
int64_t *  value 
)

Deposit money to player's bank object.

Parameters
opPlayer.
textWhat was said to trigger this.
[out]valueWill contain the deposited amount.
Returns
One of Bank return values.

Definition at line 300 of file bank.c.

object* bank_find_info ( object op)

Find bank player info object in player's inventory.

Parameters
opWhere to look for the player info object.
Returns
The player info object if found, NULL otherwise.

Definition at line 227 of file bank.c.

int64_t bank_get_balance ( object op)

Query how much money player has stored in bank.

Parameters
opPlayer to query for.
Returns
The money stored.

Definition at line 278 of file bank.c.

static uint32_t bank_get_coins_num ( object op,
archetype_t at 
)
static

Get number of specific coins in the object's inventory.

Parameters
opObject to search in.
atArchetype the coins must match.
Returns
Number of coins in the object's inventory.

Definition at line 145 of file bank.c.

static object* bank_get_info ( object op)
static

Convenience function to either find a bank player info object and if not found, create a new one.

Parameters
opPlayer object.
Returns
The bank player info object. Never NULL.

Definition at line 262 of file bank.c.

static void bank_insert_coins ( object op,
archetype_t at,
uint32_t  nrof 
)
static

Insert coins into the object.

Parameters
opObject.
atMoney arch to insert.
nrofNumber of coins.

Definition at line 212 of file bank.c.

static void bank_parse_string ( const char *  str,
bank_info_t info 
)
static

Parse a string into the bank into structure.

Parameters
strText to get money from.
infoBank info structure.

Definition at line 84 of file bank.c.

static int64_t bank_remove_coins ( object op,
archetype_t at,
uint32_t  nrof 
)
static

Remove money by the specified coin type.

Parameters
opObject we're removing from.
atArchetype the coins must match.
nrofAmount of money to remove. Has no effect if 'at' is NULL.
Returns
Removed amount.

Definition at line 171 of file bank.c.

int bank_withdraw ( object op,
const char *  text,
int64_t *  value 
)

Withdraw money player previously stored in bank object.

Parameters
opPlayer.
bankBank object in player's inventory.
textWhat was said to trigger this.
[out]valueWill contain the withdrawn amount.
Returns
One of Bank return values.

Definition at line 402 of file bank.c.