@@ -20437,34 +20437,37 @@ void sexp_string_set_substring(int node)
2043720437void sexp_debug(int node)
2043820438{
2043920439 int i;
20440- char *id;
20441- char temp_buf[MESSAGE_LENGTH] = {""};
20440+ SCP_string warning_message;
2044220441
2044320442 #ifdef NDEBUG
2044420443 int no_release_message;
2044520444 no_release_message = is_sexp_true(node);
2044620445 #endif
2044720446
2044820447 node = CDR(node);
20449- Assertion (node >= 0, "No message defined in debug SEXP");
20450- id = CTEXT(node);
20448+ Assertion (node >= 0, "No message defined in debug SEXP");
2045120449
20450+ // we'll suppose it's the string for now
20451+ warning_message = CTEXT(node);
20452+
20453+ // but use an actual message if one exists
2045220454 for (i=0; i<Num_messages; i++) {
2045320455 // find the message
20454- if ( !stricmp(id, Messages[i].name) ) {
20455- //replace variables if necessary
20456- strcpy_s(temp_buf, Messages[i].message);
20457- sexp_replace_variable_names_with_values(temp_buf, MESSAGE_LENGTH);
20456+ if ( !stricmp(Messages[i].name, warning_message.c_str()) ) {
20457+ warning_message = Messages[i].message;
2045820458 break;
2045920459 }
2046020460 }
2046120461
20462+ // replace variables if necessary
20463+ sexp_replace_variable_names_with_values(warning_message);
20464+
2046220465 //send the message
2046320466 #ifndef NDEBUG
20464- Warning(LOCATION, "%s", temp_buf );
20467+ Warning(LOCATION, "%s", warning_message.c_str() );
2046520468 #else
2046620469 if (!no_release_message) {
20467- ReleaseWarning(LOCATION, "%s", temp_buf );
20470+ ReleaseWarning(LOCATION, "%s", warning_message.c_str() );
2046820471 }
2046920472 #endif
2047020473}
@@ -26184,10 +26187,8 @@ int query_operator_argument_type(int op, int argnum)
2618426187 case OP_DEBUG:
2618526188 if (argnum == 0) {
2618626189 return OPF_BOOL;
26187- }else if (argnum == 1) {
26188- return OPF_MESSAGE;
26189- }else {
26190- return OPF_STRING;
26190+ } else {
26191+ return OPF_MESSAGE_OR_STRING;
2619126192 }
2619226193
2619326194 case OP_HAS_TIME_ELAPSED:
@@ -31662,8 +31663,8 @@ sexp_help_struct Sexp_help[] = {
3166231663 { OP_DEBUG, "debug\r\n"
3166331664 "\tPops up a warning on debug builds (and optionally on release builds)\r\n"
3166431665 "Takes 1 or more arguments...\r\n"
31665- "\t1:\t If false, popup messages in release builds too. Defaults to true.\r\n"
31666- "\t2:\tName of a message which will appear in the warning (optional) \r\n"},
31666+ "\t1:\tLimit warning to debug builds. If false, display warning in release builds too. Defaults to true.\r\n"
31667+ "\t2:\tA short string which will appear in the warning, or a message if the string matches a message name. \r\n"},
3166731668
3166831669 { OP_GRANT_PROMOTION, "Grant promotion (Action operator)\r\n"
3166931670 "\tIn a single player game, this function grants a player an automatic promotion to the "
@@ -31732,7 +31733,7 @@ sexp_help_struct Sexp_help[] = {
3173231733 "have scanned each one.\r\n\r\n"
3173331734 "Returns a boolean value after <delay> seconds when all cargo is known. Takes 2 or more arguments...\r\n"
3173431735 "\t1:\tDelay in seconds after which sexpression will return true when all cargo scanned."
31735- "\tRest:\tNames of ships/cargo to check for cargo known.. " },
31736+ "\tRest:\tNames of ships/cargo to check for cargo known." },
3173631737
3173731738 { OP_WAS_PROMOTION_GRANTED, "Was promotion granted (Boolean operator)\r\n"
3173831739 "\tReturns true if a promotion was granted via the 'Grant promotion' operator in the mission.\r\n\r\n"
0 commit comments