MDFN_Error::MDFN_Error(int errno_code_new, const char *format, ...) throw() { errno_code = errno_code_new; va_list ap; va_start(ap, format); error_message = trio_vaprintf(format, ap); va_end(ap); }
static void NetPrintText(const char *format, ...) { char *temp = NULL; va_list ap; va_start(ap, format); temp = trio_vaprintf(format, ap); va_end(ap); MDFND_NetplayText((UTF8 *)temp, FALSE); free(temp); }
// Call from game thread static void PrintNetError(const char *format, ...) { char *temp; va_list ap; va_start(ap, format); temp = trio_vaprintf(format, ap); MDFND_NetplayText((uint8 *)temp, FALSE); free(temp); va_end(ap); }
void MDFN_DebugPrintReal(const char *file, const int line, const char *format, ...) { char *temp; va_list ap; va_start(ap, format); temp = trio_vaprintf(format, ap); fprintf(stderr, "%s:%d %s\n", file, line, temp); free(temp); va_end(ap); }
void MDFN_PrintError(const char *format, ...) { char *temp; va_list ap; va_start(ap, format); temp = trio_vaprintf(format, ap); MDFND_PrintError(temp); free(temp); va_end(ap); }
void MDFN_printf(const char *format, ...) { char *format_temp; char *temp; unsigned int x, newlen; va_list ap; va_start(ap,format); // First, determine how large our format_temp buffer needs to be. uint8 lastchar_backup = lastchar; // Save lastchar! for(newlen=x=0;x<strlen(format);x++) { if(lastchar == '\n' && format[x] != '\n') { int y; for(y=0;y<curindent;y++) newlen++; } newlen++; lastchar = format[x]; } format_temp = (char *)malloc(newlen + 1); // Length + NULL character, duh // Now, construct our format_temp string lastchar = lastchar_backup; // Restore lastchar for(newlen=x=0;x<strlen(format);x++) { if(lastchar == '\n' && format[x] != '\n') { int y; for(y=0;y<curindent;y++) format_temp[newlen++] = ' '; } format_temp[newlen++] = format[x]; lastchar = format[x]; } format_temp[newlen] = 0; temp = trio_vaprintf(format_temp, ap); free(format_temp); MDFND_Message(temp); free(temp); va_end(ap); }