On Sun, Feb 24, 2002 at 10:22:46PM -0500, [EMAIL PROTECTED] wrote:
> Ok im trying to sort commands by name. And the only thing it gives me is a
> SIG_TRAP on the copyover. ok thats normal for gdb. and when the core does
> finaly dump it gives me:
Here, have mine:
void do_commands(CHAR_DATA *ch,char *argument) {
char *Commands[512]; // at most 512 commands
char buf[MAX_INPUT_LENGTH];
static BUFFER *buffer=NULL;
int cmd;
int top = 0;
int i, j;
if (!buffer) {
logf("[0] Sorting commands-table");
buffer = new_buf();
add_buf(buffer,"{cCommand List:{W\n\r");
for ( cmd = 0; cmd_table[cmd].name!=NULL; cmd++ )
if (cmd_table[cmd].vnum==0
&& cmd_table[cmd].show
&& cmd_table[cmd].disabled==FALSE) {
for ( i = 0; i < top; i++ )
if ( strcmp( Commands[i], cmd_table[cmd].name ) > 0 )
break;
for ( j = top; j > i; j-- )
Commands[j] = Commands[j-1];
Commands[i] = cmd_table[cmd].name;
top++;
if (top==512) {
bugf("More than 512 commands, please fix do_commands()");
break;
}
}
for ( i = 0; i < top; i++ ) {
sprintf( buf, "{W%-19s", Commands[i]);
add_buf(buffer, buf);
if ( ( i + 1 )%4 == 0 ) {
sprintf( buf, "{x\n\r" );
add_buf(buffer, buf);
}
}
add_buf(buffer,"\r\n{x");
}
page_to_char( buf_string(buffer), ch );
/* free_buf(buffer); this buffer is never freed, sorry */
}
--
Edwin Groothuis | Personal website: http://www.MavEtJu.org
[EMAIL PROTECTED] | Interested in MUDs? Visit Fatal Dimensions:
------------------+ http://www.FatalDimensions.org/