mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-04 14:30:35 +00:00
intra:: fixes
This commit is contained in:
parent
64268f7990
commit
5f4e03b1da
25
intra.cpp
25
intra.cpp
@ -18,7 +18,7 @@ struct intra_data {
|
|||||||
EX vector<intra_data> data;
|
EX vector<intra_data> data;
|
||||||
|
|
||||||
/** index of the space we are currently in */
|
/** index of the space we are currently in */
|
||||||
EX int intra_current;
|
EX int current;
|
||||||
|
|
||||||
/** map cells to their intra spaces */
|
/** map cells to their intra spaces */
|
||||||
EX map<cell*, int> intra_id;
|
EX map<cell*, int> intra_id;
|
||||||
@ -153,11 +153,11 @@ EX connection_data* find_connection(int a, int b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX void switch_to(int id) {
|
EX void switch_to(int id) {
|
||||||
if(intra_current == id) return;
|
if(current == id) return;
|
||||||
data[intra_current].gd.storegame();
|
data[current].gd.storegame();
|
||||||
intra_current = id;
|
current = id;
|
||||||
ginf[gProduct] = data[intra_current].gi;
|
ginf[gProduct] = data[current].gi;
|
||||||
data[intra_current].gd.restoregame();
|
data[current].gd.restoregame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect_portal_1(cellwalker cw1, cellwalker cw2) {
|
void connect_portal_1(cellwalker cw1, cellwalker cw2) {
|
||||||
@ -199,8 +199,9 @@ EX void connect_portal(cellwalker cw1, cellwalker cw2) {
|
|||||||
/** make currentmap into one of the spaces in intra */
|
/** make currentmap into one of the spaces in intra */
|
||||||
EX void become() {
|
EX void become() {
|
||||||
auto& ac = currentmap->allcells();
|
auto& ac = currentmap->allcells();
|
||||||
|
current = isize(data);
|
||||||
for(cell *c: ac)
|
for(cell *c: ac)
|
||||||
intra_id[c] = intra_current;
|
intra_id[c] = current;
|
||||||
for(cell *c: ac)
|
for(cell *c: ac)
|
||||||
currentmap->wall_offset(c);
|
currentmap->wall_offset(c);
|
||||||
for(cell *c: ac) c->item = itNone;
|
for(cell *c: ac) c->item = itNone;
|
||||||
@ -223,17 +224,17 @@ EX void become() {
|
|||||||
/** after called become() on some spaces, actually start intra */
|
/** after called become() on some spaces, actually start intra */
|
||||||
EX void start(int id IS(0)) {
|
EX void start(int id IS(0)) {
|
||||||
in = true;
|
in = true;
|
||||||
intra_current = id;
|
current = id;
|
||||||
data[intra_current].gd.restoregame();
|
data[current].gd.restoregame();
|
||||||
ginf[gProduct] = data[intra_current].gi;
|
ginf[gProduct] = data[current].gi;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
/** a convenience struct to switch back after a temporary switch_to */
|
/** a convenience struct to switch back after a temporary switch_to */
|
||||||
struct resetter {
|
struct resetter {
|
||||||
int ic;
|
int ic;
|
||||||
resetter() { ic = intra::intra_current; }
|
resetter() { ic = current; }
|
||||||
~resetter() { if(intra::in) switch_to(ic); }
|
~resetter() { if(in) switch_to(ic); }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user