Crossfire Server, Trunk  R20513
Macros | Functions
holy.c File Reference

God-related common functions. More...

#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "libproto.h"
#include "living.h"
#include "spells.h"
Include dependency graph for holy.c:

Go to the source code of this file.

Macros

#define DESCRIBE_ABILITY(retbuf, variable, name)
 
#define DESCRIBE_PATH(retbuf, variable, name)
 

Functions

static void add_god_to_list (archetype *god_arch)
 Adds specified god to linked list, gives it an id. More...
 
int describe_god (const object *god, int what, StringBuffer *buf, size_t maxlen)
 Describe a god. More...
 
void dump_gods (void)
 Prints all gods to stderr. More...
 
void free_all_god (void)
 Frees all god information. More...
 
godlinkget_rand_god (void)
 Returns a random god. More...
 
void init_gods (void)
 This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD) More...
 
static godlinkinit_godslist (void)
 Initializes a god structure. More...
 
const objectpntr_to_god_obj (godlink *godlnk)
 Returns a pointer to the object We need to be VERY careful about using this, as we are returning a pointer to the CLONE object. More...
 

Detailed Description

God-related common functions.

Definition in file holy.c.

Macro Definition Documentation

#define DESCRIBE_ABILITY (   retbuf,
  variable,
  name 
)
Value:
if (variable) { \
int i, j = 0; \
strcat(retbuf, "(" name ": "); \
for (i = 0; i < NROFATTACKS; i++) \
if (variable&(1<<i)) { \
if (j) \
strcat(retbuf, ", "); \
else \
j = 1; \
strcat(retbuf, attacks[i]); \
} \
strcat(retbuf, ")"); \
}
#define NROFATTACKS
Definition: attack.h:17
const char *const attacks[NROFATTACKS]
Attack type names.
Definition: living.c:129

Definition at line 350 of file holy.c.

Referenced by dump_gods().

#define DESCRIBE_PATH (   retbuf,
  variable,
  name 
)
Value:
if (variable) { \
int i, j = 0; \
strcat(retbuf, "(" name ": "); \
for (i = 0; i < NRSPELLPATHS; i++) \
if (variable&(1<<i)) { \
if (j) \
strcat(retbuf, ", "); \
else \
j = 1; \
strcat(retbuf, spellpathnames[i]); \
} \
strcat(retbuf, ")"); \
}
const char *const spellpathnames[NRSPELLPATHS]
Perhaps not the best place for this, but needs to be in some file in the common area so that standalo...
Definition: init.c:120
#define NRSPELLPATHS
Number of spell paths.
Definition: spells.h:40

Definition at line 365 of file holy.c.

Referenced by dump_gods().

Function Documentation

static void add_god_to_list ( archetype god_arch)
static

Adds specified god to linked list, gives it an id.

Parameters
god_archGod to add. If NULL, will log an error.

Definition at line 70 of file holy.c.

References add_string(), glnk::arch, archt::clone, first_god, glnk::id, init_godslist(), llevDebug, llevError, LOG(), glnk::name, obj::name, and glnk::next.

Referenced by init_gods().

Here is the call graph for this function:

Here is the caller graph for this function:

int describe_god ( const object god,
int  what,
StringBuffer buf,
size_t  maxlen 
)

Describe a god.

The reason we return a combination is to know what exactly was written for knowledge management.

Parameters
godwhich god to describe.
whatinformation to describe, combination of GOD_xxx flags.
bufwhere to describe, must not be NULL.
maxlenmaximum wanted length of the description, if 0 no maximum length.
Returns
information actually written, combination of GOD_xxx, based on maxlen.

Definition at line 137 of file holy.c.

References attacktype_desc, describe_resistance(), describe_spellpath_attenuation(), GOD_BLESSED, GOD_ENEMY, GOD_HOLYWORD, GOD_IMMUNITIES, GOD_PATHS, GOD_RESISTANCES, GOD_SACRED, HUGE_BUF, MAX_BUF, obj::msg, obj::name, NROFATTACKS, nstrtok(), obj::path_attuned, obj::path_denied, obj::path_repelled, PATH_SUMMON, PATH_TURNING, obj::race, obj::resist, obj::slaying, snprintf, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_append_stringbuffer(), stringbuffer_finish(), stringbuffer_length(), stringbuffer_new(), strtoktolin(), and obj::title.

Referenced by god_info_msg(), and knowledge_god_detail().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_gods ( void  )
void free_all_god ( void  )

Frees all god information.

Definition at line 337 of file holy.c.

References first_god, free_string(), llevDebug, LOG(), glnk::name, and glnk::next.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

godlink* get_rand_god ( void  )

Returns a random god.

Returns
a random god, or NULL if no god was found.

Definition at line 101 of file holy.c.

References first_god, glnk::id, llevError, LOG(), glnk::next, and RANDOM.

Referenced by god_info_msg().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_gods ( void  )

This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD)

Definition at line 53 of file holy.c.

References add_god_to_list(), archt::clone, first_archetype, GOD, llevDebug, LOG(), archt::next, and obj::type.

Referenced by generate_map(), init_beforeplay(), main(), and setup().

Here is the call graph for this function:

Here is the caller graph for this function:

static godlink* init_godslist ( void  )
static

Initializes a god structure.

Note
Will never return NULL.

Definition at line 37 of file holy.c.

References glnk::arch, fatal(), glnk::id, glnk::name, glnk::next, and OUT_OF_MEMORY.

Referenced by add_god_to_list().

Here is the call graph for this function:

Here is the caller graph for this function:

const object* pntr_to_god_obj ( godlink godlnk)

Returns a pointer to the object We need to be VERY careful about using this, as we are returning a pointer to the CLONE object.

-b.t.

Parameters
godlnkgod to get object.

Definition at line 123 of file holy.c.

References glnk::arch, and archt::clone.

Referenced by dump_gods(), find_god(), and god_info_msg().

Here is the caller graph for this function: