Well things seem to be a little... out of proportion, you could say. Let me elaborate on the code. Please note I had a previous working version that someone wrote for me, but I changed my command system in the MUD game, so Its been re-written.
Code:
struct command_type
{
void (*funp)(CHAR_DATA *ch, char *args);
};
....
const struct command_type player_commands[] = {
{ c_bug },
{ c_editcmd },
{ c_halt },
{ c_idea },
{ c_logview },
{ c_makecmd },
{ c_motd },
{ c_password },
{ c_quit },
{ c_reset_char },
{ c_save },
{ c_savecmds },
{ c_say },
{ c_show_flags },
{ c_toggle_flag },
{ c_typo },
{ c_who },
{ NULL }
};
void command_interp(CHAR_DATA *ch, char *input)
{
char *command;
char *args;
COMMAND_DATA *cmd;
int i;
bool bad_c=FALSE;
// Note: GNU claims strtok is very bad, the security concerned could
// change this to something else.
command = strtok(input, " ");
args = strtok(NULL, "");
if((input[0]==' ') || (input==NULL))
bad_c=TRUE;
/*
for (i=0; player_commands[i].name[0] != '\0'; i++) {
if(bad_c==TRUE)
break;
if (!strcmpi(command, player_commands[i].name)) {
((player_commands[i].funp))(ch, args);
return;
}
} */
for(cmd=first_command;cmd!=NULL;cmd=cmd->next){
if(bad_c==TRUE)
break;
if(!strcmpi(command, cmd->name)) {
((cmd->function))(ch, args);
return;
}
}
bad_command(ch);
}
Well, perhaps that will clear up exactley what I'm trying to do? Oh, and one more thing. I'm using MSVC++ 6.0 IDE to edit the code, but its being written to run under linux, or *unix environments. I'm using cygwin to compile under windows.
Thanks again.