mux/src/db.h File Reference

#include "attrcache.h"
#include "flags.h"
#include "timeutil.h"

Include dependency graph for db.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  attr
struct  stack
struct  boolexp
struct  object

Defines

#define SYNC   cache_sync()
#define CLOSE   cache_close()
#define ITER_PARENTS(t, p, l)
#define anum_get(x)   (anum_table[(x)])
#define anum_set(x, v)   anum_table[(x)] = v
#define ATR_INFO_CHAR   '\1'
#define BOOLEXP_AND   0
#define BOOLEXP_OR   1
#define BOOLEXP_NOT   2
#define BOOLEXP_CONST   3
#define BOOLEXP_ATR   4
#define BOOLEXP_INDIR   5
#define BOOLEXP_CARRY   6
#define BOOLEXP_IS   7
#define BOOLEXP_OWNER   8
#define BOOLEXP_EVAL   9
#define TRUE_BOOLEXP   ((BOOLEXP *) 0)
#define F_UNKNOWN   0
#define F_MUX   5
#define V_MASK   0x000000ff
#define V_ZONE   0x00000100
#define V_LINK   0x00000200
#define V_DATABASE   0x00000400
#define V_ATRNAME   0x00000800
#define V_ATRKEY   0x00001000
#define V_PARENT   0x00002000
#define V_ATRMONEY   0x00008000
#define V_XFLAGS   0x00010000
#define V_POWERS   0x00020000
#define V_3FLAGS   0x00040000
#define V_QUOTED   0x00080000
#define DB_CHANNELS   0x2
#define DB_SLOCK   0x4
#define DB_MC   0x8
#define DB_MPAR   0x10
#define DB_CLASS   0x20
#define DB_RANK   0x40
#define DB_DROPLOCK   0x80
#define DB_GIVELOCK   0x100
#define DB_GETLOCK   0x200
#define DB_THREEPOW   0x400
#define NOTHING   (-1)
#define AMBIGUOUS   (-2)
#define HOME   (-3)
#define NOPERM   (-4)
#define Location(t)   db[t].location
#define Zone(t)   db[t].zone
#define Contents(t)   db[t].contents
#define Exits(t)   db[t].exits
#define Next(t)   db[t].next
#define Link(t)   db[t].link
#define Owner(t)   db[t].owner
#define Parent(t)   db[t].parent
#define Flags(t)   db[t].fs.word[FLAG_WORD1]
#define Flags2(t)   db[t].fs.word[FLAG_WORD2]
#define Flags3(t)   db[t].fs.word[FLAG_WORD3]
#define Powers(t)   db[t].powers
#define Powers2(t)   db[t].powers2
#define Stack(t)   db[t].stackhead
#define Home(t)   Link(t)
#define Dropto(t)   Location(t)
#define ThAttrib(t)   db[t].throttled_attributes
#define ThMail(t)   db[t].throttled_mail
#define s_Location(t, n)   db[t].location = (n)
#define s_Zone(t, n)   db[t].zone = (n)
#define s_Contents(t, n)   db[t].contents = (n)
#define s_Exits(t, n)   db[t].exits = (n)
#define s_Next(t, n)   db[t].next = (n)
#define s_Link(t, n)   db[t].link = (n)
#define s_Owner(t, n)   db[t].owner = (n)
#define s_Parent(t, n)   db[t].parent = (n)
#define s_Flags(t, f, n)   db[t].fs.word[f] = (n)
#define s_Powers(t, n)   db[t].powers = (n)
#define s_Powers2(t, n)   db[t].powers2 = (n)
#define s_Stack(t, n)   db[t].stackhead = (n)
#define s_Home(t, n)   s_Link(t,n)
#define s_Dropto(t, n)   s_Location(t,n)
#define s_ThAttrib(t, n)   db[t].throttled_attributes = (n);
#define s_ThMail(t, n)   db[t].throttled_mail = (n);
#define DOLIST(thing, list)
#define SAFE_DOLIST(thing, next, list)
#define DO_WHOLE_DB(thing)   for ((thing)=0; (thing)<mudstate.db_top; (thing)++)
#define DO_WHOLE_DB_BACKWARDS(thing)   for ((thing)=mudstate.db_top-1; (thing)>=0; (thing)--)

Typedefs

typedef attr ATTR
typedef stack STACK
typedef boolexp BOOLEXP
typedef object OBJ

Functions

int get_atr (char *name)
char * MakeCanonicalAttributeName (const char *pName, int *pnName, bool *pbValid)
char * MakeCanonicalAttributeCommand (const char *pName, int *pnName, bool *pbValid)
ATTRatr_num (int anum)
ATTRatr_str (char *s)
void anum_extend (int)
int Pennies (dbref obj)
 Returns how many coins are in a player's or things's purse.
void s_Pennies (dbref obj, int howfew)
 Sets the number of coins in a player's or thing's purse.
void s_PenniesDirect (dbref obj, int howfew)
 A shortcut method of initializing the coins in a object's purse.
void load_restart_db (void)
dbref getref (FILE *)
void putref (FILE *, dbref)
void free_boolexp (BOOLEXP *)
dbref parse_dbref (const char *)
bool ThrottleMail (dbref executor)
bool ThrottleAttributeNames (dbref executor)
bool ThrottlePlayerCreate (void)
int mkattr (dbref executor, char *)
void al_store (void)
void db_grow (dbref)
void db_free (void)
void db_make_minimal (void)
dbref db_read (FILE *, int *, int *, int *)
dbref db_write (FILE *, int, int)
void destroy_thing (dbref)
void destroy_exit (dbref)
void putstring (FILE *f, const char *s)
char * getstring_noalloc (FILE *f, int new_strings)
void init_attrtab (void)

Variables

ATTR attr []
ATTR ** anum_table
char * aszSpecialDBRefNames [1-NOPERM]
const int INITIAL_ATRLIST_SIZE = 10
const int ATRLIST_CHUNK = 20
OBJdb


Define Documentation

#define AMBIGUOUS   (-2)

Definition at line 123 of file db.h.

Referenced by do_chown(), do_clone(), do_drop(), do_give(), do_kill(), do_lock(), do_mail_stats(), do_move(), do_pemit_single(), do_teleport_single(), do_unlink(), give_thing(), match_result(), match_status(), parse_boolexp_L(), promote_dflt(), and safe_match_result().

#define anum_get (  )     (anum_table[(x)])

Definition at line 62 of file db.h.

Referenced by atr_num(), db_write(), dbclean_CheckALISTtoAT(), dbclean_CheckANHtoAT(), dbclean_CheckATtoANH(), dbclean_RemoveStaleAttributeNames(), dbclean_RenumberAttributes(), and do_notify().

#define anum_set ( x,
 )     anum_table[(x)] = v

Definition at line 63 of file db.h.

Referenced by dbclean_RemoveStaleAttributeNames(), dbclean_RenumberAttributes(), init_attrtab(), vattr_define_LEN(), and vattr_delete_LEN().

#define ATR_INFO_CHAR   '\1'

Definition at line 66 of file db.h.

Referenced by atr_decode_flags_owner(), and atr_encode().

#define BOOLEXP_AND   0

Definition at line 69 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_T(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_ATR   4

Definition at line 73 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), test_atr(), and unparse_boolexp1().

#define BOOLEXP_CARRY   6

Definition at line 75 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_CONST   3

Definition at line 72 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), parse_boolexp_L(), putbool_subexp(), unparse_boolexp(), unparse_boolexp1(), unparse_boolexp_decompile(), unparse_boolexp_function(), and unparse_boolexp_quiet().

#define BOOLEXP_EVAL   9

Definition at line 78 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), putbool_subexp(), test_atr(), and unparse_boolexp1().

#define BOOLEXP_INDIR   5

Definition at line 74 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_IS   7

Definition at line 76 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_NOT   2

Definition at line 71 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_OR   1

Definition at line 70 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_E(), putbool_subexp(), and unparse_boolexp1().

#define BOOLEXP_OWNER   8

Definition at line 77 of file db.h.

Referenced by dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp_F(), putbool_subexp(), and unparse_boolexp1().

#define CLOSE   cache_close()

Definition at line 11 of file db.h.

Referenced by dbconvert(), do_restart(), do_shutdown(), main(), and sighandler().

#define Contents (  )     db[t].contents

Definition at line 185 of file db.h.

Referenced by announce_connect(), announce_disconnect(), check_dead_refs(), check_loc_contents(), check_misplaced_obj(), db_write_object(), debug_examine(), divest_object(), do_examine(), do_inventory(), do_sweep(), empty_obj(), eval_boolexp(), FUNCTION(), look_contents(), match_neighbor(), match_possession(), move_object(), notify_check(), notify_except(), notify_except2(), process_command(), and process_sticky_dropto().

#define DB_CHANNELS   0x2

Definition at line 110 of file db.h.

#define DB_CLASS   0x20

Definition at line 114 of file db.h.

#define DB_DROPLOCK   0x80

Definition at line 116 of file db.h.

#define DB_GETLOCK   0x200

Definition at line 118 of file db.h.

#define DB_GIVELOCK   0x100

Definition at line 117 of file db.h.

#define DB_MC   0x8

Definition at line 112 of file db.h.

#define DB_MPAR   0x10

Definition at line 113 of file db.h.

#define DB_RANK   0x40

Definition at line 115 of file db.h.

#define DB_SLOCK   0x4

Definition at line 111 of file db.h.

#define DB_THREEPOW   0x400

Definition at line 119 of file db.h.

#define DO_WHOLE_DB ( thing   )     for ((thing)=0; (thing)<mudstate.db_top; (thing)++)

Definition at line 257 of file db.h.

Referenced by check_contents_chains(), check_dead_refs(), check_events(), check_exit_chains(), check_floating(), check_mail_expiration(), chown_all(), count_quota(), dbclean_CheckALISTtoAT(), dbclean_CheckALISTtoDB(), dbclean_RemoveStaleAttributeNames(), dbclean_RenumberAttributes(), do_apply_marked(), do_mail_debug(), do_mail_nuke(), do_mail_stats(), do_poor(), do_quota(), do_report(), dump_mail(), FUNCTION(), get_stats(), load_player_names(), process_preload(), purge_going(), report_timecheck(), scan_zone(), and CGuests::StartUp().

#define DO_WHOLE_DB_BACKWARDS ( thing   )     for ((thing)=mudstate.db_top-1; (thing)>=0; (thing)--)

Definition at line 259 of file db.h.

Referenced by make_freelist().

#define DOLIST ( thing,
list   ) 

Value:

for ((thing)=(list); \
         ((thing)!=NOTHING) && (Next(thing)!=(thing)); \
         (thing)=Next(thing))

Definition at line 249 of file db.h.

