mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 13:07:16 +00:00
swap_data is now a general template function, not in tortoise
This commit is contained in:
parent
7b38fc4de1
commit
ca6eb9d8ef
11
complex.cpp
11
complex.cpp
@ -2585,17 +2585,6 @@ EX namespace tortoise {
|
|||||||
return "(" + its(progress(bits)) + "/" + its(tortoise::numbits) + ")";
|
return "(" + its(progress(bits)) + "/" + its(tortoise::numbits) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void swap_data(T& data, cell *c1, cell *c2) {
|
|
||||||
changes.map_value(data, c1);
|
|
||||||
changes.map_value(data, c2);
|
|
||||||
if(data.count(c1) && data.count(c2))
|
|
||||||
swap(data[c1], data[c2]);
|
|
||||||
else if(data.count(c1))
|
|
||||||
data[c2] = data[c1], data.erase(c1);
|
|
||||||
else if(data.count(c2))
|
|
||||||
data[c1] = data[c2], data.erase(c2);
|
|
||||||
}
|
|
||||||
|
|
||||||
EX void move_baby(cell *c1, cell *c2) {
|
EX void move_baby(cell *c1, cell *c2) {
|
||||||
swap_data(babymap, c1, c2);
|
swap_data(babymap, c1, c2);
|
||||||
}
|
}
|
||||||
|
13
pcmove.cpp
13
pcmove.cpp
@ -541,6 +541,19 @@ EX int chaos_mirror_dir(int dir, cellwalker src, cellwalker dst) {
|
|||||||
return (dst-src.to_spin(dir)).spin;
|
return (dst-src.to_spin(dir)).spin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HDR
|
||||||
|
template<class T> void swap_data(T& data, cell *c1, cell *c2) {
|
||||||
|
changes.map_value(data, c1);
|
||||||
|
changes.map_value(data, c2);
|
||||||
|
if(data.count(c1) && data.count(c2))
|
||||||
|
swap(data[c1], data[c2]);
|
||||||
|
else if(data.count(c1))
|
||||||
|
data[c2] = data[c1], data.erase(c1);
|
||||||
|
else if(data.count(c2))
|
||||||
|
data[c1] = data[c2], data.erase(c2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \brief Apply the Orb of Chaos.
|
/** \brief Apply the Orb of Chaos.
|
||||||
*
|
*
|
||||||
* We assume that the player moves from cwt.peek, in
|
* We assume that the player moves from cwt.peek, in
|
||||||
|
Loading…
Reference in New Issue
Block a user