]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/servercommand.cpp
Place project name and gettext use in config
[dragonfireclient.git] / src / servercommand.cpp
index 5bb4f67f823d437dff5325e5e6aacd02f1a7e80e..333e29084cd85ddec67496005de0b03b353ccd2a 100644 (file)
@@ -1,24 +1,21 @@
 /*
-Minetest-c55
-Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+Part of Minetest-c55
+Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
 Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
 
-
 #include "servercommand.h"
 #include "utility.h"
 
@@ -35,7 +32,8 @@ void cmd_privs(std::wostringstream &os,
        {
                // Show our own real privs, without any adjustments
                // made for admin status
-               os<<L"-!- " + privsToString(ctx->player->privs);
+               os<<L"-!- " + narrow_to_wide(privsToString(
+                               ctx->server->getPlayerAuthPrivs(ctx->player->getName())));
                return;
        }
 
@@ -52,7 +50,7 @@ void cmd_privs(std::wostringstream &os,
                return;
        }
        
-       os<<L"-!- " + privsToString(tp->privs);
+       os<<L"-!- " + narrow_to_wide(privsToString(ctx->server->getPlayerAuthPrivs(tp->getName())));
 }
 
 void cmd_grantrevoke(std::wostringstream &os,
@@ -70,7 +68,7 @@ void cmd_grantrevoke(std::wostringstream &os,
                return;
        }
 
-       u64 newprivs = stringToPrivs(ctx->parms[2]);
+       u64 newprivs = stringToPrivs(wide_to_narrow(ctx->parms[2]));
        if(newprivs == PRIV_INVALID)
        {
                os<<L"-!- Invalid privileges specified";
@@ -83,14 +81,19 @@ void cmd_grantrevoke(std::wostringstream &os,
                os<<L"-!- No such player";
                return;
        }
+       
+       std::string playername = wide_to_narrow(ctx->parms[1]);
+       u64 privs = ctx->server->getPlayerAuthPrivs(playername);
 
        if(ctx->parms[0] == L"grant")
-               tp->privs |= newprivs;
+               privs |= newprivs;
        else
-               tp->privs &= ~newprivs;
+               privs &= ~newprivs;
+       
+       ctx->server->setPlayerAuthPrivs(playername, privs);
        
        os<<L"-!- Privileges change to ";
-       os<<privsToString(tp->privs);
+       os<<narrow_to_wide(privsToString(privs));
 }
 
 void cmd_time(std::wostringstream &os,