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

Method SwapArray

src/game_variables.cpp:596–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

594}
595
596void Game_Variables::SwapArray(int first_id_a, int last_id_a, int first_id_b) {
597 PrepareArray(first_id_a, last_id_a, first_id_b, "Invalid write var[{},{}] <-> var[{},{}]!");
598 auto& vv = _variables;
599 const int steps = std::max(0, last_id_a - first_id_a + 1);
600 int out_b = std::max(0, first_id_b + steps - 2);
601 int out_a = std::max(0, last_id_a - 1);
602 for (int i = 0; i < steps; ++i) {
603 std::swap(vv[out_a--], vv[out_b--]);
604 }
605}
606
607std::string_view Game_Variables::GetName(int _id) const {
608 const auto* var = lcf::ReaderUtil::GetElement(lcf::Data::variables, _id);

Callers 2

variables.cppFile · 0.80

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected