src/game.c File Reference

#include "copyright.h"
#include "config.h"
#include <sys/stat.h>
#include <signal.h>
#include <event.h>
#include <regex.h>
#include "mudconf.h"
#include "file_c.h"
#include "db.h"
#include "interface.h"
#include "match.h"
#include "externs.h"
#include "flags.h"
#include "powers.h"
#include "attrs.h"
#include "alloc.h"
#include "vattr.h"
#include "commac.h"

Include dependency graph for game.c:

Go to the source code of this file.

Defines

#define NSUBEXP   10

Functions

void init_attrtab (void)
void init_cmdtab (void)
void init_mactab (void)
void init_chantab (void)
void cf_init (void)
void pcache_init (void)
int cf_read (char *fn)
void init_functab (void)
void close_sockets (int emergency, char *message)
void init_version (void)
void init_logout_cmdtab (void)
void init_timer (void)
void raw_notify (dbref, const char *)
void do_second (void)
void do_dbck (dbref, dbref, int)
void fork_and_dump (int)
void dump_database (void)
void do_dump_optimize (dbref, dbref, int)
void pcache_sync (void)
void dump_database_internal (int)
static void init_rlimit (void)
void do_dump (dbref player, dbref cause, int key)
void report (void)
int regexp_match (char *pattern, char *str, char *args[], int nargs)
static int atr_match1 (dbref thing, dbref parent, dbref player, char type, char *str, int check_exclude, int hash_insert)
int atr_match (dbref thing, dbref player, char type, char *str, int check_parents)
int check_filter (dbref object, dbref player, int filter, const char *msg)
static char * add_prefix (dbref object, dbref player, int prefix, const char *msg, const char *dflt)
static char * dflt_from_msg (dbref sender, dbref sendloc)
char * colorize (dbref player, char *from)
void notify_checked (dbref target, dbref sender, const char *msg, int key)
void notify_except (dbref loc, dbref player, dbref exception, const char *msg)
void notify_except2 (dbref loc, dbref player, dbref exc1, dbref exc2, const char *msg)
void do_shutdown (dbref player, dbref cause, int key, char *message)
static int load_game (void)
int list_check (dbref thing, dbref player, char type, char *str, int check_parent)
int Hearer (dbref thing)
void do_readcache (dbref player, dbref cause, int key)
static void process_preload (void)
int main (int argc, char *argv[])

Variables

int reserved
int corrupt


Define Documentation

#define NSUBEXP   10

Definition at line 40 of file game.c.


Function Documentation

static char* add_prefix ( dbref  object,
dbref  player,
int  prefix,
const char *  msg,
const char *  dflt 
) [static]

Definition at line 358 of file game.c.

References alloc_lbuf, atr_pget(), EV_EVAL, EV_FIGNORE, EV_TOP, exec(), free_lbuf, and safe_str.

Referenced by notify_checked().

00360 {
00361         int aflags;
00362         dbref aowner;
00363         char *buf, *nbuf, *cp, *bp, *str;
00364 
00365         buf = atr_pget(object, prefix, &aowner, &aflags);
00366         if(!*buf) {
00367                 cp = buf;
00368                 safe_str((char *) dflt, buf, &cp);
00369         } else {
00370                 nbuf = bp = alloc_lbuf("add_prefix");
00371                 str = buf;
00372                 exec(nbuf, &bp, 0, object, player, EV_FIGNORE | EV_EVAL | EV_TOP,
00373                          &str, (char **) NULL, 0);
00374                 *bp = '\0';
00375                 free_lbuf(buf);
00376                 buf = nbuf;
00377                 cp = &buf[strlen(buf)];
00378         }
00379         if(cp != buf)
00380                 safe_str((char *) " ", buf, &cp);
00381         safe_str((char *) msg, buf, &cp);
00382         *cp = '\0';
00383         return (buf);
00384 }

int atr_match ( dbref  thing,
dbref  player,
char  type,
char *  str,
int  check_parents 
)

Definition at line 281 of file game.c.

References atr_match1(), Good_obj, Halted, ITER_PARENTS, mudstate, nhashflush(), Parent, and statedata::parent_htab.

Referenced by list_check(), notify_checked(), and process_command().

00283 {
00284         int match, lev, result, exclude, insert;
00285         dbref parent;
00286 
00287         /*
00288          * If thing is halted, don't check anything 
00289          */
00290 
00291         if(Halted(thing))
00292                 return 0;
00293 
00294         /*
00295          * If not checking parents, just check the thing 
00296          */
00297 
00298         match = 0;
00299         if(!check_parents)
00300                 return atr_match1(thing, thing, player, type, str, 0, 0);
00301 
00302         /*
00303          * Check parents, ignoring halted objects 
00304          */
00305 
00306         exclude = 0;
00307         insert = 1;
00308         nhashflush(&mudstate.parent_htab, 0);
00309         ITER_PARENTS(thing, parent, lev) {
00310                 if(!Good_obj(Parent(parent)))
00311                         insert = 0;
00312                 result =
00313                         atr_match1(thing, parent, player, type, str, exclude, insert);
00314                 if(result > 0) {
00315                         match = 1;
00316                 } else if(result < 0) {
00317                         return match;
00318                 }
00319                 exclude = 1;
00320         }
00321 
00322         return match;
00323 }

static int atr_match1 ( dbref  thing,
dbref  parent,
dbref  player,
char  type,
char *  str,
int  check_exclude,
int  hash_insert 
) [static]

Check attribute list for wild card matches and queue them.

Definition at line 194 of file game.c.

References A_LUSE, AF_NOPROG, AF_PRIVATE, AF_REGEXP, args, atr_get_str(), atr_head(), atr_next(), atr_num(), could_doit(), attr::flags, free_lbuf, statedata::global_regs, LBUF_SIZE, mudstate, nhashadd(), nhashfind(), NOTHING, attr::number, statedata::parent_htab, regexp_match(), wait_que(), and wild().

Referenced by atr_match().

00196 {
00197         dbref aowner;
00198         int match, attr, aflags, i;
00199         char buff[LBUF_SIZE], *s, *as;
00200         char *args[10];
00201         ATTR *ap;
00202 
00203     memset(args, 0, sizeof(args));
00204     
00205         /*
00206          * See if we can do it.  Silently fail if we can't. 
00207          */
00208 
00209         if(!could_doit(player, parent, A_LUSE))
00210                 return -1;
00211 
00212         match = 0;
00213         for(attr = atr_head(parent, &as); attr; attr = atr_next(&as)) {
00214                 ap = atr_num(attr);
00215 
00216                 /*
00217                  * Never check NOPROG attributes. 
00218                  */
00219 
00220                 if(!ap || (ap->flags & AF_NOPROG))
00221                         continue;
00222 
00223                 /*
00224                  * If we aren't the bottom level check if we saw this attr *
00225                  * * * * before.  Also exclude it if the attribute type is *
00226                  * * PRIVATE. 
00227                  */
00228 
00229                 if(check_exclude && ((ap->flags & AF_PRIVATE) ||
00230                                                          nhashfind(ap->number, &mudstate.parent_htab))) {
00231                         continue;
00232                 }
00233                 atr_get_str(buff, parent, attr, &aowner, &aflags);
00234 
00235                 /*
00236                  * Skip if private and on a parent 
00237                  */
00238 
00239                 if(check_exclude && (aflags & AF_PRIVATE)) {
00240                         continue;
00241                 }
00242                 /*
00243                  * If we aren't the top level remember this attr so we * * *
00244                  * exclude * it from now on. 
00245                  */
00246 
00247                 if(hash_insert)
00248                         nhashadd(ap->number, (int *) &attr, &mudstate.parent_htab);
00249 
00250                 /*
00251                  * Check for the leadin character after excluding the attrib
00252                  * * * * * This lets non-command attribs on the child block * 
00253                  * *  * commands * on the parent. 
00254                  */
00255 
00256                 if((buff[0] != type) || (aflags & AF_NOPROG))
00257                         continue;
00258 
00259                 /*
00260                  * decode it: search for first un escaped : 
00261                  */
00262 
00263                 for(s = buff + 1; *s && (*s != ':'); s++);
00264                 if(!*s)
00265                         continue;
00266                 *s++ = 0;
00267                 if(((aflags & AF_REGEXP) && regexp_match(buff + 1, str, args, 10))
00268                    || wild(buff + 1, str, args, 10)) {
00269                         match = 1;
00270                         wait_que(thing, player, 0, NOTHING, 0, s, args, 10,
00271                                          mudstate.global_regs);
00272                         for(i = 0; i < 10; i++) {
00273                                 if(args[i])
00274                                         free_lbuf(args[i]);
00275                         }
00276                 }
00277         }
00278         return (match);
00279 }

void cf_init ( void   ) 

Definition at line 65 of file conf.c.

