Re: do_who problem/legend system/GET_LEVEL(tch)

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 01/20/02


On Sun, Jan 20, 2002 at 02:19:41AM -0500, Josh Harris wrote:
>Ok, let me start out with the basics.
>
>Version:  Circlemud bpl17 w/ Oasis Olc
>OS:       Windows 2K
>Compiler: Cygwin
>
>I am working on adding a newbie and legend system.  Well more or less a
>legend (Players Lvl 81-89).  I have been able to incorporate part of the
>code by giving them a legend flag and showing it on the who list.  I've
>also been able to change the color they appear on the who list to white.
>
>This is the source code (act.informative.c) of the color part and where I'm
>having the problems at:
>
>sprintf(buf, "%s%s%s[%2s %-50s] %s %s ",
>(GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
>(GET_LEVEL(tch) <=LVL_NEWBIE ? CCRED(ch, C_SPR) : ""),
>((GET_LEVEL(tch)<LVL_IMMORT && GET_LEVEL(tch)>=LVL_LEGEND) ?
>       CCWHT(ch,C_SPR) : ""),
>((GET_LEVEL(tch)<LVL_IMMORT && GET_LEVEL(tch)>=LVL_LEGEND) ?
>       "LEG" : GET_LEVEL(tch)),                  //Problem is here
>CLASS_ABBR(tch), GET_NAME(tch), GET_TITLE(tch));
>
>Ok the problem is the %2s and
>((GET_LEVEL(tch)<LVL_IMMORT && GET_LEVEL(tch)>=LVL_LEGEND) ?
>       "LEG" : GET_LEVEL(tch)),
>
>When I compile it the error I get is:
>act.informative.c:1278: warning: pointer/integer type mismatch in
>conditional expression
>
>It will run fine if I eliminate the GET_LEVEL(tch) and will put up "LEG" in
>the mud when that is eliminated.
>
>I have tried to separate the two into two different conditional statements
>and tried altering the %2* tag to c, d, and s.
>
>Any suggestions?

GET_LEVEL(tch) returns an integer (the level), but you don't have an
integer field corresponding to it in the format string, it's expecting a
string pointer.

As for changing the color fields (CCRED, etc) replace the CCxxx() with
the apropriate color string ("^R" or whatever it is).

An idea could be, define 2 format strings:
const char *fmt1 = "%s%s%s[%2s %-50s] %s %s ";
const char *fmt2 = "%s%s%s[%2d %-50s] %s %s ";

then change it to:

sprintf(buf, ((GET_LEVEL(tch) >= LVL_LEGEND)?fmt1:fmt2),
((GET_LEVEL(tch) >= LVL_IMMORT) ? "^Y" : ""),   etc...

-mike

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT