forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemporary_enchant.cpp
51 lines (40 loc) · 1.18 KB
/
temporary_enchant.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "config.hpp"
#include "temporary_enchant.hpp"
#include "generated/temporary_enchant.inc"
#if SC_USE_PTR == 1
#include "generated/temporary_enchant_ptr.inc"
#endif
const temporary_enchant_entry_t& temporary_enchant_entry_t::find( util::string_view name, unsigned rank, bool ptr )
{
auto __data = data( ptr );
auto span = range::equal_range( __data, name, {}, &temporary_enchant_entry_t::tokenized_name );
if ( span.first == span.second )
{
return nil();
}
auto it = std::find_if( span.first, span.second, [rank]( const temporary_enchant_entry_t& entry ) {
return entry.rank == rank;
} );
if ( it == span.second )
{
return nil();
}
return *it;
}
const temporary_enchant_entry_t& temporary_enchant_entry_t::find_by_enchant_id(
unsigned id, bool ptr )
{
auto __data = data( ptr );
auto it = range::find_if( __data, [id]( const temporary_enchant_entry_t& e ) {
return id == e.enchant_id;
} );
if ( it == __data.end() )
{
return nil();
}
return *it;
}
util::span<const temporary_enchant_entry_t> temporary_enchant_entry_t::data( bool ptr )
{
return SC_DBC_GET_DATA( __temporary_enchant_data, __ptr_temporary_enchant_data, ptr );
}