Example #1
0
// String format is
// <charname> - blah blah <someoneelse>
void DisplayMessage::DisplayConstantStringAction(int stridx, unsigned int color, const Scriptable *attacker, const Scriptable *target) const
{
	unsigned int attacker_color;
	const char *name1 = 0;
	const char *name2 = 0;

	if (stridx<0) return;

	GetSpeakerColor(name2, target);
	attacker_color = GetSpeakerColor(name1, attacker);

	char* text = core->GetString( strref_table[stridx], IE_STR_SOUND|IE_STR_SPEECH );
	int newlen = (int)(strlen( DisplayFormatAction ) + strlen( name1 ) +
		+ strlen( name2 ) + strlen( text ) + 18);
	char* newstr = ( char* ) malloc( newlen );
	snprintf( newstr, newlen, DisplayFormatAction, attacker_color, name1, color,
		text, name2);
	core->FreeString( text );
	DisplayString( newstr );
	free( newstr );
}
Example #2
0
void DisplayMessage::DisplayStringName(const char *text, unsigned int color, const Scriptable *speaker) const
{
	unsigned int speaker_color;
	const char *name = 0;

	if (!text) return;
	speaker_color = GetSpeakerColor(name, speaker);

	//FIXME: what happens if there is no name?
	if (name) {
		int newlen = (int)(strlen( DisplayFormatName ) + strlen( name ) +
			+ strlen( text ) + 18);
		char* newstr = ( char* ) malloc( newlen );
		snprintf( newstr, newlen, DisplayFormatName, speaker_color, name, color, text );
		DisplayString( newstr );
		free( newstr );
	}
}
Example #3
0
void DisplayMessage::DisplayStringName(const char *text, unsigned int color, const Scriptable *speaker) const
{
	unsigned int speaker_color;
	const char *name = 0;

	if (!text) return;
	speaker_color = GetSpeakerColor(name, speaker);

	// if there is no name, use the script name to help debugging
	if (!strcmp(name, "")) {
		name = speaker->GetScriptName();
	}

	int newlen = (int)(strlen(DisplayFormatName) + strlen(name) + strlen(text) + 18);
	char* newstr = (char *) malloc(newlen);
	snprintf(newstr, newlen, DisplayFormatName, speaker_color, name, color, text);
	DisplayString(newstr);
	free(newstr);
}
Example #4
0
// String format is
// <charname> - blah blah : whatever
void DisplayMessage::DisplayConstantStringNameString(int stridx, unsigned int color, int stridx2, const Scriptable *actor) const
{
	unsigned int actor_color;
	const char *name = 0;

	if (stridx<0) return;
	actor_color = GetSpeakerColor(name, actor);
	char* text = core->GetString( strref_table[stridx], IE_STR_SOUND );
	char* text2 = core->GetString( strref_table[stridx2], IE_STR_SOUND );
	int newlen = (int)(strlen( DisplayFormat ) + strlen(name) + strlen( text ) + strlen(text2) + 20);
	char* newstr = ( char* ) malloc( newlen );
	if (strlen(text2)) {
		snprintf( newstr, newlen, DisplayFormatNameString, actor_color, name, color, text, text2 );
	} else {
		snprintf( newstr, newlen, DisplayFormatName, color, name, color, text );
	}
	core->FreeString( text );
	core->FreeString( text2 );
	DisplayString( newstr );
	free( newstr );
}