MCPcopy Create free account
hub / github.com/EasyRPG/Player / SetArray

Method SetArray

src/game_variables.cpp:527–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527void 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
546void 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[{},{}]!");

Callers 2

variables.cppFile · 0.80

Calls 2

maxFunction · 0.85
VarSetFunction · 0.85

Tested by

no test coverage detected