References A_USER_START, statedata::access_list, confdata::active_q_chunk, AF_ODARK, confdata::afterlife_dbref, confdata::afterscen_dbref, confdata::allow_chanlurking, confdata::allow_unloggedwho, statedata::attr_next, statedata::badname_head, confdata::btech_critlevel, confdata::btech_defaultweapbv, confdata::btech_defaultweapdam, confdata::btech_dig_only_fs, confdata::btech_digbonus, confdata::btech_divrotordamage, confdata::btech_dynspeed, confdata::btech_erange, confdata::btech_exile_stun_code, confdata::btech_explode_ammo, confdata::btech_explode_reactor, confdata::btech_explode_stop, confdata::btech_explode_time, confdata::btech_extendedmovemod, confdata::btech_fasaadvvhlcrit, confdata::btech_fasaadvvhlfire, confdata::btech_fasaadvvtolcrit, confdata::btech_fasacrit, confdata::btech_fasaturn, confdata::btech_glancing_blows, confdata::btech_hotloadaddshalfbthmod, confdata::btech_ic, confdata::btech_idf_requires_spotter, confdata::btech_inferno_penalty, confdata::btech_limitedrepairs, confdata::btech_moddamagewithrange, confdata::btech_moddamagewithwoods, confdata::btech_mw_losmap, confdata::btech_newcharge, confdata::btech_newstagger, confdata::btech_newterrain, confdata::btech_nofusionvtolfuel, confdata::btech_oldxpsystem, confdata::btech_ooc_comsys, confdata::btech_parts, confdata::btech_perunit_xpmod, confdata::btech_phys_use_pskill, confdata::btech_roll_on_backwalk, confdata::btech_seismic_see_stopped, confdata::btech_skidcliff, confdata::btech_slowdown, confdata::btech_stackdamage, confdata::btech_stacking, confdata::btech_stackpole, confdata::btech_tankfriendly, confdata::btech_tankshield, confdata::btech_tl3_charge, confdata::btech_usedmechstore, confdata::btech_vcrit, confdata::btech_vtol_ice_causes_fire, confdata::btech_xp_ammomod, confdata::btech_xp_bthmod, confdata::btech_xp_missilemod, confdata::btech_xp_modifier, confdata::btech_xp_usePilotBVMod, confdata::btech_xp_vrtmod, confdata::btech_xploss, CACHE_DEPTH, confdata::cache_depth, confdata::cache_names, confdata::cache_trim, CACHE_WIDTH, confdata::cache_width, confdata::check_interval, confdata::check_offset, confdata::clone_copy_cost, confdata::cmd_quota_incr, confdata::cmd_quota_max, confdata::commac_db, confdata::compress, confdata::compress_db, confdata::conc_port, confdata::conn_dir, confdata::conn_file, confdata::conn_timeout, confdata::control_flags, confdata::crashdb, confdata::crea_file, confdata::createmax, confdata::createmin, confdata::creg_file, statedata::curr_enactor, statedata::curr_player, confdata::dark_sleepers, alist::data, statedata::db_size, statedata::db_top, statedata::debug_cmd, confdata::default_home, confdata::digcost, statedata::doing_hdr, confdata::down_file, confdata::downmotd_msg, confdata::dump_interval, confdata::dump_msg, confdata::dump_offset, statedata::dumping, statedata::epoch, confdata::events_daily_hour, statedata::events_flag, statedata::events_lasthour, confdata::ex_flags, confdata::exam_public, confdata::exit_flags, confdata::exit_parent, confdata::exit_quota, confdata::fascist_tport, confdata::fixed_home_msg, confdata::fixed_tel_msg, confdata::fork_dump, confdata::fork_vfork, statedata::freelist, confdata::full_file, confdata::fullmotd_msg, statedata::func_invk_ctr, confdata::func_invk_lim, statedata::func_nest_lev, confdata::func_nest_lim, confdata::gdbm, statedata::generation, statedata::global_regs, confdata::guest_char, confdata::guest_file, confdata::guest_nuker, confdata::guest_prefix, confdata::guests_channel, confdata::have_comsys, confdata::have_macros, confdata::have_mailer, confdata::have_specials, confdata::have_zones, confdata::hcode_db, confdata::help_file, confdata::help_indx, confdata::idle_interval, confdata::idle_timeout, confdata::idle_wiz_dark, confdata::indb, confdata::indent_desc, confdata::init_size, statedata::initializing, statedata::inpipe, statedata::iter_alist, confdata::killguarantee, confdata::killmax, confdata::killmin, alist::len, confdata::linkcost, statedata::lock_nest_lev, confdata::lock_nest_lim, LOG_ALWAYS, LOG_BUGS, LOG_CONFIGMODS, LOG_DBSAVES, confdata::log_info, LOG_LOGIN, LOG_NET, confdata::log_options, LOG_PCREATES, LOG_PROBLEMS, LOG_SECURITY, LOG_SHOUTS, LOG_STARTUP, LOG_WIZARD, statedata::logging, LOGOPT_LOC, LOGOPT_TIMESTAMP, confdata::machinecost, confdata::mail_db, statedata::mail_db_size, statedata::mail_db_top, confdata::mail_expiration, statedata::mail_freelist, confdata::many_coins, confdata::map_db, statedata::markbits, confdata::markdata, confdata::master_room, confdata::match_mine, confdata::match_mine_pl, MAX_GLOBAL_REGS, confdata::max_players, confdata::mech_db, statedata::min_size, statedata::mod_al_id, statedata::mod_alist, statedata::mod_size, confdata::motd_file, confdata::motd_msg, statedata::mstat_curr, statedata::mstat_idrss, statedata::mstat_isrss, statedata::mstat_ixrss, statedata::mstat_secs, confdata::mud_name, mudconf, mudstate, confdata::name_spaces, confdata::namechange_days, confdata::news_file, confdata::news_indx, alist::next, NOTHING, statedata::ntfy_nest_lev, confdata::ntfy_nest_lim, confdata::number_guests, statedata::olist, confdata::one_coin, confdata::opencost, confdata::outdb, confdata::output_limit, confdata::pagecost, statedata::panicking, confdata::paranoid_alloc, confdata::parent_nest_lim, confdata::paycheck, confdata::payfind, confdata::paylimit, confdata::paystart, confdata::pemit_any, confdata::pemit_players, confdata::player_flags, confdata::player_listen, confdata::player_quota, confdata::plushelp_file, confdata::plushelp_indx, confdata::port, confdata::postdump_msg, statedata::pout, statedata::poutbufc, statedata::poutnew, statedata::poutobj, confdata::pub_flags, confdata::public_channel, statedata::qhead, statedata::qsemfirst, statedata::qsemlast, statedata::qtail, confdata::queue_chunk, confdata::queuemax, confdata::quiet_look, confdata::quiet_whisper, confdata::quit_file, confdata::quotas, statedata::qwait, confdata::read_rem_desc, confdata::read_rem_name, confdata::regf_file, confdata::retry_limit, ROBOT, confdata::robot_flags, confdata::robot_speak, confdata::robotcost, confdata::room_flags, confdata::room_parent, confdata::room_quota, SA_DFLT, confdata::sacadjust, confdata::sacfactor, confdata::safe_unowned, confdata::searchcost, confdata::see_own_dark, statedata::shutdown_flag, confdata::sig_action, confdata::site_chars, confdata::site_file, confdata::space_compress, confdata::stack_limit, confdata::start_home, confdata::start_quota, confdata::start_room, confdata::status_file, StringCopy, statedata::suspect_list, confdata::sweep_dark, confdata::switch_df_all, confdata::terse_contents, confdata::terse_exits, confdata::terse_look, confdata::terse_movemsg, confdata::thing_flags, confdata::thing_quota, confdata::timeslice, confdata::trace_limit, confdata::trace_topdown, confdata::uncompress, confdata::use_hostname, confdata::use_http, confdata::vattr_flags, confdata::waitcost, confdata::whelp_file, confdata::whelp_indx, confdata::wizmotd_file, confdata::wizmotd_msg, confdata::wiznews_file, confdata::wiznews_indx, flagset::word1, flagset::word2, confdata::zone_nest_lim, and statedata::zone_nest_num.

Referenced by main().