Referenced by announce_connect(), announce_disconnect(), do_examine(), do_inventory(), eval_boolexp(), FUNCTION(), look_contents(), look_exits(), match_exit_internal(), match_list(), member(), notify_check(), notify_except(), notify_except2(), process_command(), process_sticky_dropto(), remove_first(), and room_list().

#define Dropto (  )     Location(t)

Definition at line 198 of file db.h.

Referenced by check_dead_refs(), do_clone(), do_entrances(), do_examine(), do_link(), FUNCTION(), process_dropped_dropto(), process_sticky_dropto(), and send_dropto().

#define Exits (  )     db[t].exits

Definition at line 186 of file db.h.

Referenced by check_dead_refs(), check_loc_exits(), db_write_object(), debug_examine(), destroy_exit(), do_clone(), do_drop(), do_entrances(), do_examine(), do_get(), do_inventory(), do_search(), do_sweep(), do_teleport_single(), empty_obj(), FUNCTION(), look_exits(), mark_place(), match_exit_internal(), move_the_exit(), notify_check(), open_exit(), room_list(), and where_is().

#define F_MUX   5

Definition at line 94 of file db.h.

Referenced by db_read(), db_write(), dbconvert(), dump_database_internal(), getboolexp(), and info().

#define F_UNKNOWN   0

Definition at line 93 of file db.h.

Referenced by db_read().

#define Flags (  )     db[t].fs.word[FLAG_WORD1]

Definition at line 191 of file db.h.

Referenced by check_idle(), chown_all(), db_make_minimal(), db_write_object(), do_chzone(), do_clone(), do_command(), handle_flaglists(), process_preload(), raw_broadcast(), Task_RunQueueEntry(), and unparse_object().

#define Flags2 (  )     db[t].fs.word[FLAG_WORD2]

Definition at line 192 of file db.h.

Referenced by announce_connect(), check_events(), db_write_object(), do_edit_msg(), do_expmail_abort(), do_expmail_start(), do_expmail_stop(), do_mail_cc(), do_mail_fwd(), do_mail_proof(), do_mail_quick(), do_mail_reply(), do_postpend(), do_prepend(), handle_flaglists(), and unparse_object().

#define Flags3 (  )     db[t].fs.word[FLAG_WORD3]

Definition at line 193 of file db.h.

Referenced by db_write_object(), do_icmd(), and handle_flaglists().

#define Home (  )     Link(t)

Definition at line 197 of file db.h.

Referenced by check_contents_chains(), check_dead_refs(), clone_home(), divest_object(), do_entrances(), do_examine(), do_link(), do_teleport_single(), empty_obj(), FUNCTION(), move_exit(), move_object(), move_via_exit(), move_via_generic(), move_via_teleport(), new_home(), and process_leave_loc().

#define HOME   (-3)

Definition at line 124 of file db.h.

Referenced by check_contents_chains(), check_dead_refs(), check_loc_exits(), could_doit(), divest_object(), do_kill(), do_link(), do_move(), do_open(), do_teleport_single(), empty_obj(), link_exit(), match_home(), move_exit(), move_object(), move_via_exit(), move_via_generic(), move_via_teleport(), open_exit(), parse_linkable_room(), process_dropped_dropto(), process_leave_loc(), send_dropto(), and unparse_object_quiet().

#define ITER_PARENTS ( t,
p,
 ) 

Value:

for ((l)=0, (p)=(t); \
                     (Good_obj(p) && \
                      ((l) < mudconf.parent_nest_lim)); \
                     (p)=Parent(p), (l)++)

Definition at line 21 of file db.h.

Referenced by atr_match(), atr_pget_info(), atr_pget_str_LEN(), check_events(), do_parent(), do_prog(), FUNCTION(), look_atrs(), look_exits(), match_carried_exit_with_parents(), match_exit_with_parents(), parse_attrib_wild(), process_preload(), room_list(), and sweep_check().

#define Link (  )     db[t].link

Definition at line 188 of file db.h.

Referenced by check_dead_refs(), create_obj(), db_write_object(), and debug_examine().

#define Location (  )     db[t].location

Definition at line 181 of file db.h.

Referenced by announce_connect(), announce_disconnect(), check_contents_chains(), check_dead_refs(), check_loc_contents(), check_loc_exits(), check_misplaced_obj(), db_write_object(), debug_examine(), destroy_obj(), did_it(), do_chown(), do_clone(), do_destroy(), do_dig(), do_drop(), do_enter_internal(), do_entrances(), do_examine(), do_get(), do_icmd(), do_kill(), do_leave(), do_look(), do_move(), do_open(), do_pcreate(), do_pemit_single(), do_say(), do_search(), do_sweep(), do_teleport_single(), do_toad(), do_train(), dump_users(), empty_obj(), FUNCTION(), link_exit(), log_name_and_loc(), look_contents(), look_exits(), look_in(), mark_place(), match_exit(), match_exit_with_parents(), match_here(), match_neighbor(), move_exit(), move_object(), move_via_exit(), move_via_generic(), move_via_teleport(), new_home(), notify_check(), process_command(), process_dropped_dropto(), process_enter_loc(), process_leave_loc(), promote_match(), purge_going(), room_list(), send_dropto(), shutdownsock(), sp_ok(), where_is(), where_room(), and zonecmdtest().

#define Next (  )     db[t].next

Definition at line 187 of file db.h.

Referenced by check_dead_refs(), check_loc_contents(), check_loc_exits(), db_write_object(), debug_examine(), do_sweep(), FUNCTION(), list_check(), mark_place(), remove_first(), and reverse_list().

#define NOPERM   (-4)

Definition at line 125 of file db.h.

Referenced by do_destroy(), match_possessed(), match_status(), promote_dflt(), and unparse_object().

#define NOTHING   (-1)

Definition at line 122 of file db.h.

Referenced by absolute_name(), add_mail_message(), al_store(), announce_connect(), announce_disconnect(), atr_decode_flags_owner(), atr_encode(), atr_match1(), bind_and_queue(), CallBack_HaltQueue(), cf_init(), check_connect(), check_contents_chains(), check_dead_refs(), check_exit_chains(), check_floating(), check_loc_contents(), check_loc_exits(), check_misplaced_obj(), check_pennies(), chown_all(), connect_player(), CGuests::Create(), create_new_comsys(), create_obj(), create_player(), db_free(), db_make_minimal(), db_read(), dbconvert(), default_home(), delete_player_name(), destroy_bad_obj(), destroy_obj(), destroy_player(), destroy_thing(), did_it(), dispatch_FreeListReconstruction(), divest_object(), do_alias(), do_boot(), do_chanlist(), do_chopen(), do_chown(), do_chownall(), do_chzone(), do_clone(), do_command(), do_create(), do_createchannel(), do_cut(), do_dbck(), do_decomp(), do_delcommand(), do_destroy(), do_dig(), do_dolist(), do_drop(), do_edit(), do_editchannel(), do_enter(), do_enter_internal(), do_examine(), do_fixdb(), do_force(), do_forwardlist(), do_give(), do_halt(), do_icmd(), do_if(), do_inventory(), do_kill(), do_last(), do_leave(), do_link(), do_listchannels(), do_lock(), do_look(), do_mail_debug(), do_mail_retract1(), do_mail_review(), do_mail_stats(), do_malias_add(), do_malias_chown(), do_malias_create(), do_malias_remove(), do_malias_send(), do_move(), do_mvattr(), do_name(), do_newpassword(), do_page(), do_parent(), do_pcreate(), do_pemit_single(), do_power(), do_ps(), do_search(), do_stats(), do_sweep(), do_switch(), do_teleport_single(), do_toad(), do_unlink(), do_unlock(), do_use(), do_verb(), do_wait(), do_wipe(), empty_obj(), exam_wildattrs(), failconn(), fcache_init(), fcache_load(), find_connected_name(), FUNCTION(), get_exit_dest(), get_stats(), give_thing(), grep_util(), halt_que(), handle_prog(), helpindex_init(), helpindex_load(), init_match(), initialize_objects(), lattr_handler(), link_exit(), list_check(), load_comsystem(), locatable(), Log_header_err(), Log_pointer_err(), Log_simple_err(), lookup_player(), mail_fetch_from(), mail_to_list(), main(), make_freelist(), make_numlist(), CGuests::MakeGuestChar(), mark_place(), match_controlled_handler(), match_player(), match_possessed(), match_result(), match_status(), move_exit(), move_object(), move_via_teleport(), olist_first(), olist_next(), open_exit(), parse_attrib(), parse_boolexp_L(), parse_dbref(), parse_linkable_room(), parse_msglist(), parse_thing_slash(), process_cmdent(), process_command(), process_dropped_dropto(), process_enter_loc(), process_leave_loc(), process_sticky_dropto(), promote_dflt(), purge_going(), que_want(), MailList::RemoveItem(), reverse_list(), search_mark(), search_perform(), search_setup(), send_mail(), SendChannelMessage(), setup_que(), start_home(), CGuests::StartUp(), Task_RunQueueEntry(), Task_SemaphoreTimeout(), unparse_object_quiet(), ValidateConfigurationDbrefs(), view_atr(), wait_que(), where_is(), and where_room().

#define Owner (  )     db[t].owner

Definition at line 189 of file db.h.

Referenced by atr_chown(), atr_cpy(), atr_decode_LEN(), atr_encode(), atr_get_info(), atr_get_str_LEN(), atr_pget_info(), atr_pget_str_LEN(), bCanLockAttr(), bCanReadAttr(), CallBack_HaltQueue(), CallBack_NotifySemaphoreDrainOrAll(), canpayfees(), check_dead_refs(), check_events(), check_floating(), check_loc_contents(), check_loc_exits(), chown_all(), clone_home(), count_quota(), create_obj(), db_write_object(), debug_examine(), destroy_obj(), destroy_thing(), do_alias(), do_chown(), do_clone(), do_comwho(), do_destroy(), do_edit(), do_examine(), do_forwardlist(), do_halt(), do_kill(), do_last(), do_move(), do_mvattr(), do_prog(), do_ps(), do_quitprog(), do_quota(), do_restart(), do_search(), do_shutdown(), do_stats(), do_teleport(), do_unlink(), eval_boolexp(), exam_wildattrs(), fh_privileged(), FUNCTION(), get_stats(), giveto(), link_exit(), load_comsystem(), log_name(), new_home(), notify_check(), pay_quota(), payfor(), process_command(), process_preload(), process_sticky_dropto(), purge_comsystem(), que_want(), search_perform(), search_setup(), send_mail(), set_attr_internal(), setup_que(), sweep_check(), Task_RunQueueEntry(), tcache_finish(), and view_atr().

#define Parent (  )     db[t].parent

Definition at line 190 of file db.h.

