void CharData::sendTagline( const char *text )
{
char output[MSL], tagline[MSL], buf[MSL];
char arg[256], arg2[256];
int value;
bool found = false;
const char *desc;
char *p_output = output, *common;
for( desc = text; *desc; desc++ )
{
/* Reset. */
bGo = false;
value = 0;
if( *desc != '[' )
{
*p_output = *desc;
*++p_output = '\0';
continue;
}
if( *++desc != '#' )
{
*p_output = *–desc;
*++p_output = '\0';
continue;
}
/* Skip beginning '[#'. */
++desc;
/* Read in the tag. */
common = buf;
while( *desc != ':' )
{
if( *desc == '\0' )
{
log_printf( "Error: tag has no parser ':'. Room: %d.", m_InRoom->vnum );
*common = *desc;
break;
}
*common = *desc;
*++common = '\0';
++desc;
}
/* Skip the colon and space ': '. */
desc += 2;
/* Read in the description. */
common = tagline;
while( *desc != ']' )
{
if( *desc == '\0' )
{
log_printf( "Error: tag has no ending ']'. Room: %d.", m_InRoom->vnum );
*common = *desc;
break;
}
*common = *desc;
*++common = '\0';
++desc;
}
/* Separate the arguments. */
common = one_argument( common, arg );
common = one_argument( common, arg2 );
if( is_number( common ) )
value = atoi( common );
else if( strlen( common ) > 0 )
log_printf( "Tag in room %d is odd: %s %s %s.", m_InRoom->vnum, arg, arg2, common );
/* Begin Tag Parsing */
//Snip Tag Parsing
/* End Tag Parsing */
/* Copy in the tagline. */
if( found == true )
{
common = tagline;
while( *common != '\0' )
{
if( strlen( output ) >= ( MAX_STRING_LENGTH - 1 ) )
break;
*p_output = *common;
++common;
*++p_output = '\0';
}
}
}
/* Send the whole thing to the player. */
common = str_dup( strdup( output ) );
print( common );
return;
}
/*
* Function for parsing descriptions for taglines.
* Example: [#dex < 9: You stumble over your own feet.]
* [#gold > 40: You draw the eye of every thief here.]
* [#wis = 10: You're no wiser than normal.]
* [#sun sunset: The sunset through the leaves is nice.]
*/
switch( UPPER( tag[0] ) )
{
case 'A':
if( !str_cmp( tag, "age" ) )
{
if( val < 0 )
found = false;
else
{
switch( value[0] )
{
case '>':
if( calculateAge( ) > val )
found = true;
break;
case '<':
if( calculateAge( ) < val )
found = true;
break;
case '=':
if( calculateAge( ) == val )
found = true;
break;
default:
found = false;
break;
}
}
}
if( !str_cmp( tag, "align" ) || !str_cmp( tag, "alignment" ) )
{
if( !str_cmp( value, "good") && isGood( ) )
{
found = true;
break;
}
else if( !str_cmp( value, "evil") && isEvil( ) )
{
found = true;
break;
}
else if( !str_cmp( value, "neutral" ) && isNeutral( ) )
{
found = true;
break;
}
}
break;
Name: Darkhaven Square
Area: New Darkhaven Filename: newdark.are
Vnum: 21000 Sector: 1 (city) Light: 0
Room flags: nomob nodropall nosummon
Description:
[#season summer: You are standing within the expanse of the famous Darkhaven Square. A
stone statue of occupies the square's center, surrounded by gardens of
flowers in full bloom which enhance the air of serenity and peace here in
the center of the city. The main road lead away in the cardinal directions, while
to the northeast and northwest are forested paths. The spires of a
cathedral can be seen rising to the northwest.]
[#season spring: You are standing within the expanse of the famous Darkhaven Square. A
stone statue of occupies the square's center, surrounded by gardens of
budding flowers which fill the air with lovely fragrances here in the center
of the city. The main road lead away in the cardinal directions, while
to the northeast and northwest are forested paths. The spires of a
cathedral can be seen rising to the northwest.]
[#season fall: You are standing within the expanse of the famous Darkhaven Square. A
stone statue of occupies the square's center, surrounded by gardens of
wilting flowers as winter fast approaches here in the center of the city.
The main road lead away in the cardinal directions, while to the northeast
and northwest are forested paths of many color falling leaves. The spires of a
cathedral can be seen rising to the northwest.]
[#season winter: You are standing within the frigid expanse of the famous Darkhaven
Square. A stone statue of occupies the square's center, surrounded by an army
of snowmen the children of the city have built here in the center of the city.
The main roads have been cleared away in the cardinal directions, while
to the northeast and northwest are forested paths which are still lightly covered
in snow. The spires of a cathedral can be seen rising to the northwest.]
Extra description keywords: 'sign post signpost'
Permanent affects: None
Characters: Kayle
Objects:
——————- EXITS ——————-
1) n to 21001. Key: -1 Keywords: (none). Flags:
2) e to 21036. Key: -1 Keywords: (none). Flags:
3) s to 21042. Key: -1 Keywords: (none). Flags:
4) w to 21039. Key: -1 Keywords: (none). Flags:
5) u to 21337. Key: -1 Keywords: (none). Flags:
6) ne to 21200. Key: -1 Keywords: (none). Flags:
7) nw to 21163. Key: -1 Keywords: (none). Flags:
/* Read in the tag. */
common = buf;
while( *desc != ':' )
{
if( *desc == '\0' )
{
log_printf( "Error: tag has no parser ':'. Room: %d.", m_InRoom->vnum );
*common = *desc;
break;
}
*common = *desc;
*++common = '\0';
++desc;
}
/* Skip the colon and space ': '. */
desc += 2;
/* Read in the description. */
common = message;
while( *desc != ']' )
{
if( *desc == '\0' )
{
log_printf( "Error: tag has no ending ']'. Room: %d.", m_InRoom->vnum );
*common = *desc;
break;
}
*common = *desc;
*++common = '\0';
++desc;
}
/* Separate the arguments. */
common = one_argument( common, tag );
common = one_argument( common, value );
/* Separate the arguments. */
common = buf;
common = one_argument( common, tag );
common = one_argument( common, value );
<32700hp 30000m 30000mv>
[Area name: New Darkhaven] [Area filename: newdark.are]
[Sector Type: city] [Area Flags: nopkill]
[21000][Room Flags: nomob nodropall nosummon]
Darkhaven Square
+———–+ You are standing within the
| | | expanse of the famous Darkhaven Square. A stone statue of
| : | occupies the square's center, surrounded by gardens of budding
+———–+ flowers which fill the air with lovely fragrances here in the
center of the city. The main road lead away in the cardinal directions, while
to the northeast and northwest are forested paths. The spires of a cathedral
can be seen rising to the northwest.
Exits: north east south west up northeast northwest.
char buf[123];
char* buf;
buf = malloc(123);
/* Read in the tag. */
common = buf;
while( *desc != ':' )
{
if( *desc == '\0' )
{
log_printf( "Error: tag has no parser ':'. Room: %d.", m_InRoom->vnum );
*common = *desc;
break;
}
*common = *desc;
*++common = '\0';
++desc;
}
/* Send the whole thing to the player. */
common = str_dup( strdup( output ) );
print( common );
return;
/* Send the whole thing to the player. */
static char *newDesc;
newDesc = str_dup( output );
return newDesc;
}
[#season winter: The snow is piled up all around.]
I need a way to parse a full room description and grab anything formatted like the example, then parse what's grabbed for everything from the [# to the : and then check to see whether or not that's true, and then if true, tack the part after the : minus the ] into the description. Hmm. Maybe there's an easier way to show this…
Description:
You are standing within the expanse of the famous Darkhaven Square. A
stone statue of occupies the square's center, surrounded by gardens of
shrubbery which enhance the air of serenity and peace here in the center
of the city. The main road lead away in the cardinal directions, while
to the northeast and northwest are forested paths. The spires of a
cathedral can be seen rising to the northwest. [#season winter: The snow is
piled up all around.]
During Winter:
So. Any suggestions are more than welcome, C or C++ solutions acceptable.
[Edit:] I have to code to parse the tags, what I don't have is a handle on how to get the tags out of the description for parsing. >.>