00066 {
00067         int i;
00068 
00069         StringCopy(mudconf.indb, "tinymush.db");
00070         StringCopy(mudconf.outdb, "");
00071         StringCopy(mudconf.crashdb, "");
00072         StringCopy(mudconf.gdbm, "");
00073         StringCopy(mudconf.mail_db, "mail.db");
00074         StringCopy(mudconf.commac_db, "commac.db");
00075         StringCopy(mudconf.hcode_db, "hcode.db");
00076 #ifdef BT_ADVANCED_ECON
00077         StringCopy(mudconf.econ_db, "econ.db");
00078 #endif
00079         StringCopy(mudconf.mech_db, "mechs");
00080         StringCopy(mudconf.map_db, "maps");
00081         mudconf.compress_db = 0;
00082         StringCopy(mudconf.compress, "gzip");
00083         StringCopy(mudconf.uncompress, "gzip -d");
00084         StringCopy(mudconf.status_file, "shutdown.status");
00085         mudconf.allow_unloggedwho = 0;
00086         mudconf.btech_explode_reactor = 1;
00087         mudconf.btech_explode_time = 120;
00088         mudconf.btech_explode_ammo = 1;
00089         mudconf.btech_explode_stop = 0;
00090         mudconf.btech_stackpole = 1;
00091         mudconf.btech_phys_use_pskill = 1;
00092         mudconf.btech_erange = 1;
00093         mudconf.btech_dig_only_fs = 0;
00094         mudconf.btech_digbonus = 3;
00095         mudconf.btech_vcrit = 2;
00096         mudconf.btech_dynspeed = 1;
00097         mudconf.btech_ic = 1;
00098         mudconf.btech_parts = 1;
00099         mudconf.btech_slowdown = 2;
00100         mudconf.btech_fasaturn = 1;
00101         mudconf.btech_fasacrit = 0;
00102         mudconf.btech_fasaadvvtolcrit = 0;
00103         mudconf.btech_fasaadvvhlcrit = 0;
00104         mudconf.btech_fasaadvvhlfire = 0;
00105         mudconf.btech_divrotordamage = 0;
00106         mudconf.btech_moddamagewithrange = 0;
00107         mudconf.btech_moddamagewithwoods = 0;
00108         mudconf.btech_hotloadaddshalfbthmod = 0;
00109         mudconf.btech_nofusionvtolfuel = 0;
00110         mudconf.btech_tankfriendly = 0;
00111         mudconf.btech_newterrain = 0;
00112         mudconf.btech_skidcliff = 0;
00113         mudconf.btech_xp_bthmod = 0;
00114         mudconf.btech_xp_missilemod = 100;
00115         mudconf.btech_xp_ammomod = 100;
00116         mudconf.btech_defaultweapdam = 5;
00117         mudconf.btech_xp_modifier = 100;
00118         mudconf.btech_defaultweapbv = 120;
00119         mudconf.btech_xp_usePilotBVMod = 1;
00120         mudconf.btech_oldxpsystem = 1;
00121         mudconf.btech_xp_vrtmod = 0;
00122         mudconf.btech_limitedrepairs = 0;
00123         mudconf.btech_newcharge = 0;
00124         mudconf.btech_tl3_charge = 0;
00125         mudconf.btech_xploss = 666;
00126         mudconf.btech_critlevel = 100;
00127         mudconf.btech_tankshield = 0;
00128         mudconf.btech_newstagger = 0;
00129         mudconf.btech_extendedmovemod = 1;
00130         mudconf.btech_stacking = 2;
00131         mudconf.btech_stackdamage = 100;
00132         mudconf.btech_mw_losmap = 1;
00133         mudconf.btech_seismic_see_stopped = 0;
00134         mudconf.btech_exile_stun_code = 0;
00135         mudconf.btech_roll_on_backwalk = 1;
00136         mudconf.btech_usedmechstore = 0;
00137         mudconf.btech_ooc_comsys = 0;
00138         mudconf.btech_idf_requires_spotter = 1;
00139         mudconf.btech_vtol_ice_causes_fire = 1;
00140         mudconf.btech_glancing_blows = 1;
00141         mudconf.btech_inferno_penalty = 0;
00142         mudconf.btech_perunit_xpmod = 1;
00143 #ifdef BT_FREETECHTIME
00144         mudconf.btech_freetechtime = 0;
00145 #endif
00146 #ifdef BT_COMPLEXREPAIRS
00147         mudconf.btech_complexrepair = 1;
00148 #endif
00149 #ifdef HUDINFO_SUPPORT
00150         mudconf.hudinfo_show_mapinfo = 0;
00151         mudconf.hudinfo_enabled;
00152 #endif
00153         mudconf.namechange_days = 60;
00154         mudconf.allow_chanlurking = 0;
00155         mudconf.afterlife_dbref = 220;
00156         mudconf.afterscen_dbref = 801;
00157         mudconf.port = 6250;
00158         mudconf.conc_port = 6251;
00159         mudconf.init_size = 1000;
00160         mudconf.guest_char = -1;
00161         mudconf.guest_nuker = 1;
00162         mudconf.number_guests = 30;
00163         StringCopy(mudconf.guest_prefix, "Guest");
00164         StringCopy(mudconf.guest_file, "text/guest.txt");
00165         StringCopy(mudconf.conn_file, "text/connect.txt");
00166         StringCopy(mudconf.conn_dir, "");
00167         StringCopy(mudconf.creg_file, "text/register.txt");
00168         StringCopy(mudconf.regf_file, "text/create_reg.txt");
00169         StringCopy(mudconf.motd_file, "text/motd.txt");
00170         StringCopy(mudconf.wizmotd_file, "text/wizmotd.txt");
00171         StringCopy(mudconf.quit_file, "text/quit.txt");
00172         StringCopy(mudconf.down_file, "text/down.txt");
00173         StringCopy(mudconf.full_file, "text/full.txt");
00174         StringCopy(mudconf.site_file, "text/badsite.txt");
00175         StringCopy(mudconf.crea_file, "text/newuser.txt");
00176         StringCopy(mudconf.help_file, "text/help.txt");
00177         StringCopy(mudconf.help_indx, "text/help.indx");
00178         StringCopy(mudconf.news_file, "text/news.txt");
00179         StringCopy(mudconf.news_indx, "text/news.indx");
00180         StringCopy(mudconf.whelp_file, "text/wizhelp.txt");
00181         StringCopy(mudconf.whelp_indx, "text/wizhelp.indx");
00182         StringCopy(mudconf.plushelp_file, "text/plushelp.txt");
00183         StringCopy(mudconf.plushelp_indx, "text/plushelp.indx");
00184         StringCopy(mudconf.wiznews_file, "text/wiznews.txt");
00185         StringCopy(mudconf.wiznews_indx, "text/wiznews.indx");
00186         StringCopy(mudconf.motd_msg, "");
00187         StringCopy(mudconf.wizmotd_msg, "");
00188         StringCopy(mudconf.downmotd_msg, "");
00189         StringCopy(mudconf.fullmotd_msg, "");
00190         StringCopy(mudconf.dump_msg, "");
00191         StringCopy(mudconf.postdump_msg, "");
00192         StringCopy(mudconf.fixed_home_msg, "");
00193         StringCopy(mudconf.fixed_tel_msg, "");
00194         StringCopy(mudconf.public_channel, "Public");
00195         StringCopy(mudconf.guests_channel, "Guests");
00196         mudconf.indent_desc = 0;
00197         mudconf.name_spaces = 1;
00198         mudconf.fork_dump = 1;
00199         mudconf.fork_vfork = 0;
00200         mudconf.have_specials = 1;
00201         mudconf.have_comsys = 1;
00202         mudconf.have_macros = 1;
00203         mudconf.have_mailer = 1;
00204         mudconf.have_zones = 1;
00205         mudconf.paranoid_alloc = 0;
00206         mudconf.sig_action = SA_DFLT;
00207         mudconf.max_players = -1;
00208         mudconf.dump_interval = 3600;
00209         mudconf.check_interval = 600;
00210         mudconf.events_daily_hour = 7;
00211         mudconf.dump_offset = 0;
00212         mudconf.check_offset = 300;
00213         mudconf.idle_timeout = 3600;
00214         mudconf.conn_timeout = 120;
00215         mudconf.idle_interval = 60;
00216         mudconf.retry_limit = 3;
00217         mudconf.output_limit = 16384;
00218         mudconf.paycheck = 0;
00219         mudconf.paystart = 0;
00220         mudconf.paylimit = 10000;
00221         mudconf.start_quota = 20;
00222         mudconf.site_chars = 25;
00223         mudconf.payfind = 0;
00224         mudconf.digcost = 10;
00225         mudconf.linkcost = 1;
00226         mudconf.opencost = 1;
00227         mudconf.createmin = 10;
00228         mudconf.createmax = 505;
00229         mudconf.killmin = 10;
00230         mudconf.killmax = 100;
00231         mudconf.killguarantee = 100;
00232         mudconf.robotcost = 1000;
00233         mudconf.pagecost = 10;
00234         mudconf.searchcost = 100;
00235         mudconf.waitcost = 10;
00236         mudconf.machinecost = 64;
00237         mudconf.exit_quota = 1;
00238         mudconf.player_quota = 1;
00239         mudconf.room_quota = 1;
00240         mudconf.thing_quota = 1;
00241         mudconf.mail_expiration = 14;
00242         mudconf.use_http = 0;
00243         mudconf.queuemax = 100;
00244         mudconf.queue_chunk = 10;
00245         mudconf.active_q_chunk = 10;
00246         mudconf.sacfactor = 5;
00247         mudconf.sacadjust = -1;
00248         mudconf.use_hostname = 1;
00249         mudconf.quotas = 0;
00250         mudconf.ex_flags = 1;
00251         mudconf.robot_speak = 1;
00252         mudconf.clone_copy_cost = 0;
00253         mudconf.pub_flags = 1;
00254         mudconf.quiet_look = 1;
00255         mudconf.exam_public = 1;
00256         mudconf.read_rem_desc = 0;
00257         mudconf.read_rem_name = 0;
00258         mudconf.sweep_dark = 0;
00259         mudconf.player_listen = 0;
00260         mudconf.quiet_whisper = 1;
00261         mudconf.dark_sleepers = 1;
00262         mudconf.see_own_dark = 1;
00263         mudconf.idle_wiz_dark = 0;
00264         mudconf.pemit_players = 0;
00265         mudconf.pemit_any = 0;
00266         mudconf.match_mine = 0;
00267         mudconf.match_mine_pl = 0;
00268         mudconf.switch_df_all = 1;
00269         mudconf.fascist_tport = 0;
00270         mudconf.terse_look = 1;
00271         mudconf.terse_contents = 1;
00272         mudconf.terse_exits = 1;
00273         mudconf.terse_movemsg = 1;
00274         mudconf.trace_topdown = 1;
00275         mudconf.trace_limit = 200;
00276         mudconf.safe_unowned = 0;
00277         /*
00278          * -- ??? Running SC on a non-SC DB may cause problems
00279          */
00280         mudconf.space_compress = 1;
00281         mudconf.start_room = 0;
00282         mudconf.start_home = -1;
00283         mudconf.default_home = -1;
00284         mudconf.master_room = -1;
00285         mudconf.player_flags.word1 = 0;
00286         mudconf.player_flags.word2 = 0;
00287         mudconf.room_flags.word1 = 0;
00288         mudconf.room_flags.word2 = 0;
00289         mudconf.exit_flags.word1 = 0;
00290         mudconf.exit_flags.word2 = 0;
00291         mudconf.thing_flags.word1 = 0;
00292         mudconf.thing_flags.word2 = 0;
00293         mudconf.robot_flags.word1 = ROBOT;
00294         mudconf.robot_flags.word2 = 0;
00295         mudconf.vattr_flags = AF_ODARK;
00296         StringCopy(mudconf.mud_name, "TinyMUX");
00297         StringCopy(mudconf.one_coin, "penny");
00298         StringCopy(mudconf.many_coins, "pennies");
00299         mudconf.timeslice = 100;
00300         mudconf.cmd_quota_max = 100;
00301         mudconf.cmd_quota_incr = 5;
00302         mudconf.control_flags = 0xffffffff;     /*
00303                                                                                  * Everything for now...
00304                                                                                  */
00305         mudconf.log_options =
00306                 LOG_ALWAYS | LOG_BUGS | LOG_SECURITY | LOG_NET | LOG_LOGIN |
00307                 LOG_DBSAVES | LOG_CONFIGMODS | LOG_SHOUTS | LOG_STARTUP |
00308                 LOG_WIZARD | LOG_PROBLEMS | LOG_PCREATES;
00309         mudconf.log_info = LOGOPT_TIMESTAMP | LOGOPT_LOC;
00310         mudconf.markdata[0] = 0x01;
00311         mudconf.markdata[1] = 0x02;
00312         mudconf.markdata[2] = 0x04;
00313         mudconf.markdata[3] = 0x08;
00314         mudconf.markdata[4] = 0x10;
00315         mudconf.markdata[5] = 0x20;
00316         mudconf.markdata[6] = 0x40;
00317         mudconf.markdata[7] = 0x80;
00318         mudconf.func_nest_lim = 50;
00319         mudconf.func_invk_lim = 2500;
00320         mudconf.ntfy_nest_lim = 20;
00321         mudconf.lock_nest_lim = 20;
00322         mudconf.parent_nest_lim = 10;
00323         mudconf.zone_nest_lim = 20;
00324         mudconf.stack_limit = 50;
00325         mudconf.cache_trim = 0;
00326         mudconf.cache_depth = CACHE_DEPTH;
00327         mudconf.cache_width = CACHE_WIDTH;
00328         mudconf.cache_names = 1;
00329 
00330         mudstate.events_flag = 0;
00331         mudstate.events_lasthour = -1;
00332         mudstate.initializing = 0;
00333         mudstate.panicking = 0;
00334         mudstate.dumping = 0;
00335         mudstate.logging = 0;
00336         mudstate.epoch = 0;
00337         mudstate.generation = 0;
00338         mudstate.curr_player = NOTHING;
00339         mudstate.curr_enactor = NOTHING;
00340         mudstate.shutdown_flag = 0;
00341         mudstate.attr_next = A_USER_START;
00342         mudstate.debug_cmd = (char *) "< init >";
00343         StringCopy(mudstate.doing_hdr, "Doing");
00344         mudstate.access_list = NULL;
00345         mudstate.suspect_list = NULL;
00346         mudstate.qhead = NULL;
00347         mudstate.qtail = NULL;
00348         mudstate.qwait = NULL;
00349         mudstate.qsemfirst = NULL;
00350         mudstate.qsemlast = NULL;
00351         mudstate.badname_head = NULL;
00352         mudstate.mstat_ixrss[0] = 0;
00353         mudstate.mstat_ixrss[1] = 0;
00354         mudstate.mstat_idrss[0] = 0;
00355         mudstate.mstat_idrss[1] = 0;
00356         mudstate.mstat_isrss[0] = 0;
00357         mudstate.mstat_isrss[1] = 0;
00358         mudstate.mstat_secs[0] = 0;
00359         mudstate.mstat_secs[1] = 0;
00360         mudstate.mstat_curr = 0;
00361         mudstate.iter_alist.data = NULL;
00362         mudstate.iter_alist.len = 0;
00363         mudstate.iter_alist.next = NULL;
00364         mudstate.mod_alist = NULL;
00365         mudstate.mod_size = 0;
00366         mudstate.mod_al_id = NOTHING;
00367         mudstate.olist = NULL;
00368         mudstate.min_size = 0;
00369         mudstate.db_top = 0;
00370         mudstate.db_size = 0;
00371         mudstate.mail_db_top = 0;
00372         mudstate.mail_db_size = 0;
00373         mudstate.mail_freelist = 0;
00374         mudstate.freelist = NOTHING;
00375         mudstate.markbits = NULL;
00376         mudstate.func_nest_lev = 0;
00377         mudstate.func_invk_ctr = 0;
00378         mudstate.ntfy_nest_lev = 0;
00379         mudstate.lock_nest_lev = 0;
00380         mudstate.zone_nest_num = 0;
00381         mudstate.inpipe = 0;
00382         mudstate.pout = NULL;
00383         mudstate.poutnew = NULL;
00384         mudstate.poutbufc = NULL;
00385         mudstate.poutobj = -1;
00386         for(i = 0; i < MAX_GLOBAL_REGS; i++)
00387                 mudstate.global_regs[i] = NULL;
00388 #ifdef SQL_SUPPORT
00389         memset(mudconf.sqlDB_type_A, '\0', 128);
00390         memset(mudconf.sqlDB_hostname_A, '\0', 128);
00391         memset(mudconf.sqlDB_username_A, '\0', 128);
00392         memset(mudconf.sqlDB_password_A, '\0', 128);
00393         memset(mudconf.sqlDB_dbname_A, '\0', 128);
00394         memset(mudconf.sqlDB_type_B, '\0', 128);
00395         memset(mudconf.sqlDB_hostname_B, '\0', 128);
00396         memset(mudconf.sqlDB_username_B, '\0', 128);
00397         memset(mudconf.sqlDB_password_B, '\0', 128);
00398         memset(mudconf.sqlDB_dbname_B, '\0', 128);
00399         memset(mudconf.sqlDB_type_C, '\0', 128);
00400         memset(mudconf.sqlDB_hostname_C, '\0', 128);
00401         memset(mudconf.sqlDB_username_C, '\0', 128);
00402         memset(mudconf.sqlDB_password_C, '\0', 128);
00403         memset(mudconf.sqlDB_dbname_C, '\0', 128);
00404         memset(mudconf.sqlDB_type_D, '\0', 128);
00405         memset(mudconf.sqlDB_hostname_D, '\0', 128);
00406         memset(mudconf.sqlDB_username_D, '\0', 128);
00407         memset(mudconf.sqlDB_password_D, '\0', 128);
00408         memset(mudconf.sqlDB_dbname_D, '\0', 128);
00409         memset(mudconf.sqlDB_type_E, '\0', 128);
00410         memset(mudconf.sqlDB_hostname_E, '\0', 128);
00411         memset(mudconf.sqlDB_username_E, '\0', 128);
00412         memset(mudconf.sqlDB_password_E, '\0', 128);
00413         memset(mudconf.sqlDB_dbname_E, '\0', 128);
00414         mudconf.sqlDB_init_A = 0;
00415         mudconf.sqlDB_init_B = 0;
00416         mudconf.sqlDB_init_C = 0;
00417         mudconf.sqlDB_init_D = 0;
00418         mudconf.sqlDB_init_E = 0;
00419         mudconf.sqlDB_max_queries = 4;
00420         memset(mudconf.sqlDB_mysql_socket, '\0', 128);
00421 #endif
00422         mudconf.exit_parent = 0;
00423         mudconf.room_parent = 0;
00424 }

int cf_read ( char *  fn  ) 

Definition at line 1660 of file conf.c.

References cf_include(), confdata::config_file, confdata::crashdb, confdata::gdbm, confdata::indb, statedata::initializing, mudconf, mudstate, confdata::outdb, and StringCopy.

Referenced by main().

01661 {
01662         int retval;
01663 
01664         StringCopy(mudconf.config_file, fn);
01665         mudstate.initializing = 1;
01666         retval = cf_include(NULL, fn, 0, 0, (char *) "init");
01667         mudstate.initializing = 0;
01668 
01669         /*
01670          * Fill in missing DB file names
01671          */
01672 
01673         if(!*mudconf.outdb) {
01674                 StringCopy(mudconf.outdb, mudconf.indb);
01675                 strcat(mudconf.outdb, ".out");
01676         }
01677         if(!*mudconf.crashdb) {
01678                 StringCopy(mudconf.crashdb, mudconf.indb);
01679                 strcat(mudconf.crashdb, ".CRASH");
01680         }
01681         if(!*mudconf.gdbm) {
01682                 StringCopy(mudconf.gdbm, mudconf.indb);
01683                 strcat(mudconf.gdbm, ".gdbm");
01684         }
01685         return retval;
01686 }

int check_filter ( dbref  object,
dbref  player,
int  filter,
const char *  msg 
)