Referenced by atr_match(), atr_pget_info(), atr_pget_str_LEN(), check_dead_refs(), CGuests::Create(), db_write_object(), do_clone(), do_entrances(), do_examine(), FUNCTION(), look_atrs(), CGuests::MakeGuestChar(), parse_attrib_wild(), and search_perform().

#define Powers (  )     db[t].powers

Definition at line 194 of file db.h.

Referenced by db_write_object(), decompile_powers(), do_chzone(), has_power(), ph_any(), powers_list(), and search_perform().

#define Powers2 (  )     db[t].powers2

Definition at line 195 of file db.h.

Referenced by db_write_object(), decompile_powers(), has_power(), ph_any(), powers_list(), and search_perform().

#define s_Contents ( t,
 )     db[t].contents = (n)

Definition at line 206 of file db.h.

Referenced by check_dead_refs(), check_loc_contents(), check_misplaced_obj(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_fixdb(), initialize_objects(), move_object(), and process_sticky_dropto().

#define s_Dropto ( t,
 )     s_Location(t,n)

Definition at line 217 of file db.h.

Referenced by check_dead_refs(), do_clone(), do_link(), and do_unlink().

#define s_Exits ( t,
 )     db[t].exits = (n)

Definition at line 207 of file db.h.

Referenced by check_loc_exits(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_exit(), destroy_obj(), do_clone(), do_drop(), do_fixdb(), do_get(), FUNCTION(), initialize_objects(), move_the_exit(), and open_exit().

#define s_Flags ( t,
f,
 )     db[t].fs.word[f] = (n)

Definition at line 212 of file db.h.

Referenced by announce_connect(), chown_all(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_clone(), do_command(), do_icmd(), do_toad(), initialize_objects(), and Task_RunQueueEntry().

#define s_Home ( t,
 )     s_Link(t,n)

Definition at line 216 of file db.h.

Referenced by check_contents_chains(), check_dead_refs(), create_player(), divest_object(), do_clone(), do_create(), do_link(), empty_obj(), and FUNCTION().

#define s_Link ( t,
 )     db[t].link = (n)

Definition at line 209 of file db.h.

Referenced by check_dead_refs(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), initialize_objects(), and make_freelist().

#define s_Location ( t,
 )     db[t].location = (n)

Definition at line 202 of file db.h.

Referenced by check_contents_chains(), check_loc_exits(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_clone(), do_fixdb(), do_unlink(), empty_obj(), initialize_objects(), link_exit(), move_object(), and open_exit().

#define s_Next ( t,
 )     db[t].next = (n)

Definition at line 208 of file db.h.

Referenced by check_contents_chains(), check_dead_refs(), check_loc_contents(), check_loc_exits(), check_misplaced_obj(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_cut(), do_fixdb(), empty_obj(), FUNCTION(), initialize_objects(), insert_first(), move_object(), open_exit(), remove_first(), and reverse_list().

#define s_Owner ( t,
 )     db[t].owner = (n)

Definition at line 210 of file db.h.

Referenced by check_dead_refs(), chown_all(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_chown(), do_fixdb(), do_toad(), initialize_objects(), and link_exit().

#define s_Parent ( t,
 )     db[t].parent = (n)

Definition at line 211 of file db.h.

Referenced by check_dead_refs(), CGuests::Create(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_clone(), do_parent(), initialize_objects(), and CGuests::MakeGuestChar().

#define s_Powers ( t,
 )     db[t].powers = (n)

Definition at line 213 of file db.h.

Referenced by db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_chown(), initialize_objects(), and ph_any().

#define s_Powers2 ( t,
 )     db[t].powers2 = (n)

Definition at line 214 of file db.h.

Referenced by db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_chown(), initialize_objects(), and ph_any().

#define s_Stack ( t,
 )     db[t].stackhead = (n)

Definition at line 215 of file db.h.

Referenced by FUNCTION(), initialize_objects(), and stack_clr().

#define s_ThAttrib ( t,
 )     db[t].throttled_attributes = (n);

Definition at line 218 of file db.h.

Referenced by create_obj(), initialize_objects(), SetupThrottle(), and ThrottleAttributeNames().

#define s_ThMail ( t,
 )     db[t].throttled_mail = (n);

Definition at line 219 of file db.h.

Referenced by create_obj(), initialize_objects(), SetupThrottle(), and ThrottleMail().

#define s_Zone ( t,
 )     db[t].zone = (n)

Definition at line 204 of file db.h.

Referenced by check_dead_refs(), chown_all(), CGuests::Create(), create_obj(), db_make_minimal(), db_read(), destroy_bad_obj(), destroy_obj(), do_toad(), initialize_objects(), and CGuests::MakeGuestChar().

#define SAFE_DOLIST ( thing,
next,
list   ) 

Value:

for ((thing)=(list),(next)=((thing)==NOTHING ? NOTHING: Next(thing)); \
         (thing)!=NOTHING && (Next(thing)!=(thing)); \
         (thing)=(next), (next)=Next(next))

Definition at line 253 of file db.h.

Referenced by divest_object(), empty_obj(), and process_sticky_dropto().

#define Stack (  )     db[t].stackhead

Definition at line 196 of file db.h.

Referenced by FUNCTION(), stack_clr(), and stacksize().

#define SYNC   cache_sync()

Definition at line 10 of file db.h.

Referenced by do_restart(), do_shutdown(), dump_database(), fork_and_dump(), and sighandler().

#define ThAttrib (  )     db[t].throttled_attributes

Definition at line 199 of file db.h.

Referenced by ThrottleAttributeNames().

#define ThMail (  )     db[t].throttled_mail

Definition at line 200 of file db.h.

Referenced by ThrottleMail().

#define TRUE_BOOLEXP   ((BOOLEXP *) 0)

Definition at line 89 of file db.h.

Referenced by do_decomp(), do_lock(), dup_bool(), eval_boolexp(), free_boolexp(), getboolexp1(), parse_boolexp(), parse_boolexp_E(), parse_boolexp_F(), parse_boolexp_L(), parse_boolexp_T(), putboolexp(), test_atr(), and unparse_boolexp1().

#define V_3FLAGS   0x00040000

Definition at line 106 of file db.h.

#define V_ATRKEY   0x00001000

Definition at line 101 of file db.h.

Referenced by db_read(), db_write_object(), and info().

#define V_ATRMONEY   0x00008000

Definition at line 103 of file db.h.

Referenced by db_read(), db_write_object(), and info().

#define V_ATRNAME   0x00000800

Definition at line 100 of file db.h.

Referenced by db_read(), db_write_object(), and info().

#define V_DATABASE   0x00000400

Definition at line 99 of file db.h.

Referenced by db_read(), db_write_object(), info(), and load_game().

#define V_LINK   0x00000200

Definition at line 98 of file db.h.

#define V_MASK   0x000000ff

Definition at line 96 of file db.h.

Referenced by db_read().

#define V_PARENT   0x00002000

Definition at line 102 of file db.h.

#define V_POWERS   0x00020000

Definition at line 105 of file db.h.

#define V_QUOTED   0x00080000

Definition at line 107 of file db.h.

#define V_XFLAGS   0x00010000

Definition at line 104 of file db.h.

#define V_ZONE   0x00000100

Definition at line 97 of file db.h.

#define Zone (  )     db[t].zone

Definition at line 183 of file db.h.

Referenced by announce_connect(), announce_disconnect(), check_dead_refs(), check_zone_handler(), CGuests::Create(), create_obj(), db_write_object(), debug_examine(), do_examine(), do_icmd(), FUNCTION(), CGuests::MakeGuestChar(), match_zone_exit(), process_command(), scan_zone(), search_perform(), and zonecmdtest().


Typedef Documentation

typedef struct attr ATTR

Definition at line 28 of file db.h.

typedef struct boolexp BOOLEXP

Definition at line 80 of file db.h.

typedef struct object OBJ

Definition at line 128 of file db.h.

typedef struct stack STACK

Definition at line 49 of file db.h.


Function Documentation

void al_store ( void   ) 

Definition at line 1475 of file db.cpp.

References A_LIST, atr_add_raw_LEN(), atr_clr(), statedata::mod_al_id, statedata::mod_alist, statedata::mod_alist_len, mudstate, and NOTHING.

Referenced by al_fetch(), atr_free(), dbconvert(), do_dbclean(), do_restart(), do_shutdown(), dump_database(), fork_and_dump(), and sighandler().

01476 {
01477     if (mudstate.mod_al_id != NOTHING)
01478     {
01479         if (mudstate.mod_alist_len)
01480         {
01481             atr_add_raw_LEN(mudstate.mod_al_id, A_LIST, mudstate.mod_alist, mudstate.mod_alist_len);
01482         }
01483         else
01484         {
01485             atr_clr(mudstate.mod_al_id, A_LIST);
01486         }
01487     }
01488     mudstate.mod_al_id = NOTHING;
01489 }

void anum_extend ( int   ) 

Definition at line 1112 of file db.cpp.

References anum_table, statedata::bStandAlone, confdata::init_size, ISOUTOFMEMORY, MEMALLOC, MEMFREE, mudconf, and mudstate.

Referenced by init_attrtab(), vattr_alloc_LEN(), and vattr_define_LEN().

01113 {
01114     ATTR **anum_table2;
01115     int delta, i;
01116 
01117     if (mudstate.bStandAlone)
01118     {
01119         delta = 1000;
01120     }
01121     else
01122     {
01123         delta = mudconf.init_size;
01124     }
01125     if (newtop <= anum_alc_top)
01126     {
01127         return;
01128     }
01129     if (newtop < anum_alc_top + delta)
01130     {
01131         newtop = anum_alc_top + delta;
01132     }
01133     if (anum_table == NULL)
01134     {
01135         anum_table = (ATTR **) MEMALLOC((newtop + 1) * sizeof(ATTR *));
01136         ISOUTOFMEMORY(anum_table);
01137         for (i = 0; i <= newtop; i++)
01138         {
01139             anum_table[i] = NULL;
01140         }
01141     }
01142     else
01143     {
01144         anum_table2 = (ATTR **) MEMALLOC((newtop + 1) * sizeof(ATTR *));
01145         ISOUTOFMEMORY(anum_table2);
01146         for (i = 0; i <= anum_alc_top; i++)
01147         {
01148             anum_table2[i] = anum_table[i];
01149         }
01150         for (i = anum_alc_top + 1; i <= newtop; i++)
01151         {
01152             anum_table2[i] = NULL;
01153         }
01154         MEMFREE((char *)anum_table);
01155         anum_table = anum_table2;
01156     }
01157     anum_alc_top = newtop;
01158 }

ATTR* atr_num ( int  anum  ) 

Definition at line 1163 of file db.cpp.

