示例#1
0
BOOL CMDWhois::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    Player* targ=nullptr;
    BOOL load=false;
    TimeInfo tm;

    if ((!args.size())||(args.size()!=1))
        {
            mobile->Message(MSG_ERROR,"Syntax: whois <player>.");
            return false;
        }

//check to see if the player is online:
    targ=world->GetPlayerManager()->FindPlayer(args[0]);
    if (!targ)
        {
//check to see if the player can be loaded
            targ=world->GetPlayerManager()->LoadPlayer(args[0]);
            load=true;
        }
//check to see if the load succeeded.
    if (!targ)
        {
            mobile->Message(MSG_ERROR,"Couldn't find the specified player.");
            return false;
        }

//check to see if a player is trying to retrieve info on a god
    if ((targ->HasAccess(RANK_GOD))&&(!mobile->HasAccess(RANK_GOD)))
        {
            mobile->Message(MSG_ERROR,"You can't whois the gods.");
//delete the pointer if it was allocated by load
            if (load)
                {
                    delete targ;
                }
            return false;
        }

    tm.Calculate(targ->GetOnlineTime());
    mobile->Message(MSG_LIST,Capitalize(targ->GetName()+" "+targ->GetTitle()));
    mobile->Message(MSG_LIST,Repeat("-",80));
    mobile->Message(MSG_LIST,Capitalize(targ->GetName())+" has spent "+tm.ToString()+" online.");
    mobile->Message(MSG_LIST,Repeat("-",80));
    if (load)
        {
            delete targ;
        }

    return true;
}
示例#2
0
文件: com_gen.cpp 项目: renokun/Aspen
BOOL CMDWho::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    std::list<Player*>* players = nullptr;
    std::list <Player*>::iterator it, itEnd;
    std::stringstream st;

    mobile->Write(Center(Capitalize(MUD_NAME),80)+"\n");
    mobile->Write(Repeat("-",80));

    players = world->GetPlayerManager()->GetPlayers();
    itEnd=players->end();
    for (it = players->begin(); it != itEnd; ++it)
        {
            if ((*it)->HasAccess(RANK_GOD))
                {
                    st << C_BLUE << "[ADMIN] " << C_RESET;
                }
            st << Capitalize((*it)->GetName()) << " " << (*it)->GetTitle();
            mobile->Message(MSG_LIST, st.str());
            st.str("");
        }
    mobile->Write(Repeat("-",80));
    st << MUD_NAME << " currently has " << players->size() << (players->size()==1?" user ":"******") << "online.\n";
    mobile->Write(st.str());
    return true;
}
示例#3
0
BOOL CMDMkwiz::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* target = nullptr;

    if (!args.size())
    {
        mobile->Message(MSG_ERROR,"You must specify the person that you would like to make a wizard.\n");
        return false;
    }

    target=manager->FindPlayer(args[0]);
    if (target==mobile)
    {
        mobile->Message(MSG_ERROR,"You may not make yourself a wizard.");
        return false;
    }
    if (target==nullptr)
    {
        mobile->Message(MSG_ERROR,"That person couldn't be found.");
        return false;
    }
    if (BitIsSet(target->GetRank(),RANK_GOD))
    {
        mobile->Message(MSG_ERROR,"That person is already a wizard.");
        return false;
    }

    target->SetRank(BitSet(mobile->GetRank(), RANK_PLAYTESTER|RANK_NEWBIEHELPER|RANK_BUILDER|RANK_ADMIN|RANK_GOD));
    target->Message(MSG_INFO,"You suddenly feel more wizardly.");
    mobile->Message(MSG_INFO, Capitalize(target->GetName())+" has been made a wizard.");
    return true;
}
示例#4
0
BOOL CMDMkbuilder::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* target = nullptr;

    if (!args.size())
    {
        mobile->Message(MSG_ERROR,"You must specify the person that you would like to make a builder.\n");
        return false;
    }

    target=manager->FindPlayer(args[0]);
    if (target==nullptr)
    {
        mobile->Message(MSG_ERROR,"That person couldn't be found.");
        return false;
    }
    if (mobile == target)
    {
        mobile->Message(MSG_INFO, "You may not make yourself a builder.");
        return false;
    }
    if (BitIsSet(target->GetRank(),RANK_BUILDER))
    {
        mobile->Message(MSG_ERROR,"That person is already a builder.");
        return false;
    }

    target->SetRank(BitSet(mobile->GetRank(),RANK_BUILDER));
    target->Message(MSG_INFO,"You were made a builder.");
    mobile->Message(MSG_INFO, Capitalize(target->GetName())+" was made a builder.");
    return true;
}
示例#5
0
BOOL CMDDisconnect::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* target = nullptr;

    if (!args.size())
    {
        mobile->Message(MSG_ERROR, "Syntax: disconnect <player>");
        return false;
    }

    target=manager->FindPlayer(args[0]);
    if (!target)
    {
        mobile->Message(MSG_ERROR, "I could not find that player.");
        return false;
    }
    if (mobile == target)
    {
        mobile->Message(MSG_ERROR, "If you really want to disconnect yourself, you could just use quit.");
        return false;
    }

    if ((BitIsSet(target->GetRank(), RANK_GOD)) || (BitIsSet(target->GetRank(), RANK_ADMIN)))
    {
        mobile->Message(MSG_ERROR, "You can't disconnect that person.");
        return false;
    }

    target->GetSocket()->Kill();
    return true;
}
示例#6
0
BOOL CMDUnsilence::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* targ = nullptr;

    if (!args.size())
    {
        mobile->Message(MSG_ERROR, "Syntax: unsilence <player>");
        return false;
    }

    targ = manager->FindPlayer(args[0]);
    if (!targ)
    {
        mobile->Message(MSG_ERROR, "Could not find the specified player.");
        return false;
    }
    if (!BitIsSet(targ->GetPflag(), PF_SILENCE))
    {
        mobile->Message(MSG_INFO, "That player is not silenced.");
        return false;
    }

    targ->SetPflag(BitClear(mobile->GetPflag(), PF_SILENCE));
    mobile->Message(MSG_INFO, Capitalize(targ->GetName())+" has been unsilenced.");
    world->WriteLog(Capitalize(targ->GetName())+" was unsilenced by "+Capitalize(mobile->GetName())+".");
    targ->Message(MSG_INFO, "You were unsilenced by "+Capitalize(mobile->GetName())+".");
    return true;
}
示例#7
0
BOOL CMDEcho::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();

    if (!args.size())
    {
        mobile->Message(MSG_ERROR, "Syntax: echo <message>");
        return false;
    }

    std::string msg = Explode(args);
    std::list<Player*>* players = manager->GetPlayers();
    for (auto it: *players)
    {
        it->Message(MSG_INFO, msg);
    }

    return true;
}
示例#8
0
BOOL CMDWho::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    std::list<Player*> *players;
    std::stringstream st;

    st << Center(Capitalize(MUD_NAME), 80) << std::endl;
    st << Repeat("-", 80);

    players = world->GetPlayerManager()->GetPlayers();
    for (auto it: *players)
        {
            if (it->HasAccess(RANK_GOD))
                {
                    st << C_BLUE << "[ADMIN] " << C_RESET;
                }
            st << Capitalize(it->GetName()) << " " << it->GetTitle();
        }
    st << Repeat("-", 80);
    st << MUD_NAME << " currently has " << players->size() << (players->size()==1?" user ":"******") << "online.\n";
    mobile->Message(MSG_LIST, st.str());

    return true;
}
示例#9
0
BOOL CMDForce::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* target = nullptr;
    std::string command;

    if (!args.size() || args.size() < 2)
    {
        mobile->Message(MSG_ERROR, "syntax: force <player> <command> [args]");
        return false;
    }

    target=manager->FindPlayer(args[0]);
    if (target == mobile)
    {
        mobile->Message(MSG_ERROR, "Why would you need to force yourself to do that?");
        return false;
    }
    if (!target)
    {
        mobile->Message(MSG_ERROR, "That player was not found.");
        return false;
    }
    if (BitIsSet(target->GetRank(),RANK_GOD) || (BitIsSet(mobile->GetRank(), RANK_ADMIN)))
    {
        mobile->Message(MSG_ERROR, "You probably shouldn't try to do that...");
        return false;
    }

    args.erase(args.begin());
    command = Explode(args);
    target->GetSocket()->AddCommand(command);
    mobile->Message(MSG_INFO, "You force "+Capitalize(target->GetName())+" to execute: "+command);
    return true;
}
示例#10
0
BOOL CMDSilence::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    PlayerManager* manager = world->GetPlayerManager();
    Player* targ = nullptr;

    if (!args.size())
    {
        mobile->Message(MSG_ERROR, "Syntax: silence <player>");
        return false;
    }

    targ = manager->FindPlayer(args[0]);
    if (!targ)
    {
        mobile->Message(MSG_ERROR, "Could not find the specified player.");
        return false;
    }
    if (targ->HasAccess(RANK_ADMIN) || targ->HasAccess(RANK_GOD))
    {
        mobile->Message(MSG_ERROR, "You should not be silencing staff.");
        return false;
    }

    if (BitIsSet(mobile->GetPflag(), PF_SILENCE))
    {
        mobile->Message(MSG_ERROR, "That player has already been silenced.");
        return false;
    }

    targ->SetPflag(BitSet(targ->GetPflag(), PF_SILENCE));
    mobile->Message(MSG_INFO, Capitalize(targ->GetName())+" was silenced.");
    world->WriteLog(Capitalize(targ->GetName())+" was silenced by "+Capitalize(mobile->GetName())+".");
    targ->Message(MSG_ERROR, "You were silenced by "+Capitalize(mobile->GetName())+".");
    return true;
}