Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 4 years ago
commit ae876e481a

@ -379,6 +379,10 @@ namespace NLGUI
TSmallScriptCache _SmallScriptCache; TSmallScriptCache _SmallScriptCache;
static const char * _NELSmallScriptTableName; static const char * _NELSmallScriptTableName;
#ifdef _WIN32
HMODULE m_LuaSocket;
#endif
private: private:
// this object isn't intended to be copied // this object isn't intended to be copied
CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); } CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); }

@ -227,6 +227,45 @@ namespace NLGUI
luaopen_debug (_State); luaopen_debug (_State);
#endif #endif
#ifdef _WIN32
// Lua socket library for MobDebug, optional
if (NLMISC::CFile::fileExists("socket\\core.dll"))
{
// Load socket\core.dll dynamically
m_LuaSocket = LoadLibraryW(L"socket\\core.dll");
if (!m_LuaSocket)
{
nlwarning("Lua socket library found, but failed to load");
}
else
{
void *luaopen_socket_core = (void *)GetProcAddress(m_LuaSocket, "luaopen_socket_core");
if (!luaopen_socket_core)
{
nlwarning("Lua socket library loaded, but `luaopen_socket_core` not found");
FreeLibrary(m_LuaSocket);
m_LuaSocket = NULL;
}
else
{
// preload['socket.core'] = luaopen_socket_core
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
lua_getglobal(_State, "package");
lua_getfield(_State, -1, "preload");
lua_pushcfunction(_State, (lua_CFunction)luaopen_socket_core);
lua_setfield(_State, -2, "socket.core");
lua_pop(_State, 2);
nlinfo("Lua socket library preloaded");
#endif
}
}
}
else
{
m_LuaSocket = NULL;
}
#endif
// open are buggy???? // open are buggy????
clear(); clear();
} }
@ -313,6 +352,14 @@ namespace NLGUI
// Clear Small Script Cache // Clear Small Script Cache
_SmallScriptPool= 0; _SmallScriptPool= 0;
_SmallScriptCache.clear(); _SmallScriptCache.clear();
#ifdef _WIN32
if (m_LuaSocket)
{
FreeLibrary(m_LuaSocket);
m_LuaSocket = NULL;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -464,7 +511,23 @@ namespace NLGUI
// execute the script text, with dbgSrc==filename (use @ for lua internal purpose) // execute the script text, with dbgSrc==filename (use @ for lua internal purpose)
executeScriptInternal(script, string("@") + CFile::getFilename(pathName)); #ifdef _WIN32
// Paths need to be correct for debugging to work
std::string pathNameStandardized = pathName;
if (pathNameStandardized.size() > 1)
{
if (pathNameStandardized[1] == ':' && pathNameStandardized[0] >= 'a' && pathNameStandardized[0] <= 'z')
pathNameStandardized[0] -= 'a' - 'A';
for (ptrdiff_t i = 0; i < (ptrdiff_t)pathNameStandardized.size(); ++i)
{
if (pathNameStandardized[i] == '/')
pathNameStandardized[i] = '\\';
}
}
#else
const std::string &pathNameStandardized = pathName;
#endif
executeScriptInternal(script, string("@") + pathNameStandardized);
return true; return true;
} }

Loading…
Cancel
Save