mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-20 16:37:40 +00:00
Replace IF_KEY_EXISTS with a plain old function, not a macro.
This commit is contained in:
12
hyper.h
12
hyper.h
@@ -575,11 +575,6 @@ typedef function<int(struct cell*)> cellfunction;
|
||||
#define forCellCM(ct, cf) forCellIdCM(ct,forCellCM ## __LINE__,cf)
|
||||
#define forCellAll(ct, cf) forCellIdCM(ct,forCellAll ## __LINE__,cf)
|
||||
|
||||
/* conditions */
|
||||
|
||||
/** `IF_KEY_EXISTS(it, map, key) statement` checks whether the map 'map' contain key 'key', and if so, executes statement with it set to the relevant iterator */
|
||||
#define IF_KEY_EXISTS(it, map, key) for(auto it: {map.find(key)}) if(it != map.end())
|
||||
|
||||
// canAttack/moveval flags
|
||||
|
||||
#define AF_NORMAL 0 // nothing special about this attack
|
||||
@@ -851,6 +846,13 @@ template<class T> array<T, 4> make_array(T a, T b, T c, T d) { array<T,4> x; x[0
|
||||
template<class T> array<T, 3> make_array(T a, T b, T c) { array<T,3> x; x[0] = a; x[1] = b; x[2] = c; return x; }
|
||||
template<class T> array<T, 2> make_array(T a, T b) { array<T,2> x; x[0] = a; x[1] = b; return x; }
|
||||
|
||||
// Find in a std::map or std::unordered_map, or return null.
|
||||
template<class Map, class Key>
|
||||
const typename Map::value_type *find_or_null(const Map& map, const Key& key) {
|
||||
auto it = map.find(key);
|
||||
return (it == map.end()) ? nullptr : &*it;
|
||||
}
|
||||
|
||||
namespace daily {
|
||||
extern bool on;
|
||||
extern int daily_id;
|
||||
|
Reference in New Issue
Block a user