Skip to content

Commit 9107da8

Browse files
authored
Merge pull request #1351 from asarium/fix/1350
Readd warning dialog counting
2 parents 1029de8 + a2e70b8 commit 9107da8

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

code/osapi/dialogs.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,15 @@ namespace os
357357
}
358358
gr_activate(1);
359359
}
360-
361-
void ReleaseWarning(const char* filename, int line, const char* format, ...)
362-
{
363-
Global_warning_count++;
364360

361+
// Actual implementation of the warning function. Used by the various warning functions
362+
void WarningImpl(const char* filename, int line, const SCP_string& text)
363+
{
365364
filename = clean_filename(filename);
366365

367366
// output to the debug log before anything else (so that we have a complete record)
368367

369-
SCP_string formatMessage;
370-
va_list args;
371-
va_start(args, format);
372-
vsprintf(formatMessage, format, args);
373-
va_end(args);
374-
375-
376-
SCP_string printfString = formatMessage;
368+
SCP_string printfString = text;
377369
std::transform(printfString.begin(), printfString.end(), printfString.begin(), replaceNewline);
378370

379371
mprintf(("WARNING: \"%s\" at %s:%d\n", printfString.c_str(), filename, line));
@@ -388,7 +380,7 @@ namespace os
388380
}
389381

390382
SCP_stringstream boxMsgStream;
391-
boxMsgStream << "Warning: " << formatMessage << "\n";
383+
boxMsgStream << "Warning: " << text << "\n";
392384
boxMsgStream << "File: " << filename << "\n";
393385
boxMsgStream << "Line: " << line << "\n";
394386

@@ -442,9 +434,25 @@ namespace os
442434

443435
gr_activate(1);
444436
}
437+
438+
439+
void ReleaseWarning(const char* filename, int line, const char* format, ...) {
440+
Global_warning_count++;
441+
442+
SCP_string msg;
443+
va_list args;
444+
445+
va_start(args, format);
446+
vsprintf(msg, format, args);
447+
va_end(args);
448+
449+
WarningImpl(filename, line, msg);
450+
}
445451

446452
void Warning(const char* filename, int line, const char* format, ...)
447453
{
454+
Global_warning_count++;
455+
448456
#ifndef NDEBUG
449457
SCP_string msg;
450458
va_list args;
@@ -453,7 +461,7 @@ namespace os
453461
vsprintf(msg, format, args);
454462
va_end(args);
455463

456-
ReleaseWarning(filename, line, "%s", msg.c_str());
464+
WarningImpl(filename, line, msg);
457465
#endif
458466
}
459467

0 commit comments

Comments
 (0)