void HUD_ship_sent_printf(int sh, const char *format, ...)
{
    va_list args;
    char tmp[HUD_MSG_LENGTH_MAX];
    tmp[sizeof(tmp)-1] = '\0';
    size_t len;

    snprintf(tmp, sizeof(tmp)-1, NOX("%s: "), Ships[sh].ship_name);
    len = strlen(tmp);

    va_start(args, format);
    vsnprintf(tmp + len, sizeof(tmp)-1-len, format, args);
    va_end(args);

    Assert(strlen(tmp) < HUD_MSG_LENGTH_MAX);	//	If greater than this, probably crashed anyway.
    hud_sourced_print(HUD_team_get_source(Ships[sh].team), tmp);
}
示例#2
0
// --------------------------------------------------------------------------------------
// HUD_sourced_printf() 
//
// HUD_sourced_printf() has the same parameters as printf(), but displays the text as a scrolling
// message on the HUD.  Text is split into multiple lines if width exceeds msg display area
// width.  'source' is used to indicate who send the message, and is used to color code text.
//
void HUD_sourced_printf(int source, char *format, ...)
{
	va_list args;
	char tmp[HUD_MSG_LENGTH_MAX];

	// make sure we only print these messages if we're in the correct state
	if((Game_mode & GM_MULTIPLAYER) && (Net_player->state != NETPLAYER_STATE_IN_MISSION)){
		nprintf(("Network","HUD_sourced_printf bailing because not in multiplayer game play state\n"));
		return;
	}
	
	va_start(args, format);
	vsprintf(tmp, format, args);
	va_end(args);
	Assert(strlen(tmp) < HUD_MSG_LENGTH_MAX);	//	If greater than this, probably crashed anyway.
	hud_sourced_print(source, tmp);
}
// --------------------------------------------------------------------------------------
// HUD_sourced_printf()
//
// HUD_sourced_printf() has the same parameters as printf(), but displays the text as a scrolling
// message on the HUD.  Text is split into multiple lines if width exceeds msg display area
// width.  'source' is used to indicate who send the message, and is used to color code text.
//
void HUD_sourced_printf(int source, const char *format, ...)
{
    va_list args;
    char tmp[HUD_MSG_LENGTH_MAX];

    // make sure we only print these messages if we're in the correct state
    if((Game_mode & GM_MULTIPLAYER) && (Net_player->state != NETPLAYER_STATE_IN_MISSION)) {
        nprintf(("Network","HUD_sourced_printf bailing because not in multiplayer game play state\n"));
        return;
    }

    va_start(args, format);
    vsnprintf(tmp, sizeof(tmp)-1, format, args);
    va_end(args);
    tmp[sizeof(tmp)-1] = '\0';

    hud_sourced_print(source, tmp);
}