Crossfire Server, Trunk
party.cpp File Reference
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "sproto.h"
+ Include dependency graph for party.cpp:

Go to the source code of this file.

Functions

int party_confirm_password (const partylist *party, const char *password)
 
partylistparty_find (const char *partyname)
 
partylistparty_form (object *op, const char *partyname)
 
partylistparty_get_first (void)
 
const char * party_get_leader (const partylist *party)
 
partylistparty_get_next (const partylist *party)
 
const char * party_get_password (const partylist *party)
 
void party_join (object *op, partylist *party)
 
void party_leave (object *op)
 
void party_obsolete_parties (void)
 
void party_remove (partylist *party)
 
void party_send_message (object *op, const char *message)
 
void party_set_password (partylist *party, const char *password)
 
static void remove_if_unused (partylist *party)
 

Variables

static partylistfirstparty = NULL
 
static partylistlastparty = NULL
 

Detailed Description

Party-structure related functions.

Definition in file party.cpp.

Function Documentation

◆ party_confirm_password()

int party_confirm_password ( const partylist party,
const char *  password 
)

Checks whether a given password matches the party's password.

Parameters
partythe party to check
passwordthe password to check for
Returns
whether the password matches

Definition at line 259 of file party.cpp.

References partylist::passwd.

Referenced by check_login(), and confirm_party_password().

+ Here is the caller graph for this function:

◆ party_find()

partylist* party_find ( const char *  partyname)

Find a party by name.

Parameters
partynamethe party's name to find
Returns
the party or NULL if no such party exists

Definition at line 148 of file party.cpp.

References firstparty, partylist::next, and partylist::partyname.

Referenced by check_login(), command_party(), confirm_party_password(), and party_form().

+ Here is the caller graph for this function:

◆ party_form()

partylist* party_form ( object op,
const char *  partyname 
)

Forms the party struct for a party called 'partyname'. it is the responsibility of the caller to ensure that the name is unique. New item is placed on the party list.

Parameters
opparty creator.
partynamethe party name.
Returns
new party or NULL if the name is not unique.

Definition at line 40 of file party.cpp.

References buf, draw_ext_info_format(), firstparty, lastparty, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, partylist::next, give::op, party_find(), party_leave(), partylist::partyleader, partylist::partyname, partylist::passwd, replace_unprintable_chars(), strdup_local, and strlcpy().

Referenced by check_login(), command_party(), and START_TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_get_first()

partylist* party_get_first ( void  )

Returns the first party from the list of all parties.

Returns
the first party or NULL if no party exists

Definition at line 196 of file party.cpp.

References firstparty.

Referenced by cfapi_party_get_property(), cfapi_system_get_party_vector(), command_party(), and START_TEST().

+ Here is the caller graph for this function:

◆ party_get_leader()

const char* party_get_leader ( const partylist party)

Returns the name of the party's leader.

Parameters
partythe party to query
Returns
the leader's name

Definition at line 292 of file party.cpp.

References partylist::partyleader.

Referenced by command_party(), and START_TEST().

+ Here is the caller graph for this function:

◆ party_get_next()

partylist* party_get_next ( const partylist party)

Returns the next party from the list of all parties.

Parameters
partythe party to use
Returns
the next party or NULL if party is the last one in list

Definition at line 208 of file party.cpp.

References partylist::next.

Referenced by cfapi_party_get_property(), cfapi_system_get_party_vector(), command_party(), and START_TEST().

+ Here is the caller graph for this function:

◆ party_get_password()

const char* party_get_password ( const partylist party)

Returns the party's password.

Parameters
partythe party to query
Returns
the password or an empty string if the party has no password

Definition at line 232 of file party.cpp.

References partylist::passwd.

Referenced by cfapi_party_get_property(), command_party(), get_party_password(), and save_player().

+ Here is the caller graph for this function:

◆ party_join()

void party_join ( object op,
partylist party 
)

Makes a player join a party. Leaves the former party if necessary. Does nothing if the player already is a member of the party.

Parameters
opthe player
partythe party to join

Definition at line 85 of file party.cpp.

References buf, draw_ext_info_format(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, give::op, party_leave(), party_send_message(), and partylist::partyname.

Referenced by cfapi_object_set_property(), check_login(), command_party(), and receive_party_password().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_leave()

void party_leave ( object op)

Makes a player leave his party. Does nothing if the player is not member of a party.

Parameters
opthe player

Definition at line 123 of file party.cpp.

References buf, draw_ext_info_format(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, give::op, party_send_message(), partylist::partyname, and remove_if_unused().

Referenced by apply_savebed(), command_party(), key_confirm_quit(), kill_player_permadeath(), leave(), party_form(), and party_join().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_obsolete_parties()

void party_obsolete_parties ( void  )

Remove unused parties (no players).

Definition at line 215 of file party.cpp.

References firstparty, partylist::next, give::next, and remove_if_unused().

Referenced by do_specials(), and START_TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_remove()

void party_remove ( partylist party)

Removes and frees a party. Removes all members from the party.

Parameters
partythe party to remove

Definition at line 164 of file party.cpp.

References first_player, firstparty, lastparty, llevError, LOG(), partylist::next, partylist::partyleader, partylist::partyname, and altar_valkyrie::pl.

Referenced by remove_if_unused(), and START_TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_send_message()

void party_send_message ( object op,
const char *  message 
)

Send a message to all party members except the speaker.

Parameters
opplayer talking.
messagemessage to send.
Todo:
should be moved to player.c?

Definition at line 274 of file party.cpp.

References draw_ext_info(), first_player, diamondslots::message, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_PARTY, NDI_WHITE, give::op, and altar_valkyrie::pl.

Referenced by command_party(), party_join(), and party_leave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ party_set_password()

void party_set_password ( partylist party,
const char *  password 
)

Sets a party's password.

Parameters
partythe party to change
passwordthe new password to set

Definition at line 244 of file party.cpp.

References partylist::passwd, replace_unprintable_chars(), and strlcpy().

Referenced by check_login(), and command_party().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove_if_unused()

static void remove_if_unused ( partylist party)
static

Remove party if it has no players.

Definition at line 108 of file party.cpp.

References first_player, party_remove(), and altar_valkyrie::pl.

Referenced by party_leave(), and party_obsolete_parties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ firstparty

partylist* firstparty = NULL
static

Keeps track of first party in list

Definition at line 26 of file party.cpp.

Referenced by party_find(), party_form(), party_get_first(), party_obsolete_parties(), and party_remove().

◆ lastparty

partylist* lastparty = NULL
static

Keeps track of last party in list

Definition at line 27 of file party.cpp.

Referenced by party_form(), and party_remove().