/* help_proc() - Process the HELP command.
   Parameters:  helpwds - Number of words in the command string.
   Returns:  Nothing.
*/
void help_proc(XINT helpwds)
    { // Will need to change the order to the order proc'd later.
    char hused = 0; /* Flag if a help file has been shown or not. */
    unsigned char *helpfile = NULL; /* Name of help file to show. */

    /* In this function, basically every command is checked to see if it
       follows the HELP command.  If a match is found, the name of the
       file to show is set, as is a flag. */

    /* Due to the simplicity of this function, comments have been kept
       to a minimum. */

    /* Regular commands. */
    if (!hused && (helpwds < 2 ||
                   checkcmdmatch(get_word(1), getlang("CmdsHelp"))))
        {
        hused = 1;
        helpfile = "HELP_HLP";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsQuit")))
        {
        hused = 1;
        helpfile = "HELPQUIT";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsCommands")))
        {
        hused = 1;
        helpfile = "HELPCMDS";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsColourHelp")))
        {
        hused = 1;
        helpfile = "HELPCHLP";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsTime")))
        {
        hused = 1;
        helpfile = "HELPTIME";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsWho")))
        {
        hused = 1;
        helpfile = "HELP_WHO";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsProfile")))
        {
        hused = 1;
        helpfile = "HELPPROF";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLookUp")))
        {
        hused = 1;
        helpfile = "HELPLKUP";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsNodes")))
        {
        hused = 1;
        helpfile = "HELPNODS";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPage")))
        {
        hused = 1;
        helpfile = "HELPPAGE";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsForget")))
        {
        hused = 1;
        helpfile = "HELP_FGT";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsRemember")))
        {
        hused = 1;
        helpfile = "HELPRMBR";
        } // May need slight mods below
    /* Whispers have two command forms; each is checked. */
    if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsWhisperLong1")) ||
                   checkcmdmatch(get_word(1), getlang("WhisperShortChar"))))
        {
        hused = 1;
        helpfile = "HELPWHIS";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA")))
        {
        hused = 1;
        helpfile = "HELP_GA1";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA2")))
        {
        hused = 1;
        helpfile = "HELP_GA2";
        } // May need slight mods below
    /* Directed messages have two command forms; each is checked. */
    if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsDirectedLong1")) ||
                   checkcmdmatch(get_word(1), getlang("DirectedShortChar"))))
        {
        hused = 1;
        helpfile = "HELP_DIR";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsJoin")))
        {
        hused = 1;
        helpfile = "HELPJOIN";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivChat")))
        {
        hused = 1;
        helpfile = "HELPCHAT";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivDenyChat")))
        {
        hused = 1;
        helpfile = "HELPDENY";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLogOff")))
        {
        hused = 1;
        helpfile = "HELPLGOF";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsConfList")))
        {
        hused = 1;
        helpfile = "HELPCLST";
        }

    /* Multi-part commands.  If a valid secondary command is recognized
       then its specific help file will be shown, otherwise a general help
       file for the multi-part command will be shown. */
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsAction")))
        {
        hused = 1;
        helpfile = "HELPACT0";
        if (helpwds >= 2)
            {
            if (checkcmdmatch(get_word(2), getlang("CmdsActionList")))
                helpfile = "HELPACT1";
            if (checkcmdmatch(get_word(2), getlang("CmdsActionOn")))
                helpfile = "HELPACT2";
            if (checkcmdmatch(get_word(2), getlang("CmdsActionOff")))
                helpfile = "HELPACT3";
            }
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsChange")))
        {
        hused = 1;
        helpfile = "HELPCHG0";
        if (helpwds >= 2)
            {
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeHandle")))
                helpfile = "HELPCHG1";
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeEMessage")))
                helpfile = "HELPCHG2";
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeXMessage")))
                helpfile = "HELPCHG3";
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeSex")))
                helpfile = "HELPCHG4";
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeChatMode")))
                helpfile = "HELPCHG5";
            if (checkcmdmatch(get_word(2), getlang("CmdsChangeListed")))
                helpfile = "HELPCHG6";
            }
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsSysop")))
        {
        hused = 1;
        helpfile = "HELPSYS0";
        if (helpwds >= 2)
            {
            if (checkcmdmatch(get_word(2), getlang("CmdsSysopClear")))
                helpfile = "HELPSYS1";
            if (checkcmdmatch(get_word(2), getlang("CmdsSysopToss")))
                helpfile = "HELPSYS2";
            if (checkcmdmatch(get_word(2), getlang("CmdsSysopZap")))
                helpfile = "HELPSYS3";
            if (checkcmdmatch(get_word(2), getlang("CmdsSysopSetSec")))
                helpfile = "HELPSYS4";
            }
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsModerator")))
        {
        hused = 1;
        helpfile = "HELPMOD0";
        if (helpwds >= 2)
            {
            if (checkcmdmatch(get_word(2), getlang("CmdsModTopicChg")))
                helpfile = "HELPMOD1";
            if (checkcmdmatch(get_word(2), getlang("CmdsModModChg")))
                helpfile = "HELPMOD2";
            if (checkcmdmatch(get_word(2), getlang("CmdsModBan")))
                helpfile = "HELPMOD3";
            if (checkcmdmatch(get_word(2), getlang("CmdsModUnBan")))
                helpfile = "HELPMOD4";
            if (checkcmdmatch(get_word(2), getlang("CmdsModInvite")))
                helpfile = "HELPMOD5";
            if (checkcmdmatch(get_word(2), getlang("CmdsModUnInvite")))
                helpfile = "HELPMOD6";
            }
        }

    /* Non-command help topics. */
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpTopics")))
        {
        hused = 1;
        helpfile = "HELP_TOP";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpGeneral")))
        {
        hused = 1;
        helpfile = "HELP_GEN";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpActions")))
        {
        hused = 1;
        helpfile = "HELPACTS";
        }
    if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpChannels")))
        {
        hused = 1;
        helpfile = "HELPCHAN";
        }

    if (hused)
        {
        /* Show the help file if one was set. */
        show_helpfile(helpfile);
        }
    else
        {
        /* Unknown command. */
        top_output(OUT_SCREEN, getlang("NoHelpAvailable"));
        }

    }
Beispiel #2
0
void do_help(CHAR_DATA *ch, char *argument)
{
	int numresults=0;
	MYSQL *conn;
	MYSQL_RES *res_set = NULL, *res_set2 = NULL;
	MYSQL_ROW row;
	char query[MSL*2], buf[MSL];

	if(!str_cmp(argument,""))
		return do_help(ch, "topics");
	else
	{
		if((!is_alphanum(argument) && !have_space(argument)) || have_schar(argument))
			return do_help(ch, "topics");
	}

	conn = open_conn();
	if(!conn)
		return send_to_char("Error opening help database.\n\r",ch);

	if(is_number(argument))
		sprintf(query,"select * from helpfiles where id=%d", atoi(argument));
	else if(!is_number(argument))
		sprintf(query,"select * from helpfiles where title RLIKE '%s' ORDER BY id ASC", argument);

	mysql_query(conn,query);
	res_set = mysql_store_result(conn);
	numresults = mysql_affected_rows(conn);
	
	if(!numresults || (res_set == NULL && mysql_field_count(conn)>0))
		send_to_char("No matching helpfiles found.\n\r",ch);
	else if(numresults == 1)
	{
		row = mysql_fetch_row (res_set);
		if(!can_see_help(ch, row, TRUE))
			send_to_char("No matching helpfiles found.\n\r",ch);
		else
			show_helpfile(ch, row);
	}
	else
	{
		sprintf(query,"select * from helpfiles where title RLIKE '\\'%s\\'' OR title = '%s'", argument, argument);
		mysql_query(conn,query);
		res_set2 = mysql_store_result(conn);
		numresults = mysql_affected_rows(conn);
		if(numresults > 0)
		{
			row = mysql_fetch_row(res_set2);
			if(!can_see_help(ch, row, FALSE))
				send_to_char("No matching helpfiles found.\n\r", ch);
			else
			{
				show_helpfile(ch, row);
				mysql_free_result(res_set2);
			}
		}
		else
		{
			send_to_char("Multiple helpfiles matched your request:\n\r",ch);
			while((row = mysql_fetch_row (res_set)) != NULL)
        	{
	   			if(!can_see_help(ch,row, FALSE))
					continue;
	   			sprintf(buf,"%-5s %s\n\r", row[0], row[1]);
	   			send_to_char(buf,ch);
        	}
		}
	}
	mysql_free_result (res_set);
	do_disc(conn);
}