23 Sep, 2008, gorex wrote in the 1st comment:
Votes: 0
So I'm attempting to switch "IMP" ,"CRE" , "DEM" , blah blah so it appears in LEVEL under do_who instead of replacing the class. I understand how to remove it from class, but I'm having problems switching it under LEVEL.

The error I receive says I'm trying to put a CHAR into an INT. I attempted atoi? Am I on the right track, any suggestions?

Please help!

Thanks!
24 Sep, 2008, Kline wrote in the 2nd comment:
Votes: 0
Hi It'd be helpful to at a minimum know what code base you're working from, or even better, a snippet of the specific problem area.
24 Sep, 2008, gorex wrote in the 3rd comment:
Votes: 0
Sorry, new to this. Rom code base.


This is where it switches to the CLASS
#
class = class_table[wch->class].who_name;
#
switch ( wch->level )
#
{
#
default: break;
#
{
#
case MAX_LEVEL - 0 : class = "IMP"; break;
#
case MAX_LEVEL - 1 : class = "CRE"; break;
#
case MAX_LEVEL - 2 : class = "SUP"; break;
#
case MAX_LEVEL - 3 : class = "DEI"; break;
#
case MAX_LEVEL - 4 : class = "GOD"; break;
#
case MAX_LEVEL - 5 : class = "IMM"; break;
#
case MAX_LEVEL - 6 : class = "DEM"; break;
#
case MAX_LEVEL - 7 : class = "ANG"; break;
#
case MAX_LEVEL - 8 : class = "AVA"; break;
#
case MAX_LEVEL - 9 : class = "BLD"; break;
#
}
#
}

I
24 Sep, 2008, Lobotomy wrote in the 4th comment:
Votes: 0
What variable type do you have "class" defined as?

Edit: It seems my browser had a seizure. Out of curiosity, how do I go about deleting a blank post?
24 Sep, 2008, Fizban wrote in the 5th comment:
Votes: 0
Stock ROM? I'm going to assume so and pull its do_who and edit it to do what you want:

void do_who( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char rank[3];
BUFFER *output;
DESCRIPTOR_DATA *d;
int iClass;
int iRace;
int iClan;
int iLevelLower;
int iLevelUpper;
int nNumber;
int nMatch;
bool rgfClass[MAX_CLASS];
bool rgfRace[MAX_PC_RACE];
bool rgfClan[MAX_CLAN];
bool fClassRestrict = FALSE;
bool fClanRestrict = FALSE;
bool fClan = FALSE;
bool fRaceRestrict = FALSE;
bool fImmortalOnly = FALSE;

/*
* Set default arguments.
*/
iLevelLower = 0;
iLevelUpper = MAX_LEVEL;
for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
rgfClass[iClass] = FALSE;
for ( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
rgfRace[iRace] = FALSE;
for (iClan = 0; iClan < MAX_CLAN; iClan++)
rgfClan[iClan] = 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
{

/*
* Look for classes to turn on.
*/
if (!str_prefix(arg,"immortals"))
{
fImmortalOnly = TRUE;
}
else
{
iClass = class_lookup(arg);
if (iClass == -1)
{
iRace = race_lookup(arg);

if (iRace == 0 || iRace >= MAX_PC_RACE)
{
if (!str_prefix(arg,"clan"))
fClan = TRUE;
else
{
iClan = clan_lookup(arg);
if (iClan)
{
fClanRestrict = TRUE;
rgfClan[iClan] = TRUE;
}
else
{
send_to_char(
"That's not a valid race, class, or clan.\n\r",
ch);
return;
}
}
}
else
{
fRaceRestrict = TRUE;
rgfRace[iRace] = TRUE;
}
}
else
{
fClassRestrict = TRUE;
rgfClass[iClass] = TRUE;
}
}
}
}

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

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

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

if (!can_see(ch,wch))
continue;

if ( wch->level < iLevelLower
|| wch->level > iLevelUpper
|| ( fImmortalOnly && wch->level < LEVEL_IMMORTAL )
|| ( fClassRestrict && !rgfClass[wch->class] )
|| ( fRaceRestrict && !rgfRace[wch->race])
|| ( fClan && !is_clan(wch))
|| ( fClanRestrict && !rgfClan[wch->clan]))
continue;

nMatch++;

/*
* Figure out what to print for level.
*/
switch (wch->level) {
case MAX_LEVEL - 0 : rank = "IMP"; break;
case MAX_LEVEL - 1 : rank = "CRE"; break;
case MAX_LEVEL - 2 : rank = "SUP"; break;
case MAX_LEVEL - 3 : rank = "DEI"; break;
case MAX_LEVEL - 4 : rank = "GOD"; break;
case MAX_LEVEL - 5 : rank = "IMM"; break;
case MAX_LEVEL - 6 : rank = "DEM"; break;
case MAX_LEVEL - 7 : rank = "ANG"; break;
case MAX_LEVEL - 8 : rank = "AVA"; break;
case MAX_LEVEL - 9 : rank = "BLD"; break;
default: rank = strdup(wch->level); break;
}
class = class_table[wch->class].who_name;

/*
* Format it up.
*/
sprintf( buf, "[%2d %6s %s] %s%s%s%s%s%s%s%s\n\r",
rank,
wch->race < MAX_PC_RACE ? pc_race_table[wch->race].who_name
: " ",
class,
wch->incog_level >= LEVEL_HERO ? "(Incog) " : "",
wch->invis_level >= LEVEL_HERO ? "(Wizi) " : "",
clan_table[wch->clan].who_name,
IS_SET(wch->comm, COMM_AFK) ? "[AFK] " : "",
IS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
IS_SET(wch->act, PLR_THIEF) ? "(THIEF) " : "",
wch->name,
IS_NPC(wch) ? "" : wch->pcdata->title );
add_buf(output,buf);
}

