Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

src/util.c File Reference


Detailed Description

Miscellaneous useful functions.

Definition in file util.c.

#include "crogue.h"

Go to the source code of this file.

Data Structures

struct  jumptabentry
struct  jumptable

Typedefs

typedef jumptabentry jumptabentry
typedef jumptable jumptable

Functions

void catprintf (char *target, const char *format,...)
 Appends to a string.

const char * retprintf (const char *format,...)
 Print into a string, and return its address.

const char * vretprintf (const char *format, va_list args)
 Print into a string, and return its address, with a va_list.

coord trace_path (int x, int y, direction dir, int distance)
 Look for a hit in a direction.

const char * pluralize (int num, const char *str)
 Return a pluralized version of a string.

const char * indefinite_article (const char *noun)
 Return the indefinite article for a string.

monstdescfind_monster_description (int m)
 Returns the description of monster given its index.

void init_shuffle_tab (void)
 Initialize the shuffle table.

filelink deref_jump_table (jumptable *table)
const void * deref_file_ptr (filelink p)
 Dereference a file pointer.

filelink deref_file_ptr_partial (filelink p)
 Dereference through jump tables/shuffle tables.


Variables

const filelink filelink_null = { 0, 0, 0 }


Typedef Documentation

typedef struct jumptabentry jumptabentry
 

typedef struct jumptable jumptable
 


Function Documentation

void catprintf char *  target,
const char *  format,
... 
 

Appends to a string.

This function is the same as 'sprintf', except that instead of replacing the target string, it appends (catenates).

Definition at line 30 of file util.c.

Referenced by append_armor_description(), display_scores(), draw(), itemname(), and print_skills().

const void* deref_file_ptr filelink  p  ) 
 

Dereference a file pointer.

Todo:
Write a decent description of how file pointers work
See also:
init_shuffle_tab

deref_file_ptr_partial

deref_jump_table

Definition at line 257 of file util.c.

References world::constfileoffset, deref_file_ptr_partial(), isNull, filelink::offset, filelink::type, and w.

Referenced by addmonster(), auto_follow_connection(), base_coat(), char_info(), draw(), extract_item_property(), find_monster_description(), follow_connection(), gen_map(), init_inventory(), init_shuffle_tab(), iterate_item_property(), learn_spell(), link_data_file(), list_discoveries(), main_menu(), monstname(), place_player_on_map(), playerclassname(), plr_moveto(), randitem(), refresh_spell(), restore_game(), shortitemname(), spellbookString(), and spellString().

filelink deref_file_ptr_partial filelink  p  ) 
 

Dereference through jump tables/shuffle tables.

Definition at line 275 of file util.c.

References world::constfileoffset, deref_jump_table(), filelink::offset, PTR_JUMPTABLE, PTR_SHUFFLETAB, world::shuffledata, world::shuffletranslation, filelink::type, and w.

Referenced by addmonster(), call_attackfunc(), call_genericfunc(), call_stepfunc(), call_throwhitfunc(), call_usefunc(), and deref_file_ptr().

filelink deref_jump_table jumptable table  )  [static]
 

Definition at line 293 of file util.c.

References player::class, jumptabentry::condition, jumptable::condition, jumptable::entries, jumptabentry::freq, jt_avglevel, jt_class, jt_dungeonlevel, jt_playerlevel, jt_unconditional, player::level, lrand(), MAPDESC_CURRENT, range::min, jumptable::numEntries, world::plr, jumptabentry::target, uint, and w.

Referenced by deref_file_ptr_partial().

monstdesc* find_monster_description int  m  ) 
 

Returns the description of monster given its index.

Definition at line 190 of file util.c.

References deref_file_ptr(), world::m, monster::type, and w.

const char* indefinite_article const char *  noun  ) 
 

Return the indefinite article for a string.

Words beginning with a vowel get "an"; other words "a". Some special cases will probably be needed in the future, but there are none yet. (In particular, some words start with U but are pronounced with a Y sound; these do not get "an".)

Definition at line 166 of file util.c.

void init_shuffle_tab void   ) 
 

Initialize the shuffle table.

See also:
deref_file_ptr

Definition at line 199 of file util.c.

References debug_malloc, deref_file_ptr(), world::desc, world_descriptor::numshuffletabs, RANGE, world_descriptor::shuffletabsize, world::shuffletranslation, world_descriptor::stsizes, uint, and w.

Referenced by initialize().

const char* pluralize int  num,
const char *  str
 

Return a pluralized version of a string.

Returns an appropriate string for a number of a noun. If num is 1, the return is in the singular; otherwise, it is plural. (The rules vary by language.) It is an error to pass something which would pluralize to longer than 63 characters.

Definition at line 98 of file util.c.

Referenced by itemname().

const char* retprintf const char *  format,
... 
 

Print into a string, and return its address.

Note:
Return is invalidated by the next call. If you want to still use it after calling retprintf again, you must save a copy.
See also:
vretprintf

Definition at line 47 of file util.c.

References vretprintf().

Referenced by attack_tile(), cleanup_save(), do_drop_item(), fix_rust(), levelfile_name(), pickup(), plr_walk(), restore_game(), save_game(), and sys_init_data_file().

coord trace_path int  x,
int  y,
direction  dir,
int  distance
 

Look for a hit in a direction.

Starting at (x,y), walks in direction (dir) until either:

  • It's gone the maximum distance
  • It's inside a wall
  • It's hit a monster

Definition at line 75 of file util.c.

References COORD, dir, tile::flags, tiledesc::passable, world::t, TFLAG_OCCUPIED, world::tiledescs, tile::type, and w.

Referenced by throw_item().

const char* vretprintf const char *  format,
va_list  args
 

Print into a string, and return its address, with a va_list.

See also:
retprintf

Definition at line 60 of file util.c.

Referenced by panic(), and retprintf().


Variable Documentation

const filelink filelink_null = { 0, 0, 0 }
 

Definition at line 247 of file util.c.

Referenced by base_coat(), and monst_remove().


Generated on Thu May 20 13:12:13 2004 for CalcRogue by doxygen 1.3.6