//#include "main.h" // for g_settings
#include <sstream>
#include "strfnd.h"
-#include "debug.h"
+#include "log.h"
+
+std::set<std::string> privsToSet(u64 privs)
+{
+ std::set<std::string> s;
+ if(privs & PRIV_INTERACT)
+ s.insert("interact");
+ if(privs & PRIV_TELEPORT)
+ s.insert("teleport");
+ if(privs & PRIV_SETTIME)
+ s.insert("settime");
+ if(privs & PRIV_PRIVS)
+ s.insert("privs");
+ if(privs & PRIV_SHOUT)
+ s.insert("shout");
+ if(privs & PRIV_BAN)
+ s.insert("ban");
+ if(privs & PRIV_GIVE)
+ s.insert("give");
+ if(privs & PRIV_PASSWORD)
+ s.insert("password");
+ return s;
+}
// Convert a privileges value into a human-readable string,
// with each component separated by a comma.
std::string privsToString(u64 privs)
{
std::ostringstream os(std::ios_base::binary);
- if(privs & PRIV_BUILD)
- os<<"build,";
+ if(privs & PRIV_INTERACT)
+ os<<"interact,";
if(privs & PRIV_TELEPORT)
os<<"teleport,";
if(privs & PRIV_SETTIME)
os<<"privs,";
if(privs & PRIV_SHOUT)
os<<"shout,";
+ if(privs & PRIV_BAN)
+ os<<"ban,";
+ if(privs & PRIV_GIVE)
+ os<<"give,";
+ if(privs & PRIV_PASSWORD)
+ os<<"password,";
if(os.tellp())
{
// Drop the trailing comma. (Why on earth can't
{
std::string s = trim(f.next(","));
if(s == "build")
- privs |= PRIV_BUILD;
+ privs |= PRIV_INTERACT;
+ else if(s == "interact")
+ privs |= PRIV_INTERACT;
else if(s == "teleport")
privs |= PRIV_TELEPORT;
else if(s == "settime")
privs |= PRIV_PRIVS;
else if(s == "shout")
privs |= PRIV_SHOUT;
+ else if(s == "ban")
+ privs |= PRIV_BAN;
+ else if(s == "give")
+ privs |= PRIV_GIVE;
+ else if(s == "password")
+ privs |= PRIV_PASSWORD;
else
return PRIV_INVALID;
}
}
catch(SerializationError &e)
{
- dstream<<"WARNING: AuthManager: creating "
+ infostream<<"WARNING: AuthManager: creating "
<<m_authfilepath<<std::endl;
}
}
{
JMutexAutoLock lock(m_mutex);
- dstream<<"AuthManager: loading from "<<m_authfilepath<<std::endl;
+ infostream<<"AuthManager: loading from "<<m_authfilepath<<std::endl;
std::ifstream is(m_authfilepath.c_str(), std::ios::binary);
if(is.good() == false)
{
- dstream<<"AuthManager: failed loading from "<<m_authfilepath<<std::endl;
+ infostream<<"AuthManager: failed loading from "<<m_authfilepath<<std::endl;
throw SerializationError("AuthManager::load(): Couldn't open file");
}
{
JMutexAutoLock lock(m_mutex);
- dstream<<"AuthManager: saving to "<<m_authfilepath<<std::endl;
+ infostream<<"AuthManager: saving to "<<m_authfilepath<<std::endl;
std::ofstream os(m_authfilepath.c_str(), std::ios::binary);
if(os.good() == false)
{
- dstream<<"AuthManager: failed saving to "<<m_authfilepath<<std::endl;
+ infostream<<"AuthManager: failed saving to "<<m_authfilepath<<std::endl;
throw SerializationError("AuthManager::save(): Couldn't open file");
}