do_who

Posted by Ithildin on Thu 25 Mar 2004 04:51 AM — 46 posts, 133,087 views.

USA #0
I am completely redoing my who list. i searched this site for some help but it seemed like everyone else had the same problem and didn't say if they fixed it or not. so here i go as well. what i'm wanting it this:


[---------------------Immortals--------------------]
[Supreme Intity  ] Ithildin                        ]
[--------------------------------------------------]

[---------------------Mortals----------------------]
[ 10 Cleric      ] Player                          ]
[ 15 Ranger      ] Player                          ]
[ 28 Mage        ] Player                          ]
[--------------------------------------------------]
You see 3 players in the game.
The high players this reboot was 25.


here's what i have so far code wise:


void do_who( CHAR_DATA *ch, char *argument )
{
	char buf[MAX_STRING_LENGTH];
//	char clan_name[MAX_INPUT_LENGTH];
	char invis_str[MAX_INPUT_LENGTH];
	char char_name[MAX_INPUT_LENGTH];
	char class_text[MAX_INPUT_LENGTH];
	

	DESCRIPTOR_DATA *d;

	int iClass, iRace;
    int iLevelLower;
    int iLevelUpper;
    int nNumber;
    int nMatch;
    bool rgfClass[MAX_CLASS];
    bool rgfRace[MAX_RACE];
	bool fImmortalOnly;



	//CLAN_DATA *pClan = NULL;
	FILE *whoout = NULL;

	iLevelLower    = 0;
    iLevelUpper    = MAX_LEVEL;
	fImmortalOnly  = FALSE;


	WHO_DATA *cur_who = NULL;
    WHO_DATA *next_who = NULL;
    WHO_DATA *first_mortal = NULL;
    WHO_DATA *first_imm = NULL;

	for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
	rgfClass[iClass] = FALSE;
    for ( iRace = 0; iRace < MAX_RACE; iRace++ )
	rgfRace[iRace] = FALSE;




	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.\n\r", ch );
		return;
	    }
	}
	else
	{
	    if ( strlen(arg) < 3 )
	    {
		send_to_char( "Arguments must be longer than that.\n\r", ch );
		return;
	    }

	
    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;

	
	strcpy( char_name, wch->name );

	sprintf( class_text, "%s%2d %s", NOT_AUTHED(wch) ? "" : "", wch->level, class_table[wch->class]->who_name );
	class = class_text;
	/*sprintf( class_text, "&w[&W%s &c%s&w]", wch->level, class_table[wch->class]->who_name );
	class = class_text;*/
	switch ( wch->level )
	{
	default: break;
	case MAX_LEVEL -  0: class = "&W&cSu&Cp&Br&ceme Entity&Y&W";	break;
	case MAX_LEVEL -  1: class = "&W&CInfinite&Y&W      ";	break;
	case MAX_LEVEL -  2: class = "&W&pEternal&Y&W       ";	break;
	case MAX_LEVEL -  3: class = "&Y&WAncient       ";	break;
	case MAX_LEVEL -  4: class = "&Y&WExalted God   ";	break;
	case MAX_LEVEL -  5: class = "&Y&WAscendant God ";	break;
	case MAX_LEVEL -  6: class = "&Y&WGreater God   ";	break;
	case MAX_LEVEL -  7: class = "&Y&WGod           ";	break;
	case MAX_LEVEL -  8: class = "&Y&WLesser God    ";	break;
	case MAX_LEVEL -  9: class = "&Y&WImmortal      ";	break;
	case MAX_LEVEL - 10: class = "&Y&WDemi God      ";	break;
	case MAX_LEVEL - 11: class = "&Y&WSavior        ";	break;
	case MAX_LEVEL - 12: class = "&Y&WCreator       ";	break;
	case MAX_LEVEL - 13: class = "&Y&WAcolyte       ";	break;
	case MAX_LEVEL - 14: class = "&Y&WNeophyte      ";	break;
	case MAX_LEVEL - 15: class = "&Y&WAvatar        ";	break;
	}
  
		
		  

    if ( xIS_SET(wch->act, PLR_WIZINVIS) )
	  sprintf( invis_str, "(%d) ", wch->pcdata->wizinvis );
	else
	  invis_str[0] = '\0';
	

			
	CREATE( cur_who, WHO_DATA, 1 );
          cur_who->text = str_dup( buf );
          if ( wch->level > 100 && IS_IMMORTAL( wch ) )
            cur_who->type = WT_IMM;




	if ( first_imm )
    {
      if ( !ch )
        fprintf( whoout, "&c\n\r[--------------------------------[ &WIMMORTALS&c ]----------------------------]\n\r\n\r" );
      else
       send_to_pager( "&c\n\r[-------------------------------[ &WIMMORTALS&c ]----------------------------]\n\r\n\r", ch );
    }

    for ( cur_who = first_imm; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, 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, "&c\n\r[-------------------------------[ &WADVENTURERS&c ]-------------------------]\n\r\n\r" );
      else
       send_to_pager( "&c\n\r[-------------------------------[ &WADVENTURERS&c ]--------------------------]\n\r\n\r", ch );
    }  
		
	for ( cur_who = first_mortal; cur_who; cur_who = next_who )  
	{
      if ( !ch )
        fprintf( whoout, 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.\n\r", nMatch, nMatch == 1 ? "" : "s" );
	fclose( whoout );
	return;
    }
	
    send_to_pager( "&w\n\r[------------------------------------------------------------------------]\n\r\n\r", ch );
	set_char_color( AT_YELLOW, ch );
    ch_printf( ch, "%d player%s.\n\r", nMatch, nMatch == 1 ? "" : "s" );
    return;
	
}




Thanks
Ithildin






Amended on Thu 25 Mar 2004 04:54 AM by Ithildin
USA #1
i couldn't finish my last post without going over limit

here's my error

the only error i'm getting is this:

