File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,26 +24,7 @@ namespace REL
2424 return singleton;
2525 }
2626
27- [[nodiscard]] std::size_t id2offset (std::uint64_t a_id) const
28- {
29- if (_id2offset.empty ()) {
30- stl::report_and_fail (" data is empty" sv);
31- }
32-
33- const mapping_t elem{ a_id, 0 };
34- const auto it = std::lower_bound (
35- _id2offset.begin (),
36- _id2offset.end (),
37- elem,
38- [](auto && a_lhs, auto && a_rhs) {
39- return a_lhs.id < a_rhs.id ;
40- });
41- if (it == _id2offset.end ()) {
42- stl::report_and_fail (" id not found" sv);
43- }
44-
45- return static_cast <std::size_t >(it->offset );
46- }
27+ [[nodiscard]] std::size_t id2offset (std::uint64_t a_id) const ;
4728
4829 protected:
4930 friend class Offset2ID ;
Original file line number Diff line number Diff line change 11#include " REL/IDDB.h"
2+ #include " REL/Module.h"
23#include " REL/Version.h"
34
45#include " REX/W32/BCRYPT.h"
@@ -105,4 +106,27 @@ namespace REL
105106 *reinterpret_cast <const std::uint64_t *>(_mmap.data ())
106107 };
107108 }
109+
110+ std::size_t IDDB::id2offset (std::uint64_t a_id) const
111+ {
112+ if (_id2offset.empty ()) {
113+ stl::report_and_fail (" data is empty" sv);
114+ }
115+
116+ const mapping_t elem{ a_id, 0 };
117+ const auto it = std::lower_bound (
118+ _id2offset.begin (),
119+ _id2offset.end (),
120+ elem,
121+ [](auto && a_lhs, auto && a_rhs) {
122+ return a_lhs.id < a_rhs.id ;
123+ });
124+ if (it == _id2offset.end ()) {
125+ const auto version = Module::get ().version ();
126+ const auto str = std::format (" id {} not found!\n game version: {}" sv, a_id, version.string ());
127+ stl::report_and_fail (str);
128+ }
129+
130+ return static_cast <std::size_t >(it->offset );
131+ }
108132}
You can’t perform that action at this time.
0 commit comments