notify.c
TinyMAZE/src/io/notify.c · 2.1 KB
From the archive TinyMAZEv2.5a.tar.gz
Download the archive « Back to the archive contents
#include <stdio.h>
#include <string.h>
#include "db.h"
#include "externs.h"
void notify(OBJ *player, char *msg)
{
raw_notify(player, msg, 1);
if(player->flags & PUPPET && player->owner != player &&
player->owner->location != player->location)
{
raw_notify(player->owner,
tprintf("%s|+W|> %s", name(player), msg), 1);
}
}
void notify_in(OBJ *room, OBJ *exception, char *msg)
{
OBJ *o;
for(o = room->contents;o;o = o->next_con)
if(o != exception)
notify(o, msg);
}
void notify_in2(OBJ *room, OBJ *exception1, OBJ *exception2, char *msg)
{
OBJ *o;
for(o = room->contents;o;o = o->next_con)
if(o != exception1 && o != exception2)
notify(o, msg);
}
void notify_all(char *arg, OBJ *exception)
{
DDATA *d;
OBJ *list[100];
int i, ctr = 0;
for(d = descriptor_list;d;d = d->next)
{
if(!check_state(d, STATE_CONNECTED) || d->player == exception)
continue;
for(i = 0;i < ctr;++i)
if(list[i] == d->player)
break;
if(i == ctr)
{
notify(d->player, arg);
list[ctr++] = d->player;
}
}
}
/* Just like notify_all() but doesn't send to people who are NO_WALLS. */
void notify_except_flag(char *arg, OBJ *exception, unsigned long flag)
{
DDATA *d;
OBJ *list[100];
int i, ctr = 0;
for(d = descriptor_list;d;d = d->next)
{
if(!check_state(d, STATE_CONNECTED) || d->player == exception ||
d->player->flags & flag)
continue;
for(i = 0;i < ctr;++i)
if(list[i] == d->player)
break;
if(i == ctr)
{
notify(d->player, arg);
list[ctr++] = d->player;
}
}
}
/* Just like notify_all() but doesn't check if the descriptor is connected */
/* Also doesn't support color */
/* Made for the db loading routine */
void notify_all2(char *arg, OBJ *exception)
{
DDATA *d;
for(d = descriptor_list;d;d = d->next)
{
/* Check for d->player here because on reboot d->player is NULL until */
/* reference_db() is called...but we still want to send the */
/* descriptor messages while the MAZE is rebooting */
if(d->player && d->player == exception)
continue;
queue_string(d, arg, 1);
}
}