Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions code/object/waypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void waypoint_stuff_name(char *dest, const char *waypoint_list_name, int waypoin

if (waypoint_num < 1)
{
Assertion(LOCATION, "A waypoint number must be at least 1!");
Error(LOCATION, "A waypoint number must be at least 1!");
*dest = 0;
return;
}
Expand All @@ -410,8 +410,9 @@ void waypoint_stuff_name(char *dest, const char *waypoint_list_name, int waypoin
return;
}

strncpy(dest, waypoint_list_name, name_max_len);
sprintf(dest + name_max_len, ":%d", waypoint_num);
auto name_len = std::min(strlen(waypoint_list_name), name_max_len);
strncpy(dest, waypoint_list_name, name_len);
sprintf(dest + name_len, ":%d", waypoint_num);
}

void waypoint_stuff_name(SCP_string &dest, const char *waypoint_list_name, int waypoint_num)
Expand All @@ -420,7 +421,7 @@ void waypoint_stuff_name(SCP_string &dest, const char *waypoint_list_name, int w

if (waypoint_num < 1)
{
Assertion(LOCATION, "A waypoint number must be at least 1!");
Error(LOCATION, "A waypoint number must be at least 1!");
dest = "";
return;
}
Expand Down
17 changes: 11 additions & 6 deletions fred2/campaigntreewnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,25 @@ int campaign_tree_wnd::error(const char *msg, ...)

int campaign_tree_wnd::internal_error(const char *msg, ...)
{
SCP_string buf, buf2;
SCP_string buf;
va_list args;

g_err++;
va_start(args, msg);
vsprintf(buf, msg, args);
va_end(args);

sprintf(buf2, "%s\n\nThis is an internal error. Please let Hoffoss\n"
"know about this so he can fix it. Click cancel to debug.", buf.c_str());
g_err++;

nprintf(("Error", buf.c_str()));
if (MessageBox(buf2.c_str(), "Internal Error", MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
#ifndef NDEBUG
nprintf(("Internal Error", buf.c_str()));

buf += "\n\nThis is an internal error. Please notify a coder about this. Click cancel to debug.";

if (MessageBox(buf.c_str(), "Internal Error", MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
Int3(); // drop to debugger so the problem can be analyzed.
#else
MessageBox(buf.c_str(), "Error", MB_OK | MB_ICONEXCLAMATION);
#endif

return -1;
}
Expand Down
15 changes: 5 additions & 10 deletions fred2/fredview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3400,27 +3400,22 @@ int CFREDView::error(const char *msg, ...)

int CFREDView::internal_error(const char *msg, ...)
{
char buf[2048];
SCP_string buf;
va_list args;

va_start(args, msg);
vsnprintf(buf, sizeof(buf)-1, msg, args);
vsprintf(buf, msg, args);
va_end(args);
buf[sizeof(buf)-1] = '\0';

g_err = 1;

#ifndef NDEBUG
char buf2[2048];
buf += "\n\nThis is an internal error. Please notify a coder about this. Click cancel to debug.";

sprintf(buf2, "%s\n\nThis is an internal error. Please let Jason\n"
"know about this so he can fix it. Click cancel to debug.", buf);

if (MessageBox(buf2, "Internal Error", MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
if (MessageBox(buf.c_str(), "Internal Error", MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
Int3(); // drop to debugger so the problem can be analyzed.

#else
MessageBox(buf, "Error", MB_OK | MB_ICONEXCLAMATION);
MessageBox(buf.c_str(), "Error", MB_OK | MB_ICONEXCLAMATION);
#endif

return -1;
Expand Down
13 changes: 4 additions & 9 deletions qtfred/src/mission/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2642,29 +2642,24 @@ int Editor::error(const char* msg, ...) {
return 1;
}
int Editor::internal_error(const char* msg, ...) {
char buf[2048];
SCP_string buf;
va_list args;

va_start(args, msg);
vsnprintf(buf, sizeof(buf) - 1, msg, args);
vsprintf(buf, msg, args);
va_end(args);
buf[sizeof(buf) - 1] = '\0';

g_err = 1;

#ifndef NDEBUG
char buf2[2048];

sprintf_safe(buf2, "%s\n\nThis is an internal error. Please let Jason\n"
"know about this so he can fix it. Click cancel to debug.", buf);
buf += "\n\nThis is an internal error. Please notify a coder about this. Click cancel to debug.";

if (_lastActiveViewport->dialogProvider->showButtonDialog(DialogType::Error,
"Internal Error",
buf2,
buf,
{ DialogButton::Ok, DialogButton::Cancel })
== DialogButton::Cancel)
Int3(); // drop to debugger so the problem can be analyzed.

#else
_lastActiveViewport->dialogProvider->showButtonDialog(DialogType::Error, "Error", buf, { DialogButton::Ok });
#endif
Expand Down