Atrinik Server  4.0
Data Structures | Typedefs | Functions | Variables
readable.c File Reference
#include <global.h>
#include <book.h>
#include <toolkit/string.h>
#include <arch.h>
#include <artifact.h>

Go to the source code of this file.

Data Structures

struct  namebytype
 

Typedefs

typedef struct namebytype arttypename
 

Functions

static int buf_overflow (const char *buf1, const char *buf2, size_t bufsize)
 
int book_overflow (const char *buf1, const char *buf2, size_t booksize)
 
static void init_msgfile (void)
 
static void init_mon_info (void)
 
void init_readable (void)
 
static void new_text_name (object *book, int msgtype)
 
static void add_author (object *op, int msgtype)
 
static void change_book (object *book, int msgtype)
 
objectget_random_mon (void)
 
static char * mon_desc (object *mon, char *buf, size_t size)
 
static char * mon_info_msg (char *buf, size_t booksize)
 
static char * artifact_msg (int level, char *buf, size_t booksize)
 
static char * spellpath_msg (int level, char *buf, size_t booksize)
 
static char * msgfile_msg (size_t booksize)
 
void tailor_readable_ob (object *book, int msg_type)
 
void free_all_readable (void)
 

Variables

static object ** monsters = NULL
 
static size_t num_monsters = 0
 
static char ** msgs = NULL
 
static size_t num_msgs = 0
 
static uint32_t spellpathdef [NRSPELLPATHS]
 
static const char *const path_book_name []
 
static const char *const path_author []
 
static arttypename art_name_array []
 
static const char *const art_book_name []
 
static const char *const art_author []
 
static const char *const mon_book_name []
 
static const char *const mon_author []
 
static const char *const book_name []
 
static const char *const book_author []
 

Detailed Description

This file contains code relevant to allow randomly occurring messages in non-magical texts.

Author
b.t. thoma.nosp@m.s@as.nosp@m.tro.p.nosp@m.su.e.nosp@m.du
Date
December 1995

Definition in file readable.c.

Typedef Documentation

typedef struct namebytype arttypename

special structure, used only by art_name_array[]

Function Documentation

static void add_author ( object op,
int  msgtype 
)
static

A lot like new_text_name(), but instead chooses an author and sets op->title to that value.

Parameters
opThe book object.
msgtypeMessage type.

Definition at line 503 of file readable.c.

static char* artifact_msg ( int  level,
char *  buf,
size_t  booksize 
)
static

Generate a message detailing the properties of 1-6 artifacts drawn sequentially from the artifact list.

Parameters
levelLevel of the book
bufBuffer to contain the description.
booksizeLength of the book.
Returns
'buf'.

Definition at line 637 of file readable.c.

int book_overflow ( const char *  buf1,
const char *  buf2,
size_t  booksize 
)

Checks if book will overflow.

Parameters
buf1
buf2Buffers we plan on combining.
booksizeMaximum book size.
Returns
1 if it will overflow, 0 otherwise.

Definition at line 346 of file readable.c.

static int buf_overflow ( const char *  buf1,
const char *  buf2,
size_t  bufsize 
)
static

We don't want to exceed the buffer size of buf1 by adding on buf2!

Parameters
buf1
buf2Buffers we plan on concatenating. Can be NULL.
bufsizeSize of buf1. Can be 0.
Returns
1 if overflow will occur, 0 otherwise.

Definition at line 315 of file readable.c.

static void change_book ( object book,
int  msgtype 
)
static

Give a new, fancier name to generated objects of type BOOK and SPELLBOOK.

Will attempt to create consistent author/title and message content for BOOKs. Also, will alter books that match archive entries to the archival levels and archetypes.

Parameters
bookThe book object to alter.
msgtypeMessage type to make.

Definition at line 546 of file readable.c.

void free_all_readable ( void  )

Cleanup routine for readable stuff.

Definition at line 896 of file readable.c.

object* get_random_mon ( void  )

Returns a random monster from all the monsters in the game.

Returns
The monster object

Definition at line 563 of file readable.c.

static void init_mon_info ( void  )
static

Initialize array of monsters.

