|
From: <cro...@li...> - 2005-03-22 02:39:57
|
Module Name: crossfire
Committed By: majorwoo
Date: Tue Mar 22 02:39:50 UTC 2005
Modified Files:
crossfire/server: c_misc.c
Log Message:
Updated who to sort case insensitive and prevent the occasional printing of garbage characters
Start of context diffs
Index: crossfire/server/c_misc.c
diff -c crossfire/server/c_misc.c:1.50 crossfire/server/c_misc.c:1.51
*** crossfire/server/c_misc.c:1.50 Sun Mar 20 14:23:40 2005
--- crossfire/server/c_misc.c Mon Mar 21 18:39:50 2005
***************
*** 1,6 ****
/*
* static char *rcsid_c_misc_c =
! * "$Id: c_misc.c,v 1.50 2005/03/20 22:23:40 majorwoo Exp $";
*/
/*
--- 1,6 ----
/*
* static char *rcsid_c_misc_c =
! * "$Id: c_misc.c,v 1.51 2005/03/22 02:39:50 majorwoo Exp $";
*/
/*
***************
*** 250,256 ****
else
new_draw_info(NDI_UNIQUE, 0,op,"Heap checks out OK.");
return 1;
! }
#endif
int command_who (object *op, char *params) {
--- 250,256 ----
else
new_draw_info(NDI_UNIQUE, 0,op,"Heap checks out OK.");
return 1;
! yea }
#endif
int command_who (object *op, char *params) {
***************
*** 270,276 ****
/*local functon for qsort comparison*/
int name_cmp (chars_names *c1, chars_names *c2)
{
! return strcmp (c1->namebuf, c2->namebuf);
}
/*
--- 270,276 ----
/*local functon for qsort comparison*/
int name_cmp (chars_names *c1, chars_names *c2)
{
! return strcasecmp (c1->namebuf, c2->namebuf);
}
/*
***************
*** 292,305 ****
if (pl->state==ST_PLAYING || pl->state==ST_GET_PARTY_PASSWORD) {
num_players++;
! chars = (chars_names *) realloc(chars, (num_players+1)*sizeof(chars_names));
! sprintf(chars[num_players].namebuf, "");
! chars[num_players].login_order = num_players;
if (chars == NULL)
{
new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!");
return 0;
}
/*Check for WIZ's & AFK's*/
if (QUERY_FLAG(pl->ob,FLAG_WIZ))
num_wiz++;
--- 292,305 ----
if (pl->state==ST_PLAYING || pl->state==ST_GET_PARTY_PASSWORD) {
num_players++;
! chars = (chars_names *) realloc(chars, num_players*sizeof(chars_names));
if (chars == NULL)
{
new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!");
return 0;
}
+ sprintf(chars[num_players-1].namebuf, "");
+ chars[num_players-1].login_order = num_players;
/*Check for WIZ's & AFK's*/
if (QUERY_FLAG(pl->ob,FLAG_WIZ))
num_wiz++;
***************
*** 310,322 ****
if (settings.who_wiz_format[i]=='%') {
i++;
get_who_escape_code_value(tmpbuf,settings.who_wiz_format[i],pl);
! strcat(chars[num_players].namebuf, tmpbuf);
}
else if (settings.who_wiz_format[i]=='_')
! strcat(chars[num_players].namebuf," "); /* allow '_' to be used in place of spaces */
else {
sprintf(tmpbuf,"%c",settings.who_wiz_format[i]);
! strcat(chars[num_players].namebuf,tmpbuf);
}
}
}
--- 310,322 ----
if (settings.who_wiz_format[i]=='%') {
i++;
get_who_escape_code_value(tmpbuf,settings.who_wiz_format[i],pl);
! strcat(chars[num_players-1].namebuf, tmpbuf);
}
else if (settings.who_wiz_format[i]=='_')
! strcat(chars[num_players-1].namebuf," "); /* allow '_' to be used in place of spaces */
else {
sprintf(tmpbuf,"%c",settings.who_wiz_format[i]);
! strcat(chars[num_players-1].namebuf,tmpbuf);
}
}
}
***************
*** 325,337 ****
if (settings.who_format[i]=='%') {
i++;
get_who_escape_code_value(tmpbuf,settings.who_format[i],pl);
! strcat(chars[num_players].namebuf, tmpbuf);
}
else if (settings.who_format[i]=='_')
! strcat(chars[num_players].namebuf," "); /* allow '_' to be used in place of spaces */
else {
sprintf(tmpbuf,"%c",settings.who_format[i]);
! strcat(chars[num_players].namebuf,tmpbuf);
}
}
}
--- 325,337 ----
if (settings.who_format[i]=='%') {
i++;
get_who_escape_code_value(tmpbuf,settings.who_format[i],pl);
! strcat(chars[num_players-1].namebuf, tmpbuf);
}
else if (settings.who_format[i]=='_')
! strcat(chars[num_players-1].namebuf," "); /* allow '_' to be used in place of spaces */
else {
sprintf(tmpbuf,"%c",settings.who_format[i]);
! strcat(chars[num_players-1].namebuf,tmpbuf);
}
}
}
***************
*** 342,349 ****
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);
}
! qsort (chars, (num_players+1), sizeof(chars_names), name_cmp);
! for (i=1;i<=num_players;i++)
new_draw_info(NDI_UNIQUE, 0, op, chars[i].namebuf);
free (chars);
return 1;
--- 342,349 ----
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);
}
! qsort (chars, num_players, sizeof(chars_names), name_cmp);
! for (i=0;i<num_players;i++)
new_draw_info(NDI_UNIQUE, 0, op, chars[i].namebuf);
free (chars);
return 1;
|