Skip to content

Commit 8645210

Browse files
authored
Fix type checking and FRED help for containers in special argument lists (#4486)
1 parent 8c39bf5 commit 8645210

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

code/parse/sexp.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,12 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i
21252125

21262126
} else if (Sexp_nodes[node].subtype == SEXP_ATOM_CONTAINER_DATA) {
21272127
// this is an instance of "Replace Container Data"
2128+
2129+
// can't be used in special argument list
2130+
if (type == OPF_ANYTHING || type == OPF_DATA_OR_STR_CONTAINER) {
2131+
return SEXP_CHECK_TYPE_MISMATCH;
2132+
}
2133+
21282134
const int modifier_node = Sexp_nodes[node].first;
21292135
if (modifier_node == -1) {
21302136
return SEXP_CHECK_MISSING_CONTAINER_MODIFIER;
@@ -11029,6 +11035,13 @@ void sexp_change_argument_validity(int n, bool invalidate)
1102911035
// first we must check if the arg_handler marks a selection. At the moment random-of is the only one that does this
1103011036
arg_n = CDR(arg_handler);
1103111037
while (invalidate && (arg_n != -1)) {
11038+
Assertion(Sexp_nodes[arg_n].subtype != SEXP_ATOM_CONTAINER_NAME,
11039+
"Attempt to use invalidate-argument with container %s. Please report!",
11040+
Sexp_nodes[arg_n].text);
11041+
Assertion(Sexp_nodes[arg_n].subtype != SEXP_ATOM_CONTAINER_DATA,
11042+
"Attempt to use invalidate-argument with data from container %s. Please report!",
11043+
Sexp_nodes[arg_n].text);
11044+
1103211045
if (Sexp_nodes[arg_n].flags & SNF_ARGUMENT_SELECT) {
1103311046
// now check if the selected argument matches the one we want to invalidate
1103411047
if (!strcmp(CTEXT(n), CTEXT(arg_n))) {
@@ -11047,6 +11060,13 @@ void sexp_change_argument_validity(int n, bool invalidate)
1104711060
arg_n = CDR(arg_handler);
1104811061
while (arg_n != -1)
1104911062
{
11063+
Assertion(Sexp_nodes[arg_n].subtype != SEXP_ATOM_CONTAINER_NAME,
11064+
"Attempt to change argument validity of container %s. Please report!",
11065+
Sexp_nodes[arg_n].text);
11066+
Assertion(Sexp_nodes[arg_n].subtype != SEXP_ATOM_CONTAINER_DATA,
11067+
"Attempt to change argument validity of data from container %s. Please report!",
11068+
Sexp_nodes[arg_n].text);
11069+
1105011070
// match?
1105111071
if (!strcmp(CTEXT(n), CTEXT(arg_n)))
1105211072
{
@@ -33892,27 +33912,31 @@ SCP_vector<sexp_help_struct> Sexp_help = {
3389233912
// Goober5000
3389333913
{ OP_INVALIDATE_ARGUMENT, "Invalidate-argument (Conditional operator)\r\n"
3389433914
"\tRemoves an argument from future consideration as a " SEXP_ARGUMENT_STRING " special data item.\r\n"
33895-
"\tFor argument-related SEXPs that accept containers as arguments, the retrieved arguments can't be individually invalidated.\r\n\r\n"
33915+
"\tFor argument-related SEXPs that accept containers as arguments, the retrieved arguments can't be individually invalidated.\r\n"
33916+
"\tAdditionally, you can't invalidate individual container arguments.\r\n\r\n"
3389633917
"Takes 1 or more arguments...\r\n"
3389733918
"\tAll:\tThe argument to remove from the preceding argument list." },
3389833919

3389933920
// Karajorma
3390033921
{ OP_VALIDATE_ARGUMENT, "Validate-argument (Conditional operator)\r\n"
3390133922
"\tRestores an argument for future consideration as a " SEXP_ARGUMENT_STRING " special data item.\r\n"
3390233923
"\tIf the argument hasn't been previously invalidated, it will do nothing.\r\n"
33903-
"\tFor argument-related SEXPs that accept containers as arguments, the retrieved arguments can't be individually validated.\r\n\r\n"
33924+
"\tFor argument-related SEXPs that accept containers as arguments, the retrieved arguments can't be individually validated.\r\n"
33925+
"\tAdditionally, you can't validate individual container arguments.\r\n\r\n"
3390433926
"Takes 1 or more arguments...\r\n"
3390533927
"\tAll:\tThe argument to restore to the preceding argument list." },
3390633928

3390733929
// Karajorma
3390833930
{ OP_INVALIDATE_ALL_ARGUMENTS, "Invalidate-all-arguments (Conditional operator)\r\n"
3390933931
"\tRemoves all argument from future consideration as " SEXP_ARGUMENT_STRING " special data items.\r\n"
33932+
"\tFor argument-related SEXPs that accept containers as arguments, container arguments will also be invalidated, but they can't be indvidiually validated.\r\n\r\n"
3391033933
"Takes no arguments." },
3391133934

3391233935
// Karajorma
3391333936
{ OP_VALIDATE_ALL_ARGUMENTS, "Validate-all-arguments (Conditional operator)\r\n"
3391433937
"\tRestores all arguments for future consideration as " SEXP_ARGUMENT_STRING " special data items.\r\n"
3391533938
"\tIf the argument hasn't been previously invalidated, it will do nothing.\r\n"
33939+
"\tFor argument-related SEXPs that accept containers as arguments, container arguments will also be validated, but they can't be indvidiually invalidated.\r\n\r\n"
3391633940
"Takes no arguments." },
3391733941

3391833942
// Goober5000 - added wing capability

0 commit comments

Comments
 (0)