Definition at line 423 of file readable.c.

static void init_msgfile ( void  )
static

Reads the messages file into the list pointed to by first_msg.

Definition at line 359 of file readable.c.

void init_readable ( void  )

Initializes linked lists utilized by message functions in tailor_readable_ob().

This is the function called by the main routine to initialize all the readable information.

Definition at line 447 of file readable.c.

static char* mon_desc ( object mon,
char *  buf,
size_t  size 
)
static

Returns a description of the monster.

Parameters
monMonster to describe.
bufBuffer that will contain the description.
sizeSize of 'buf'.
Returns
'buf'.

Definition at line 584 of file readable.c.

static char* mon_info_msg ( char *  buf,
size_t  booksize 
)
static

Generate a message detailing the properties of randomly selected monsters.

Parameters
bufBuffer that will contain the message.
booksizeSize (in characters) of the book we want.
Returns
'buf'.

Definition at line 602 of file readable.c.

static char* msgfile_msg ( size_t  booksize)
static

Generate a message drawn randomly from a file in lib/.

Parameters
booksizeMaximum book size.
Returns
Pointer to the generated message.

Definition at line 810 of file readable.c.

static void new_text_name ( object book,
int  msgtype 
)
static

Only for objects of type BOOK. SPELLBOOK stuff is handled directly in change_book_name(). Names are based on text msgtype.

This sets book book->name based on msgtype given. What name is given is based on various criteria.

Parameters
bookThe book object.
msgtypeMessage type.

Definition at line 465 of file readable.c.

static char* spellpath_msg ( int  level,
char *  buf,
size_t  booksize 
)
static

Generate a message detailing the member incantations (and some of their properties) belonging to a random spellpath.

Parameters
levelLevel of the book.
bufBuffer to write the description into.
booksizeLength of the book.
Returns
'buf'.

Definition at line 757 of file readable.c.

void tailor_readable_ob ( object book,
int  msg_type 
)

The main routine. This chooses a random message to put in given readable object (type == BOOK) which will be referred hereafter as a 'book'. We use the book level to de- termine the value of the information we will insert. Higher values mean the book will (generally) have better/more info. See individual cases as to how this will be utilized. "Book" name/content length are based on the weight of the document. If the value of msg_type is negative, we will randomly choose the kind of message to generate.

Parameters
bookThe object we are creating into.
msg_typeIf this is a positive value, we use it to determine the message type - otherwise a random value is used.
Author
b.t. thoma.nosp@m.s@as.nosp@m.tro.p.nosp@m.su.e.nosp@m.du

Definition at line 847 of file readable.c.

Variable Documentation

const char* const art_author[]
static
Initial value:
= {
"ancient things",
"artifacts",
"Havlor",
"items",
"lost artifacts",
"the ancients",
"useful things"
}

Used by artifact texts

Definition at line 184 of file readable.c.

const char* const art_book_name[]
static
Initial value:
= {
"collection",
"file",
"files",
"guide",
"handbook",
"index",
"inventory",
"list",
"listing",
"record",
"record book"
}

Artifact book information

Definition at line 169 of file readable.c.

arttypename art_name_array[]
static
Initial value:
= {
{"Helmet", HELMET},
{"Amulet", AMULET},
{"Shield", SHIELD},
{"Bracers", BRACERS},
{"Boots", BOOTS},
{"Cloak", CLOAK},
{"Gloves", GLOVES},
{"Girdle", GIRDLE},
{"Ring", RING},
{"Missile Weapon", BOW},
{"Missile", ARROW},
{"Hand Weapon", WEAPON},
{"Artifact", SKILL},
{"Food", FOOD},
{"Body Armour", ARMOUR},
{"Pants", PANTS}
}
#define GIRDLE
Definition: define.h:461
#define BOW
Definition: define.h:174
#define SHIELD
Definition: define.h:214
#define BRACERS
Definition: define.h:433
#define ARMOUR
Definition: define.h:182
#define ARROW
Definition: define.h:170
#define RING
Definition: define.h:320
#define SKILL
Definition: define.h:246
#define WEAPON
Definition: define.h:178
#define FOOD
Definition: define.h:142
#define HELMET
Definition: define.h:218
#define BOOTS
Definition: define.h:413
#define GLOVES
Definition: define.h:417
#define PANTS
Definition: define.h:222
#define AMULET
Definition: define.h:234
#define CLOAK
Definition: define.h:381

