| 525 | } |
| 526 | |
| 527 | void Game_Variables::SetArray(int first_id_a, int last_id_a, int first_id_b) { |
| 528 | PrepareArray(first_id_a, last_id_a, first_id_b, "Invalid write var[{},{}] = var[{},{}]!"); |
| 529 | // Maniac Patch uses memcpy which is actually a memmove |
| 530 | // This ensures overlapping areas are copied properly |
| 531 | if (first_id_a < first_id_b) { |
| 532 | WriteArray(first_id_a, last_id_a, first_id_b, VarSet); |
| 533 | } else { |
| 534 | auto& vv = _variables; |
| 535 | const int steps = std::max(0, last_id_a - first_id_a + 1); |
| 536 | int out_b = std::max(0, first_id_b + steps - 2); |
| 537 | int out_a = std::max(0, last_id_a - 1); |
| 538 | for (int i = 0; i < steps; ++i) { |
| 539 | auto& v_a = vv[out_a--]; |
| 540 | auto v_b = vv[out_b--]; |
| 541 | v_a = Utils::Clamp(VarSet(v_a, v_b), _min, _max); |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | void Game_Variables::AddArray(int first_id_a, int last_id_a, int first_id_b) { |
| 547 | PrepareArray(first_id_a, last_id_a, first_id_b, "Invalid write var[{},{}] += var[{},{}]!"); |
no test coverage detected