Custom leader ranks on Who list

Posted by Rhayne on Sun 02 Sep 2012 12:18 AM — 9 posts, 28,474 views.

#0
I'm trying to make it so that leadrank, onerank, tworank show on do_who before the clan name. Ex: (I am the Leader of This Clan). While this seems like a relatively simple thing to do it has been giving me a headache for quite a while now.

What I've done so far:


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


Added the first mudstrlcat statement which should display the custom rank and:


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%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_onerank, clan_tworank , clan_display, council_name );


Added the leadrank, onerank, tworank to the output. To me it looks like it should be working, but when typing who it displays as: Player. I am the Leader( of This Clan).

I'm pretty sure the problem lies in the bottom code with the leadrank, onerank, etc. but I have no idea what to do to fix this. Any help is appreciated.
USA Global Moderator #1
I'm guessing the problem here is that the open parenthesis is in the wrong place? As there appear to be no literal parentheses in that snprintf line, I believe you are incorrect. You should inspect the values of clan_leadrank and clan_display before and after you run those mudstrlcats in the first part.

If parenthesis placement is not the issue, please elaborate on the problem you see.
Amended on Sun 02 Sep 2012 08:39 PM by Fiendish
#2
Not completely certain, but I don't think the problem lies in the parentheses placement. Here's the entire first section of code for a little better clarification.


      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_display, "Leader, ", MAX_INPUT_LENGTH );
            if( !str_cmp( wch->name, pclan->number1 ) )
               mudstrlcat( clan_display, "First, ", MAX_INPUT_LENGTH );
            if( !str_cmp( wch->name, pclan->number2 ) )
               mudstrlcat( clan_display, "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_leadrank, " ", MAX_INPUT_LENGTH );
	          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';
#3
Note that the only one I'm trying to replace in that code is in the Clans (not Orders or Guilds) as I'm sure if I can get it working there it will work for the others as well. I did notice that with the stock FUSS it places the custom leadranks in Class which makes it display as:

CustomRank Playername and title. (Leader of This Clan)

Seems like it would be a simple move but it's frustrating the hell out of me.
Amended on Mon 03 Sep 2012 06:25 AM by Rhayne
USA Global Moderator #4
Rhayne said:
Not completely certain, but I don't think the problem lies in the parentheses placement.

Then you need to clarify what your problem is, because what you said is...

Quote:
I'm trying to ... (I am the Leader of This Clan).

Quote:
but when typing who... I am the Leader( of This Clan).


Explain to me how that isn't just a parenthesis being out of place in your output.
Amended on Mon 03 Sep 2012 03:52 PM by Fiendish
#5
The reason I'm unsure that the problem lies with the parentheses placement is that I'm new to coding so I'm leaving open the possibility that I'm wrong in that. The reason that I don't think it's the parentheses placement is because


      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 )


comes before and contains


            else if( !str_cmp (wch->name, pclan->leader ) )
	       {
	          mudstrlcat( clan_leadrank, " ", MAX_INPUT_LENGTH );
	          mudstrlcat( clan_display, " of ", MAX_INPUT_LENGTH );
	       }
USA Global Moderator #6
Quote:
The reason that I don't think it's the parentheses placement is because

And yet the only apparent difference between what you said you want and what you said you're getting is that the "(" is in the wrong location. So I'm going to suggest again that you inspect the values of clan_leadrank and clan_display before and after you run those mudstrlcats. Maybe then the problem will become clear to you.
Amended on Mon 03 Sep 2012 07:08 PM by Fiendish
#7
I finally fixed it. Made me facepalm at how completely stupid I was being up until this point.


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


And I never moved the parentheses XD
USA Global Moderator #8
Quote:
And I never moved the parentheses XD

I'm glad you solved your problem. This means, though, that you didn't describe the problem accurately. :\