act_info.c: In function `do_who':
act_info.c:4409: error: syntax error at end of input
make[1]: *** [act_info.o] Error 1


at the end of my file is the error. i'm not sure why that's not working. any thoughts?
Australia Forum Administrator #2
You have too many { symbols in the function (or not enough } symbols). I haven't looked at which one it is, but you can use MUSHclient's "find matching brace" function (or the same thing in vi) to match your braces.
USA #3
ok, here's what i got. it all compiles fine, but slight problem. here's the code:


void do_who( CHAR_DATA *ch, char *argument )
{
    DESCRIPTOR_DATA *d;
    char             buf      [ MAX_STRING_LENGTH*3 ];
    char             buf2     [ MAX_STRING_LENGTH   ];
    int              iClass;
    int              iLevelLower;
    int              iLevelUpper;
    int              nNumber;
    int              nMatch;
    bool             rgfClass [ MAX_CLASS ];
    bool             fClassRestrict;
    bool             fImmortalOnly;
 
    /*
     * Set default arguments.
     */
    iLevelLower    = 0;
    iLevelUpper    = MAX_LEVEL; /*Used to be Max_level */
    fClassRestrict = FALSE;
    fImmortalOnly  = FALSE;
    for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
	rgfClass[iClass] = FALSE;

    /*
     * 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.\n\r", ch );
		return;
	    }
	}
	else
	{
	    int iClass;

	    if ( strlen( arg ) < 3 )
	    {
		send_to_char( "Classes must be longer than that.\n\r", ch );
		return;
	    }

	    /*
	     * Look for classes to turn on.
	     */
	    arg[3]    = '\0';
	    if ( !str_cmp( arg, "imm" ) )
	    {
		fImmortalOnly = TRUE;
	    }
	    else
	    {
		fClassRestrict = TRUE;
		for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
		{
		    if ( !str_cmp( arg, class_table[iClass]->who_name ) )
		    {
			rgfClass[iClass] = TRUE;
			break;
		    }
		}

		if ( iClass == MAX_CLASS )
		{
		    send_to_char( "That's not a class.\n\r", ch );
		    return;
		}
	    }
	}
    }

    /*
     * Now show matching chars.
     */
    nMatch = 0;
    buf[0] = '\0';
    for ( d = first_descriptor; d; d = d->next )
    {
	CHAR_DATA       *wch;
	char      const *class;

	wch   = ( d->original ) ? d->original : d->character;

	/*
	 * Check for match against restrictions.
	 * Don't use trust as that exposes trusted mortals.
	 */
	if ( d->connected != CON_PLAYING || !can_see( ch, wch ) )
	    continue;

	if (   wch->level < iLevelLower
	    || wch->level > iLevelUpper
	    || ( fImmortalOnly  && wch->level < LEVEL_HERO )
	    || ( fClassRestrict && !rgfClass[wch->class] ) )
	    continue;

	nMatch++;

	/*
	 * Figure out what to print for class.
	 */
	class = class_table[wch->class]->who_name;
	if ( wch->level >= (MAX_LEVEL -15) )
	    switch ( wch->level )
	{
	default: break;
	case MAX_LEVEL -  0: class = "&W&cSu&Cp&Br&ceme Entity&Y&W";	break;
	case MAX_LEVEL -  1: class = "&W&CInfinite&Y&W      ";	break;
	case MAX_LEVEL -  2: class = "&W&pEternal&Y&W       ";	break;
	case MAX_LEVEL -  3: class = "&Y&WAncient       ";	break;
	case MAX_LEVEL -  4: class = "&Y&WExalted God   ";	break;
	case MAX_LEVEL -  5: class = "&Y&WAscendant God ";	break;
	case MAX_LEVEL -  6: class = "&Y&WGreater God   ";	break;
	case MAX_LEVEL -  7: class = "&Y&WGod           ";	break;
	case MAX_LEVEL -  8: class = "&Y&WLesser God    ";	break;
	case MAX_LEVEL -  9: class = "&Y&WImmortal      ";	break;
	case MAX_LEVEL - 10: class = "&Y&WDemi God      ";	break;
	case MAX_LEVEL - 11: class = "&Y&WSavior        ";	break;
	case MAX_LEVEL - 12: class = "&Y&WCreator       ";	break;
	case MAX_LEVEL - 13: class = "&Y&WAcolyte       ";	break;
	case MAX_LEVEL - 14: class = "&Y&WNeophyte      ";	break;
	case MAX_LEVEL - 15: class = "&Y&WAvatar        ";	break;
	}

	/*
	 * Format it up.
	 */
	if ( wch->level >= (MAX_LEVEL - 15) )
	    
		send_to_pager( "&w\n\r[------------------------------------------------------------------------]\n\r", ch ),
		sprintf( buf + strlen( buf ), "&w[ %s       &w] %s%s%s&w\n\r",
		    class,
	  (wch->desc && wch->desc->connected) ? "" : "",
	   	    wch->name,
		    wch->pcdata->title );
	else
		send_to_pager( "&w\n\r[--------5----------------------------------------------------------------]\n\r", ch);
	
	if ( wch->level < (MAX_LEVEL - 15))
	
		send_to_pager( "&w\n\r[------------------------------------------------------------------------]\n\r", ch ),
		sprintf( buf + strlen( buf ), "&w[%2d %s %-10s&w] %s%s&w\n\r",
		    wch->level,
		    class,
	  (wch->desc && wch->desc->connected) ? "" : "",
	   	    wch->name,
		    wch->pcdata->title );
    

	else
	   send_to_pager( "&w\n\r[--------4----------------------------------------------------------------]\n\r", ch);
	

	}

    sprintf( buf2, "\n\r&w[------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r",
	    nMatch, nMatch == 1 ? "" : "s" );
    strcat( buf, buf2 );
    send_to_char( buf, ch );
    return;
}



and here's the output:

look at next message
Amended on Fri 26 Mar 2004 06:41 AM by Ithildin
USA #4
here's what i'm getting.




[--------4----------------------------------------------------------------]

[--------5----------------------------------------------------------------]

[------------------------------------------------------------------------]
[ Supreme Entity       ] Ithildin the head cheese
[35 Cleric           ] Gomer the High Priest of the Heavens

[------------------------------------------------------------------------]
You see 2 players in the game.



what i'm wanting is:



[---------------------Immortals--------------------]
[Supreme Intity  ] Ithildin                        ]
[--------------------------------------------------]

[---------------------Mortals----------------------]
[ 10 Cleric      ] Player                          ]
[ 15 Ranger      ] Player                          ]
[ 28 Mage        ] Player                          ]
[--------------------------------------------------]
You see 3 players in the game.
The high players this reboot was 25.


i'm not sure what's goin on here...i can see that i'm on the right path, just need to know where to put my lines.


Amended on Fri 26 Mar 2004 06:40 AM by Ithildin
Canada #5
I dunno fully, but I beleive the problem comes in that your having to paste the info in the order that the descriptors are read. In my version of do_who it uses linked lists, and sort what category the info goes into, and then displays all newbies, then all players, then all imms. You may need to do something similiar.
USA #6
yea, that's what the stock smaug who does. i've been looking at it, but i want to do away with all the if checks. i just want my immortals separate from my mortals. in the end i'm going to do away with all the deadly nice flags. i just want them all to be seen on one who list.
Canada #7
Oh, k, well the stock SWR do_who is alot more like that. It shows everyone thats on, assuming that they are not wizinvis. All you would have to do is remove a few of the extra checks, it has optional "just clan" or "just immortal", but it defaults to everyone. The immortal list could just be thrown onto the top of the list, above newbies and players, if thats the way you wanted it.
USA #8
yea, i'm using an envy who function right now. but all it shows is just the players on. no seperation or anything. so i've just kind of tried to add my own stuff. but to no avail. i just need some help on what 'im doin wrong.

Ithildin
USA #9
ok, i switched over to the stock smaugfuss who again. modified it and here's what i got:


if ( first_imm )
    {
      if ( !ch )
        fprintf( whoout, "&w\n\r                                  &WImmortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "&w\n\r                                  &WImmortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r", ch );
    }

    for ( cur_who = first_imm; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, cur_who->text );
      else
        send_to_pager( cur_who->text, ch );
      next_who = cur_who->next;
      DISPOSE( cur_who->text );
      DISPOSE( cur_who );
	  send_to_pager( "&w[----------------------------------------------------------------------------]\n\r",ch );
    } 


    if ( first_mortal )
	{
      if ( !ch )
        fprintf( whoout, "&w\n\r\n\r                                  &WMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "&w\n\r\n\r                                  &WMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r", ch );
    }

	 for ( cur_who = first_mortal; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, 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, "&w[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
	fclose( whoout );
	return;
    }

    set_char_color( AT_YELLOW, ch );

    ch_printf( ch, "&w[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
    return;
}


here's my output:
with 1 player

                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.
[----------------------------------------------------------------------------]
You see 1 player in the game.



with 2 players

                                 Immortals                                 
[----------------------------------------------------------------------------]
[Supreme Entity] Ithildin the head cheese.
[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.
[----------------------------------------------------------------------------]


when only one player is on i want it to show the whole who function like this.


                                 Immortals                                 
[----------------------------------------------------------------------------]

[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.
[----------------------------------------------------------------------------]


any thoughts? i'm getting closer...heh

Canada #10
Yeah, just change them to look something like this:
      if ( !ch )
        fprintf( whoout, "&w\n\r                                  &WImmortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "&w\n\r                                  &WImmortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r", ch );
	  if ( first_imm )
		send_to_pager( "\n\r", ch );		

    for ( cur_who = first_imm; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, cur_who->text );
      else
        send_to_pager( cur_who->text, ch );
      next_who = cur_who->next;
      DISPOSE( cur_who->text );
      DISPOSE( cur_who );
    } 
    send_to_pager( "&w[----------------------------------------------------------------------------]\n\r",ch );

      if ( !ch )
        fprintf( whoout, "&w\n\r\n\r                                  &WMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "&w\n\r\n\r                                  &WMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r", ch );
	  if ( first_mortal )
		send_to_pager( "\n\r", ch );

	 for ( cur_who = first_mortal; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, 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, "&w[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
	fclose( whoout );
	return;
    }

    set_char_color( AT_YELLOW, ch );

    ch_printf( ch, "&w[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
    return;
}
I beleive something like that is what your looking for. Dunno if it will work cleanly, but it should.
USA #11
what exactly does the

if ( first_mortal )
	{
      if ( !ch )
        fprintf( whoout, "&w\n\r\n\r                                  &WMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
     


do?

does it mean that if there is no character then show the fprint? it never seemed to do that when i didn't have another player on. here's my code now though.


send_to_pager( "&w\n\r                                  &WImmortals&w                                 \n\r", ch );
	send_to_pager( "&w[----------------------------------------------------------------------------]\n\r", ch );
    
	if ( first_imm )
    {
      if ( !ch )
        fprintf( whoout, "&w\n\r                                  &WImmortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "", ch );
	
	}


    for ( cur_who = first_imm; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, cur_who->text );
      else
        send_to_pager( cur_who->text, ch );
      next_who = cur_who->next;
      DISPOSE( cur_who->text );
      DISPOSE( cur_who );
	  } 
		send_to_pager( "\n\r&w[----------------------------------------------------------------------------]\n\r",ch );
    
		send_to_pager( "&w\n\r\n\r                                  &WMortals&w                                 \n\r", ch );
		send_to_pager( "&w[----------------------------------------------------------------------------]\n\r", ch );
    

    if ( first_mortal )
	{
      if ( !ch )
        fprintf( whoout, "&w\n\r\n\r                                  &rMortals&w                                 \n\r&w[----------------------------------------------------------------------------]\n\r" );
      else
       send_to_pager( "", ch );
	}

	 for ( cur_who = first_mortal; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, 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, "\n\r&b[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
	fclose( whoout );
	return;
    }

    set_char_color( AT_YELLOW, ch );

    ch_printf( ch, "\n\r&w[----------------------------------------------------------------------------]\n\r&BYou see &W%d &Bplayer%s in the game.\n\r", nMatch, nMatch == 1 ? "" : "s" );
    return;
}


here's my output:


                                 Immortals                                 
[----------------------------------------------------------------------------]
[Supreme Entity] Ithildin the head cheese.

[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.

[----------------------------------------------------------------------------]
You see 2 players in the game.


and with only 1 player:


                                 Immortals                                 
[----------------------------------------------------------------------------]

[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.

[----------------------------------------------------------------------------]
You see 1 player in the game.


ok, my first question. What does the if function above do? i changed the output colors to see if it would show up, but it never did.

second question will be in next message...
USA #12
second question. when no immortal is on and only players, it looks fine. it's how i want it. vice versa when only imms on and no mortals. i have an extra return in between the dashed lines like so..

 
                               Immortals                                 
[----------------------------------------------------------------------------]

[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.

[----------------------------------------------------------------------------]
You see 1 player in the game.


problem is the return after the mortal and after the imm once he's on. i can't really explain this any better. here's how i want it to look.

                                 Immortals                                 
[----------------------------------------------------------------------------]
[Supreme Entity] Ithildin the head cheese.
[----------------------------------------------------------------------------]


                                  Mortals                                 
[----------------------------------------------------------------------------]
[ 35 Cleric     ] Gomer the High Priest of the Heavens.
[----------------------------------------------------------------------------]
You see 2 players in the game.


is there any way to go about this? need more explanation?
USA #13
i just added the race into the who list. now it comes out with the race. i want the race and class to have color in it. is there anyway i can do this? has anyone tried it? so when you type who it shows

&w[ &W45 &YCleric&w] Gomer (&ODwarf&w)
&w[ &W23 &PMage &w] Camilla (&pDrow&w)

how would i put color in there? the classes and races would switch color based on what they were.

any suggestions?

Thanks,
Ithildin

USA #14
i put this in the who function, but it doesn't work.


switch ( wch->class )
	{
	default: break;
	case MAX_CLASS - 0: class =  "&PMage     ";	break;
	case MAX_CLASS - 1: class =  "&YCleric   ";	break;
	case MAX_CLASS - 2: class =  "&RThief    ";	break;
	case MAX_CLASS - 3: class =  "&bWarrior  ";	break;
	case MAX_CLASS - 4: class =  "&zVampire  ";	break;
	case MAX_CLASS - 5: class =  "&GDruid    ";	break;
	case MAX_CLASS - 6: class =  "&gRanger   ";	break;
	case MAX_CLASS - 7: class =  "&OAugurer  ";	break;
	case MAX_CLASS - 8: class =  "&WPaladin  "; break;
	
	}


am i at least on the right track?
Canada #15
That looks ok, whats wrong? Is it not compiling, not working properly, or just displaying the entirely wrong text.
USA #16
it compiled ok and everything, but nothing changed at all. i'm not in my room right now so i can't post any code. i will later though. my output was the same. i'll post my code later tonite.

weren't any errors or anything. not sure wha'ts up
USA #17
here's part of the code:



sprintf( class_text, "%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 = "&W&cSu&Cp&Br&ceme Entity&Y&W";	break;
	case MAX_LEVEL -  1: class = "&W&CInfinite&Y&W      ";	break;
	case MAX_LEVEL -  2: class = "&W&pEternal&Y&W       ";	break;
	case MAX_LEVEL -  3: class = "&Y&WAncient       ";	break;
	case MAX_LEVEL -  4: class = "&Y&WExalted God   ";	break;
	case MAX_LEVEL -  5: class = "&Y&WAscendant God ";	break;
	case MAX_LEVEL -  6: class = "&Y&WGreater God   ";	break;
	case MAX_LEVEL -  7: class = "&Y&WGod           ";	break;
	case MAX_LEVEL -  8: class = "&Y&WLesser God    ";	break;
	case MAX_LEVEL -  9: class = "&Y&WImmortal      ";	break;
	case MAX_LEVEL - 10: class = "&Y&WDemi God      ";	break;
	case MAX_LEVEL - 11: class = "&Y&WSavior        ";	break;
	case MAX_LEVEL - 12: class = "&Y&WCreator       ";	break;
	case MAX_LEVEL - 13: class = "&Y&WAcolyte       ";	break;
	case MAX_LEVEL - 14: class = "&Y&WNeophyte      ";	break;
	case MAX_LEVEL - 15: class = "&Y&WAvatar        ";	break;
	}

   switch ( wch->class )
	{
	default: break;
	case MAX_CLASS - 0: class =  "&PMage     ";	break;
	case MAX_CLASS - 1: class =  "&YCleric   ";	break;
	case MAX_CLASS - 2: class =  "&RThief    ";	break;
	case MAX_CLASS - 3: class =  "&bWarrior  ";	break;
	case MAX_CLASS - 4: class =  "&zVampire  ";	break;
	case MAX_CLASS - 5: class =  "&GDruid    ";	break;
	case MAX_CLASS - 6: class =  "&gRanger   ";	break;
	case MAX_CLASS - 7: class =  "&OAugurer  ";	break;
	case MAX_CLASS - 8: class =  "&WPaladin  "; break;
	
	}

and then...

if ( xIS_SET(wch->act, PLR_WIZINVIS) )
	  sprintf( invis_str, "(%d) ", wch->pcdata->wizinvis );
	else
	  invis_str[0] = '\0';
	sprintf( buf, "&w[&W%*s%-15s&w] %s%s%s%s%s%s%s%s.%s%s%s &w(&W%s&w)\n\r",
	  (fGroup ? whogr->indent : 0), "",
	  class,
	  invis_str,
          (wch->desc && wch->desc->connected) ? "" : "",
	  xIS_SET(wch->act, PLR_AFK) ? "" : "",
	  xIS_SET(wch->act, PLR_ATTACKER) ? "" : "",
	  xIS_SET(wch->act, PLR_KILLER) ? "" : "",
	  xIS_SET(wch->act, PLR_THIEF)  ? ""  : "",
	  char_name,
	  	  wch->pcdata->title,
          extra_title,
	  clan_name,
	  council_name,
	  get_race(wch));



how do i point that switch function to go into the class?
USA #18
well. i think i might try this sometime. something along these lines...

if (wch->class == Mage)
send_to_pager( "&Pmage ", ch);
elseif (wch-> == Thief)
send_to_pager( "&Rthief ", ch);

and go through the classes. i dont' have enough time to try it now, but would that work? also, is that the correct way to write it?

Australia Forum Administrator #19
I don't get this bit ...


switch ( wch->level )
	{
	default: break;
	case MAX_LEVEL -  0: class = "&W&cSu&Cp&Br&ceme Entity&Y&W";	break;
// blah blah
	case MAX_LEVEL - 15: class = "&Y&WAvatar        ";	break;
	}

   switch ( wch->class )
	{
	default: break;
	case MAX_CLASS - 0: class =  "&PMage     ";	break;
// blah blah
	case MAX_CLASS - 8: class =  "&WPaladin  "; break;
	
	}


Isn't the second switch statement going to overwrite the first? The first one sets "class" to something, and then the second one sets it to something else.

Also, I would personally choose a different word than "class" (like mud_class). If you ever convert to C++ "class" is a reserved word, as I found out when I tried to do exactly that.
USA #20
well, that's the thing, i'm just tryin to figure out how to do it. i just put that in there to see if it would work. but it doesn't. i tried putting the color codes into the class and race files, and that works, but when you start up, you can see the &*class at the get class thing. also, in the score on some of the classes, it only shows &ycleric and such. but on others it shows the actual colors. here's what an imm said on another mud, but i'm not sure how to do this:

Quote:


have some kind of a colored name associated to each race ahead of
time. This typically involves adding a new field to your race
data structure, something thats a character string. Then you
go in and just color each race you want to be a different color
by making that new variable/string be the colored race-name.
This might be kinda tricky however, since it involves modifying
how the game saves race files, and to make things worse, you might
have a hard time sorting pc races out from npc races. I think
initially, pc races are indeed seperate from npc ones, and since
only players show up on the who list, this makes things a little
simpler since you wouldn't have to worry about any of the 100 or
however many npc races that there are.
but anyway, after you've succeeded in adding the new string field
to your races, its a simple matter to make the who command call
on that string instead of the race-name string, you just swap it
in with the other one. Watch out for the length of some of those
colored names, they can shift the other parts of the who list
around a lot, and in some cases even crash the mud.


would be like this:


struct	race_type
{
    char 	race_name	[16];	/* Race name			*/
    char        race_name_color; <----added
    EXT_BV	affected;		/* Default affect bitvectors	*/
    sh_int	str_plus;		/* Str bonus/penalty		*/



then change the way that the code saves the races?
USA #21
here's what i could do with the output:


void write_class_file( int cl )
{
    FILE *fpout;
    char buf[MAX_STRING_LENGTH];
    char filename[MAX_INPUT_LENGTH];
    struct class_type *class = class_table[cl];
    int x, y;

    sprintf( filename, "%s%s.class", CLASSDIR, class->who_name );
    if ( (fpout=fopen(filename, "w")) == NULL )
    {
	sprintf( buf, "Cannot open: %s for writing", filename );
	bug( buf, 0 );
	return;
    }
    fprintf( fpout, "Name        %s~\n",	class->who_name		);
    fprintf( fpout, "Namecolor   %s~\n",    class->who_name     );


i'm not really sure how it would automatically know to do namecolor. i might need some help on that idea as well.

Thanks Nick.
Tyler
Canada #22
If your going to write to files, its not actually that hard. If the field for name is already race_name, and you want a colored version, just add like you had, "race_name_color" to the structure. Then you could change fwrite_race to

    fprintf( fpout, "Name        %s~\n",	class->race_name		);
    fprintf( fpout, "Namecolor   %s~\n",    class->race_name_color     );
Add the field to read it in, and maybe to initialize it to race_name if it is null in the end part of fread_race, and that should be all you need. I dunno if races are OLC in smaug, but either way you have to modify each PC races race_name_color to the one you want. Then in do_who:
get_race_color(wch));
Which would return race_name_color instead of race_name.
USA #23
ok, here's what i have:


fprintf( fpout, "Name        %s~\n",	race->race_name		);
	fprintf( fpout, "Namecolor   %s~\n",	race->race_name_color		);

and...

case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
		KEY( "Namecolor",	race_name_color,	fread_string( fp )	);
	    break;



it's giving me a warning:

warning: format argument is not a pointer (arg 3)

i'm not sure what that warning is meaning. it goes to the

fprintf( fpout, "Namecolor   %s~\n",	race->race_name_color		)


line of code. what am i doing wrong here.

Canada #24
How did you define it in your structure?
Australia Forum Administrator #25
You have it defined like this:


char race_name_color; <----added


Now you are printing it with %s which expects a pointer to a string, a couple of possibilities would be:


char * race_name_color;
char race_name_color [32];


But, not what you have. That is a single 8-byte field.

Do you mean:


int race_name_color;


If that is the case you need to print it with %i not %s.


USA #26
ok i switched the char race_name_color to the

char race_name_color [32];

and it compiled clean. is that what you were wanting me to do or do i want the int? i'm confused. sorry.

in the who function i added:

instead of

get_race(wch)

i put

get_race_name_color(wch)

and that didn't work.

i'm just kinda confused on this thing right now.
USA #27
here's some code:


in mud.h

struct	race_type
{
    char 	race_name	[16];	/* Race name			*/
    char	race_name_color [32];   /*Name for who*/
	EXT_BV	affected;		/* Default affect bitvectors	*/
    sh_int	str_plus;		/* Str bonus/penalty		*/

in table.c

fprintf( fpout, "Name        %s~\n",	race->race_name	    );
	fprintf( fpout, "Namecolor   %s~\n",	race->race_name_color		);
    fprintf( fpout, "Race        %d\n",		ra  			);

further down in load race

case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
		KEY( "Namecolor",	race_name_color,	fread_string( fp )	);
	    break;

act_info.c

do_who function

get_race(wch));




do you need anymore?
Canada #28
you need to make a copy of get_race, and change it to return race_name_color.
USA #29
with this one?

char *  get_race 	args( (CHAR_DATA *ch) );
char *  get_race_name_color   args( (CHAR_DATA *ch) );


or this one?

char *
get_race( CHAR_DATA *ch)
{
    if(  ch->race < MAX_PC_RACE  && ch->race >= 0)
        return (race_table[ch->race]->race_name);
    if ( ch->race < MAX_NPC_RACE && ch->race >= 0)
	return ( npc_race[ch->race] );
    return ("Unknown");
}

char *
get_race_name_color( CHAR_DATA *ch)
{
    if(  ch->race < MAX_PC_RACE  && ch->race >= 0)
        return (race_table[ch->race]->race_name_color);
    if ( ch->race < MAX_NPC_RACE && ch->race >= 0)
	return ( npc_race[ch->race] );
    return ("Unknown");
}



or both?

when i use both i get a clean compile, but here is my output:

[ 66 Cleric ] Gomer the great ()

i switched the who function to

get_race_name_color(wch)

so there's still a little something that i'm missing.
Amended on Thu 01 Apr 2004 05:13 AM by Ithildin
Canada #30
Yeah, that looks right, do you have race_name_color set differently than race_name?
USA #31
what i have in my code, is what i have. is there somewhere i else i need to put it?
Canada #32
I have meant, do you have the value of the field set differently? Like, did you modify setrace(?) so that you can make the race_name_color fiend different than that of race_name? Cause if its defaulting to the same one, that might be the problem.

For example, you can check your racial files, does it look like this?

Name Human~
Namecolor &RHuman&D~
USA #33
yep,

Name Dwarf~
Namecolor &ODwarf~
Race 2

that is in my .race file.


but i had modified that myself. i just went into the file and edited it.
Amended on Thu 01 Apr 2004 03:42 PM by Ithildin
Canada #34
Quote:
when i use both i get a clean compile, but here is my output:

[ 66 Cleric ] Gomer the great ()
Since we can't see the colors, I'm assuming that it is supposed to be in the ()? Earlier, you were talking about coloring class names, not races, so why you were adding race... I beleive things got confused somewhere, likely on my part. This should be the code your using?
if ( xIS_SET(wch->act, PLR_WIZINVIS) )
	  sprintf( invis_str, "(%d) ", wch->pcdata->wizinvis );
	else
	  invis_str[0] = '\0';
	sprintf( buf, "&w[&W%*s%-15s&w] %s%s%s%s%s%s%s%s.%s%s%s &w(&W%s&w)\n\r",
	  (fGroup ? whogr->indent : 0), "",
	  class,
	  invis_str,
          (wch->desc && wch->desc->connected) ? "" : "",
	  xIS_SET(wch->act, PLR_AFK) ? "" : "",
	  xIS_SET(wch->act, PLR_ATTACKER) ? "" : "",
	  xIS_SET(wch->act, PLR_KILLER) ? "" : "",
	  xIS_SET(wch->act, PLR_THIEF)  ? ""  : "",
	  char_name,
	  	  wch->pcdata->title,
          extra_title,
	  clan_name,
	  council_name,
	  get_race_name_color(wch));


Heh, so in all this I think you were trying to color class names, but we ended up coloring races, which is not what you wanted, yes? as to why the () has nothinh between then... I dunno? Can you confirm that race_name_color is being read in properly, I don't know the command, but... showrace? If it is, then there is something else wrong, but it makes it easier to narrow down.

As to the colored classes, I guess we have to start over again with that.
USA #35
well my first intentions were to do classes and races. we got switched up somewhere along the lines, so i just went with races, and then i would figure out the class from what i did with the races. and yes, i do have get_race_name_color(wch) in my do_who function.

i set the showrace to race_name_color, but it doesn't show anything. here is my output:


<   > showrace
Syntax: showrace  
 0>             1>             2>             3>             4>            
 5>             6>             7>             8>             9>            
10>            11>            12>            13>            14>            
15>            16>            17>            18>            19>            
 


so for some reason i'm still not getting anything. i have in my .race files all the namecolor's. so i'm just missing something somewhere.
Canada #36
Possible problem: can you paste fread_race? What I can see, its reading it into a variable called race_name_color, but is this variable ever being assigned into the structure? Why not read it directly into race_table[x]->race_name_color? That might be why it seems empty.
USA #37
i did a search for fread_race and didn't find anything. here's this. i think this might be what you are talkinga bout:


void write_race_file( int ra )
{
    FILE *fpout;
    char buf[MAX_STRING_LENGTH];
    char filename[MAX_INPUT_LENGTH];
    struct race_type *race = race_table[ra];
    int i;
    int x,y;

    if( !race->race_name)
    {
	sprintf( buf, "Race %d has null name, not writing .race file.", ra );
	bug( buf, 0 );
	return;
    }

    sprintf( filename, "%s%s.race", RACEDIR, race->race_name );
    if ( (fpout=fopen(filename, "w+")) == NULL )
    {
	sprintf( buf, "Cannot open: %s for writing", filename );
	bug( buf, 0 );
	return;
    }

    fprintf( fpout, "Name        %s~\n",	race->race_name	    );
	fprintf( fpout, "Namecolor   %s~\n",	race->race_name_color		);
    fprintf( fpout, "Race        %d\n",		ra  			);
    fprintf( fpout, "Classes     %d\n",		race->class_restriction );
    fprintf( fpout, "Str_Plus    %d\n",		race->str_plus		);
    fprintf( fpout, "Dex_Plus    %d\n",		race->dex_plus		);
    fprintf( fpout, "Wis_Plus    %d\n",		race->wis_plus		);
    fprintf( fpout, "Int_Plus    %d\n",		race->int_plus		);
    fprintf( fpout, "Con_Plus    %d\n",		race->con_plus		);
    fprintf( fpout, "Cha_Plus    %d\n",		race->cha_plus		);
    fprintf( fpout, "Lck_Plus    %d\n",		race->lck_plus		);
    fprintf( fpout, "Hit         %d\n",		race->hit		);
    fprintf( fpout, "Mana        %d\n",		race->mana		);
    fprintf( fpout, "Affected    %s\n",		print_bitvector(&race->affected)	);
    fprintf( fpout, "Resist      %d\n",		race->resist		);
    fprintf( fpout, "Suscept     %d\n",		race->suscept		);
    fprintf( fpout, "Language    %d\n",		race->language		);
    fprintf( fpout, "Align       %d\n",		race->alignment		);
    fprintf( fpout, "Min_Align  %d\n",		race->minalign		);
    fprintf( fpout, "Max_Align	%d\n",		race->maxalign		);
    fprintf( fpout, "AC_Plus    %d\n",		race->ac_plus		);
    fprintf( fpout, "Exp_Mult   %d\n",		race->exp_multiplier	); 
    fprintf( fpout, "Attacks    %s\n",		print_bitvector(&race->attacks)	);
    fprintf( fpout, "Defenses   %s\n",		print_bitvector(&race->defenses) );
    fprintf( fpout, "Height     %d\n",		race->height		);
    fprintf( fpout, "Weight     %d\n",		race->weight		);
    fprintf( fpout, "Hunger_Mod  %d\n",		race->hunger_mod	);
    fprintf( fpout, "Thirst_mod  %d\n",		race->thirst_mod	);
    fprintf( fpout, "Mana_Regen  %d\n",		race->mana_regen	);
    fprintf( fpout, "HP_Regen    %d\n",		race->hp_regen		);
    fprintf( fpout, "Race_Recall %d\n",		race->race_recall	);
    for ( i = 0; i < MAX_WHERE_NAME; i++ )
	fprintf( fpout, "WhereName  %s~\n",
		race->where_name );

    for ( x = 0; x < top_sn; x++ )
    {
	if ( !skill_table[x]->name || skill_table[x]->name[0] == '\0' )
	   break;
	if ( (y=skill_table[x]->race_level[ra]) < LEVEL_IMMORTAL )
	  fprintf( fpout, "Skill '%s' %d %d\n",
		skill_table[x]->name, y, skill_table[x]->race_adept[ra] );
    }
    fprintf( fpout, "End\n" );
    fclose( fpout );
}


if not i'll post some more. Thanks for your Help man
USA #38
i did a search for fread_race and didn't find anything. here's this. i think this might be what you are talkinga bout:


void write_race_file( int ra )
{
    FILE *fpout;
    char buf[MAX_STRING_LENGTH];
    char filename[MAX_INPUT_LENGTH];
    struct race_type *race = race_table[ra];
    int i;
    int x,y;

    if( !race->race_name)
    {
	sprintf( buf, "Race %d has null name, not writing .race file.", ra );
	bug( buf, 0 );
	return;
    }

    sprintf( filename, "%s%s.race", RACEDIR, race->race_name );
    if ( (fpout=fopen(filename, "w+")) == NULL )
    {
	sprintf( buf, "Cannot open: %s for writing", filename );
	bug( buf, 0 );
	return;
    }

    fprintf( fpout, "Name        %s~\n",	race->race_name	    );
	fprintf( fpout, "Namecolor   %s~\n",	race->race_name_color		);
    fprintf( fpout, "Race        %d\n",		ra  			);
    fprintf( fpout, "Classes     %d\n",		race->class_restriction );
    fprintf( fpout, "Str_Plus    %d\n",		race->str_plus		);
    fprintf( fpout, "Dex_Plus    %d\n",		race->dex_plus		);
    fprintf( fpout, "Wis_Plus    %d\n",		race->wis_plus		);
    fprintf( fpout, "Int_Plus    %d\n",		race->int_plus		);
    fprintf( fpout, "Con_Plus    %d\n",		race->con_plus		);
    fprintf( fpout, "Cha_Plus    %d\n",		race->cha_plus		);
    fprintf( fpout, "Lck_Plus    %d\n",		race->lck_plus		);
    fprintf( fpout, "Hit         %d\n",		race->hit		);
    fprintf( fpout, "Mana        %d\n",		race->mana		);
    fprintf( fpout, "Affected    %s\n",		print_bitvector(&race->affected)	);
    fprintf( fpout, "Resist      %d\n",		race->resist		);
    fprintf( fpout, "Suscept     %d\n",		race->suscept		);
    fprintf( fpout, "Language    %d\n",		race->language		);
    fprintf( fpout, "Align       %d\n",		race->alignment		);
    fprintf( fpout, "Min_Align  %d\n",		race->minalign		);
    fprintf( fpout, "Max_Align	%d\n",		race->maxalign		);
    fprintf( fpout, "AC_Plus    %d\n",		race->ac_plus		);
    fprintf( fpout, "Exp_Mult   %d\n",		race->exp_multiplier	); 
    fprintf( fpout, "Attacks    %s\n",		print_bitvector(&race->attacks)	);
    fprintf( fpout, "Defenses   %s\n",		print_bitvector(&race->defenses) );
    fprintf( fpout, "Height     %d\n",		race->height		);
    fprintf( fpout, "Weight     %d\n",		race->weight		);
    fprintf( fpout, "Hunger_Mod  %d\n",		race->hunger_mod	);
    fprintf( fpout, "Thirst_mod  %d\n",		race->thirst_mod	);
    fprintf( fpout, "Mana_Regen  %d\n",		race->mana_regen	);
    fprintf( fpout, "HP_Regen    %d\n",		race->hp_regen		);
    fprintf( fpout, "Race_Recall %d\n",		race->race_recall	);
    for ( i = 0; i < MAX_WHERE_NAME; i++ )
	fprintf( fpout, "WhereName  %s~\n",
		race->where_name );

    for ( x = 0; x < top_sn; x++ )
    {
	if ( !skill_table[x]->name || skill_table[x]->name[0] == '\0' )
	   break;
	if ( (y=skill_table[x]->race_level[ra]) < LEVEL_IMMORTAL )
	  fprintf( fpout, "Skill '%s' %d %d\n",
		skill_table[x]->name, y, skill_table[x]->race_adept[ra] );
    }
    fprintf( fpout, "End\n" );
    fclose( fpout );
}


if not i'll post some more.
Canada #39
Sorry, I'm not sure of the actual name of the funtion, I was refering to the one that reads in the data, where you have this:
case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
		KEY( "Namecolor",	race_name_color,	fread_string( fp )	);
	    break;
load_race, possibly?
USA #40
alrighty, here it is:



bool load_race_file( char *fname )
{
    char buf[MAX_STRING_LENGTH];
    char *word;
    char *race_name = NULL;
	char *race_name_color = NULL;
    bool fMatch;
    struct race_type *race;
    int ra = -1;
    FILE *fp;
    int i, wear=0;

    sprintf( buf, "%s%s", RACEDIR, fname );
    if ( ( fp = fopen( buf, "r" ) ) == NULL )
    {
	perror( buf );
	return FALSE;
    }

    CREATE( race, struct race_type, 1 );
    for(i=0;i<MAX_WHERE_NAME;i++)
       race->where_name = where_name;

    for ( ; ; )
    {
	word   = feof( fp ) ? "End" : fread_word( fp );
	fMatch = FALSE;

	switch ( UPPER(word[0]) )
	{
	case '*':
	    fMatch = TRUE;
	    fread_to_eol( fp );
	    break;

	case 'A':
	    KEY( "Align",	race->alignment,		fread_number( fp )	);
	    KEY( "AC_Plus",	race->ac_plus,		fread_number( fp )	);
	    KEY( "Affected",	race->affected,		fread_bitvector( fp )	);
	    KEY( "Attacks",	race->attacks,		fread_bitvector( fp )	);
	    break;

	case 'C':
	    KEY( "Con_Plus",	race->con_plus,		fread_number( fp )	);
	    KEY( "Cha_Plus",	race->cha_plus,		fread_number( fp )	);
	    KEY( "Classes",	race->class_restriction,		fread_number( fp )	);
	    break;


	case 'D':
	    KEY( "Dex_Plus",	race->dex_plus,		fread_number( fp )	);
	    KEY( "Defenses",	race->defenses,		fread_bitvector( fp )	);
	    break;

	case 'E':
            if ( !str_cmp( word, "End" ) )
            {
                fclose( fp );
                if ( ra < 0 || ra >= MAX_RACE )
                {
                    bug( "Load_race_file: Race (%s) bad/not found (%d)",
                        race->race_name ? race->race_name : "name not found", ra );
			  if( race_name )
  				STRFREE( race_name );
                    DISPOSE( race );
                    return FALSE;
                }
                race_table[ra] = race;
		    if( race_name )
		      STRFREE( race_name );
                return TRUE;
            }

	    KEY( "Exp_Mult",	race->exp_multiplier,	fread_number( fp )	);

	    break;


	case 'I':
	    KEY( "Int_Plus",	race->int_plus,		fread_number( fp )	);
	    break;

	case 'H':
	    KEY( "Height",	race->height,		fread_number( fp )	);
	    KEY( "Hit",		race->hit,		fread_number( fp )	);
	    KEY( "HP_Regen",	race->hp_regen,		fread_number( fp )	);
	    KEY( "Hunger_Mod",	race->hunger_mod,	fread_number( fp )	);
	    break;

	case 'L':
	    KEY( "Language",	race->language,		fread_number( fp )	);
	    KEY( "Lck_Plus",	race->lck_plus,		fread_number( fp )	);
	    break;


	case 'M':
	    KEY( "Mana",	race->mana,		fread_number( fp )	);
	    KEY( "Mana_Regen",	race->mana_regen,	fread_number( fp )	);
	    KEY( "Min_Align",	race->minalign,		fread_number( fp )	);
            race->minalign = -1000;
	    KEY( "Max_Align",	race->maxalign,		fread_number( fp )	);
            race->maxalign = -1000;
	    break;

	case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
		KEY( "Namecolor",	race_name_color,	fread_string( fp )	);
	    break;

	case 'R':
	    KEY( "Race",	ra,			fread_number( fp )	);
	    KEY( "Race_Recall",	race->race_recall,		fread_number( fp )	);
	    KEY( "Resist",	race->resist,		fread_number( fp )	);
	    
		break;

	case 'S':
	    KEY( "Str_Plus",	race->str_plus,		fread_number( fp )	);
	    KEY( "Suscept",	race->suscept,		fread_number( fp )	);
	    if ( !str_cmp( word, "Skill" ) )
	    {
		int sn, lev, adp;

		word = fread_word( fp );
		lev = fread_number( fp );
		adp = fread_number( fp );
		sn = skill_lookup( word );
		if ( ra < 0 || ra >= MAX_RACE )
		{
		    sprintf( buf, "load_race_file: Skill %s -- race bad/not found (%d)", word, ra );
		    bug( buf, 0 );
		}
		else
		if ( !IS_VALID_SN(sn) )
		{
		    sprintf( buf, "load_race_file: Skill %s unknown", word);
		    bug( buf, 0 );
		}
		else
		{
		    skill_table[sn]->race_level[ra] = lev;
		    skill_table[sn]->race_adept[ra] = adp;
		}
		fMatch = TRUE;
		break;
            }
	    break;

	case 'T':
	    KEY( "Thirst_Mod",	race->thirst_mod,	fread_number( fp )	);
	    break;

	case 'W':
	    KEY( "Weight",	race->weight,		fread_number( fp )	);
	    KEY( "Wis_Plus",	race->wis_plus,		fread_number( fp )	);
	    if ( !str_cmp( word, "WhereName" ) )
	    {
		if ( ra < 0 || ra >= MAX_RACE )
		{
		    char *tmp;

		    sprintf( buf, "load_race_file: Title -- race bad/not found (%d)", ra );
		    bug( buf, 0 );
		    tmp = fread_string_nohash( fp );
		    DISPOSE( tmp );
		    tmp = fread_string_nohash( fp );
		    DISPOSE( tmp );
		}
		else
		if ( wear < MAX_WHERE_NAME )
		{
		    race->where_name[wear] = fread_string_nohash( fp );
		    ++wear;
		}
		else
		    bug( "load_race_file: Too many where_names" );
		fMatch = TRUE;
		break;
	    }
	    break;
	}

        if ( race_name != NULL) 
             sprintf(race->race_name,"%-.16s",race_name);
		

	if ( !fMatch )
	{
            sprintf( buf, "load_race_file: no match: %s", word );
	    bug( buf, 0 );
	}
    }
    return FALSE;
}



Canada #41
The easiest way to be to change the N case to look like this:
	case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
		KEY( "Namecolor",	race->race_name_color,	fread_string( fp )	);
	    break;
Try that.
USA #42
when i try that, i get this error.



tables.c: In function `load_race_file':
tables.c:1777: error: incompatible types in assignment
tables.c:1676: warning: unused variable `race_name_color'



so my

char *race_name_color

is a warning because of that.

how do i make that compatible?
Canada #43
Bah, I shouldn't try and help when I'm that tired, sorry. I guess you can try something like this:
bool load_race_file( char *fname )
{
    char buf[MAX_STRING_LENGTH];
    char *word;
    char *race_name = NULL;
    char *race_name_color = NULL;
    bool fMatch;
    struct race_type *race;
    int ra = -1;
    FILE *fp;
    int i, wear=0;

    sprintf( buf, "%s%s", RACEDIR, fname );
    if ( ( fp = fopen( buf, "r" ) ) == NULL )
    {
	perror( buf );
	return FALSE;
    }

    CREATE( race, struct race_type, 1 );
    for(i=0;i<MAX_WHERE_NAME;i++)
       race->where_name = where_name;

    for ( ; ; )
    {
	word   = feof( fp ) ? "End" : fread_word( fp );
	fMatch = FALSE;

	switch ( UPPER(word[0]) )
	{
	case '*':
	    fMatch = TRUE;
	    fread_to_eol( fp );
	    break;

	case 'A':
	    KEY( "Align",	race->alignment,		fread_number( fp )	);
	    KEY( "AC_Plus",	race->ac_plus,		fread_number( fp )	);
	    KEY( "Affected",	race->affected,		fread_bitvector( fp )	);
	    KEY( "Attacks",	race->attacks,		fread_bitvector( fp )	);
	    break;

	case 'C':
	    KEY( "Con_Plus",	race->con_plus,		fread_number( fp )	);
	    KEY( "Cha_Plus",	race->cha_plus,		fread_number( fp )	);
	    KEY( "Classes",	race->class_restriction,		fread_number( fp )	);
	    break;


	case 'D':
	    KEY( "Dex_Plus",	race->dex_plus,		fread_number( fp )	);
	    KEY( "Defenses",	race->defenses,		fread_bitvector( fp )	);
	    break;

	case 'E':
            if ( !str_cmp( word, "End" ) )
            {
                fclose( fp );
                if ( ra < 0 || ra >= MAX_RACE )
                {
                    bug( "Load_race_file: Race (%s) bad/not found (%d)",
                        race->race_name ? race->race_name : "name not found", ra );
			  if( race_name )
  				STRFREE( race_name );
			  if( race_name_color )
  				STRFREE( race_name_color );
                    DISPOSE( race );
                    return FALSE;
                }
                race_table[ra] = race;
		    if( race_name )
		      STRFREE( race_name );
		    if( race_name_color )
		      STRFREE( race_name_color );
                return TRUE;
            }

	    KEY( "Exp_Mult",	race->exp_multiplier,	fread_number( fp )	);

	    break;


	case 'I':
	    KEY( "Int_Plus",	race->int_plus,		fread_number( fp )	);
	    break;

	case 'H':
	    KEY( "Height",	race->height,		fread_number( fp )	);
	    KEY( "Hit",		race->hit,		fread_number( fp )	);
	    KEY( "HP_Regen",	race->hp_regen,		fread_number( fp )	);
	    KEY( "Hunger_Mod",	race->hunger_mod,	fread_number( fp )	);
	    break;

	case 'L':
	    KEY( "Language",	race->language,		fread_number( fp )	);
	    KEY( "Lck_Plus",	race->lck_plus,		fread_number( fp )	);
	    break;


	case 'M':
	    KEY( "Mana",	race->mana,		fread_number( fp )	);
	    KEY( "Mana_Regen",	race->mana_regen,	fread_number( fp )	);
	    KEY( "Min_Align",	race->minalign,		fread_number( fp )	);
            race->minalign = -1000;
	    KEY( "Max_Align",	race->maxalign,		fread_number( fp )	);
            race->maxalign = -1000;
	    break;

	case 'N':
	    KEY( "Name",	race_name,	fread_string( fp )	);
	    KEY( "Namecolor",	race_name_color,	fread_string( fp )	);
	    break;

	case 'R':
	    KEY( "Race",	ra,			fread_number( fp )	);
	    KEY( "Race_Recall",	race->race_recall,		fread_number( fp )	);
	    KEY( "Resist",	race->resist,		fread_number( fp )	);
	    
		break;

	case 'S':
	    KEY( "Str_Plus",	race->str_plus,		fread_number( fp )	);
	    KEY( "Suscept",	race->suscept,		fread_number( fp )	);
	    if ( !str_cmp( word, "Skill" ) )
	    {
		int sn, lev, adp;

		word = fread_word( fp );
		lev = fread_number( fp );
		adp = fread_number( fp );
		sn = skill_lookup( word );
		if ( ra < 0 || ra >= MAX_RACE )
		{
		    sprintf( buf, "load_race_file: Skill %s -- race bad/not found (%d)", word, ra );
		    bug( buf, 0 );
		}
		else
		if ( !IS_VALID_SN(sn) )
		{
		    sprintf( buf, "load_race_file: Skill %s unknown", word);
		    bug( buf, 0 );
		}
		else
		{
		    skill_table[sn]->race_level[ra] = lev;
		    skill_table[sn]->race_adept[ra] = adp;
		}
		fMatch = TRUE;
		break;
            }
	    break;

	case 'T':
	    KEY( "Thirst_Mod",	race->thirst_mod,	fread_number( fp )	);
	    break;

	case 'W':
	    KEY( "Weight",	race->weight,		fread_number( fp )	);
	    KEY( "Wis_Plus",	race->wis_plus,		fread_number( fp )	);
	    if ( !str_cmp( word, "WhereName" ) )
	    {
		if ( ra < 0 || ra >= MAX_RACE )
		{
		    char *tmp;

		    sprintf( buf, "load_race_file: Title -- race bad/not found (%d)", ra );
		    bug( buf, 0 );
		    tmp = fread_string_nohash( fp );
		    DISPOSE( tmp );
		    tmp = fread_string_nohash( fp );
		    DISPOSE( tmp );
		}
		else
		if ( wear < MAX_WHERE_NAME )
		{
		    race->where_name[wear] = fread_string_nohash( fp );
		    ++wear;
		}
		else
		    bug( "load_race_file: Too many where_names" );
		fMatch = TRUE;
		break;
	    }
	    break;
	}

        if ( race_name != NULL) 
             sprintf(race->race_name,"%-.16s",race_name);
        if ( race_name_color != NULL) 
             sprintf(race->race_name_color,"%-.16s",race_name_color);		

	if ( !fMatch )
	{
            sprintf( buf, "load_race_file: no match: %s", word );
	    bug( buf, 0 );
	}
    }
    return FALSE;
}
USA #44
you are the man! it works great now.

...now i gotta try and find out the class one. i might be back for some help on that. i'll try and figure it out first though.

thanks so much.


______________________________

Just got color in my who list...wo0t. you rock greven.
Amended on Fri 02 Apr 2004 03:05 AM by Ithildin
Australia Forum Administrator #45
Your posts are coming out half in italics because you have lines like this in them:

race->where_name[i]

If you are using forum codes on this forum, then you should "escape" things like [i] which indicate italics.

Thus it should be:

race->where_name\[i\]

A quick way of doing that is to use MUSHclient's notepad which has a "quote forum codes" feature. Failing that, use a text editor to change:

\ to \\
[ to \[
] to \]

... and you are done!