# Patch name: NveidGoodies+TrivStuff # Patch version: 2.1 # Author's name: RLB # Author's email: nveid@master.mu-net.org # Version of PennMUSH: 1.7.3p2 # Date patch made: Wed Jun 27 06:40:00 2000 # Author is willing to support (yes/no): yes # Patch format: Context # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise below. # CHANGES: Well, apparently no one emailed me any of the bugs. :P Anyhow, found 'em & found out no substitute in 1.7.3 is there for @cname(so put it back in).. btw if the one i put in doesn't work right email me cause i didn't check it thruoghly.. Anyhow, tbhere was also another i can think off hand.. The infinite loop @dpage could be sent into... Also changed somethings with @showlog & some other shit.. Added in showlogs() Anyhow, didn't throughly check the stuff in here.. I really did it awhile back now(like a day after i sent int eh last patch :P so its not fresh in my mind), just never felt like making the actual patch. So if you do find any problems email me & i'll send you a fix ASAP. :) About my email, lusis.org seems kinda flaky lately.. So be sendnig 'em to master.mu-net.org for awhile(not that it isn't flakey either) OH Ya, & one more note.... Some people didn't know this, but to use gdbm, you need to stick -lgdbm in your Makefile. P.S. - Find any bugs, don't be afraid to email. :) Brief Documentation ################### ASwitch() This is the same as switch(), except instead of breaking off returning just the first match. It evaluates all of teh matches it finds. (sorta like @switch) Force() Same as @force, but its a function, whee. force(,) Wait() Wait(,) Trigger() Trigger(/,,,...,) Master Object: Alright, i'm gonna explain master objects. Some people get the wrong ideas abotu these things. First off, you declare your msater object in mush.cnf with the conf parameter 'master_object' sameway as master_room 'cept this one will represent your master object. All that carries down from this is the @verbs i guess(@attr @aattr & @oattr). So @desc, @adesc & @odesc will carry down to all objects that the master object has set. If you don't set your master object It'll just use #1's stuff. (Of course you don't have to use this, just don't define USE_MASTEROBJECT) DEFINES NEEDED: USE_MASTEROBJECT @CNAME: Welp, hopefully everyone understands the concepts of this. @cname player=colname @DPAGE & REPLY: @DPAGE is sorta like what @CPAGE was on MUSE if anyone remembers. You could page a concid. Welp i did the same for penmush, 'cept called it @DPAGE as in descriptor page. And i'm allowing a reply command as well for the person at the connect screen to reply to you. @DPAGE Syntax: @DPAGE [] = The replysecs is how many secs your giving the person to reply to you. If you don't specify it, it defaults to 15. REPLY Syntax: reply [] The player slot is if multiple players have @dpage'd them. Otherwise it will just result to the last person that @dpage'd 'em. DEFINES NEEDED: DPAGER @SHOWLOG @SHOWLOG system is a system that allows logs to be shown to players online. Restricted: The @showlog command is restricted to Wizards Syntax: Setting a log(preceed with NOT_TOKEN to reset): @showlog [=][!] Listing Logs showing: @showlog/list [] If you don't use the [] in the command syntax, it'll default to you. Logs: Error, Commands, Wizard, Connect, Trace, Check, Huh, All(toggles all logs) (when shown with @showlog/list a s is appended to each of the names) Note.. This information is not stored to teh database, so put the @showlog stuff in your @aconnect attribute if your gonna be using a normal set of logs often. (ignore all that if you system supports gdbm, & thats most systems) If your system has gdbm, #define SHOWLOG_SAVE & it'll save the LOCAL_DATA [showlog] information to a gdbm file. (also comes with a @showlog function, showlogs() which displays log on a player.. Useful for running a dolist across the db to make sure no one who doesn't suppose to have a log has it) DEFINES NEEDED: SHOWLOG_SYS and/or SHOWLOG_SAVE & LOCAL_DATA diff -c /home/nveid/pennmush/src/bsd.c ./src/bsd.c *** /home/nveid/pennmush/src/bsd.c Wed Jun 14 19:59:30 2000 --- ./src/bsd.c Sun Jun 18 01:25:46 2000 *************** *** 216,221 **** --- 216,224 ---- #ifdef USE_MAILER struct mail *mailp; #endif + #ifdef DPAGER + DPAGER_DATA *dpage_list; + #endif /* DPAGER */ int pueblo; }; *************** *** 2149,2154 **** --- 2152,2160 ---- #ifdef USE_MAILER d->mailp = NULL; #endif + #ifdef DPAGER + d->dpage_list = NULL; + #endif welcome_user(d); } *************** *** 2280,2285 **** --- 2286,2294 ---- /* Go find where this player's messages start */ d->mailp = NULL; #endif + #ifdef DPAGER + d->dpage_list = NULL; + #endif /* DPAGER */ strncpy(d->addr, addr, 100); d->addr[99] = '\0'; strncpy(d->ip, ip, 100); *************** *** 3239,3249 **** char *command; { int j; depth = 0; (d->cmds)++; ! if (!strcmp(command, QUIT_COMMAND)) { return 0; } else if (!strcmp(command, LOGOUT_COMMAND)) { return -1; --- 3248,3312 ---- char *command; { int j; + #ifdef DPAGER + char *tbuf1, *tbuf2, *bp, *p, *t; + int found = 0; + DPAGER_DATA *dp; + dbref rplyr; + #endif depth = 0; (d->cmds)++; ! #ifdef DPAGER ! if(d->dpage_list != NULL && strncasecmp(command, (char *)"REPLY", 5) == 0) { ! tbuf1 = (char *) mush_malloc(BUFFER_LEN/2, "do_command.tbuf1"); ! tbuf2 = (char *) mush_malloc(BUFFER_LEN/2, "do_command.tbuf2"); ! if(!tbuf1 || !tbuf2) ! panic("Out of memory"); ! bp = tbuf1; ! send_prefix(d); ! safe_copy_str(command + 5, tbuf1, &bp,(BUFFER_LEN/2)-1); ! *bp = '\0'; ! for(p = tbuf1; p && *p == ' '; p++) ! ; ! for(t = tbuf2; p && *p != ' '; *t++ = *p++) ! ; ! *t = '\0'; ! if(tbuf2) ! /* ok.. now we're gonna see if this arg represents a name for them to reply to */ ! for(dp = d->dpage_list; dp ; dp = dp->next) ! if(!strcasecmp(tbuf2, Name(dp->reply_plyr))) { ! found = 1; ! break; ! } ! rplyr = (found == 1? dp->reply_plyr : d->dpage_list->reply_plyr); ! /* modify tbuf2 to be the message now */ ! mush_free((Malloc_t) tbuf2, "do_command.tbuf2"); ! tbuf2 = (char *) mush_malloc(BUFFER_LEN/2, "do_command.tbuf2"); ! bp = tbuf2; ! for(p = tbuf1; p && *p == ' '; p++) ! ; ! if(!found) ! safe_copy_str(p, tbuf2, &bp, (BUFFER_LEN/2)-1); ! else { ! for(; p && *p != ' '; p++) ! ; ! for(; p && *p == ' '; p++) ! ; ! safe_copy_str(p, tbuf2, &bp, (BUFFER_LEN/2)-1); ! } ! *bp = '\0'; ! ! notify(rplyr, tprintf("Descriptor %d replies with: %s", d->descriptor, tbuf2)); ! queue_string(d, tprintf("You reply to %s with: %s\r\n", Name(rplyr), tbuf2)); ! ! mush_free((Malloc_t) tbuf2, "do_command.tbuf2"); ! mush_free((Malloc_t) tbuf1, "do_command.tbuf1"); ! send_suffix(d); ! } else ! #endif /* DPAGER */ ! if (!strcmp(command, QUIT_COMMAND)) { return 0; } else if (!strcmp(command, LOGOUT_COMMAND)) { return -1; *************** *** 5118,5123 **** --- 5181,5189 ---- d->raw_input = NULL; d->raw_input_at = NULL; d->quota = options.starting_quota; + #ifdef DPAGER + d->dpage_list = NULL; + #endif #ifdef USE_MAILER d->mailp = NULL; #endif diff -c /home/nveid/pennmush/src/cmdlocal.c ./src/cmdlocal.c *** /home/nveid/pennmush/src/cmdlocal.c Wed Jun 14 19:59:30 2000 --- ./src/cmdlocal.c Tue Jun 27 06:23:47 2000 *************** *** 20,25 **** --- 20,36 ---- #include "htab.h" #include "command.h" #include "confmagic.h" + #ifdef USE_COLNAME + #include "match.h" + #include "ansi.h" + #endif /* USE_COLNAME */ + #ifdef SHOWLOG_SYS + #include "globals.h" + #endif /* SHOWLOG_SYS */ + + #ifdef DPAGER + #include "ddata.h" + #endif extern HASHTAB htab_reserved_aliases; void reserve_aliases _((void)); *************** *** 62,67 **** --- 73,281 ---- } #endif + #ifdef DPAGER + COMMAND(local_cmd_dpage) { /* syntax @dpage [] = */ + struct descriptor_data *d; + int pdesc, secs; + char *buf, *p, *t; + + if(do_wordcount(arg_left, ' ') > 1) { + buf = mush_malloc(BUFFER_LEN, "dpage.buf"); + t = buf; + for(p = arg_left; *p && (*p == ' '); p++) /* may not need this, but just incase */ + ; + for(; *p && *p != ' '; *t++ = *p++) + ; + *t = '\0'; + secs = atoi(buf); + mush_free((Malloc_t) buf, "dpage.buf"); + buf = mush_malloc(BUFFER_LEN, "dpage.buf"); + t = buf; + for(; *p && *p == ' '; p++) + ; for(; *p && *p != ' '; *t++ = *p++) + ; + *t = '\0'; + pdesc = atoi(buf); + mush_free((Malloc_t) buf, "dpage.buf"); + } else { + pdesc = atoi(arg_left); + secs = 15; + } + + for (d=descriptor_list; d; d=d->next) + if(d->descriptor == pdesc) { + if(!d->connected) + break; + else { + notify(player, "Use 'page' silly."); + return; + } + } + + + if(!d) { + notify(player,"Can't find that descriptor. :P"); + return; + } + if(secs > 0) { + notify(player, tprintf("You page descriptor '%d' with(reply limit set to %d): %s", pdesc, secs, arg_right)); + queue_string(d, tprintf("Descriptor page from %s(%ds to reply): %s\r\n", Name(player), secs, arg_right)); + dpager_schedule(d, player, secs); + } else { + notify(player, tprintf("You page descriptor '%d' with: %s", pdesc, arg_right)); + queue_string(d, tprintf("Descriptor page from %s: %s\r\n", Name(player), arg_right)); + } + } + + COMMAND(local_cmd_cwho) { + DESC *d; + char buf[BUFFER_LEN]; + time_t now; + + now = time((time_t *) 0); + + sprintf(buf, "Desc On For Idle Cmds Addr\r\n"); + for(d = descriptor_list; d ; d = d->next) + if(!d->connected) + sprintf(buf, "%3d %9s %5s %4d %s\r\n", d->descriptor, time_format_1(now - d->connected_at), + time_format_2(now - d->last_time), d->cmds, d->addr); + notify(player, buf); + } + #endif /* DPAGER */ + + #ifdef SHOWLOG_SYS + struct log_list_t log_tab[] = { + {"ERROR", LTB_ERR}, + {"COMMAND", LTB_CMD}, + {"WIZARD", LTB_WIZ}, + {"CONNECTION", LTB_CONN}, + {"TRACE", LTB_TRACE}, + {"CHECKPOINT", LTB_CHECK}, + {"HUH", LTB_HUH}, + {"ALL", (LTB_ERR | LTB_CMD | LTB_WIZ | LTB_CONN | LTB_TRACE | LTB_CHECK | LTB_HUH)}, + {NULL, '\0'} + }; + + COMMAND(local_cmd_showlog) { + char buf[BUFFER_LEN]; + char *p, *t, noton; + unsigned char ltogs; + int i; + dbref target; + + if((arg_right && *arg_right) || (SW_ISSET(sw,SWITCH_LIST) && arg_left && *arg_left)) { + p = arg_right; + target = lookup_player(arg_left); + if(target == NOTHING || (target == GOD && player != GOD)) { + notify(player, "I can't find that player"); + return; + } + } else { + target = player; + p = arg_left; + } + + memset(buf, '\0', BUFFER_LEN); + ltogs = *(unsigned char *) &LocData(target); + + if(!SW_ISSET(sw, SWITCH_LIST)) { /* they're wanting to set showlog on someone */ + noton = 0; + do { + if(isspace(*p)) { + p = skip_space(p); + continue; + } else if(*p == NOT_TOKEN) { + noton = 1; + p++; + } + t = buf; + while(*p && !isspace(*p)) + safe_chr(UPCASE(*p++), buf, &t); + *t = '\0'; + if(*buf) { + for(i = 0;log_tab[i].name != NULL; i++) + if(string_prefix(log_tab[i].name, buf)) { + if(noton) + ltogs &= ~(log_tab[i].toggle); + else + ltogs |= log_tab[i].toggle; + notify(target, tprintf("SHOWLOG->%s: %s", log_tab[i].name, noton ? "Reset" : "Set")); + if(target != player) + do_log(LT_WIZ, player, target, "@SHOWLOG: %s %s", log_tab[i].name, noton ? "RESET" : "SET"); + break; + } + if(!log_tab[i].name) + notify(player, tprintf("Bad LogType: %s", buf)); + /* reset stuff */ + noton = 0; + memset(buf, '\0', BUFFER_LEN); + } + } while(*p); + LocData(target) = (void *) ltogs; + } else { /* they're wanting to know what logs they have toggled */ + p = buf; + safe_str("Currently Showing Logs:", buf, &p); + for(i = 0;i < 7; i++) + if(ltogs & log_tab[i].toggle) { + safe_chr(' ', buf, &p); + safe_str(slist_adjust(log_tab[i].name), buf, &p); + safe_chr(',', buf, &p); + } + if(*(p-1) == ':') + safe_str(" None.", buf, &p); + else *(p-1) = '.'; + *p = '\0'; + notify(player, buf); + } + + } + #endif /* SHOWLOG_SYS */ + + #ifdef USE_COLNAME + /* Ok.. 1.7.3 @nameformat doesn't seem to quite work for players.. Though it works for rooms, + so we won't be implementing ShowZone though, we will add in a versoin of @cname */ + COMMAND(local_cmd_colname) { + dbref target; + char buf[BUFFER_LEN]; + char nbuf[OBJECT_NAME_LIMIT]; + char *p, *t; + + target=noisy_match_result(player, arg_left, NOTYPE, MAT_EVERYTHING | MAT_ME | MAT_HERE); + if(target == NOTHING) + return; + if(!controls(player, target)) { + notify(player, "Permission denied."); + return; + } + + if(!arg_right || !*arg_right) { + atr_clr(target, "COLNAME", GOD); + notify(player, "Colname cleared"); + } else { + /* @cname code */ + t = buf; + p = arg_right; + while(*p) + if(*p == ESC_CHAR) + while(*p && *p++ != 'm'); + else + *t++ = *p++; + *t = '\0'; + strcpy(nbuf, Name(target)); + if(Typeof(target) == TYPE_EXIT) { + t = strchr(nbuf, ';'); + if(t) + *t = '\0'; + } + if(!strstr(buf, nbuf)) + notify(player, tprintf("New name \"%s\" does not contain old name \"%s\".", buf, Name(target))); + else { + atr_add(target, "COLNAME", arg_right, GOD, AF_NOPROG | AF_MDARK | AF_WIZARD | AF_PRIVATE); + notify(player, "Colname set."); + } + } + } + #endif /* USE_COLNAME */ /* Called during the command init sequence. * This is where you'd put calls to add_command to insert a local *************** *** 75,78 **** --- 289,302 ---- command_add("@SILLY", CMD_T_ANY, 0, 0, 0, switchmask("NOISY NOEVAL"), cmd_local_silly); #endif + #ifdef DPAGER + command_add("@DPAGER", CMD_T_PLAYER | CMD_T_EQSPLIT | CMD_T_NOGAGGED, WIZARD, 0, 0, NULL, local_cmd_dpage); + command_add("@CWHO", CMD_T_PLAYER, WIZARD, 0, 0, NULL, local_cmd_cwho); + #endif /* DPAGER */ + #ifdef SHOWLOG_SYS + command_add("@SHOWLOG", CMD_T_PLAYER | CMD_T_EQSPLIT, WIZARD, 0, 0, switchmask("LIST"), local_cmd_showlog); + #endif /* SHOWLOG_SYS */ + #ifdef USE_COLNAME + command_add("@CNAME", CMD_T_PLAYER | CMD_T_EQSPLIT, 0, 0, 0, NULL, local_cmd_colname); + #endif /* USE_COLNAME */ } diff -c /home/nveid/pennmush/src/conf.c ./src/conf.c *** /home/nveid/pennmush/src/conf.c Wed Jun 14 19:59:30 2000 --- ./src/conf.c Wed Jun 14 18:47:39 2000 *************** *** 56,61 **** --- 56,64 ---- {"mud_name", cf_str, (int *) options.mud_name, 128, 0, "net"}, {"port", cf_int, &options.port, 32000, 0, "net"}, {"use_dns", cf_bool, &options.use_dns, 2, 0, "net"}, + #ifdef USE_MASTEROBJECT + {"master_object", cf_int, &options.master_object, 100000, 0, "cosmetic"}, + #endif /* USE_MASTEROBJECT */ {"ip_addr", cf_str, (int *) options.ip_addr, 64, 0, "net"}, {"input_database", cf_str, (int *) options.input_db, 256, 0, "files"}, {"output_database", cf_str, (int *) options.output_db, 256, 0, "files"}, *************** *** 522,527 **** --- 525,533 ---- options.warn_interval = 3600; #endif options.use_dns = 1; + #ifdef USE_MASTEROBJECT + options.master_object = 1; + #endif options.haspower_restricted = 0; options.safer_ufun = 1; strcpy(options.dump_warning_1min, diff -c /home/nveid/pennmush/src/funlocal.c ./src/funlocal.c *** /home/nveid/pennmush/src/funlocal.c Wed Jun 14 19:59:30 2000 --- ./src/funlocal.c Tue Jun 27 06:33:02 2000 *************** *** 36,48 **** { safe_str(tprintf("Silly%sSilly", args[0]), buff, bp); } - #endif void local_functions() { #ifdef EXAMPLE function_add("SILLY", local_fun_silly, 1, 1, FN_REG); #endif } --- 36,131 ---- { safe_str(tprintf("Silly%sSilly", args[0]), buff, bp); } #endif + FUNCTION(local_fun_wait) { + if(!command_check_byname(executor, "@wait")) + safe_str("#-1 PERMISSION DENIED", buff, bp); + else do_wait(executor, executor, args[0], args[1]); + } + + FUNCTION(local_fun_force) { + if(!command_check_byname(executor, "@force")) + safe_str("#-1 PERMISION DENIED", buff, bp); + else do_force(executor, args[0], args[1]); + } + + FUNCTION(local_fun_trigger) { + if(!command_check_byname(executor, "@trigger")) + safe_str("#-1 PERMISSION DENIED", buff, bp); + else do_trigger(executor, args[0], args); + } + + FUNCTION(local_fun_myswitch) { + char mbuf[BUFFER_LEN], pstr[BUFFER_LEN], *mbp; + char const *map; + char *tbuf1; + int j; + + if(!pstr || !mbuf) + return; + mbp = mbuf; + map = args[0]; + process_expression(mbuf, &mbp, &map, executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + *mbp = '\0'; + + /* Match all */ + for(j = 1;j < (nargs - 1); j += 2) { + mbp = pstr; + map = args[j]; + process_expression(pstr, &mbp, &map, executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + + *mbp = '\0'; + + if(local_wild_match(pstr, mbuf)) { + tbuf1 = replace_string("#$", mbuf, args[j + 1]); + map = tbuf1; + process_expression(buff, bp, &map, executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + } + } + } + + #ifdef SHOWLOG_SYS + extern struct log_list_t log_tab[]; + FUNCTION(local_fun_showlogs) { + dbref target; + unsigned char ltogs; + int i; + + target = args[0] ? lookup_player(args[0]) : executor; + + if(target == NOTHING) { + safe_str("#-1 NO SUCH PLAYER", buff, bp); + return; + } + + ltogs = *(unsigned char *) &LocData(target); + + for(i = 0;i < 7;i++) + if(ltogs & log_tab[i].toggle) { + safe_str(log_tab[i].name, buff, bp); + safe_chr(' ', buff, bp); + } + if(i > 0) + bp--; + } + #endif /* SHOWLOG_SYS */ + + void local_functions() { #ifdef EXAMPLE function_add("SILLY", local_fun_silly, 1, 1, FN_REG); #endif + function_add("TRIGGER", local_fun_trigger, 1, 11, FN_REG); + function_add("WAIT", local_fun_wait, 2, 2, FN_REG); + function_add("FORCE", local_fun_force, 2, 2, FN_REG); + function_add("ASWITCH", local_fun_myswitch, 3, INT_MAX, FN_NOPARSE); + #ifdef SHOWLOG_SYS + function_add("SHOWLOGS", local_fun_showlogs, 0, 1, FN_REG); + #endif } diff -c /home/nveid/pennmush/src/funtime.c ./src/funtime.c *** /home/nveid/pennmush/src/funtime.c Sat Jun 10 09:53:52 2000 --- ./src/funtime.c Fri Jun 16 17:05:54 2000 *************** *** 15,26 **** extern time_t mudtime; int do_convtime _((char *str, struct tm * ttm)); /* ARGSUSED */ FUNCTION(fun_time) { char *s; ! s = (char *) ctime(&mudtime); s[strlen(s) - 1] = '\0'; if (s[8] == ' ') s[8] = '0'; --- 15,42 ---- extern time_t mudtime; int do_convtime _((char *str, struct tm * ttm)); + time_t tz_charadj(char *str) { + ATTR *a; + dbref who; + + if(is_dbref(str)) { + who = parse_dbref(str); + a = atr_get(who, "TIMEZONE"); + if(a) + return parse_integer(uncompress(a->value)) * 3600; + } else if(is_integer(str)) + return parse_integer(str) * 3600; + return 0; + } + /* ARGSUSED */ FUNCTION(fun_time) { char *s; + time_t tt; ! tt = mudtime + ((nargs == 1) ? tz_charadj(args[0]) : 0); ! s = (char *) ctime(&tt); s[strlen(s) - 1] = '\0'; if (s[8] == ' ') s[8] = '0'; diff -c /home/nveid/pennmush/src/local.c ./src/local.c *** /home/nveid/pennmush/src/local.c Wed Jun 14 19:59:30 2000 --- ./src/local.c Sun Jun 18 02:00:30 2000 *************** *** 20,33 **** --- 20,163 ---- #include "htab.h" #include "command.h" #include "confmagic.h" + #ifdef SHOWLOG_SYS + #include "globals.h" + #endif /* SHOWLOG_SYS */ + #if defined(SHOWLOG_SAVE) && defined(SHOWLOG_SYS) + #include + GDBM_FILE showlog_file; + #define SHOWLOG_GDBM_FILE "data/showlog.gdbm" + #endif /* SHOWLOG_SYS & SHOWLOG_SAVE */ + #if defined(DPAGER) || defined(SHOWLOG_SYS) + #include "ddata.h" + #endif /* SHOWLOG_SYS OR DPAGER */ + #ifdef DPAGER + void dpager_schedule(DESC *, dbref, int); + static int dpage_schedules; + void dpage_check(void); + #endif /* DPAGER */ extern HASHTAB htab_reserved_aliases; + #ifdef DPAGER + void dpager_schedule(struct descriptor_data *d, dbref plyr, int wait) { + DPAGER_DATA *dp, *pdp; + time_t expire; + + expire = time((time_t *) 0); + expire += wait; + + for(pdp = dp = d->dpage_list; dp && dp->reply_plyr != plyr;pdp = dp, dp = dp->next) + ; + if(dp != NULL) { /* refresh expire & put 'em at the front */ + pdp->next = dp->next; + dp->expire = expire; + if(pdp != dp) dp->next = d->dpage_list; + d->dpage_list = dp; + return; + } + + dp = (DPAGER_DATA *) malloc(sizeof(DPAGER_DATA)); + + if(!dp) + panic("Out of memory"); + dp->reply_plyr = plyr; + dp->expire = expire; + dp->next = d->dpage_list; + d->dpage_list = dp; + dpage_schedules++; + } + #endif /* DPAGER */ + + #ifdef SHOWLOG_SYS + extern struct log_list_t log_tab[]; + void showlog_broadcast(char l, char *m, char *t) { + DESC *d; + char buf[BUFFER_LEN + 86]; + char *p; + int i; + + for(i = 0; log_tab[i].name != NULL; i++) + if(l & log_tab[i].toggle) + break; + p = strchr(m, ':'); + if(!p) + p = m; + else p = p+2; + sprintf(buf, "[%s|%s] %s", log_tab[i].name, t, p); + DESC_ITER_CONN(d) + if((*(unsigned char *)&LocData(d->player)) & l) { + queue_string(d, buf); + queue_write(d, "\r\n", 2); + process_output(d); + } + } + + char *slist_adjust(const char *s) { + static char buf[BUFFER_LEN]; + const char *p; + char *t; + + p = s; + t = buf; + *t++ = UPCASE(*p++); + while(*p) + *t++ = DOWNCASE(*p++); + *t++ = 's'; /* pluralize */ + *t++ = '\0'; + return buf; + } + #endif /* SHOWLOG_SYS */ + #ifdef USE_COLNAME + const char *colname(dbref obj) { + ATTR *a; + static char buf[BUFFER_LEN]; + + a = atr_get_noparent(obj, "COLNAME"); + if(!a) + return Name(obj); + else + strcpy(buf,uncompress(a->value)); + return buf; + } + #endif /* USE_COLNAME */ + /* Called after all MUSH init is done. */ void local_startup() { + #if defined(SHOWLOG_SYS) && defined(SHOWLOG_SAVE) + int cobj; + char tbuf[8]; + datum key, data; + + showlog_file = gdbm_open(SHOWLOG_GDBM_FILE, 512, GDBM_READER, 00664, 0); + if(!showlog_file) + do_rawlog(LT_ERR, "Can't open showlog's GDBM file. %s(%d)", gdbm_strerror(gdbm_errno), gdbm_errno); + else { + for(cobj = 0; cobj < db_top ; cobj++) + if(Typeof(cobj) == TYPE_PLAYER) { + sprintf(tbuf, "%d", cobj); + key.dptr = tbuf; + key.dsize = strlen(tbuf); + + if(!gdbm_exists(showlog_file, key)) + continue; + data = gdbm_fetch(showlog_file, key); + if(!data.dptr) { + do_rawlog(LT_ERR, "GDBM showlog retrievel of %d fucked up. %s(%d)", cobj, gdbm_strerror(gdbm_errno), gdbm_errno); + continue; + } + LocData(cobj) = (void *) *data.dptr; + } + gdbm_close(showlog_file); + } + + #endif /* SHOWLOG_SYS, SHOWLOG_SAVE */ + #ifdef DPAGER + dpage_schedules = 0; + #endif /* DPAGER */ } /* Called when the database will be saved *************** *** 39,44 **** --- 169,197 ---- void local_dump_database() { + #if defined(SHOWLOG_SYS) && defined(SHOWLOG_SAVE) + int cobj; + char tbuf[9]; + datum key, data; + + showlog_file = gdbm_open(SHOWLOG_GDBM_FILE, 512, GDBM_NEWDB, 00664, NULL); + if(!showlog_file) + do_rawlog(LT_ERR, "Can't open showlog's GDBM file, %s(%d)", gdbm_strerror(gdbm_errno), gdbm_errno); + else { + for(cobj = 0; cobj < db_top; cobj++) + if((Typeof(cobj) == TYPE_PLAYER) && LocData(cobj)) { + memset(tbuf, '\0', 9); + sprintf(tbuf, "%d", cobj); + key.dptr = tbuf; + key.dsize = strlen(tbuf); + data.dptr = (unsigned char *) &LocData(cobj); + data.dsize = 2; + if(gdbm_store(showlog_file, key, data, GDBM_INSERT) != 0) + do_rawlog(LT_ERR, "Can't store showlog info for object '%d'. %s(%d)", cobj, gdbm_strerror(gdbm_errno), gdbm_errno); + } + gdbm_close(showlog_file); + } + #endif } /* Called when the MUSH is shutting down. *************** *** 65,70 **** --- 218,246 ---- void local_timer() { + #ifdef DPAGER + struct descriptor_data *d; + DPAGER_DATA *dp, *pd; + time_t now; + now = time((time_t *) 0); + + for(d = descriptor_list; (dpage_schedules > 0) && d ; d = d->next) + if(d->dpage_list) { + if(d->dpage_list->expire >= now) { + dp = d->dpage_list->next; + free(d->dpage_list); + d->dpage_list = dp; + dpage_schedules--; + } else { + for(dp = d->dpage_list, pd = d->dpage_list; dp; pd = dp, dp = dp->next) + if(dp->expire >= now) { + pd->next = dp->next; + free(dp); + dpage_schedules--; + } + } + } + #endif } #ifdef LOCAL_DATA diff -c /home/nveid/pennmush/src/log.c ./src/log.c *** /home/nveid/pennmush/src/log.c Sat Jun 10 09:53:53 2000 --- ./src/log.c Fri Jun 16 19:14:59 2000 *************** *** 139,144 **** --- 139,147 ---- struct tm *ttm; char timebuf[16]; char tbuf1[BUFFER_LEN + 50]; + #ifdef SHOWLOG_SYS + char lt; + #endif va_list args; FILE *f = NULL; #ifndef I_STDARG *************** *** 164,192 **** --- 167,219 ---- switch (logtype) { case LT_ERR: f = stderr; + #ifdef SHOWLOG_SYS + lt = LTB_ERR; + #endif break; case LT_CMD: f = cmdlog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_CMD; + #endif break; case LT_WIZ: f = wizlog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_WIZ; + #endif break; case LT_CONN: f = connlog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_CONN; + #endif break; case LT_TRACE: f = tracelog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_TRACE; + #endif break; case LT_CHECK: f = checklog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_CHECK; + #endif break; case LT_HUH: f = cmdlog_fp; + #ifdef SHOWLOG_SYS + lt = LTB_HUH; + #endif break; default: f = stderr; break; } + #ifdef SHOWLOG_SYS + showlog_broadcast(lt, tbuf1, timebuf); + #endif /* SHOWLOG_SYS */ fprintf(f, "%s %s\n", timebuf, tbuf1); fflush(f); } diff -c /home/nveid/pennmush/src/look.c ./src/look.c *** /home/nveid/pennmush/src/look.c Sat Jun 10 09:53:53 2000 --- ./src/look.c Fri Jun 16 15:10:21 2000 *************** *** 180,186 **** --- 180,190 ---- for (; thing != NOTHING; thing = Next(thing)) { if (Name(thing) && !DarkLegal(thing) && (!Dark(loc) || Light(thing))) { + #ifndef USE_COLNAME strcpy(pbuff, Name(thing)); + #else + strcpy(pbuff, colname(thing)); + #endif /* !USE_COLNAME */ if ((p = strchr(pbuff, ';'))) *p = '\0'; p = nbuf; *************** *** 206,212 **** --- 210,220 ---- else { safe_str(" leads to ", tbuf1, &s1); if (Name(Location(thing))) + #ifndef USE_COLNAME safe_str(Name(Location(thing)), tbuf1, &s1); + #else + safe_str(colname(Location(thing)), tbuf1, &s1); + #endif /* !USE_COLNAME */ safe_chr('.', tbuf1, &s1); } *s1 = '\0'; diff -c /home/nveid/pennmush/src/predicat.c ./src/predicat.c *** /home/nveid/pennmush/src/predicat.c Wed Jun 14 19:59:30 2000 --- ./src/predicat.c Wed Jun 14 19:09:34 2000 *************** *** 185,190 **** --- 185,194 ---- int j; char *preserve[10]; int need_pres = 0; + #ifdef USE_MASTEROBJECT + char tbuf[BUFFER_LEN]; + int oldhalt; + #endif /* USE_MASTEROBJECT */ loc = (loc == NOTHING) ? Location(player) : loc; *************** *** 206,211 **** --- 210,236 ---- PE_DEFAULT, PT_DEFAULT, NULL); *bp = '\0'; notify_by(thing, player, buff); + #ifdef USE_MASTEROBJECT + d = atr_get(MASTER_OBJECT, what); + if(d) { + oldhalt = Halted(thing); + Flags(thing) &= ~HALT; + if(!need_pres) { + need_pres = 1; + save_global_regs("did_it_save", preserve); + } + asave = safe_uncompress(d->value); + ap = asave; + bp = buff; + process_expression(buff, &bp, &ap, thing, player, player, + PE_DEFAULT, PT_DEFAULT, NULL); + *bp = '\0'; + notify_by(thing, player, buff); + free((Malloc_t) asave); + Flags(thing) |= oldhalt; + } + #endif /* USE_MASTEROBJECT */ + free((Malloc_t) asave); } else if (def && *def) notify_by(thing, player, def); *************** *** 237,242 **** --- 262,291 ---- tprintf("%s %s", Name(player), odef)); } } + #ifdef USE_MASTEROBJECT + d = atr_get(MASTER_OBJECT, owhat); + if (d) { + oldhalt = Halted(thing); + Flags(thing) &= ~HALT; + if (!need_pres) { + need_pres = 1; + save_global_regs("did_it_save", preserve); + } + asave = safe_uncompress(d->value); + ap = asave; + bp = buff; + safe_str(Name(player), buff, &bp); + safe_chr(' ', buff, &bp); + sp = bp; + process_expression(buff, &bp, &ap, thing, player, player, + PE_DEFAULT, PT_DEFAULT, NULL); + *bp = '\0'; + if (bp != sp) + notify_except2(Contents(loc), player, thing, buff); + free((Malloc_t) asave); + Flags(thing) |= oldhalt; + } + #endif /* USE_MASTEROBJECT */ } } } *************** *** 247,252 **** --- 296,310 ---- rnxt[j] = NULL; } charge_action(player, thing, awhat); + #ifdef USE_MASTEROBJECT + if ((d = atr_get(MASTER_OBJECT, awhat))) { + if (!Halted(thing)) { + strcpy(tbuf, uncompress(d->value)); + parse_que(thing, tbuf, player); + } + } + #endif /* USE_MASTEROBJECT */ + } dbref diff -c /home/nveid/pennmush/src/unparse.c ./src/unparse.c *** /home/nveid/pennmush/src/unparse.c Sat Jun 10 09:53:54 2000 --- ./src/unparse.c Fri Jun 16 16:40:08 2000 *************** *** 147,153 **** --- 147,157 ---- } } else { /* Not using @nameformat */ + #ifndef USE_COLNAME strcpy(tbuf1, Name(loc)); + #else + strcpy(tbuf1, colname(loc)); + #endif /* USE_COLNAME */ } if (IsExit(loc) && obey_myopic) { if ((p = strchr(tbuf1, ';'))) diff -c /home/nveid/pennmush/hdrs/buildinf.h ./hdrs/buildinf.h *** /home/nveid/pennmush/hdrs/buildinf.h Wed Jun 14 19:59:30 2000 --- ./hdrs/buildinf.h Tue Jun 27 06:33:08 2000 *************** *** 1,5 **** /* This file generated automatically from Makefile */ ! #define BUILDDATE "Wed Jun 14 19:57:23 CDT 2000" #define COMPILER "cc" #define CCFLAGS "-g -O -W -Wreturn-type -Wswitch -Wshadow -Wwrite-strings -Wformat -Wparentheses -Wuninitialized -I.. -I../hdrs" #define RDEFS "" --- 1,5 ---- /* This file generated automatically from Makefile */ ! #define BUILDDATE "Tue Jun 27 06:33:08 CDT 2000" #define COMPILER "cc" #define CCFLAGS "-g -O -W -Wreturn-type -Wswitch -Wshadow -Wwrite-strings -Wformat -Wparentheses -Wuninitialized -I.. -I../hdrs" #define RDEFS "" diff -c /home/nveid/pennmush/hdrs/cmds.h ./hdrs/cmds.h *** /home/nveid/pennmush/hdrs/cmds.h Wed Jun 14 19:59:30 2000 --- ./hdrs/cmds.h Tue Jun 27 06:33:08 2000 *************** *** 145,147 **** --- 145,151 ---- COMMAND_PROTO(cmd_wizwall); COMMAND_PROTO(cmd_zemit); COMMAND_PROTO(command_atrset); + COMMAND_PROTO(local_cmd_colname); + COMMAND_PROTO(local_cmd_cwho); + COMMAND_PROTO(local_cmd_dpage); + COMMAND_PROTO(local_cmd_showlog); diff -c /home/nveid/pennmush/hdrs/conf.h ./hdrs/conf.h *** /home/nveid/pennmush/hdrs/conf.h Wed Jun 14 19:59:56 2000 --- ./hdrs/conf.h Thu Jun 15 03:20:32 2000 *************** *** 14,20 **** /*----- Miscellaneous other stuff -----*/ ! /* limit on player name length */ #define PLAYER_NAME_LIMIT 16 /* limit on object name length */ --- 14,22 ---- /*----- Miscellaneous other stuff -----*/ ! #ifndef LOCAL_DATA ! #undef SHOWLOG_SYS ! #endif /* !LOCAL_DATA */ /* limit on player name length */ #define PLAYER_NAME_LIMIT 16 /* limit on object name length */ *************** *** 179,184 **** --- 181,189 ---- #endif int base_room; int use_dns; + #ifdef USE_MASTEROBJECT + int master_object; + #endif /* USE_MASTEROBJECT */ int haspower_restricted; int safer_ufun; char dump_warning_1min[256]; *************** *** 282,288 **** (Wizard(p) && (g->viewperms & CGP_WIZARD)) || \ (Hasprivs(p) && (g->viewperms & CGP_ADMIN))) ! #define DUMP_INTERVAL (options.dump_interval) #define DUMP_NOFORK_MESSAGE (options.dump_message) #define DUMP_NOFORK_COMPLETE (options.dump_complete) --- 287,295 ---- (Wizard(p) && (g->viewperms & CGP_WIZARD)) || \ (Hasprivs(p) && (g->viewperms & CGP_ADMIN))) ! #ifdef USE_MASTEROBJECT ! #define MASTER_OBJECT (options.master_object) ! #endif /* USE_MASTEROBJECT */ #define DUMP_INTERVAL (options.dump_interval) #define DUMP_NOFORK_MESSAGE (options.dump_message) #define DUMP_NOFORK_COMPLETE (options.dump_complete) diff -c /home/nveid/pennmush/hdrs/externs.h ./hdrs/externs.h *** /home/nveid/pennmush/hdrs/externs.h Wed Jun 14 19:59:30 2000 --- ./hdrs/externs.h Fri Jun 16 15:16:15 2000 *************** *** 447,452 **** --- 447,480 ---- void local_data_clone _((dbref clone, dbref source)); void local_data_free _((dbref object)); #endif + #ifdef DPAGER + typedef struct dpage_reply_data_t { + dbref reply_plyr; + time_t expire; + struct dpage_reply_data_t *next; + } DPAGER_DATA; + extern void dpager_schedule(DESC *, dbref, int); + #endif /* DPAGER */ + #ifdef SHOWLOG_SYS + /* */ + #define LTB_ERR 0x01 + #define LTB_CMD 0x02 + #define LTB_WIZ 0x04 + #define LTB_CONN 0x08 + #define LTB_TRACE 0x10 + #define LTB_CHECK 0x20 + #define LTB_HUH 0x40 + /* */ + struct log_list_t { + const char *name; + unsigned char toggle; + }; + void showlog_broadcast(char, char *, char *); + char *slist_adjust(const char *); + #endif /* SHOWLOG_SYS */ + #ifdef USE_COLNAME + const char *colname(dbref); + #endif /* USE_COLNAME */ /* funlist.c */ void do_gensort _((char **s, int n, int sort_type)); diff -c /home/nveid/pennmush/hdrs/funs.h ./hdrs/funs.h *** /home/nveid/pennmush/hdrs/funs.h Wed Jun 14 19:59:30 2000 --- ./hdrs/funs.h Tue Jun 27 06:33:08 2000 *************** *** 293,296 **** --- 293,301 ---- FUNCTION_PROTO(fun_zemit); FUNCTION_PROTO(fun_zfun); FUNCTION_PROTO(fun_zone); + FUNCTION_PROTO(local_fun_force); + FUNCTION_PROTO(local_fun_myswitch); + FUNCTION_PROTO(local_fun_showlogs); FUNCTION_PROTO(local_fun_silly); + FUNCTION_PROTO(local_fun_trigger); + FUNCTION_PROTO(local_fun_wait); *** /dev/null Sat Nov 27 07:16:32 1999 --- ./hdrs/ddata.h Tue Jun 13 17:36:52 2000 *************** *** 0 **** --- 1,62 ---- + #ifndef __DDATA_H_ + #define __DDATA_H_ + struct text_block { + int nchars; + struct text_block *nxt; + char *start; + char *buf; + }; + struct text_queue { + struct text_block *head; + struct text_block **tail; + }; + + struct descriptor_data { + int descriptor; + int connected; + char addr[101]; + char ip[101]; + dbref player; + char *output_prefix; + char *output_suffix; + int output_size; + struct text_queue output; + struct text_queue input; + char *raw_input; + char *raw_input_at; + long connected_at; + long last_time; + int quota; + int cmds; + int hide; + char doing[DOING_LEN]; + #ifdef NT_TCP + /* these are for the Windows NT TCP/IO */ + char input_buffer[512]; /* buffer for reading */ + char output_buffer[512]; /* buffer for writing */ + OVERLAPPED InboundOverlapped; /* for asynchronous reading */ + OVERLAPPED OutboundOverlapped; /* for asynchronous writing */ + BOOL bWritePending; /* true if in process of writing */ + BOOL bConnectionDropped; /* true if we cannot send to player */ + BOOL bConnectionShutdown; /* true if connection has been shutdown */ + #endif + struct descriptor_data *next; + struct descriptor_data *prev; + #ifdef USE_MAILER + struct mail *mailp; + #endif + #ifdef DPAGER + DPAGER_DATA *dpage_list; + #endif /* DPAGER */ + int pueblo; + }; + + + extern struct descriptor_data *descriptor_list; + + #define DESC_ITER_CONN(d) \ + for(d = descriptor_list;(d);d=(d)->next) \ + if((d)->connected) + #define Hidden(d) ((d->hide == 1) && Can_Hide(d->player)) + + #endif /* __DDATA_H_ */