tmi2_fluffos_v2/
tmi2_fluffos_v2/bin/
tmi2_fluffos_v2/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/ChangeLog.old/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/Win32/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/simuls/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/clone/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/command/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/data/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/master/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/log/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/u/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/tmp/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/windows/
tmi2_fluffos_v2/lib/
tmi2_fluffos_v2/lib/adm/
tmi2_fluffos_v2/lib/adm/daemons/languages/
tmi2_fluffos_v2/lib/adm/daemons/network/I3/
tmi2_fluffos_v2/lib/adm/daemons/virtual/
tmi2_fluffos_v2/lib/adm/daemons/virtual/template/
tmi2_fluffos_v2/lib/adm/news/
tmi2_fluffos_v2/lib/adm/obj/
tmi2_fluffos_v2/lib/adm/obj/master/
tmi2_fluffos_v2/lib/adm/priv/
tmi2_fluffos_v2/lib/adm/shell/
tmi2_fluffos_v2/lib/adm/tmp/
tmi2_fluffos_v2/lib/cmds/
tmi2_fluffos_v2/lib/d/
tmi2_fluffos_v2/lib/d/Conf/
tmi2_fluffos_v2/lib/d/Conf/adm/
tmi2_fluffos_v2/lib/d/Conf/boards/
tmi2_fluffos_v2/lib/d/Conf/cmds/
tmi2_fluffos_v2/lib/d/Conf/data/
tmi2_fluffos_v2/lib/d/Conf/logs/
tmi2_fluffos_v2/lib/d/Conf/obj/
tmi2_fluffos_v2/lib/d/Conf/text/help/
tmi2_fluffos_v2/lib/d/Fooland/adm/
tmi2_fluffos_v2/lib/d/Fooland/data/
tmi2_fluffos_v2/lib/d/Fooland/data/attic/
tmi2_fluffos_v2/lib/d/Fooland/items/
tmi2_fluffos_v2/lib/d/TMI/
tmi2_fluffos_v2/lib/d/TMI/adm/
tmi2_fluffos_v2/lib/d/TMI/boards/
tmi2_fluffos_v2/lib/d/TMI/data/
tmi2_fluffos_v2/lib/d/TMI/rooms/
tmi2_fluffos_v2/lib/d/grid/
tmi2_fluffos_v2/lib/d/grid/adm/
tmi2_fluffos_v2/lib/d/grid/data/
tmi2_fluffos_v2/lib/d/std/
tmi2_fluffos_v2/lib/d/std/adm/
tmi2_fluffos_v2/lib/data/adm/
tmi2_fluffos_v2/lib/data/adm/daemons/
tmi2_fluffos_v2/lib/data/adm/daemons/doc_d/
tmi2_fluffos_v2/lib/data/adm/daemons/emoted/
tmi2_fluffos_v2/lib/data/adm/daemons/network/http/
tmi2_fluffos_v2/lib/data/adm/daemons/network/services/mail_q/
tmi2_fluffos_v2/lib/data/adm/daemons/network/smtp/
tmi2_fluffos_v2/lib/data/adm/daemons/news/archives/
tmi2_fluffos_v2/lib/data/attic/connection/
tmi2_fluffos_v2/lib/data/attic/user/
tmi2_fluffos_v2/lib/data/std/connection/b/
tmi2_fluffos_v2/lib/data/std/connection/l/
tmi2_fluffos_v2/lib/data/std/user/a/
tmi2_fluffos_v2/lib/data/std/user/b/
tmi2_fluffos_v2/lib/data/std/user/d/
tmi2_fluffos_v2/lib/data/std/user/f/
tmi2_fluffos_v2/lib/data/std/user/l/
tmi2_fluffos_v2/lib/data/std/user/x/
tmi2_fluffos_v2/lib/data/u/d/dm/working/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/smtp/
tmi2_fluffos_v2/lib/doc/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/interactive/
tmi2_fluffos_v2/lib/doc/driverdoc/concepts/
tmi2_fluffos_v2/lib/doc/driverdoc/driver/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/arrays/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/buffers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/compile/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/ed/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/filesystem/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/floats/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/functions/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/general/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/mappings/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/numbers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/parsing/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/constructs/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/preprocessor/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/types/
tmi2_fluffos_v2/lib/doc/driverdoc/platforms/
tmi2_fluffos_v2/lib/doc/mudlib/
tmi2_fluffos_v2/lib/ftp/
tmi2_fluffos_v2/lib/include/driver/
tmi2_fluffos_v2/lib/log/
tmi2_fluffos_v2/lib/log/driver/
tmi2_fluffos_v2/lib/obj/net/
tmi2_fluffos_v2/lib/obj/shells/
tmi2_fluffos_v2/lib/obj/tools/
tmi2_fluffos_v2/lib/std/adt/
tmi2_fluffos_v2/lib/std/board/
tmi2_fluffos_v2/lib/std/body/
tmi2_fluffos_v2/lib/std/fun/
tmi2_fluffos_v2/lib/std/living/
tmi2_fluffos_v2/lib/std/object/
tmi2_fluffos_v2/lib/std/shop/
tmi2_fluffos_v2/lib/std/socket/
tmi2_fluffos_v2/lib/std/user/
tmi2_fluffos_v2/lib/std/virtual/
tmi2_fluffos_v2/lib/student/
tmi2_fluffos_v2/lib/student/kalypso/
tmi2_fluffos_v2/lib/student/kalypso/armor/
tmi2_fluffos_v2/lib/student/kalypso/rooms/
tmi2_fluffos_v2/lib/student/kalypso/weapons/
tmi2_fluffos_v2/lib/u/l/leto/
tmi2_fluffos_v2/lib/u/l/leto/cmds/
tmi2_fluffos_v2/lib/www/errors/
tmi2_fluffos_v2/lib/www/gateways/
tmi2_fluffos_v2/lib/www/images/
tmi2_fluffos_v2/old/
tmi2_fluffos_v2/win32/
 
//	File	:  /adm/daemons/news.c
//	Creator	:  Glenn Ferguson  (Watcher@TMI)  02/03/93
//
//	This daemon handles the MOTD/NEWS displayed to a 
//	user on login.  It distinguishes between type of
//	user and how many times they have seen a message.
//
// 19-Dec-94 Leto added some copy()'s to prevent fake news ;)
 
#include <mudlib.h>
#include <config.h>
#include <ansi.h>
 
inherit DAEMON ;
 
// If HEADER = 1, the header will be placed on news message
// If HEADER = 0, the header will be ignored 
 
#define	HEADER	1
 
// If ANSI = 1, portions of the header will be bolded
// If ANSI = 0, standard header output will be used
 
#define ANSI	0
 
#define MUD_INTRO	NEWS_DIR + "news"
 
int load_news_list();
static int sweep_save();
static string add_message(string file);
static string make_header(string file, string type, int date);
static int check_read_num(string file, int view);
 
mapping list;
string *files;
 
void create() {  ::create();  load_news_list();  }
 
int load_news_list() {
   mixed *dir;
   string type;
   int date, view, loop;
 
   //	First declare the master list mapping
 
   list = ([ ]);
 
   //	Get array of all filenames in the news directory

   dir = get_dir( NEWS_DIR );
   if(!dir || !sizeof(dir))  return 0;		// Hmmmm...no news files
 
   for(loop=0; loop<sizeof(dir); loop++) {
 
   //	First parse the news item for structure info and
   //	discard any that do not match the preset format
 
   if(!dir || sscanf(dir[loop],"%d:%s:%d", date, type, view) != 3)
	continue;
 
   //	Save news item information in master list mapping
 
   list[ dir[loop] ] = ([ "date" : date, "type" : type, "view" : view ]);
   }
 
   //	Produce a list of news files in the master list mapping
 
   files = keys( list );
 
return 1; }
 
mapping query_list() {  return copy(list); }
 
 string *query_files() {  return copy(files); }
 
//   Display the news to user when called during login.  The news
//   are returned in the form of a string in case someone wants to
//   put the output in the form of a more, in the future.
 
string display_news() {
   string output, who;
   int loop, flag;
 
   // 	Initalize MOTD output string
 
   if(file_exists( MUD_INTRO ))  output = read_file( MUD_INTRO );
   else output = "";
 
   if (this_player()->query("hushlogin")) output = "";
   for(loop=0; loop<sizeof(files); loop++) {
 
   //	Ignore player news when user is a wizard
 
   if(list[files[loop]]["type"] == "p" && wizardp(this_player()))
	continue;
 
   //	Ignore wizard news when user is a player
 
   if(list[files[loop]]["type"] == "w" && !wizardp(this_player()))
	continue;
 
   //	Display news file if no view time limitations
 
   if(list[files[loop]]["view"] == 0) {
 
   if(HEADER)  
      output += make_header(files[loop], list[files[loop]]["type"],
			    list[files[loop]]["date"]);
 
   output += add_message(files[loop]);  flag++;  continue;  }

 
   //	Display news file if view times is under required
 
   if(check_read_num(files[loop], list[files[loop]]["view"])) {
 
   if(HEADER)
      output += make_header(files[loop], list[files[loop]]["type"],
			    list[files[loop]]["date"]);
 
   output += add_message(files[loop]);  flag++;  continue;  }
 
   }
 
   who = (string) this_player()->query("name");
 
   if(!flag)  output += "** No new News to read **\n\n";
 
   //  Clean up old news file names saved in user mapping
 
   sweep_save();
 
return output; }
 
//	Check to see how many times the news item has been
//	read by this user and save updated count.
 
static int check_read_num(string file, int view) {
   mapping store;
 
   store = this_player()->query("news_save");
   if(!store)  store = ([ ]);
 
   if(store[file]) {
   if(store[file] == view)  return 0;		// Viewed required times
 
   store[file]++;
   this_player()->set("news_save", store);
   return 1; }
 
   store[file] = 1;
   this_player()->set("news_save", store);
 
return  1; }
 
//	Check through user's stored files and delete old versions
 
static int sweep_save() {
   mapping save;
   string *tmp;
   int loop;
 
   save = (mapping)this_player()->query("news_save");
   if(!save || !sizeof(save))  return 0;
 
   tmp = keys( save );
   if(!tmp || !sizeof(tmp))  return 0;

   for(loop=0; loop<sizeof(tmp); loop++)
   if(member_array(tmp[loop], files) == -1)
	map_delete(save, tmp[loop]);

   this_player()->set("news_save", save);
 
return 1; }
 
//	Add news file contents to displaying output
 
static string add_message(string file) {
   return read_file( NEWS_DIR + file, 3) + "\n";  }
 
//	Construct title header for news item
 
static string make_header(string file, string type, int date) {
   string header;

   //	If ansi bolding is enabled, bold the news type
 
   if(ANSI)	header = ESC + "[7m";
   else		header = "";
 
   //	Output message news type
 
   if(type == "p")	header += "[Player News]";
   else if(type == "w") header += "[Wizard News]";
   else			header += "[General News]";
 
   if(ANSI)	header += ESC + "[0m";
 
   //	Add news item's title to header
 
   header += "  " + read_file ( NEWS_DIR + file, 1, 1);
 
   //	Add time stamp to header
 
   header += "Posted:\t" + ctime(date) + "\n";
 
return (header + "\n"); }
 
static int clean_news_save() {
   mapping tmp;
 
   tmp = this_player()->query("news_save");
   

return 1; }