References anum_get.

Referenced by atr_cpy(), atr_match1(), atr_pget_info(), atr_pget_str_LEN(), Commer(), db_write_object(), debug_examine(), do_alias(), do_decomp(), do_edit(), do_examine(), do_function(), do_listcommands(), do_mvattr(), do_set(), do_verb(), do_wait(), do_wipe(), eval_boolexp(), exam_wildattrs(), find_wild_attrs(), FUNCTION(), get_obj_and_lock(), grep_util(), Hearer(), lattr_handler(), look_atrs1(), mem_usage(), putbool_subexp(), set_attr_internal(), set_player_folder(), show_a_desc(), sweep_check(), unparse_boolexp1(), and CGuests::WipeAttrs().

01164 {
01165     if (anum > anum_alc_top)
01166     {
01167         return NULL;
01168     }
01169     return  anum_get(anum);
01170 }

ATTR* atr_str ( char *  s  ) 

Definition at line 1079 of file db.cpp.

References statedata::attr_name_htab, hashfindLEN(), MakeCanonicalAttributeName(), mudstate, and vattr_find_LEN().

Referenced by CF_HAND(), default_handler(), do_attribute(), do_chanlog(), do_comlast(), do_mvattr(), do_verb(), do_wait(), FUNCTION(), get_atr(), hasattr_handler(), higcheck(), hook_fail(), mkattr(), parse_and_get_attrib(), parse_attrib(), process_cmdent(), SendChannelMessage(), and test_atr().

01080 {
01081     // Make attribute name canonical.
01082     //
01083     int nBuffer;
01084     bool bValid;
01085     char *buff = MakeCanonicalAttributeName(s, &nBuffer, &bValid);
01086     if (!bValid)
01087     {
01088         return NULL;
01089     }
01090 
01091     // Look for a predefined attribute.
01092     //
01093     ATTR *a = (ATTR *)hashfindLEN(buff, nBuffer, &mudstate.attr_name_htab);
01094     if (a != NULL)
01095     {
01096         return a;
01097     }
01098 
01099     // Nope, look for a user attribute.
01100     //
01101     a = vattr_find_LEN(buff, nBuffer);
01102     return a;
01103 }

void db_free ( void   ) 

Definition at line 2659 of file db.cpp.

References db, statedata::db_size, statedata::db_top, statedata::freelist, MEMFREE, mudstate, NOTHING, and SIZE_HACK.

Referenced by db_make_minimal(), db_read(), dbconvert(), init_dbfile(), and main().

02660 {
02661     char *cp;
02662 
02663     if (db != NULL)
02664     {
02665         db -= SIZE_HACK;
02666         cp = (char *)db;
02667         MEMFREE(cp);
02668         cp = NULL;
02669         db = NULL;
02670     }
02671     mudstate.db_top = 0;
02672     mudstate.db_size = 0;
02673     mudstate.freelist = NOTHING;
02674 }

void db_grow ( dbref   ) 

Definition at line 2554 of file db.cpp.

References statedata::bfCommands, statedata::bfListens, statedata::bfNoCommands, statedata::bfNoListens, statedata::bStandAlone, db, statedata::db_size, statedata::db_top, confdata::init_size, initialize_objects(), ISOUTOFMEMORY, statedata::markbits, MEMALLOC, MEMFREE, statedata::min_size, mudconf, mudstate, CBitField::Resize(), and SIZE_HACK.

Referenced by create_obj(), db_make_minimal(), and db_read().

02555 {
02556     mudstate.bfCommands.Resize(newtop);
02557     mudstate.bfNoCommands.Resize(newtop);
02558     mudstate.bfListens.Resize(newtop);
02559     mudstate.bfNoListens.Resize(newtop);
02560 
02561     int delta;
02562     if (mudstate.bStandAlone)
02563     {
02564         delta = 1000;
02565     }
02566     else
02567     {
02568         delta = mudconf.init_size;
02569     }
02570 
02571     // Determine what to do based on requested size, current top and size.
02572     // Make sure we grow in reasonable-sized chunks to prevent frequent
02573     // reallocations of the db array.
02574     //
02575     // If requested size is smaller than the current db size, ignore it.
02576     //
02577     if (newtop <= mudstate.db_top)
02578     {
02579         return;
02580     }
02581 
02582     // If requested size is greater than the current db size but smaller
02583     // than the amount of space we have allocated, raise the db size and
02584     // initialize the new area.
02585     //
02586     if (newtop <= mudstate.db_size)
02587     {
02588         initialize_objects(mudstate.db_top, newtop);
02589         mudstate.db_top = newtop;
02590         return;
02591     }
02592 
02593     // Grow by a minimum of delta objects
02594     //
02595     int newsize;
02596     if (newtop <= mudstate.db_size + delta)
02597     {
02598         newsize = mudstate.db_size + delta;
02599     }
02600     else
02601     {
02602         newsize = newtop;
02603     }
02604 
02605     // Enforce minimum database size
02606     //
02607     if (newsize < mudstate.min_size)
02608     {
02609         newsize = mudstate.min_size + delta;
02610     }
02611 
02612     // Grow the db array
02613     //
02614 
02615     // NOTE: There is always one copy of 'db' around that isn't freed even
02616     // just before the process terminates. We rely (quite safely) on the OS
02617     // to reclaim the memory.
02618     //
02619     OBJ *newdb = (OBJ *)MEMALLOC((newsize + SIZE_HACK) * sizeof(OBJ));
02620     ISOUTOFMEMORY(newdb);
02621     if (db)
02622     {
02623         // An old struct database exists. Copy it to the new buffer.
02624         //
02625         db -= SIZE_HACK;
02626         memcpy(newdb, db, (mudstate.db_top + SIZE_HACK) * sizeof(OBJ));
02627         MEMFREE(db);
02628     }
02629     else
02630     {
02631         // Creating a brand new struct database. Fill in the 'reserved' area
02632         // in case it is referenced.
02633         //
02634         db = newdb;
02635         initialize_objects(0, SIZE_HACK);
02636     }
02637     db = newdb + SIZE_HACK;
02638     newdb = NULL;
02639 
02640     initialize_objects(mudstate.db_top, newtop);
02641     mudstate.db_top = newtop;
02642     mudstate.db_size = newsize;
02643 
02644     // Grow the db mark buffer.
02645     //
02646     int marksize = (newsize + 7) >> 3;
02647     MARKBUF *newmarkbuf = (MARKBUF *)MEMALLOC(marksize);
02648     ISOUTOFMEMORY(newmarkbuf);
02649     memset(newmarkbuf, 0, marksize);
02650     if (mudstate.markbits)
02651     {
02652         marksize = (newtop + 7) >> 3;
02653         memcpy(newmarkbuf, mudstate.markbits, marksize);
02654         MEMFREE(mudstate.markbits);
02655     }
02656     mudstate.markbits = newmarkbuf;
02657 }

void db_make_minimal ( void   ) 

Definition at line 2676 of file db.cpp.

References create_player(), db_free(), db_grow(), FLAG_WORD1, FLAG_WORD2, FLAG_WORD3, Flags, load_player_names(), NOTHING, s_Contents, s_Exits, s_Flags, s_Link, s_Location, s_Name(), s_Next, s_Owner, s_Parent, s_Pennies(), s_Powers, s_Powers2, s_Zone, TYPE_ROOM, and WIZARD.

Referenced by main().

02677 {
02678     db_free();
02679     db_grow(1);
02680     s_Name(0, "Limbo");
02681     s_Flags(0, FLAG_WORD1, TYPE_ROOM);
02682     s_Flags(0, FLAG_WORD2, 0);
02683     s_Flags(0, FLAG_WORD3, 0);
02684     s_Powers(0, 0);
02685     s_Powers2(0, 0);
02686     s_Location(0, NOTHING);
02687     s_Exits(0, NOTHING);
02688     s_Link(0, NOTHING);
02689     s_Parent(0, NOTHING);
02690     s_Zone(0, NOTHING);
02691     s_Pennies(0, 0);
02692     s_Owner(0, 1);
02693 
02694     // should be #1
02695     //
02696     load_player_names();
02697     const char *pmsg;
02698     dbref obj = create_player("Wizard", "potrzebie", NOTHING, false, &pmsg);
02699     s_Flags(obj, FLAG_WORD1, Flags(obj) | WIZARD);
02700     s_Powers(obj, 0);
02701     s_Powers2(obj, 0);
02702     s_Pennies(obj, 1000);
02703 
02704     // Manually link to Limbo, just in case
02705     //
02706     s_Location(obj, 0);
02707     s_Next(obj, NOTHING);
02708     s_Contents(0, obj);
02709     s_Link(obj, 0);
02710 }

dbref db_read ( FILE *  ,
int *  ,
int *  ,
int *   
)

Definition at line 501 of file db_rw.cpp.

References A_LOCK, alloc_lbuf, ANSI_ENDGOAL_NORMAL, ANSI_TruncateToField(), atr_add_raw(), statedata::attr_next, statedata::bStandAlone, c_Connected, db_free(), db_grow(), statedata::db_top, ENDLINE, F_MUX, F_UNKNOWN, FLAG_WORD1, FLAG_WORD2, FLAG_WORD3, CLogFile::Flush(), free_boolexp(), free_lbuf, g_flags, g_format, g_version, get_list(), getboolexp(), getref(), getstring_noalloc(), isPlayer, load_player_names(), Log, MakeCanonicalAttributeName(), MANDFLAGS, MAX_SUPPORTED_VERSION, MBUF_SIZE, statedata::min_size, MIN_SUPPORTED_VERSION, mudconf, mudstate, mux_assert, mux_isdigit, mux_isprint, NOTHING, statedata::record_players, confdata::reset_players, s_Contents, s_Exits, s_Flags, s_Link, s_Location, s_Name(), s_Next, s_Owner, s_Parent, s_PenniesDirect(), s_Powers, s_Powers2, s_Zone, CLogFile::tinyprintf(), unparse_boolexp_quiet(), V_ATRKEY, V_ATRMONEY, V_ATRNAME, V_DATABASE, V_MASK, vattr_define_LEN(), confdata::vattr_flags, and CLogFile::WriteString().

Referenced by dbconvert(), and load_game().

