message = message.substr(commandprefix.size());
+ // Local player gets all privileges regardless of
+ // what's set on their account.
+ u64 privs = player->privs;
+ if(g_settings.get("name") == player->getName())
+ privs = PRIV_ALL;
+
ServerCommandContext *ctx = new ServerCommandContext(
str_split(message, L' '),
this,
&m_env,
- player
- );
+ player,
+ privs);
line += processServerCommand(ctx);
send_to_sender = ctx->flags & 1;
{
if(ctx->parms.size() == 1)
{
+ // Show our own real privs, without any adjustments
+ // made for admin status
os<<L"-!- " + privsToString(ctx->player->privs);
return;
}
- if((ctx->player->privs & PRIV_PRIVS) == 0)
+ if((ctx->privs & PRIV_PRIVS) == 0)
{
os<<L"-!- You don't have permission to do that";
return;
return;
}
- if((ctx->player->privs & PRIV_PRIVS) == 0)
+ if((ctx->privs & PRIV_PRIVS) == 0)
{
os<<L"-!- You don't have permission to do that";
return;
return;
}
- if((ctx->player->privs & PRIV_SETTIME) ==0)
+ if((ctx->privs & PRIV_SETTIME) ==0)
{
os<<L"-!- You don't have permission to do that";
return;
void cmd_shutdown(std::wostringstream &os,
ServerCommandContext *ctx)
{
- if((ctx->player->privs & PRIV_SERVER) ==0)
+ if((ctx->privs & PRIV_SERVER) ==0)
{
os<<L"-!- You don't have permission to do that";
return;
void cmd_setting(std::wostringstream &os,
ServerCommandContext *ctx)
{
- if((ctx->player->privs & PRIV_SERVER) ==0)
+ if((ctx->privs & PRIV_SERVER) ==0)
{
os<<L"-!- You don't have permission to do that";
return;
void cmd_teleport(std::wostringstream &os,
ServerCommandContext *ctx)
{
- if((ctx->player->privs & PRIV_TELEPORT) ==0)
+ if((ctx->privs & PRIV_TELEPORT) ==0)
{
os<<L"-!- You don't have permission to do that";
return;
std::wostringstream os(std::ios_base::binary);
ctx->flags = 1; // Default, unless we change it.
- u64 privs = ctx->player->privs;
+ u64 privs = ctx->privs;
if(ctx->parms.size() == 0 || ctx->parms[0] == L"help")
{
Server* server;
ServerEnvironment *env;
Player* player;
+ // Effective privs for the player, which may be different to their
+ // stored ones - e.g. if they are named in the config as an admin.
+ u64 privs;
u32 flags;
ServerCommandContext(
std::vector<std::wstring> parms,
Server* server,
ServerEnvironment *env,
- Player* player)
- : parms(parms), server(server), env(env), player(player)
+ Player* player,
+ u64 privs)
+ : parms(parms), server(server), env(env), player(player), privs(privs)
{
}