Crossfire Server, Trunk  R20513
Functions | Variables
party.c File Reference

Party-structure related functions. More...

#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "sproto.h"
Include dependency graph for party.c:

Go to the source code of this file.

Functions

int party_confirm_password (const partylist *party, const char *password)
 Checks whether a given password matches the party's password. More...
 
partylistparty_find (const char *partyname)
 Find a party by name. More...
 
partylistparty_form (object *op, const char *partyname)
 Forms the party struct for a party called 'partyname'. More...
 
partylistparty_get_first (void)
 Returns the first party from the list of all parties. More...
 
const char * party_get_leader (const partylist *party)
 Returns the name of the party's leader. More...
 
partylistparty_get_next (const partylist *party)
 Returns the next party from the list of all parties. More...
 
const char * party_get_password (const partylist *party)
 Returns the party's password. More...
 
void party_join (object *op, partylist *party)
 Makes a player join a party. More...
 
void party_leave (object *op)
 Makes a player leave his party. More...
 
void party_obsolete_parties (void)
 Remove unused parties (no players), this could be made to scale a lot better. More...
 
void party_remove (partylist *party)
 Removes and frees a party. More...
 
void party_send_message (object *op, const char *message)
 Send a message to all party members except the speaker. More...
 
void party_set_password (partylist *party, const char *password)
 Sets a party's password. More...
 

Variables

static partylistfirstparty = NULL
 Keeps track of first party in list. More...
 
static partylistlastparty = NULL
 Keeps track of last party in list. More...
 

Detailed Description

Party-structure related functions.

Definition in file party.c.

Function Documentation

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 290 of file party.c.

References party_struct::passwd.

Referenced by check_login(), and confirm_party_password().

Here is the caller graph for this function:

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 147 of file party.c.

References party_struct::next, and party_struct::partyname.

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

Here is the caller graph for this function:

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.c.

References obj::contr, draw_ext_info_format(), firstparty, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, obj::name, NDI_UNIQUE, party_struct::next, pl::party, party_find(), party_leave(), party_struct::partyleader, party_struct::partyname, party_struct::passwd, replace_unprintable_chars(), snprintf, and strdup_local.

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:

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 217 of file party.c.

References firstparty.

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

Here is the caller graph for this function:

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 322 of file party.c.

References MAX_NAME, and party_struct::partyleader.

Referenced by command_party(), and START_TEST().

Here is the caller graph for this function:

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 229 of file party.c.

References party_struct::next.

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

Here is the caller graph for this function:

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 263 of file party.c.

References party_struct::passwd.

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

Here is the caller graph for this function:

void party_join ( object op,
partylist party 
)

Makes a player join a party.

Leaves the a former party if necessary.

Parameters
opthe player
partythe party to join

Definition at line 84 of file party.c.

References obj::contr, draw_ext_info_format(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, obj::name, NDI_UNIQUE, pl::party, party_leave(), party_send_message(), party_struct::partyname, and snprintf.

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:

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 104 of file party.c.

References obj::contr, draw_ext_info_format(), first_player, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, obj::name, NDI_UNIQUE, pl::next, pl::party, party_remove(), party_send_message(), party_struct::partyname, and snprintf.

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:

void party_obsolete_parties ( void  )

Remove unused parties (no players), this could be made to scale a lot better.

Definition at line 236 of file party.c.

References first_player, party_struct::next, pl::next, pl::party, and party_remove().

Referenced by do_specials(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void party_remove ( partylist party)

Removes and frees a party.

Removes all members from the party.

Parameters
partythe party to remove
Todo:
clean/simplify the mess.

Definition at line 165 of file party.c.

References llevError, LOG(), party_struct::next, party_struct::partyleader, and party_struct::partyname.

Referenced by party_leave(), party_obsolete_parties(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

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 305 of file party.c.

References obj::contr, draw_ext_info(), first_player, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_PARTY, NDI_WHITE, pl::next, pl::ob, and pl::party.

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:

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 275 of file party.c.

References party_struct::passwd, replace_unprintable_chars(), and snprintf.

Referenced by check_login(), and command_party().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

partylist* firstparty = NULL
static

Keeps track of first party in list.

Definition at line 26 of file party.c.

Referenced by party_form(), and party_get_first().

partylist* lastparty = NULL
static

Keeps track of last party in list.

Definition at line 27 of file party.c.