Skip to content

Commit 9a404e4

Browse files
authored
Merge pull request #19 from Pika-Software/dev
Fix wrong lines in errors + crash on changing `moonloader_detour_getinfo`
2 parents a7e517c + 844e0cd commit 9a404e4

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.3
1+
2.1.4

source/compiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ void yue_openlibs(void* state);
1515

1616
using namespace MoonLoader;
1717

18-
std::unordered_map<int, int> ParseYueLines(std::string_view code) {
18+
std::map<int, int> ParseYueLines(std::string_view code) {
1919
static std::regex YUE_LINE_REGEX("--\\s*(\\d*)\\s*$", std::regex_constants::optimize);
2020

21-
std::unordered_map<int, int> line_map;
21+
std::map<int, int> line_map;
2222
Utils::Split(code, [&](std::string_view line, size_t num) {
2323
std::cmatch match;
2424
if (std::regex_search(line.data(), line.data() + line.size(), match, YUE_LINE_REGEX)) {

source/compiler.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <unordered_map>
77
#include <unordered_set>
8+
#include <map>
89
#include <string>
910
#include <string_view>
1011
#include <optional>
@@ -35,7 +36,7 @@ namespace MoonLoader {
3536
size_t update_date = 0;
3637
Type type;
3738

38-
std::unordered_map<int, int> line_map;
39+
std::map<int, int> line_map;
3940
};
4041

4142
private:

source/core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ void Core::Initialize(GarrysMod::Lua::ILuaInterface* LUA) {
280280

281281
cvar = InterfacePointers::Cvar();
282282
if (cvar == nullptr) throw std::runtime_error("failed to get ICvar interface");
283+
284+
g_pCVar = cvar;
283285
for (ConVar* convar : moonloader_convars)
284286
cvar->RegisterConCommand(convar);
285287

source/utils.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <optional>
1414
#include <memory>
1515
#include <unordered_map>
16+
#include <map>
1617

1718
#if IS_SERVERSIDE
1819
#include <GarrysMod/FactoryLoader.hpp>
@@ -219,7 +220,7 @@ namespace MoonLoader::Utils {
219220
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
220221
}
221222

222-
inline std::optional<int> FindClosestLine(const std::unordered_map<int, int>& lines, int line) {
223+
inline std::optional<int> FindClosestLine(const std::map<int, int>& lines, int line) {
223224
int closest = -1;
224225
for (auto& [key, value] : lines) {
225226
if (key > line) break;

0 commit comments

Comments
 (0)