00502 {
00503     dbref i, anum;
00504     int ch;
00505     const char *tstr;
00506     int aflags;
00507     BOOLEXP *tempbool;
00508     char *buff;
00509     int nVisualWidth;
00510 
00511     g_format = F_UNKNOWN;
00512     g_version = 0;
00513     g_flags = 0;
00514 
00515     bool header_gotten = false;
00516     bool size_gotten = false;
00517     bool nextattr_gotten = false;
00518 
00519     bool read_attribs = true;
00520     bool read_name = true;
00521     bool read_key = true;
00522     bool read_money = true;
00523 
00524     int nName;
00525     bool bValid;
00526     char *pName;
00527 
00528     int iDotCounter = 0;
00529     if (mudstate.bStandAlone)
00530     {
00531         Log.WriteString("Reading ");
00532         Log.Flush();
00533     }
00534     db_free();
00535     for (i = 0;; i++)
00536     {
00537         if (mudstate.bStandAlone)
00538         {
00539             if (!iDotCounter)
00540             {
00541                 iDotCounter = 100;
00542                 fputc('.', stderr);
00543                 fflush(stderr);
00544             }
00545             iDotCounter--;
00546         }
00547 
00548         ch = getc(f);
00549         switch (ch)
00550         {
00551         case '-':   // Misc tag
00552             ch = getc(f);
00553             if (ch == 'R')
00554             {
00555                 // Record number of players
00556                 //
00557                 mudstate.record_players = getref(f);
00558                 if (mudconf.reset_players)
00559                 {
00560                     mudstate.record_players = 0;
00561                 }
00562             }
00563             break;
00564 
00565         case '+':
00566 
00567             // MUX header
00568             //
00569             ch = getc(f);
00570             if (ch == 'A')
00571             {
00572                 // USER-NAMED ATTRIBUTE
00573                 //
00574                 anum = getref(f);
00575                 tstr = getstring_noalloc(f, true);
00576                 if (mux_isdigit(*tstr))
00577                 {
00578                     aflags = 0;
00579                     while (mux_isdigit(*tstr))
00580                     {
00581                         aflags = (aflags * 10) + (*tstr++ - '0');
00582                     }
00583                     tstr++; // skip ':'
00584                 }
00585                 else
00586                 {
00587                     aflags = mudconf.vattr_flags;
00588                 }
00589                 pName = MakeCanonicalAttributeName(tstr, &nName, &bValid);
00590                 if (bValid)
00591                 {
00592                     vattr_define_LEN(pName, nName, anum, aflags);
00593                 }
00594             }
00595             else if (ch == 'X')
00596             {
00597                 // MUX VERSION
00598                 //
00599                 if (header_gotten)
00600                 {
00601                     Log.tinyprintf(ENDLINE "Duplicate MUX version header entry at object %d, ignored." ENDLINE, i);
00602                     tstr = getstring_noalloc(f, 0);
00603                 }
00604                 else
00605                 {
00606                     header_gotten = true;
00607                     g_format = F_MUX;
00608                     g_version = getref(f);
00609                     mux_assert((g_version & MANDFLAGS) == MANDFLAGS);
00610 
00611                     // Otherwise extract feature flags
00612                     //
00613                     if (g_version & V_DATABASE)
00614                     {
00615                         read_attribs = false;
00616                         read_name = !(g_version & V_ATRNAME);
00617                     }
00618                     read_key = !(g_version & V_ATRKEY);
00619                     read_money = !(g_version & V_ATRMONEY);
00620                     g_flags = g_version & ~V_MASK;
00621 
00622                     g_version &= V_MASK;
00623                     if (  g_version < MIN_SUPPORTED_VERSION
00624                        || MAX_SUPPORTED_VERSION < g_version)
00625                     {
00626                         Log.tinyprintf(ENDLINE "Unsupported flatfile version: %d." ENDLINE, g_version);
00627                         return -1;
00628                     }
00629                 }
00630             }
00631             else if (ch == 'S')
00632             {
00633                 // SIZE
00634                 //
00635                 if (size_gotten)
00636                 {
00637                     Log.tinyprintf(ENDLINE "Duplicate size entry at object %d, ignored." ENDLINE, i);
00638                     tstr = getstring_noalloc(f, 0);
00639                 }
00640                 else
00641                 {
00642                     mudstate.min_size = getref(f);
00643                     size_gotten = true;
00644                 }
00645             }
00646             else if (ch == 'N')
00647             {
00648                 // NEXT ATTR TO ALLOC WHEN NO FREELIST
00649                 //
00650                 if (nextattr_gotten)
00651                 {
00652                     Log.tinyprintf(ENDLINE "Duplicate next free vattr entry at object %d, ignored." ENDLINE, i);
00653                     tstr = getstring_noalloc(f, 0);
00654                 }
00655                 else
00656                 {
00657                     mudstate.attr_next = getref(f);
00658                     nextattr_gotten = true;
00659                 }
00660             }
00661             else
00662             {
00663                 Log.tinyprintf(ENDLINE "Unexpected character '%c' in MUX header near object #%d, ignored." ENDLINE, ch, i);
00664                 tstr = getstring_noalloc(f, 0);
00665             }
00666             break;
00667 
00668         case '!':   // MUX entry
00669             i = getref(f);
00670             db_grow(i + 1);
00671 
00672             if (read_name)
00673             {
00674                 tstr = getstring_noalloc(f, true);
00675                 buff = alloc_lbuf("dbread.s_Name");
00676                 (void)ANSI_TruncateToField(tstr, MBUF_SIZE, buff, MBUF_SIZE,
00677                     &nVisualWidth, ANSI_ENDGOAL_NORMAL);
00678                 s_Name(i, buff);
00679                 free_lbuf(buff);
00680 
00681                 s_Location(i, getref(f));
00682             }
00683             else
00684             {
00685                 s_Location(i, getref(f));
00686             }
00687 
00688             // ZONE
00689             //
00690             int zone;
00691             zone = getref(f);
00692             if (zone < NOTHING)
00693             {
00694                 zone = NOTHING;
00695             }
00696             s_Zone(i, zone);
00697 
00698             // CONTENTS and EXITS
00699             //
00700             s_Contents(i, getref(f));
00701             s_Exits(i, getref(f));
00702 
00703             // LINK
00704             //
00705             s_Link(i, getref(f));
00706 
00707             // NEXT
00708             //
00709             s_Next(i, getref(f));
00710 
00711             // LOCK
00712             //
00713             if (read_key)
00714             {
00715                 tempbool = getboolexp(f);
00716                 atr_add_raw(i, A_LOCK,
00717                 unparse_boolexp_quiet(1, tempbool));
00718                 free_boolexp(tempbool);
00719             }
00720 
00721             // OWNER
00722             //
00723             s_Owner(i, getref(f));
00724 
00725             // PARENT
00726             //
00727             s_Parent(i, getref(f));
00728 
00729             // PENNIES
00730             //
00731             if (read_money)
00732             {
00733                 s_PenniesDirect(i, getref(f));
00734             }
00735 
00736             // FLAGS
00737             //
00738             s_Flags(i, FLAG_WORD1, getref(f));
00739             s_Flags(i, FLAG_WORD2, getref(f));
00740             s_Flags(i, FLAG_WORD3, getref(f));
00741 
00742             // POWERS
00743             //
00744             s_Powers(i, getref(f));
00745             s_Powers2(i, getref(f));
00746 
00747             // ATTRIBUTES
00748             //
00749             if (read_attribs)
00750             {
00751                 if (!get_list(f, i))
00752                 {
00753                     Log.tinyprintf(ENDLINE "Error reading attrs for object #%d" ENDLINE, i);
00754                     return -1;
00755                 }
00756             }
00757 
00758             // check to see if it's a player
00759             //
00760             if (isPlayer(i))
00761             {
00762                 c_Connected(i);
00763             }
00764             break;
00765 
00766         case '*':   // EOF marker
00767             tstr = getstring_noalloc(f, 0);
00768             if (strncmp(tstr, "**END OF DUMP***", 16))
00769             {
00770                 Log.tinyprintf(ENDLINE "Bad EOF marker at object #%d" ENDLINE, i);
00771                 return -1;
00772             }
00773             else
00774             {
00775                 *db_version = g_version;
00776                 *db_format = g_format;
00777                 *db_flags = g_flags;
00778                 if (mudstate.bStandAlone)
00779                 {
00780                     Log.WriteString(ENDLINE);
00781                     Log.Flush();
00782                 }
00783                 else
00784                 {
00785                     load_player_names();
00786                 }
00787                 return mudstate.db_top;
00788             }
00789 
00790         case EOF:
00791             Log.tinyprintf(ENDLINE "Unexpected end of file near object #%d" ENDLINE, i);
00792             return -1;
00793 
00794         default:
00795             if (mux_isprint(ch))
00796             {
00797                 Log.tinyprintf(ENDLINE "Illegal character '%c' near object #%d" ENDLINE, ch, i);
00798             }
00799             else
00800             {
00801                 Log.tinyprintf(ENDLINE "Illegal character 0x%02x near object #%d" ENDLINE, ch, i);
00802             }
00803             return -1;
00804         }
00805     }
00806 }

dbref db_write ( FILE *  ,
int  ,
int   
)

Definition at line 910 of file db_rw.cpp.

References A_USER_START, AF_DELETED, anum_alc_top, anum_get, statedata::attr_next, statedata::bStandAlone, statedata::db_top, ENDLINE, F_MUX, attr::flags, CLogFile::Flush(), LBUF_SIZE, Log, mudstate, mux_ltoa(), attr::name, attr::number, statedata::record_players, and CLogFile::WriteString().

Referenced by dbconvert(), and dump_database_internal().

00911 {
00912     dbref i;
00913     int flags;
00914     ATTR *vp;
00915 
00916     switch (format)
00917     {
00918     case F_MUX:
00919         flags = version;
00920         break;
00921 
00922     default:
00923         Log.WriteString("Can only write MUX format." ENDLINE);
00924         return -1;
00925     }
00926     if (mudstate.bStandAlone)
00927     {
00928         Log.WriteString("Writing ");
00929         Log.Flush();
00930     }
00931     i = mudstate.attr_next;
00932     fprintf(f, "+X%d\n+S%d\n+N%d\n", flags, mudstate.db_top, i);
00933     fprintf(f, "-R%d\n", mudstate.record_players);
00934 
00935     // Dump user-named attribute info.
00936     //
00937     char Buffer[LBUF_SIZE];
00938     Buffer[0] = '+';
00939     Buffer[1] = 'A';
00940     int iAttr;
00941     for (iAttr = A_USER_START; iAttr <= anum_alc_top; iAttr++)
00942     {
00943         vp = (ATTR *) anum_get(iAttr);
00944         if (  vp != NULL
00945            && !(vp->flags & AF_DELETED))
00946         {
00947             // Format is: "+A%d\n\"%d:%s\"\n", vp->number, vp->flags, vp->name
00948             //
00949             char *pBuffer = Buffer+2;
00950             pBuffer += mux_ltoa(vp->number, pBuffer);
00951             *pBuffer++ = '\n';
00952             *pBuffer++ = '"';
00953             pBuffer += mux_ltoa(vp->flags, pBuffer);
00954             *pBuffer++ = ':';
00955             int nNameLength = strlen(vp->name);
00956             memcpy(pBuffer, vp->name, nNameLength);
00957             pBuffer += nNameLength;
00958             *pBuffer++ = '"';
00959             *pBuffer++ = '\n';
00960             fwrite(Buffer, sizeof(char), pBuffer-Buffer, f);
00961         }
00962     }
00963 
00964     int iDotCounter = 0;
00965     char buf[SBUF_SIZE];
00966     buf[0] = '!';
00967     DO_WHOLE_DB(i)
00968     {
00969         if (mudstate.bStandAlone)
00970         {
00971             if (!iDotCounter)
00972             {
00973                 iDotCounter = 100;
00974                 fputc('.', stderr);
00975                 fflush(stderr);
00976             }
00977             iDotCounter--;
00978         }
00979 
00980         if (!isGarbage(i))
00981         {
00982             // Format is: "!%d\n", i
00983             //
00984             int n = mux_ltoa(i, buf+1) + 1;
00985             buf[n++] = '\n';
00986             fwrite(buf, sizeof(char), n, f);
00987             db_write_object(f, i, format, flags);
00988         }
00989     }
00990     fputs("***END OF DUMP***\n", f);
00991     if (mudstate.bStandAlone)
00992     {
00993         Log.WriteString(ENDLINE);
00994         Log.Flush();
00995     }
00996     return mudstate.db_top;
00997 }

