stuff affected by on_dim_change now implements the dim_listener interface

This commit is contained in:
Zeno Rogue committed 2026-04-16 19:02:07 +02:00
1 parent 58c243f3f0
commit 9bfc3ba400
6 files changed
+35 -17

No files matched your search

+1 -1
View File
@@ -784,7 +784,7 @@ vector<rule_recursive> spectre_rules_recursive = { rule_recursive
EX ld hat_param = 1;
EX ld hat_param_imag = 0;
struct hrmap_hat : hrmap {
struct hrmap_hat : hrmap, dim_listener {
// always generate the same way
std::mt19937 hatrng;
+4 -3
View File
@@ -29,7 +29,6 @@ struct hrmap {
virtual ~hrmap() { }
virtual vector<cell*>& allcells();
virtual void verify() { }
virtual void on_dim_change() { }
virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir);
virtual void extend_altmap(heptagon *h, int levs = default_levs(), bool link_cdata = true);
heptagon *may_create_step(heptagon *h, int direction) {
@@ -37,6 +36,8 @@ struct hrmap {
return create_step(h, direction);
}
virtual heptagon *create_step(heptagon *h, int direction);
/** reinitialize the map after swapping dimensions */
virtual void reinit() {}
protected:
virtual transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint);
virtual transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint);
@@ -103,7 +104,7 @@ public:
* Liskov substitution warning: maps which produce both tiling like above and 3D tilings
* (e.g. Euclidean and Crystal) also inherit from hrmap_standard
**/
struct hrmap_standard : hrmap {
struct hrmap_standard : hrmap, dim_listener {
void draw_at(cell *at, const shiftmatrix& where) override;
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override;
transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override;
@@ -592,7 +593,7 @@ EX void initcells() {
check_cgi();
geom3::swap_direction = +1;
for(auto& m: cgi.heptmove) swapmatrix(m);
currentmap->on_dim_change();
currentmap->reinit();
return;
}
+2 -2
View File
@@ -25,8 +25,8 @@ EX namespace fake {
EX bool in_ext() { return in() || (mhybrid && PIU(in())); }
EX void on_dim_change() { pmap->on_dim_change(); }
EX void reinit() override { pmap->reinit(); }
/** like in() but takes slided arb into account */
EX bool split() { return in() || arb::in_slided(); }
+20 -1
View File
@@ -986,6 +986,25 @@ void geometry_information::prepare_basics() {
EX purehookset hooks_swapdim;
#if HDR
extern struct dim_listener *dl_list;
struct dim_listener {
dim_listener *next, **prev;
dim_listener() {
dl_list->prev = &next;
next = dl_list;
dl_list = this;
}
~dim_listener() {
*prev = next; next->prev = prev;
}
virtual void on_dim_change() {}
};
#endif
dim_listener *dl_list;
EX hookset<void(geometry_information*)> hooks_scalefactor;
EX namespace geom3 {
@@ -1210,7 +1229,7 @@ EX namespace geom3 {
swapmatrix_view(NLP, View);
swapmatrix_view(NLP, current_display->which_copy);
callhooks(hooks_swapdim);
for(auto m: allmaps) m->on_dim_change();
auto dl = dl_list; while(dl) { dl->on_dim_change(); dl = dl->next; }
}
#if MAXMDIM >= 4
+4 -8
View File
@@ -34,7 +34,8 @@ ld sqdist(shiftpoint a, shiftpoint b) {
EX namespace shmup {
#if HDR
struct monster {
struct monster : dim_listener {
eMonster type;
cell *base; ///< on which base cell this monster currently is
cell *torigin; ///< tortoises: origin, butterflies: last position
@@ -92,7 +93,8 @@ struct monster {
parent->refs++;
}
};
void on_dim_change() override { swapmatrix(at); }
};
#endif
void monster::reset() {
@@ -3056,12 +3058,6 @@ EX void switch_shmup() {
start_game();
}
#if MAXMDIM >= 4
auto hooksw = addHook(hooks_swapdim, 100, [] {
for(auto& p: monstersAt) swapmatrix(p.second->at);
});
#endif
EX shiftmatrix at_missile_level(const shiftmatrix& T) {
if(WDIM == 3) return T;
if(GDIM == 3) return orthogonal_move(T, cgi.BODY);
+4 -2
View File
@@ -172,11 +172,13 @@ struct hrmap_spherical : hrmap_standard {
return Id;
}
void on_dim_change() override {
hrmap_standard::on_dim_change();
void reinit() override {
hrmap_standard::reinit();
where.clear();
}
void on_dim_change() override { reinit(); }
transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override {
if(IRREGULAR) return relative_matrix_via_masters(c2, c1, hint);
transmatrix T = iso_inverse(get_where(c1)) * get_where(c2);