Skip to content

Commit 13d4eba

Browse files
committed
leave a 'node' variable pointing to the beginning of the sexp node list so that we can manipulate it later
1 parent ed6a780 commit 13d4eba

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

code/parse/sexp.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,18 +4781,16 @@ int sexp_bitwise_xor(int node)
47814781
}
47824782

47834783
// seeding added by Karajorma and Goober5000
4784-
int rand_sexp(int n, bool multiple)
4784+
int rand_sexp(int node, bool multiple)
47854785
{
47864786
bool is_nan, is_nan_forever;
4787-
int low, high, rand_num, seed;
4788-
4789-
Assert(n >= 0);
4787+
int n = node, low, high, rand_num, seed;
47904788

47914789
// when getting a saved value
4792-
if (Sexp_nodes[n].value == SEXP_NUM_EVAL)
4790+
if (Sexp_nodes[node].value == SEXP_NUM_EVAL)
47934791
{
47944792
// don't regenerate new random number
4795-
return atoi(CTEXT(n));
4793+
return atoi(CTEXT(node));
47964794
}
47974795

47984796
// get low, high, and (optional) seed - seed will be 0, per eval_nums, if not specified
@@ -4809,15 +4807,15 @@ int rand_sexp(int n, bool multiple)
48094807
if (!multiple)
48104808
{
48114809
// set .value and .text so random number is generated only once.
4812-
Sexp_nodes[n].value = SEXP_NUM_EVAL;
4813-
sprintf(Sexp_nodes[n].text, "%d", rand_num);
4810+
Sexp_nodes[node].value = SEXP_NUM_EVAL;
4811+
sprintf(Sexp_nodes[node].text, "%d", rand_num);
48144812
}
48154813
// if this is multiple with a nonzero seed provided
48164814
else if (seed > 0)
48174815
{
48184816
// Set the seed to a new seeded random value. This will ensure that the next time the method
48194817
// is called it will return a predictable but different number from the previous time.
4820-
sprintf(Sexp_nodes[CDDR(n)].text, "%d", rand_internal(1, INT_MAX, seed));
4818+
sprintf(Sexp_nodes[CDDR(node)].text, "%d", rand_internal(1, INT_MAX, seed));
48214819
}
48224820

48234821
return rand_num;

0 commit comments

Comments
 (0)