void destroy_exit ( dbref   ) 

Definition at line 665 of file object.cpp.

References destroy_obj(), Exits, remove_first(), and s_Exits.

Referenced by do_destroy(), and purge_going().

00666 {
00667     dbref loc = Exits(exit);
00668     s_Exits(loc, remove_first(Exits(loc), exit));
00669     destroy_obj(exit);
00670 }

void destroy_thing ( dbref   ) 

Definition at line 672 of file object.cpp.

References destroy_obj(), empty_obj(), move_via_generic(), NOTHING, and Owner.

Referenced by do_destroy(), and purge_going().

00673 {
00674     move_via_generic(thing, NOTHING, Owner(thing), 0);
00675     empty_obj(thing);
00676     destroy_obj(thing);
00677 }

void free_boolexp ( BOOLEXP  ) 

Definition at line 3017 of file db.cpp.

References BOOLEXP_AND, BOOLEXP_ATR, BOOLEXP_CARRY, BOOLEXP_CONST, BOOLEXP_EVAL, BOOLEXP_INDIR, BOOLEXP_IS, BOOLEXP_NOT, BOOLEXP_OR, BOOLEXP_OWNER, free_bool, free_boolexp(), MEMFREE, boolexp::sub1, boolexp::sub2, TRUE_BOOLEXP, and boolexp::type.

Referenced by db_read(), db_write_object(), debug_examine(), do_decomp(), do_examine(), do_lock(), eval_boolexp_atr(), free_boolexp(), FUNCTION(), parse_boolexp_E(), parse_boolexp_F(), parse_boolexp_L(), parse_boolexp_T(), and view_atr().

03018 {
03019     if (b == TRUE_BOOLEXP)
03020         return;
03021 
03022     switch (b->type)
03023     {
03024     case BOOLEXP_AND:
03025     case BOOLEXP_OR:
03026         free_boolexp(b->sub1);
03027         free_boolexp(b->sub2);
03028         free_bool(b);
03029         break;
03030     case BOOLEXP_NOT:
03031     case BOOLEXP_CARRY:
03032     case BOOLEXP_IS:
03033     case BOOLEXP_OWNER:
03034     case BOOLEXP_INDIR:
03035         free_boolexp(b->sub1);
03036         free_bool(b);
03037         break;
03038     case BOOLEXP_CONST:
03039         free_bool(b);
03040         break;
03041     case BOOLEXP_ATR:
03042     case BOOLEXP_EVAL:
03043         MEMFREE(b->sub1);
03044         b->sub1 = NULL;
03045         free_bool(b);
03046         break;
03047     }
03048 }

int get_atr ( char *  name  ) 

Definition at line 2061 of file db.cpp.

References atr_str(), and attr::number.

Referenced by FUNCTION(), and move_exit().

02062 {
02063     ATTR *ap = atr_str(name);
02064 
02065     if (!ap)
02066         return 0;
02067     if (!(ap->number))
02068         return -1;
02069     return ap->number;
02070 }

dbref getref ( FILE *   ) 

Definition at line 3010 of file db.cpp.

References mux_atol(), and SBUF_SIZE.

Referenced by db_read(), get_list(), load_mail_V5(), load_malias(), load_restart_db(), and malias_read().

03011 {
03012     static char buf[SBUF_SIZE];
03013     fgets(buf, sizeof(buf), f);
03014     return mux_atol(buf);
03015 }

char* getstring_noalloc ( FILE *  f,
int  new_strings 
)

Definition at line 2796 of file db.cpp.

References ESC_CHAR, LBUF_SIZE, nLine, STATE_HAVE_ESC, and STATE_START.

Referenced by db_read(), get_list(), getboolexp1(), load_mail_V5(), and load_restart_db().

02797 {
02798     static char buf[2*LBUF_SIZE + 20];
02799     int c = fgetc(f);
02800     if (new_strings && c == '"')
02801     {
02802         int nBufferLeft = sizeof(buf)-10;
02803         int iState = STATE_START;
02804         char *pOutput = buf;
02805         for (;;)
02806         {
02807             // Fetch up to and including the next LF.
02808             //
02809             char *pInput = pOutput + 6;
02810             if (fgets(pInput, nBufferLeft, f) == NULL)
02811             {
02812                 // EOF or ERROR.
02813                 //
02814                 *pOutput = 0;
02815                 return buf;
02816             }
02817 
02818             int nOutput = 0;
02819 
02820             // De-escape this data. removing the '\\' prefixes.
02821             // Terminate when you hit a '"'.
02822             //
02823             for (;;)
02824             {
02825                 char ch = *pInput++;
02826                 if (iState == STATE_START)
02827                 {
02828                     if (decode_table[(unsigned char)ch] == 0)
02829                     {
02830                         // As long as decode_table[*p] is 0, just keep copying the characters.
02831                         //
02832                         char *p = pOutput;
02833                         do
02834                         {
02835                             *pOutput++ = ch;
02836                             ch = *pInput++;
02837                         } while (decode_table[(unsigned char)ch] == 0);
02838                         nOutput = pOutput - p;
02839                     }
02840                 }
02841                 int iAction = action_table[iState][decode_table[(unsigned char)ch]];
02842                 if (iAction <= 2)
02843                 {
02844                     if (iAction == 1)
02845                     {
02846                         // Get Buffer and remain in the current state.
02847                         //
02848                         break;
02849                     }
02850                     else
02851                     {
02852                         // iAction == 2
02853                         // Emit X and move to START state.
02854                         //
02855                         *pOutput++ = ch;
02856                         nOutput++;
02857                         iState = STATE_START;
02858                     }
02859                 }
02860                 else if (iAction == 3)
02861                 {
02862                     // Terminate parsing.
02863                     //
02864                     *pOutput = 0;
02865                     return buf;
02866                 }
02867                 else if (iAction == 4)
02868                 {
02869                     // Move to ESC state.
02870                     //
02871                     iState = STATE_HAVE_ESC;
02872                 }
02873                 else if (iAction == 5)
02874                 {
02875                     *pOutput++ = ESC_CHAR;
02876                     nOutput++;
02877                     iState = STATE_START;
02878                 }
02879                 else if (iAction == 6)
02880                 {
02881                     *pOutput++ = '\n';
02882                     nOutput++;
02883                     iState = STATE_START;
02884                 }
02885                 else if (iAction == 7)
02886                 {
02887                     *pOutput++ = '\r';
02888                     nOutput++;
02889                     iState = STATE_START;
02890                 }
02891                 else
02892                 {
02893                     // if (iAction == 8)
02894                     *pOutput++ = '\t';
02895                     nOutput++;
02896                     iState = STATE_START;
02897                 }
02898             }
02899 
02900             nBufferLeft -= nOutput;
02901 
02902             // Do we have any more room?
02903             //
02904             if (nBufferLeft <= 0)
02905             {
02906                 *pOutput = 0;
02907                 return buf;
02908             }
02909         }
02910     }
02911     else
02912     {
02913         ungetc(c, f);
02914 
02915         char *p = buf;
02916         for (;;)
02917         {
02918             // Fetch up to and including the next LF.
02919             //
02920             if (fgets(p, LBUF_SIZE, f) == NULL)
02921             {
02922                 // EOF or ERROR.
02923                 //
02924                 p[0] = 0;
02925             }
02926             else
02927             {
02928                 // How much data did we fetch?
02929                 //
02930                 int nLine = strlen(p);
02931                 if (nLine >= 2)
02932                 {
02933                     if (p[nLine-2] == '\r')
02934                     {
02935                         // Line is continued on the next line.
02936                         //
02937                         p += nLine;
02938                         continue;
02939                     }
02940 
02941                     // Eat '\n'
02942                     //
02943                     p[nLine-1] = '\0';
02944                 }
02945             }
02946             return buf;
02947         }
02948     }
02949 }

void init_attrtab ( void   ) 

Definition at line 1047 of file db.cpp.

References anum_extend(), anum_set, attr, statedata::attr_name_htab, hashaddLEN(), MakeCanonicalAttributeName(), mudstate, mux_AttrNameInitialSet, mux_AttrNameSet, attr::name, and attr::number.

Referenced by dbconvert(), and main().

01048 {
01049     ATTR *a;
01050 
01051     // We specifically allow the '*' character at server
01052     // initialization because it's part of the A_PASS attribute
01053     // name.
01054     //
01055     const unsigned char star = '*';
01056     mux_AttrNameSet[star] = true;
01057     mux_AttrNameInitialSet[star] = true;
01058     for (a = attr; a->number; a++)
01059     {
01060         int nLen;
01061         bool bValid;
01062         char *buff = MakeCanonicalAttributeName(a->name, &nLen, &bValid);
01063         if (!bValid)
01064         {
01065             continue;
01066         }
01067         anum_extend(a->number);
01068         anum_set(a->number, a);
01069         hashaddLEN(buff, nLen, a, &mudstate.attr_name_htab);
01070     }
01071     mux_AttrNameInitialSet[star] = false;
01072     mux_AttrNameSet[star] = false;
01073 }

void load_restart_db ( void   ) 

Definition at line 3213 of file db.cpp.

