1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-08-29 08:52:19 +00:00

get_next_room now accepts which

This commit is contained in:
Zeno Rogue 2025-07-29 18:00:06 +02:00
parent efd6c90400
commit 142308567b
2 changed files with 25 additions and 13 deletions

View File

@ -169,4 +169,7 @@ string parse_markup(string s);
struct power& find_power(string name); struct power& find_power(string name);
tuple<struct xy, ld, int> get_next_room(struct xy w, room *r, int which = -1);
extern shiftmatrix scrm;
} }

View File

@ -97,31 +97,40 @@ void editmap_frame() {
} }
/* new w, velocity multiplier, neighbor id */ /* new w, velocity multiplier, neighbor id */
tuple<xy, ld, int> get_next_room(xy w, room *r) { tuple<xy, ld, int> get_next_room(xy w, room *r, int which) {
if(w.x < l_margin_at) { 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; w.x += actual_screen_x;
return {w, 1, 2}; 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; w.x -= actual_screen_x;
return {w, 1, non_hyperbolic ? 0 : 4}; return {w, 1, non_hyperbolic ? 0 : 4};
} }
if(w.y < t_margin_at && !non_hyperbolic) { xy w1;
w.y = (w.y - t_margin_at) * 2 + b_margin_at; w1.y = (w.y - t_margin_at) * 2 + b_margin_at;
w.x -= l_margin_at; w1.x = 2 * (w.x - l_margin_at);
w.x = 2 * w.x;
int rid = w.x <= actual_screen_x; if(chk(w.y < t_margin_at && !non_hyperbolic && w1.x <= actual_screen_x, 1)) {
if(rid == 0) w.x -= actual_screen_x; w1.x += l_margin_at;
w.x += l_margin_at; return {w1, 2, 1};
return {w, 2, rid};
} }
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.x -= l_margin_at;
w.y -= b_margin_at; w.y -= b_margin_at;
w.y /= 2; w.y /= 2;
w.y += t_margin_at; w.y += t_margin_at;
if(is_right(current_room)) if(is_right(r))
w.x += actual_screen_x; w.x += actual_screen_x;
w.x /= 2; w.x /= 2;
w.x += l_margin_at; w.x += l_margin_at;