Notifies the object target of the message msg, and optionally notify the contents, neighbors, and location also.

Definition at line 329 of file game.c.

References alloc_lbuf, atr_pget(), EV_EVAL, EV_FIGNORE, EV_STRIP, EV_TOP, exec(), free_lbuf, parse_to(), and quick_wild().

Referenced by notify_checked().

00330 {
00331         int aflags;
00332         dbref aowner;
00333         char *buf, *nbuf, *cp, *dp, *str;
00334 
00335         buf = atr_pget(object, filter, &aowner, &aflags);
00336         if(!*buf) {
00337                 free_lbuf(buf);
00338                 return (1);
00339         }
00340         nbuf = dp = alloc_lbuf("check_filter");
00341         str = buf;
00342         exec(nbuf, &dp, 0, object, player, EV_FIGNORE | EV_EVAL | EV_TOP, &str,
00343                  (char **) NULL, 0);
00344         *dp = '\0';
00345         dp = nbuf;
00346         free_lbuf(buf);
00347         do {
00348                 cp = parse_to(&dp, ',', EV_STRIP);
00349                 if(quick_wild(cp, (char *) msg)) {
00350                         free_lbuf(nbuf);
00351                         return (0);
00352                 }
00353         } while (dp != NULL);
00354         free_lbuf(nbuf);
00355         return (1);
00356 }

void close_sockets ( int  emergency,
char *  message 
)

Definition at line 716 of file bsd.c.

References DESC_SAFEITER_ALL, descriptor_data::descriptor, dnschild_kill(), dprintk, listen_sock_ev, log_perror(), mux_bound_socket, descriptor_data::outstanding_dnschild_query, queue_string(), queue_write(), R_GOING_DOWN, shutdownsock(), descriptor_data::sock_buff, and descriptor_data::sock_ev.

Referenced by emergency_shutdown(), and main().

00717 {
00718         DESC *d, *dnext;
00719 
00720         DESC_SAFEITER_ALL(d, dnext) {
00721                 if(emergency) {
00722                         write(d->descriptor, message, strlen(message));
00723                         if(shutdown(d->descriptor, 2) < 0)
00724                                 log_perror("NET", "FAIL", NULL, "shutdown");
00725                         dprintk("shutting down fd %d", d->descriptor);
00726                         dprintk("output evbuffer misalign: %d, totallen: %d, off: %d",
00727                                         d->sock_buff->output->misalign,
00728                                         d->sock_buff->output->totallen,
00729                                         d->sock_buff->output->off);
00730                         fsync(d->descriptor);
00731                         if(d->outstanding_dnschild_query)
00732                                 dnschild_kill(d->outstanding_dnschild_query);
00733             d->outstanding_dnschild_query = NULL;
00734                         event_loop(EVLOOP_ONCE);
00735                         event_del(&d->sock_ev);
00736                         bufferevent_free(d->sock_buff);
00737                         close(d->descriptor);
00738                 } else {
00739                         queue_string(d, message);
00740                         queue_write(d, "\r\n", 2);
00741                         shutdownsock(d, R_GOING_DOWN);
00742                 }
00743         }
00744         close(mux_bound_socket);
00745         event_del(&listen_sock_ev);
00746 }

char* colorize ( dbref  player,
char *  from 
)

Definition at line 1411 of file glue.c.

Referenced by mecha_notify(), and notify_checked().

01412 {
01413         char *to;
01414         char *p, *q;
01415         int color_wanted = 0;
01416         int i;
01417         int cnt;
01418 
01419         q = to = alloc_lbuf("colorize");
01420 #if 1
01421         for(p = from; *p; p++) {
01422                 if(*p == '%' && *(p + 1) == 'c') {
01423                         p += 2;
01424                         if(*p <= 0)
01425                                 i = DEFAULT;
01426                         else
01427                                 i = colorc_reverse[(short) *p];
01428                         if(i == DEFAULT && *p != 'n')
01429                                 p--;
01430                         color_wanted &= ~color_table[i].negbit;
01431                         color_wanted |= color_table[i].bit;
01432                 } else {
01433                         if(color_wanted && Ansi(player)) {
01434                                 *q = 0;
01435                                 /* Generate efficient color string */
01436                                 strcpy(q, ANSI_START);
01437                                 q += ANSI_START_LEN;
01438                                 cnt = 0;
01439                                 for(i = 0; color_table[i].string; i++)
01440                                         if(color_wanted & color_table[i].bit &&
01441                                            color_table[i].bit != color_table[i].negbit) {
01442                                                 if(cnt)
01443                                                         *q++ = ';';
01444                                                 strcpy(q, color_table[i].sstring);
01445                                                 q += strlen(color_table[i].sstring);
01446                                                 cnt++;
01447                                         }
01448                                 strcpy(q, ANSI_END);
01449                                 q += ANSI_END_LEN;
01450                                 color_wanted = 0;
01451                         }
01452                         *q++ = *p;
01453                 }
01454         }
01455         *q = 0;
01456         if(color_wanted && Ansi(player)) {
01457                 /* Generate efficient color string */
01458                 strcpy(q, ANSI_START);
01459                 q += ANSI_START_LEN;
01460                 cnt = 0;
01461                 for(i = 0; color_table[i].string; i++)
01462                         if(color_wanted & color_table[i].bit &&
01463                            color_table[i].bit != color_table[i].negbit) {
01464                                 if(cnt)
01465                                         *q++ = ';';
01466                                 strcpy(q, color_table[i].sstring);
01467                                 q += strlen(color_table[i].sstring);
01468                                 cnt++;
01469                         }
01470                 strcpy(q, ANSI_END);
01471                 q += ANSI_END_LEN;
01472                 color_wanted = 0;
01473         }
01474 #else
01475         strcpy(to, p);
01476 #endif
01477         return to;
01478 }

static char* dflt_from_msg ( dbref  sender,
dbref  sendloc 
) [static]

Definition at line 386 of file game.c.

References alloc_lbuf, Good_obj, Name(), safe_chr, and safe_str.

Referenced by notify_checked().

00387 {
00388         char *tp, *tbuff;
00389 
00390         tp = tbuff = alloc_lbuf("notify_checked.fwdlist");
00391         safe_str((char *) "From ", tbuff, &tp);
00392         if(Good_obj(sendloc))
00393                 safe_str(Name(sendloc), tbuff, &tp);
00394         else
00395                 safe_str(Name(sender), tbuff, &tp);
00396         safe_chr(',', tbuff, &tp);
00397         *tp = '\0';
00398         return tbuff;
00399 }

void do_dbck ( dbref  player,
dbref  cause,
int  key 
)

Perform a database consistency check and clean up damage.

Definition at line 1431 of file object.c.

References check_contents_chains(), check_dead_refs(), check_exit_chains(), check_floating(), check_type, make_freelist(), NOTHING, notify, purge_going(), and Quiet.

Referenced by dispatch(), and main().

01432 {
01433         check_type = key;
01434         make_freelist();
01435         check_dead_refs();
01436         check_exit_chains();
01437         check_contents_chains();
01438         check_floating();
01439         purge_going();
01440 
01441         if(player != NOTHING) {
01442                 if(!Quiet(player))
01443                         notify(player, "Done.");
01444         }
01445 }

void do_dump ( dbref  player,
dbref  cause,
int  key 
)

Definition at line 83 of file game.c.

References do_dump_optimize(), DUMP_OPTIMIZE, fork_and_dump(), and notify.

00084 {
00085         notify(player, "Dumping...");
00086 
00087         /*
00088          * DUMP_OPTIMIZE takes advantage of a feature of GDBM to compress  
00089          * unused space in the database, and will not be very useful
00090          * except sparingly, perhaps done every month or so. 
00091          */
00092 
00093         if(key & DUMP_OPTIMIZE)
00094                 do_dump_optimize(player, cause, key);
00095         else
00096                 fork_and_dump(key);
00097 }

void do_dump_optimize ( dbref  ,
dbref  ,
int   
)

Definition at line 99 of file game.c.

References raw_notify().

Referenced by do_dump().

00100 {
00101         raw_notify(player, "Database is memory based.");
00102 }

void do_readcache ( dbref  player,
dbref  cause,
int  key 
)

Definition at line 1183 of file game.c.

References fcache_load(), and helpindex_load().

01184 {
01185         helpindex_load(player);
01186         fcache_load(player);
01187 }

void do_second ( void   ) 

Definition at line 862 of file cque.c.

00863 {
00864         BQUE *trail, *point, *next;
00865         char *cmdsave;
00866 
00867         /*
00868          * move contents of low priority queue onto end of normal one this
00869          * helps to keep objects from getting out of control since
00870          * its affects on other objects happen only after one
00871          * second  this should allow @halt to be type before
00872          * getting blown away  by scrolling text 
00873          */
00874 
00875         if((mudconf.control_flags & CF_DEQUEUE) == 0)
00876                 return;
00877 
00878         cmdsave = mudstate.debug_cmd;
00879         mudstate.debug_cmd = (char *) "< do_second >";
00880 
00881         /*
00882          * Note: the point->waittime test would be 0 except the command is
00883          * being put in the low priority queue to be done in one
00884          * second anyways 
00885          */
00886 
00887         /*
00888          * Check the semaphore queue for expired timed-waits 
00889          */
00890 
00891         for(point = mudstate.qsemfirst, trail = NULL; point; point = next) {
00892                 if(point->waittime == 0) {
00893                         next = (trail = point)->next;
00894                         continue;                       /*
00895                                                                  * Skip if not timed-wait 
00896                                                                  */
00897                 }
00898                 if(point->waittime <= mudstate.now) {
00899                         if(trail != NULL)
00900                                 trail->next = next = point->next;
00901                         else
00902                                 mudstate.qsemfirst = next = point->next;
00903                         if(point == mudstate.qsemlast)
00904                                 mudstate.qsemlast = trail;
00905                         add_to(point->sem, -1, point->attr);
00906                         point->sem = NOTHING;
00907             point->waittime = 0;
00908                         printk("promoting, %d/%s", point->player, point->comm);
00909                         cque_enqueue(point->player, point);
00910                 } else
00911                         next = (trail = point)->next;
00912         }
00913         mudstate.debug_cmd = cmdsave;
00914         return;
00915 }

void do_shutdown ( dbref  player,
dbref  cause,
int  key,
char *  message 
)

Definition at line 788 of file game.c.

References confdata::crashdb, DUMP_CRASHED, dump_database_internal(), emergency_shutdown(), ENDLOG, LOG_ALWAYS, log_name(), log_text(), mudconf, mudstate, Name(), NOTHING, Owner, pcache_sync(), raw_broadcast(), ResetSpecialObjects(), SHUTDN_PANIC, statedata::shutdown_flag, STARTLOG, and confdata::status_file.

Referenced by signal_TERM().

00789 {
00790         FILE *fs;
00791 
00792         ResetSpecialObjects();
00793         if(player != NOTHING) {
00794                 raw_broadcast(0, "Game: Shutdown by %s", Name(Owner(player)));
00795                 STARTLOG(LOG_ALWAYS, "WIZ", "SHTDN") {
00796                         log_text((char *) "Shutdown by ");
00797                         log_name(player);
00798                         ENDLOG;
00799                 }
00800         } else {
00801                 raw_broadcast(0, "Game: Fatal Error: %s", message);
00802                 STARTLOG(LOG_ALWAYS, "WIZ", "SHTDN") {
00803                         log_text((char *) "Fatal error: ");
00804                         log_text(message);
00805                         ENDLOG;
00806                 }
00807         }
00808         STARTLOG(LOG_ALWAYS, "WIZ", "SHTDN") {
00809                 log_text((char *) "Shutdown status: ");
00810                 log_text(message);
00811                 ENDLOG;
00812         }
00813 
00814         fs = fopen(mudconf.status_file, "w");
00815         fprintf(fs, "%s\n", message);
00816         fclose(fs);
00817 
00818         /*
00819          * Do we perform a normal or an emergency shutdown?  Normal shutdown
00820          * * * * * is handled by exiting the main loop in shovechars,
00821          * emergency  * * * * shutdown is done here. 
00822          */
00823 
00824         if(key & SHUTDN_PANIC) {
00825 
00826                 /*
00827                  * Close down the network interface 
00828                  */
00829 
00830                 emergency_shutdown();
00831 
00832                 /*
00833                  * Close the attribute text db and dump the header db 
00834                  */
00835 
00836                 pcache_sync();
00837                 STARTLOG(LOG_ALWAYS, "DMP", "PANIC") {
00838                         log_text((char *) "Panic dump: ");
00839                         log_text(mudconf.crashdb);
00840                         ENDLOG;
00841                 } dump_database_internal(DUMP_CRASHED);
00842 
00843                 STARTLOG(LOG_ALWAYS, "DMP", "DONE") {
00844                         log_text((char *) "Panic dump complete: ");
00845                         log_text(mudconf.crashdb);
00846                         ENDLOG;
00847                 }
00848         }
00849         /*
00850          * Set up for normal shutdown 
00851          */
00852 
00853         mudstate.shutdown_flag = 1;
00854         event_loopexit(NULL);
00855         return;
00856 }