sprintf( buf2, "\n\rPlayers found: %d\n\r", nMatch );
add_buf(output,buf2);
page_to_char( buf_string(output), ch );
free_buf(output);
return;
}



Warning: Mailer Code, this was never tested or even compiled.
24 Sep, 2008, gorex wrote in the 6th comment:
Votes: 0
Error: incompatible types in assignment
24 Sep, 2008, Fizban wrote in the 7th comment:
Votes: 0
What line?

default: rank = strdup(wch->level); break;

?

if so try

default: sprintf(rank, "%d", wch->level); break;
24 Sep, 2008, gorex wrote in the 8th comment:
Votes: 0
case: MAX_LEVEL - 0 : rank is getting the first error.
The rest all get errors.
24 Sep, 2008, Fizban wrote in the 9th comment:
Votes: 0
err, that's odd….


rank is defined as:

char rank[3];

that should have no issue containing "IMP"
24 Sep, 2008, gorex wrote in the 10th comment:
Votes: 0
is it because level is expecting an int?
24 Sep, 2008, Asylumius wrote in the 11th comment:
Votes: 0
gorex said:
case: MAX_LEVEL - 0 : rank is getting the first error.
The rest all get errors.


The semicolon after the word 'case' isn't correct. Maybe you want:
case MAX_LEVEL - 0:
24 Sep, 2008, gorex wrote in the 12th comment:
Votes: 0
it's coded like that, when I retyped, that was my error.
24 Sep, 2008, Fizban wrote in the 13th comment:
Votes: 0
Are the strings you're assigning still all three characters or less or did you pick new strings? ie. "IMP" "DEI" etc were all three characters so to save space I set rank to only accept three characters it might be choking if you're assigning something longer than three characters to it.
24 Sep, 2008, gorex wrote in the 14th comment:
Votes: 0
all 3. IMP, CRE, SUP, DEI, GOD, IMM, DEM, ANG, AVA, and BLD
24 Sep, 2008, Asylumius wrote in the 15th comment:
Votes: 0
Post the entire function again, as it reads now? (You may want to post it to the Pastebin and link to it from the post, since it's long and it doesn't get syntax highlighted here.)
24 Sep, 2008, gorex wrote in the 16th comment:
Votes: 0
It's exactly has Fizban has it posted.
24 Sep, 2008, Fizban wrote in the 17th comment:
Votes: 0
Here is what I wrote before with one change, I realized in the sprintf I didn't change the %2d to %3s but that is below his error and should be unrelated.
24 Sep, 2008, Skol wrote in the 18th comment:
Votes: 0
Vaporize (or comment out /* like this */:
/*
* Figure out what to print for level.
*/
switch (wch->level)
{
case MAX_LEVEL - 0 : rank = "IMP"; break;
case MAX_LEVEL - 1 : rank = "CRE"; break;
case MAX_LEVEL - 2 : rank = "SUP"; break;
case MAX_LEVEL - 3 : rank = "DEI"; break;
case MAX_LEVEL - 4 : rank = "GOD"; break;
case MAX_LEVEL - 5 : rank = "IMM"; break;
case MAX_LEVEL - 6 : rank = "DEM"; break;
case MAX_LEVEL - 7 : rank = "ANG"; break;
case MAX_LEVEL - 8 : rank = "AVA"; break;
case MAX_LEVEL - 9 : rank = "BLD"; break;
default: rank = strdup(wch->level); break;
}


(yeah, that ENTIRE thing)

and also
rank = strdup(wch->level);

See, if you simply want level, you can later call it just
as %d (or %-3d) (with the corresponding being wch->level).

// so later instead of this:
sprintf( buf, "[%3d %6s %s] %s%s%s%s%s%s%s%s\n\r",
rank,
wch->race < MAX_PC_RACE ? pc_race_table[wch->race].who_name
: " ",
class,
wch->incog_level >= LEVEL_HERO ? "(Incog) " : "",
wch->invis_level >= LEVEL_HERO ? "(Wizi) " : "",
clan_table[wch->clan].who_name,
IS_SET(wch->comm, COMM_AFK) ? "[AFK] " : "",
IS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
IS_SET(wch->act, PLR_THIEF) ? "(THIEF) " : "",
wch->name,
IS_NPC(wch) ? "" : wch->pcdata->title );


You'd have:
sprintf( buf, "[%-3d %6s %s] %s%s%s%s%s%s%s%s\n\r",
wch->level,
wch->race < MAX_PC_RACE ? pc_race_table[wch->race].who_name
: " ",
class,
wch->incog_level >= LEVEL_HERO ? "(Incog) " : "",
wch->invis_level >= LEVEL_HERO ? "(Wizi) " : "",
clan_table[wch->clan].who_name,
IS_SET(wch->comm, COMM_AFK) ? "[AFK] " : "",
IS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
IS_SET(wch->act, PLR_THIEF) ? "(THIEF) " : "",
wch->name,
IS_NPC(wch) ? "" : wch->pcdata->title );



For the Class part?

First, change that char const class crap to:
char class[32]; // or bigger than your longest class name etc.

Then THIS part:
class = class_table[wch->class].who_name;

becomes
sprintf (class, "%32s", class_table[wch->class].who_name != NULL 
class_table[wch->class].who_name : "Unknown");
// the second part is simply a safety

OR
sprintf (class, "%32s", class_table[wch->class].who_name); // that works also


Comment out /* these around */
switch ( wch->level )
{
default: break;
case MAX_LEVEL - 0 : class = "IMP"; break;
case MAX_LEVEL - 1 : class = "CRE"; break;
case MAX_LEVEL - 2 : class = "SUP"; break;
case MAX_LEVEL - 3 : class = "DEI"; break;
case MAX_LEVEL - 4 : class = "GOD"; break;
case MAX_LEVEL - 5 : class = "IMM"; break;
case MAX_LEVEL - 6 : class = "DEM"; break;
case MAX_LEVEL - 7 : class = "ANG"; break;
case MAX_LEVEL - 8 : class = "AVA"; break;
case MAX_LEVEL - 9 : class = "BLD"; break;
}
}


Anyway, let me know if that helps, if not, post your _entire_ do_who function and I'll post the fixed one.
24 Sep, 2008, Skol wrote in the 19th comment:
Votes: 0
Assuming no one beats me to it heh. ;)
24 Sep, 2008, gorex wrote in the 20th comment:
Votes: 0
I still want IMP, DEM, CRE, blah blah to appear. However, instead of being under class I want it to show up under level. So…do who for the IMP should look like
[IMP Ava Cle] Gorex the blah. Instead of [409 Ava IMP] Gorex the blah.
0.0/39