References descriptor_data::addr, alloc_desc, alloc_lbuf, aMainGamePorts, confdata::cmd_quota_max, descriptor_data::command_count, descriptor_data::connected_at, DebugTotalFiles, DebugTotalSockets, desc_addhash(), DESC_ITER_CONN, descriptor_data::descriptor, descriptor_list, descriptor_data::doing, statedata::doing_hdr, descriptor_data::flags, getref(), getstring_noalloc(), descriptor_data::hashnext, descriptor_data::height, descriptor_data::host_info, descriptor_data::input_head, descriptor_data::input_lost, descriptor_data::input_size, descriptor_data::input_tail, descriptor_data::input_tot, isPlayer, descriptor_data::last_time, maxd, mudconf, mudstate, mux_assert, ndescriptors, descriptor_data::next, nMainGamePorts, descriptor_data::nOption, descriptor_data::nvt_eor_him_state, descriptor_data::nvt_eor_us_state, NVT_IS_NORMAL, descriptor_data::nvt_naws_him_state, descriptor_data::nvt_naws_us_state, descriptor_data::nvt_sga_him_state, descriptor_data::nvt_sga_us_state, OPTION_NO, descriptor_data::output_head, descriptor_data::output_lost, descriptor_data::output_prefix, descriptor_data::output_size, descriptor_data::output_suffix, descriptor_data::output_tail, descriptor_data::output_tot, descriptor_data::player, descriptor_data::prev, descriptor_data::program_data, descriptor_data::quota, R_QUIT, raw_broadcast(), descriptor_data::raw_input, descriptor_data::raw_input_at, descriptor_data::raw_input_state, statedata::record_players, confdata::reset_players, statedata::restarting, s_Connected, CLinearTimeAbsolute::SetSeconds(), shutdownsock(), PortInfo::socket, statedata::start_time, descriptor_data::timeout, descriptor_data::username, and descriptor_data::width.

Referenced by main().

03214 {
03215     DESC *d;
03216     DESC *p;
03217 
03218     int val;
03219     char *temp, buf[8];
03220 
03221     FILE *f = fopen("restart.db", "r");
03222     if (!f)
03223     {
03224         mudstate.restarting = false;
03225         return;
03226     }
03227     DebugTotalFiles++;
03228     mudstate.restarting = true;
03229 
03230     fgets(buf, 3, f);
03231     mux_assert(strncmp(buf, "+V", 2) == 0);
03232     int version = getref(f);
03233     if (  1 == version
03234        || 2 == version)
03235     {
03236         // Version 1 started on 2001-DEC-03
03237         // Version 2 started on 2005-NOV-08
03238         //
03239         nMainGamePorts = getref(f);
03240         for (int i = 0; i < nMainGamePorts; i++)
03241         {
03242             aMainGamePorts[i].port   = getref(f);
03243             mux_assert(aMainGamePorts[i].port > 0);
03244             aMainGamePorts[i].socket = getref(f);
03245             if (maxd <= aMainGamePorts[i].socket)
03246             {
03247                 maxd = aMainGamePorts[i].socket + 1;
03248             }
03249         }
03250     }
03251     else
03252     {
03253         // The restart file, restart.db, has a version other than 1.  You
03254         // cannot @restart from the previous version to the new version.  Use
03255         // @shutdown instead.
03256         //
03257         mux_assert(0);
03258     }
03259     DebugTotalSockets += nMainGamePorts;
03260 
03261     mudstate.start_time.SetSeconds(getref(f));
03262     strcpy(mudstate.doing_hdr, getstring_noalloc(f, true));
03263     mudstate.record_players = getref(f);
03264     if (mudconf.reset_players)
03265     {
03266         mudstate.record_players = 0;
03267     }
03268 
03269     while ((val = getref(f)) != 0)
03270     {
03271         ndescriptors++;
03272         DebugTotalSockets++;
03273         d = alloc_desc("restart");
03274         d->descriptor = val;
03275         d->flags = getref(f);
03276         d->connected_at.SetSeconds(getref(f));
03277         d->command_count = getref(f);
03278         d->timeout = getref(f);
03279         d->host_info = getref(f);
03280         d->player = getref(f);
03281         d->last_time.SetSeconds(getref(f));
03282         if (2 == version)
03283         {
03284             d->raw_input_state    = getref(f);
03285             d->nvt_sga_him_state  = getref(f);
03286             d->nvt_sga_us_state   = getref(f);
03287             d->nvt_eor_him_state  = getref(f);
03288             d->nvt_eor_us_state   = getref(f);
03289             d->nvt_naws_him_state = getref(f);
03290             d->nvt_naws_us_state  = getref(f);
03291             d->height = getref(f);
03292             d->width = getref(f);
03293         }
03294         else
03295         {
03296             d->raw_input_state    = NVT_IS_NORMAL;
03297             d->nvt_sga_him_state  = OPTION_NO;
03298             d->nvt_sga_us_state   = OPTION_NO;
03299             d->nvt_eor_him_state  = OPTION_NO;
03300             d->nvt_eor_us_state   = OPTION_NO;
03301             d->nvt_naws_him_state = OPTION_NO;
03302             d->nvt_naws_us_state  = OPTION_NO;
03303             d->height = 24;
03304             d->width = 78;
03305         }
03306 
03307         temp = getstring_noalloc(f, true);
03308         if (*temp)
03309         {
03310             d->output_prefix = alloc_lbuf("set_userstring");
03311             strcpy(d->output_prefix, temp);
03312         }
03313         else
03314         {
03315             d->output_prefix = NULL;
03316         }
03317         temp = getstring_noalloc(f, true);
03318         if (*temp)
03319         {
03320             d->output_suffix = alloc_lbuf("set_userstring");
03321             strcpy(d->output_suffix, temp);
03322         }
03323         else
03324         {
03325             d->output_suffix = NULL;
03326         }
03327 
03328         strcpy(d->addr, getstring_noalloc(f, true));
03329         strcpy(d->doing, getstring_noalloc(f, true));
03330         strcpy(d->username, getstring_noalloc(f, true));
03331 
03332         d->output_size = 0;
03333         d->output_tot = 0;
03334         d->output_lost = 0;
03335         d->output_head = NULL;
03336         d->output_tail = NULL;
03337         d->input_head = NULL;
03338         d->input_tail = NULL;
03339         d->input_size = 0;
03340         d->input_tot = 0;
03341         d->input_lost = 0;
03342         d->raw_input = NULL;
03343         d->raw_input_at = NULL;
03344         d->nOption = 0;
03345         d->quota = mudconf.cmd_quota_max;
03346         d->program_data = NULL;
03347         d->hashnext = NULL;
03348 
03349         if (descriptor_list)
03350         {
03351             for (p = descriptor_list; p->next; p = p->next) ;
03352             d->prev = &p->next;
03353             p->next = d;
03354             d->next = NULL;
03355         }
03356         else
03357         {
03358             d->next = descriptor_list;
03359             d->prev = &descriptor_list;
03360             descriptor_list = d;
03361         }
03362 
03363         if (maxd <= d->descriptor)
03364         {
03365             maxd = d->descriptor + 1;
03366         }
03367         desc_addhash(d);
03368         if (isPlayer(d->player))
03369         {
03370             s_Connected(d->player);
03371         }
03372     }
03373 
03374     DESC_ITER_CONN(d)
03375     {
03376         if (!isPlayer(d->player))
03377         {
03378             shutdownsock(d, R_QUIT);
03379         }
03380     }
03381 
03382     if (fclose(f) == 0)
03383     {
03384         DebugTotalFiles--;
03385     }
03386     remove("restart.db");
03387     raw_broadcast(0, "GAME: Restart finished.");
03388 }

char* MakeCanonicalAttributeCommand ( const char *  pName,
int *  pnName,
bool *  pbValid 
)

Definition at line 1007 of file db.cpp.

References mux_tolower, and SBUF_SIZE.

Referenced by CF_HAND(), and init_cmdtab().

01008 {
01009     if (!pName)
01010     {
01011         *pnName = 0;
01012         *pbValid = false;
01013         return NULL;
01014     }
01015 
01016     static char Buffer[SBUF_SIZE];
01017     int nLeft = SBUF_SIZE-2;
01018     char *p = Buffer;
01019 
01020     *p++ = '@';
01021     while (*pName && nLeft)
01022     {
01023         *p = mux_tolower(*pName);
01024         p++;
01025         pName++;
01026         nLeft--;
01027     }
01028     *p = '\0';
01029 
01030     // Length of result.
01031     //
01032     *pnName = p - Buffer;
01033 
01034     // Is the result valid?
01035     //
01036     *pbValid = (*pnName > 1);
01037 
01038     // Pointer to result
01039     //
01040     return Buffer;
01041 }

char* MakeCanonicalAttributeName ( const char *  pName,
int *  pnName,
bool *  pbValid 
)

Definition at line 954 of file db.cpp.

References mux_AttrNameInitialSet, mux_AttrNameSet, mux_toupper, and SBUF_SIZE.

Referenced by atr_str(), db_read(), do_attribute(), FUNCTION(), init_attrtab(), and mkattr().

00955 {
00956     static char Buffer[SBUF_SIZE];
00957 
00958     if (  !pName
00959        || !mux_AttrNameInitialSet(*pName))
00960     {
00961         *pnName = 0;
00962         *pbValid = false;
00963         return NULL;
00964     }
00965     int nLeft = SBUF_SIZE-1;
00966     char *p = Buffer;
00967     while (*pName && nLeft)
00968     {
00969         if (!mux_AttrNameSet(*pName))
00970         {
00971             *pnName = 0;
00972             *pbValid = false;
00973             return Buffer;
00974         }
00975         *p = mux_toupper(*pName);
00976         p++;
00977         pName++;
00978         nLeft--;
00979     }
00980     *p = '\0';
00981 
00982     // Continue to validate remaining characters even though
00983     // we aren't going to use them. This helps to ensure that
00984     // softcode will run in the future if we increase the
00985     // size of SBUF_SIZE.
00986     //
00987     while (*pName)
00988     {
00989         if (!mux_AttrNameSet(*pName))
00990         {
00991             *pnName = 0;
00992             *pbValid = false;
00993             return Buffer;
00994         }
00995         pName++;
00996     }
00997 
00998     // Length of truncated result.
00999     //
01000     *pnName = p - Buffer;
01001     *pbValid = true;
01002     return Buffer;
01003 }

int mkattr ( dbref  executor,
char *   
)

Definition at line 1252 of file db.cpp.

References AF_MDARK, AF_WIZARD, atr_str(), MakeCanonicalAttributeName(), mudconf, attr::number, ThrottleAttributeNames(), vattr_alloc_LEN(), confdata::vattr_flags, and Wizard.

Referenced by do_chanlog(), do_mvattr(), do_notify(), do_set(), do_setvattr(), do_wait(), FUNCTION(), getboolexp1(), and SendChannelMessage().