void dump_database ( void   ) 

Definition at line 979 of file game.c.

References alloc_mbuf, dump_database_internal(), DUMP_NORMAL, statedata::dumping, ENDLOG, statedata::epoch, free_mbuf, LOG_DBSAVES, log_text(), mudconf, mudstate, confdata::outdb, pcache_sync(), and STARTLOG.

Referenced by main().

00980 {
00981         char *buff;
00982 
00983         mudstate.epoch++;
00984         mudstate.dumping = 1;
00985         buff = alloc_mbuf("dump_database");
00986         sprintf(buff, "%s.#%d#", mudconf.outdb, mudstate.epoch);
00987         STARTLOG(LOG_DBSAVES, "DMP", "DUMP") {
00988                 log_text((char *) "Dumping: ");
00989                 log_text(buff);
00990                 ENDLOG;
00991         } pcache_sync();
00992 
00993         dump_database_internal(DUMP_NORMAL);
00994         STARTLOG(LOG_DBSAVES, "DMP", "DONE") {
00995                 log_text((char *) "Dump complete: ");
00996                 log_text(buff);
00997                 ENDLOG;
00998         } free_mbuf(buff);
00999 
01000         mudstate.dumping = 0;
01001 }

void dump_database_internal ( int   ) 

void fork_and_dump ( int   ) 

Definition at line 1003 of file game.c.

References alloc_mbuf, check_mail_expiration(), dprintk, dump_database_internal(), confdata::dump_msg, DUMP_NORMAL, DUMP_STRUCT, statedata::dumping, statedata::epoch, LOG_DBSAVES, log_error(), mudconf, mudstate, confdata::outdb, pcache_sync(), confdata::postdump_msg, raw_broadcast(), and unbind_signals().

Referenced by dispatch(), and do_dump().

01004 {
01005         char *buff;
01006 
01007         if(*mudconf.dump_msg)
01008                 raw_broadcast(0, "%s", mudconf.dump_msg);
01009 
01010         check_mail_expiration();
01011         mudstate.epoch++;
01012         mudstate.dumping = 1;
01013         buff = alloc_mbuf("fork_and_dump");
01014         sprintf(buff, "%s.#%d#", mudconf.outdb, mudstate.epoch);
01015    
01016     log_error(LOG_DBSAVES, "DMP", "CHKPT", "Saving database: %s", buff);
01017     
01018     pcache_sync();
01019     
01020         if(!key || (key & DUMP_STRUCT)) {
01021                 if(!fork()) {
01022             dprintk("child database write process starting.");
01023                         unbind_signals();
01024                         dump_database_internal(DUMP_NORMAL);
01025             dprintk("child database write process finished.");
01026             exit(0);
01027                 }
01028         }
01029 
01030         mudstate.dumping = 0;
01031 
01032         if(*mudconf.postdump_msg)
01033                 raw_broadcast(0, "%s", mudconf.postdump_msg);
01034 }

int Hearer ( dbref  thing  ) 

Definition at line 1130 of file game.c.

References A_LISTEN, AF_NOPROG, alloc_lbuf, AMATCH_LISTEN, atr_get_str(), atr_head(), atr_next(), atr_num(), Connected, attr::flags, free_lbuf, statedata::inpipe, Monitor, mudstate, statedata::poutobj, and Puppet.

Referenced by do_examine(), do_set(), fh_hear_bit(), fun_set(), look_in(), look_simple(), move_via_exit(), move_via_generic(), move_via_teleport(), and set_attr_internal().

01131 {
01132         char *as, *buff, *s;
01133         dbref aowner;
01134         int attr, aflags;
01135         ATTR *ap;
01136 
01137         if(mudstate.inpipe && (thing == mudstate.poutobj))
01138                 return 1;
01139 
01140         if(Connected(thing) || Puppet(thing))
01141                 return 1;
01142 
01143         if(Monitor(thing))
01144                 buff = alloc_lbuf("Hearer");
01145         else
01146                 buff = NULL;
01147         for(attr = atr_head(thing, &as); attr; attr = atr_next(&as)) {
01148                 if(attr == A_LISTEN) {
01149                         if(buff)
01150                                 free_lbuf(buff);
01151                         return 1;
01152                 }
01153                 if(Monitor(thing)) {
01154                         ap = atr_num(attr);
01155                         if(!ap || (ap->flags & AF_NOPROG))
01156                                 continue;
01157 
01158                         atr_get_str(buff, thing, attr, &aowner, &aflags);
01159 
01160                         /*
01161                          * Make sure we can execute it 
01162                          */
01163 
01164                         if((buff[0] != AMATCH_LISTEN) || (aflags & AF_NOPROG))
01165                                 continue;
01166 
01167                         /*
01168                          * Make sure there's a : in it 
01169                          */
01170 
01171                         for(s = buff + 1; *s && (*s != ':'); s++);
01172                         if(s) {
01173                                 free_lbuf(buff);
01174                                 return 1;
01175                         }
01176                 }
01177         }
01178         if(buff)
01179                 free_lbuf(buff);
01180         return 0;
01181 }

void init_attrtab ( void   ) 

Definition at line 772 of file db.c.

References alloc_sbuf, anum_extend(), anum_set, attr, statedata::attr_name_htab, free_sbuf, hashadd(), hashinit(), mudstate, attr::name, attr::number, and ToUpper.

Referenced by main().

00773 {
00774         ATTR *a;
00775         char *buff, *p, *q;
00776 
00777         hashinit(&mudstate.attr_name_htab, 512);
00778         buff = alloc_sbuf("init_attrtab");
00779         for(a = attr; a->number; a++) {
00780                 anum_extend(a->number);
00781                 anum_set(a->number, a);
00782                 for(p = buff, q = (char *) a->name; *q; p++, q++)
00783                         *p = ToUpper(*q);
00784                 *p = '\0';
00785                 hashadd(buff, (int *) a, &mudstate.attr_name_htab);
00786         }
00787         free_sbuf(buff);
00788 }

void init_chantab ( void   ) 

Definition at line 41 of file comsys.c.

00042 {
00043         hashinit(&mudstate.channel_htab, 30 * HASH_FACTOR);
00044 }

void init_cmdtab ( void   ) 

Definition at line 693 of file command.c.

References AF_MDARK, AF_NOCMD, AF_WIZARD, alloc_sbuf, CA_NO_GUEST, CA_NO_SLAVE, CA_WIZARD, cmdentry::callseq, cmdentry::cmdname, statedata::command_htab, CS_TWO_ARG, do_setattr(), cmdentry::extra, attr::flags, cmdentry::handler, HASH_FACTOR, hashadd(), hashinit(), mudstate, attr::name, attr::number, cmdentry::perms, strsave(), cmdentry::switches, and ToLower.

Referenced by main().

00694 {
00695         CMDENT *cp;
00696         ATTR *ap;
00697         char *p, *q;
00698         char *cbuff;
00699 
00700         hashinit(&mudstate.command_htab, 250 * HASH_FACTOR);
00701 
00702         /*
00703          * Load attribute-setting commands 
00704          */
00705 
00706         cbuff = alloc_sbuf("init_cmdtab");
00707         for(ap = attr; ap->name; ap++) {
00708                 if((ap->flags & AF_NOCMD) == 0) {
00709                         p = cbuff;
00710                         *p++ = '@';
00711                         for(q = (char *) ap->name; *q; p++, q++)
00712                                 *p = ToLower(*q);
00713                         *p = '\0';
00714                         cp = (CMDENT *) malloc(sizeof(CMDENT));
00715                         cp->cmdname = (char *) strsave(cbuff);
00716                         cp->perms = CA_NO_GUEST | CA_NO_SLAVE;
00717                         cp->switches = NULL;
00718                         if(ap->flags & (AF_WIZARD | AF_MDARK)) {
00719                                 cp->perms |= CA_WIZARD;
00720                         }
00721                         cp->extra = ap->number;
00722                         cp->callseq = CS_TWO_ARG;
00723                         cp->handler = do_setattr;
00724                         hashadd(cp->cmdname, (int *) cp, &mudstate.command_htab);
00725                 }
00726         }
00727         free_sbuf(cbuff);
00728 
00729         /*
00730          * Load the builtin commands 
00731          */
00732 
00733         for(cp = command_table; cp->cmdname; cp++)
00734                 hashadd(cp->cmdname, (int *) cp, &mudstate.command_htab);
00735 
00736         set_prefix_cmds();
00737 
00738         goto_cmdp = (CMDENT *) hashfind("goto", &mudstate.command_htab);
00739 }

void init_functab ( void   ) 

Definition at line 5808 of file functions.c.

05809 {
05810         FUN *fp;
05811         char *buff, *cp, *dp;
05812 
05813         buff = alloc_sbuf("init_functab");
05814         hashinit(&mudstate.func_htab, 100 * HASH_FACTOR);
05815         for(fp = flist; fp->name; fp++) {
05816                 cp = (char *) fp->name;
05817                 dp = buff;
05818                 while (*cp) {
05819                         *dp = ToLower(*cp);
05820                         cp++;
05821                         dp++;
05822                 }
05823                 *dp = '\0';
05824                 hashadd(buff, (int *) fp, &mudstate.func_htab);
05825         }
05826         free_sbuf(buff);
05827         ufun_head = NULL;
05828         hashinit(&mudstate.ufunc_htab, 11);
05829 }

void init_logout_cmdtab ( void   ) 

Definition at line 1145 of file netcommon.c.

References name_table::flag, HASH_FACTOR, hashadd(), hashinit(), statedata::logout_cmd_htab, logout_cmdtable, mudstate, and name_table::name.

Referenced by main().

01146 {
01147         NAMETAB *cp;
01148 
01149         /*
01150          * Make the htab bigger than the number of entries so that we find
01151          * things on the first check.  Remember that the admin can add
01152          * aliases. 
01153          */
01154 
01155         hashinit(&mudstate.logout_cmd_htab, 3 * HASH_FACTOR);
01156         for(cp = logout_cmdtable; cp->flag; cp++)
01157                 hashadd(cp->name, (int *) cp, &mudstate.logout_cmd_htab);
01158 }

void init_mactab ( void   ) 

Definition at line 36 of file macro.c.

References macroentry::cmdname, HASH_FACTOR, hashadd(), hashinit(), statedata::macro_htab, macro_table, and mudstate.

Referenced by main().

00037 {
00038         MACENT *mp;
00039 
00040         hashinit(&mudstate.macro_htab, 5 * HASH_FACTOR);
00041 
00042         for(mp = macro_table; mp->cmdname; mp++)
00043                 hashadd(mp->cmdname, (int *) mp, &mudstate.macro_htab);
00044 }

static void init_rlimit ( void   )  [static]

Definition at line 1410 of file game.c.

References alloc_lbuf, free_lbuf, and log_perror().

Referenced by main().

01411 {
01412 #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
01413         struct rlimit *rlp;
01414 
01415         rlp = (struct rlimit *) alloc_lbuf("rlimit");
01416 
01417         if(getrlimit(RLIMIT_NOFILE, rlp)) {
01418                 log_perror("RLM", "FAIL", NULL, "getrlimit()");
01419                 free_lbuf(rlp);
01420                 return;
01421         }
01422         rlp->rlim_cur = rlp->rlim_max;
01423         if(setrlimit(RLIMIT_NOFILE, rlp))
01424                 log_perror("RLM", "FAIL", NULL, "setrlimit()");
01425         free_lbuf(rlp);
01426 
01427 #endif /*
01428             * HAVE_SETRLIMIT 
01429             */
01430 }

void init_timer ( void   ) 

Definition at line 32 of file timer.c.

