/**************************************************************************** ** Project : pDirt (Aber IV MUD daemon) ** Module : infosys.c ** Author : various ** Description: Some functions used to show info/help on things. ****************************************************************************/ #define INFOSYS_C #include "kernel.h" #include <unistd.h> #include "bprintf.h" #include "sendsys.h" #include "sflags.h" #include "mobile.h" #include "parse.h" #include "quest.h" /*************************************************************************** ** PROTOTYPES ***************************************************************************/ A_COMMAND(helpcom); /* General help command */ A_COMMAND(infocom); /* Informations system command */ A_COMMAND(qinfocom); /* Quest information systemcommand */ A_COMMAND(powerinfocom); int showhelp(char *verb); /* Used by helpcom */ A_COMMAND(helpcom) { int a, b; if (item1[0] != 0) { if (showhelp (item1) < 0) return; if ((a = vichere ()) < 0) return; if ((b = phelping (mynum)) >= 0) { sillytp (b, "stopped helping you."); bprintf ("Stopped helping \001p%s\003.\n", pname (b)); return; } if (a == mynum) { bprintf ("You are beyond help.\n"); return; } setphelping (mynum, a); sillytp (a, "has offered to help you."); bprintf ("Started helping \001p%s\003.\n", pname (phelping (mynum))); return; } if (cur_player->aliased || cur_player->polymorphed != -1) { bprintf("Not while aliased.\n"); return; } if (plev (mynum) >= LVL_GOD) read_file (HELP, NULL, False, NULL); else if (plev (mynum) >= LVL_DEMI) read_file (HELP, "GOD", False, NULL); else if (plev (mynum) >= LVL_ARCHWIZARD) read_file (HELP, "DEMIGOD", False, NULL); else if (plev (mynum) >= LVL_APPREN) read_file (HELP, "ARCHWIZARD", False, NULL); else read_file (HELP, "WIZARD", False, NULL); return; } int showhelp (char *verb) { char file[256]; char line[80]; char ext; int scanreturn = 0; int v; FILE *fp; ext = toupper(verb[0]); if(!isalpha(ext)) ext = '0'; sprintf(line,"HELP/%c/%s.h",ext,lowercase(verb)); sprintf (file, ROOTDIR"/drv/bin/pfilter %d 0x%08lx:0x%08lx:0x%08lx 0x%08lx:0x%08lx:0x%08lx %s", plev (mynum), pflags (mynum).b3, pflags (mynum).b2, pflags(mynum).b1, pmask (mynum).b3, pmask (mynum).b2, pmask(mynum).b1,line); if ((fp = popen (file, "r")) == NULL) { bprintf ("Someone's editing the help file.\n"); return -1; } ssetflg (mynum, SFL_BUSY); pbfr (); v = strlen (verb); if (fgets (line, sizeof (line), fp) == NULL) { scanreturn = EOF; } if (scanreturn == EOF) { /* command not found in extern list */ pclose (fp); sclrflg (mynum, SFL_BUSY); return 0; } bprintf("&+w%s",DASHLINE); bprintf ("\n&+wUsage: &+w%s\n", line); while (fgets (line, sizeof (line), fp) != 0 && line[0] != '^') { bprintf ("%s", line); } bprintf ("&+w%s&*\n",DASHLINE); pclose (fp); sclrflg (mynum, SFL_BUSY); return -1; } /*************************************************************************** ** Main viewer by QINFO and INFO. ** The Boolean is used to indicate if we want to use the Quests info dir. ***************************************************************************/ PRIVATE void info_viewer(Boolean Qinfo) { char file[100]; char file1[110]; if (brkword () == -1) { if (Qinfo) { /*strcpy (file,QINDEX);*/ qinfo_list(); return; } else strcpy (file, INFO); } else { if (strlen(wordbuf) > 15) { bprintf("Filename too long.\n"); return; } if (Qinfo) { sprintf(file, "%s/%s.i",QUEST_DIR,lowercase(wordbuf)); sprintf(file1,"%s/%s.i.Z",QUEST_DIR,lowercase(wordbuf)); } else { sprintf (file, "INFO/%s.i", lowercase (wordbuf)); sprintf (file1, "INFO/%s.i.Z", lowercase (wordbuf)); } if (access (file, R_OK) < 0 && access (file1, R_OK) < 0) { bprintf ("No info available on that topic.\n"); return; } } read_file(file,NULL,True,NULL); } /* The INFO command. */ A_COMMAND(infocom) { info_viewer(False); } /* The QINFO command. * Show information about a specific quest */ A_COMMAND(qinfocom) { info_viewer(True); } A_COMMAND(powerinfocom) { char file[255]; if (plev(mynum) < LVL_ARCHWIZARD) { erreval(); return; } if (EMPTY(item1)) { strcpy(file,"POWERINFO/index.pi"); } else { sprintf(file,"POWERINFO/%s.pi",lowercase(item1)); if (access(file,R_OK) < 0) { bprintf("No info on %s.\n",item1); return; } bprintf("&+wPowers Information System&*\n"); } read_file(file,NULL,True,NULL); }