01253 {
01254     ATTR *ap = atr_str(buff);
01255     if (!ap)
01256     {
01257         // Unknown attribute name, create a new one.
01258         //
01259         int nName;
01260         bool bValid;
01261         char *pName = MakeCanonicalAttributeName(buff, &nName, &bValid);
01262         ATTR *va;
01263         if (bValid)
01264         {
01265             if (  !Wizard(executor)
01266                && ThrottleAttributeNames(executor))
01267             {
01268                 return -1;
01269             }
01270             int aflags = mudconf.vattr_flags;
01271             if (pName[0] == '_')
01272             {
01273                 // An attribute that begins with an underline is
01274                 // hidden from mortals and only changeable by
01275                 // WIZARDs.
01276                 //
01277                 aflags |=  AF_MDARK | AF_WIZARD;
01278             }
01279             va = vattr_alloc_LEN(pName, nName, aflags);
01280             if (va && va->number)
01281             {
01282                 return va->number;
01283             }
01284         }
01285         return -1;
01286     }
01287     else if (ap->number)
01288     {
01289         return ap->number;
01290     }
01291     return -1;
01292 }

dbref parse_dbref ( const char *   ) 

Definition at line 2712 of file db.cpp.

References mux_atol(), mux_isdigit, and NOTHING.

Referenced by absolute_name(), do_malias_add(), do_malias_remove(), and FUNCTION().

02713 {
02714     // Enforce completely numeric dbrefs
02715     //
02716     const char *p = s;
02717     if (p[0])
02718     {
02719         do
02720         {
02721             if (!mux_isdigit(*p))
02722             {
02723                 return NOTHING;
02724             }
02725             p++;
02726         } while (*p);
02727     }
02728     else
02729     {
02730         return NOTHING;
02731     }
02732     int x = mux_atol(s);
02733     return ((x >= 0) ? x : NOTHING);
02734 }

int Pennies ( dbref  obj  ) 

Returns how many coins are in a player's or things's purse.

Parameters:
player dbref of player object.
Returns:
None.

Definition at line 295 of file player_c.cpp.

References A_MONEY, atr_get_raw(), statedata::bStandAlone, Good_obj, player_cache::money, mudstate, mux_atol(), OwnsOthers, and pcache_find().

Referenced by canpayfees(), check_pennies(), CGuests::Create(), db_write_object(), debug_examine(), destroy_obj(), do_chown(), do_clone(), do_decomp(), do_examine(), do_kill(), do_poor(), do_score(), FUNCTION(), give_money(), giveto(), CGuests::MakeGuestChar(), move_object(), payfor(), and shutdownsock().

00296 {
00297     if (Good_obj(obj))
00298     {
00299         if (  !mudstate.bStandAlone
00300            && OwnsOthers(obj))
00301         {
00302             PCACHE *pp = pcache_find(obj);
00303             return pp->money;
00304         }
00305         else
00306         {
00307             const char *cp = atr_get_raw(obj, A_MONEY);
00308             if (cp)
00309             {
00310                 return mux_atol(cp);
00311             }
00312         }
00313     }
00314     return 0;
00315 }

void putref ( FILE *  ,
dbref   
)

Definition at line 2737 of file db.cpp.

References mux_ltoa(), and SBUF_SIZE.

Referenced by db_write_object(), dump_mail(), dump_restart_db(), malias_write(), and putbool_subexp().

02738 {
02739     char buf[SBUF_SIZE];
02740     int n = mux_ltoa(ref, buf);
02741     buf[n] = '\n';
02742     fwrite(buf, sizeof(char), n+1, f);
02743 }

void putstring ( FILE *  f,
const char *  s 
)

Definition at line 2976 of file db.cpp.

References LBUF_SIZE.

Referenced by db_write_object(), dump_mail(), and dump_restart_db().

02977 {
02978     static char aBuffer[2*LBUF_SIZE+4];
02979     char *pBuffer = aBuffer;
02980 
02981     // Always leave room for four characters. One at the beginning and
02982     // three on the end. '\\"\n' or '\""\n'
02983     //
02984     *pBuffer++ = '"';
02985 
02986     if (pRaw)
02987     {
02988         for (;;)
02989         {
02990             char ch;
02991             while ((ch = encode_table[(unsigned char)*pRaw]) == 0)
02992             {
02993                 *pBuffer++ = *pRaw++;
02994             }
02995             if (ch == 1)
02996             {
02997                 break;
02998             }
02999             *pBuffer++ = '\\';
03000             *pBuffer++ = *pRaw++;
03001         }
03002     }
03003 
03004     *pBuffer++ = '"';
03005     *pBuffer++ = '\n';
03006 
03007     fwrite(aBuffer, sizeof(char), pBuffer - aBuffer, f);
03008 }

void s_Pennies ( dbref  obj,
int  howfew 
)

Sets the number of coins in a player's or thing's purse.

This changes the number of coins a player holds and sets this attribute as dirty so that it will be updated in the attribute database later.

Parameters:
player dbref of player object responsible for command.
howfew Number of coins
Returns:
None.

Definition at line 328 of file player_c.cpp.

References A_MONEY, atr_add_raw(), statedata::bStandAlone, player_cache::cflags, Good_obj, player_cache::money, mudstate, mux_ltoa(), OwnsOthers, pcache_find(), and PF_MONEY_CH.

Referenced by check_pennies(), CGuests::Create(), create_obj(), db_make_minimal(), destroy_bad_obj(), destroy_obj(), do_clone(), do_fixdb(), do_poor(), do_toad(), giveto(), CGuests::MakeGuestChar(), and payfor().

00329 {
00330     if (Good_obj(obj))
00331     {
00332         if (  !mudstate.bStandAlone
00333            && OwnsOthers(obj))
00334         {
00335             PCACHE *pp = pcache_find(obj);
00336             pp->money = howfew;
00337             pp->cflags |= PF_MONEY_CH;
00338         }
00339         else
00340         {
00341             IBUF tbuf;
00342             mux_ltoa(howfew, tbuf);
00343             atr_add_raw(obj, A_MONEY, tbuf);
00344         }
00345     }
00346 }

void s_PenniesDirect ( dbref  obj,
int  howfew 
)

A shortcut method of initializing the coins in a object's purse.

This method should only be used from db_rw.cpp while loading the database. From there, the object will be in a half-way state, and has not been fully loaded. The object type is not known. Likewise, at database load time, using the player cache is ineffective -- causing a read request for A_MONEY to obtain a value for coins (probably zero) that we immediate change again.

Parameters:
obj dbref of object.
howfew Number of coins
Returns:
None.

Definition at line 361 of file player_c.cpp.

References A_MONEY, atr_add_raw(), and mux_ltoa().

Referenced by db_read().

00362 {
00363     IBUF tbuf;
00364     mux_ltoa(howfew, tbuf);
00365     atr_add_raw(obj, A_MONEY, tbuf);
00366 }

bool ThrottleAttributeNames ( dbref  executor  ) 

Definition at line 1214 of file db.cpp.

References db, CLinearTimeAbsolute::GetUTC(), s_ThAttrib, SetupThrottle(), and ThAttrib.

Referenced by mkattr().

01215 {
01216     if (0 < ThAttrib(executor))
01217     {
01218         s_ThAttrib(executor, ThAttrib(executor)-1);
01219         return false;
01220     }
01221     CLinearTimeAbsolute tNow;
01222     tNow.GetUTC();
01223     if (db[executor].tThrottleExpired <= tNow)
01224     {
01225         SetupThrottle(executor);
01226         return false;
01227     }
01228     return true;
01229 }

bool ThrottleMail ( dbref  executor  ) 

Definition at line 1231 of file db.cpp.

References db, CLinearTimeAbsolute::GetUTC(), s_ThMail, SetupThrottle(), and ThMail.

Referenced by do_expmail_start(), do_mail_fwd(), do_mail_quick(), and do_mail_reply().

01232 {
01233     if (0 < ThMail(executor))
01234     {
01235         s_ThMail(executor, ThMail(executor)-1);
01236         return false;
01237     }
01238     CLinearTimeAbsolute tNow;
01239     tNow.GetUTC();
01240     if (db[executor].tThrottleExpired <= tNow)
01241     {
01242         SetupThrottle(executor);
01243         return false;
01244     }
01245     return true;
01246 }

bool ThrottlePlayerCreate ( void   ) 

Definition at line 1197 of file db.cpp.

References CLinearTimeAbsolute::GetUTC(), mudstate, statedata::pcreates_this_hour, SetupGlobalThrottle(), and statedata::tThrottleExpired.

Referenced by create_player().

01198 {
01199     if (0 < mudstate.pcreates_this_hour)
01200     {
01201         mudstate.pcreates_this_hour--;
01202         return false;
01203     }
01204     CLinearTimeAbsolute tNow;
01205     tNow.GetUTC();
01206     if (mudstate.tThrottleExpired <= tNow)
01207     {
01208         SetupGlobalThrottle();
01209         return false;
01210     }
01211     return true;
01212 }


Variable Documentation

ATTR** anum_table

Definition at line 1109 of file db.cpp.

Referenced by anum_extend(), vattr_delete_LEN(), vattr_find_LEN(), vattr_first(), vattr_next(), and vattr_rename_LEN().

char* aszSpecialDBRefNames[1-NOPERM]

Definition at line 222 of file db.cpp.

Referenced by Moniker(), Name(), PureName(), unparse_object(), and unparse_object_numonly().

const int ATRLIST_CHUNK = 20

Definition at line 177 of file db.h.

Referenced by atr_add_raw_LEN().

ATTR attr[]

Definition at line 37 of file db.cpp.

Referenced by check_attr(), get_obj_and_lock(), init_attrtab(), and parse_attrib().

OBJ* db

Definition at line 26 of file db.cpp.

Referenced by announce_connect(), announce_disconnect(), atr_add_raw_LEN(), atr_clr(), atr_free(), atr_head(), atr_next(), check_connect(), check_idle(), CGuests::Create(), create_obj(), db_free(), db_grow(), decompile_flags(), do_chown(), do_chzone(), fh_any(), fh_privileged(), flag_description(), FUNCTION(), has_flag(), initialize_objects(), link_exit(), CGuests::MakeGuestChar(), Moniker(), Name(), PureName(), purge_going(), ratio(), report_timecheck(), s_Moniker(), s_Name(), search_perform(), SetupThrottle(), shovechars(), shutdownsock(), Task_RunQueueEntry(), ThrottleAttributeNames(), ThrottleMail(), and unparse_object().

const int INITIAL_ATRLIST_SIZE = 10

Definition at line 176 of file db.h.

Referenced by atr_add_raw_LEN().


Generated on Mon May 28 04:40:15 2007 for MUX by  doxygen 1.4.7