References statedata::check_counter, confdata::check_interval, confdata::check_offset, statedata::dump_counter, confdata::dump_interval, confdata::dump_offset, statedata::events_counter, statedata::idle_counter, confdata::idle_interval, statedata::mstats_counter, mudconf, mudstate, statedata::now, time(), timer_callback(), timer_event, and tv.

Referenced by main().

00033 {
00034         mudstate.now = time(NULL);
00035         mudstate.dump_counter =
00036                 ((mudconf.dump_offset ==
00037                   0) ? mudconf.dump_interval : mudconf.dump_offset) + mudstate.now;
00038         mudstate.check_counter =
00039                 ((mudconf.check_offset ==
00040                   0) ? mudconf.check_interval : mudconf.check_offset) + mudstate.now;
00041         mudstate.idle_counter = mudconf.idle_interval + mudstate.now;
00042         mudstate.mstats_counter = 15 + mudstate.now;
00043         mudstate.events_counter = 900 + mudstate.now;
00044         evtimer_set(&timer_event, timer_callback, NULL);
00045         evtimer_add(&timer_event, &tv);
00046 }

void init_version ( void   ) 

Definition at line 82 of file version.c.

References ENDLOG, LOG_ALWAYS, log_text(), mudstate, mux_version, STARTLOG, strlcpy(), and statedata::version.

Referenced by main().

00083 {
00084     strlcpy(mudstate.version, mux_version, sizeof(mudstate.version));
00085 
00086         STARTLOG(LOG_ALWAYS, "INI", "START") {
00087                 log_text((char *) "Starting: ");
00088                 log_text(mudstate.version);
00089                 ENDLOG;
00090         } STARTLOG(LOG_ALWAYS, "INI", "START") {
00091                 log_text((char *) "Build date: ");
00092 
00093                 log_text((char *) MUX_BUILD_DATE);
00094                 ENDLOG;
00095         }
00096 }

int list_check ( dbref  thing,
dbref  player,
char  type,
char *  str,
int  check_parent 
)

match a list of things, using the no_command flag

Definition at line 1111 of file game.c.

References atr_match(), statedata::db_top, mudstate, Next, No_Command, and NOTHING.

Referenced by process_command().

01113 {
01114         int match, limit;
01115 
01116         match = 0;
01117         limit = mudstate.db_top;
01118         while (thing != NOTHING) {
01119                 if((thing != player) && (!(No_Command(thing)))) {
01120                         if(atr_match(thing, player, type, str, check_parent) > 0)
01121                                 match = 1;
01122                 }
01123                 thing = Next(thing);
01124                 if(--limit < 0)
01125                         return match;
01126         }
01127         return match;
01128 }

static int load_game ( void   )  [static]

Definition at line 1036 of file game.c.

References confdata::commac_db, confdata::compress_db, db_read(), ENDLOG, confdata::have_comsys, confdata::have_macros, confdata::have_mailer, confdata::have_specials, confdata::indb, load_comsys_and_macros(), load_mail(), LoadSpecialObjects(), LOG_ALWAYS, LOG_STARTUP, log_text(), confdata::mail_db, mudconf, STARTLOG, StringCopy, tprintf(), and confdata::uncompress.

Referenced by main().

01037 {
01038         FILE *f;
01039         int compressed;
01040         char infile[256];
01041         struct stat statbuf;
01042         int db_format, db_version, db_flags;
01043 
01044         f = NULL;
01045         compressed = 0;
01046         if(mudconf.compress_db) {
01047                 StringCopy(infile, mudconf.indb);
01048                 strcat(infile, ".gz");
01049                 if(stat(infile, &statbuf) == 0) {
01050                         if((f = popen(tprintf(" %s < %s", mudconf.uncompress,
01051                                                                   infile), "r")) != NULL)
01052                                 compressed = 1;
01053                 }
01054         }
01055         if(compressed == 0) {
01056                 StringCopy(infile, mudconf.indb);
01057                 if((f = fopen(mudconf.indb, "r")) == NULL)
01058                         return -1;
01059         }
01060         /*
01061          * ok, read it in 
01062          */
01063 
01064         STARTLOG(LOG_STARTUP, "INI", "LOAD") {
01065                 log_text((char *) "Loading: ");
01066                 log_text(infile);
01067                 ENDLOG;
01068         };
01069         if(db_read(f, &db_format, &db_version, &db_flags) < 0) {
01070                 STARTLOG(LOG_ALWAYS, "INI", "FATAL") {
01071                         log_text((char *) "Error loading ");
01072                         log_text(infile);
01073                         ENDLOG;
01074                 }
01075                 if(compressed)
01076                         pclose(f);
01077                 else
01078                         fclose(f);
01079                 return -1;
01080         }
01081         if(compressed)
01082                 pclose(f);
01083         else
01084                 fclose(f);
01085 
01086         if(mudconf.have_comsys || mudconf.have_macros)
01087                 load_comsys_and_macros(mudconf.commac_db);
01088 
01089         /* Load the mecha stuff.. */
01090         if(mudconf.have_specials)
01091                 LoadSpecialObjects();
01092 
01093         if(mudconf.have_mailer)
01094                 if((f = fopen(mudconf.mail_db, "r"))) {
01095                         load_mail(f);
01096                         fclose(f);
01097                 }
01098         STARTLOG(LOG_STARTUP, "INI", "LOAD") {
01099                 log_text((char *) "Load complete.");
01100                 ENDLOG;
01101         }
01102         /*
01103          * everything ok 
01104          */
01105         return (0);
01106 }

int main ( int  argc,
char *  argv[] 
)

Definition at line 1245 of file game.c.

References alloc_lbuf, bind_signals(), cf_init(), cf_read(), close_sockets(), CONF_FILE, corrupt, db_free(), db_make_minimal(), desc_cmp(), dnschild_init(), do_dbck(), dump_database(), ENDLOG, fcache_init(), HASH_FACTOR, hashinit(), hashreset(), helpindex_init(), confdata::indb, init_attrtab(), init_chantab(), init_cmdtab(), init_flagtab(), init_functab(), init_logout_cmdtab(), init_mactab(), init_powertab(), init_rlimit(), init_timer(), init_version(), LBUF_SIZE, load_game(), load_restart_db(), load_restart_db_xdr(), LOG_ALWAYS, log_text(), logcache_destruct(), logcache_init(), MAX_GLOBAL_REGS, mudconf, mudstate, nhashinit(), nhashreset(), NOTHING, pcache_init(), confdata::port, process_preload(), rb_init(), shovechars(), sqlchild_destruct(), sqlchild_init(), srandom, STARTLOG, tcache_init(), time(), and vattr_init().

01246 {
01247         int mindb;
01248 
01249         if((argc > 2) && (!strcmp(argv[1], "-s") && (argc > 3))) {
01250                 fprintf(stderr, "Usage: %s [-s] [config-file]\n", argv[0]);
01251                 exit(1);
01252         }
01253 
01254         event_init();
01255 
01256 #if defined(HAVE_IEEEFP_H) && defined(HAVE_SYS_UCONTEXT_H)
01257         /*
01258          * Inhibit IEEE fp exception on overflow 
01259          */
01260 
01261         fpsetmask(fpgetmask() & ~FP_X_OFL);
01262 #endif
01263 
01264         mindb = 0;                                      /* Are we creating a new db? */
01265         corrupt = 0;                            /* Database isn't corrupted. */
01266     memset(&mudstate, 0, sizeof(mudstate));
01267         time(&mudstate.start_time);
01268         time(&mudstate.restart_time);
01269         mudstate.executable_path = strdup(argv[0]);
01270     mudstate.db_top = -1;
01271         tcache_init();
01272         pcache_init();
01273         cf_init();
01274         init_rlimit();
01275         init_cmdtab();
01276         init_mactab();
01277         init_chantab();
01278         init_logout_cmdtab();
01279         init_flagtab();
01280         init_powertab();
01281         init_functab();
01282         init_attrtab();
01283         init_version();
01284 
01285 #ifdef HUDINFO_SUPPORT
01286         init_hudinfo();
01287 #endif
01288 
01289         hashinit(&mudstate.player_htab, 250 * HASH_FACTOR);
01290         nhashinit(&mudstate.mail_htab, 50 * HASH_FACTOR);
01291         nhashinit(&mudstate.fwdlist_htab, 25 * HASH_FACTOR);
01292         nhashinit(&mudstate.parent_htab, 5 * HASH_FACTOR);
01293         mudstate.desctree = rb_init(desc_cmp, NULL);
01294         vattr_init();
01295 
01296         if(argc > 1 && !strcmp(argv[1], "-s")) {
01297                 mindb = 1;
01298                 if(argc == 3)
01299                         cf_read(argv[2]);
01300                 else
01301                         cf_read((char *) CONF_FILE);
01302         } else if(argc == 2) {
01303                 cf_read(argv[1]);
01304         } else {
01305                 cf_read((char *) CONF_FILE);
01306         }
01307 
01308         fcache_init();
01309         helpindex_init();
01310         db_free();
01311 
01312         mudstate.record_players = 0;
01313 
01314         if(mindb)
01315                 db_make_minimal();
01316         else if(load_game() < 0) {
01317                 STARTLOG(LOG_ALWAYS, "INI", "LOAD") {
01318                         log_text((char *) "Couldn't load: ");
01319                         log_text(mudconf.indb);
01320                         ENDLOG;
01321                 } exit(2);
01322         }
01323 #ifdef USE_PYTHON
01324         MUXPy_Init();
01325         runPythonHook("load");
01326 #endif
01327 
01328         /* initialize random.. */
01329         srandom(getpid());
01330         /* set singnals.. */
01331         bind_signals();
01332 
01333         /*
01334          * Do a consistency check and set up the freelist 
01335          */
01336 
01337         do_dbck(NOTHING, NOTHING, 0);
01338 
01339         /*
01340          * Reset all the hash stats 
01341          */
01342 
01343         hashreset(&mudstate.command_htab);
01344         hashreset(&mudstate.macro_htab);
01345         hashreset(&mudstate.channel_htab);
01346         nhashreset(&mudstate.mail_htab);
01347         hashreset(&mudstate.logout_cmd_htab);
01348         hashreset(&mudstate.func_htab);
01349         hashreset(&mudstate.flags_htab);
01350         hashreset(&mudstate.attr_name_htab);
01351         hashreset(&mudstate.player_htab);
01352         nhashreset(&mudstate.fwdlist_htab);
01353         hashreset(&mudstate.news_htab);
01354         hashreset(&mudstate.help_htab);
01355         hashreset(&mudstate.wizhelp_htab);
01356         hashreset(&mudstate.plushelp_htab);
01357         hashreset(&mudstate.wiznews_htab);
01358 
01359         for(mindb = 0; mindb < MAX_GLOBAL_REGS; mindb++) {
01360                 mudstate.global_regs[mindb] = alloc_lbuf("main.global_reg");
01361         memset(mudstate.global_regs[mindb], 0, LBUF_SIZE);
01362         }
01363 
01364         mudstate.now = time(NULL);
01365         process_preload();
01366 
01367         dnschild_init();
01368 
01369     if(!load_restart_db_xdr()) {
01370         load_restart_db();
01371     }
01372 
01373 #ifdef SQL_SUPPORT
01374         sqlchild_init();
01375 #endif
01376 
01377 #ifdef ARBITRARY_LOGFILES
01378         logcache_init();
01379 #endif
01380 
01381 #ifdef MCHECK
01382         mtrace();
01383 #endif
01384 
01385         /*
01386          * go do it 
01387          */
01388 
01389         mudstate.now = time(NULL);
01390         init_timer();
01391         shovechars(mudconf.port);
01392 
01393 #ifdef MCHECK
01394         muntrace();
01395 #endif
01396 
01397         close_sockets(0, (char *) "Going down - Bye");
01398         dump_database();
01399 
01400 #ifdef ARBITRARY_LOGFILES
01401         logcache_destruct();
01402 #endif
01403 #ifdef SQL_SUPPORT
01404         sqlchild_destruct();
01405 #endif
01406 
01407         exit(0);
01408 }

void notify_checked ( dbref  target,
dbref  sender,
const char *  msg,
int  key 
)

Definition at line 403 of file game.c.

