/* * The unique portions of SunderMud code as well as the integration efforts * for code from other sources is based on the efforts of: * * Lotherius (elfren@aros.net) * * This code can only be used under the terms of the DikuMud, Merc, * and ROM licenses. The same requirements apply to the changes that * have been made. * * All other copyrights remain in place and in force. */ /* * notify.c - added by Zeran to support notification and wiznet systems for * various events in Dark Times. Note, wiznet was hacked in after the * notify system, thus the somewhat odd handling to avoid dup'ing code * like crazy. */ #include "everything.h" DECLARE_DO_FUN ( do_help ); struct event_type { char *event_name; int event_flag; int level; } ; struct event_type wiznet_table [] = { /* { "event", WIZNET_FLAG, LEVEL }, */ { "sites", WIZNET_SITES, LEVEL_IMMORTAL }, { "newbie", WIZNET_NEWBIE, LEVEL_IMMORTAL }, { "spam", WIZNET_SPAM, LEVEL_IMMORTAL }, { "death", WIZNET_DEATH, LEVEL_IMMORTAL }, { "reset", WIZNET_RESET, LEVEL_IMMORTAL }, { "mobdeath", WIZNET_MOBDEATH, LEVEL_IMMORTAL }, { "bug", WIZNET_BUG, LEVEL_IMMORTAL }, { "switch", WIZNET_SWITCH, LEVEL_IMMORTAL }, { "links", WIZNET_LINK, LEVEL_IMMORTAL }, { "load", WIZNET_LOAD, LEVEL_ADMIN }, { "restore", WIZNET_RESTORE, LEVEL_ADMIN }, { "snoop", WIZNET_SNOOP, LEVEL_ADMIN }, { "secure", WIZNET_SECURE, LEVEL_ADMIN }, { "", -1, -1 } }; struct event_type notify_table [] = { { "level", NOTIFY_LEVEL, 1 }, { "death", NOTIFY_DEATH, 1 }, { "delete", NOTIFY_DELETE, 1 }, { "login", NOTIFY_LOGIN, 1 }, { "quitgame", NOTIFY_QUITGAME, 1 }, { "lostlink", NOTIFY_LOSTLINK, 1 }, { "reconnect", NOTIFY_RECONNECT, 1 }, { "newnote", NOTIFY_NEWNOTE, 1 }, { "tick", NOTIFY_TICK, LEVEL_IMMORTAL }, { "weather", NOTIFY_WEATHER, LEVEL_IMMORTAL }, { "clanaccept", NOTIFY_CLANACCEPT, 1 }, { "clanpromote",NOTIFY_CLANPROMOTE, 1 }, { "clanquit", NOTIFY_CLANQUIT, 1 }, { "repop", NOTIFY_REPOP, LEVEL_IMMORTAL }, { "", -1 -1 } }; void do_wiznet ( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int count; int level; char outbuf[MAX_STRING_LENGTH]; level = get_trust (ch); if (argument == NULL || argument[0] == '\0' || !str_cmp (argument, "status") ) { send_to_char ("{CWiznet events{x\n\r",ch); send_to_char ("------ --------\n\r",ch); for (count = 0 ; wiznet_table[count].event_name[0] != '\0' ; count++) { if (wiznet_table[count].level <= level ) { sprintf (outbuf, "{c%-12s{x", wiznet_table[count].event_name); send_to_char(outbuf, ch); if (IS_SET(ch->wiznet, wiznet_table[count].event_flag)) send_to_char ("{gON{x\n\r",ch); else send_to_char ("{rOFF{x\n\r",ch); } } send_to_char ("\n\r",ch); return; } /* end event status display */ else /* check for valid command */ { one_argument (argument, arg); if (!str_cmp (arg, "off")) { ch->wiznet = 0; send_to_char ("All Wiznet events turned off.\n\r",ch); return; } else if (!str_cmp (arg, "help")) { do_help (ch, "wiznet"); return; } for (count = 0 ; wiznet_table[count].event_name[0] != '\0' ; count++) { if (!str_cmp (arg, wiznet_table[count].event_name) && level >= wiznet_table[count].level ) { if (IS_SET(ch->wiznet, wiznet_table[count].event_flag)) { ch->wiznet-=wiznet_table[count].event_flag; sprintf (outbuf, "Wiznet {c%s{x is now {roff{x.\n\r", wiznet_table[count].event_name); send_to_char (outbuf, ch); return; } else { ch->wiznet+=wiznet_table[count].event_flag; sprintf (outbuf, "Wiznet {c%s{x is now {gon{x.\n\r", wiznet_table[count].event_name); send_to_char (outbuf, ch); return; } } } /* end match command loop */ send_to_char ("No such wiznet event...\n\r",ch); } /* end match command section */ } /* end wiznet function */ void do_notify (CHAR_DATA *ch, char *argument) { char arg[MAX_INPUT_LENGTH]; int count; int level; char outbuf[MAX_STRING_LENGTH]; level = get_trust (ch); if (argument == NULL || argument[0] == '\0' || !str_cmp (argument, "status") ) { send_to_char ("{CNotify events{x\n\r",ch); send_to_char ("------ --------\n\r",ch); for (count = 0 ; notify_table[count].event_name[0] != '\0' ; count++) { if (notify_table[count].level <= level ) { sprintf (outbuf, "{c%-12s{x", notify_table[count].event_name); send_to_char(outbuf, ch); if (IS_SET(ch->notify, notify_table[count].event_flag)) send_to_char ("{gON{x\n\r",ch); else send_to_char ("{rOFF{x\n\r",ch); } } send_to_char ("\n\r",ch); return; } /* end event status display */ else /* check for valid command */ { one_argument (argument, arg); if (!str_cmp (arg, "none")) { ch->notify = 0; send_to_char ("All Notify events turned off.\n\r",ch); return; } else if (!str_cmp (arg, "help")) { do_help (ch, "notify"); return; } else if (!str_cmp (arg, "all")) { ch->notify = NOTIFY_ALL; send_to_char ("All Notify events turned on.\n\r",ch); return; } for (count = 0 ; notify_table[count].event_name[0] != '\0' ; count++) { if (!str_cmp (arg, notify_table[count].event_name) && level >= notify_table[count].level ) { if (IS_SET(ch->notify, notify_table[count].event_flag)) { ch->notify-=notify_table[count].event_flag; sprintf (outbuf, "Notify {c%s{x is now {roff{x.\n\r", notify_table[count].event_name); send_to_char (outbuf, ch); return; } else { ch->notify+=notify_table[count].event_flag; sprintf (outbuf, "Notify {c%s{x is now {gon{x.\n\r", notify_table[count].event_name); send_to_char (outbuf, ch); return; } } } /* end match command loop */ send_to_char ("No such notify event...\n\r",ch); } /* end match command section */ } /* end notify function */ /* function to be called throughout code whenever notify or wiznet is needed */ void notify_message (CHAR_DATA *ch, long type, long to, char *extra_name) { char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; bool need_vision=FALSE; bool notify_note=FALSE; bool notify_repop=FALSE; bool check_vict_lvl=FALSE; bool is_wiznet=FALSE; bool is_secure=FALSE; long plr_var_type; /* Ok, hack for wiznet messaging without duplicating all this code */ if (to >= TO_WIZNET) { char tmpbuf[MAX_STRING_LENGTH]; is_wiznet=TRUE; switch (type) { case WIZNET_SITES: sprintf (tmpbuf, "Connect by: [ %s ]\n\r", extra_name); check_vict_lvl = TRUE; break; case WIZNET_NEWBIE: sprintf (tmpbuf, "New player: [ %s ]\n\r", ch->name); break; case WIZNET_LINK: sprintf (tmpbuf, "Links: [ %s ]\n\r", extra_name); check_vict_lvl = TRUE; break; case WIZNET_SPAM: sprintf (tmpbuf, "Spam: [ %s ] [ %s ]\n\r", ch->name, extra_name); break; case WIZNET_DEATH: sprintf (tmpbuf, "Death: [ %s ]\n\r", extra_name); break; case WIZNET_RESET: sprintf (tmpbuf, "Repop: [ %s ]\n\r", extra_name); break; case WIZNET_MOBDEATH: sprintf (tmpbuf, "Mob death: [ %s ]\n\r", extra_name); break; case WIZNET_BUG: sprintf (tmpbuf, "Bug: [ %s ]\n\r", extra_name); break; case WIZNET_SWITCH: sprintf (tmpbuf, "Switch: by [ %s ] into [ %s ]\n\r", ch->name, extra_name); check_vict_lvl=TRUE; break; case WIZNET_LOAD: sprintf (tmpbuf, "Load: by [ %s ] of [ %s ]\n\r",ch->name, extra_name); check_vict_lvl=TRUE; break; case WIZNET_RESTORE: sprintf (tmpbuf, "Restore: by [ %s ] of [ %s ]\n\r", ch->name, extra_name); check_vict_lvl=TRUE; break; case WIZNET_SNOOP: sprintf (tmpbuf, "Snoop: by [ %s ] of [ %s ]\n\r", ch->name, extra_name); check_vict_lvl=TRUE; break; case WIZNET_SECURE: sprintf (tmpbuf, "Secure: [ %s ]\n\r", extra_name); is_secure = TRUE; break; default: sprintf (tmpbuf, "Unrecognized wiznet event, please inform coders.\n\r"); break; } /* end switch */ sprintf (buf, "{y----> {BWIZNET{y <----{x\n\r"); strcat (buf, tmpbuf); } /* end if wiznet */ else { is_wiznet=FALSE; switch (type) { case NOTIFY_LEVEL: sprintf (buf, "{BNotify{r->{x %s has gained a level!\n\r", ch->name); break; case NOTIFY_LOGIN: sprintf (buf, "{BNotify{r->{x %s has entered the portal leading to SunderMud.\n\r",ch->name); need_vision=TRUE; break; case NOTIFY_QUITGAME: sprintf (buf, "{BNotify{r->{x %s has found the portal back to reality.\n\r",ch->name); need_vision=TRUE; break; case NOTIFY_DELETE: sprintf (buf, "{BNotify{r->{x %s has deleted...\n\r",ch->name); break; case NOTIFY_DEATH: if (str_cmp(ch->name, extra_name)) sprintf (buf, "{BNotify{r->{x %s killed by %s.\n\r",ch->name, extra_name); else sprintf (buf, "{BNotify{r->{x %s has died.\n\r",ch->name); break; case NOTIFY_LOSTLINK: sprintf (buf, "{BNotify{r->{x %s has gone link dead.\n\r",ch->name); need_vision=TRUE; break; case NOTIFY_RECONNECT: sprintf (buf, "{BNotify{r->{x %s has reconnected.\n\r",ch->name); need_vision=TRUE; break; case NOTIFY_NEWNOTE: sprintf (buf, "{BNotify{r->{x A new message has been posted!.\n\r"); notify_note=TRUE; need_vision = TRUE; break; case NOTIFY_TICK: sprintf (buf, "TICK...\n\r"); break; case NOTIFY_CLANACCEPT: sprintf (buf, "{BClan Notify{r->{x %s has been accepted into clan %s.\n\r",ch->name, extra_name); break; case NOTIFY_CLANPROMOTE: sprintf (buf, "{BClan Notify{r->{x %s has been promoted to the clan rank of %s.\n\r", ch->name, extra_name); break; case NOTIFY_CLANQUIT: sprintf (buf, "{BClan Notify{r->{x %s has quit clan %s.\n\r",ch->name, extra_name); break; case NOTIFY_REPOP: sprintf (buf, "{CRepop:{x Area %s has reset.\n\r", extra_name); notify_repop=TRUE; break; default: { char messbuf[80]; sprintf (messbuf, "Unrecognized NOTIFY code [%ld]", type); bug (messbuf,0); break; } } /*end switch*/ } /* end else notify message section */ /* got message, send to appropriate characters */ for ( d = descriptor_list; d != NULL; d = d->next ) { CHAR_DATA *victim; victim = d->original ? d->original : d->character; if (d->connected != CON_PLAYING) continue; if (is_wiznet) plr_var_type = victim->wiznet; else plr_var_type = victim->notify; if ( d->connected == CON_PLAYING && IS_SET(plr_var_type,type) && !IS_SET(victim->comm,COMM_QUIET) ) { if (is_secure && ch == victim) continue; if (check_vict_lvl && get_trust(victim) < get_trust(ch) ) continue; if (notify_note ) continue; if (need_vision && !can_see (victim, ch) ) continue; if (notify_repop && (!IS_IMMORTAL(victim) || str_cmp(victim->in_room->area->name, extra_name) ) ) continue; if ( to == TO_IMM && !IS_IMMORTAL(victim) ) continue; if ( to == TO_IMM_ADMIN && get_trust(victim) < TO_IMM_ADMIN) continue; if ( to == TO_IMP && !IS_IMP(victim) ) continue; if ( (to == TO_CLAN) && (victim->pcdata->clan_num != ch->pcdata->clan_num) ) continue; send_to_char (buf, victim); } } /*end for*/ } /*end notify_message */