]> code.citadel.org Git - citadel.git/commitdiff
Applied Matt's patches for the addition of four new client
authorArt Cancro <ajc@citadel.org>
Wed, 21 Jun 2006 02:45:12 +0000 (02:45 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 21 Jun 2006 02:45:12 +0000 (02:45 +0000)
commands for quick navigation between rooms and floors.

citadel/citadel.c
citadel/citadel.rc
citadel/clientsocket.h
citadel/commands.c
citadel/docs/citadel.html
citadel/messages/help

index d7875992b3b328271896ab45b37418d4c8dc9ced..6cfe72f9a52717b2f751e83121d8aaad1747d8a1 100644 (file)
@@ -59,6 +59,8 @@
 #define IFAIDE if (axlevel>=6)
 #define IFNAIDE if (axlevel<6)
 
+int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2);
+
 struct march *march = NULL;
 
 /* globals associated with the client program */
@@ -301,7 +303,7 @@ void remove_march(char *roomname, int floornum)
  * Locate the room on the march list which we most want to go to.  Each room
  * is measured given a "weight" of preference based on various factors.
  */
-char *pop_march(int desired_floor)
+char *pop_march(int desired_floor, struct march *_march)
 {
        static char TheRoom[ROOMNAMELEN];
        int TheFloor = 0;
@@ -311,10 +313,10 @@ char *pop_march(int desired_floor)
        struct march *mptr = NULL;
 
        strcpy(TheRoom, "_BASEROOM_");
-       if (march == NULL)
+       if (_march == NULL)
                return (TheRoom);
 
-       for (mptr = march; mptr != NULL; mptr = mptr->next) {
+       for (mptr = _march; mptr != NULL; mptr = mptr->next) {
                weight = 0;
                if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
                        weight = weight + 10000;
@@ -529,7 +531,7 @@ void gotonext(CtdlIPC *ipc)
                remove_march(room_name, 0);
        }
        if (march != NULL) {
-               strcpy(next_room, pop_march(curr_floor));
+               strcpy(next_room, pop_march(curr_floor, march));
        } else {
                strcpy(next_room, "_BASEROOM_");
        }
@@ -645,9 +647,9 @@ void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
        if (r / 100 == 1) {
                struct march *tmp = mptr;
 
-               /* TODO: room order is being ignored? */
+               /*. . . according to room order */
                if (mptr)
-                       strncpy(targ, mptr->march_name, ROOMNAMELEN);
+           strcpy(targ, pop_march(tofloor, mptr));
                while (mptr) {
                        tmp = mptr->next;
                        free(mptr);
@@ -666,10 +668,10 @@ void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
        r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, tofloor, &mptr, buf);
        if (r / 100 == 1) {
                struct march *tmp = mptr;
-
-               /* TODO: room order is being ignored? */
+               
+        /*. . . according to room order */
                if (mptr)
-                       strncpy(targ, mptr->march_name, ROOMNAMELEN);
+                       strcpy(targ, pop_march(tofloor, mptr));
                while (mptr) {
                        tmp = mptr->next;
                        free(mptr);
@@ -683,6 +685,179 @@ void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
        }
 }
 
+/*
+ * Indexing mechanism for a room list, called by gotoroomstep()
+ */
+void room_tree_list_query(struct ctdlroomlisting *rp, char *findrmname, int findrmslot, char *rmname, int *rmslot, int *rmtotal)
+{
+       char roomname[ROOMNAMELEN];
+       static int cur_rmslot = 0;
+
+       if (rp == NULL) {
+               cur_rmslot = 0;
+               return;
+       }
+
+       if (rp->lnext != NULL) {
+               room_tree_list_query(rp->lnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
+       }
+
+       if (sigcaught == 0) {
+               strcpy(roomname, rp->rlname);
+
+               if (rmname != NULL) {
+                       if (cur_rmslot == findrmslot) {
+                               strcpy(rmname, roomname);
+                       }
+               }
+               if (rmslot != NULL) {
+                       if (!strcmp(roomname, findrmname)) {
+                               *rmslot = cur_rmslot;
+                       }
+               }
+               cur_rmslot++;
+       }
+
+       if (rp->rnext != NULL) {
+               room_tree_list_query(rp->rnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
+       }
+
+       if ((rmname == NULL) && (rmslot == NULL))
+               free(rp);
+
+       if (rmtotal != NULL) {
+               *rmtotal = cur_rmslot;
+       }
+}
+
+/*
+ * step through rooms on current floor
+ */
+void  gotoroomstep(CtdlIPC *ipc, int direction)
+{
+       struct march *listing = NULL;
+       struct march *mptr;
+       int r;          /* IPC response code */
+       char buf[SIZ];
+       struct ctdlroomlisting *rl = NULL;
+       struct ctdlroomlisting *rp;
+       struct ctdlroomlisting *rs;
+       int list_it;
+       char rmname[ROOMNAMELEN];
+       int rmslot;
+       int rmtotal;
+
+       /* Ask the server for a room list */
+       r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
+       if (r / 100 != 1) {
+               listing = NULL;
+       }
+
+       load_floorlist(ipc);
+
+       for (mptr = listing; mptr != NULL; mptr = mptr->next) {
+               list_it = 1;
+
+               if ( floor_mode 
+                        && (mptr->march_floor != curr_floor))
+                       list_it = 0;
+
+               if (list_it) {
+                       rp = malloc(sizeof(struct ctdlroomlisting));
+                       strncpy(rp->rlname, mptr->march_name, ROOMNAMELEN);
+                       rp->rlflags = mptr->march_flags;
+                       rp->rlfloor = mptr->march_floor;
+                       rp->rlorder = mptr->march_order;
+                       rp->lnext = NULL;
+                       rp->rnext = NULL;
+
+                       rs = rl;
+                       if (rl == NULL) {
+                               rl = rp;
+                       } else {
+                               while (rp != NULL) {
+                                       if (rordercmp(rp, rs) < 0) {
+                                               if (rs->lnext == NULL) {
+                                                       rs->lnext = rp;
+                                                       rp = NULL;
+                                               } else {
+                                                       rs = rs->lnext;
+                                               }
+                                       } else {
+                                               if (rs->rnext == NULL) {
+                                                       rs->rnext = rp;
+                                                       rp = NULL;
+                                               } else {
+                                                       rs = rs->rnext;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* Find position of current room */
+       room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
+       room_tree_list_query(rl,  room_name, 0, NULL, &rmslot, &rmtotal);
+
+       if (direction == 0) { /* Previous room */
+               /* If we're at the first room, wrap to the last room */
+               if (rmslot == 0) {
+                       rmslot = rmtotal - 1;
+               } else {
+                       rmslot--;
+               }
+       } else {                 /* Next room */
+               /* If we're at the last room, wrap to the first room */
+               if (rmslot == rmtotal - 1) {
+                       rmslot = 0; 
+               } else {
+                       rmslot++;
+               }
+       }
+
+       /* Get name of next/previous room */
+       room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
+       room_tree_list_query(rl,  NULL, rmslot, rmname, NULL, NULL);
+
+       /* Free the tree */
+       room_tree_list_query(rl, NULL, 0, NULL, NULL, NULL);
+
+       updatels(ipc);
+       dotgoto(ipc, rmname, 1, 0);
+}
+
+
+/*
+ * step through floors on system
+ */
+void  gotofloorstep(CtdlIPC *ipc, int direction)
+{
+       int  tofloor;
+
+       if (floorlist[0][0] == 0)
+               load_floorlist(ipc);
+
+       if (direction == 0) { /* Previous floor */
+               if (curr_floor) tofloor = curr_floor - 1;
+               else tofloor = 127;
+
+               while (!floorlist[tofloor][0]) tofloor--;
+       } else {                   /* Next floor */
+               if (curr_floor < 127) tofloor = curr_floor + 1;
+               else tofloor = 0;
+
+               while (!floorlist[tofloor][0] && tofloor < 127) tofloor++;
+               if (!floorlist[tofloor][0])     tofloor = 0;
+       }
+       /* ;g works when not in floor mode so . . . */
+       if (!floor_mode) {
+               scr_printf("(%s)\n", floorlist[tofloor] );
+       }
+
+       gotofloor(ipc, floorlist[tofloor], GF_GOTO);
+}
+
 
 /*
  * forget all rooms on current floor
@@ -1850,6 +2025,22 @@ NEWUSR:  if (strlen(rc_password) == 0) {
                                page_user(ipc);
                                break;
 
+            case 110:           /* <+> Next room */
+                 gotoroomstep(ipc, 1);
+                            break;
+
+            case 111:           /* <-> Previous room */
+                 gotoroomstep(ipc, 0);
+                            break;
+
+                       case 112:           /* <>> Next floor */
+                 gotofloorstep(ipc, 1);
+                            break;
+
+                       case 113:           /* <<> Previous floor */
+                 gotofloorstep(ipc, 0);
+                                break;
+
                        default: /* allow some math on the command */
                                /* commands 100... to 100+MAX_EDITORS-1 will
                                   call the appropriate editor... in other
index 39278f1cbcf104680344d6ccca6c3a7e4c53c3fa..774ced13d6ecbf90281b9c909d045a7c9cfddc85 100644 (file)
@@ -369,6 +369,11 @@ cmd=76,0,&.,&Wholist,&Hostname
 cmd=91,0,&.,&Wholist,&Active
 cmd=93,0,&.,&Wholist,&Stealth mode
 
+cmd=110,0,&+Next room
+cmd=111,0,&-Previous room
+cmd=112,0,&>Next floor
+cmd=113,0,&<Previous floor
+
 #
 # Command 69 allows the user to enter a server command directly.  It is
 # primarily for testing and not intended for general use.  Usually there
index 21d414c3b52d1160981a060f8fc80f1bf695c1d4..1fdbcb1af2b5eac66f38f060494fceafb75588cc 100644 (file)
@@ -22,4 +22,4 @@ int sock_puts(int sock, char *buf);
 /* 
  * Default timeout for client sessions
  */
-#define CLIENT_TIMEOUT         90
+#define CLIENT_TIMEOUT         600
index 78fd4f5c6168549903da096e375c1c68ae3212a6..a575103175fcf83def5a683f961da232199b7195 100644 (file)
@@ -985,8 +985,11 @@ char *cmd_expand(char *strbuf, int mode)
        for (a = 0; a < strlen(exp); ++a) {
                if (strbuf[a] == '&') {
 
+                       /* dont echo these non mnemonic command keys */
+                       int noecho = strbuf[a+1] == '<' || strbuf[a+1] == '>' || strbuf[a+1] == '+' || strbuf[a+1] == '-';
+
                        if (mode == 0) {
-                               strcpy(&exp[a], &exp[a + 1]);
+                               strcpy(&exp[a], &exp[a + 1 + noecho]);
                        }
                        if (mode == 1) {
                                exp[a] = '<';
index f2c4b5d1f6117607a603011c52deac573b061462..a04245b4de1a8abea34c6572773efe6755a7e64d 100644 (file)
@@ -92,6 +92,12 @@ others<br>
       <td valign="top"><i>RBL checking function design<br>
       </i></td>
     </tr>
+    <tr>
+      <td valign="top">Matt McBride<br>
+      </td>
+      <td valign="top"><i>additional client features<br>
+      </i></td>
+    </tr>
     <tr>
       <td valign="top">Ben Mehlman<br>
       </td>
index a11b5f89cd6e402c5a4d11b7bd3f000861b14bae..4ccc16f0f814d79779d2f64f93db186a371b52cc 100644 (file)
@@ -21,6 +21,8 @@
  W         Displays who is currently logged in.
  X         Toggle eXpert mode (menus and help blurbs on/off)
  Z         Zap (forget) room. (Removes the room from your list)
+ + -       Goto next, previous room on current floor.
+ > <       Goto next, previous floor.
  *         Enter any locally installed 'doors'.
    
  In addition, there are dot commands. You hit the . (dot), then press the