char * center_string(char * str, int width)
{
static char result[MSL];
int length = colorstrlen(str);
if (length >= width)
return str;
int tspace = (width-length);
int lspace = (tspace/2);
int rspace = (tspace/2);
if ((rspace * 2) < tspace)
rspace++;
sprintf(result,"%*s%s%*s",lspace,"",str,rspace,"");
return result;
}
const char* center_string(const char* str, int width)
{
static char result[MSL];
int length = colorstrlen(str);
if (length >= width)
return str;
int tspace = (width-length);
int lspace = (tspace/2);
int rspace = (tspace/2);
if ((rspace * 2) < tspace)
rspace++;
sprintf(result,"%*s%s%*s",lspace,"",str,rspace,"");
return result;
}
int length = colorstrlen(str);
if (wch->pcdata->whotitle[0] != '\0')
{
sprintf( buf, "{D[{x%s{D]{x [%s] %s %s %s%s%s%s%s%s%s\n\r",
whotitle,
clanname,
wch->name,
wch->lastname,
IS_NPC(wch) ? "" : wch->pcdata->title,
wch->incog_level >= LEVEL_HERO ? "(Incog) " : "",
wch->invis_level >= LEVEL_HERO ? "(Wizi) " : "",
wch->timer >= 10 ? "[IDLE]" : "",
IS_SET(wch->comm, COMM_AFK) ? "[AFK] " : "",
IS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
IS_SET(wch->act, PLR_THIEF) ? "(THIEF) " : "");
}
char const *whotitle;
char const *clanname;
if (wch->pcdata->whotitle[0] != '\0')
whotitle = center_string(wch->pcdata->whotitle,16);
else
whotitle = center_string("NULL",16);
if (wch->clan)
clanname = center_string(clan_table[wch->clan].who_name,23);
else
clanname = center_string("Adventurer",23);
if (wch->pcdata->whotitle[0] != '\0')
sprintf(whotitle,"%s",center_string(wch->pcdata->whotitle,16));
else
sprintf(whotitle,"%s",center_string("NULL",16));
if (wch->clan)
sprintf(clanname,"%s",center_string(clan_table[wch->clan].who_name,23));
else
sprintf(clanname,"%s",center_string("Adventurer",23));
string.c: In function center_string:code warning though.
string.c:747: warning: passing argument 1 of colorstrlen discards qualifiers from pointer target type
char whotitle[1024];
char* center_string(const char* string, int width)
{
static char result[MSL];
int length = colorstrlen(string);
if (length >= width)
return string;
int tspace = (width-length);
int lspace = (tspace/2);
int rspace = (tspace/2);
if ((rspace * 2) < tspace)
rspace++;
sprintf(result,"%*s%s%*s",lspace,"",string,rspace,"");
return result;
}
int length = colorstrlen(string);
Well for some reason it aint lining up on here right but in game it does so you get the idea.
Edit by kiasyn: code tags