Skip to content

Commit b2a2c7b

Browse files
author
Goober5000
committed
make sure we find the correct operator for logging in short-circuited sexps
1 parent eb1389d commit b2a2c7b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

code/parse/sexp.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22773,22 +22773,26 @@ int eval_sexp(int cur_node, int referenced_node)
2277322773
// trap known true and known false sexpressions. We don't trap on SEXP_NAN sexpressions since
2277422774
// they may yet evaluate to true or false.
2277522775

22776+
// we want to log event values for KNOWN_X or FOREVER_X before returning
22777+
if (Log_event && ((Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) || (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) || (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER))) {
22778+
// if this is a node that has been assigned the value by short-circuiting,
22779+
// it might not be the operator that returned the value
22780+
int op_index = get_operator_index(cur_node);
22781+
if (op_index < 0)
22782+
op_index = get_operator_index(CAR(cur_node));
22783+
22784+
// log the known value
22785+
add_to_event_log_buffer(op_index, Sexp_nodes[cur_node].value);
22786+
}
22787+
22788+
// now do a quick return whether or not we log, per the comment above about trapping known sexpressions
2277622789
if (Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) {
22777-
if (Log_event) {
22778-
add_to_event_log_buffer(get_operator_index(cur_node), SEXP_KNOWN_TRUE);
22779-
}
2278022790
return SEXP_TRUE;
2278122791
}
2278222792
else if (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) {
22783-
if (Log_event) {
22784-
add_to_event_log_buffer(get_operator_index(cur_node), SEXP_KNOWN_FALSE);
22785-
}
2278622793
return SEXP_FALSE;
2278722794
}
2278822795
else if (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER) {
22789-
if (Log_event) {
22790-
add_to_event_log_buffer(get_operator_index(cur_node), SEXP_NAN_FOREVER);
22791-
}
2279222796
return SEXP_FALSE;
2279322797
}
2279422798

0 commit comments

Comments
 (0)