02 Sep, 2012, thatjdguy wrote in the 1st comment:
Votes: 0
I'm using SmaugFUSS 1.9 and want to do a little revamping to the Who list. So far I've added colorized clan names by implementing clan_display (works much like badge). There's one thing that's still stumping me quite a bit.

Basically I'm wanting to make it so that leaders and ranking members of clans will have custom ranks displayed in front of the clan name. Stock SmaugFUSS places these in the rank section of the who list (in place of Avatar or 25 Mage or whatever). The format I'm going for would look like this.

25 Mage PlayerName and title. (CustomRank of This Clan)

In order to achieve this, I've changed the following code in act_info.c under do_who:

else if( !str_cmp (wch->name, pclan->leader ) )
{
mudstrlcat( clan_leadrank, " ", MAX_INPUT_LENGTH );
mudstrlcat( clan_display, " of ", MAX_INPUT_LENGTH );
}


I added the first mudstrlcat statement for displaying of the custom rank

snprintf( buf, MAX_STRING_LENGTH, "%*s&B[&W%-15s&B]&G%-2s%s%s%s%s%s%s%s.%s%s%s%s\r\n",
( fGroup ? whogr->indent : 0 ), "",
Class,
invis_str,
( wch->desc && wch->desc->connected ) ? "&R[&WWRITING&R]&G " : "",
xIS_SET( wch->act, PLR_AFK ) ? "&R[&BA&WF&YK&R]&G " : "",
xIS_SET( wch->act, PLR_ATTACKER ) ? "&R(&WATTACKER&R)&G " : "",
xIS_SET( wch->act, PLR_KILLER ) ? "&R(&WKILLER&R)&G " : "",
xIS_SET( wch->act, PLR_THIEF ) ? "&R(&WTHIEF&R)&G " : "",
char_name, wch->pcdata->title, extra_title, clan_leadrank, clan_display, council_name );


Added an extra %s behind the period for displaying clan_leadrank

With the code like this, the display is as follows:

25 Mage PlayerName with title. ( of This Clan)