References A_AAHEAR, A_AHEAR, A_AMHEAR, A_FILTER, A_INFILTER, A_INPREFIX, A_LISTEN, A_LUSE, A_PREFIX, add_prefix(), alloc_lbuf, alloc_sbuf, AMATCH_LISTEN, args, atr_get(), atr_match(), Audible, check_filter(), colorize(), Connected, Contents, could_doit(), forward_list::count, statedata::curr_enactor, statedata::curr_player, forward_list::data, dflt_from_msg(), did_it(), DOLIST, Exits, free_lbuf, free_sbuf, fwdlist_get(), GOD, Good_obj, H_Listen, Halted, Has_location, statedata::inpipe, isPlayer, Location, Monitor, MSG_COLORIZE, MSG_F_CONTENTS, MSG_F_DOWN, MSG_F_UP, MSG_FWDLIST, MSG_INV, MSG_INV_EXITS, MSG_INV_L, MSG_LOC, MSG_LOC_A, MSG_ME, MSG_NBR, MSG_NBR_A, MSG_NBR_EXITS, MSG_NBR_EXITS_A, MSG_NO_SLAVE, MSG_PUP_ALWAYS, MSG_S_INSIDE, MSG_S_OUTSIDE, mudconf, mudstate, Name(), Nospoof, notify_checked(), statedata::ntfy_nest_lev, confdata::ntfy_nest_lim, ufun::obj, Owner, confdata::player_listen, Puppet, raw_notify(), safe_chr, safe_str, Slave, Staff, TYPE_PLAYER, TYPE_ROOM, TYPE_THING, Typeof, where_is(), and wild().

Referenced by announce_connect(), announce_disconnect(), handle_ears(), mecha_notify_except(), notify_checked(), notify_except(), and notify_except2().

00404 {
00405         char *msg_ns, *mp, *tbuff, *tp, *buff, *colbuf = NULL;
00406         char *args[10];
00407         dbref aowner, targetloc, recip, obj;
00408         int i, nargs, aflags, has_neighbors, pass_listen;
00409         int check_listens, pass_uselock, is_audible;
00410         FWDLIST *fp;
00411 
00412         /*
00413          * If speaker is invalid or message is empty, just exit 
00414          */
00415 
00416         if(!Good_obj(target) || !msg || !*msg)
00417                 return;
00418 
00419         /*
00420          * Enforce a recursion limit 
00421          */
00422 
00423         mudstate.ntfy_nest_lev++;
00424         if(mudstate.ntfy_nest_lev >= mudconf.ntfy_nest_lim) {
00425                 mudstate.ntfy_nest_lev--;
00426                 return;
00427         }
00428         /*
00429          * If we want NOSPOOF output, generate it.  It is only needed if 
00430          * we are sending the message to the target object 
00431          */
00432 
00433         if(key & MSG_ME) {
00434                 mp = msg_ns = alloc_lbuf("notify_checked");
00435                 if(Nospoof(target) && (target != sender) &&
00436                    (target != mudstate.curr_enactor) &&
00437                    (target != mudstate.curr_player && Good_obj(sender))) {
00438 
00439                         /*
00440                          * I'd really like to use tprintf here but I can't 
00441                          * because the caller may have.
00442                          * notify(target, tprintf(...)) is quite common 
00443                          * in the code. 
00444                          */
00445 
00446                         tbuff = alloc_sbuf("notify_checked.nospoof");
00447                         safe_chr('[', msg_ns, &mp);
00448                         safe_str(Name(sender), msg_ns, &mp);
00449                         sprintf(tbuff, "(#%d)", sender);
00450                         safe_str(tbuff, msg_ns, &mp);
00451 
00452                         if(sender != Owner(sender)) {
00453                                 safe_chr('{', msg_ns, &mp);
00454                                 safe_str(Name(Owner(sender)), msg_ns, &mp);
00455                                 safe_chr('}', msg_ns, &mp);
00456                         }
00457                         if(sender != mudstate.curr_enactor) {
00458                                 sprintf(tbuff, "<-(#%d)", mudstate.curr_enactor);
00459                                 safe_str(tbuff, msg_ns, &mp);
00460                         }
00461                         safe_str((char *) "] ", msg_ns, &mp);
00462                         free_sbuf(tbuff);
00463                 }
00464                 safe_str((char *) msg, msg_ns, &mp);
00465                 *mp = '\0';
00466         } else {
00467                 msg_ns = NULL;
00468         }
00469 
00470         /*
00471          * msg contains the raw message, msg_ns contains the NOSPOOFed msg 
00472          */
00473 
00474         check_listens = Halted(target) ? 0 : 1;
00475         switch (Typeof(target)) {
00476         case TYPE_PLAYER:
00477                 if(key & MSG_ME) {
00478                         if(key & MSG_COLORIZE)
00479                                 colbuf = colorize(target, msg_ns);
00480                         raw_notify(target, colbuf ? colbuf : msg_ns);
00481 
00482 
00483                 }
00484 
00485                 if(colbuf)
00486                         free_lbuf(colbuf);
00487                 if(!mudconf.player_listen)
00488                         check_listens = 0;
00489         case TYPE_THING:
00490         case TYPE_ROOM:
00491 
00492                 /* If we're in a pipe, objects can receive raw_notify
00493                  * if they're not a player and connected (if we didn't
00494                  * do this, they'd be notified twice! */
00495 
00496                 if(mudstate.inpipe && (!isPlayer(target) || (isPlayer(target) &&
00497                                                                                                          !Connected(target)))) {
00498                         raw_notify(target, msg_ns);
00499                 }
00500 
00501                 /*
00502                  * Forward puppet message if it is for me 
00503                  */
00504 
00505                 has_neighbors = Has_location(target);
00506                 targetloc = where_is(target);
00507                 is_audible = Audible(target);
00508 
00509                 if((key & MSG_ME) && Puppet(target) && (target != Owner(target))
00510                    && ((key & MSG_PUP_ALWAYS) ||
00511                            ((targetloc != Location(Owner(target))) &&
00512                                 (targetloc != Owner(target))))) {
00513                         tp = tbuff = alloc_lbuf("notify_checked.puppet");
00514                         safe_str(Name(target), tbuff, &tp);
00515                         safe_str((char *) "> ", tbuff, &tp);
00516                         if(key & MSG_COLORIZE)
00517                                 colbuf = colorize(Owner(target), msg_ns);
00518                         safe_str(colbuf ? colbuf : msg_ns, tbuff, &tp);
00519                         *tp = '\0';
00520                         raw_notify(Owner(target), tbuff);
00521                         if(colbuf)
00522                                 free_lbuf(colbuf);
00523                         free_lbuf(tbuff);
00524                 }
00525                 /*
00526                  * Check for @Listen match if it will be useful 
00527                  */
00528 
00529                 pass_listen = 0;
00530                 nargs = 0;
00531                 if(check_listens && (key & (MSG_ME | MSG_INV_L)) && H_Listen(target)) {
00532                         tp = atr_get(target, A_LISTEN, &aowner, &aflags);
00533                         if(*tp && wild(tp, (char *) msg, args, 10)) {
00534                                 for(nargs = 10;
00535                                         nargs && (!args[nargs - 1] || !(*args[nargs - 1]));
00536                                         nargs--);
00537                                 pass_listen = 1;
00538                         }
00539                         free_lbuf(tp);
00540                 }
00541                 /*
00542                  * If we matched the @listen or are monitoring, check the * * 
00543                  * USE lock 
00544                  */
00545 
00546                 if(sender < 0)
00547                         sender = GOD;
00548                 pass_uselock = 0;
00549                 if((key & MSG_ME) && check_listens && (pass_listen ||
00550                                                                                            Monitor(target)))
00551                         pass_uselock = could_doit(sender, target, A_LUSE);
00552 
00553                 /*
00554                  * Process AxHEAR if we pass LISTEN, USElock and it's for me 
00555                  */
00556 
00557                 if((key & MSG_ME) && pass_listen && pass_uselock) {
00558                         if(sender != target)
00559                                 did_it(sender, target, 0, NULL, 0, NULL, A_AHEAR, args,
00560                                            nargs);
00561                         else
00562                                 did_it(sender, target, 0, NULL, 0, NULL, A_AMHEAR, args,
00563                                            nargs);
00564                         did_it(sender, target, 0, NULL, 0, NULL, A_AAHEAR, args, nargs);
00565                 }
00566                 /*
00567                  * Get rid of match arguments. We don't need them anymore 
00568                  */
00569 
00570                 if(pass_listen) {
00571                         for(i = 0; i < 10; i++)
00572                                 if(args[i] != NULL)
00573                                         free_lbuf(args[i]);
00574                 }
00575                 /*
00576                  * Process ^-listens if for me, MONITOR, and we pass USElock 
00577                  */
00578                 /*
00579                  * \todo Eventually come up with a cleaner method for making sure
00580                  * the sender isn't the same as the target.
00581                  */
00582                 if((key & MSG_ME) && (sender != target || Staff(target))
00583                    && pass_uselock && Monitor(target)) {
00584                         (void) atr_match(target, sender, AMATCH_LISTEN, (char *) msg, 0);
00585                 }
00586                 /*
00587                  * Deliver message to forwardlist members 
00588                  */
00589 
00590                 if((key & MSG_FWDLIST) && Audible(target) &&
00591                    check_filter(target, sender, A_FILTER, msg)) {
00592                         tbuff = dflt_from_msg(sender, target);
00593                         buff = add_prefix(target, sender, A_PREFIX, msg, tbuff);
00594                         free_lbuf(tbuff);
00595 
00596                         fp = fwdlist_get(target);
00597                         if(fp) {
00598                                 for(i = 0; i < fp->count; i++) {
00599                                         recip = fp->data[i];
00600                                         if(!Good_obj(recip) || (recip == target))
00601                                                 continue;
00602                                         notify_checked(recip, sender, buff,
00603                                                                    (MSG_ME | MSG_F_UP | MSG_F_CONTENTS |
00604                                                                         MSG_S_INSIDE));
00605                                 }
00606                         }
00607                         free_lbuf(buff);
00608                 }
00609                 /*
00610                  * Deliver message through audible exits 
00611                  */
00612 
00613                 if(key & MSG_INV_EXITS) {
00614                         DOLIST(obj, Exits(target)) {
00615                                 recip = Location(obj);
00616                                 if(Audible(obj) && ((recip != target) &&
00617                                                                         check_filter(obj, sender, A_FILTER,
00618                                                                                                  msg))) {
00619                                         buff =
00620                                                 add_prefix(obj, target, A_PREFIX, msg,
00621                                                                    "From a distance,");
00622                                         notify_checked(recip, sender, buff,
00623                                                                    MSG_ME | MSG_F_UP | MSG_F_CONTENTS |
00624                                                                    MSG_S_INSIDE);
00625                                         free_lbuf(buff);
00626                                 }
00627                         }
00628                 }
00629                 /*
00630                  * Deliver message through neighboring audible exits 
00631                  */
00632 
00633                 if(has_neighbors && ((key & MSG_NBR_EXITS) ||
00634                                                          ((key & MSG_NBR_EXITS_A) && is_audible))) {
00635 
00636                         /*
00637                          * If from inside, we have to add the prefix string * 
00638                          * 
00639                          * *  * * of * the container. 
00640                          */
00641 
00642                         if(key & MSG_S_INSIDE) {
00643                                 tbuff = dflt_from_msg(sender, target);
00644                                 buff = add_prefix(target, sender, A_PREFIX, msg, tbuff);
00645                                 free_lbuf(tbuff);
00646                         } else {
00647                                 buff = (char *) msg;
00648                         }
00649 
00650                         DOLIST(obj, Exits(Location(target))) {
00651                                 recip = Location(obj);
00652                                 if(Good_obj(recip) && Audible(obj) && (recip != targetloc)
00653                                    && (recip != target) &&
00654                                    check_filter(obj, sender, A_FILTER, msg)) {
00655                                         tbuff =
00656                                                 add_prefix(obj, target, A_PREFIX, buff,
00657                                                                    "From a distance,");
00658                                         notify_checked(recip, sender, tbuff,
00659                                                                    MSG_ME | MSG_F_UP | MSG_F_CONTENTS |
00660                                                                    MSG_S_INSIDE);
00661                                         free_lbuf(tbuff);
00662                                 }
00663                         }
00664                         if(key & MSG_S_INSIDE) {
00665                                 free_lbuf(buff);
00666                         }
00667                 }
00668                 /*
00669                  * Deliver message to contents 
00670                  */
00671 
00672                 if(((key & MSG_INV) || ((key & MSG_INV_L) && pass_listen)) &&
00673                    (check_filter(target, sender, A_INFILTER, msg))) {
00674 
00675                         /*
00676                          * Don't prefix the message if we were given the * *
00677                          * * * MSG_NOPREFIX key. 
00678                          */
00679 
00680                         if(key & MSG_S_OUTSIDE) {
00681                                 buff = add_prefix(target, sender, A_INPREFIX, msg, "");
00682                         } else {
00683                                 buff = (char *) msg;
00684                         }
00685                         DOLIST(obj, Contents(target)) {
00686                                 if(Slave(obj) && (key & MSG_NO_SLAVE))
00687                                         continue;
00688                                 if(obj != target) {
00689                                         notify_checked(obj, sender, buff,
00690                                                                    MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE );
00691                                 }
00692                         }
00693                         if(key & MSG_S_OUTSIDE)
00694                                 free_lbuf(buff);
00695                 }
00696                 /*
00697                  * Deliver message to neighbors 
00698                  */
00699 
00700                 if(has_neighbors && ((key & MSG_NBR) || ((key & MSG_NBR_A) &&
00701                                                                                                  is_audible &&
00702                                                                                                  check_filter(target, sender,
00703                                                                                                                           A_FILTER,
00704                                                                                                                           msg)))) {
00705                         if(key & MSG_S_INSIDE) {
00706                                 tbuff = dflt_from_msg(sender, target);
00707                                 buff = add_prefix(target, sender, A_PREFIX, msg, "");
00708                                 free_lbuf(tbuff);
00709                         } else {
00710                                 buff = (char *) msg;
00711                         }
00712                         DOLIST(obj, Contents(targetloc)) {
00713                                 if((obj != target) && (obj != targetloc)) {
00714                                         notify_checked(obj, sender, buff,
00715                                                                    MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE | (key
00716                                                                                                                                                   &
00717                                                                                                                                                   MSG_COLORIZE));
00718                                 }
00719                         }
00720                         if(key & MSG_S_INSIDE) {
00721                                 free_lbuf(buff);
00722                         }
00723                 }
00724                 /*
00725                  * Deliver message to container 
00726                  */
00727 
00728                 if(has_neighbors && ((key & MSG_LOC) || ((key & MSG_LOC_A) &&
00729                                                                                                  is_audible &&
00730                                                                                                  check_filter(target, sender,
00731                                                                                                                           A_FILTER,
00732                                                                                                                           msg)))) {
00733                         if(key & MSG_S_INSIDE) {
00734                                 tbuff = dflt_from_msg(sender, target);
00735                                 buff = add_prefix(target, sender, A_PREFIX, msg, tbuff);
00736                                 free_lbuf(tbuff);
00737                         } else {
00738                                 buff = (char *) msg;
00739                         }
00740                         notify_checked(targetloc, sender, buff,
00741                                                    MSG_ME | MSG_F_UP | MSG_S_INSIDE);
00742                         if(key & MSG_S_INSIDE) {
00743                                 free_lbuf(buff);
00744                         }
00745                 }
00746         }
00747         if(msg_ns)
00748                 free_lbuf(msg_ns);
00749         mudstate.ntfy_nest_lev--;
00750 }

