version 1.50 | | version 1.51 |
---|
| | |
/* | | /* |
* static char *rcsid_c_misc_c = | | * static char *rcsid_c_misc_c = |
* "$Id: c_misc.c,v 1.50 2005/03/20 22:23:40 majorwoo Exp $"; | | * "$Id: c_misc.c,v 1.51 2005/03/22 02:39:50 majorwoo Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
else | | else |
new_draw_info(NDI_UNIQUE, 0,op,"Heap checks out OK."); | | new_draw_info(NDI_UNIQUE, 0,op,"Heap checks out OK."); |
return 1; | | return 1; |
} | | yea } |
#endif | | #endif |
| | |
int command_who (object *op, char *params) { | | int command_who (object *op, char *params) { |
| | |
/*local functon for qsort comparison*/ | | /*local functon for qsort comparison*/ |
int name_cmp (chars_names *c1, chars_names *c2) | | int name_cmp (chars_names *c1, chars_names *c2) |
{ | | { |
return strcmp (c1->namebuf, c2->namebuf); | | return strcasecmp (c1->namebuf, c2->namebuf); |
} | | } |
| | |
/* | | /* |
| | |
if (pl->state==ST_PLAYING || pl->state==ST_GET_PARTY_PASSWORD) { | | if (pl->state==ST_PLAYING || pl->state==ST_GET_PARTY_PASSWORD) { |
| | |
num_players++; | | num_players++; |
chars = (chars_names *) realloc(chars, (num_players+1)*sizeof(chars_names)); | | chars = (chars_names *) realloc(chars, num_players*sizeof(chars_names)); |
sprintf(chars[num_players].namebuf, ""); | | |
chars[num_players].login_order = num_players; | | |
if (chars == NULL) | | if (chars == NULL) |
{ | | { |
new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!"); | | new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!"); |
return 0; | | return 0; |
} | | } |
| | sprintf(chars[num_players-1].namebuf, ""); |
| | chars[num_players-1].login_order = num_players; |
/*Check for WIZ's & AFK's*/ | | /*Check for WIZ's & AFK's*/ |
if (QUERY_FLAG(pl->ob,FLAG_WIZ)) | | if (QUERY_FLAG(pl->ob,FLAG_WIZ)) |
num_wiz++; | | num_wiz++; |
| | |
if (settings.who_wiz_format[i]=='%') { | | if (settings.who_wiz_format[i]=='%') { |
i++; | | i++; |
get_who_escape_code_value(tmpbuf,settings.who_wiz_format[i],pl); | | get_who_escape_code_value(tmpbuf,settings.who_wiz_format[i],pl); |
strcat(chars[num_players].namebuf, tmpbuf); | | strcat(chars[num_players-1].namebuf, tmpbuf); |
} | | } |
else if (settings.who_wiz_format[i]=='_') | | else if (settings.who_wiz_format[i]=='_') |
strcat(chars[num_players].namebuf," "); /* allow '_' to be used in place of spaces */ | | strcat(chars[num_players-1].namebuf," "); /* allow '_' to be used in place of spaces */ |
else { | | else { |
sprintf(tmpbuf,"%c",settings.who_wiz_format[i]); | | sprintf(tmpbuf,"%c",settings.who_wiz_format[i]); |
strcat(chars[num_players].namebuf,tmpbuf); | | strcat(chars[num_players-1].namebuf,tmpbuf); |
} | | } |
} | | } |
} | | } |
| | |
if (settings.who_format[i]=='%') { | | if (settings.who_format[i]=='%') { |
i++; | | i++; |
get_who_escape_code_value(tmpbuf,settings.who_format[i],pl); | | get_who_escape_code_value(tmpbuf,settings.who_format[i],pl); |
strcat(chars[num_players].namebuf, tmpbuf); | | strcat(chars[num_players-1].namebuf, tmpbuf); |
} | | } |
else if (settings.who_format[i]=='_') | | else if (settings.who_format[i]=='_') |
strcat(chars[num_players].namebuf," "); /* allow '_' to be used in place of spaces */ | | strcat(chars[num_players-1].namebuf," "); /* allow '_' to be used in place of spaces */ |
else { | | else { |
sprintf(tmpbuf,"%c",settings.who_format[i]); | | sprintf(tmpbuf,"%c",settings.who_format[i]); |
strcat(chars[num_players].namebuf,tmpbuf); | | strcat(chars[num_players-1].namebuf,tmpbuf); |
} | | } |
} | | } |
} | | } |
| | |
sprintf(players_str, "Total Players (%d) -- WIZ(%d) AFK(%d)", num_players, num_wiz, num_afk); | | sprintf(players_str, "Total Players (%d) -- WIZ(%d) AFK(%d)", num_players, num_wiz, num_afk); |
new_draw_info(NDI_UNIQUE, 0, op, players_str); | | new_draw_info(NDI_UNIQUE, 0, op, players_str); |
} | | } |
qsort (chars, (num_players+1), sizeof(chars_names), name_cmp); | | qsort (chars, num_players, sizeof(chars_names), name_cmp); |
for (i=1;i<=num_players;i++) | | for (i=0;i<num_players;i++) |
new_draw_info(NDI_UNIQUE, 0, op, chars[i].namebuf); | | new_draw_info(NDI_UNIQUE, 0, op, chars[i].namebuf); |
free (chars); | | free (chars); |
return 1; | | return 1; |