I added the word test between " " of the first mudstrlcat statement and it added test before the ( of the clan display.

Any ideas on how to get the custom rank inside the ( ) in front of the clan name?
02 Sep, 2012, thatjdguy wrote in the 2nd comment:
Votes: 0
In the hopes that it will help, here is the entire do_who I'm using.

void do_who( CHAR_DATA* ch, const char* argument)
{
char buf[MAX_STRING_LENGTH];
char clan_name[MAX_INPUT_LENGTH];
char clan_display[MAX_INPUT_LENGTH];
char clan_leadrank[MAX_INPUT_LENGTH];
char council_name[MAX_INPUT_LENGTH];
char invis_str[MAX_INPUT_LENGTH];
char char_name[MAX_INPUT_LENGTH];
const char *extra_title;
char class_text[MAX_INPUT_LENGTH];
struct whogr_s *whogr, *whogr_p;
DESCRIPTOR_DATA *d;
int iClass, iRace;
int iLevelLower;
int iLevelUpper;
int nNumber;
int nMatch;
bool rgfClass[MAX_CLASS];
bool rgfRace[MAX_RACE];
bool fClassRestrict;
bool fRaceRestrict;
bool fImmortalOnly;
bool fLeader;
bool fPkill;
bool fShowHomepage;
bool fClanMatch; /* SB who clan (order),who guild, and who council */
bool fCouncilMatch;
bool fDeityMatch;
bool fGroup;
CLAN_DATA *pClan = NULL;
COUNCIL_DATA *pCouncil = NULL;
DEITY_DATA *pDeity = NULL;
FILE *whoout = NULL;

/*
* #define WT_IMM 0;
* #define WT_MORTAL 1;
* #define WT_DEADLY 2;
*/

WHO_DATA *cur_who = NULL;
WHO_DATA *next_who = NULL;
WHO_DATA *first_mortal = NULL;
WHO_DATA *first_imm = NULL;
WHO_DATA *first_deadly = NULL;
WHO_DATA *first_grouped = NULL;
WHO_DATA *first_groupwho = NULL;


/*
* Set default arguments.
*/
iLevelLower = 0;
iLevelUpper = MAX_LEVEL;
fClassRestrict = FALSE;
fRaceRestrict = FALSE;
fImmortalOnly = FALSE;
fPkill = FALSE;
fShowHomepage = FALSE;
fClanMatch = FALSE; /* SB who clan (order), who guild, who council */
fCouncilMatch = FALSE;
fDeityMatch = FALSE;
fGroup = FALSE; /* Alty who group */
fLeader = FALSE;
for( iClass = 0; iClass < MAX_CLASS; iClass++ )
rgfClass[iClass] = FALSE;
for( iRace = 0; iRace < MAX_RACE; iRace++ )
rgfRace[iRace] = FALSE;

#ifdef REQWHOARG
/*
* The who command must have at least one argument because we often
* have up to 500 players on. Too much spam if a player accidentally
* types "who" with no arguments. –Gorog
*/
if( ch && argument[0] == '\0' )
{
send_to_pager_color( "\r\n&GYou must specify at least one argument.\r\nUse 'who 1' to view the entire who list.\r\n",
ch );
return;
}
#endif

/*
* Parse arguments.
*/
nNumber = 0;
for( ;; )
{
char arg[MAX_STRING_LENGTH];

argument = one_argument( argument, arg );
if( arg[0] == '\0' )
break;

if( is_number( arg ) )
{
switch ( ++nNumber )
{
case 1:
iLevelLower = atoi( arg );
break;
case 2:
iLevelUpper = atoi( arg );
break;
default:
send_to_char( "Only two level numbers allowed.\r\n", ch );
return;
}
}
else
{
if( strlen( arg ) < 3 )
{
send_to_char( "Arguments must be longer than that.\r\n", ch );
return;
}

/*
* Look for classes to turn on.
*/
if( !str_cmp( arg, "deadly" ) || !str_cmp( arg, "pkill" ) )
fPkill = TRUE;
else if( !str_cmp( arg, "imm" ) || !str_cmp( arg, "gods" ) )
fImmortalOnly = TRUE;
else if( !str_cmp( arg, "leader" ) )
fLeader = TRUE;
else if( !str_cmp( arg, "www" ) )
fShowHomepage = TRUE;
else if( !str_cmp( arg, "group" ) && ch )
fGroup = TRUE;
else /* SB who clan (order), guild, council */ if( ( pClan = get_clan( arg ) ) )
fClanMatch = TRUE;
else if( ( pCouncil = get_council( arg ) ) )
fCouncilMatch = TRUE;
else if( ( pDeity = get_deity( arg ) ) )
fDeityMatch = TRUE;
else
{
for( iClass = 0; iClass < MAX_CLASS; iClass++ )
{
if( !str_cmp( arg, class_table[iClass]->who_name ) )
{
rgfClass[iClass] = TRUE;
break;
}
}
if( iClass != MAX_CLASS )
fClassRestrict = TRUE;

for( iRace = 0; iRace < MAX_RACE; iRace++ )
{
if( !str_cmp( arg, race_table[iRace]->race_name ) )
{
rgfRace[iRace] = TRUE;
break;
}
}
if( iRace != MAX_RACE )
fRaceRestrict = TRUE;

if( iClass == MAX_CLASS && iRace == MAX_RACE
&& fClanMatch == FALSE && fCouncilMatch == FALSE && fDeityMatch == FALSE )
{
send_to_char( "That's not a class, race, order, guild," " council or deity.\r\n", ch );
return;
}
}
}
}

/*
* Now find matching chars.
*/
nMatch = 0;
buf[0] = '\0';
if( ch )
set_pager_color( AT_GREEN, ch );
else
{
if( fShowHomepage )
whoout = fopen( WEBWHO_FILE, "w" );
else
whoout = fopen( WHO_FILE, "w" );
if( !whoout )
{
bug( "do_who: cannot open who file!" );
return;
}
}

/* start from last to first to get it in the proper order */
if( fGroup )
{
create_whogr( ch );
whogr = first_whogr;
d = whogr->d;
}
else
{
whogr = NULL;
d = last_descriptor;
}
whogr_p = NULL;
for( ; d; whogr_p = whogr, whogr = ( fGroup ? whogr->next : NULL ),
d = ( fGroup ? ( whogr ? whogr->d : NULL ) : d->prev ) )
{
CHAR_DATA *wch;
char const *Class;

if( ( d->connected != CON_PLAYING && d->connected != CON_EDITING ) || !can_see( ch, d->character ) || d->original )
continue;
wch = d->original ? d->original : d->character;
if( wch->level < iLevelLower || wch->level > iLevelUpper || ( fPkill && !CAN_PKILL( wch ) ) || ( fImmortalOnly && wch->level < LEVEL_IMMORTAL ) || ( fClassRestrict && !rgfClass[wch->Class] ) || ( fRaceRestrict && !rgfRace[wch->race] ) || ( fClanMatch && ( pClan != wch->pcdata->clan ) ) /* SB */
|| ( fCouncilMatch && ( pCouncil != wch->pcdata->council ) ) /* SB */
|| ( fDeityMatch && ( pDeity != wch->pcdata->deity ) ) )
continue;
if( fLeader && !( wch->pcdata->council &&
( ( wch->pcdata->council->head2 &&
!str_cmp( wch->pcdata->council->head2, wch->name ) ) ||
( wch->pcdata->council->head &&
!str_cmp( wch->pcdata->council->head, wch->name ) ) ) ) &&
!( wch->pcdata->clan && ( ( wch->pcdata->clan->deity &&
!str_cmp( wch->pcdata->clan->deity, wch->name ) )
|| ( wch->pcdata->clan->leader
&& !str_cmp( wch->pcdata->clan->leader, wch->name ) )
|| ( wch->pcdata->clan->number1
&& !str_cmp( wch->pcdata->clan->number1, wch->name ) )
|| ( wch->pcdata->clan->number2
&& !str_cmp( wch->pcdata->clan->number2, wch->name ) ) ) ) )
continue;

if( fGroup && !wch->leader && !IS_SET( wch->pcdata->flags, PCFLAG_GROUPWHO ) && ( !whogr_p || !whogr_p->indent ) )
continue;

nMatch++;

if( fShowHomepage && wch->pcdata->homepage && wch->pcdata->homepage[0] != '\0' )
snprintf( char_name, MAX_INPUT_LENGTH, "<A HREF=\"%s\">%s</A>", show_tilde( wch->pcdata->homepage ), wch->name );
else
mudstrlcpy( char_name, wch->name, MAX_INPUT_LENGTH );

snprintf( class_text, MAX_INPUT_LENGTH, "%s%2d %s", NOT_AUTHED( wch ) ? "N" : " ", wch->level,
class_table[wch->Class]->who_name );
Class = class_text;

switch ( wch->level )
{
default:
break;
case MAX_LEVEL - 0:
Class = "Supreme Entity";
break;
case MAX_LEVEL - 1:
Class = "Infinite";
break;
case MAX_LEVEL - 2:
Class = "Eternal";
break;
case MAX_LEVEL - 3:
Class = "Ancient";
break;
case MAX_LEVEL - 4:
Class = "Exalted God";
break;
case MAX_LEVEL - 5:
Class = "Ascendant God";
break;
case MAX_LEVEL - 6:
Class = "Greater God";
break;
case MAX_LEVEL - 7:
Class = "God";
break;
case MAX_LEVEL - 8:
Class = "Lesser God";
break;
case MAX_LEVEL - 9:
Class = "Immortal";
break;
case MAX_LEVEL - 10:
Class = "Demi God";
break;
case MAX_LEVEL - 11:
Class = "Savior";
break;
case MAX_LEVEL - 12:
Class = "Creator";
break;
case MAX_LEVEL - 13:
Class = "Acolyte";
break;
case MAX_LEVEL - 14:
Class = "Neophyte";
break;
case MAX_LEVEL - 15:
Class = "Avatar";
break;
}

if( !str_cmp( wch->name, sysdata.guild_overseer ) )
extra_title = " [Overseer of Guilds]";
else if( !str_cmp( wch->name, sysdata.guild_advisor ) )
extra_title = " [Advisor to Guilds]";
else
extra_title = "";

if( IS_RETIRED( wch ) )
Class = "Retired";
else if( IS_GUEST( wch ) )
Class = "Guest";
else if( wch->pcdata->clan
&& !str_cmp( wch->name, wch->pcdata->clan->leader ) && wch->pcdata->clan->leadrank[0] != '\0' )
Class = wch->pcdata->clan->leadrank;
else if( wch->pcdata->clan
&& !str_cmp( wch->name, wch->pcdata->clan->number1 ) && wch->pcdata->clan->onerank[0] != '\0' )
Class = wch->pcdata->clan->onerank;
else if( wch->pcdata->clan
&& !str_cmp( wch->name, wch->pcdata->clan->number2 ) && wch->pcdata->clan->tworank[0] != '\0' )
Class = wch->pcdata->clan->tworank;
else if( wch->pcdata->rank && wch->pcdata->rank[0] != '\0' )
Class = wch->pcdata->rank;

if( wch->pcdata->clan )
{
CLAN_DATA *pclan = wch->pcdata->clan;
if( pclan->clan_type == CLAN_GUILD )
mudstrlcpy( clan_display, " <", MAX_INPUT_LENGTH );
else
mudstrlcpy( clan_display, " (", MAX_INPUT_LENGTH );

if( pclan->clan_type == CLAN_ORDER )
{
if( !str_cmp( wch->name, pclan->deity ) )
mudstrlcat( clan_display, "Deity, Order of ", MAX_INPUT_LENGTH );
else if( !str_cmp( wch->name, pclan->leader ) )
mudstrlcat( clan_display, "Leader, Order of ", MAX_INPUT_LENGTH );
else if( !str_cmp( wch->name, pclan->number1 ) )
mudstrlcat( clan_display, "Number One, Order of ", MAX_INPUT_LENGTH );
else if( !str_cmp( wch->name, pclan->number2 ) )
mudstrlcat( clan_display, "Number Two, Order of ", MAX_INPUT_LENGTH );
else
mudstrlcat( clan_display, "Order of ", MAX_INPUT_LENGTH );
}
else if( pclan->clan_type == CLAN_GUILD )
{
if( !str_cmp( wch->name, pclan->leader ) )
mudstrlcat( clan_name, "Leader, ", MAX_INPUT_LENGTH );
if( !str_cmp( wch->name, pclan->number1 ) )
mudstrlcat( clan_name, "First, ", MAX_INPUT_LENGTH );
if( !str_cmp( wch->name, pclan->number2 ) )
mudstrlcat( clan_name, "Second, ", MAX_INPUT_LENGTH );
}
else
{
if( !str_cmp( wch->name, pclan->deity ) )
mudstrlcat( clan_display, "Deity of ", MAX_INPUT_LENGTH );
else if( !str_cmp (wch->name, pclan->leader ) )
mudstrlcat( clan_display, " of ", MAX_INPUT_LENGTH );
else if( !str_cmp( wch->name, pclan->number1 ) )
mudstrlcat( clan_display, "Number One of ", MAX_INPUT_LENGTH );
else if( !str_cmp( wch->name, pclan->number2 ) )
mudstrlcat( clan_display, "Number Two of ", MAX_INPUT_LENGTH );
}
mudstrlcat( clan_display, pclan->display, MAX_INPUT_LENGTH );
if( pclan->clan_type == CLAN_GUILD )
mudstrlcat( clan_display, ">", MAX_INPUT_LENGTH );
else
mudstrlcat( clan_display, ")", MAX_INPUT_LENGTH );
}
else
clan_display[0] = '\0';

if( wch->pcdata->council )
{
mudstrlcpy( council_name, " [", MAX_INPUT_LENGTH );
if( wch->pcdata->council->head2 == NULL )
{
if( !str_cmp( wch->name, wch->pcdata->council->head ) )
mudstrlcat( council_name, "Head of ", MAX_INPUT_LENGTH );
}
else
{
if( !str_cmp( wch->name, wch->pcdata->council->head ) || !str_cmp( wch->name, wch->pcdata->council->head2 ) )
mudstrlcat( council_name, "Co-Head of ", MAX_INPUT_LENGTH );
}
mudstrlcat( council_name, wch->pcdata->council_name, MAX_INPUT_LENGTH );
mudstrlcat( council_name, "]", MAX_INPUT_LENGTH );
}
else
council_name[0] = '\0';

if( xIS_SET( wch->act, PLR_WIZINVIS ) )
snprintf( invis_str, MAX_INPUT_LENGTH, "(%d) ", wch->pcdata->wizinvis );
else
invis_str[0] = '\0';
snprintf( buf, MAX_STRING_LENGTH, "%*s&B[&W%-15s&B]&G%-2s%s%s%s%s%s%s%s.%s%s%s%s\r\n",
( fGroup ? whogr->indent : 0 ), "",
Class,
invis_str,
( wch->desc && wch->desc->connected ) ? "&R[&WWRITING&R]&G " : "",
xIS_SET( wch->act, PLR_AFK ) ? "&R[&BA&WF&YK&R]&G " : "",
xIS_SET( wch->act, PLR_ATTACKER ) ? "&R(&WATTACKER&R)&G " : "",
xIS_SET( wch->act, PLR_KILLER ) ? "&R(&WKILLER&R)&G " : "",
xIS_SET( wch->act, PLR_THIEF ) ? "&R(&WTHIEF&R)&G " : "",
char_name, wch->pcdata->title, extra_title, clan_leadrank, clan_display, council_name );
/*
* This is where the old code would display the found player to the ch.
* What we do instead is put the found data into a linked list
*/

/*
* First make the structure.
*/
CREATE( cur_who, WHO_DATA, 1 );
cur_who->text = str_dup( buf );
if( wch->level > LEVEL_AVATAR && IS_IMMORTAL( wch ) )
cur_who->type = WT_IMM;
else if( fGroup )
if( wch->leader || ( whogr_p && whogr_p->indent ) )
cur_who->type = WT_GROUPED;
else
cur_who->type = WT_GROUPWHO;
else if( CAN_PKILL( wch ) )
cur_who->type = WT_DEADLY;
else
cur_who->type = WT_MORTAL;

/*
* Then put it into the appropriate list.
*/
switch ( cur_who->type )
{
case WT_MORTAL:
cur_who->next = first_mortal;
first_mortal = cur_who;
break;
case WT_DEADLY:
cur_who->next = first_deadly;
first_deadly = cur_who;
break;
case WT_GROUPED:
cur_who->next = first_grouped;
first_grouped = cur_who;
break;
case WT_GROUPWHO:
cur_who->next = first_groupwho;
first_groupwho = cur_who;
break;
case WT_IMM:
cur_who->next = first_imm;
first_imm = cur_who;
break;
}

}


/*
* Ok, now we have three separate linked lists and what remains is to
* * display the information and clean up.
*/
/*
* Two extras now for grouped and groupwho (wanting group). – Alty
*/

if( first_imm )
{
if( !ch )
fprintf( whoout, "%s",
"\r\n &W[ &YIMMORTALS &W]&G\r\n\r\n" );
else
send_to_pager( "\r\n &W[ &YIMMORTALS &W]&G\r\n\r\n", ch );
}

for( cur_who = first_imm; cur_who; cur_who = next_who )
{
if( !ch )
fprintf( whoout, "%s", cur_who->text );
else
send_to_pager( cur_who->text, ch );
next_who = cur_who->next;
DISPOSE( cur_who->text );
DISPOSE( cur_who );
}

if( first_deadly )
{
if( !ch )
fprintf( whoout, "%s",
"\r\n &W[ &RDEADLIES &W]&G\r\n\r\n" );
else
send_to_pager( "\r\n &W[ &RDEADLIES &W]&G\r\n\r\n", ch );
}

for( cur_who = first_deadly; cur_who; cur_who = next_who )
{
if( !ch )
fprintf( whoout, "%s", cur_who->text );
else
send_to_pager( cur_who->text, ch );
next_who = cur_who->next;
DISPOSE( cur_who->text );
DISPOSE( cur_who );
}

if( first_mortal )
{
if( !ch )
fprintf( whoout, "%s",
"\r\n &W[ &CPEACEFULS &W]&G\r\n\r\n" );
else
send_to_pager( "\r\n &W[ &CPEACEFULS &W]&G\r\n\r\n", ch );
}

for( cur_who = first_mortal; cur_who; cur_who = next_who )
{
if( !ch )
fprintf( whoout, "%s", cur_who->text );
else
send_to_pager( cur_who->text, ch );
next_who = cur_who->next;
DISPOSE( cur_who->text );
DISPOSE( cur_who );
}

if( !ch )
{
fprintf( whoout, "%d player%s.\r\n", nMatch, nMatch == 1 ? "" : "s" );
fclose( whoout );
return;
}

set_char_color( AT_YELLOW, ch );
ch_printf( ch, "%d player%s.\r\n", nMatch, nMatch == 1 ? "" : "s" );
return;
}


The clan_display was added in place of clan_name so that clan names can display colorized on the who list. Still no idea on how to get the custom leadrank, onerank, tworank inside the parentheses though.
03 Sep, 2012, thatjdguy wrote in the 3rd comment:
Votes: 0
After a couple of days of bashing my head against the wall and smoking over 2 packs of cigarettes I was finally able to fix it. I had to facepalm when it worked at how simple it was and how complex I was making it. In case anyone else may have the same issue, here's what I did.

else if( !str_cmp (wch->name, pclan->leader ) )
{
mudstrlcat( clan_leadrank, " ", MAX_INPUT_LENGTH );
mudstrlcat( clan_display, " of ", MAX_INPUT_LENGTH );
}


That was the original code I was using that gave me the problems. Here's what fixed it.

else if( !str_cmp( wch->name, pclan->leader ) )
{
mudstrlcat( clan_display, pclan->leadrank, MAX_INPUT_LENGTH );
mudstrlcat( clan_display, " of ", MAX_INPUT_LEGNTH );
}
0.0/3