diff --git a/rogueviz/ru/globals.cpp b/rogueviz/ru/globals.cpp index ce805f08..2a5c35af 100644 --- a/rogueviz/ru/globals.cpp +++ b/rogueviz/ru/globals.cpp @@ -169,4 +169,7 @@ string parse_markup(string s); struct power& find_power(string name); +tuple get_next_room(struct xy w, room *r, int which = -1); + +extern shiftmatrix scrm; } diff --git a/rogueviz/ru/ru.cpp b/rogueviz/ru/ru.cpp index 2d486700..a0085162 100644 --- a/rogueviz/ru/ru.cpp +++ b/rogueviz/ru/ru.cpp @@ -97,31 +97,40 @@ void editmap_frame() { } /* new w, velocity multiplier, neighbor id */ -tuple get_next_room(xy w, room *r) { - if(w.x < l_margin_at) { +tuple get_next_room(xy w, room *r, int which) { + auto chk = [&] (bool b, int rid) { + return which == rid || (which == -1 && b); + }; + + if(chk(w.x < l_margin_at, 2)) { w.x += actual_screen_x; return {w, 1, 2}; } - if(w.x > r_margin_at) { + if(chk(w.x > r_margin_at, non_hyperbolic ? 0 : 4)) { w.x -= actual_screen_x; return {w, 1, non_hyperbolic ? 0 : 4}; } - if(w.y < t_margin_at && !non_hyperbolic) { - w.y = (w.y - t_margin_at) * 2 + b_margin_at; - w.x -= l_margin_at; - w.x = 2 * w.x; - int rid = w.x <= actual_screen_x; - if(rid == 0) w.x -= actual_screen_x; - w.x += l_margin_at; - return {w, 2, rid}; + xy w1; + w1.y = (w.y - t_margin_at) * 2 + b_margin_at; + w1.x = 2 * (w.x - l_margin_at); + + if(chk(w.y < t_margin_at && !non_hyperbolic && w1.x <= actual_screen_x, 1)) { + w1.x += l_margin_at; + return {w1, 2, 1}; } - if(w.y > b_margin_at && !non_hyperbolic) { + if(chk(w.y < t_margin_at && !non_hyperbolic && w1.x > actual_screen_x, 0)) { + w1.x -= actual_screen_x; + w1.x += l_margin_at; + return {w1, 2, 0}; + } + + if(chk(w.y > b_margin_at && !non_hyperbolic, 3)) { w.x -= l_margin_at; w.y -= b_margin_at; w.y /= 2; w.y += t_margin_at; - if(is_right(current_room)) + if(is_right(r)) w.x += actual_screen_x; w.x /= 2; w.x += l_margin_at;