[mw-devel] MW3 r1044 - in trunk: help src
arthur at sucs.org
arthur at sucs.org
Tue Jul 15 15:16:03 BST 2008
Author: arthur
Date: 2008-07-15 15:16:02 +0100 (Tue, 15 Jul 2008)
New Revision: 1044
Added:
trunk/help/what
Modified:
trunk/help/doing
trunk/src/bb.h
trunk/src/chattable.c
trunk/src/edit.c
trunk/src/incoming.c
trunk/src/ipc.h
trunk/src/js.c
trunk/src/main.c
trunk/src/mesg.c
trunk/src/newmain.c
trunk/src/proto.h
trunk/src/rooms.c
trunk/src/rooms.h
trunk/src/sizes.c
trunk/src/talker.c
trunk/src/talker.h
trunk/src/talker_privs.c
trunk/src/user.c
trunk/src/who.c
Log:
Reuse the doing field to display a persistant status string
Modified: trunk/help/doing
===================================================================
--- trunk/help/doing 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/help/doing 2008-07-15 14:16:02 UTC (rev 1044)
@@ -1,15 +1,15 @@
[1mNAME[0m
- doing - set [4mDOING[0m field of who
+ doing - set your displayed status
[1mSYNOPSIS[0m
[1mdoing[0m [4mWHAT[0m
[1mDESCRIPTION[0m
- When a user is on the board (but not on the talker), you get a description
- of their current action (e.g. "Logging on", "Nothing" "Reading message")
- You can use the [1mdoing[0m command to set this string to something else,
- such as "Eating", "Working" or "Very little".
+ You can use this command to change/clear your status string.
+ The change will be announced to all the logged in users and the
+ current status of each user can be viewed with the 1mwhat[0m command.
[4mWHAT[0m
What you are doing - a text string.
+ Leave empty to clear your status
Added: trunk/help/what
===================================================================
--- trunk/help/what (rev 0)
+++ trunk/help/what 2008-07-15 14:16:02 UTC (rev 1044)
@@ -0,0 +1,10 @@
+[1mNAME[0m
+ what - see what other people are doing
+
+[1mSYNOPSIS[0m
+ [1mwhat[0m
+
+[1mDESCRIPTION[0m
+ This command will display the status of all logged in users that
+ currently have a status string set.
+
Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/bb.h 2008-07-15 14:16:02 UTC (rev 1044)
@@ -67,7 +67,7 @@
#define REALNAMESIZE 30 /* real name */
#define CONTACTSIZE 60 /* contact address */
#define LOGLINESIZE 2048 /* size of a line printed to log file */
-#define DOINGSIZE 80 /* 'doing' user record field */
+#define DOINGSIZE 79 /* 'doing' user record field */
#define MAXTEXTLENGTH 2048 /* text buffer size */
#define MAXPIPELENGTH 4096 /* maximum length of a pipe message */
@@ -142,6 +142,7 @@
int32_t idletime;
char groups;
char doing[DOINGSIZE];
+ int32_t dowhen; /* unix time of last doing update */
int32_t timeout;
unsigned char spare;
Modified: trunk/src/chattable.c
===================================================================
--- trunk/src/chattable.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/chattable.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -28,6 +28,7 @@
{"bind" ,0x0200, 2, "Usage: bind <bind> <function>", "Add the bind to the current session", t_bind, 1},
{"debug" ,0x0200 ,1, "Usage: debug <on|off>", "Toggle verbose script debugging", t_debug, 1},
{"destroy" ,0x0200 ,1, "Usage: destroy <function | *>", "Destroy function (* - all functions)", t_destroy, 1},
+{"doing" ,0x0000 ,0, "Usage: doing <status...>", "Set status message", c_doing, 1},
{"e" ,0x0000 ,1, "Usage: e <message>", "Emote message", t_emote, 1},
{"e'" ,0x0000 ,1, "Usage: e' <message>", "Emote' message", t_emotes2, 0},
{"e's" ,0x0000 ,1, "Usage: e's <message>", "Emote's message", t_emotes, 0},
@@ -73,6 +74,7 @@
{"unignore" ,0x0000 ,1, "Usage: unignore <user>", "Stop filtering user out so you can hear them", t_unignore, 1},
{"unprotect" ,0x0020 ,1, "Usage: unprotect <user>", "Remove protection from user", t_unprotect, 1},
{"variables" ,0x0200 ,0, "Usage: variables [mask]", "List script variables + contents [or starting with mask]", t_showvars, 1},
+{"what" ,0x0000 ,0, "Usage: what", "See peoples status", t_what, 1},
{"whisper" ,0x0000 ,2, "Usage: whisper <user> <message>", "Send a message to a single user", t_whisper, 1},
{"who" ,0x0000 ,0, "Usage: who", "See who's about", t_who, 1},
{"zod" ,0x0004 ,1, "Usage: zod <user> [reason]", "Eject user from talker", t_zod, 1},
Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/edit.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -24,7 +24,7 @@
char *partlist_user[]={
"edit", "status", "special", "groups", "passwd", "chatprivs", "chatmode",
"realname", "username", "contact", "timeout", "lastread", "view", "room",
-"clearignore", "protection", NULL};
+"clearignore", "protection", "doing", NULL};
extern int busy;
extern int mesg_waiting;
@@ -334,6 +334,21 @@
mwlog("CHANGE(CONTACT) of %s to %s", usr.name, contact);
}
}else
+ if (stringcmp(args,"doing",2))
+ {
+ char doing[DOINGSIZE];
+ printf(_("Current Status: %s\n"),usr.doing);
+ printf(_("New Status (%d chars): "),DOINGSIZE-1);
+ get_str(doing,DOINGSIZE-1);
+ if (*doing)
+ {
+ strcpy(usr.doing,doing);
+ ipc_send_to_username(usr.name, IPC_DOING, usr.doing);
+ printf(_("New status set.\n"));
+ broadcast(3, "%s has just changed %s's status to %s.", user->name, usr.name, doing);
+ mwlog("CHANGE(STATUS) of %s to %s", usr.name, doing);
+ }
+ }else
if (stringcmp(args,"timeout",1))
{
char tt[20];
Modified: trunk/src/incoming.c
===================================================================
--- trunk/src/incoming.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/incoming.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -539,6 +539,10 @@
case IPC_CONTACT:
strcpy(user->contact,newbuff);
break;
+ case IPC_DOING:
+ snprintf(user->doing,DOINGSIZE,"%s",newbuff);
+ user->dowhen=time(0);
+ break;
case IPC_SPECIAL:
user->special=set_special(newbuff,user->special);
break;
@@ -927,9 +931,6 @@
{
char text[MAXTEXTLENGTH];
- /* update the doing text before anything, so that the script below can set it if it wished */
- snprintf(user->doing, DOINGSIZE-1, "Sulking...");
-
/* remove from talker */
user->chatmode=cm_flags(user->chatmode, CM_ONCHAT, CM_MODE_CLEAR);
Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/ipc.h 2008-07-15 14:16:02 UTC (rev 1044)
@@ -25,7 +25,8 @@
IPC_SCRIPTRPC = 22,
IPC_CHECKONOFF = 23,
IPC_PROTLEVEL = 24,
- IPC_PROTPOWER = 25
+ IPC_PROTPOWER = 25,
+ IPC_DOING = 26
};
typedef int (send_filter)(const struct person * usr, const struct who * who, const void * info);
Modified: trunk/src/js.c
===================================================================
--- trunk/src/js.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/js.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -724,6 +724,15 @@
jsstr = JS_NewStringCopyZ(cx, display_cpflags(u.chatprivs & user->chatprivs));
jv = STRING_TO_JSVAL(jsstr);
JS_DefineProperty(cx, user_record, "chatprivs", jv, NULL, NULL, 0);
+ /* status string */
+ jsstr = JS_NewStringCopyZ(cx, u.doing);
+ jv = STRING_TO_JSVAL(jsstr);
+ JS_DefineProperty(cx, user_record, "doing", jv, NULL, NULL, 0);
+ if (u.dowhen)
+ jv = INT_TO_JSVAL(time(0)-u.dowhen);
+ else
+ jv = INT_TO_JSVAL(0);
+ JS_DefineProperty(cx, user_record, "since", jv, NULL, NULL, 0);
/* stick line into master array */
JS_SetElement(cx, res, n++, &user_jv);
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/main.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -410,7 +410,7 @@
{
/* try and load user - dont care if it fails */
is_old(user,b,&userposn);
- who_list();
+ who_list(0);
}else
printf(_("Username not permitted.\n"));
}
@@ -636,7 +636,6 @@
user->chatmode |= (oldchat & CM_PROTMASK);
user->idletime=time(0);
- snprintf(user->doing, DOINGSIZE-1, "Logging in");
update_user(user,userposn);
who_add(getpid(),userposn);
@@ -815,7 +814,6 @@
new_mail_waiting=0;
}
user->idletime=time(0);
- snprintf(user->doing, DOINGSIZE-1, "Nothing");
update_user(user,userposn);
if (*comm == 0) return;
#ifdef RWHO
Modified: trunk/src/mesg.c
===================================================================
--- trunk/src/mesg.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/mesg.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -142,6 +142,7 @@
if (state==0) mwlog("WALL %s", text);
else if (state==1 && israw) mwlog("BROADCAST %s", text);
else if (state==2) mwlog("WIZ %s", text);
+ else if (state==5) mwlog("STATUS %s", text);
wfile=openwhofile(O_RDONLY);
ufile=openuserfile(O_RDONLY);
@@ -183,6 +184,10 @@
ipc_send_to_pid(w.pid, IPC_WIZ, buff);
}
break;
+ case 5:
+ snprintf(buff, MAXTEXTLENGTH, "\03304STATUS: \03314%s",text);
+ ipc_send_to_pid(w.pid, IPC_WIZ, buff);
+ break;
default:
snprintf(buff, MAXTEXTLENGTH, "\03304%s%s", israw?"":"SYSTEM: ", text);
ipc_send_to_pid(w.pid, IPC_WIZ, buff);
Modified: trunk/src/newmain.c
===================================================================
--- trunk/src/newmain.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/newmain.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -90,8 +90,6 @@
void c_new(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "Reading New Messages");
- update_user(user,userposn);
busy++;
new(user);
busy--;
@@ -108,7 +106,6 @@
printf(_("Moved to end of folder. (message %d)\n"),last_mesg);
read_msg(currentfolder,last_mesg,user);
- snprintf(user->doing, DOINGSIZE-1, "Reading folder %s",fold->name);
}
void c_first(CommandList *cm, int argc, char **argv, char *args)
@@ -117,13 +114,10 @@
printf(_("Moved to start of folder. (message %d)\n"),last_mesg);
read_msg(currentfolder,last_mesg,user);
- snprintf(user->doing, DOINGSIZE-1, "Reading folder %s",fold->name);
}
void c_user(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "Editing User %s",argv[2]);
- update_user(user,userposn);
busy++;
edit_user(argv[1],argv[2]);
busy--;
@@ -131,15 +125,11 @@
void c_search(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "Searching Users");
- update_user(user,userposn);
search(argv[1],argv[2]);
}
void c_folder(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "Editing folder %s",fold->name);
- update_user(user,userposn);
edit_folder(argv[1],argv[2]);
}
@@ -398,7 +388,6 @@
void c_mesg(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "MsgEdit %s:%d",fold->name,atoi(argv[2]));
update_user(user,userposn);
busy++;
mesg_edit(argv[1],fold->name,atoi(argv[2]),user);
@@ -413,9 +402,8 @@
void c_who(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1, "Checking 'Who'");
update_user(user,userposn);
- who_list();
+ who_list(0);
}
void c_tell(CommandList *cm, int argc, char **argv, char *args)
@@ -426,7 +414,6 @@
{
char text[MAXTEXTLENGTH];
- snprintf(user->doing, DOINGSIZE-1, "Talking to %s",argv[1]);
update_user(user,userposn);
text[0]=0;
strncat(text, args, MAXTEXTLENGTH - strlen(text) - 1);
@@ -463,9 +450,17 @@
void c_doing(CommandList *cm, int argc, char **argv, char *args)
{
- user->doing[0]=0;
- strncat(user->doing, args, DOINGSIZE - strlen(user->doing) - 1);
- update_user(user,userposn);
+ if (argc > 1) {
+ snprintf(user->doing, DOINGSIZE, "%s", args);
+ user->dowhen = time(0);
+ update_user(user,userposn);
+ broadcast(5, "%s %s", user->name, user->doing);
+ } else {
+ user->doing[0] = 0;
+ user->dowhen = time(0);
+ update_user(user,userposn);
+ printf(_("You are marked as doing nothing.\n"));
+ }
}
void c_pwd(CommandList *cm, int argc, char **argv, char *args)
@@ -547,17 +542,12 @@
printf(_("Sorry, no help available.\n"));
else
{
- snprintf(user->doing, DOINGSIZE-1, "Reading help");
- update_user(user,userposn);
-
help(topic,u_god(user->status));
}
}
void c_listusers(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1,"Listing Users");
- update_user(user,userposn);
list_users(FALSE);
}
@@ -568,15 +558,11 @@
void c_since(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing, DOINGSIZE-1,"Checking Since");
- update_user(user,userposn);
list_users_since(user->lastlogout);
}
void c_mod(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing,DOINGSIZE-1,"Moderating");
- update_user(user,userposn);
moderate();
}
@@ -584,9 +570,6 @@
{
char pw1[PASSWDSIZE], pw2[PASSWDSIZE], salt[3];
- snprintf(user->doing,DOINGSIZE-1,"Changing Password");
- update_user(user,userposn);
-
salt[2]=0;
strncpy(salt,user->passwd,2);
if (strcmp(user->passwd,crypt(get_pass(_("Enter old password: ")),salt)))
@@ -634,7 +617,6 @@
{
int num=atoi(argv[1]);
- snprintf(user->doing,DOINGSIZE-1,"Reading folder %s",fold->name);
if (read_msg(currentfolder,num,user)) last_mesg=num;
}
@@ -642,14 +624,12 @@
{
if (last_mesg<=fold->first) printf(_("You are already at the beginning of the folder.\n"));
else if (read_msg(currentfolder,last_mesg-1,user)) last_mesg--;
- snprintf(user->doing,DOINGSIZE-1,"Reading folder %s",fold->name);
}
void c_next(CommandList *cm, int argc, char **argv, char *args)
{
if (last_mesg>=fold->last) printf(_("You are already at the end of this folder.\n"));
else if (read_msg(currentfolder,last_mesg+1,user)) last_mesg++;
- snprintf(user->doing,DOINGSIZE-1,"Reading folder %s",fold->name);
}
void c_status(CommandList *cm, int argc, char **argv, char *args)
@@ -714,8 +694,6 @@
void c_write(CommandList *cm, int argc, char **argv, char *args)
{
- snprintf(user->doing,DOINGSIZE-1,"Writing in folder %s",fold->name);
- update_user(user,userposn);
busy++;
add_msg(currentfolder,user,0);
busy--;
@@ -727,9 +705,6 @@
printf(_("You have to read a message before you can reply to it.\n"));
else
{
- snprintf(user->doing,DOINGSIZE-1,"Replying in folder %s",fold->name);
- update_user(user,userposn);
-
printf(_("Replying to message %d.\n"),last_mesg);
busy++;
add_msg(currentfolder,user,last_mesg);
@@ -975,8 +950,6 @@
/* user is allowed to change their contact address */
if (!s_fixedcontact(user->special))
{
- snprintf(user->doing, DOINGSIZE-1, "Editing Contact");
- update_user(user,userposn);
busy++;
edit_contact();
busy--;
Modified: trunk/src/proto.h
===================================================================
--- trunk/src/proto.h 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/proto.h 2008-07-15 14:16:02 UTC (rev 1044)
@@ -220,7 +220,7 @@
/* who.c */
void who_delete(int pid);
void copy(char *a, char *b);
-void who_list(void);
+void who_list(int mode);
int get_pid(char *name);
void check_copies(int32_t where);
char *itime(unsigned long t);
Modified: trunk/src/rooms.c
===================================================================
--- trunk/src/rooms.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/rooms.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -564,7 +564,7 @@
room_who_list();
}
-void talker_who(void)
+void talker_who(int mode)
{
struct person u;
struct who w;
@@ -580,6 +580,9 @@
ufile=openuserfile(O_RDONLY);
if (wfile<0 || ufile<0) return; /* whoops */
+ if (mode == 1)
+ snprintf(line,81, "%-*s Since Status...\n", NAMESIZE, "Name" );
+ else
snprintf(line,81, "%-*s Idle Room Description...\n", NAMESIZE, "Name" );
display_message("\n", 0, 1);
display_message(line, 0, 1);
@@ -618,9 +621,12 @@
label=strdup(room.name);
}else {
label=malloc(56);
- snprintf(label, 55, "Not On Talker: %.40s", u.doing);
+ snprintf(label, 55, "Not On Talker");
}
+ if (mode == 1)
+ snprintf(line, 81, "%-*s %6s %s %s\n", NAMESIZE, u.name, itime(time(0)-u.dowhen), u.name, u.doing);
+ else
if (room.num==-1)
snprintf(line, 81, "%-*s %6s ***** %.54s\n", NAMESIZE, u.name, itime(time(0)-u.idletime), label);
else if (room.hidden>0)
Modified: trunk/src/rooms.h
===================================================================
--- trunk/src/rooms.h 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/rooms.h 2008-07-15 14:16:02 UTC (rev 1044)
@@ -6,7 +6,7 @@
int LoadRoom(struct room *room, int num);
void RoomLook(struct room *room, int full);
void RoomExits(struct room *room);
-void talker_who(void);
+void talker_who(int mode);
void room_who_list(void);
char *room_name(struct room tmp, int roomnum);
int ChangeRoom(char *room, int quiet);
Modified: trunk/src/sizes.c
===================================================================
--- trunk/src/sizes.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/sizes.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -47,6 +47,7 @@
addmap(map, "idletime", 'i', sizeof(pp.idletime), &pp.idletime, &pp );
addmap(map, "groups", 'g', sizeof(pp.groups), &pp.groups, &pp );
addmap(map, "doing", 'd', sizeof(pp.doing), &pp.doing, &pp );
+ addmap(map, "dowhen", 'w', sizeof(pp.dowhen), &pp.dowhen, &pp );
addmap(map, "timeout", 'T', sizeof(pp.timeout), &pp.timeout, &pp );
addmap(map, "spare", 'p', sizeof(pp.spare), &pp.spare, &pp );
addmap(map, "colour", 'c', sizeof(pp.colour), &pp.colour, &pp );
Modified: trunk/src/talker.c
===================================================================
--- trunk/src/talker.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/talker.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -268,12 +268,17 @@
void t_who(CommandList *cm, int argc, char **argv, char *args)
{
if (cp_flags(user->chatprivs,CP_MUD,CM_MODE_ALL))
- talker_who();
+ talker_who(0);
else
- who_list();
+ who_list(0);
}
+void t_what(CommandList *cm, int argc, char **argv, char *args)
+{
+ who_list(1);
+}
+
void t_quit(CommandList *cm, int argc, char **argv, char *args)
{
char text[MAXTEXTLENGTH];
@@ -1372,7 +1377,6 @@
snprintf(mtext,MAXTEXTLENGTH-1,"\03310%s has just joined talker room %d",user->name, user->room);
snprintf(text,MAXTEXTLENGTH-1,"\03310%s has just joined talker room %d",user->name, user->room);
if (!quietmode) talk_send_rawbcast(text); /*talk_send_mud(text,mtext,3,0);*/
- snprintf(user->doing, DOINGSIZE-1, "Talking");
printf("\nNow entering the Talker. Use \".quit\" to leave and \".help\" for help.\n");
/* run the common stuff for entering the talker */
@@ -1676,9 +1680,8 @@
/* if user wishes to automatically display a wholist on talker entry */
if (autowho)
{
- snprintf(user->doing, DOINGSIZE-1, "Checking 'Who'");
update_user(user,userposn);
- who_list();
+ who_list(0);
/* turn off the autowho, so it only occurs on first usage */
autowho = 0;
}
Modified: trunk/src/talker.h
===================================================================
--- trunk/src/talker.h 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/talker.h 2008-07-15 14:16:02 UTC (rev 1044)
@@ -8,6 +8,7 @@
void t_unbind(CommandList *cm, int argc, char **argv, char *args);
void t_scrhelp(CommandList *cm, int argc, char **argv, char *args);
void t_who(CommandList *cm, int argc, char **argv, char *args);
+void t_what(CommandList *cm, int argc, char **argv, char *args);
void t_help(CommandList *cm, int argc, char **argv, char *args);
void t_quit(CommandList *cm, int argc, char **argv, char *args);
void t_script(CommandList *cm, int argc, char **argv, char *args);
Modified: trunk/src/talker_privs.c
===================================================================
--- trunk/src/talker_privs.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/talker_privs.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -477,9 +477,6 @@
if (!quietmode) talk_send_rawbcast(text);
set_rights();
-
- /* update users doing */
- snprintf(user->doing, DOINGSIZE-1, "Sulking...");
}
if (cm_flags(add, CM_ONCHAT, CM_MODE_ALL))
{
Modified: trunk/src/user.c
===================================================================
--- trunk/src/user.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/user.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -284,6 +284,8 @@
tmp->chatprivs=0l;
/* default timeout value */
tmp->timeout = 86400;
+ tmp->doing[0]=0;
+ tmp->dowhen=0;
/********************************************
Modified: trunk/src/who.c
===================================================================
--- trunk/src/who.c 2008-06-23 08:28:23 UTC (rev 1043)
+++ trunk/src/who.c 2008-07-15 14:16:02 UTC (rev 1044)
@@ -66,7 +66,7 @@
close(bf);
}
-void who_list(void)
+void who_list(int mode)
{
struct person u;
struct who w;
@@ -88,6 +88,9 @@
/* do we tell them who can hear wiz messages */
if (u_god(user->status) || s_wizchat(user->special)) wizchat=1; else wizchat=0;
+ if (mode==1)
+ printf("\nUser status...\n");
+ else
if (wiz) printf("\nPID %-*s %-*s Idle What...\n",NAMESIZE,"Name",20,"RealName");
else printf("\n %-*s Idle What...\n",NAMESIZE,"Name");
@@ -116,6 +119,10 @@
/* check they are still alive and show info */
if (! ipc_send_to_pid(w.pid, IPC_NOOP, NULL))
{
+ if (mode == 1) {
+ if (u.dowhen && u.doing[0] != 0)
+ printf("%s %s (%s ago)\n",u.name, u.doing ,itime(time(0)-u.dowhen));
+ } else {
if (cm_flags(u.chatmode,CM_ONCHAT,CM_MODE_ANY))
{
int cml, cpl, pll, myapl;
@@ -139,30 +146,30 @@
if (myroom.name != NULL)
{
if(myroom.hidden>0)
- snprintf(u.doing,DOINGSIZE-1, "------");
+ snprintf(u.doing,DOINGSIZE, "------");
else
- snprintf(u.doing,DOINGSIZE-1, "Room %d",u.room);
+ snprintf(u.doing,DOINGSIZE, "Room %d",u.room);
}
else
- snprintf(u.doing,DOINGSIZE-1, "Room %d",u.room);
+ snprintf(u.doing,DOINGSIZE, "Room %d",u.room);
}
else if (myroom.hidden>0 && u.room==user->room)
- snprintf(u.doing,DOINGSIZE-1, "------");
+ snprintf(u.doing,DOINGSIZE, "------");
else
- snprintf(u.doing,DOINGSIZE-1, "Room %d",u.room);
+ snprintf(u.doing,DOINGSIZE, "Room %d",u.room);
}
else
- snprintf(u.doing,DOINGSIZE-1, "Room %d",u.room);
+ snprintf(u.doing,DOINGSIZE, "Room %d",u.room);
off=strlen(u.doing);
- snprintf(&u.doing[off],DOINGSIZE-off-1," (");
+ snprintf(&u.doing[off],DOINGSIZE-off," (");
/* Show chatmode flags */
cmt=display_cmflags(mask);
cml=strlen(display_cmflags(mask));
off=strlen(u.doing);
if (strlen(cmt)>0)
{
- snprintf(&u.doing[off],DOINGSIZE-off-1,"%-*s", cml, cmt);
+ snprintf(&u.doing[off],DOINGSIZE-off,"%-*s", cml, cmt);
}
/* Show protection */
if (myapl > 0 && cm_flags(user->chatprivs, CP_PROTECT, CM_MODE_ALL))
@@ -177,10 +184,10 @@
off=strlen(u.doing);
if (strlen(cmt)>0)
{
- snprintf(&u.doing[off],DOINGSIZE-off-1,",");
+ snprintf(&u.doing[off],DOINGSIZE-off,",");
}
off=strlen(u.doing);
- snprintf(&u.doing[off],DOINGSIZE-off-1,"%-*s", pll, plt);
+ snprintf(&u.doing[off],DOINGSIZE-off,"%-*s", pll, plt);
} else
plt[0] = '\0';
/* Show chatpriv flags */
@@ -192,16 +199,16 @@
cpl=strlen(cpt);
if ((strlen(cmt)+strlen(plt))>0 && cpl>0)
{
- snprintf(&u.doing[off],DOINGSIZE-off-1,",");
+ snprintf(&u.doing[off],DOINGSIZE-off,",");
}
off=strlen(u.doing);
if (cpl>0)
{
- snprintf(&u.doing[off],DOINGSIZE-off-1,"%-*s", cpl, cpt);
+ snprintf(&u.doing[off],DOINGSIZE-off,"%-*s", cpl, cpt);
}
off=strlen(u.doing);
- snprintf(&u.doing[off],DOINGSIZE-off-1,")");
+ snprintf(&u.doing[off],DOINGSIZE-off,")");
}
if (wiz)
@@ -211,6 +218,7 @@
{
printf("%c%-*s %6s %s\n",wizchat?chat:' ',NAMESIZE,u.name,itime(time(0)-u.idletime),u.doing);
}
+ }
}
}
printf("%s\n", divider);
More information about the mw-devel
mailing list