void notify_except ( dbref  loc,
dbref  player,
dbref  exception,
const char *  msg 
)

Definition at line 752 of file game.c.

References Contents, DOLIST, MSG_F_DOWN, MSG_F_UP, MSG_ME, MSG_ME_ALL, MSG_NBR_EXITS_A, MSG_NO_SLAVE, MSG_S_INSIDE, MSG_S_OUTSIDE, NOSLAVE, notify_checked(), and Slave.

00753 {
00754         dbref first;
00755 
00756         if(loc != exception)
00757                 notify_checked(loc, player, msg,
00758                                            (MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE |
00759                                                 MSG_NBR_EXITS_A));
00760         DOLIST(first, Contents(loc)) {
00761                 if(exception == NOSLAVE)
00762                         if(Slave(first))
00763                                 continue;
00764                 if(first != exception)
00765                         notify_checked(first, player, msg,
00766                                                    (MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE |
00767                                                         (exception == NOSLAVE ? MSG_NO_SLAVE : 0)));
00768         }
00769 }

void notify_except2 ( dbref  loc,
dbref  player,
dbref  exc1,
dbref  exc2,
const char *  msg 
)

Definition at line 771 of file game.c.

References Contents, DOLIST, MSG_F_DOWN, MSG_F_UP, MSG_ME, MSG_ME_ALL, MSG_NBR_EXITS_A, MSG_S_INSIDE, MSG_S_OUTSIDE, and notify_checked().

Referenced by did_it(), do_pemit(), do_toad(), process_enter_loc(), and process_leave_loc().

00773 {
00774         dbref first;
00775 
00776         if((loc != exc1) && (loc != exc2))
00777                 notify_checked(loc, player, msg,
00778                                            (MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE |
00779                                                 MSG_NBR_EXITS_A));
00780         DOLIST(first, Contents(loc)) {
00781                 if(first != exc1 && first != exc2) {
00782                         notify_checked(first, player, msg,
00783                                                    (MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE));
00784                 }
00785         }
00786 }

void pcache_init ( void   ) 

Definition at line 22 of file player_c.c.

References compare_pcache(), pcache_head, pcache_tree, and rb_init().

Referenced by main().

00023 {
00024         pcache_tree = rb_init((void *)compare_pcache, NULL);
00025         pcache_head = NULL;
00026 }

void pcache_sync ( void   ) 

Definition at line 125 of file player_c.c.

References pcache_head, and pcache_save().

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

00126 {
00127         PCACHE *pp;
00128 
00129         pp = pcache_head;
00130         while (pp) {
00131                 pcache_save(pp);
00132                 pp = pp->next;
00133         }
00134 }

static void process_preload ( void   )  [static]

Definition at line 1189 of file game.c.

References A_FORWARDLIST, A_STARTUP, alloc_lbuf, atr_get_str(), did_it(), do_second(), do_top(), DO_WHOLE_DB, Flags, free_lbuf, fwdlist_load(), fwdlist_set(), GOD, Going, H_Fwdlist, HAS_STARTUP, ITER_PARENTS, and Owner.

Referenced by main().

01190 {
01191         dbref thing, parent, aowner;
01192         int aflags, lev, i;
01193         char *tstr;
01194         FWDLIST *fp;
01195 
01196         fp = (FWDLIST *) alloc_lbuf("process_preload.fwdlist");
01197         tstr = alloc_lbuf("process_preload.string");
01198         i = 0;
01199         DO_WHOLE_DB(thing) {
01200 
01201                 /*
01202                  * Ignore GOING objects 
01203                  */
01204 
01205                 if(Going(thing))
01206                         continue;
01207 
01208                 do_top(10);
01209 
01210                 /*
01211                  * Look for a STARTUP attribute in parents 
01212                  */
01213 
01214                 ITER_PARENTS(thing, parent, lev) {
01215                         if(Flags(thing) & HAS_STARTUP) {
01216                                 did_it(Owner(thing), thing, 0, NULL, 0, NULL, A_STARTUP,
01217                                            (char **) NULL, 0);
01218                                 /*
01219                                  * Process queue entries as we add them 
01220                                  */
01221 
01222                                 do_second();
01223                                 do_top(10);
01224                                 break;
01225                         }
01226                 }
01227 
01228                 /*
01229                  * Look for a FORWARDLIST attribute 
01230                  */
01231 
01232                 if(H_Fwdlist(thing)) {
01233                         (void) atr_get_str(tstr, thing, A_FORWARDLIST, &aowner, &aflags);
01234                         if(*tstr) {
01235                                 fwdlist_load(fp, GOD, tstr);
01236                                 if(fp->count > 0)
01237                                         fwdlist_set(thing, fp);
01238                         }
01239                 }
01240         }
01241         free_lbuf(fp);
01242         free_lbuf(tstr);
01243 }

void raw_notify ( dbref  ,
const char *   
)

Definition at line 243 of file netcommon.c.

Referenced by announce_connect(), do_addcom(), do_allcom(), do_cemit(), do_chanlist(), do_channelwho(), do_chanobj(), do_chanstatus(), do_chboot(), do_chclose(), do_chloud(), do_chopaque(), do_chopen(), do_chsquelch(), do_chtransparent(), do_clearcom(), do_comlist(), do_comprintf(), do_comsend(), do_comtitle(), do_comwho(), do_createchannel(), do_delcom(), do_destroychannel(), do_dump_optimize(), do_editchannel(), do_listchannels(), do_processcom(), list_attrtable(), list_costs(), list_db_stats(), list_df_flags(), list_options(), list_process(), list_vattrs(), mecha_notify(), and notify_checked().

00244 {
00245         raw_notify_raw(player, msg, "\r\n");
00246 }

int regexp_match ( char *  pattern,
char *  str,
char *  args[],
int  nargs 
)

Definition at line 131 of file game.c.

References alloc_lbuf, LBUF_SIZE, and NSUBEXP.

Referenced by atr_match1().

00132 {
00133         regex_t re;
00134         int got_match;
00135         regmatch_t pmatch[NSUBEXP];
00136         int i, len;
00137 
00138         /*
00139          * Load the regexp pattern. This allocates memory which must be
00140          * later freed. A free() of the regexp does free all structures
00141          * under it.
00142          */
00143 
00144         if(regcomp(&re, pattern, REG_EXTENDED) != 0) {
00145                 /*
00146                  * This is a matching error. We have an error message in
00147                  * regexp_errbuf that we can ignore, since we're doing
00148                  * command-matching.
00149                  */
00150                 return 0;
00151         }
00152 
00153         /* 
00154          * Now we try to match the pattern. The relevant fields will
00155          * automatically be filled in by this.
00156          */
00157         got_match = (regexec(&re, str, NSUBEXP, pmatch, 0) == 0);
00158         if(!got_match) {
00159                 regfree(&re);
00160                 return 0;
00161         }
00162 
00163         /*
00164          * Now we fill in our args vector. Note that in regexp matching,
00165          * 0 is the entire string matched, and the parenthesized strings
00166          * go from 1 to 9. We DO PRESERVE THIS PARADIGM, for consistency
00167          * with other languages.
00168          */
00169 
00170         for(i = 0; i < nargs; i++) {
00171                 args[i] = NULL;
00172         }
00173 
00174         /* Convenient: nargs and NSUBEXP are the same.
00175          * We are also guaranteed that our buffer is going to be LBUF_SIZE
00176          * so we can copy without fear.
00177          */
00178 
00179         for(i = 0; (i < NSUBEXP) && (pmatch[i].rm_so != -1) && (pmatch[i].rm_eo != -1); i++) {
00180                 len = pmatch[i].rm_eo - pmatch[i].rm_so;
00181                 args[i] = alloc_lbuf("regexp_match");
00182         memset(args[i], 0, LBUF_SIZE);
00183                 strncpy(args[i], str + pmatch[i].rm_so, len);
00184                 args[i][len] = '\0';    /* strncpy() does not null-terminate */
00185         }
00186 
00187         regfree(&re);
00188         return 1;
00189 }

void report ( void   ) 

print out stuff into error file

Definition at line 107 of file game.c.

References statedata::curr_enactor, statedata::curr_player, statedata::debug_cmd, ENDLOG, Good_obj, LOG_BUGS, log_name_and_loc(), log_text(), mudstate, and STARTLOG.

Referenced by signal_BUS(), and signal_SEGV().

00108 {
00109         STARTLOG(LOG_BUGS, "BUG", "INFO") {
00110                 log_text((char *) "Command: '");
00111                 log_text(mudstate.debug_cmd);
00112                 log_text((char *) "'");
00113                 ENDLOG;
00114         } if(Good_obj(mudstate.curr_player)) {
00115                 STARTLOG(LOG_BUGS, "BUG", "INFO") {
00116                         log_text((char *) "Player: ");
00117                         log_name_and_loc(mudstate.curr_player);
00118                         if((mudstate.curr_enactor != mudstate.curr_player) &&
00119                            Good_obj(mudstate.curr_enactor)) {
00120                                 log_text((char *) " Enactor: ");
00121                                 log_name_and_loc(mudstate.curr_enactor);
00122                         }
00123                         ENDLOG;
00124         }}
00125 }


Variable Documentation

int corrupt

Definition at line 42 of file db.c.

Referenced by main().

int reserved

Definition at line 74 of file game.c.


Generated on Mon May 28 04:25:31 2007 for BattletechMUX by  doxygen 1.4.7