VERSIÓ 1.5.6:
- [FIX] Acallats warnings en findloader de lua - [FIX] Acallats alguns 'Illegal music handle' innecesaris - [NEW] Ara detecta que no s'ha conectat al debuger de vscode i trau els missatges per consola com abans - [NEW] Missatges de error més clars - [NEW] Ara també trau els missatges de debug per consola en la versió release
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#if defined(DEBUG) && defined(__linux__)
|
||||
|
||||
#include "lua.debug.h"
|
||||
#include "lua.utils.h"
|
||||
|
||||
#include "external/lua/lua.hpp"
|
||||
#include "mini/win/win.h"
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace mini
|
||||
int g_pauseLine = 0;
|
||||
bool function_has_breakpoints = false;
|
||||
std::stack<bool> funBreakStack;
|
||||
bool debug_enabled = true;
|
||||
bool debug_enabled = false;
|
||||
|
||||
enum StepMode {
|
||||
STEP_NONE,
|
||||
@@ -77,52 +78,6 @@ namespace mini
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
std::string pathToChunk(const std::string& path) {
|
||||
std::filesystem::path p(path);
|
||||
|
||||
// 1. Normalizar la ruta
|
||||
p = p.lexically_normal();
|
||||
|
||||
// 2. Buscar el directorio "data"
|
||||
auto it = std::find(p.begin(), p.end(), "data");
|
||||
if (it == p.end())
|
||||
return ""; // no es un script Lua válido
|
||||
|
||||
// 3. Construir la parte relativa después de "data"
|
||||
std::filesystem::path rel;
|
||||
for (++it; it != p.end(); ++it)
|
||||
rel /= *it;
|
||||
|
||||
// 4. Quitar ".lua"
|
||||
std::string s = rel.string();
|
||||
if (s.ends_with(".lua"))
|
||||
s = s.substr(0, s.size() - 4);
|
||||
|
||||
// 5. Convertir "/" → "."
|
||||
for (char& c : s)
|
||||
if (c == '/')
|
||||
c = '.';
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string chunkToPath(const std::string& chunk) {
|
||||
// 1. Convertir "ia.test" → "ia/test"
|
||||
std::string rel;
|
||||
rel.reserve(chunk.size() + 10);
|
||||
|
||||
for (char c : chunk)
|
||||
rel += (c == '.' ? '/' : c);
|
||||
|
||||
// 2. Añadir prefijo y sufijo
|
||||
rel = "data/" + rel + ".lua";
|
||||
|
||||
// 3. Convertir a ruta absoluta
|
||||
std::filesystem::path abs = std::filesystem::current_path() / rel;
|
||||
|
||||
return abs.lexically_normal().string();
|
||||
}
|
||||
|
||||
int getStackDepth(lua_State* L) {
|
||||
lua_Debug ar;
|
||||
int depth = 0;
|
||||
@@ -880,8 +835,11 @@ namespace mini
|
||||
|
||||
void processDebugCommand(lua_State* L, const std::string& line) {
|
||||
//printf("COMANDO PROCESADO: %s\n", line.c_str());
|
||||
if (!line.starts_with("@@DEBUGCMD@@"))
|
||||
if (!line.starts_with("@@DEBUGCMD@@")) {
|
||||
disable(L);
|
||||
return;
|
||||
}
|
||||
enable(L);
|
||||
|
||||
json j = json::parse(line.substr(12));
|
||||
|
||||
@@ -1348,7 +1306,7 @@ namespace mini
|
||||
}
|
||||
|
||||
void init(lua_State* L) {
|
||||
lua_sethook(L, luaHook, LUA_MASKCALL | LUA_MASKRET, 0);
|
||||
//lua_sethook(L, luaHook, LUA_MASKCALL | LUA_MASKRET, 0);
|
||||
}
|
||||
|
||||
void kill_thread() {
|
||||
@@ -1366,6 +1324,19 @@ namespace mini
|
||||
}
|
||||
}
|
||||
|
||||
void enable(lua_State* L) {
|
||||
if (debug_enabled) return;
|
||||
debug_enabled = true;
|
||||
lua_sethook(L, luaHook, LUA_MASKCALL | LUA_MASKRET, 0);
|
||||
}
|
||||
|
||||
void disable(lua_State* L) {
|
||||
if (!debug_enabled) return;
|
||||
debug_enabled = false;
|
||||
lua_sethook(L, NULL,0, 0);
|
||||
}
|
||||
|
||||
bool is_enabled() { return debug_enabled; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user