diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 0d7059e74..41c16b4bc 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -500,6 +500,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(getDbProp), LUABIND_FUNC(getDbProp64), LUABIND_FUNC(setDbProp), + LUABIND_FUNC(setDbProp64), LUABIND_FUNC(addDbProp), LUABIND_FUNC(delDbProp), LUABIND_FUNC(debugInfo), @@ -2630,6 +2631,36 @@ void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value) debugInfo(toString("setDbProp(): '%s' dbProp Not found", dbProp.c_str())); } +void CLuaIHMRyzom::setDbProp64(const std::string &dbProp, sint64 value) +{ + //H_AUTO(Lua_CLuaIHM_setDbProp) + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer = "SERVER:"; + static const std::string dbLocal = "LOCAL:"; + static const std::string dbLocalR2 = "LOCAL:R2"; + + if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) || + (dbProp.compare(0, dbLocal.size(), dbLocal) == 0) + ) + { + if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0) + { + nlstop; + throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + } + } + + // Write to the DB if found + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false); + + if (node) + node->setValue64(value); + else + debugInfo(toString("setDbProp(): '%s' dbProp Not found", dbProp.c_str())); +} + + void CLuaIHMRyzom::delDbProp(const string &dbProp) { //H_AUTO(Lua_CLuaIHM_setDbProp) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 104fb20e6..b201fae87 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -122,6 +122,7 @@ private: static sint32 getDbProp(const std::string &dbProp); // return 0 if not found. static sint64 getDbProp64(const std::string &dbProp); // return 0 if not found. static void setDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is not created if not present. + static void setDbProp64(const std::string &dbProp, sint64 value); // Nb: the db prop is not created if not present. static void addDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is created if not present. static void delDbProp(const std::string &dbProp);