Artifact/item information

If it isn't listed here, then art_attr_msg will never generate a message for this type of artifact.

Definition at line 149 of file readable.c.

const char* const book_author[]
static

Used by 'generic' books

Definition at line 257 of file readable.c.

const char* const book_name[]
static
Initial value:
= {
"calendar",
"datebook",
"diary",
"guidebook",
"handbook",
"ledger",
"notes",
"notebook",
"octavo",
"pamphlet",
"practicum",
"script",
"transcript",
"catalog",
"compendium",
"guide",
"manual",
"opus",
"tome",
"treatise",
"volume",
"work"
}

Generic book information.

Definition at line 231 of file readable.c.

const char* const mon_author[]
static
Initial value:
= {
"beasts",
"creatures",
"dezidens",
"dwellers",
"evil nature",
"life",
"monsters",
"nature",
"new life",
"residents",
"the spawn",
"the living",
"things"
}

Used by monster bestiary texts

Definition at line 212 of file readable.c.

const char* const mon_book_name[]
static
Initial value:
= {
"bestiary",
"catalog",
"compilation",
"collection",
"encyclopedia",
"guide",
"handbook",
"list",
"manual",
"notes",
"record",
"register",
"volume"
}

Monster book information

Definition at line 195 of file readable.c.

object** monsters = NULL
static

Array of all the monsters.

Definition at line 55 of file readable.c.

char** msgs = NULL
static

Array of the messages as read from the messages file.

Definition at line 64 of file readable.c.

size_t num_monsters = 0
static

Number of the monsters.

Definition at line 59 of file readable.c.

size_t num_msgs = 0
static

Number of msgs.

Definition at line 68 of file readable.c.

const char* const path_author[]
static
Initial value:
= {
"aether",
"astral byways",
"connections",
"the Grey Council",
"deep pathways",
"knowledge",
"magic",
"mystic ways",
"pathways",
"power",
"spells",
"transforms",
"the mystic veil",
"unknown spells",
"cults",
"joy",
"lasting curse",
"madness",
"religions",
"the dead",
"the gods",
"the heirophant",
"the poor priest",
"the priestess",
"pain",
"white"
}

Used by spellpath texts

Definition at line 114 of file readable.c.

const char* const path_book_name[]
static
Initial value:
= {
"codex",
"compendium",
"exposition",
"tables",
"treatise",
"devotional",
"devout notes",
"divine text",
"divine work",
"holy book",
"holy record",
"moral text",
"sacred guide",
"testament",
"transcript"
}

Path book information

Definition at line 95 of file readable.c.

uint32_t spellpathdef[NRSPELLPATHS]
static
Initial value:
= {
}
#define PATH_TURNING
Definition: spells.h:70
#define PATH_CREATE
Definition: spells.h:60
#define PATH_SELF
Definition: spells.h:48
#define PATH_SUMMON
Definition: spells.h:50
#define PATH_TRANSMUTE
Definition: spells.h:66
#define PATH_RESTORE
Definition: spells.h:54
#define PATH_FIRE
Definition: spells.h:40
#define PATH_WOUNDING
Definition: spells.h:72
#define PATH_MISSILE
Definition: spells.h:46
#define PATH_INFO
Definition: spells.h:64
#define PATH_PROT
Definition: spells.h:38
#define PATH_DETONATE
Definition: spells.h:56
#define PATH_LIGHT
Definition: spells.h:76
#define PATH_FROST
Definition: spells.h:42
#define PATH_DEATH
Definition: spells.h:74
#define PATH_TELE
Definition: spells.h:62
#define PATH_ELEC
Definition: spells.h:44
#define PATH_ABJURE
Definition: spells.h:52
#define PATH_MIND
Definition: spells.h:58
#define PATH_TRANSFER
Definition: spells.h:68

Spellpath information

Definition at line 71 of file readable.c.