Atrinik Server 2.5
Defines | Functions | Variables
server/arch.c File Reference
#include <global.h>
#include <loader.h>

Go to the source code of this file.

Defines

#define TIME_ARCH_LOAD   0

Functions

static void clear_archetable ()
static void init_archetable ()
static archetypeget_archetype_struct ()
static void first_arch_pass (FILE *fp)
static void second_arch_pass (FILE *fp_start)
static void load_archetypes ()
static unsigned long hasharch (const char *str, int tablesize)
static void add_arch (archetype *at)
archetypeget_skill_archetype (int skillnr)
void init_archetypes ()
void arch_info (object *op)
void dump_all_archetypes ()
void free_all_archs ()
objectarch_to_object (archetype *at)
objectcreate_singularity (const char *name)
objectget_archetype (const char *name)
archetypefind_archetype (const char *name)

Variables

static archetypearch_table [ARCHTABLE]
int arch_cmp = 0
int arch_search = 0
int arch_init

Detailed Description

Arch related functions.

Definition in file arch.c.


Define Documentation

#define TIME_ARCH_LOAD   0

If set, does a little timing on the archetype load.

Definition at line 34 of file arch.c.


Function Documentation

static void add_arch ( archetype at) [static]

Adds an archetype to the hashtable.

Definition at line 670 of file arch.c.

void arch_info ( object op)

Prints how efficient the hashtable used for archetypes has been in.

Parameters:
opPlayer object to print the information to.

Definition at line 98 of file arch.c.

object* arch_to_object ( archetype at)

Creates and returns a new object which is a copy of the given archetype.

Parameters:
atArchetype from which to get an object.
Returns:
Object of specified type.

Definition at line 546 of file arch.c.

static void clear_archetable ( ) [static]

Initialize the hashtable used by the archetypes.

Definition at line 108 of file arch.c.

object* create_singularity ( const char *  name)

Creates a dummy object. This function is called by get_archetype() if it fails to find the appropriate archetype.

Thus get_archetype() will be guaranteed to always return an object, and never NULL.

Parameters:
nameName to give the dummy object.
Returns:
Object of specified name. It fill have the FLAG_NO_PICK flag set.

Definition at line 572 of file arch.c.

void dump_all_archetypes ( )

Dumps _all_ archetypes and artifacts to debug-level output.

Definition at line 132 of file arch.c.

archetype* find_archetype ( const char *  name)

Finds, using the hashtable, which archetype matches the given name.

Returns:
Pointer to the found archetype, otherwise NULL.

Definition at line 631 of file arch.c.

static void first_arch_pass ( FILE *  fp) [static]

Reads/parses the archetype-file, and copies into a linked list of archetype structures.

Parameters:
fpOpened file descriptor which will be used to read the archetypes.

Definition at line 229 of file arch.c.

void free_all_archs ( )

Frees all memory allocated to archetypes.

After calling this, it's possible to call again init_archetypes() to reload data.

Definition at line 173 of file arch.c.

object* get_archetype ( const char *  name)

Finds which archetype matches the given name, and returns a new object containing a copy of the archetype.

Parameters:
nameArchetype name.
Returns:
Object of specified archetype, or a singularity. Will never be NULL.

Definition at line 591 of file arch.c.

static archetype * get_archetype_struct ( ) [static]

Allocates, initializes and returns the pointer to an archetype structure.

Returns:
New archetype structure, will never be NULL.

Definition at line 207 of file arch.c.

archetype* get_skill_archetype ( int  skillnr)

Get the skill object for skill ID.

Parameters:
skillnrThe skill number to find object for.
Returns:
Object if found, NULL otherwise.

Definition at line 58 of file arch.c.

static unsigned long hasharch ( const char *  str,
int  tablesize 
) [static]

Hash-function used by the arch-hashtable.

Parameters:
strArchetype name.
tablesizeSize of the hash table
Returns:
Hash of the archetype name

Definition at line 608 of file arch.c.

static void init_archetable ( ) [static]

An alternative way to init the hashtable which is slower, but _works_...

Definition at line 116 of file arch.c.

void init_archetypes ( )

Initializes the internal linked list of archetypes (read from file). Some commonly used archetype pointers like empty_archetype, base_info_archetype are initialized.

Can be called multiple times, will just return.

Definition at line 79 of file arch.c.

static void load_archetypes ( ) [static]

Loads all archetypes and treasures.

First initializes the archtype hash-table (init_archetable()). Reads and parses the archetype file (with the first and second-pass functions). Then initializes treasures by calling load_treasures().

Definition at line 479 of file arch.c.

static void second_arch_pass ( FILE *  fp_start) [static]

Reads the archetype file once more, and links all pointers between archetypes and treasure lists. Must be called after first_arch_pass().

Parameters:
fp_startFile from which to read. Won't be rewinded.

Definition at line 313 of file arch.c.


Variable Documentation

int arch_cmp = 0

How many strcmp's

Definition at line 39 of file arch.c.

int arch_init

True if doing arch initialization

Definition at line 43 of file arch.c.

int arch_search = 0

How many searches

Definition at line 41 of file arch.c.

archetype* arch_table[ARCHTABLE] [static]

The arch table.

Definition at line 37 of file arch.c.