4 * citadel.c - Main source file.
16 #include <sys/types.h>
19 #include <sys/ioctl.h>
26 #include "serv_info.h"
28 #include "routines2.h"
33 #include "client_chat.h"
34 #include "citadel_decls.h"
42 #define IFEXPERT if (userflags&US_EXPERT)
43 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
44 #define IFAIDE if (axlevel>=6)
45 #define IFNAIDE if (axlevel<6)
47 struct march *march = NULL;
49 /* globals associated with the client program */
50 char temp[16]; /* Name of general temp file */
51 char temp2[16]; /* Name of general temp file */
52 char tempdir[16]; /* Name of general temp dir */
53 char editor_path[256]; /* path to external editor */
54 char printcmd[256]; /* print command */
55 int editor_pid = (-1);
58 struct CtdlServInfo serv_info; /* Info on the server connected */
63 char ugname[ROOMNAMELEN];
64 long uglsn; /* holds <u>ngoto info */
65 char is_mail = 0; /* nonzero when we're in a mail room */
66 char axlevel = 0; /* access level */
67 char is_room_aide = 0; /* boolean flag, 1 if room aide */
71 long usernum = 0L; /* user number */
73 long highest_msg_read; /* used for <A>bandon room cmd */
74 long maxmsgnum; /* used for <G>oto */
76 char have_xterm = 0; /* are we running on an xterm? */
81 char curr_floor = 0; /* number of current floor */
82 char floorlist[128][256]; /* names of floors */
83 char express_msgs = 0; /* express messages waiting! */
84 char last_paged[32]="";
87 * here is our 'clean up gracefully and exit' routine
91 if (editor_pid>0) { /* kill the editor if it's running */
92 kill(editor_pid,SIGHUP);
95 /* shut down the server... but not if the logoff code is 3, because
96 * that means we're exiting because we already lost the server
98 if (code!=3) serv_puts("QUIT");
101 * now clean up various things
108 /* Violently kill off any child processes if Citadel is
112 kill(0-getpgrp(),SIGTERM);
114 kill(0-getpgrp(),SIGKILL);
117 sttybbs(SB_RESTORE); /* return the old terminal settings */
118 exit(code); /* exit with the proper exit code */
124 * We handle "next" and "stop" much differently than in earlier versions.
125 * The signal catching routine simply sets a flag and returns.
127 void sighandler(int which_sig)
129 signal(SIGINT,SIG_IGN);
130 signal(SIGQUIT,SIG_IGN);
131 sigcaught = which_sig;
137 * signal catching function for hangups...
139 void dropcarr(int signum) {
145 /* general purpose routines */
147 void formout(char *name) /* display a file */
151 sprintf(cmd,"MESG %s",name);
155 printf("%s\n",&cmd[4]);
158 fmout(screenwidth,NULL,
159 ((userflags & US_PAGINATOR) ? 1 : 0),
164 void userlist(void) {
174 printf("%s\n",&buf[4]);
178 sttybbs(SB_YES_INTR);
179 printf(" User Name Num L LastCall Calls Posts\n");
180 printf("------------------------- ----- - ---------- ----- -----\n");
181 while (serv_gets(buf), strcmp(buf,"000")) {
182 if (sigcaught == 0) {
185 printf("%5ld %d ",extract_long(buf,2),
187 lc = extract_long(buf,3);
188 tmbuf = (struct tm *)localtime(&lc);
189 printf("%02d/%02d/%04d ",
192 (tmbuf->tm_year + 1900));
193 printf("%5ld %5ld\n",extract_long(buf,4),extract_long(buf,5));
196 linecount = checkpagin(linecount,
197 ((userflags & US_PAGINATOR) ? 1 : 0),
208 * grab assorted info about the user...
210 void load_user_info(char *params)
212 extract(fullname,params,0);
213 axlevel = extract_int(params,1);
214 timescalled = extract_int(params,2);
215 posted = extract_int(params,3);
216 userflags = extract_int(params,4);
217 usernum = extract_long(params,5);
222 * Remove a room from the march list. 'floornum' is ignored unless
223 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
224 * floor will be removed from the march list.
226 void remove_march(char *roomname, int floornum)
228 struct march *mptr,*mptr2;
230 if (march==NULL) return;
232 if ( (!strucmp(march->march_name,roomname))
233 || ((!strucmp(roomname,"_FLOOR_"))&&(march->march_floor==floornum))) {
241 for (mptr=march; mptr!=NULL; mptr=mptr->next) {
243 if ( (!strucmp(mptr->march_name,roomname))
244 || ((!strucmp(roomname,"_FLOOR_"))
245 &&(mptr->march_floor==floornum))) {
247 mptr2->next = mptr->next;
258 * sort the march list by floor
260 void sort_march_list(void) {
261 struct march *mlist[129];
262 struct march *mptr = NULL;
265 if (march == NULL) return;
267 for (a=0; a<129; ++a) mlist[a] = NULL;
269 /* first, create 128 separate lists for each floor. */
270 while (march != NULL) {
272 a = (int)(march->march_floor);
274 /* assign an illegal floor number of 128 to _BASEROOM_
275 * in order to force it to show up last */
276 if (!strucmp(march->march_name,"_BASEROOM_")) a = 128;
280 mptr->next = mlist[a];
284 /* now merge the lists, in order, into one big list,
285 * except the current floor
287 for (a=128; a>=0; --a) if (a != curr_floor) {
288 while (mlist[a] != NULL) {
290 mlist[a] = mlist[a]->next;
296 /* now merge in rooms from the current floor */
297 while (mlist[(int)curr_floor] != NULL) {
298 mptr = mlist[(int)curr_floor];
299 mlist[(int)curr_floor] = mlist[(int)curr_floor]->next;
309 * jump directly to a room
311 void dotgoto(char *towhere, int display_name)
313 char aaa[256],bbb[256],psearch[256];
316 static int oldmailcount = (-1);
317 int partial_match,best_match;
320 /* store ungoto information */
321 strcpy(ugname,room_name);
324 /* first try an exact match */
325 sprintf(aaa,"GOTO %s",towhere);
328 if (aaa[3]=='*') express_msgs = 1;
329 if (!strncmp(aaa,"54",2)) {
330 newprompt("Enter room password: ",bbb,9);
331 sprintf(aaa,"GOTO %s|%s",towhere,bbb);
334 if (aaa[3]=='*') express_msgs = 1;
336 if (!strncmp(aaa,"54",2)) {
337 printf("Wrong password.\n");
343 * If a match is not found, try a partial match.
344 * Partial matches anywhere in the string carry a weight of 1,
345 * left-aligned matches carry a weight of 2. Pick the room that
346 * has the highest-weighted match.
353 if (aaa[0]=='1') while (serv_gets(aaa), strcmp(aaa,"000")) {
354 extract(psearch,aaa,0);
356 if (pattern(psearch,towhere)>=0) {
359 if (!struncmp(towhere,psearch,strlen(towhere))) {
362 if (partial_match > best_match) {
364 best_match = partial_match;
367 if (strlen(bbb)==0) {
368 printf("No room '%s'.\n",towhere);
371 sprintf(aaa,"GOTO %s",bbb);
374 if (aaa[3]=='*') express_msgs = 1;
382 extract(room_name,&aaa[4],0);
383 room_flags = extract_int(&aaa[4],4);
384 from_floor = curr_floor;
385 curr_floor = extract_int(&aaa[4],10);
387 remove_march(room_name,0);
388 if (!strucmp(towhere,"_BASEROOM_")) remove_march(towhere,0);
389 if ((from_floor!=curr_floor) && (display_name>0) && (floor_mode==1)) {
390 if (floorlist[(int)curr_floor][0]==0) load_floorlist();
391 printf("(Entering floor: %s)\n",&floorlist[(int)curr_floor][0]);
393 if (display_name == 1) printf("%s - ",room_name);
394 if (display_name != 2) printf("%d new of %d messages.\n",
395 extract_int(&aaa[4],1),
396 extract_int(&aaa[4],2));
397 highest_msg_read = extract_int(&aaa[4],6);
398 maxmsgnum = extract_int(&aaa[4],5);
399 is_mail = (char) extract_int(&aaa[4],7);
400 is_room_aide = (char) extract_int(&aaa[4],8);
401 ls = extract_long(&aaa[4],6);
403 /* read info file if necessary */
404 if (extract_int(&aaa[4],3) > 0) readinfo();
406 /* check for newly arrived mail if we can */
407 if (num_parms(&aaa[4])>=10) {
408 newmailcount = extract_int(&aaa[4],9);
409 if ( (oldmailcount >= 0) && (newmailcount > oldmailcount) )
410 printf("*** You have new mail\n");
411 oldmailcount = newmailcount;
415 /* Goto next room having unread messages.
416 * We want to skip over rooms that the user has already been to, and take the
417 * user back to the lobby when done. The room we end up in is placed in
418 * newroom - which is set to 0 (the lobby) initially.
420 void gotonext(void) {
422 struct march *mptr,*mptr2;
425 /* Check to see if the march-mode list is already allocated.
426 * If it is, pop the first room off the list and go there.
432 while (serv_gets(buf), strcmp(buf,"000")) {
433 mptr = (struct march *) malloc(sizeof(struct march));
435 extract(mptr->march_name,buf,0);
436 mptr->march_floor = (char) (extract_int(buf,2) & 0x7F);
442 while (mptr2->next != NULL)
448 /* add _BASEROOM_ to the end of the march list, so the user will end up
449 * in the system base room (usually the Lobby>) at the end of the loop
451 mptr = (struct march *) malloc(sizeof(struct march));
453 strcpy(mptr->march_name,"_BASEROOM_");
459 while (mptr2->next != NULL)
464 * ...and remove the room we're currently in, so a <G>oto doesn't make us
465 * walk around in circles
467 remove_march(room_name,0);
473 strcpy(next_room,march->march_name);
476 strcpy(next_room,"_BASEROOM_");
478 remove_march(next_room,0);
479 dotgoto(next_room,1);
483 * forget all rooms on a given floor
485 void forget_all_rooms_on(int ffloor)
488 struct march *flist,*fptr;
490 printf("Forgetting all rooms on %s...\r",&floorlist[ffloor][0]);
492 sprintf(buf,"LKRA %d",ffloor);
496 printf("%-72s\n",&buf[4]);
500 while (serv_gets(buf), strcmp(buf,"000")) {
501 fptr = (struct march *) malloc(sizeof(struct march));
504 extract(fptr->march_name,buf,0);
506 while (flist != NULL) {
507 sprintf(buf,"GOTO %s",flist->march_name);
518 printf("%-72s\r","");
523 * routine called by gotofloor() to move to a new room on a new floor
525 void gf_toroom(char *towhere, int mode)
527 int floor_being_left;
529 floor_being_left = curr_floor;
531 if (mode == GF_GOTO) { /* <;G>oto mode */
536 if (mode == GF_SKIP) { /* <;S>kip mode */
538 remove_march("_FLOOR_",floor_being_left);
541 if (mode == GF_ZAP) { /* <;Z>ap mode */
543 remove_march("_FLOOR_",floor_being_left);
544 forget_all_rooms_on(floor_being_left);
552 void gotofloor(char *towhere, int mode)
556 char buf[256],targ[256];
558 if (floorlist[0][0]==0) load_floorlist();
560 for (a=0; a<128; ++a) if (!strucmp(&floorlist[a][0],towhere))
564 for (a=0; a<128; ++a) {
565 if (!struncmp(&floorlist[a][0],towhere,strlen(towhere))) {
572 for (a=0; a<128; ++a)
573 if (pattern(towhere,&floorlist[a][0])>0)
578 printf("No floor '%s'.\n",towhere);
582 for (mptr = march; mptr != NULL; mptr = mptr->next) {
583 if ((mptr->march_floor) == tofloor)
584 gf_toroom(mptr->march_name,mode);
589 sprintf(buf,"LKRA %d",tofloor);
592 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf,"000")) {
593 if ((extract_int(buf,2)==tofloor)&&(strlen(targ)==0))
596 if (strlen(targ)>0) {
597 gf_toroom(targ,mode);
600 printf("There are no rooms on '%s'.\n",&floorlist[tofloor][0]);
606 * forget all rooms on current floor
608 void forget_this_floor(void) {
610 if (curr_floor == 0) {
611 printf("Can't forget this floor.\n");
615 if (floorlist[0][0]==0) load_floorlist();
616 printf("Are you sure you want to forget all rooms on %s? ",
617 &floorlist[(int)curr_floor][0]);
618 if (yesno()==0) return;
620 gf_toroom("_BASEROOM_",GF_ZAP);
625 * Figure out the physical screen dimensions, if we can
627 void check_screen_dims(void) {
630 unsigned short height; /* rows */
631 unsigned short width; /* columns */
632 unsigned short xpixels;
633 unsigned short ypixels; /* pixels */
636 if (have_xterm) { /* dynamically size screen if on an xterm */
637 if ( ioctl(0, TIOCGWINSZ, &xwinsz) == 0 ) {
638 if (xwinsz.height) screenheight = (int) xwinsz.height;
639 if (xwinsz.width) screenwidth = (int) xwinsz.width;
647 * set floor mode depending on client, server, and user settings
649 void set_floor_mode(void) {
650 if (serv_info.serv_ok_floors == 0) {
651 floor_mode = 0; /* Don't use floors if the server */
652 } /* doesn't support them! */
654 if (rc_floor_mode == RC_NO) { /* never use floors */
657 if (rc_floor_mode == RC_YES) { /* always use floors */
660 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
661 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
667 * Set or change the user's password
669 int set_password(void) {
674 if (strlen(rc_password) > 0) {
675 strcpy(pass1,rc_password);
676 strcpy(pass2,rc_password);
679 IFNEXPERT formout("changepw");
680 newprompt("Enter a new password: ", pass1, -19);
681 newprompt("Enter it again to confirm: ", pass2, -19);
683 if (!strucmp(pass1,pass2)) {
684 sprintf(buf,"SETP %s",pass1);
687 printf("%s\n",&buf[4]);
691 printf("*** They don't match... try again.\n");
699 * get info about the server we've connected to
701 void get_serv_info(void) {
704 CtdlInternalGetServInfo(&serv_info);
706 /* be nice and identify ourself to the server */
707 sprintf(buf,"IDEN %d|%d|%d|%s|",
708 SERVER_TYPE,0,REV_LEVEL,
709 (server_is_local ? "local" : CITADEL));
710 locate_host(&buf[strlen(buf)]); /* append to the end */
712 serv_gets(buf); /* we don't care about the result code */
720 * Display list of users currently logged on to the server
722 void who_is_online(int longlist)
724 char buf[128], username[128], roomname[128], fromhost[128], flags[128];
725 char tbuf[128], timestr[128], idlebuf[128], clientsoft[128];
727 time_t idletime, idlehours, idlemins, idlesecs;
733 extract(timestr, tbuf, 1);
734 timenow = atol(timestr);
737 printf("FLG ### User Name Room From host\n");
738 printf("--- --- ------------------------- -------------------- ------------------------\n");
744 while(serv_gets(buf), strcmp(buf,"000"))
746 extract(username,buf,1);
747 extract(roomname,buf,2);
748 extract(fromhost,buf,3);
749 extract(clientsoft, buf, 4);
750 extract(idlebuf, buf,5);
751 extract(flags,buf,7);
754 idletime = timenow - atol(idlebuf);
755 idlehours = idletime / 3600;
756 idlemins = (idletime - (idlehours*3600)) / 60;
757 idlesecs = (idletime - (idlehours*3600) - (idlemins*60) );
758 printf("\nFlags: %-3s Sess# %-3d Name: %-25s Room: %s\n",
759 flags, extract_int(buf,0), username, roomname);
760 printf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n",
761 fromhost, clientsoft,
762 (long)idlehours, (long)idlemins, (long)idlesecs);
766 printf("%-3s %-3d %-25s %-20s %-24s\n",
767 flags, extract_int(buf,0), username,
774 void enternew(char *desc, char *buf, int maxlen)
777 sprintf(bbb, "Enter in your new %s: ", desc);
778 newprompt(bbb, buf, maxlen);
784 int main(int argc, char **argv)
788 char aaa[100],bbb[100],ccc[100],eee[100]; /* general purpose variables */
789 char argbuf[32]; /* command line buf */
792 load_command_set(); /* parse the citadel.rc file */
793 sttybbs(SB_SAVE); /* Store the old terminal parameters */
794 sttybbs(SB_NO_INTR); /* Install the new ones */
795 signal(SIGINT,SIG_IGN);
796 signal(SIGQUIT,SIG_IGN);
797 signal(SIGHUP,dropcarr); /* Cleanup gracefully if carrier is dropped */
798 signal(SIGTERM,dropcarr); /* Cleanup gracefully if terminated */
801 printf("Attaching to server...\r");
803 attach_to_server(argc,argv);
809 printf("%s\n",&aaa[4]);
814 printf("%-22s\n%s\n%s\n",serv_info.serv_software,serv_info.serv_humannode,
815 serv_info.serv_bbs_city);
816 screenwidth = 80; /* default screen dimensions */
819 printf(" pause next stop\n");
820 printf(" ctrl-s ctrl-o ctrl-c\n\n");
821 formout("hello"); /* print the opening greeting */
824 /* if we're not the login shell, try auto-login */
829 load_user_info(&aaa[4]);
836 GSTA: termn8=0; newnow=0;
838 if (strlen(rc_username) > 0) {
839 strcpy(fullname,rc_username);
842 newprompt("Enter your name: ",fullname,29);
845 if (!strucmp(fullname,"new")) { /* just in case */
846 printf("Please enter the name you wish to log in with.\n");
849 (!strucmp(fullname,"bbs"))
850 || (!strucmp(fullname,"new"))
851 || (strlen(fullname)==0) );
853 if (!strucmp(fullname,"off")) {
858 /* sign on to the server */
859 sprintf(aaa,"USER %s",fullname);
862 if (aaa[0]!='3') goto NEWUSR;
864 /* password authentication */
865 if (strlen(rc_password)>0) {
866 strcpy(eee,rc_password);
869 newprompt("\rPlease enter your password: ",eee,-19);
872 sprintf(aaa,"PASS %s",eee);
876 load_user_info(&aaa[4]);
880 printf("<< wrong password >>\n");
881 if (strlen(rc_password)>0) logoff(0);
884 NEWUSR: if (strlen(rc_password)==0) {
885 printf("No record. Enter as new user? ");
886 if (yesno()==0) goto GSTA;
889 sprintf(aaa,"NEWU %s",fullname);
896 load_user_info(&aaa[4]);
898 while (set_password() != 0) ;;
904 PWOK: printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
905 fullname,axlevel,axdefs[(int)axlevel],
906 usernum,timescalled);
911 b = extract_int(&aaa[4],0);
912 if (b==1) printf("*** You have a new private message in Mail>\n");
913 if (b>1) printf("*** You have %d new private messages in Mail>\n",b);
915 if ((axlevel>=6) && (extract_int(&aaa[4],2)>0)) {
916 printf("*** Users need validation\n");
919 if (extract_int(&aaa[4],1)>0) {
920 printf("*** Please register.\n");
926 /* Make up some temporary filenames for use in various parts of the
927 * program. Don't mess with these once they've been set, because we
928 * will be unlinking them later on in the program and we don't
929 * want to delete something that we didn't create. */
930 sprintf(temp,"/tmp/citA%d",getpid());
931 sprintf(temp2,"/tmp/citB%d",getpid());
932 sprintf(tempdir,"/tmp/citC%d",getpid());
934 /* Get screen dimensions. First we go to a default of 80x24. Then
935 * we try to get the user's actual screen dimensions off the server.
936 * However, if we're running on an xterm, all this stuff is
937 * irrelevant because we're going to dynamically size the screen
938 * during the session.
945 screenwidth = extract_int(&aaa[4],0);
946 screenheight = extract_int(&aaa[4],1);
948 if (getenv("TERM")!=NULL) if (!strcmp(getenv("TERM"),"xterm")) {
958 /* Enter the lobby */
959 dotgoto("_BASEROOM_",1);
961 /* Main loop for the system... user is logged in. */
965 if (newnow==1) readmsgs(3,1,5);
966 else readmsgs(1,1,0);
968 do { /* MAIN LOOP OF PROGRAM */
969 signal(SIGINT,SIG_IGN);
970 signal(SIGQUIT,SIG_IGN);
977 if (termn8==0) switch(mcmd) {
978 case 1: formout("help");
982 case 36: entmsg(0,1);
984 case 46: entmsg(0,2);
986 case 78: newprompt("What do you want your username to be? ", aaa, 32);
987 sprintf(bbb, "ENT0 2|0|0|0|%s", aaa);
990 if (strncmp("200", aaa, 3))
991 printf("\n%s\n", aaa);
998 case 47: updatelsa();
1001 case 58: updatelsa();
1002 dotgoto("_MAIL_",1);
1004 case 20: updatels();
1005 case 52: dotgoto(argbuf,0);
1007 case 10: readmsgs(0,1,0);
1009 case 9: readmsgs(3,1,5);
1011 case 13: readmsgs(1,1,0);
1013 case 11: readmsgs(0,(-1),0);
1015 case 12: readmsgs(2,(-1),0);
1017 case 71: readmsgs(3, 1, atoi(argbuf));
1019 case 7: forget(); break;
1020 case 18: subshell(); break;
1021 case 38: updatels();
1023 case 22: killroom(); break;
1024 case 32: userlist(); break;
1025 case 27: invite(); break;
1026 case 28: kickout(); break;
1027 case 23: editthisroom(); break;
1028 case 14: roomdir(); break;
1029 case 33: download(0); break;
1030 case 34: download(1); break;
1031 case 31: download(2); break;
1032 case 43: download(3); break;
1033 case 45: download(4); break;
1034 case 55: download(5); break;
1035 case 39: upload(0); break;
1036 case 40: upload(1); break;
1037 case 42: upload(2); break;
1038 case 44: upload(3); break;
1039 case 57: cli_upload(); break;
1040 case 16: ungoto(); break;
1041 case 24: whoknows(); break;
1042 case 26: validate(); break;
1043 case 29: updatels();
1046 case 30: updatels();
1049 case 48: enterinfo();
1051 case 49: readinfo();
1053 case 72: cli_image_upload("_userpic_");
1055 case 73: cli_image_upload("_roompic_");
1059 sprintf(aaa, "_floorpic_|%d", curr_floor);
1060 cli_image_upload(aaa);
1064 enternew("roomname", aaa, 20);
1065 sprintf(bbb, "RCHG %s", aaa);
1068 if (strncmp("200",aaa, 3))
1069 printf("\n%s\n", aaa);
1072 enternew("hostname", aaa, 25);
1073 sprintf(bbb, "HCHG %s", aaa);
1076 if (strncmp("200",aaa, 3))
1077 printf("\n%s\n", aaa);
1080 enternew("username", aaa, 32);
1081 sprintf(bbb, "UCHG %s", aaa);
1084 if (strncmp("200",aaa, 3))
1085 printf("\n%s\n", aaa);
1093 if (argbuf[0]==0) strcpy(aaa,"?");
1094 display_help(argbuf);
1098 formout("register");
1103 printf("Are you sure (y/n)? ");
1118 case 2: if (server_is_local) {
1119 sttybbs(SB_RESTORE);
1120 sprintf(aaa,"USERNAME=\042%s\042; export USERNAME; exec ./subsystem %ld %d %d",
1122 usernum,screenwidth,axlevel);
1124 sttybbs(SB_NO_INTR);
1127 printf("*** Can't run doors when server is not local.\n");
1154 gotofloor(argbuf,GF_GOTO);
1158 gotofloor(argbuf,GF_SKIP);
1162 forget_this_floor();
1190 knrooms(floor_mode);
1200 misc_server_cmd(argbuf);
1204 edit_system_message(argbuf);
1226 sprintf(bbb, "Page who [%s]? ", last_paged);
1228 sprintf(bbb, "Page who? ");
1229 newprompt(bbb,aaa,30);
1231 strcpy(aaa, last_paged);
1233 newprompt("Message: ",bbb,69);
1234 sprintf(ccc,"SEXP %s|%s",aaa,bbb);
1237 if (!strncmp("200", ccc, 3))
1238 strcpy(last_paged, aaa);
1239 printf("%s\n",&ccc[4]);
1245 TERMN8: printf("%s logged out.\n",fullname);
1246 while (march!=NULL) remove_march(march->march_name,0);
1248 printf("\n\nType 'off' to hang up, or next user...\n");
1249 sprintf(aaa,"LOUT");
1252 if ((mcmd==29)||(mcmd==15)) {