mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
dice:: now work correctly in non-orientable spaces
This commit is contained in:
parent
ca6eb9d8ef
commit
e6dd27f5bf
12
complex2.cpp
12
complex2.cpp
@ -963,6 +963,7 @@ EX namespace dice {
|
||||
struct die_structure *which;
|
||||
int val;
|
||||
int dir;
|
||||
bool mirrored;
|
||||
int happy();
|
||||
};
|
||||
#endif
|
||||
@ -1113,12 +1114,11 @@ EX namespace dice {
|
||||
|
||||
auto& dw = dd.which;
|
||||
|
||||
int si = isize(dw->sides[val]);
|
||||
int si = dw->facesides;
|
||||
|
||||
if(t % si) { println(hlog, "error: bad roll"); return dd; }
|
||||
|
||||
int sideid = (rdir - dir) * si / t;
|
||||
if(sideid < 0) sideid += si;
|
||||
int sideid = gmod((rdir - dir) * (dd.mirrored?-1:1) * si / t, si);
|
||||
|
||||
int val1 = dw->sides[val][sideid];
|
||||
|
||||
@ -1131,10 +1131,13 @@ EX namespace dice {
|
||||
|
||||
int rdir1 = mi.rev_dir_force();
|
||||
|
||||
int dir1 = rdir1 - sideid1 * t1 / si1;
|
||||
bool mirror1 = dd.mirrored ^ mi.mirror();
|
||||
|
||||
int dir1 = rdir1 - (mirror1?-1:1) * sideid1 * t1 / si1;
|
||||
|
||||
dir1 = gmod(dir1, t1);
|
||||
|
||||
dd.mirrored = mirror1;
|
||||
dd.val = val1;
|
||||
dd.dir = dir1;
|
||||
return dd;
|
||||
@ -1211,6 +1214,7 @@ EX namespace dice {
|
||||
#endif
|
||||
|
||||
shiftmatrix V1 = V * ddspin(c, dir) * spin(M_PI);
|
||||
if(dd.mirrored) V1 = V1 * MirrorY;
|
||||
|
||||
// loop:
|
||||
|
||||
|
@ -677,6 +677,7 @@ EX namespace mapstream {
|
||||
f.write_char(dice::get_die_id(dat.which));
|
||||
f.write_char(dat.val);
|
||||
f.write_char(dat.dir);
|
||||
f.write_char(dat.mirrored);
|
||||
}
|
||||
// f.write_char(c->barleft);
|
||||
// f.write_char(c->barright);
|
||||
@ -833,6 +834,8 @@ EX namespace mapstream {
|
||||
dat.which = dice::get_by_id(f.read_char());
|
||||
dat.val = f.read_char();
|
||||
dat.dir = fixspin(rspin, f.read_char(), c->type, f.vernum);
|
||||
if(f.vernum >= 0xA902)
|
||||
dat.mirrored = f.read_char();
|
||||
}
|
||||
// c->barleft = (eLand) f.read_char();
|
||||
// c->barright = (eLand) f.read_char();
|
||||
|
Loading…
Reference in New Issue
Block a user