/**************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefiting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************
* ROM 2.4 is copyright 1993-1998 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor (rtaylor@hypercube.org) *
* Gabrielle Taylor (gtaylor@hypercube.org) *
* Brian Moore (zump@rom.org) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Rom24/doc/rom.license *
***************************************************************************
***************************************************************************/
#include "merc.h"
#include "interp.h"
#include "tables.h"
#include "globals.h"
#include "recycle.h"
PROTOTYPE(void show_flags, (CHAR_DATA *, const struct flag_type *));
bool is_ignoring(CHAR_DATA * ch, const char *name, flag_t bit)
{
int pos;
if (ch == NULL || IS_NULLSTR(name))
return FALSE;
if (IS_NPC(ch))
return FALSE;
for (pos = 0; pos < MAX_IGNORE; pos++)
{
if (IS_NULLSTR(ch->pcdata->ignore[pos]))
break;
if (is_name(ch->pcdata->ignore[pos], name))
{
if (bit == 0
|| IS_SET(ch->pcdata->ignore_flags[pos], bit | IGNORE_ALL))
return TRUE;
}
}
return FALSE;
}
CH_CMD(do_ignore)
{
CHAR_DATA *victim;
char arg[MIL];
int pos;
bool found = FALSE;
CHAR_DATA *wch;
flag_t iValue;
argument = one_argument(argument, arg);
if (IS_NPC(ch))
return;
if (IS_NULLSTR(arg))
{
BUFFER *output = new_buf();
bprintln(output, "People you are ignoring:");
bprintln(output, draw_line(ch, "-", 0));
for (pos = 0; pos < MAX_IGNORE; pos++)
{
if (IS_NULLSTR(ch->pcdata->ignore[pos]))
break;
found = TRUE;
bprintlnf(output, "[%02d] %-12s", pos + 1, ch->pcdata->ignore[pos]);
}
if (!found)
bprintln(output, "No one.");
found = FALSE;
pos = 0;
bprintln(output, "");
bprintln(output, "People online who are ignoring you:");
bprintln(output, draw_line(ch, "-", 0));
for (wch = player_first; wch != NULL; wch = wch->next_player)
{
if (!can_see(ch, wch) || !is_ignoring(wch, ch->name, 0))
continue;
pos++;
found = TRUE;
bprintlnf(output, "[%02d] %s", pos, wch->name);
}
if (!found)
bprintln(output, "No one.");
bprintln(output, "");
bprintln
(output,
"Use 'ignore list' to show possible flags, use 'ignore <name> <flag>' to set a flags.");
sendpage(ch, buf_string(output));
free_buf(output);
return;
}
if (IS_NULLSTR(argument))
{
if (!str_cmp(arg, "list"))
{
show_flags(ch, ignore_flags);
return;
}
found = FALSE;
for (pos = 0; pos < MAX_IGNORE; pos++)
{
if (IS_NULLSTR(ch->pcdata->ignore[pos]))
break;
if (found)
{
replace_string(ch->pcdata->ignore[pos - 1],
ch->pcdata->ignore[pos]);
free_string(ch->pcdata->ignore[pos]);
ch->pcdata->ignore[pos] = NULL;
continue;
}
if (!str_cmp(arg, ch->pcdata->ignore[pos]))
{
free_string(ch->pcdata->ignore[pos]);
ch->pcdata->ignore[pos] = NULL;
found = TRUE;
}
}
if (found)
{
chprintlnf(ch, "You stop ignoring %s.", arg);
return;
}
}
else
{
for (pos = 0; pos < MAX_IGNORE; pos++)
{
if (IS_NULLSTR(ch->pcdata->ignore[pos]))
break;
if (!str_cmp(arg, ch->pcdata->ignore[pos]))
{
found = TRUE;
break;
}
}
if (!found)
{
chprintln(ch, "They are not on your ignore list.");
return;
}
}
if (pos >= MAX_IGNORE)
{
chprintln(ch, "You can't ignore anymore people");
return;
}
if ((victim = get_char_world(ch, arg)) == NULL)
{
chprintln(ch, "That character isn't online.");
return;
}
else
{
if (IS_NPC(victim))
{
chprintln(ch, "Ignore a mob? I don't think so.");
return;
}
if (ch == victim)
{
chprintln(ch, "I don't think you really want to ignore yourself.");
return;
}
if (!is_exact_name(victim->name, arg))
{
chprintln(ch, "You must spell out their entire name.");
return;
}
if (IS_IMMORTAL(victim))
{
chprintln(ch, "You're not going to ignore us that easily!");
return;
}
}
if (IS_NULLSTR(argument))
{
replace_string(ch->pcdata->ignore[pos], capitalize(arg));
ch->pcdata->ignore_flags[pos] = IGNORE_CHANNELS;
chprintlnf(ch, "You now ignore %s.", capitalize(arg));
chprintln
(ch,
"Use 'ignore list' to show possible flags, use 'ignore <name> <flag>' to set a flags.");
}
else if ((iValue = flag_value(ignore_flags, argument)) != NO_FLAG)
{
set_on_off(ch, &ch->pcdata->ignore_flags[pos], iValue,
FORMATF("%s ignore flag set for %s.",
flag_string(ignore_flags, iValue),
ch->pcdata->ignore[pos]),
FORMATF("%s ignore flag removed for %s.",
flag_string(ignore_flags, iValue),
ch->pcdata->ignore[pos]));
return;
}
else
{
int i;
chprintlnf(ch, "Valid flags for %s are:", arg);
for (i = 0; ignore_flags[i].name != NULL; i++)
{
print_on_off(ch,
IS_SET(ch->pcdata->ignore_flags[pos],
ignore_flags[i].bit), ignore_flags[i].name,
NULL);
chprintln(ch, "");
}
}
return;
}