Spacing issues [FIXED]

Posted by Findecano_Elendil on Thu 09 Jul 2009 06:37 PM — 5 posts, 22,276 views.

United Kingdom #0
Ok this ones abit weird as its not an issue what is loading etc, more of a display issue I cant seem to put my thing on...

Basically my mud has a 'family name' system so that people can become part of a family and have a few other features too... however.

I have an issue with the display of do_who and show_char_to_char_0

The problem lies that it seems to be joining the characters name with their family name for example it displayers this:
(Immortal) FindecanoElendil, the Dreamer is here before you.

Now, this works fine if I just set the players family name, so if I typed 'mset findecano family Elendil'
It will then display correctly.. so it seems to only happen when the character has closed its connection to the mud. And then reloaded on the mud... so reading the data from the pfile.

I guess, im just curious if anyone has had this problem before as I just cant put my finger on what could be causing it. Cheers for any help, its probably just me being dumb =)
USA #1
Can you show us the lines that append family name and name into a string?
United Kingdom #2
Yep, I can do that =)

act_info.c under 'show_char_to_char_0'

   if ( victim->pcdata->family && !IS_NPC ( victim) )
      mudstrlcat( buf, victim->pcdata->family, MAX_STRING_LENGTH );
  
   if( !IS_NPC( victim ) && !xIS_SET( ch->act, PLR_BRIEF ) )
      mudstrlcat( buf, victim->pcdata->title, MAX_STRING_LENGTH );


This prints out the family name before the title..

and then act_info.c under 'do_who'

      snprintf( buf, MAX_STRING_LENGTH, "%*s%-15s%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 ) ? "&z[&WWRITING&w]&D " : "",
                xIS_SET( wch->act, PLR_AFK ) ? "&z[&WAFK&z]&D " : "",
                xIS_SET( wch->act, PLR_ATTACKER ) ? "&g(&GATTACKER&g)&D " : "",
                xIS_SET( wch->act, PLR_KILLER ) ? "&r(&RKILLER&r)&D " : "",
                xIS_SET( wch->act, PLR_THIEF ) ? "&g(&GTHIEF&g)&D " : "",
                char_name, wch->pcdata->family, wch->pcdata->title, extra_title, clan_name, council_name );


Now I can cheat... and put a space in there, however it doesn't resolve the under-lying problem... because when the family name is created, the people then have two spaces instead.

Family name is pretty much just a basic char inside pc_data, which is similar to the 'title' I guess... however, there seems to be something i might have missed? I'm not to sure.

Amended on Thu 09 Jul 2009 10:48 PM by Findecano_Elendil
Australia Forum Administrator #3
Your basic problem is that you are not saving (or reading back in perhaps) what the variable initially had in it. So if you make a new family name the variable wch->pcdata->family contains "Elendil " (or " Elendil" perhaps?), but when written to disk the space is dropped. Or perhaps, the space is on the pfile, but it is dropped when reading back in. Inspecting the pfile should show you which.

I think your easiest solution is to make the wch->pcdata->family contain the family name without spaces (for example, you may want to put a comma after it). Then just amend your displays to insert the space where required. This probably requires simply removing extra leading or trailing spaces on the command they use to set their family name.
United Kingdom #4
Cheers Nick & Zeno,
Some reason I couldn't just put my finger on it... ended up having to add this to save.c

if( !strcmp( word, "Family" ) )   
{
   ch->pcdata->family = fread_string( fp );
   if( isalpha( ch->pcdata->family[0] ) || isdigit( ch->pcdata->family[0] ) )
   {
       snprintf( buf, MAX_STRING_LENGTH, " %s", ch->pcdata->family );
          if( ch->pcdata->family )
             STRFREE( ch->pcdata->family );
          ch->pcdata->family = STRALLOC( buf );
    }
             fMatch = TRUE;
             break;
}