mirror of
https://github.com/Relintai/tile_map_backport.git
synced 2024-11-05 10:11:16 +01:00
Fix array not having < operator in 3.x.
This commit is contained in:
parent
fdfdf6953e
commit
0f236ed797
27
array_lt_op.h
Normal file
27
array_lt_op.h
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef ARRAY_LT_OP_H
|
||||
#define ARRAY_LT_OP_H
|
||||
|
||||
#include "core/array.h"
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
bool operator<(const Array &p_array_a, const Array &p_array_b) {
|
||||
int a_len = p_array_a.size();
|
||||
int b_len = p_array_b.size();
|
||||
|
||||
int min_cmp = MIN(a_len, b_len);
|
||||
|
||||
for (int i = 0; i < min_cmp; i++) {
|
||||
if (p_array_a.operator[](i) < p_array_b[i]) {
|
||||
return true;
|
||||
} else if (p_array_b[i] < p_array_a.operator[](i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return a_len < b_len;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -31,6 +31,7 @@
|
||||
#ifndef RTILE_SET_H
|
||||
#define RTILE_SET_H
|
||||
|
||||
#include "array_lt_op.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/object.h"
|
||||
#include "core/vector.h"
|
||||
|
Loading…
Reference in New Issue
Block a user